@evomap/evolver 1.89.3 → 1.89.4
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/.cursor/BUGBOT.md +182 -0
- package/.env.example +68 -0
- package/.git-commit-guard-token +1 -0
- package/.github/CODEOWNERS +63 -0
- package/.github/ISSUE_TEMPLATE/good_first_issue.md +23 -0
- package/.github/pull_request_template.md +45 -0
- package/.github/workflows/test.yml +75 -0
- package/CHANGELOG.md +1237 -0
- package/README.md +86 -528
- package/README.public.md +569 -0
- package/SECURITY.md +108 -0
- package/assets/gep/events.jsonl +3 -0
- package/examples/atp-consumer-quickstart.md +100 -0
- package/examples/hello-world.md +38 -0
- package/index.js +30 -1
- package/package.json +6 -17
- package/proxy-package.json +39 -0
- package/public.manifest.json +143 -0
- package/src/config.js +23 -0
- package/src/evolve/guards.js +721 -1
- package/src/evolve/pipeline/collect.js +1283 -1
- package/src/evolve/pipeline/dispatch.js +421 -1
- package/src/evolve/pipeline/enrich.js +440 -1
- package/src/evolve/pipeline/hub.js +319 -1
- package/src/evolve/pipeline/select.js +274 -1
- package/src/evolve/pipeline/signals.js +206 -1
- package/src/evolve/utils.js +264 -1
- package/src/evolve.js +350 -1
- package/src/experiment/agentRunner.js +229 -0
- package/src/experiment/cli.js +159 -0
- package/src/experiment/comparison.js +233 -0
- package/src/experiment/metrics.js +75 -0
- package/src/forceUpdate.js +147 -59
- package/src/gep/a2aProtocol.js +4455 -1
- package/src/gep/antiAbuseTelemetry.js +233 -0
- package/src/gep/autoDistillConv.js +205 -1
- package/src/gep/autoDistillLlm.js +315 -1
- package/src/gep/candidateEval.js +92 -1
- package/src/gep/candidates.js +198 -1
- package/src/gep/contentHash.js +30 -1
- package/src/gep/conversationSniffer.js +266 -1
- package/src/gep/crypto.js +89 -1
- package/src/gep/curriculum.js +163 -1
- package/src/gep/deviceId.js +218 -1
- package/src/gep/envFingerprint.js +118 -1
- package/src/gep/epigenetics.js +31 -1
- package/src/gep/execBridge.js +711 -1
- package/src/gep/explore.js +289 -1
- package/src/gep/hash.js +15 -1
- package/src/gep/hubFetch.js +359 -1
- package/src/gep/hubReview.js +207 -1
- package/src/gep/hubSearch.js +526 -1
- package/src/gep/hubVerify.js +306 -1
- package/src/gep/learningSignals.js +89 -1
- package/src/gep/memoryGraph.js +1374 -1
- package/src/gep/memoryGraphAdapter.js +203 -1
- package/src/gep/mutation.js +203 -1
- package/src/gep/narrativeMemory.js +108 -1
- package/src/gep/openPRRegistry.js +205 -1
- package/src/gep/personality.js +423 -1
- package/src/gep/policyCheck.js +599 -1
- package/src/gep/prompt.js +836 -1
- package/src/gep/recallInject.js +409 -1
- package/src/gep/recallVerifier.js +318 -1
- package/src/gep/reflection.js +177 -1
- package/src/gep/sanitize.js +9 -0
- package/src/gep/selector.js +602 -1
- package/src/gep/skillDistiller.js +1294 -1
- package/src/gep/solidify.js +1699 -1
- package/src/gep/strategy.js +136 -1
- package/src/gep/tokenSavings.js +88 -1
- package/src/gep/validator/sandboxExecutor.js +29 -1
- package/src/gep/workspaceKeychain.js +174 -1
- package/src/proxy/extensions/traceControl.js +99 -1
- package/src/proxy/index.js +10 -1
- package/src/proxy/inject.js +52 -1
- package/src/proxy/lifecycle/manager.js +19 -0
- package/src/proxy/mailbox/store.js +2 -1
- package/src/proxy/router/messages_route.js +5 -2
- package/src/proxy/trace/extractor.js +646 -1
- package/src/proxy/trace/usage.js +105 -1
- package/CONTRIBUTING.md +0 -19
- package/assets/cover.png +0 -0
- package/scripts/a2a_export.js +0 -63
- package/scripts/a2a_ingest.js +0 -79
- package/scripts/a2a_promote.js +0 -118
- package/scripts/analyze_by_skill.js +0 -121
- package/scripts/build_binaries.js +0 -479
- package/scripts/check-changelog.js +0 -166
- package/scripts/extract_log.js +0 -85
- package/scripts/generate_history.js +0 -75
- package/scripts/gep_append_event.js +0 -96
- package/scripts/gep_personality_report.js +0 -234
- package/scripts/human_report.js +0 -147
- package/scripts/recall-verify-report.js +0 -234
- package/scripts/recover_loop.js +0 -61
- package/scripts/refresh_stars_badge.js +0 -168
- package/scripts/seed-merchants.js +0 -91
- package/scripts/suggest_version.js +0 -89
- package/scripts/validate-modules.js +0 -38
- package/scripts/validate-suite.js +0 -78
- package/skills/index.json +0 -14
- /package/assets/gep/{genes.seed.json → genes.json} +0 -0
- /package/{skills → bundled-skills}/_meta/SKILL.md +0 -0
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/* eslint-disable no-console */
|
|
3
|
-
//
|
|
4
|
-
// build_binaries.js — produce standalone CLI binaries of evolver via the
|
|
5
|
-
// hardened "obfuscator -> bun bundle -> bun compile" pipeline.
|
|
6
|
-
//
|
|
7
|
-
// Pipeline (decided after empirical testing — see notes at end of this file):
|
|
8
|
-
//
|
|
9
|
-
// 1. bun build ./index.js --target=node --outfile=stage/bundled.js
|
|
10
|
-
// -> resolves all require() into one self-contained file.
|
|
11
|
-
//
|
|
12
|
-
// 2. javascript-obfuscator stage/bundled.js -> stage/bundled.obf.js
|
|
13
|
-
// -> high-strength config: stringArray (rc4) + controlFlowFlattening +
|
|
14
|
-
// deadCodeInjection + identifier hex + splitStrings + numbers-to-expr.
|
|
15
|
-
// -> selfDefending MUST be off: it triggers infinite-loop self-defense
|
|
16
|
-
// when bun later wraps the bundle inside its standalone container.
|
|
17
|
-
// -> renameGlobals MUST be off (otherwise bun's bundle step fails to
|
|
18
|
-
// resolve dynamic require strings — but we already pass a single-file
|
|
19
|
-
// bundle here, so this no longer applies; kept off for safety).
|
|
20
|
-
// -> transformObjectKeys MUST be off (similar reason as above).
|
|
21
|
-
//
|
|
22
|
-
// 3. bun build stage/bundled.obf.js --compile --minify --target=<TARGET>
|
|
23
|
-
// -> embeds bun runtime + bundled+obfuscated JS into a single executable.
|
|
24
|
-
// -> --minify gives a second-pass identifier/whitespace squash on top
|
|
25
|
-
// of the obfuscator output.
|
|
26
|
-
//
|
|
27
|
-
// Targets shipped (decision per AGENTS sync 2026-05-05):
|
|
28
|
-
// bun-darwin-arm64 -> evolver-darwin-arm64
|
|
29
|
-
// bun-darwin-x64 -> evolver-darwin-x64
|
|
30
|
-
// bun-linux-x64 -> evolver-linux-x64
|
|
31
|
-
// bun-linux-arm64 -> evolver-linux-arm64
|
|
32
|
-
// bun-windows-x64 -> evolver-windows-x64.exe
|
|
33
|
-
//
|
|
34
|
-
// Usage:
|
|
35
|
-
// node scripts/build_binaries.js # builds all 4 targets
|
|
36
|
-
// node scripts/build_binaries.js --target=darwin-arm64
|
|
37
|
-
// node scripts/build_binaries.js --skip-obfuscate # bun-only fast path (DEV)
|
|
38
|
-
// node scripts/build_binaries.js --out-dir=dist-binaries
|
|
39
|
-
// node scripts/build_binaries.js --dry-run
|
|
40
|
-
//
|
|
41
|
-
// Outputs:
|
|
42
|
-
// <outDir>/evolver-<platform> binary
|
|
43
|
-
// <outDir>/evolver-<platform>.sha256 hash file (one line)
|
|
44
|
-
// <outDir>/SHA256SUMS.txt combined sha256 manifest
|
|
45
|
-
//
|
|
46
|
-
// Exit codes:
|
|
47
|
-
// 0 success
|
|
48
|
-
// 1 precondition failed (missing tool, version mismatch)
|
|
49
|
-
// 2 build step failed
|
|
50
|
-
// 3 smoke test of produced binary failed
|
|
51
|
-
|
|
52
|
-
'use strict';
|
|
53
|
-
|
|
54
|
-
const fs = require('fs');
|
|
55
|
-
const path = require('path');
|
|
56
|
-
const crypto = require('crypto');
|
|
57
|
-
const { execFileSync, spawnSync } = require('child_process');
|
|
58
|
-
|
|
59
|
-
// ---------- argv ----------
|
|
60
|
-
|
|
61
|
-
const argv = process.argv.slice(2);
|
|
62
|
-
const OPTS = {
|
|
63
|
-
target: null,
|
|
64
|
-
skipObfuscate: false,
|
|
65
|
-
outDir: 'dist-binaries',
|
|
66
|
-
dryRun: false,
|
|
67
|
-
keepStage: false,
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
for (const a of argv) {
|
|
71
|
-
if (a === '--skip-obfuscate') OPTS.skipObfuscate = true;
|
|
72
|
-
else if (a === '--dry-run') OPTS.dryRun = true;
|
|
73
|
-
else if (a === '--keep-stage') OPTS.keepStage = true;
|
|
74
|
-
else if (a.startsWith('--target=')) OPTS.target = a.slice('--target='.length);
|
|
75
|
-
else if (a.startsWith('--out-dir=')) OPTS.outDir = a.slice('--out-dir='.length);
|
|
76
|
-
else if (a === '--help' || a === '-h') {
|
|
77
|
-
console.log(fs.readFileSync(__filename, 'utf8').split('\n').filter(l => l.startsWith('//')).map(l => l.replace(/^\/\/ ?/, '')).slice(0, 50).join('\n'));
|
|
78
|
-
process.exit(0);
|
|
79
|
-
} else {
|
|
80
|
-
console.error(`build_binaries: unknown argument: ${a}`);
|
|
81
|
-
process.exit(1);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// ---------- constants ----------
|
|
86
|
-
|
|
87
|
-
const REPO_ROOT = path.resolve(__dirname, '..');
|
|
88
|
-
const ENTRY = path.join(REPO_ROOT, 'index.js');
|
|
89
|
-
const STAGE_DIR = path.join(REPO_ROOT, '.binary-stage');
|
|
90
|
-
const OUT_DIR = path.resolve(REPO_ROOT, OPTS.outDir);
|
|
91
|
-
|
|
92
|
-
const ALL_TARGETS = [
|
|
93
|
-
{ triple: 'bun-darwin-arm64', name: 'evolver-darwin-arm64' },
|
|
94
|
-
{ triple: 'bun-darwin-x64', name: 'evolver-darwin-x64' },
|
|
95
|
-
{ triple: 'bun-linux-x64', name: 'evolver-linux-x64' },
|
|
96
|
-
{ triple: 'bun-linux-arm64', name: 'evolver-linux-arm64' },
|
|
97
|
-
{ triple: 'bun-windows-x64', name: 'evolver-windows-x64.exe' },
|
|
98
|
-
];
|
|
99
|
-
|
|
100
|
-
const TARGETS = OPTS.target
|
|
101
|
-
? ALL_TARGETS.filter(t => t.name.endsWith(OPTS.target) || t.triple.endsWith(OPTS.target))
|
|
102
|
-
: ALL_TARGETS;
|
|
103
|
-
|
|
104
|
-
if (TARGETS.length === 0) {
|
|
105
|
-
console.error(`build_binaries: target "${OPTS.target}" matched no known triple. Known: ${ALL_TARGETS.map(t => t.triple).join(', ')}`);
|
|
106
|
-
process.exit(1);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// ---------- helpers ----------
|
|
110
|
-
|
|
111
|
-
function step(label) {
|
|
112
|
-
console.log(`\n>> ${label}`);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function run(cmd, args, opts = {}) {
|
|
116
|
-
if (OPTS.dryRun) {
|
|
117
|
-
console.log(` [dry-run] ${cmd} ${args.join(' ')}`);
|
|
118
|
-
return { status: 0, stdout: '', stderr: '' };
|
|
119
|
-
}
|
|
120
|
-
const r = spawnSync(cmd, args, { stdio: 'inherit', ...opts });
|
|
121
|
-
if (r.status !== 0) {
|
|
122
|
-
console.error(` command failed (exit ${r.status}): ${cmd} ${args.join(' ')}`);
|
|
123
|
-
process.exit(2);
|
|
124
|
-
}
|
|
125
|
-
return r;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function runCapture(cmd, args, opts = {}) {
|
|
129
|
-
// Preflight version checks must always run (even in dry-run mode); use this
|
|
130
|
-
// helper only for read-only commands.
|
|
131
|
-
return execFileSync(cmd, args, { encoding: 'utf8', ...opts });
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function ensureDir(d) {
|
|
135
|
-
if (!fs.existsSync(d)) fs.mkdirSync(d, { recursive: true });
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function rmDir(d) {
|
|
139
|
-
if (fs.existsSync(d)) fs.rmSync(d, { recursive: true, force: true });
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function sha256(filePath) {
|
|
143
|
-
const buf = fs.readFileSync(filePath);
|
|
144
|
-
return crypto.createHash('sha256').update(buf).digest('hex');
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// ---------- preflight ----------
|
|
148
|
-
|
|
149
|
-
step('Preflight');
|
|
150
|
-
|
|
151
|
-
if (!fs.existsSync(ENTRY)) {
|
|
152
|
-
console.error(` ERROR: entry not found: ${ENTRY}`);
|
|
153
|
-
process.exit(1);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
try {
|
|
157
|
-
const v = runCapture('bun', ['--version']).trim();
|
|
158
|
-
console.log(` bun: ${v}`);
|
|
159
|
-
// Pin a sane minimum. As of writing pipeline tested on 1.3.13.
|
|
160
|
-
const [maj, min] = v.split('.').map(Number);
|
|
161
|
-
if (maj < 1 || (maj === 1 && min < 3)) {
|
|
162
|
-
console.error(` ERROR: bun >= 1.3 required; found ${v}`);
|
|
163
|
-
process.exit(1);
|
|
164
|
-
}
|
|
165
|
-
} catch (e) {
|
|
166
|
-
console.error(' ERROR: `bun` not found in PATH. Install from https://bun.com');
|
|
167
|
-
process.exit(1);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (!OPTS.skipObfuscate) {
|
|
171
|
-
try {
|
|
172
|
-
require.resolve('javascript-obfuscator', { paths: [REPO_ROOT] });
|
|
173
|
-
console.log(' javascript-obfuscator: present');
|
|
174
|
-
} catch {
|
|
175
|
-
console.error(' ERROR: javascript-obfuscator not installed. Run `npm install` in repo root first.');
|
|
176
|
-
process.exit(1);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const releaseVersion = process.env.RELEASE_VERSION
|
|
181
|
-
|| JSON.parse(fs.readFileSync(path.join(REPO_ROOT, 'package.json'), 'utf8')).version;
|
|
182
|
-
console.log(` release version: ${releaseVersion}`);
|
|
183
|
-
console.log(` targets: ${TARGETS.map(t => t.name).join(', ')}`);
|
|
184
|
-
console.log(` out dir: ${OUT_DIR}`);
|
|
185
|
-
if (OPTS.skipObfuscate) console.log(' WARN: --skip-obfuscate => DEV-grade binary, do NOT distribute');
|
|
186
|
-
if (OPTS.dryRun) console.log(' mode: DRY RUN (no files will change)');
|
|
187
|
-
|
|
188
|
-
// ---------- stage 1: bun bundle ----------
|
|
189
|
-
|
|
190
|
-
step('Stage 1 — bun bundle (resolve require tree to one file)');
|
|
191
|
-
|
|
192
|
-
ensureDir(STAGE_DIR);
|
|
193
|
-
const BUNDLED_JS = path.join(STAGE_DIR, 'bundled.js');
|
|
194
|
-
|
|
195
|
-
// `--external '@napi-rs/keyring'`: keyring is an optional dep loaded via
|
|
196
|
-
// dynamic require() in workspace-id; bun otherwise tries to bundle the
|
|
197
|
-
// platform-specific `.node` file as a second output asset, which makes
|
|
198
|
-
// `bun build … --outfile=…` fail with "cannot write multiple output files
|
|
199
|
-
// without an output directory". Treating it as external preserves the
|
|
200
|
-
// existing optional-fallback behaviour (require throws → FS path used) in
|
|
201
|
-
// the standalone binaries.
|
|
202
|
-
run('bun', ['build', ENTRY, '--target=node', `--outfile=${BUNDLED_JS}`, '--external', '@napi-rs/keyring']);
|
|
203
|
-
|
|
204
|
-
const bundleSize = OPTS.dryRun ? 0 : fs.statSync(BUNDLED_JS).size;
|
|
205
|
-
console.log(` bundled.js: ${(bundleSize / 1024 / 1024).toFixed(2)} MB`);
|
|
206
|
-
|
|
207
|
-
// ---------- stage 2: obfuscate ----------
|
|
208
|
-
|
|
209
|
-
let payloadJs = BUNDLED_JS;
|
|
210
|
-
|
|
211
|
-
if (!OPTS.skipObfuscate) {
|
|
212
|
-
step('Stage 2 — javascript-obfuscator (high strength, bundler-safe)');
|
|
213
|
-
const OBF_JS = path.join(STAGE_DIR, 'bundled.obf.js');
|
|
214
|
-
|
|
215
|
-
if (!OPTS.dryRun) {
|
|
216
|
-
const O = require(require.resolve('javascript-obfuscator', { paths: [REPO_ROOT] }));
|
|
217
|
-
const src = fs.readFileSync(BUNDLED_JS, 'utf8');
|
|
218
|
-
// Seed obfuscation from release version: gives same-version reruns a
|
|
219
|
-
// narrow PRNG path, but the obfuscator has internal non-determinism
|
|
220
|
-
// beyond the seed (Set iteration / stringArray rotation timing) so two
|
|
221
|
-
// runs with the same seed can still differ slightly. Empirically ~5%
|
|
222
|
-
// of those runs emit invalid syntax (e.g. mangling `new.target` to
|
|
223
|
-
// `#target`, which then crashes `bun compile`). Validate after each
|
|
224
|
-
// attempt and retry — see RETRY note in pipeline rationale below.
|
|
225
|
-
const baseSeed = parseInt(crypto.createHash('sha256').update(`evolver:${releaseVersion}`).digest('hex').slice(0, 8), 16);
|
|
226
|
-
const obfOpts = {
|
|
227
|
-
compact: true,
|
|
228
|
-
controlFlowFlattening: true,
|
|
229
|
-
controlFlowFlatteningThreshold: 0.75,
|
|
230
|
-
deadCodeInjection: true,
|
|
231
|
-
deadCodeInjectionThreshold: 0.4,
|
|
232
|
-
stringArray: true,
|
|
233
|
-
stringArrayEncoding: ['rc4'],
|
|
234
|
-
stringArrayThreshold: 0.85,
|
|
235
|
-
identifierNamesGenerator: 'hexadecimal',
|
|
236
|
-
// The next three MUST stay disabled — they are incompatible with bun's
|
|
237
|
-
// standalone wrapping (selfDefending + transformObjectKeys + renameGlobals
|
|
238
|
-
// each break either compile-time bundling or run-time module resolution).
|
|
239
|
-
// See pipeline notes at top of file.
|
|
240
|
-
renameGlobals: false,
|
|
241
|
-
selfDefending: false,
|
|
242
|
-
transformObjectKeys: false,
|
|
243
|
-
debugProtection: false,
|
|
244
|
-
splitStrings: true,
|
|
245
|
-
splitStringsChunkLength: 8,
|
|
246
|
-
numbersToExpressions: true,
|
|
247
|
-
unicodeEscapeSequence: true,
|
|
248
|
-
target: 'node',
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
const MAX_OBF_ATTEMPTS_RAW = process.env.OBF_MAX_ATTEMPTS;
|
|
252
|
-
// Default 12 (was 4). The obfuscator's new.target -> #target mangling is
|
|
253
|
-
// non-deterministic ACROSS PROCESSES, not just across seeds: the same seed
|
|
254
|
-
// + same input can pass in one node process and fail in another (Set
|
|
255
|
-
// iteration / internal-state timing). So perturbing the seed per attempt is
|
|
256
|
-
// not the real lever — re-running the obfuscate call is. The v1.87.4 deploy
|
|
257
|
-
// hit 4/4 consecutive failures with the default of 4 and aborted the npm
|
|
258
|
-
// publish + binary upload. At an observed per-attempt failure rate that can
|
|
259
|
-
// run well above the historical ~5% for some bundles, 4 retries is too few;
|
|
260
|
-
// 12 drives the all-fail probability to negligible while costing only extra
|
|
261
|
-
// attempts on the rare unlucky run. Override with OBF_MAX_ATTEMPTS.
|
|
262
|
-
const MAX_OBF_ATTEMPTS = MAX_OBF_ATTEMPTS_RAW === undefined
|
|
263
|
-
? 12
|
|
264
|
-
: parseInt(MAX_OBF_ATTEMPTS_RAW, 10);
|
|
265
|
-
if (!Number.isInteger(MAX_OBF_ATTEMPTS) || MAX_OBF_ATTEMPTS < 1) {
|
|
266
|
-
console.error(` ERROR: OBF_MAX_ATTEMPTS must be a positive integer; got ${JSON.stringify(MAX_OBF_ATTEMPTS_RAW)}.`);
|
|
267
|
-
process.exit(1);
|
|
268
|
-
}
|
|
269
|
-
let attempt = 0;
|
|
270
|
-
let usedSeed = baseSeed;
|
|
271
|
-
let lastValidationErr = null;
|
|
272
|
-
let succeeded = false;
|
|
273
|
-
while (attempt < MAX_OBF_ATTEMPTS) {
|
|
274
|
-
attempt++;
|
|
275
|
-
// Perturb seed on retries to dodge a stuck PRNG path. Attempt 1 keeps
|
|
276
|
-
// the canonical seed for best-effort reproducibility; later attempts
|
|
277
|
-
// shift by attempt index so the next deploy gets a fresh trajectory.
|
|
278
|
-
usedSeed = baseSeed + (attempt - 1);
|
|
279
|
-
const t0 = Date.now();
|
|
280
|
-
const result = O.obfuscate(src, { ...obfOpts, seed: usedSeed });
|
|
281
|
-
fs.writeFileSync(OBF_JS, result.getObfuscatedCode());
|
|
282
|
-
const obfSize = fs.statSync(OBF_JS).size;
|
|
283
|
-
const obfSecs = ((Date.now() - t0) / 1000).toFixed(1);
|
|
284
|
-
|
|
285
|
-
const check = spawnSync('node', ['--check', OBF_JS], { encoding: 'utf8' });
|
|
286
|
-
if (check.status !== 0) {
|
|
287
|
-
lastValidationErr = (check.stderr || check.stdout || '').split('\n').slice(0, 3).join(' | ');
|
|
288
|
-
console.warn(` attempt ${attempt}/${MAX_OBF_ATTEMPTS}: obfuscator output failed node --check (${lastValidationErr.slice(0, 200)}); retrying with perturbed seed...`);
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
// Second gate: bun's compile-time parser is stricter than node's.
|
|
292
|
-
// 1.87.x (post `@napi-rs/keyring` dep) revealed that ~5% of obfuscator
|
|
293
|
-
// outputs that pass `node --check` still trip bun with errors like
|
|
294
|
-
// `Expected "in" but found ","`. Probe with a cheap bundle-only call
|
|
295
|
-
// (no --compile, native target) to fail fast and feed back into the
|
|
296
|
-
// seed-perturbation loop instead of dying in stage 3.
|
|
297
|
-
const bunProbe = spawnSync('bun', [
|
|
298
|
-
'build', OBF_JS,
|
|
299
|
-
'--target=bun',
|
|
300
|
-
`--outfile=${path.join(STAGE_DIR, 'bundled.obf.bunprobe.js')}`,
|
|
301
|
-
], { encoding: 'utf8' });
|
|
302
|
-
if (bunProbe.status !== 0) {
|
|
303
|
-
lastValidationErr = (bunProbe.stderr || bunProbe.stdout || '').split('\n').slice(0, 3).join(' | ');
|
|
304
|
-
console.warn(` attempt ${attempt}/${MAX_OBF_ATTEMPTS}: obfuscator output rejected by bun parser (${lastValidationErr.slice(0, 200)}); retrying with perturbed seed...`);
|
|
305
|
-
continue;
|
|
306
|
-
}
|
|
307
|
-
console.log(` obfuscation: ${obfSecs}s, output ${(obfSize / 1024 / 1024).toFixed(2)} MB (attempt ${attempt}/${MAX_OBF_ATTEMPTS}, seed=0x${usedSeed.toString(16)})`);
|
|
308
|
-
succeeded = true;
|
|
309
|
-
break;
|
|
310
|
-
}
|
|
311
|
-
if (!succeeded) {
|
|
312
|
-
console.error(` ERROR: javascript-obfuscator produced syntactically invalid output in ${MAX_OBF_ATTEMPTS} attempts.`);
|
|
313
|
-
console.error(` last error: ${lastValidationErr || '(none — loop did not run)'}`);
|
|
314
|
-
console.error(` raise OBF_MAX_ATTEMPTS env var to retry more times, or temporarily run with --skip-obfuscate.`);
|
|
315
|
-
process.exit(2);
|
|
316
|
-
}
|
|
317
|
-
} else {
|
|
318
|
-
console.log(' [dry-run] would obfuscate stage/bundled.js -> stage/bundled.obf.js (with retry-on-syntax-error)');
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
payloadJs = OBF_JS;
|
|
322
|
-
} else {
|
|
323
|
-
console.log('\n>> Stage 2 — SKIPPED (--skip-obfuscate)');
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// ---------- stage 3: per-target compile ----------
|
|
327
|
-
|
|
328
|
-
step(`Stage 3 — bun compile (${TARGETS.length} target${TARGETS.length === 1 ? '' : 's'})`);
|
|
329
|
-
|
|
330
|
-
// Idempotency: scrub OUT_DIR up front so stale binaries from a prior partial
|
|
331
|
-
// run can't leak into a subsequent `gh release upload dist-binaries/*`.
|
|
332
|
-
if (!OPTS.dryRun) {
|
|
333
|
-
rmDir(OUT_DIR);
|
|
334
|
-
}
|
|
335
|
-
ensureDir(OUT_DIR);
|
|
336
|
-
const sums = [];
|
|
337
|
-
|
|
338
|
-
for (const t of TARGETS) {
|
|
339
|
-
const outPath = path.join(OUT_DIR, t.name);
|
|
340
|
-
console.log(`\n --- ${t.triple} -> ${path.relative(REPO_ROOT, outPath)} ---`);
|
|
341
|
-
|
|
342
|
-
run('bun', [
|
|
343
|
-
'build',
|
|
344
|
-
payloadJs,
|
|
345
|
-
'--compile',
|
|
346
|
-
'--minify',
|
|
347
|
-
`--target=${t.triple}`,
|
|
348
|
-
`--outfile=${outPath}`,
|
|
349
|
-
]);
|
|
350
|
-
|
|
351
|
-
if (!OPTS.dryRun) {
|
|
352
|
-
const stat = fs.statSync(outPath);
|
|
353
|
-
fs.chmodSync(outPath, 0o755);
|
|
354
|
-
const hash = sha256(outPath);
|
|
355
|
-
fs.writeFileSync(`${outPath}.sha256`, `${hash} ${t.name}\n`);
|
|
356
|
-
sums.push(`${hash} ${t.name}`);
|
|
357
|
-
console.log(` size: ${(stat.size / 1024 / 1024).toFixed(1)} MB sha256: ${hash.slice(0, 16)}…`);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// Smoke test only the host platform binary (cross-platform binaries cannot
|
|
362
|
-
// be executed on the build host without an emulator; skip them by design).
|
|
363
|
-
const hostTriple = (() => {
|
|
364
|
-
const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
|
|
365
|
-
const plat = process.platform === 'darwin' ? 'darwin'
|
|
366
|
-
: process.platform === 'linux' ? 'linux'
|
|
367
|
-
: process.platform === 'win32' ? 'windows'
|
|
368
|
-
: null;
|
|
369
|
-
return plat ? `${plat}-${arch}` : null;
|
|
370
|
-
})();
|
|
371
|
-
|
|
372
|
-
if (!OPTS.dryRun && hostTriple) {
|
|
373
|
-
// Match against the triple suffix (e.g. "darwin-arm64"), since the binary
|
|
374
|
-
// name on Windows includes a ".exe" extension.
|
|
375
|
-
const hostBin = TARGETS.find(t => t.triple.endsWith(hostTriple));
|
|
376
|
-
if (hostBin) {
|
|
377
|
-
step(`Stage 4 — smoke test ${hostBin.name}`);
|
|
378
|
-
const r = spawnSync(path.join(OUT_DIR, hostBin.name), ['--help'], {
|
|
379
|
-
timeout: 15000,
|
|
380
|
-
encoding: 'utf8',
|
|
381
|
-
});
|
|
382
|
-
if (r.status !== 0 || !r.stdout || !r.stdout.includes('Usage:')) {
|
|
383
|
-
console.error(' ERROR: smoke test failed.');
|
|
384
|
-
console.error(` exit: ${r.status}`);
|
|
385
|
-
console.error(` stdout: ${(r.stdout || '').slice(0, 200)}`);
|
|
386
|
-
console.error(` stderr: ${(r.stderr || '').slice(0, 200)}`);
|
|
387
|
-
process.exit(3);
|
|
388
|
-
}
|
|
389
|
-
console.log(' smoke test: OK');
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// ---------- write combined SHA256SUMS ----------
|
|
394
|
-
|
|
395
|
-
if (!OPTS.dryRun) {
|
|
396
|
-
step('Writing combined SHA256SUMS.txt');
|
|
397
|
-
const sumsFile = path.join(OUT_DIR, 'SHA256SUMS.txt');
|
|
398
|
-
fs.writeFileSync(sumsFile, sums.join('\n') + '\n');
|
|
399
|
-
console.log(` wrote ${path.relative(REPO_ROOT, sumsFile)}`);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// ---------- cleanup ----------
|
|
403
|
-
|
|
404
|
-
if (!OPTS.keepStage && !OPTS.dryRun) {
|
|
405
|
-
rmDir(STAGE_DIR);
|
|
406
|
-
} else if (OPTS.keepStage) {
|
|
407
|
-
console.log(`\n (kept stage at ${path.relative(REPO_ROOT, STAGE_DIR)} for inspection)`);
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
step(`Done. ${TARGETS.length} binar${TARGETS.length === 1 ? 'y' : 'ies'} in ${path.relative(REPO_ROOT, OUT_DIR)}/`);
|
|
411
|
-
console.log(' next: gh release upload v<ver> dist-binaries/* --repo EvoMap/evolver');
|
|
412
|
-
|
|
413
|
-
//
|
|
414
|
-
// =====================================================================
|
|
415
|
-
// PIPELINE RATIONALE — 2026-05-05
|
|
416
|
-
// =====================================================================
|
|
417
|
-
//
|
|
418
|
-
// Why "bun-bundle then obfuscate" rather than the more obvious
|
|
419
|
-
// "obfuscate src/ then bun-bundle":
|
|
420
|
-
//
|
|
421
|
-
// javascript-obfuscator at high strength (stringArray + RC4 +
|
|
422
|
-
// transformObjectKeys + ...) rewrites string literals through a runtime
|
|
423
|
-
// lookup function: require('./gep/paths') becomes
|
|
424
|
-
// require(_0xLOOKUP(0x82b)). Bun's bundler does static analysis on
|
|
425
|
-
// require() arguments at compile time, so it cannot resolve those
|
|
426
|
-
// dynamic require calls and the resulting binary throws "Cannot find
|
|
427
|
-
// module './gep/paths'" on first invocation.
|
|
428
|
-
//
|
|
429
|
-
// By bundling FIRST, every require() is inlined and resolved before the
|
|
430
|
-
// obfuscator ever sees the code. The obfuscator then operates on a
|
|
431
|
-
// single self-contained file with no remaining dynamic requires, so
|
|
432
|
-
// stringArray and friends are safe.
|
|
433
|
-
//
|
|
434
|
-
// Why selfDefending must stay OFF:
|
|
435
|
-
//
|
|
436
|
-
// selfDefending: true injects a guard that hangs (infinite while loop)
|
|
437
|
-
// when it detects formatting changes. bun --compile wraps the JS payload
|
|
438
|
-
// in a standalone executable container that re-emits the source with
|
|
439
|
-
// different whitespace + line endings, which trips the guard immediately.
|
|
440
|
-
// Symptom: binary launches, opens stdio, then never exits.
|
|
441
|
-
//
|
|
442
|
-
// Why transformObjectKeys must stay OFF:
|
|
443
|
-
//
|
|
444
|
-
// Same family of issue — it rewrites top-level module.exports / exports
|
|
445
|
-
// patterns in ways that bun's standalone runtime cannot rebuild.
|
|
446
|
-
//
|
|
447
|
-
// Why renameGlobals must stay OFF:
|
|
448
|
-
//
|
|
449
|
-
// Not strictly required after the bundle step (no external require'd
|
|
450
|
-
// modules remain), but kept off as a safety belt; the cost is small
|
|
451
|
-
// because identifier hashing already covers >99% of names through
|
|
452
|
-
// identifierNamesGenerator='hexadecimal'.
|
|
453
|
-
//
|
|
454
|
-
// Smoke test policy:
|
|
455
|
-
//
|
|
456
|
-
// We only smoke test the binary that matches the BUILD HOST triple.
|
|
457
|
-
// Cross-compiled binaries can't be executed without an emulator
|
|
458
|
-
// (qemu-user-static on linux, Rosetta on darwin-x64-on-arm64). CI/CD
|
|
459
|
-
// in GitHub Actions on `runs-on: macos-latest, ubuntu-latest` should
|
|
460
|
-
// set up the matrix so each runner smoke-tests its own native target.
|
|
461
|
-
//
|
|
462
|
-
// Stage 2 retry-on-syntax-error (added 2026-05-22, v1.85.0 deploy
|
|
463
|
-
// post-mortem):
|
|
464
|
-
//
|
|
465
|
-
// The v1.85.0 release deploy hit `bun compile` failing with
|
|
466
|
-
// `Expected "in" but found ","` at offset ~1.5MB into bundled.obf.js.
|
|
467
|
-
// The failing region contained `(#target,this)` — javascript-obfuscator
|
|
468
|
-
// had mangled `new.target` into `#target` (a private class field syntax
|
|
469
|
-
// that's only legal inside a class body). A from-scratch rebuild on the
|
|
470
|
-
// same source + seed produced a different output (15.18 MB vs 15.14 MB)
|
|
471
|
-
// that compiled cleanly, confirming the obfuscator has internal
|
|
472
|
-
// non-determinism beyond the user-supplied seed.
|
|
473
|
-
//
|
|
474
|
-
// Mitigation: after each obfuscation attempt, run `node --check` on the
|
|
475
|
-
// output; if syntax is invalid, perturb the seed by +attempt and retry
|
|
476
|
-
// up to OBF_MAX_ATTEMPTS times (default 4). Cost of validation is
|
|
477
|
-
// ~1 second on 15 MB; cost of catching the failure here vs after a
|
|
478
|
-
// doomed bun compile pass is roughly 50s saved per failure.
|
|
479
|
-
//
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* CHANGELOG release-section integrity guard.
|
|
5
|
-
*
|
|
6
|
-
* Catches the misattribution pattern that bit us with #540 / PR #107:
|
|
7
|
-
* an entry filed under `## [X.Y.Z]` AFTER v1.85.0 was already published
|
|
8
|
-
* to npm, so the changelog claimed a fix the binary didn't contain.
|
|
9
|
-
*
|
|
10
|
-
* Algorithm: for every `## [X.Y.Z]` heading in CHANGELOG.md that has a
|
|
11
|
-
* matching git tag (`vX.Y.Z`), compare the section content at HEAD
|
|
12
|
-
* against the section content at that tag. If they differ, somebody
|
|
13
|
-
* edited a frozen-and-released section — fail loud.
|
|
14
|
-
*
|
|
15
|
-
* Notes:
|
|
16
|
-
* - `## [Unreleased]` is exempt (it's the staging area, no tag).
|
|
17
|
-
* - Version headings without a corresponding tag are exempt — that's
|
|
18
|
-
* usually the "preparing X.Y.Z" state right before the tag exists.
|
|
19
|
-
* - Tag lookup is local-only (`git rev-parse`); CI must `git fetch
|
|
20
|
-
* --tags` first if it runs on a shallow clone.
|
|
21
|
-
* - `repoRoot` is injectable so tests don't need to monkey-patch the
|
|
22
|
-
* module by re-evaluating source (see PR #115 review).
|
|
23
|
-
*
|
|
24
|
-
* Usage:
|
|
25
|
-
* node scripts/check-changelog.js # CLI mode, exits 0/1
|
|
26
|
-
* const { checkChangelogIntegrity } = require('./check-changelog');
|
|
27
|
-
* const result = checkChangelogIntegrity({ repoRoot });
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
const { execFileSync } = require('child_process');
|
|
31
|
-
const fs = require('fs');
|
|
32
|
-
const path = require('path');
|
|
33
|
-
|
|
34
|
-
const DEFAULT_REPO_ROOT = path.resolve(__dirname, '..');
|
|
35
|
-
|
|
36
|
-
function readChangelogAtHead(repoRoot) {
|
|
37
|
-
return fs.readFileSync(path.join(repoRoot, 'CHANGELOG.md'), 'utf8');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function readChangelogAtRef(repoRoot, ref) {
|
|
41
|
-
try {
|
|
42
|
-
return execFileSync('git', ['show', `${ref}:CHANGELOG.md`], {
|
|
43
|
-
cwd: repoRoot,
|
|
44
|
-
encoding: 'utf8',
|
|
45
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
46
|
-
});
|
|
47
|
-
} catch {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function tagExists(repoRoot, tag) {
|
|
53
|
-
try {
|
|
54
|
-
execFileSync('git', ['rev-parse', '--verify', `refs/tags/${tag}`], {
|
|
55
|
-
cwd: repoRoot,
|
|
56
|
-
stdio: ['ignore', 'ignore', 'ignore'],
|
|
57
|
-
});
|
|
58
|
-
return true;
|
|
59
|
-
} catch {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Pull every `## [X.Y.Z]` heading from the file, skipping `[Unreleased]`.
|
|
65
|
-
function listReleasedVersionHeadings(text) {
|
|
66
|
-
const versions = [];
|
|
67
|
-
const re = /^## \[(\d+\.\d+\.\d+(?:[-+][\w.]+)?)\]/gm;
|
|
68
|
-
let m;
|
|
69
|
-
while ((m = re.exec(text)) !== null) {
|
|
70
|
-
versions.push(m[1]);
|
|
71
|
-
}
|
|
72
|
-
return versions;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Extract the body between `## [X.Y.Z]` and the next `## [` (or EOF).
|
|
76
|
-
// Normalises trailing whitespace and trailing blank lines so a stray
|
|
77
|
-
// newline doesn't fail the equality check.
|
|
78
|
-
//
|
|
79
|
-
// Heading match is line-anchored (`/^## \[X\.Y\.Z\]/m`) so a fenced
|
|
80
|
-
// code block or quoted text containing `## [X.Y.Z]` mid-line cannot be
|
|
81
|
-
// mistaken for the section start (Bugbot PR #115 review).
|
|
82
|
-
function extractSection(text, version) {
|
|
83
|
-
const escaped = version.replace(/[.+]/g, (c) => '\\' + c);
|
|
84
|
-
const re = new RegExp(`^## \\[${escaped}\\]`, 'm');
|
|
85
|
-
const match = re.exec(text);
|
|
86
|
-
if (!match) return null;
|
|
87
|
-
const after = match.index + match[0].length;
|
|
88
|
-
const rest = text.slice(after);
|
|
89
|
-
const nextRel = rest.search(/\n## \[/);
|
|
90
|
-
const raw = nextRel === -1 ? rest : rest.slice(0, nextRel);
|
|
91
|
-
return raw
|
|
92
|
-
.split('\n')
|
|
93
|
-
.map((line) => line.replace(/\s+$/, ''))
|
|
94
|
-
.join('\n')
|
|
95
|
-
.replace(/\n+$/, '');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function checkChangelogIntegrity(opts) {
|
|
99
|
-
const repoRoot = (opts && opts.repoRoot) || DEFAULT_REPO_ROOT;
|
|
100
|
-
const head = readChangelogAtHead(repoRoot);
|
|
101
|
-
const versions = listReleasedVersionHeadings(head);
|
|
102
|
-
|
|
103
|
-
const drift = [];
|
|
104
|
-
const skipped = [];
|
|
105
|
-
|
|
106
|
-
for (const version of versions) {
|
|
107
|
-
const tag = `v${version}`;
|
|
108
|
-
if (!tagExists(repoRoot, tag)) {
|
|
109
|
-
skipped.push({ version, reason: 'no matching git tag (probably preparing this release)' });
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
const tagText = readChangelogAtRef(repoRoot, tag);
|
|
113
|
-
if (tagText == null) {
|
|
114
|
-
skipped.push({ version, reason: `tag ${tag} exists but its CHANGELOG.md is unreadable` });
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
const headSection = extractSection(head, version);
|
|
118
|
-
const tagSection = extractSection(tagText, version);
|
|
119
|
-
if (headSection == null || tagSection == null) {
|
|
120
|
-
skipped.push({ version, reason: 'section parse failed' });
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
if (headSection !== tagSection) {
|
|
124
|
-
drift.push({ version, tag });
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return { drift, skipped, checked: versions.length - skipped.length };
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function main() {
|
|
132
|
-
const result = checkChangelogIntegrity();
|
|
133
|
-
|
|
134
|
-
process.stdout.write(`\n=== CHANGELOG release-section guard ===\n`);
|
|
135
|
-
process.stdout.write(`Checked ${result.checked} released version section(s); skipped ${result.skipped.length}.\n`);
|
|
136
|
-
|
|
137
|
-
for (const s of result.skipped) {
|
|
138
|
-
process.stdout.write(` [skip] ${s.version}: ${s.reason}\n`);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (result.drift.length === 0) {
|
|
142
|
-
process.stdout.write(`\n[OK] No released CHANGELOG section was edited after its release tag.\n`);
|
|
143
|
-
return 0;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
process.stderr.write(`\n[FAIL] ${result.drift.length} CHANGELOG section(s) diverged from their release tag:\n`);
|
|
147
|
-
for (const d of result.drift) {
|
|
148
|
-
process.stderr.write(` - ## [${d.version}] differs from ${d.tag}:CHANGELOG.md\n`);
|
|
149
|
-
}
|
|
150
|
-
process.stderr.write(
|
|
151
|
-
`\nReleased sections must stay frozen. Move any new entries under ## [Unreleased],\n` +
|
|
152
|
-
`or, if the entry was genuinely missing from the release, amend it on a hotfix\n` +
|
|
153
|
-
`branch and tag a patch release.\n`
|
|
154
|
-
);
|
|
155
|
-
return 1;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (require.main === module) {
|
|
159
|
-
process.exit(main());
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
module.exports = {
|
|
163
|
-
checkChangelogIntegrity,
|
|
164
|
-
extractSection, // for tests
|
|
165
|
-
listReleasedVersionHeadings, // for tests
|
|
166
|
-
};
|