@tradejs/cli 3.0.0 → 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.
@@ -3760,7 +3760,10 @@ var loadRuntimeStrategies = async ({
3760
3760
  interval
3761
3761
  }) => {
3762
3762
  const deploymentStrategies = new Map(
3763
- (deployment?.strategies ?? []).filter(({ enabled }) => enabled !== false).map((strategy) => [strategy.strategyName, strategy])
3763
+ (deployment?.strategies ?? []).map((strategy) => [
3764
+ strategy.strategyName,
3765
+ strategy
3766
+ ])
3764
3767
  );
3765
3768
  const strategyConfigs = await Promise.all(
3766
3769
  (await (0, import_runtimeStrategyConfigs.loadRuntimeStrategyConfigs)(userName)).map(
@@ -3771,7 +3774,13 @@ var loadRuntimeStrategies = async ({
3771
3774
  strategyConfig
3772
3775
  }) => {
3773
3776
  const deploymentStrategy = deployment ? deploymentStrategies.get(strategyName) : void 0;
3774
- if (deployment && !deploymentStrategy) return null;
3777
+ if (deploymentStrategy?.enabled === false) {
3778
+ import_logger.logger.info(
3779
+ "Skip deployment-disabled strategy config: %s",
3780
+ strategyName
3781
+ );
3782
+ return null;
3783
+ }
3775
3784
  if (!isRuntimeStrategyEnabled(strategyConfig)) {
3776
3785
  import_logger.logger.info(
3777
3786
  "Skip inactive strategy config by ENABLE=false: %s",
@@ -4005,28 +4014,37 @@ var import_strategyReleaseEvidence = require("@tradejs/infra/strategyReleaseEvid
4005
4014
 
4006
4015
  // src/lib/strategyGateFingerprint.ts
4007
4016
  var import_node_crypto = require("crypto");
4017
+ var import_node_module = require("module");
4008
4018
  var import_promises = __toESM(require("fs/promises"));
4009
4019
  var import_node_path = __toESM(require("path"));
4010
- var gateFingerprintRelativePaths = (strategyName) => [
4011
- `packages/strategies/src/${strategyName}/adapters/ai.ts`,
4012
- `packages/strategies/src/${strategyName}/guardrails.ts`,
4013
- `packages/strategies/src/${strategyName}/pockets.ts`,
4014
- `packages/strategies/src/${strategyName}/config.ts`,
4015
- "packages/strategies/src/shared/localAiGate.ts",
4016
- "packages/node/src/ai.ts",
4017
- "packages/core/src/utils/strategyHelpers/signalBuilders.ts"
4020
+ var toPackageToken = (strategyName) => strategyName.replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").replace(/([a-z\d])([A-Z])/g, "$1-$2").toLowerCase();
4021
+ var getStrategyPackageName = (strategyName) => strategyName === "TrendLine" || strategyName === "ReverseTrendLine" ? "@tradejs/strategy-trend-line" : `@tradejs/strategy-${toPackageToken(strategyName)}`;
4022
+ var gateFingerprintSpecifiers = (strategyName) => [
4023
+ getStrategyPackageName(strategyName),
4024
+ "@tradejs/strategy-kit/ai-gate",
4025
+ "@tradejs/node/ai",
4026
+ "@tradejs/core/strategies"
4018
4027
  ];
4019
4028
  var resolveStrategyGateFingerprint = async ({
4020
4029
  projectRoot,
4021
4030
  strategyName,
4022
4031
  gitSha
4023
4032
  }) => {
4024
- const candidates = await Promise.all(
4025
- gateFingerprintRelativePaths(strategyName).map(async (relativePath) => {
4026
- const content = await import_promises.default.readFile(import_node_path.default.join(projectRoot, relativePath)).catch(() => null);
4027
- return content == null ? null : { relativePath, content };
4033
+ const projectManifestPath = import_node_path.default.join(projectRoot, "package.json");
4034
+ const projectExists = await import_promises.default.access(projectManifestPath).then(() => true).catch(() => false);
4035
+ const requireFromProject = projectExists ? (0, import_node_module.createRequire)(projectManifestPath) : null;
4036
+ const candidates = requireFromProject ? await Promise.all(
4037
+ gateFingerprintSpecifiers(strategyName).map(async (specifier) => {
4038
+ let resolvedPath;
4039
+ try {
4040
+ resolvedPath = requireFromProject.resolve(specifier);
4041
+ } catch {
4042
+ return null;
4043
+ }
4044
+ const content = await import_promises.default.readFile(resolvedPath).catch(() => null);
4045
+ return content == null ? null : { specifier, content };
4028
4046
  })
4029
- );
4047
+ ) : [];
4030
4048
  const sourceEntries = candidates.filter(
4031
4049
  (entry) => entry != null
4032
4050
  );
@@ -4034,7 +4052,7 @@ var resolveStrategyGateFingerprint = async ({
4034
4052
  hash.update(strategyName);
4035
4053
  if (sourceEntries.length) {
4036
4054
  for (const entry of sourceEntries) {
4037
- hash.update(entry.relativePath);
4055
+ hash.update(entry.specifier);
4038
4056
  hash.update(entry.content);
4039
4057
  }
4040
4058
  } else {
@@ -4042,7 +4060,7 @@ var resolveStrategyGateFingerprint = async ({
4042
4060
  }
4043
4061
  return {
4044
4062
  gateFingerprint: hash.digest("hex").slice(0, 16),
4045
- gateFingerprintFiles: sourceEntries.map((entry) => entry.relativePath)
4063
+ gateFingerprintFiles: sourceEntries.map((entry) => entry.specifier)
4046
4064
  };
4047
4065
  };
4048
4066