@tradejs/cli 3.0.1 → 3.1.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/dist/cli.js +2593 -2167
- package/dist/lib/aiPocketSearch.js +10 -0
- package/dist/lib/aiTrainResearch.js +24 -15
- package/dist/lib/researchAgent.js +16 -2
- package/dist/lib/runtimeLineage.js +24 -15
- package/dist/lib/strategyGateFingerprint.js +26 -15
- package/dist/lib/strategyRelease.js +266 -253
- package/dist/scripts/agentRun.js +50 -45
- package/dist/scripts/aiPocketSearch.js +2269 -1972
- package/dist/scripts/aiTrain.js +24 -15
- package/dist/scripts/replay.js +24 -15
- package/dist/scripts/replayRunner.js +24 -15
- package/dist/scripts/researchAuto.js +2 -2
- package/dist/scripts/runtimeEvidence.js +1 -0
- package/dist/scripts/runtimeScorecard.js +108 -103
- package/dist/scripts/signals.js +24 -15
- package/dist/scripts/signalsDaemon.js +24 -15
- package/dist/scripts/strategyRelease.js +222 -209
- package/dist/scripts/test-ml.js +8 -2
- package/package.json +8 -9
|
@@ -32,6 +32,8 @@ __export(aiPocketSearch_exports, {
|
|
|
32
32
|
summarizeAiPocketRows: () => summarizeAiPocketRows
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(aiPocketSearch_exports);
|
|
35
|
+
|
|
36
|
+
// src/lib/aiPocketSearch/features.ts
|
|
35
37
|
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
36
38
|
var DAYS_PER_WEEK = 7;
|
|
37
39
|
var DAYS_PER_MONTH = 30.4375;
|
|
@@ -674,6 +676,8 @@ var collectAiPocketFeatureSnapshot = ({
|
|
|
674
676
|
return { features, featureCoverage };
|
|
675
677
|
};
|
|
676
678
|
var collectAiPocketFeatures = (options) => collectAiPocketFeatureSnapshot(options).features;
|
|
679
|
+
|
|
680
|
+
// src/lib/aiPocketSearch/summary.ts
|
|
677
681
|
var formatNumber = (value) => {
|
|
678
682
|
if (Number.isInteger(value)) {
|
|
679
683
|
return String(value);
|
|
@@ -970,6 +974,8 @@ var summarizeAiPocketFeatureCoverage = (rows, family) => {
|
|
|
970
974
|
maxTimestamp
|
|
971
975
|
};
|
|
972
976
|
};
|
|
977
|
+
|
|
978
|
+
// src/lib/aiPocketSearch/predicates.ts
|
|
973
979
|
var matchesPredicate = (value, predicate) => {
|
|
974
980
|
if (predicate.kind === "numeric") {
|
|
975
981
|
if (!isFiniteNumber(value)) {
|
|
@@ -1218,6 +1224,8 @@ var buildAiPocketPredicateResult = (rows, options = {}) => {
|
|
|
1218
1224
|
return { featureKeys: buckets.size, predicates };
|
|
1219
1225
|
};
|
|
1220
1226
|
var buildAiPocketPredicates = (rows, options = {}) => buildAiPocketPredicateResult(rows, options).predicates.map(toPublicPredicate);
|
|
1227
|
+
|
|
1228
|
+
// src/lib/aiPocketSearch/searchEngine.ts
|
|
1221
1229
|
var scorePositivePocket = (summary) => {
|
|
1222
1230
|
const profitFactor = summary.profitFactor ?? (summary.grossLoss === 0 ? 8 : 0);
|
|
1223
1231
|
const winRate = summary.winRate ?? 0;
|
|
@@ -1796,6 +1804,8 @@ var searchAiPockets = (rows, options = {}) => {
|
|
|
1796
1804
|
}
|
|
1797
1805
|
};
|
|
1798
1806
|
};
|
|
1807
|
+
|
|
1808
|
+
// src/lib/aiPocketSearch/markdownReport.ts
|
|
1799
1809
|
var formatMdNumber = (value, digits = 2) => value == null || !Number.isFinite(value) ? "n/a" : value.toFixed(digits);
|
|
1800
1810
|
var formatMdPercent = (value) => value == null || !Number.isFinite(value) ? "n/a" : `${(value * 100).toFixed(1)}%`;
|
|
1801
1811
|
var escapeMarkdownCell = (value) => String(value ?? "n/a").replace(/\|/g, "\\|").replace(/\n/g, "<br>");
|
|
@@ -346,28 +346,37 @@ var import_types = require("@tradejs/types");
|
|
|
346
346
|
|
|
347
347
|
// src/lib/strategyGateFingerprint.ts
|
|
348
348
|
var import_node_crypto = require("crypto");
|
|
349
|
+
var import_node_module = require("module");
|
|
349
350
|
var import_promises = __toESM(require("fs/promises"));
|
|
350
351
|
var import_node_path = __toESM(require("path"));
|
|
351
|
-
var
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
"
|
|
357
|
-
"
|
|
358
|
-
"packages/core/src/utils/strategyHelpers/signalBuilders.ts"
|
|
352
|
+
var toPackageToken = (strategyName) => strategyName.replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").replace(/([a-z\d])([A-Z])/g, "$1-$2").toLowerCase();
|
|
353
|
+
var getStrategyPackageName = (strategyName) => strategyName === "TrendLine" || strategyName === "ReverseTrendLine" ? "@tradejs/strategy-trend-line" : `@tradejs/strategy-${toPackageToken(strategyName)}`;
|
|
354
|
+
var gateFingerprintSpecifiers = (strategyName) => [
|
|
355
|
+
getStrategyPackageName(strategyName),
|
|
356
|
+
"@tradejs/strategy-kit/ai-gate",
|
|
357
|
+
"@tradejs/node/ai",
|
|
358
|
+
"@tradejs/core/strategies"
|
|
359
359
|
];
|
|
360
360
|
var resolveStrategyGateFingerprint = async ({
|
|
361
361
|
projectRoot,
|
|
362
362
|
strategyName,
|
|
363
363
|
gitSha
|
|
364
364
|
}) => {
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
365
|
+
const projectManifestPath = import_node_path.default.join(projectRoot, "package.json");
|
|
366
|
+
const projectExists = await import_promises.default.access(projectManifestPath).then(() => true).catch(() => false);
|
|
367
|
+
const requireFromProject = projectExists ? (0, import_node_module.createRequire)(projectManifestPath) : null;
|
|
368
|
+
const candidates = requireFromProject ? await Promise.all(
|
|
369
|
+
gateFingerprintSpecifiers(strategyName).map(async (specifier) => {
|
|
370
|
+
let resolvedPath;
|
|
371
|
+
try {
|
|
372
|
+
resolvedPath = requireFromProject.resolve(specifier);
|
|
373
|
+
} catch {
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
const content = await import_promises.default.readFile(resolvedPath).catch(() => null);
|
|
377
|
+
return content == null ? null : { specifier, content };
|
|
369
378
|
})
|
|
370
|
-
);
|
|
379
|
+
) : [];
|
|
371
380
|
const sourceEntries = candidates.filter(
|
|
372
381
|
(entry) => entry != null
|
|
373
382
|
);
|
|
@@ -375,7 +384,7 @@ var resolveStrategyGateFingerprint = async ({
|
|
|
375
384
|
hash.update(strategyName);
|
|
376
385
|
if (sourceEntries.length) {
|
|
377
386
|
for (const entry of sourceEntries) {
|
|
378
|
-
hash.update(entry.
|
|
387
|
+
hash.update(entry.specifier);
|
|
379
388
|
hash.update(entry.content);
|
|
380
389
|
}
|
|
381
390
|
} else {
|
|
@@ -383,7 +392,7 @@ var resolveStrategyGateFingerprint = async ({
|
|
|
383
392
|
}
|
|
384
393
|
return {
|
|
385
394
|
gateFingerprint: hash.digest("hex").slice(0, 16),
|
|
386
|
-
gateFingerprintFiles: sourceEntries.map((entry) => entry.
|
|
395
|
+
gateFingerprintFiles: sourceEntries.map((entry) => entry.specifier)
|
|
387
396
|
};
|
|
388
397
|
};
|
|
389
398
|
|
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var researchAgent_exports = {};
|
|
22
22
|
__export(researchAgent_exports, {
|
|
23
23
|
RESEARCH_AGENT_BRANCH_PREFIX: () => RESEARCH_AGENT_BRANCH_PREFIX,
|
|
24
|
+
RESEARCH_AGENT_DEFAULT_GITHUB_ORGANIZATION: () => RESEARCH_AGENT_DEFAULT_GITHUB_ORGANIZATION,
|
|
24
25
|
RESEARCH_AGENT_MODEL: () => RESEARCH_AGENT_MODEL,
|
|
25
26
|
RESEARCH_AGENT_REASONING_EFFORT: () => RESEARCH_AGENT_REASONING_EFFORT,
|
|
26
27
|
assertDiffAllowed: () => assertDiffAllowed,
|
|
@@ -29,6 +30,8 @@ __export(researchAgent_exports, {
|
|
|
29
30
|
buildResearchAgentPrBody: () => buildResearchAgentPrBody,
|
|
30
31
|
buildResearchAgentPrTitle: () => buildResearchAgentPrTitle,
|
|
31
32
|
getResearchAgentAllowedPathPrefixes: () => getResearchAgentAllowedPathPrefixes,
|
|
33
|
+
getResearchAgentRepository: () => getResearchAgentRepository,
|
|
34
|
+
getResearchAgentRepositoryName: () => getResearchAgentRepositoryName,
|
|
32
35
|
normalizeDiffOutput: () => normalizeDiffOutput,
|
|
33
36
|
parseChangedFilesFromDiff: () => parseChangedFilesFromDiff,
|
|
34
37
|
parseGithubRepositoryFromRemote: () => parseGithubRepositoryFromRemote
|
|
@@ -37,6 +40,7 @@ module.exports = __toCommonJS(researchAgent_exports);
|
|
|
37
40
|
var RESEARCH_AGENT_MODEL = "openai/gpt-5.4";
|
|
38
41
|
var RESEARCH_AGENT_REASONING_EFFORT = "medium";
|
|
39
42
|
var RESEARCH_AGENT_BRANCH_PREFIX = "codex/research";
|
|
43
|
+
var RESEARCH_AGENT_DEFAULT_GITHUB_ORGANIZATION = "TradeJS-Dev";
|
|
40
44
|
var buildResearchAgentBranchName = (strategy, runId) => {
|
|
41
45
|
const normalizedStrategy = strategy.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9-]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase();
|
|
42
46
|
const normalizedRunId = runId.trim().replace(/[^a-zA-Z0-9-]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase();
|
|
@@ -44,8 +48,15 @@ var buildResearchAgentBranchName = (strategy, runId) => {
|
|
|
44
48
|
};
|
|
45
49
|
var buildResearchAgentCommitMessage = (strategy, runId) => `Research agent: ${strategy} follow-up for ${runId}`;
|
|
46
50
|
var buildResearchAgentPrTitle = (strategy, runId) => `Research agent: ${strategy} follow-up for ${runId}`;
|
|
51
|
+
var getResearchAgentRepositoryName = (strategy) => {
|
|
52
|
+
if (strategy === "TrendLine" || strategy === "ReverseTrendLine") {
|
|
53
|
+
return "TradeJS-Strategy-TrendLine";
|
|
54
|
+
}
|
|
55
|
+
return `TradeJS-Strategy-${strategy}`;
|
|
56
|
+
};
|
|
57
|
+
var getResearchAgentRepository = (strategy, organization = RESEARCH_AGENT_DEFAULT_GITHUB_ORGANIZATION) => `${organization}/${getResearchAgentRepositoryName(strategy)}`;
|
|
47
58
|
var getResearchAgentAllowedPathPrefixes = (strategy) => [
|
|
48
|
-
`
|
|
59
|
+
`src/${strategy}/`
|
|
49
60
|
];
|
|
50
61
|
var parseGithubRepositoryFromRemote = (value) => {
|
|
51
62
|
const trimmed = value.trim();
|
|
@@ -99,7 +110,7 @@ var buildResearchAgentPrBody = (params) => {
|
|
|
99
110
|
lines.push("");
|
|
100
111
|
lines.push("## Notes");
|
|
101
112
|
lines.push("- Created automatically by the TradeJS research agent.");
|
|
102
|
-
lines.push("- Base branch: `
|
|
113
|
+
lines.push("- Base branch: `main`.");
|
|
103
114
|
return lines.join("\n");
|
|
104
115
|
};
|
|
105
116
|
var normalizeDiffOutput = (value) => {
|
|
@@ -154,6 +165,7 @@ ${diffText}`)) {
|
|
|
154
165
|
// Annotate the CommonJS export names for ESM import in node:
|
|
155
166
|
0 && (module.exports = {
|
|
156
167
|
RESEARCH_AGENT_BRANCH_PREFIX,
|
|
168
|
+
RESEARCH_AGENT_DEFAULT_GITHUB_ORGANIZATION,
|
|
157
169
|
RESEARCH_AGENT_MODEL,
|
|
158
170
|
RESEARCH_AGENT_REASONING_EFFORT,
|
|
159
171
|
assertDiffAllowed,
|
|
@@ -162,6 +174,8 @@ ${diffText}`)) {
|
|
|
162
174
|
buildResearchAgentPrBody,
|
|
163
175
|
buildResearchAgentPrTitle,
|
|
164
176
|
getResearchAgentAllowedPathPrefixes,
|
|
177
|
+
getResearchAgentRepository,
|
|
178
|
+
getResearchAgentRepositoryName,
|
|
165
179
|
normalizeDiffOutput,
|
|
166
180
|
parseChangedFilesFromDiff,
|
|
167
181
|
parseGithubRepositoryFromRemote
|
|
@@ -47,28 +47,37 @@ var import_strategyReleaseEvidence = require("@tradejs/infra/strategyReleaseEvid
|
|
|
47
47
|
|
|
48
48
|
// src/lib/strategyGateFingerprint.ts
|
|
49
49
|
var import_node_crypto = require("crypto");
|
|
50
|
+
var import_node_module = require("module");
|
|
50
51
|
var import_promises = __toESM(require("fs/promises"));
|
|
51
52
|
var import_node_path = __toESM(require("path"));
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"packages/core/src/utils/strategyHelpers/signalBuilders.ts"
|
|
53
|
+
var toPackageToken = (strategyName) => strategyName.replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").replace(/([a-z\d])([A-Z])/g, "$1-$2").toLowerCase();
|
|
54
|
+
var getStrategyPackageName = (strategyName) => strategyName === "TrendLine" || strategyName === "ReverseTrendLine" ? "@tradejs/strategy-trend-line" : `@tradejs/strategy-${toPackageToken(strategyName)}`;
|
|
55
|
+
var gateFingerprintSpecifiers = (strategyName) => [
|
|
56
|
+
getStrategyPackageName(strategyName),
|
|
57
|
+
"@tradejs/strategy-kit/ai-gate",
|
|
58
|
+
"@tradejs/node/ai",
|
|
59
|
+
"@tradejs/core/strategies"
|
|
60
60
|
];
|
|
61
61
|
var resolveStrategyGateFingerprint = async ({
|
|
62
62
|
projectRoot,
|
|
63
63
|
strategyName,
|
|
64
64
|
gitSha
|
|
65
65
|
}) => {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
const projectManifestPath = import_node_path.default.join(projectRoot, "package.json");
|
|
67
|
+
const projectExists = await import_promises.default.access(projectManifestPath).then(() => true).catch(() => false);
|
|
68
|
+
const requireFromProject = projectExists ? (0, import_node_module.createRequire)(projectManifestPath) : null;
|
|
69
|
+
const candidates = requireFromProject ? await Promise.all(
|
|
70
|
+
gateFingerprintSpecifiers(strategyName).map(async (specifier) => {
|
|
71
|
+
let resolvedPath;
|
|
72
|
+
try {
|
|
73
|
+
resolvedPath = requireFromProject.resolve(specifier);
|
|
74
|
+
} catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const content = await import_promises.default.readFile(resolvedPath).catch(() => null);
|
|
78
|
+
return content == null ? null : { specifier, content };
|
|
70
79
|
})
|
|
71
|
-
);
|
|
80
|
+
) : [];
|
|
72
81
|
const sourceEntries = candidates.filter(
|
|
73
82
|
(entry) => entry != null
|
|
74
83
|
);
|
|
@@ -76,7 +85,7 @@ var resolveStrategyGateFingerprint = async ({
|
|
|
76
85
|
hash.update(strategyName);
|
|
77
86
|
if (sourceEntries.length) {
|
|
78
87
|
for (const entry of sourceEntries) {
|
|
79
|
-
hash.update(entry.
|
|
88
|
+
hash.update(entry.specifier);
|
|
80
89
|
hash.update(entry.content);
|
|
81
90
|
}
|
|
82
91
|
} else {
|
|
@@ -84,7 +93,7 @@ var resolveStrategyGateFingerprint = async ({
|
|
|
84
93
|
}
|
|
85
94
|
return {
|
|
86
95
|
gateFingerprint: hash.digest("hex").slice(0, 16),
|
|
87
|
-
gateFingerprintFiles: sourceEntries.map((entry) => entry.
|
|
96
|
+
gateFingerprintFiles: sourceEntries.map((entry) => entry.specifier)
|
|
88
97
|
};
|
|
89
98
|
};
|
|
90
99
|
|
|
@@ -30,32 +30,42 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/lib/strategyGateFingerprint.ts
|
|
31
31
|
var strategyGateFingerprint_exports = {};
|
|
32
32
|
__export(strategyGateFingerprint_exports, {
|
|
33
|
+
getStrategyPackageName: () => getStrategyPackageName,
|
|
33
34
|
resolveStrategyGateFingerprint: () => resolveStrategyGateFingerprint
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(strategyGateFingerprint_exports);
|
|
36
37
|
var import_node_crypto = require("crypto");
|
|
38
|
+
var import_node_module = require("module");
|
|
37
39
|
var import_promises = __toESM(require("fs/promises"));
|
|
38
40
|
var import_node_path = __toESM(require("path"));
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"packages/core/src/utils/strategyHelpers/signalBuilders.ts"
|
|
41
|
+
var toPackageToken = (strategyName) => strategyName.replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").replace(/([a-z\d])([A-Z])/g, "$1-$2").toLowerCase();
|
|
42
|
+
var getStrategyPackageName = (strategyName) => strategyName === "TrendLine" || strategyName === "ReverseTrendLine" ? "@tradejs/strategy-trend-line" : `@tradejs/strategy-${toPackageToken(strategyName)}`;
|
|
43
|
+
var gateFingerprintSpecifiers = (strategyName) => [
|
|
44
|
+
getStrategyPackageName(strategyName),
|
|
45
|
+
"@tradejs/strategy-kit/ai-gate",
|
|
46
|
+
"@tradejs/node/ai",
|
|
47
|
+
"@tradejs/core/strategies"
|
|
47
48
|
];
|
|
48
49
|
var resolveStrategyGateFingerprint = async ({
|
|
49
50
|
projectRoot,
|
|
50
51
|
strategyName,
|
|
51
52
|
gitSha
|
|
52
53
|
}) => {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
const projectManifestPath = import_node_path.default.join(projectRoot, "package.json");
|
|
55
|
+
const projectExists = await import_promises.default.access(projectManifestPath).then(() => true).catch(() => false);
|
|
56
|
+
const requireFromProject = projectExists ? (0, import_node_module.createRequire)(projectManifestPath) : null;
|
|
57
|
+
const candidates = requireFromProject ? await Promise.all(
|
|
58
|
+
gateFingerprintSpecifiers(strategyName).map(async (specifier) => {
|
|
59
|
+
let resolvedPath;
|
|
60
|
+
try {
|
|
61
|
+
resolvedPath = requireFromProject.resolve(specifier);
|
|
62
|
+
} catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const content = await import_promises.default.readFile(resolvedPath).catch(() => null);
|
|
66
|
+
return content == null ? null : { specifier, content };
|
|
57
67
|
})
|
|
58
|
-
);
|
|
68
|
+
) : [];
|
|
59
69
|
const sourceEntries = candidates.filter(
|
|
60
70
|
(entry) => entry != null
|
|
61
71
|
);
|
|
@@ -63,7 +73,7 @@ var resolveStrategyGateFingerprint = async ({
|
|
|
63
73
|
hash.update(strategyName);
|
|
64
74
|
if (sourceEntries.length) {
|
|
65
75
|
for (const entry of sourceEntries) {
|
|
66
|
-
hash.update(entry.
|
|
76
|
+
hash.update(entry.specifier);
|
|
67
77
|
hash.update(entry.content);
|
|
68
78
|
}
|
|
69
79
|
} else {
|
|
@@ -71,10 +81,11 @@ var resolveStrategyGateFingerprint = async ({
|
|
|
71
81
|
}
|
|
72
82
|
return {
|
|
73
83
|
gateFingerprint: hash.digest("hex").slice(0, 16),
|
|
74
|
-
gateFingerprintFiles: sourceEntries.map((entry) => entry.
|
|
84
|
+
gateFingerprintFiles: sourceEntries.map((entry) => entry.specifier)
|
|
75
85
|
};
|
|
76
86
|
};
|
|
77
87
|
// Annotate the CommonJS export names for ESM import in node:
|
|
78
88
|
0 && (module.exports = {
|
|
89
|
+
getStrategyPackageName,
|
|
79
90
|
resolveStrategyGateFingerprint
|
|
80
91
|
});
|