@alphafox/cli 0.3.5 → 0.3.7
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/README.md +3 -0
- package/dist/catalog/omit.d.ts +3 -1
- package/dist/catalog/omit.js +9 -2
- package/dist/commands/run.js +10 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -1
- package/dist/resolve-symbols/catalog.d.ts +6 -0
- package/dist/resolve-symbols/catalog.js +43 -0
- package/dist/resolve-symbols/exchanges.js +7 -4
- package/dist/resolve-symbols/match.d.ts +4 -3
- package/dist/resolve-symbols/match.js +50 -48
- package/dist/resolve-symbols/parse-args.d.ts +1 -0
- package/dist/resolve-symbols/parse-args.js +20 -3
- package/dist/resolve-symbols/run-command.js +19 -6
- package/dist/resolve-symbols/types.d.ts +14 -0
- package/dist/skills-manifest.json +41 -41
- package/dist/update/notify.d.ts +24 -0
- package/dist/update/notify.js +109 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/account/SKILL.md +1 -1
- package/skills/admin/SKILL.md +1 -1
- package/skills/alphafox/SKILL.md +32 -8
- package/skills/alphafox-shared/SKILL.md +12 -4
- package/skills/auth/SKILL.md +1 -1
- package/skills/engine-backtest/SKILL.md +5 -5
- package/skills/exchange/SKILL.md +1 -1
- package/skills/market/SKILL.md +32 -12
- package/skills/notification/SKILL.md +1 -1
- package/skills/strategy/SKILL.md +17 -15
- package/skills/trading/SKILL.md +37 -7
|
@@ -1,141 +1,141 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"packageName": "@alphafox/cli",
|
|
4
|
-
"packageVersion": "0.3.
|
|
4
|
+
"packageVersion": "0.3.7",
|
|
5
5
|
"contractVersion": "2026-08-13",
|
|
6
|
-
"bundleHash": "
|
|
6
|
+
"bundleHash": "e12e1922538778707e60e931a247ecebb3e028cefeba295f4ca299d8d82d661b",
|
|
7
7
|
"skills": [
|
|
8
8
|
{
|
|
9
9
|
"name": "alphafox",
|
|
10
|
-
"version": "0.3.
|
|
10
|
+
"version": "0.3.7",
|
|
11
11
|
"files": [
|
|
12
12
|
{
|
|
13
13
|
"path": "SKILL.md",
|
|
14
|
-
"sha256": "
|
|
15
|
-
"size":
|
|
14
|
+
"sha256": "2cd53898008075e68afd8ce955b63cf61f2971ef28f6c13c41853b1c5de967c8",
|
|
15
|
+
"size": 3553
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
|
-
"hash": "
|
|
18
|
+
"hash": "d687ecf8cc366e26dcb535bf31a30faceb037f021c818fa24997d144a22d3c20"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"name": "alphafox-account",
|
|
22
|
-
"version": "0.3.
|
|
22
|
+
"version": "0.3.7",
|
|
23
23
|
"files": [
|
|
24
24
|
{
|
|
25
25
|
"path": "SKILL.md",
|
|
26
|
-
"sha256": "
|
|
26
|
+
"sha256": "fc5675dc44494227679994b761ca2e014d36acc207c68e3fb6d833912a7644ee",
|
|
27
27
|
"size": 783
|
|
28
28
|
}
|
|
29
29
|
],
|
|
30
|
-
"hash": "
|
|
30
|
+
"hash": "bc1352e9d352f313f69f5257ba351137778c3ee1d8714d2d80fc39c0824c5cec"
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
"name": "alphafox-admin",
|
|
34
|
-
"version": "0.3.
|
|
34
|
+
"version": "0.3.7",
|
|
35
35
|
"files": [
|
|
36
36
|
{
|
|
37
37
|
"path": "SKILL.md",
|
|
38
|
-
"sha256": "
|
|
38
|
+
"sha256": "6594e6cbfd319a41ae3abf9bf4f8239bb42bc25e6eec295999fe39cd694b2b8b",
|
|
39
39
|
"size": 787
|
|
40
40
|
}
|
|
41
41
|
],
|
|
42
|
-
"hash": "
|
|
42
|
+
"hash": "d6c5573444a020f376d51a73d44f39da9de8ea20bfd160f838b0de01bbb5e798"
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
"name": "alphafox-auth",
|
|
46
|
-
"version": "0.3.
|
|
46
|
+
"version": "0.3.7",
|
|
47
47
|
"files": [
|
|
48
48
|
{
|
|
49
49
|
"path": "SKILL.md",
|
|
50
|
-
"sha256": "
|
|
50
|
+
"sha256": "b7b2694cbcf6e784d89943950435cb34454309cfbe07e383cc028a435dfec77d",
|
|
51
51
|
"size": 1919
|
|
52
52
|
}
|
|
53
53
|
],
|
|
54
|
-
"hash": "
|
|
54
|
+
"hash": "aa7e2a39058660c4c803ed6e1bed94da0559aa943998336d6f0c83d8930a1d9d"
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
57
|
"name": "alphafox-engine-backtest",
|
|
58
|
-
"version": "0.3.
|
|
58
|
+
"version": "0.3.7",
|
|
59
59
|
"files": [
|
|
60
60
|
{
|
|
61
61
|
"path": "SKILL.md",
|
|
62
|
-
"sha256": "
|
|
63
|
-
"size":
|
|
62
|
+
"sha256": "e09e938c9dd90d0be156b2d8bd83ba854c4d1a190a1b4aa575ca67db70184ebc",
|
|
63
|
+
"size": 7584
|
|
64
64
|
}
|
|
65
65
|
],
|
|
66
|
-
"hash": "
|
|
66
|
+
"hash": "91de2131ffde0b9fef16221d5589a8c430ae48ddfc4f2dc781d510b9d4c90532"
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
"name": "alphafox-exchange",
|
|
70
|
-
"version": "0.3.
|
|
70
|
+
"version": "0.3.7",
|
|
71
71
|
"files": [
|
|
72
72
|
{
|
|
73
73
|
"path": "SKILL.md",
|
|
74
|
-
"sha256": "
|
|
74
|
+
"sha256": "53cba327c5507266b4dca7193fad67ba33c0c7bb745be41fd194425b9ef5928e",
|
|
75
75
|
"size": 743
|
|
76
76
|
}
|
|
77
77
|
],
|
|
78
|
-
"hash": "
|
|
78
|
+
"hash": "910f451fc7939926cfbeee27ee72f2aae86fcdd78f343e9f02c30df105ac6480"
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
"name": "alphafox-market",
|
|
82
|
-
"version": "0.3.
|
|
82
|
+
"version": "0.3.7",
|
|
83
83
|
"files": [
|
|
84
84
|
{
|
|
85
85
|
"path": "SKILL.md",
|
|
86
|
-
"sha256": "
|
|
87
|
-
"size":
|
|
86
|
+
"sha256": "6589628478dc9c98c20479a2ffdded4014ce71b9c488dd386a606fef25a37d26",
|
|
87
|
+
"size": 3078
|
|
88
88
|
}
|
|
89
89
|
],
|
|
90
|
-
"hash": "
|
|
90
|
+
"hash": "84d243b7c53c519cba34c8c487ba23eae60bde8440c4dcfff06e20efd63c07fa"
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
"name": "alphafox-notification",
|
|
94
|
-
"version": "0.3.
|
|
94
|
+
"version": "0.3.7",
|
|
95
95
|
"files": [
|
|
96
96
|
{
|
|
97
97
|
"path": "SKILL.md",
|
|
98
|
-
"sha256": "
|
|
98
|
+
"sha256": "8b985ff7f33696eb11427147cd021d32654f525eea54f8098f368e8750a59381",
|
|
99
99
|
"size": 698
|
|
100
100
|
}
|
|
101
101
|
],
|
|
102
|
-
"hash": "
|
|
102
|
+
"hash": "1f316dc3fe251699b3f90102cbc16cb4fbd3a3c5c07b923297c075fe2e73a4b3"
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
"name": "alphafox-shared",
|
|
106
|
-
"version": "0.3.
|
|
106
|
+
"version": "0.3.7",
|
|
107
107
|
"files": [
|
|
108
108
|
{
|
|
109
109
|
"path": "SKILL.md",
|
|
110
|
-
"sha256": "
|
|
111
|
-
"size":
|
|
110
|
+
"sha256": "3aac1ab46a759a2c6748516936f886ec028e680bff7deb3ff1abc51af99ed18a",
|
|
111
|
+
"size": 5163
|
|
112
112
|
}
|
|
113
113
|
],
|
|
114
|
-
"hash": "
|
|
114
|
+
"hash": "72a7255ab23ff7c1adf41b1ff2e22834d1b58ee9e2ccea990c64f9277bf8b0a3"
|
|
115
115
|
},
|
|
116
116
|
{
|
|
117
117
|
"name": "alphafox-strategy",
|
|
118
|
-
"version": "0.3.
|
|
118
|
+
"version": "0.3.7",
|
|
119
119
|
"files": [
|
|
120
120
|
{
|
|
121
121
|
"path": "SKILL.md",
|
|
122
|
-
"sha256": "
|
|
123
|
-
"size":
|
|
122
|
+
"sha256": "1ef2a00dd1c74922a3d0248041813609fc58701e7857bb069cbed511b0c46168",
|
|
123
|
+
"size": 1826
|
|
124
124
|
}
|
|
125
125
|
],
|
|
126
|
-
"hash": "
|
|
126
|
+
"hash": "44c2bf74ff053977f3a8631115ebf868af7cff33856e0c6a4fe55080049c1ae1"
|
|
127
127
|
},
|
|
128
128
|
{
|
|
129
129
|
"name": "alphafox-trading",
|
|
130
|
-
"version": "0.3.
|
|
130
|
+
"version": "0.3.7",
|
|
131
131
|
"files": [
|
|
132
132
|
{
|
|
133
133
|
"path": "SKILL.md",
|
|
134
|
-
"sha256": "
|
|
135
|
-
"size":
|
|
134
|
+
"sha256": "db065fcc272e66d091cfe7469317d7911946f96094f475f64d34d201c392424c",
|
|
135
|
+
"size": 3122
|
|
136
136
|
}
|
|
137
137
|
],
|
|
138
|
-
"hash": "
|
|
138
|
+
"hash": "af36dc51e47ca91cb4a2f5ca78e03e17f003ee47b5354cef42947f401fbe48c0"
|
|
139
139
|
}
|
|
140
140
|
]
|
|
141
141
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const UPDATE_CHECK_INTERVAL_MS: number;
|
|
2
|
+
export interface UpdateCheckState {
|
|
3
|
+
readonly schemaVersion: 1;
|
|
4
|
+
readonly checkedAt: string;
|
|
5
|
+
readonly currentVersion: string;
|
|
6
|
+
readonly latestVersion: string | null;
|
|
7
|
+
readonly updateAvailable: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface UpdateNoticeResult {
|
|
10
|
+
readonly checked: boolean;
|
|
11
|
+
readonly notified: boolean;
|
|
12
|
+
readonly latestVersion: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface UpdateNoticeDeps {
|
|
15
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
16
|
+
readonly currentVersion?: string;
|
|
17
|
+
readonly now?: Date;
|
|
18
|
+
readonly fetchLatest?: () => Promise<string>;
|
|
19
|
+
readonly writeNotice?: (line: string) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare function updateCheckStatePath(env?: NodeJS.ProcessEnv): string;
|
|
22
|
+
export declare function formatUpdateNotice(currentVersion: string, latestVersion: string): string;
|
|
23
|
+
export declare function shouldSkipUpdateCheck(command: string | undefined, env?: NodeJS.ProcessEnv): boolean;
|
|
24
|
+
export declare function maybeNotifyCliUpdate(deps?: UpdateNoticeDeps): Promise<UpdateNoticeResult>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UPDATE_CHECK_INTERVAL_MS = void 0;
|
|
4
|
+
exports.updateCheckStatePath = updateCheckStatePath;
|
|
5
|
+
exports.formatUpdateNotice = formatUpdateNotice;
|
|
6
|
+
exports.shouldSkipUpdateCheck = shouldSkipUpdateCheck;
|
|
7
|
+
exports.maybeNotifyCliUpdate = maybeNotifyCliUpdate;
|
|
8
|
+
const node_fs_1 = require("node:fs");
|
|
9
|
+
const node_path_1 = require("node:path");
|
|
10
|
+
const profiles_1 = require("../config/profiles");
|
|
11
|
+
const exec_1 = require("../install/exec");
|
|
12
|
+
const wizard_1 = require("../install/wizard");
|
|
13
|
+
const version_1 = require("../version");
|
|
14
|
+
exports.UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
15
|
+
const NPM_VIEW_TIMEOUT_MS = 4_000;
|
|
16
|
+
function updateCheckStatePath(env = process.env) {
|
|
17
|
+
return (0, node_path_1.join)((0, profiles_1.defaultConfigDir)(env), "update-check.json");
|
|
18
|
+
}
|
|
19
|
+
function formatUpdateNotice(currentVersion, latestVersion) {
|
|
20
|
+
return `[alphafox] update available: ${currentVersion} -> ${latestVersion}. After the user confirms, run: alphafox update --format json --no-input`;
|
|
21
|
+
}
|
|
22
|
+
function shouldSkipUpdateCheck(command, env = process.env) {
|
|
23
|
+
if (env.ALPHAFOX_SKIP_UPDATE_CHECK === "1")
|
|
24
|
+
return true;
|
|
25
|
+
return command === "update" || command === "install";
|
|
26
|
+
}
|
|
27
|
+
async function maybeNotifyCliUpdate(deps = {}) {
|
|
28
|
+
const env = deps.env ?? process.env;
|
|
29
|
+
const currentVersion = deps.currentVersion ?? version_1.CLI_VERSION;
|
|
30
|
+
const now = deps.now ?? new Date();
|
|
31
|
+
const writeNotice = deps.writeNotice ??
|
|
32
|
+
((line) => {
|
|
33
|
+
process.stderr.write(`${line}\n`);
|
|
34
|
+
});
|
|
35
|
+
const previous = loadUpdateCheckState(updateCheckStatePath(env));
|
|
36
|
+
if (previous &&
|
|
37
|
+
now.getTime() - Date.parse(previous.checkedAt) < exports.UPDATE_CHECK_INTERVAL_MS) {
|
|
38
|
+
return {
|
|
39
|
+
checked: false,
|
|
40
|
+
notified: false,
|
|
41
|
+
latestVersion: previous.latestVersion,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
let latestVersion = null;
|
|
45
|
+
try {
|
|
46
|
+
latestVersion = await (deps.fetchLatest ?? defaultFetchLatest)(env);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
saveUpdateCheckState(updateCheckStatePath(env), {
|
|
50
|
+
schemaVersion: 1,
|
|
51
|
+
checkedAt: now.toISOString(),
|
|
52
|
+
currentVersion,
|
|
53
|
+
latestVersion: previous?.latestVersion ?? null,
|
|
54
|
+
updateAvailable: false,
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
checked: true,
|
|
58
|
+
notified: false,
|
|
59
|
+
latestVersion: previous?.latestVersion ?? null,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const updateAvailable = (0, wizard_1.semverLessThan)(currentVersion, latestVersion);
|
|
63
|
+
saveUpdateCheckState(updateCheckStatePath(env), {
|
|
64
|
+
schemaVersion: 1,
|
|
65
|
+
checkedAt: now.toISOString(),
|
|
66
|
+
currentVersion,
|
|
67
|
+
latestVersion,
|
|
68
|
+
updateAvailable,
|
|
69
|
+
});
|
|
70
|
+
if (updateAvailable) {
|
|
71
|
+
writeNotice(formatUpdateNotice(currentVersion, latestVersion));
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
checked: true,
|
|
75
|
+
notified: updateAvailable,
|
|
76
|
+
latestVersion,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function loadUpdateCheckState(path) {
|
|
80
|
+
if (!(0, node_fs_1.existsSync)(path))
|
|
81
|
+
return null;
|
|
82
|
+
try {
|
|
83
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)(path, "utf8"));
|
|
84
|
+
if (parsed.schemaVersion !== 1 ||
|
|
85
|
+
typeof parsed.checkedAt !== "string" ||
|
|
86
|
+
Number.isNaN(Date.parse(parsed.checkedAt))) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return parsed;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function saveUpdateCheckState(path, state) {
|
|
96
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(path, ".."), { recursive: true });
|
|
97
|
+
(0, node_fs_1.writeFileSync)(path, `${JSON.stringify(state, null, 2)}\n`, { mode: 0o600 });
|
|
98
|
+
}
|
|
99
|
+
async function defaultFetchLatest(env) {
|
|
100
|
+
const runner = (0, exec_1.createDefaultInstallRunner)(env, []);
|
|
101
|
+
const { stdout } = await runner.exec("npm", ["view", version_1.CLI_PACKAGE, "version"], {
|
|
102
|
+
timeoutMs: NPM_VIEW_TIMEOUT_MS,
|
|
103
|
+
});
|
|
104
|
+
const version = stdout.trim();
|
|
105
|
+
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(version)) {
|
|
106
|
+
throw new Error(`invalid npm version: ${version}`);
|
|
107
|
+
}
|
|
108
|
+
return version;
|
|
109
|
+
}
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CLI_CONTRACT_VERSION = exports.CLI_VERSION = exports.CLI_PACKAGE = exports.CLI_NAME = void 0;
|
|
4
4
|
exports.CLI_NAME = "alphafox";
|
|
5
5
|
exports.CLI_PACKAGE = "@alphafox/cli";
|
|
6
|
-
exports.CLI_VERSION = "0.3.
|
|
6
|
+
exports.CLI_VERSION = "0.3.7";
|
|
7
7
|
var operations_1 = require("./catalog/operations");
|
|
8
8
|
Object.defineProperty(exports, "CLI_CONTRACT_VERSION", { enumerable: true, get: function () { return operations_1.CATALOG_VERSION; } });
|
package/package.json
CHANGED
package/skills/account/SKILL.md
CHANGED
package/skills/admin/SKILL.md
CHANGED
package/skills/alphafox/SKILL.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: alphafox
|
|
3
|
-
description: AlphaFox CLI entry router. Use for any AlphaFox request — install, update, login, whoami, 回测, engine backtest, strategy
|
|
4
|
-
version: 0.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. If a CLI command prints `[alphafox] update available`, ask the user「检测到新的版本,是否需要我帮你升级?」and only then run `alphafox update --format json --no-input`. 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.7
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AlphaFox
|
|
@@ -10,7 +10,9 @@ This skill only routes. After choosing a row, **read that skill's `SKILL.md` and
|
|
|
10
10
|
|
|
11
11
|
Also read `alphafox-shared` before any CLI invocation (envelope, auth, risk, schema-first writes). Always `--format json --no-input`. Never `--token`.
|
|
12
12
|
|
|
13
|
-
Human-mentioned tickers go through `alphafox-market` (`alphafox resolve-symbols`) **before** they enter config, backtest, or writes.
|
|
13
|
+
Human-mentioned tickers go through `alphafox-market` (`alphafox resolve-symbols`) **before** they enter config, backtest, or writes. Keep the operator's asset class (美股 → `equity_perp` on `binance_perp_usdt`).
|
|
14
|
+
|
|
15
|
+
A **trader** is a running strategy instance (paper or live), not a person. Creating a strategy means creating a trader.
|
|
14
16
|
|
|
15
17
|
## Route
|
|
16
18
|
|
|
@@ -18,21 +20,43 @@ Human-mentioned tickers go through `alphafox-market` (`alphafox resolve-symbols`
|
|
|
18
20
|
|---|---|
|
|
19
21
|
| Install, update, Skills status/sync, doctor, version, catalog, how to call the CLI | `alphafox-shared` |
|
|
20
22
|
| Login, logout, whoami, profile, staging vs production | `alphafox-auth` |
|
|
21
|
-
|
|
|
23
|
+
| Ticker / 标的 / 美股 / crypto / resolve a misspelled symbol | `alphafox-market` |
|
|
22
24
|
| Engine WASM backtest, experiment, `engine-backtest run`, persist a local run | `alphafox-engine-backtest` |
|
|
23
|
-
| Strategy
|
|
24
|
-
|
|
|
25
|
+
| Strategy types / definitions / validate config (grid, dca, copy, …) | `alphafox-strategy` |
|
|
26
|
+
| Create, list, start, or stop a running strategy (trader), including copy | `alphafox-trading` |
|
|
25
27
|
| Exchange connectors | `alphafox-exchange` |
|
|
26
28
|
| Account, wallet, subscription | `alphafox-account` |
|
|
27
29
|
| Notification channels | `alphafox-notification` |
|
|
28
30
|
| Admin-only operations | `alphafox-admin` |
|
|
29
31
|
|
|
30
|
-
If several rows apply, load **all** of them (typical: `alphafox-shared` + `alphafox-market` + one domain skill).
|
|
32
|
+
If several rows apply, load **all** of them (typical: `alphafox-shared` + `alphafox-market` + one domain skill). “帮我建一个网格/DCA/跟单策略” → `alphafox-strategy` (pick the definition) **and** `alphafox-trading` (create the trader).
|
|
33
|
+
|
|
34
|
+
## Upgrade reminder
|
|
35
|
+
|
|
36
|
+
The CLI may print this on **stderr** at most once every 24 hours:
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
[alphafox] update available: 0.3.6 -> 0.3.7. After the user confirms, run: alphafox update --format json --no-input,
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
If you see that notice (or `updateAvailable: true` from `alphafox update --check`):
|
|
43
|
+
|
|
44
|
+
1. Ask the user: **检测到新的版本,是否需要我帮你升级?**
|
|
45
|
+
2. Wait for an explicit yes. Do not upgrade on your own.
|
|
46
|
+
3. After they confirm:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
alphafox update --format json --no-input
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
4. Tell the user to **restart the AI tool** so the new Skills load.
|
|
53
|
+
|
|
54
|
+
Do not install Skills from GitHub. Details and dry-run / check commands live in `alphafox-shared`.
|
|
31
55
|
|
|
32
56
|
## Do not mix these backtest paths
|
|
33
57
|
|
|
34
58
|
- Local Engine tape + wasm + optional persist → `alphafox-engine-backtest` (`alphafox engine-backtest run`, hyphen).
|
|
35
59
|
- Experiment catalog CRUD → same skill, underscore catalog `engine_backtest.*`.
|
|
36
|
-
-
|
|
60
|
+
- Web `/api/v1/backtests` (`backtests.*`) is **not** a CLI surface. Do not call it via typed commands, `schema`, or `alphafox api`.
|
|
37
61
|
|
|
38
62
|
Ambiguous “帮我回测” → `alphafox-engine-backtest`, after resolving symbols.
|
|
@@ -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.
|
|
4
|
+
version: 0.3.7
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AlphaFox shared Agent contract
|
|
@@ -24,7 +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
|
-
|
|
27
|
+
The CLI checks npm at most once every 24 hours and only prints a notice on
|
|
28
|
+
**stderr**. It never auto-upgrades. If you see
|
|
29
|
+
`[alphafox] update available` (or `updateAvailable: true`), ask the user:
|
|
30
|
+
|
|
31
|
+
**检测到新的版本,是否需要我帮你升级?**
|
|
32
|
+
|
|
33
|
+
Wait for an explicit yes. Then keep CLI and Skills co-versioned:
|
|
28
34
|
|
|
29
35
|
```bash
|
|
30
36
|
alphafox update --check --format json --no-input
|
|
@@ -32,6 +38,8 @@ alphafox update --format json --no-input
|
|
|
32
38
|
alphafox skills status --format json --no-input
|
|
33
39
|
```
|
|
34
40
|
|
|
41
|
+
After a successful `alphafox update`, tell the user to restart the AI tool.
|
|
42
|
+
|
|
35
43
|
Never update AlphaFox Skills independently from GitHub. If `skills status`
|
|
36
44
|
reports local modifications, stop and ask before using
|
|
37
45
|
`alphafox skills sync --force --yes`; the CLI backs up replaced files.
|
|
@@ -68,7 +76,7 @@ Wrong environment / missing permission / missing `--yes`: stop. Do not retry wit
|
|
|
68
76
|
|
|
69
77
|
## Commands
|
|
70
78
|
|
|
71
|
-
User-mentioned tickers (including typos) must be resolved with `alphafox resolve-symbols` before they are written into config. See `skills/market`.
|
|
79
|
+
User-mentioned tickers (including typos) must be resolved with `alphafox resolve-symbols` before they are written into config. See `skills/market`. 美股 are `equity_perp` on `binance_perp_usdt`; do not swap them for a crypto coin.
|
|
72
80
|
|
|
73
81
|
1. Prefer typed catalog: `alphafox schema <operationId>` then invoke domain commands.
|
|
74
82
|
2. Raw escape hatch only for allowlisted facade:
|
|
@@ -96,7 +104,7 @@ Uncataloged writes cannot carry a non-empty body. Find the `operationId` first.
|
|
|
96
104
|
## Risk
|
|
97
105
|
|
|
98
106
|
- `high-risk-write` and uncataloged mutations (`unknown`) require `--yes` (exit code `10` if missing).
|
|
99
|
-
- Prefer `--dry-run` first for trader start/stop, withdrawals, admin writes.
|
|
107
|
+
- Prefer `--dry-run` first for trader create/start/stop, withdrawals, admin writes.
|
|
100
108
|
- Never auto-retry unknown write outcomes.
|
|
101
109
|
- CLI `--yes` is UX only; the server still enforces role, ownership, and scopes.
|
|
102
110
|
|
package/skills/auth/SKILL.md
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
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.
|
|
4
|
+
version: 0.3.7
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Engine Backtest
|
|
8
8
|
|
|
9
9
|
Always `--format json --no-input` (or `--format jsonl` when you need progress). Never `--token`. Tokens live in the OS keychain via `alphafox auth login`.
|
|
10
10
|
|
|
11
|
-
Human-mentioned tickers must be resolved with `alphafox resolve-symbols` (`skills/market`) before they go into `--config`. Use `data.queries[].resolved` only when `status` is `exact`, or `close` after confirming with the human.
|
|
11
|
+
Human-mentioned tickers must be resolved with `alphafox resolve-symbols` (`skills/market`) before they go into `--config`. Use `data.queries[].resolved` only when `status` is `exact`, or `close` after confirming with the human, and only when `assetClass` matches the operator (美股 → `equity_perp`). Local Engine tape is Binance-style USDT-M perps (`binance|okx|bybit|bitget|hyperliquid`), which is the same catalog that lists equity perps. Aster is in the public catalog but is **not** an Engine tape source. Do not rewrite `NVDA/USDT:USDT` into a crypto coin to force a backtest.
|
|
12
12
|
|
|
13
13
|
## Which command
|
|
14
14
|
|
|
15
15
|
| Intent | Use | Do not |
|
|
16
16
|
|---|---|---|
|
|
17
17
|
| Iterate a strategy locally (pull tape + run wasm + optional persist) | `alphafox engine-backtest run` (hyphen, built-in) | Do not treat this as server-side execution of `engine_backtest.experiments.byId.runs.create` |
|
|
18
|
-
| Local parameter search with explicit axes; persist one Sweep after completion | `alphafox engine-backtest sweep` | Never loop `runs.create` per coordinate. Do not call
|
|
18
|
+
| Local parameter search with explicit axes; persist one Sweep after completion | `alphafox engine-backtest sweep` | Never loop `runs.create` per coordinate. Do not call `backtests.*` |
|
|
19
19
|
| Local search with zero writes | `alphafox engine-backtest sweep ... --no-persist` | Do not persist a cancelled or incomplete search |
|
|
20
20
|
| List / get / delete persisted Sweeps | Catalog `engine_backtest.experiments.byId.sweeps.*` | Do not invent a second catalog. Delete is high-risk and needs `--yes` |
|
|
21
21
|
| List / get / create / rename / delete experiments and persisted runs | Catalog `engine_backtest.*` (underscore) | Do not invent a second catalog |
|
|
22
|
-
|
|
|
22
|
+
| Web `/api/v1/backtests` job | — | Not a CLI surface. Do not call `backtests.*` or `/api/v1/backtests` |
|
|
23
23
|
|
|
24
24
|
Read the create-experiment body with `alphafox schema` **before** composing JSON. Do not invent experiment fields. Large create/run/sweep payloads use `--config @file`, never a guessed `--body`.
|
|
25
25
|
|
|
@@ -110,4 +110,4 @@ Owner isolation and 7-day expiry are enforced by the server. Applying a coordina
|
|
|
110
110
|
- `engine_backtest.experiments.byId.sweeps.byId.get`
|
|
111
111
|
- High-risk (not this skill's run/sweep path): `engine_backtest.experiments.byId.update` / `.byId.delete` / `.byId.runs.byId.delete` / `.byId.sweeps.byId.delete`
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
`backtests.*` is not an Engine Sweep or Engine Run surface. Do not call it from this skill.
|
package/skills/exchange/SKILL.md
CHANGED
package/skills/market/SKILL.md
CHANGED
|
@@ -1,33 +1,53 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: alphafox-market
|
|
3
|
-
description: Market data
|
|
4
|
-
version: 0.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.7
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Market
|
|
8
8
|
|
|
9
9
|
Always `--format json --no-input`. Prefer readonly scopes. No mock success if upstream fails.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Asset class first
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Binance US stocks are **equity perps in the same** `binance_perp_usdt` catalog (`NVDA/USDT:USDT`). They are not a second exchange. `symbolMetadata` tags them:
|
|
14
|
+
|
|
15
|
+
| Tag | Meaning |
|
|
16
|
+
|---|---|
|
|
17
|
+
| `assetClass: "equity_perp"` and `isTradFiRwa: true` | US stock perp (NVDA, AAPL, TSLA) |
|
|
18
|
+
| `assetClass: "rwa_perp"` and `isTradFiRwa: true` | TradFi RWA perp (XAU, XAG) |
|
|
19
|
+
| untagged / not TradFi | Crypto perp (BTC, ETH) |
|
|
20
|
+
|
|
21
|
+
| Operator said | Resolve with |
|
|
22
|
+
|---|---|
|
|
23
|
+
| 美股 / US stocks / 持仓 / NVDA the company | `--exchange binance --asset-class equity_perp` |
|
|
24
|
+
| 黄金 / 白银 / RWA | `--exchange binance --asset-class rwa_perp` |
|
|
25
|
+
| BTC / ETH / 加密永续 | `--exchange binance` or `--asset-class crypto` |
|
|
26
|
+
|
|
27
|
+
`NVDA/USDT:USDT` with `equity_perp` **is** the US stock product. Do not replace it with a different crypto base.
|
|
28
|
+
|
|
29
|
+
## Resolve tickers
|
|
30
|
+
|
|
31
|
+
Whenever a human mentions a stock, coin, ticker, or contract — including typos — resolve it **before** putting a symbol into strategy config, backtest, trader settings, or any write.
|
|
14
32
|
|
|
15
33
|
```bash
|
|
16
|
-
alphafox resolve-symbols BTC ETH
|
|
34
|
+
alphafox resolve-symbols BTC ETH --exchange binance --format json --no-input
|
|
35
|
+
alphafox resolve-symbols NVDA AAPL TSLA --exchange binance --asset-class equity_perp --format json --no-input
|
|
17
36
|
```
|
|
18
37
|
|
|
19
38
|
- Default `--exchange` is Binance (`binance_perp_usdt`). Aliases: `binance|okx|bybit|bitget|hyperliquid|aster`.
|
|
20
|
-
- This built-in loads
|
|
21
|
-
- Read `data.queries[]`. `resolved` is a
|
|
39
|
+
- This built-in loads `GET /api/v1/market/symbols?exchange=...` (includes `symbolMetadata`) and matches locally. Do not invent a symbol from memory. Do not pull a second ccxt universe.
|
|
40
|
+
- Read `data.queries[]`. `resolved` is a catalog id such as `NVDA/USDT:USDT` or `BTC/USDT:USDT`. Also read `assetClass` and `isTradFiRwa` on the query and on `matches[]`.
|
|
41
|
+
- `matchCount` is the full hit count; `matches` may be capped by `--limit`.
|
|
22
42
|
|
|
23
43
|
| `status` | Agent action |
|
|
24
44
|
|---|---|
|
|
25
|
-
| `exact` | Use `resolved
|
|
26
|
-
| `close` | One near match already in `resolved`.
|
|
27
|
-
| `ambiguous` | `resolved` is null. Show `matches[].symbol` and ask the human to pick. Do not pick. |
|
|
28
|
-
| `none` | Stop. Ask
|
|
45
|
+
| `exact` | Use `resolved` when `assetClass` matches the operator (美股 → `equity_perp`). |
|
|
46
|
+
| `close` | One near match already in `resolved`. Confirm with the human, and confirm the asset class. |
|
|
47
|
+
| `ambiguous` | `resolved` is null. Show `matches[].symbol` plus `assetClass` and ask the human to pick. Do not pick. |
|
|
48
|
+
| `none` | Stop. Ask for another ticker. Do not invent a symbol and do not swap in a crypto coin. |
|
|
29
49
|
|
|
30
|
-
Do not treat `close` as exact. Do not retry a failed resolve as a different
|
|
50
|
+
Do not treat `close` as exact. Do not retry a failed equity resolve as a different crypto base.
|
|
31
51
|
|
|
32
52
|
Raw catalog dump (no matching):
|
|
33
53
|
|