Rewrite built-in strategy store templates for QuickJS
Summary
Converted the built-in strategy source path used by the Strategy Store and clone flow from legacy native-wrapper code to self-contained QuickJS-safe templates.
Why
The Store was seeding cloned strategies from STRATEGY_SOURCES, and that file was generated directly from native index.ts strategy modules. Most of those modules still used the legacy Strategy(manifest, ...) wrapper, which is intentionally rejected by the custom strategy validator.
That meant default strategies looked fine in the Store, but their editable source was not valid for the QuickJS custom runtime.
What changed
- Updated
projects/quantago/scripts/gen-strategy-sources.mjsto prefertemplate.jssources before falling back to nativeindex.tsfiles. - Added self-contained QuickJS templates for every built-in strategy directory.
- Used the
f7657e75-dbfb-4854-9af6-67f538c1362bcustom strategy shape as the blueprint:export default function strategy(input)entrypoint- structured
checks - explicit HOLD reasons
- JSON-safe metadata
- Added Store/catalog metadata so built-in strategies surface as
QuickJS Templateentries in the frontend. - Added a backend regression test to ensure every generated built-in source validates as custom strategy code.
Key implementation detail
The template layer now lives in template.js files so the repo's strict TypeScript program does not try to typecheck raw QuickJS template assets as native modules.
export default function strategy(input) {
const checks = [];
if (!input.candle) {
return { action: 'HOLD', reason: 'missing candle data', checks, metadata: {} };
}
return {
action: 'BUY',
reason: 'Template-specific confluence is aligned',
checks,
metadata: { price: input.candle.close },
};
}
Validation
pnpm typecheckpnpm lint- Passed with existing unrelated warnings elsewhere in the repo
node --import tsx --test tests/custom-strategy-runtime.test.ts- Passed, including the new generated-template regression test
Result
Built-in strategies in the Store now clone into QuickJS-compatible editable templates instead of legacy native wrapper code, while native built-in execution remains unchanged.