@alphafox/cli 0.3.12 → 0.3.14

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.
Files changed (36) hide show
  1. package/README.md +26 -0
  2. package/dist/engine-backtest/activity.d.ts +60 -0
  3. package/dist/engine-backtest/activity.js +215 -0
  4. package/dist/engine-backtest/dca-first-order-amount-compat.d.ts +7 -0
  5. package/dist/engine-backtest/dca-first-order-amount-compat.js +71 -0
  6. package/dist/engine-backtest/load-config.d.ts +6 -2
  7. package/dist/engine-backtest/load-config.js +23 -0
  8. package/dist/engine-backtest/persist.d.ts +3 -0
  9. package/dist/engine-backtest/persist.js +22 -1
  10. package/dist/engine-backtest/prepared-tape.d.ts +10 -0
  11. package/dist/engine-backtest/prepared-tape.js +136 -0
  12. package/dist/engine-backtest/result-attribution.d.ts +35 -0
  13. package/dist/engine-backtest/result-attribution.js +156 -0
  14. package/dist/engine-backtest/run-command.js +21 -13
  15. package/dist/engine-backtest/sweep-command.d.ts +2 -2
  16. package/dist/engine-backtest/sweep-command.js +70 -51
  17. package/dist/engine-backtest/types.d.ts +18 -2
  18. package/dist/skills-manifest.json +42 -42
  19. package/dist/version.d.ts +1 -1
  20. package/dist/version.js +1 -1
  21. package/docs/alphafox-cli-installation-guide.md +16 -0
  22. package/docs/release-supply-chain.md +4 -4
  23. package/package.json +2 -1
  24. package/scripts/uninstall.cjs +438 -0
  25. package/skills/account/SKILL.md +1 -1
  26. package/skills/admin/SKILL.md +1 -1
  27. package/skills/alphafox/SKILL.md +3 -3
  28. package/skills/alphafox-shared/SKILL.md +8 -1
  29. package/skills/auth/SKILL.md +1 -1
  30. package/skills/cache/SKILL.md +1 -1
  31. package/skills/engine-backtest/SKILL.md +3 -1
  32. package/skills/exchange/SKILL.md +1 -1
  33. package/skills/market/SKILL.md +1 -1
  34. package/skills/notification/SKILL.md +1 -1
  35. package/skills/strategy/SKILL.md +17 -11
  36. package/skills/trading/SKILL.md +1 -1
@@ -0,0 +1,438 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawnSync } = require("node:child_process");
5
+ const fs = require("node:fs");
6
+ const os = require("node:os");
7
+ const path = require("node:path");
8
+ const readline = require("node:readline/promises");
9
+
10
+ const CLI_PACKAGE = "@alphafox/cli";
11
+ const PROFILES = Object.freeze(["production", "staging", "local"]);
12
+ const NPM_TIMEOUT_MS = 120_000;
13
+ const KEYCHAIN_TIMEOUT_MS = 10_000;
14
+ const USAGE_EXIT = 64;
15
+ const UNINSTALL_RAW_URL =
16
+ "https://raw.githubusercontent.com/alphafoxai/alphafox-cli/main/scripts/uninstall.cjs";
17
+ const UNINSTALL_CURL = `curl -fsSL ${UNINSTALL_RAW_URL} | node -- --yes`;
18
+ const UNINSTALL_DRY_RUN = `curl -fsSL ${UNINSTALL_RAW_URL} | node -- --dry-run`;
19
+
20
+ function parseUninstallArgs(argv) {
21
+ let dryRun = false;
22
+ let yes = false;
23
+ let help = false;
24
+ const unknown = [];
25
+ for (const arg of argv.slice(1)) {
26
+ if (isLauncherArg(arg)) continue;
27
+ if (arg === "--dry-run") dryRun = true;
28
+ else if (arg === "--yes" || arg === "-y") yes = true;
29
+ else if (arg === "--help" || arg === "-h") help = true;
30
+ else unknown.push(arg);
31
+ }
32
+ return { dryRun, yes, help, unknown };
33
+ }
34
+
35
+ function isLauncherArg(arg) {
36
+ return (
37
+ arg === "-" ||
38
+ arg === "--" ||
39
+ arg.endsWith("uninstall.cjs") ||
40
+ arg.endsWith("uninstall.mjs")
41
+ );
42
+ }
43
+
44
+ function uninstallHelpText() {
45
+ return [
46
+ "卸载 AlphaFox CLI、Agent Skills、本机配置、登录凭据和回测缓存。",
47
+ "",
48
+ "用法:",
49
+ ` ${UNINSTALL_CURL}`,
50
+ ` ${UNINSTALL_DRY_RUN}`,
51
+ " node scripts/uninstall.cjs [--dry-run|--yes]",
52
+ "",
53
+ "不会删除服务器上的策略实例或账户数据。完成后请重启 AI 工具。",
54
+ ].join("\n");
55
+ }
56
+
57
+ function homeDir(env) {
58
+ return env.ALPHAFOX_AGENT_HOME?.trim() || os.homedir();
59
+ }
60
+
61
+ function isAlphafoxSkillName(name) {
62
+ return name === "alphafox" || name.startsWith("alphafox-");
63
+ }
64
+
65
+ function readSkillName(skillMd) {
66
+ try {
67
+ const match = fs.readFileSync(skillMd, "utf8").match(
68
+ /^name:\s*["']?([^"'\s]+)["']?\s*$/m
69
+ );
70
+ return match?.[1] ?? null;
71
+ } catch {
72
+ return null;
73
+ }
74
+ }
75
+
76
+ function lexists(target) {
77
+ try {
78
+ fs.lstatSync(target);
79
+ return true;
80
+ } catch {
81
+ return false;
82
+ }
83
+ }
84
+
85
+ function isAlphafoxSkillDir(target) {
86
+ if (isAlphafoxSkillName(path.basename(target))) return true;
87
+ const name = readSkillName(path.join(target, "SKILL.md"));
88
+ return name != null && isAlphafoxSkillName(name);
89
+ }
90
+
91
+ function skillRoots(env) {
92
+ const home = homeDir(env);
93
+ const claudeHome = env.CLAUDE_CONFIG_DIR?.trim() || path.join(home, ".claude");
94
+ const codexHome = env.CODEX_HOME?.trim() || path.join(home, ".codex");
95
+ return [
96
+ env.ALPHAFOX_SKILLS_DIR?.trim() || path.join(home, ".agents", "skills"),
97
+ path.join(claudeHome, "skills"),
98
+ path.join(home, ".cursor", "skills"),
99
+ path.join(codexHome, "skills"),
100
+ path.join(home, ".grok", "skills"),
101
+ ];
102
+ }
103
+
104
+ function configDir(env) {
105
+ return env.ALPHAFOX_CONFIG_DIR?.trim() || path.join(homeDir(env), ".config", "alphafox");
106
+ }
107
+
108
+ function tapeCacheDir(env) {
109
+ return (
110
+ env.ALPHAFOX_TAPE_CACHE_DIR?.trim() ||
111
+ path.join(homeDir(env), ".alphafox", "cache", "engine-backtest")
112
+ );
113
+ }
114
+
115
+ function runtimeCacheDir(env) {
116
+ if (env.ALPHAFOX_BACKTEST_RUNTIME_CACHE_DIR?.trim()) {
117
+ return env.ALPHAFOX_BACKTEST_RUNTIME_CACHE_DIR.trim();
118
+ }
119
+ const xdg = env.XDG_CACHE_HOME?.trim();
120
+ return path.join(xdg || path.join(homeDir(env), ".cache"), "alphafox", "engine-backtest");
121
+ }
122
+
123
+ function managedPath(target, env) {
124
+ const resolved = path.resolve(target);
125
+ const home = path.resolve(homeDir(env));
126
+ const roots = [
127
+ home,
128
+ env.ALPHAFOX_SKILLS_DIR,
129
+ env.ALPHAFOX_CONFIG_DIR,
130
+ env.ALPHAFOX_TAPE_CACHE_DIR,
131
+ env.ALPHAFOX_BACKTEST_RUNTIME_CACHE_DIR,
132
+ env.XDG_CACHE_HOME,
133
+ env.CLAUDE_CONFIG_DIR,
134
+ env.CODEX_HOME,
135
+ ]
136
+ .filter(Boolean)
137
+ .map((root) => path.resolve(root));
138
+ if (resolved === home || resolved === path.parse(resolved).root) return false;
139
+ return roots.some(
140
+ (root) => resolved === root || resolved.startsWith(root + path.sep)
141
+ );
142
+ }
143
+
144
+ function assertRemovable(target, env) {
145
+ const resolved = path.resolve(target);
146
+ if (!managedPath(resolved, env)) {
147
+ throw Object.assign(new Error(`Refusing to remove unmanaged path ${resolved}`), {
148
+ type: "usage",
149
+ subtype: "uninstall_path_unsafe",
150
+ });
151
+ }
152
+ return resolved;
153
+ }
154
+
155
+ function collectSkillPaths(env) {
156
+ const found = [];
157
+ for (const root of skillRoots(env)) {
158
+ if (!lexists(root)) continue;
159
+ let entries;
160
+ try {
161
+ entries = fs.readdirSync(root, { withFileTypes: true });
162
+ } catch {
163
+ continue;
164
+ }
165
+ for (const entry of entries) {
166
+ if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
167
+ const target = path.join(root, entry.name);
168
+ if (isAlphafoxSkillDir(target)) found.push(target);
169
+ }
170
+ }
171
+ return found;
172
+ }
173
+
174
+ function collectDirPaths(env) {
175
+ const tape = path.resolve(tapeCacheDir(env));
176
+ const runtime = path.resolve(runtimeCacheDir(env));
177
+ const runtimeRoot =
178
+ path.basename(runtime) === "engine-backtest"
179
+ ? path.dirname(runtime)
180
+ : runtime;
181
+ return [configDir(env), tape, runtimeRoot];
182
+ }
183
+
184
+ function buildUninstallPlan(env = process.env) {
185
+ const paths = [...collectSkillPaths(env), ...collectDirPaths(env)]
186
+ .map((target) => path.resolve(target))
187
+ .filter((target, index, all) => all.indexOf(target) === index)
188
+ .filter((target) => lexists(target))
189
+ .map((target) => ({ kind: "path", path: assertRemovable(target, env) }));
190
+ return [
191
+ ...paths,
192
+ ...PROFILES.map((profile) => ({ kind: "keychain", profile })),
193
+ { kind: "npm", package: CLI_PACKAGE },
194
+ ];
195
+ }
196
+
197
+ function rmdirIfEmpty(dir) {
198
+ try {
199
+ fs.rmdirSync(dir);
200
+ } catch (err) {
201
+ if (err && (err.code === "ENOENT" || err.code === "ENOTEMPTY")) return;
202
+ throw err;
203
+ }
204
+ }
205
+
206
+ function pruneEmptyParents(target, env) {
207
+ const home = path.resolve(homeDir(env));
208
+ let current = path.dirname(path.resolve(target));
209
+ while (current !== home && current !== path.parse(current).root) {
210
+ const base = path.basename(current);
211
+ const parentName = path.basename(path.dirname(current));
212
+ const alphafoxCache = base === "cache" && parentName === ".alphafox";
213
+ if (base !== "alphafox" && base !== ".alphafox" && !alphafoxCache) break;
214
+ rmdirIfEmpty(current);
215
+ current = path.dirname(current);
216
+ }
217
+ }
218
+
219
+ function defaultRunCommand(command, args, options = {}) {
220
+ const timeout = options.timeoutMs ?? NPM_TIMEOUT_MS;
221
+ const env = options.env ?? process.env;
222
+ const platform = options.platform ?? process.platform;
223
+ const file = platform === "win32" ? "cmd.exe" : command;
224
+ const argv = platform === "win32" ? ["/c", command, ...args] : args;
225
+ const result = spawnSync(file, argv, {
226
+ encoding: "utf8",
227
+ env: { ...process.env, ...env },
228
+ timeout,
229
+ stdio: ["ignore", "pipe", "pipe"],
230
+ });
231
+ return {
232
+ status: result.status,
233
+ stdout: result.stdout ?? "",
234
+ stderr: result.stderr ?? "",
235
+ error: result.error,
236
+ };
237
+ }
238
+
239
+ function keychainPlatform(env) {
240
+ const raw = env.ALPHAFOX_KEYCHAIN_PLATFORM?.trim();
241
+ if (raw === "darwin" || raw === "linux" || raw === "win32") return raw;
242
+ return process.platform;
243
+ }
244
+
245
+ function keychainDeleteArgs(profile, env) {
246
+ const platform = keychainPlatform(env);
247
+ const service = `alphafox-cli.${profile}`;
248
+ if (platform === "darwin") {
249
+ return {
250
+ command: "security",
251
+ args: ["delete-generic-password", "-s", service, "-a", "oauth-tokens"],
252
+ };
253
+ }
254
+ if (platform === "linux") {
255
+ return {
256
+ command: env.ALPHAFOX_SECRET_TOOL?.trim() || "secret-tool",
257
+ args: ["clear", "service", service, "account", "oauth-tokens"],
258
+ };
259
+ }
260
+ return {
261
+ command: "cmdkey",
262
+ args: [`/delete:alphafox-cli/${profile}/oauth-tokens`],
263
+ };
264
+ }
265
+
266
+ function isMissingSecret(result) {
267
+ if (result.status === 0) return false;
268
+ const text = `${result.stdout}\n${result.stderr}`.toLowerCase();
269
+ return (
270
+ result.status === 44 ||
271
+ text.includes("could not be found") ||
272
+ text.includes("not found") ||
273
+ text.includes("no such") ||
274
+ text.includes("cannot find")
275
+ );
276
+ }
277
+
278
+ function applyPath(item, env) {
279
+ fs.rmSync(item.path, { recursive: true, force: true });
280
+ pruneEmptyParents(item.path, env);
281
+ }
282
+
283
+ function applyKeychain(item, env, runCommand) {
284
+ const spec = keychainDeleteArgs(item.profile, env);
285
+ const result = runCommand(spec.command, spec.args, {
286
+ env,
287
+ timeoutMs: KEYCHAIN_TIMEOUT_MS,
288
+ });
289
+ if (result.error && result.error.code === "ENOENT") return "skipped";
290
+ if (result.status === 0) return "removed";
291
+ if (isMissingSecret(result)) return "skipped";
292
+ throw new Error(
293
+ `删除 ${item.profile} 凭据失败:${result.stderr.trim() || result.error || result.status}`
294
+ );
295
+ }
296
+
297
+ function applyNpm(env, runCommand) {
298
+ const result = runCommand("npm", ["uninstall", "-g", CLI_PACKAGE], {
299
+ env,
300
+ timeoutMs: NPM_TIMEOUT_MS,
301
+ });
302
+ if (result.status === 0 && !result.error) return;
303
+ throw new Error(
304
+ `npm uninstall -g ${CLI_PACKAGE} 失败:${(result.stderr || result.stdout).trim() || result.error || result.status}`
305
+ );
306
+ }
307
+
308
+ async function confirmUninstall(confirm, isTty) {
309
+ if (typeof confirm === "function") return confirm();
310
+ if (!isTty()) return null;
311
+ const rl = readline.createInterface({
312
+ input: process.stdin,
313
+ output: process.stderr,
314
+ });
315
+ try {
316
+ const answer = await rl.question(
317
+ "将卸载全局 @alphafox/cli、本机 Agent Skills、配置、登录凭据和回测缓存。继续? [Y/n] "
318
+ );
319
+ const token = answer.trim().toLowerCase();
320
+ return token === "" || token === "y" || token === "yes" || token === "是" || token === "好";
321
+ } finally {
322
+ rl.close();
323
+ }
324
+ }
325
+
326
+ function describeItem(item) {
327
+ if (item.kind === "path") return item.path;
328
+ if (item.kind === "keychain") return `keychain:${item.profile}`;
329
+ return `npm uninstall -g ${item.package}`;
330
+ }
331
+
332
+ function applyItem(item, env, runCommand, log) {
333
+ if (item.kind === "path") {
334
+ applyPath(item, env);
335
+ log(`已删除 ${item.path}`);
336
+ return describeItem(item);
337
+ }
338
+ if (item.kind === "keychain") {
339
+ if (applyKeychain(item, env, runCommand) !== "removed") return null;
340
+ log(`已删除 ${item.profile} 登录凭据`);
341
+ return describeItem(item);
342
+ }
343
+ applyNpm(env, runCommand);
344
+ log(`已卸载 ${CLI_PACKAGE}`);
345
+ return describeItem(item);
346
+ }
347
+
348
+ function usageError(error, hint) {
349
+ return { ok: false, exitCode: USAGE_EXIT, error, hint, plan: [], removed: [] };
350
+ }
351
+
352
+ async function approveUninstall(flags, input, isTty, log) {
353
+ if (flags.yes) return { ok: true };
354
+ const approved = await confirmUninstall(input.confirm, isTty);
355
+ if (approved === true) return { ok: true };
356
+ if (approved === false) {
357
+ log("已取消。");
358
+ return { ok: true, cancelled: true, plan: [], removed: [] };
359
+ }
360
+ return usageError("非交互卸载需要 --yes。", UNINSTALL_CURL);
361
+ }
362
+
363
+ async function runUninstall(input = {}) {
364
+ const env = input.env ?? process.env;
365
+ const flags = input.flags ?? parseUninstallArgs(process.argv);
366
+ const log = input.log ?? ((message) => process.stderr.write(`${message}\n`));
367
+ const runCommand = input.runCommand ?? defaultRunCommand;
368
+ const isTty =
369
+ input.isTty ?? (() => Boolean(process.stdin.isTTY && process.stderr.isTTY));
370
+
371
+ if (flags.unknown.length > 0) {
372
+ return usageError(
373
+ `未知的 uninstall 参数:${flags.unknown.join(" ")}`,
374
+ "用法:node scripts/uninstall.cjs [--dry-run|--yes]"
375
+ );
376
+ }
377
+ if (flags.help) {
378
+ log(uninstallHelpText());
379
+ return { ok: true, help: true, plan: [], removed: [] };
380
+ }
381
+
382
+ const plan = buildUninstallPlan(env);
383
+ if (flags.dryRun) {
384
+ log("这是 --dry-run,不会真正删除:");
385
+ for (const item of plan) log(` ${describeItem(item)}`);
386
+ return { ok: true, dryRun: true, plan, removed: [] };
387
+ }
388
+
389
+ const approval = await approveUninstall(flags, input, isTty, log);
390
+ if (!approval.ok || approval.cancelled) return approval;
391
+
392
+ const removed = [];
393
+ const errors = [];
394
+ for (const item of plan) {
395
+ try {
396
+ const label = applyItem(item, env, runCommand, log);
397
+ if (label) removed.push(label);
398
+ } catch (err) {
399
+ errors.push(err instanceof Error ? err.message : String(err));
400
+ }
401
+ }
402
+ if (errors.length > 0) return { ok: false, exitCode: 1, plan, removed, errors };
403
+ log("卸载完成。请重启 AI 工具,以便卸载后的 Skills 生效。");
404
+ return { ok: true, plan, removed };
405
+ }
406
+
407
+ async function main() {
408
+ const result = await runUninstall();
409
+ if (result.error) process.stderr.write(`${result.error}\n`);
410
+ if (result.hint) process.stderr.write(`${result.hint}\n`);
411
+ if (result.errors) {
412
+ for (const line of result.errors) process.stderr.write(`${line}\n`);
413
+ }
414
+ process.exit(result.ok ? 0 : (result.exitCode ?? 1));
415
+ }
416
+
417
+ if (require.main === module) {
418
+ main().catch((err) => {
419
+ process.stderr.write(`${err instanceof Error ? err.message : String(err)}\n`);
420
+ process.exit(1);
421
+ });
422
+ }
423
+
424
+ module.exports = {
425
+ CLI_PACKAGE,
426
+ PROFILES,
427
+ UNINSTALL_CURL,
428
+ UNINSTALL_DRY_RUN,
429
+ UNINSTALL_RAW_URL,
430
+ USAGE_EXIT,
431
+ buildUninstallPlan,
432
+ isAlphafoxSkillDir,
433
+ isAlphafoxSkillName,
434
+ parseUninstallArgs,
435
+ runUninstall,
436
+ skillRoots,
437
+ uninstallHelpText,
438
+ };
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: alphafox-account
3
3
  description: Account, wallet, and subscription read paths.
4
- version: 0.3.12
4
+ version: 0.3.14
5
5
  ---
6
6
 
7
7
  # Account / wallet
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: alphafox-admin
3
3
  description: Admin-only operations reusing Web role authorization.
4
- version: 0.3.12
4
+ version: 0.3.14
5
5
  ---
6
6
 
7
7
  # Admin
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: alphafox
3
3
  description: AlphaFox CLI entry router. Use for any AlphaFox request — install, update, login, whoami, 回测, engine backtest, 清理回测缓存 / 历史数据, strategy definitions, create/list/start/stop a running strategy (trader), ticker/标的 resolve (美股 or crypto), market data, exchange connectors, wallet, subscriptions, notifications, or admin. After a successful install and login, present the 新人引导 in this file (Lite square 带单员 + classic strategies). If a CLI command prints `[alphafox] update available`, ask the user「检测到新的版本,是否需要我帮你升级?」and only then run `alphafox update --format json --no-input`. After a large backtest, if tape cache is large, ask「回测下载的历史数据比较大,要不要我帮你清理本地缓存?」then open `alphafox-cache`. Start here, then open the routed domain skill. Do not guess alphafox-engine-backtest vs alphafox-strategy vs alphafox-trading from memory.
4
- version: 0.3.12
4
+ version: 0.3.14
5
5
  ---
6
6
 
7
7
  # AlphaFox
@@ -18,7 +18,7 @@ A **trader** is a running strategy instance (paper or live), not a person. Creat
18
18
 
19
19
  | User intent | Skill |
20
20
  |---|---|
21
- | Install, update, Skills status/sync, doctor, version, catalog, how to call the CLI | `alphafox-shared` |
21
+ | Install, update, uninstall, Skills status/sync, doctor, version, catalog, how to call the CLI | `alphafox-shared` |
22
22
  | 刚安装完 / 新人引导 / 热门带单员 / 经典策略介绍 | this file, **After install** |
23
23
  | Login, logout, whoami, profile, staging vs production | `alphafox-auth` |
24
24
  | Ticker / 标的 / 美股 / crypto / resolve a misspelled symbol | `alphafox-market` |
@@ -41,7 +41,7 @@ If several rows apply, load **all** of them (typical: `alphafox-shared` + `alpha
41
41
  The CLI may print this on **stderr** at most once every 24 hours:
42
42
 
43
43
  ```text
44
- [alphafox] update available: 0.3.11 -> 0.3.12. After the user confirms, run: alphafox update --format json --no-input,
44
+ [alphafox] update available: 0.3.13 -> 0.3.14. After the user confirms, run: alphafox update --format json --no-input,
45
45
  ```
46
46
 
47
47
  If you see that notice (or `updateAvailable: true` from `alphafox update --check`):
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: alphafox-shared
3
3
  description: Shared AlphaFox CLI rules for Agents — auth, profiles, envelopes, risk gates, and public operationIds only.
4
- version: 0.3.12
4
+ version: 0.3.14
5
5
  ---
6
6
 
7
7
  # AlphaFox shared Agent contract
@@ -24,6 +24,13 @@ npx @alphafox/cli version --format json --no-input
24
24
  npx @alphafox/cli doctor --format json --no-input
25
25
  ```
26
26
 
27
+ Uninstall is **not** `alphafox uninstall`. After an explicit user request:
28
+
29
+ ```bash
30
+ curl -fsSL https://raw.githubusercontent.com/alphafoxai/alphafox-cli/main/scripts/uninstall.cjs | node -- --dry-run
31
+ curl -fsSL https://raw.githubusercontent.com/alphafoxai/alphafox-cli/main/scripts/uninstall.cjs | node -- --yes
32
+ ```
33
+
27
34
  After install, `auth status --verify` shows `session: active`, and the AI tool has restarted, follow skill `alphafox` **After install** (Lite square 带单员 + classic strategies). Do not skip that welcome.
28
35
 
29
36
  The CLI checks npm at most once every 24 hours and only prints a notice on
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: alphafox-auth
3
3
  description: Login, status, logout, whoami, and environment isolation for AlphaFox CLI.
4
- version: 0.3.12
4
+ version: 0.3.14
5
5
  ---
6
6
 
7
7
  # Auth Skill
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: alphafox-cache
3
3
  description: Inspect and clean local Engine backtest caches (downloaded OHLCV tape and wasm runtime). Use when the user asks to 清理缓存, free disk, or after a large historical backtest.
4
- version: 0.3.12
4
+ version: 0.3.14
5
5
  ---
6
6
 
7
7
  # Cache
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: alphafox-engine-backtest
3
3
  description: Local Engine WASM backtest (alphafox engine-backtest run|sweep) vs catalog experiment CRUD.
4
- version: 0.3.12
4
+ version: 0.3.14
5
5
  ---
6
6
 
7
7
  # Engine Backtest
@@ -52,6 +52,8 @@ alphafox engine-backtest run \
52
52
  --format jsonl --no-input
53
53
  ```
54
54
 
55
+ `--config` is `{ common, strategy }` (the source file from skill `alphafox-strategy`). It is not the `validate_config` HTTP body `{ configSchemaVersion, config }`.
56
+
55
57
  Also valid: `--from` / `--to` instead of `--range`. `--create-experiment --name "..."` when there is no `--experiment` (needs `strategyDefinitionId` + `strategyDefinitionDisplay` `{zh,en}`; pass `--definition-label-zh` / `--definition-label-en` or the CLI falls back to the definition id). Persisted runs use the account tier from `subscriptions.me.get`; if `--tier` is supplied, it must match. With `--no-persist`, `runs.create` is skipped and `--tier` may simulate `free|pro|pro_max` (default `pro`). `--data-quality` defaults to `basic` (soft gaps finish the run and appear as `coverageNotice`; `prefix_gap` is less severe than `internal_gap`). `--data-quality strict` still fails on any gap. `--replay-timeframe` defaults to `1m` (allowed `1m|3m|5m|15m|30m|1h|4h`); this is the replay/download bar and is merged with plan indicator timeframes so a 4h RSI grid still replays on 1m. `runs.create` is `write`, not `high-risk-write` — do not add `--yes`. Do not update or delete experiments through this command.
56
58
 
57
59
  `--format jsonl` writes one JSON object per progress line (`{event:"progress",stage,fraction}`), then a final `{ok:true,data:{...}}` envelope.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: alphafox-exchange
3
3
  description: Exchange connectors list and connection management via Public API.
4
- version: 0.3.12
4
+ version: 0.3.14
5
5
  ---
6
6
 
7
7
  # Exchange connectors
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: alphafox-market
3
3
  description: Market data and ticker resolution for US equity perps, RWAs, and crypto on the same perp catalog. Use when the user names 美股, NVDA, AAPL, BTC, or any 标的. Keep the operator's asset class via symbolMetadata — do not rewrite NVDA into a crypto coin.
4
- version: 0.3.12
4
+ version: 0.3.14
5
5
  ---
6
6
 
7
7
  # Market
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: alphafox-notification
3
3
  description: Notification channels and subscriptions.
4
- version: 0.3.12
4
+ version: 0.3.14
5
5
  ---
6
6
 
7
7
  # Notification
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: alphafox-strategy
3
3
  description: Strategy definitions — list types, read a definition's contract, and validate config. Creating a running strategy is creating a trader; use alphafox-trading for that. Local Engine backtest is alphafox-engine-backtest.
4
- version: 0.3.12
4
+ version: 0.3.14
5
5
  ---
6
6
 
7
7
  # Strategy definitions
@@ -42,28 +42,34 @@ The human answers knobs. You write JSON.
42
42
 
43
43
  1. Confirm the definition from `byId.get` in the operator's language (what it is, what drives it, how positions change).
44
44
  2. From `strategyConfigSchema` plus common required fields, ask **only** values the human must choose: symbols (resolve first), direction / mode, size, signal source, leverage. Do not walk every optional key.
45
- 3. Write `strategy-config.json` as:
45
+ 3. Write `strategy-config.json` as the trader object:
46
46
 
47
47
  ```json
48
48
  {
49
- "configSchemaVersion": 4,
50
- "config": {
51
- "common": {},
52
- "strategy": {}
53
- }
49
+ "common": {},
50
+ "strategy": {}
54
51
  }
55
52
  ```
56
53
 
57
- `configSchemaVersion` comes from the definition (`configSchemaVersion` on `byId.get` / list). Omit it only when the schema says it is optional; when present it must match the definition. `common` is shared risk / SLTP / execution / market. `strategy` is this type's parameters and decision logic. Do not use top-level `settings`, `policyId`, or `policyParams`.
54
+ `common` is shared risk / SLTP / execution / market. `strategy` is this type's parameters and decision logic. Do not use top-level `settings`, `policyId`, or `policyParams`. `configSchemaVersion` comes from the definition (`byId.get` / list); keep it off this file.
58
55
 
59
- 4. Keys and enums come from the definition schema, not from this skill. Do not ship a default `grid.json` / `dca.json`.
56
+ 4. Keys and enums come from the definition schema, not from this skill. Do not ship a default `grid.json` / `dca.json`. Reuse this source file for `engine-backtest --config` and as `trading.traders.create` `config`.
60
57
 
61
58
  ## Validate config
62
59
 
63
- Read `alphafox schema trading.strategy_definitions.byId.validate_config` first. Catalog `request.body` may look like a free `JsonObject`; still send the envelope above. The server checks the definition schema.
60
+ Read `alphafox schema trading.strategy_definitions.byId.validate_config` first. Catalog `request.body` may look like a free `JsonObject`; still send the HTTP envelope, wrapping the source file do not overwrite `strategy-config.json`:
61
+
62
+ ```json
63
+ {
64
+ "configSchemaVersion": 4,
65
+ "config": { "common": {}, "strategy": {} }
66
+ }
67
+ ```
68
+
69
+ `config` is the contents of `strategy-config.json`. `configSchemaVersion` must match the definition.
64
70
 
65
71
  ```bash
66
- alphafox trading strategy_definitions byId validate_config --definitionId <id> --config @./strategy-config.json --format json --no-input
72
+ alphafox trading strategy_definitions byId validate_config --definitionId <id> --config @./validate-config.json --format json --no-input
67
73
  ```
68
74
 
69
75
  `body_schema` / `body_schema_missing` (exit `64`): re-read the operation schema. Server field-path errors: fix that path. Do not retry with a different envelope.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: alphafox-trading
3
3
  description: Running strategies (traders) — create, list, start, and stop. A trader is a live or paper strategy instance (grid, dca, copy, …), not a person.
4
- version: 0.3.12
4
+ version: 0.3.14
5
5
  ---
6
6
 
7
7
  # Running strategies (traders)