@alphafox/cli 0.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/LICENSE +21 -0
- package/README.md +53 -0
- package/bin/alphafox.js +2 -0
- package/dist/auth/pkce.d.ts +13 -0
- package/dist/auth/pkce.js +27 -0
- package/dist/catalog/allowlist.d.ts +9 -0
- package/dist/catalog/allowlist.js +69 -0
- package/dist/catalog/operations.d.ts +34 -0
- package/dist/catalog/operations.js +247 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +18 -0
- package/dist/commands/run.d.ts +14 -0
- package/dist/commands/run.js +855 -0
- package/dist/config/profiles.d.ts +29 -0
- package/dist/config/profiles.js +134 -0
- package/dist/envelope.d.ts +37 -0
- package/dist/envelope.js +78 -0
- package/dist/http/client.d.ts +19 -0
- package/dist/http/client.js +110 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +36 -0
- package/dist/keychain/store.d.ts +19 -0
- package/dist/keychain/store.js +149 -0
- package/dist/safety/confirmation.d.ts +22 -0
- package/dist/safety/confirmation.js +29 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.js +7 -0
- package/docs/e2e-staging.md +24 -0
- package/docs/release-supply-chain.md +49 -0
- package/package.json +60 -0
- package/skills/account/SKILL.md +21 -0
- package/skills/admin/SKILL.md +19 -0
- package/skills/alphafox-shared/SKILL.md +59 -0
- package/skills/auth/SKILL.md +35 -0
- package/skills/exchange/SKILL.md +17 -0
- package/skills/market/SKILL.md +14 -0
- package/skills/notification/SKILL.md +16 -0
- package/skills/strategy/SKILL.md +37 -0
- package/skills/trading/SKILL.md +28 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertHighRiskConfirmation = assertHighRiskConfirmation;
|
|
4
|
+
/**
|
|
5
|
+
* High-risk writes require explicit --yes (or equivalent confirmation token).
|
|
6
|
+
* Server still enforces scopes/roles; this is CLI UX only.
|
|
7
|
+
*/
|
|
8
|
+
function assertHighRiskConfirmation(input) {
|
|
9
|
+
if (input.risk !== "high-risk-write") {
|
|
10
|
+
return { allowed: true };
|
|
11
|
+
}
|
|
12
|
+
if (input.dryRun) {
|
|
13
|
+
return { allowed: true };
|
|
14
|
+
}
|
|
15
|
+
if (input.yes) {
|
|
16
|
+
return { allowed: true };
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
allowed: false,
|
|
20
|
+
error: {
|
|
21
|
+
type: "confirmation",
|
|
22
|
+
subtype: "confirmation_required",
|
|
23
|
+
message: `${input.action} requires confirmation`,
|
|
24
|
+
hint: "add --yes to confirm",
|
|
25
|
+
risk: "high-risk-write",
|
|
26
|
+
action: input.action,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLI_CONTRACT_VERSION = exports.CLI_VERSION = exports.CLI_PACKAGE = exports.CLI_NAME = void 0;
|
|
4
|
+
exports.CLI_NAME = "alphafox";
|
|
5
|
+
exports.CLI_PACKAGE = "@alphafox/cli";
|
|
6
|
+
exports.CLI_VERSION = "0.1.0";
|
|
7
|
+
exports.CLI_CONTRACT_VERSION = "2026-08-11";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Staging E2E checklist (t101364 / t101369)
|
|
2
|
+
|
|
3
|
+
## Scenarios
|
|
4
|
+
|
|
5
|
+
1. Install CLI → `version` / `doctor`
|
|
6
|
+
2. Device Flow split (`--no-wait` + `--device-code`)
|
|
7
|
+
3. `whoami` / `auth status --verify`
|
|
8
|
+
4. Readonly: strategy definitions, connectors, traders
|
|
9
|
+
5. Write: create chat with idempotency
|
|
10
|
+
6. Backtest create → watch stream → cancel
|
|
11
|
+
7. High-risk without `--yes` → exit 10
|
|
12
|
+
8. Logout / revoke
|
|
13
|
+
9. Cross-env token rejection (prod token on staging)
|
|
14
|
+
|
|
15
|
+
## Evidence policy
|
|
16
|
+
|
|
17
|
+
If staging domain/secrets are unavailable in the runner, capture provisioning failure to evidence logs and rely on:
|
|
18
|
+
|
|
19
|
+
- local unit/integration tests of envelope, allowlist, token model, confirmation
|
|
20
|
+
- structural presence of deploy workflow + runbooks
|
|
21
|
+
|
|
22
|
+
**Never fabricate staging success.**
|
|
23
|
+
|
|
24
|
+
Parent Feishu task stays `todo` until human acceptance of staging evidence.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Release: npm, Skills, supply chain (t101375)
|
|
2
|
+
|
|
3
|
+
## Package
|
|
4
|
+
|
|
5
|
+
| Field | Value |
|
|
6
|
+
|-------|--------|
|
|
7
|
+
| Name | `@alphafoxai/cli` |
|
|
8
|
+
| Binary | `alphafox` |
|
|
9
|
+
| Visibility | public npm (org `@alphafoxai`) |
|
|
10
|
+
| Node | LTS ≥ 20 |
|
|
11
|
+
| OS | macOS, Linux, Windows |
|
|
12
|
+
|
|
13
|
+
## Publish rules
|
|
14
|
+
|
|
15
|
+
- Publish **only** from CI on protected tags (`v*`)
|
|
16
|
+
- Prefer npm **trusted publishing / OIDC provenance** — no long-lived npm tokens
|
|
17
|
+
- 2FA required for org owners
|
|
18
|
+
- Package contents: `dist/`, `skills/`, README, docs — **no** secrets, fixtures, private endpoints, or `.env`
|
|
19
|
+
|
|
20
|
+
## Skills distribution
|
|
21
|
+
|
|
22
|
+
- Co-versioned inside the npm package under `skills/`
|
|
23
|
+
- Compatibility: Skills major aligns with CLI major; `contractVersion` must match API or CLI fails closed
|
|
24
|
+
|
|
25
|
+
## Support matrix
|
|
26
|
+
|
|
27
|
+
| Platform | Install | Keychain |
|
|
28
|
+
|----------|---------|----------|
|
|
29
|
+
| macOS | npm global / npx | Keychain Access |
|
|
30
|
+
| Linux | npm global / npx | Secret Service or file fallback 0600 |
|
|
31
|
+
| Windows | npm global / npx | Credential Manager (file fallback until implemented) |
|
|
32
|
+
|
|
33
|
+
## Channels
|
|
34
|
+
|
|
35
|
+
- `latest` — stable
|
|
36
|
+
- `next` — prerelease
|
|
37
|
+
- Deprecation window: ≥ 30 days for breaking contract changes
|
|
38
|
+
|
|
39
|
+
## Rollback
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g @alphafoxai/cli@<previous>
|
|
43
|
+
alphafox version
|
|
44
|
+
alphafox doctor
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## SBOM / audit
|
|
48
|
+
|
|
49
|
+
CI should generate SBOM (e.g. `cyclonedx` / `npm sbom`) and fail on critical vulns in runtime deps.
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alphafox/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Alphafox CLI \u2014 Agent/Human entry for the public Application API.",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"bin": {
|
|
7
|
+
"alphafox": "bin/alphafox.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"bin",
|
|
13
|
+
"dist",
|
|
14
|
+
"skills",
|
|
15
|
+
"README.md",
|
|
16
|
+
"docs",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.build.json && node scripts/postbuild.cjs",
|
|
21
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
22
|
+
"test": "npm run build && node scripts/build-mvp-web-bundle.mjs && tsc -p tsconfig.test.json && node --test dist-test/**/*.test.js",
|
|
23
|
+
"test:mvp": "node scripts/build-mvp-web-bundle.mjs && tsc -p tsconfig.test.json && node --test dist-test/tests/mvp-oauth-web-handlers.test.js",
|
|
24
|
+
"alphafox": "node dist/cli.js",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=20"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/alphafoxai/alphafox-cli.git"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/alphafoxai/alphafox-cli/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/alphafoxai/alphafox-cli#readme",
|
|
38
|
+
"keywords": [
|
|
39
|
+
"alphafox",
|
|
40
|
+
"cli",
|
|
41
|
+
"trading",
|
|
42
|
+
"agent",
|
|
43
|
+
"oauth",
|
|
44
|
+
"device-flow"
|
|
45
|
+
],
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public",
|
|
48
|
+
"registry": "https://registry.npmjs.org/"
|
|
49
|
+
},
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"packageManager": "pnpm@10.33.0",
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"zod": "^4.3.6"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^24.9.1",
|
|
57
|
+
"tsx": "^4.23.12",
|
|
58
|
+
"typescript": "^6.0.2"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: alphafox-account
|
|
3
|
+
description: Account, wallet, and subscription read paths.
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Account / wallet
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
alphafox api GET /api/v1/wallet
|
|
11
|
+
alphafox api GET /api/v1/account/exchange-uids
|
|
12
|
+
alphafox api GET /api/v1/subscriptions/me
|
|
13
|
+
alphafox api GET /api/v1/managed-wallets
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## operationIds
|
|
17
|
+
|
|
18
|
+
- `wallet.get`
|
|
19
|
+
- `account.exchange_uids.list`
|
|
20
|
+
- `subscriptions.me.get`
|
|
21
|
+
- `managed_wallets.list`
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: alphafox-admin
|
|
3
|
+
description: Admin-only operations reusing Web role authorization.
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Admin
|
|
8
|
+
|
|
9
|
+
Requires admin role on the server. CLI confirmation does not grant privilege.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
alphafox api GET /api/v1/admin/users
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
High-risk admin writes: `--dry-run` then `--yes`. Not available to automation (v1 deferred).
|
|
16
|
+
|
|
17
|
+
## operationIds
|
|
18
|
+
|
|
19
|
+
- `admin.users.list`
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: alphafox-shared
|
|
3
|
+
description: Shared Alphafox CLI rules for Agents — auth, profiles, envelopes, risk gates, and public operationIds only.
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Alphafox shared Agent contract
|
|
8
|
+
|
|
9
|
+
## Install / identity
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx @alphafoxai/cli version
|
|
13
|
+
npx @alphafoxai/cli doctor
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- Default profile: `production`. Use `--profile staging|local` explicitly.
|
|
17
|
+
- Tokens: OS keychain only. Never pass `--token`. Never read tokens from config JSON.
|
|
18
|
+
- Automation tokens are **not supported in v1** (interactive Device Flow / PKCE only).
|
|
19
|
+
|
|
20
|
+
## Output
|
|
21
|
+
|
|
22
|
+
Always use:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
alphafox … --format json --no-input
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Parse the JSON envelope: `ok === true` for success. Errors land on **stderr** with `ok: false` and may include HTTP `status` + `requestId`.
|
|
29
|
+
|
|
30
|
+
## Auth
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
alphafox auth login --no-wait
|
|
34
|
+
# show verification_uri to the user, then:
|
|
35
|
+
alphafox auth login --device-code <device_code>
|
|
36
|
+
alphafox auth status --verify
|
|
37
|
+
alphafox whoami
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Commands
|
|
41
|
+
|
|
42
|
+
1. Prefer typed catalog: `alphafox schema <operationId>` then invoke domain commands.
|
|
43
|
+
2. Raw escape hatch only for allowlisted facade:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
alphafox api GET /api/v1/me
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Forbidden: `/backend`, `/control-plane`, `/signal-center`, internal secrets, non-`/api/v1` product routes.
|
|
50
|
+
|
|
51
|
+
## Risk
|
|
52
|
+
|
|
53
|
+
- `high-risk-write` requires `--yes` (exit code `10` if missing).
|
|
54
|
+
- Prefer `--dry-run` first for trader start/stop, withdrawals, admin writes.
|
|
55
|
+
- Never auto-retry unknown write outcomes.
|
|
56
|
+
|
|
57
|
+
## Public operationIds only
|
|
58
|
+
|
|
59
|
+
Skills must reference registry `operationId`s (see `alphafox schema` / `alphafox catalog`). Do not hardcode internal service URLs.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: alphafox-auth
|
|
3
|
+
description: Login, status, logout, whoami, and environment isolation for Alphafox CLI.
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Auth Skill
|
|
8
|
+
|
|
9
|
+
## When to use
|
|
10
|
+
|
|
11
|
+
User needs to sign in, verify session, switch profile, or revoke tokens.
|
|
12
|
+
|
|
13
|
+
## Workflows
|
|
14
|
+
|
|
15
|
+
### Device Flow (headless / Agent)
|
|
16
|
+
|
|
17
|
+
1. `alphafox auth login --no-wait --format json`
|
|
18
|
+
2. Present `verification_uri` / `user_code` to the human.
|
|
19
|
+
3. After approval: `alphafox auth login --device-code <device_code>`
|
|
20
|
+
4. `alphafox whoami` / `alphafox auth status --verify`
|
|
21
|
+
|
|
22
|
+
### Status / logout
|
|
23
|
+
|
|
24
|
+
- `alphafox auth status --verify`
|
|
25
|
+
- `alphafox auth logout` (server revoke + local keychain clear)
|
|
26
|
+
|
|
27
|
+
## Safety
|
|
28
|
+
|
|
29
|
+
- Fail closed on cross-environment tokens (prod token never hits staging).
|
|
30
|
+
- Do not copy refresh tokens into CI (automation deferred — ADR 0004).
|
|
31
|
+
|
|
32
|
+
## operationIds
|
|
33
|
+
|
|
34
|
+
- `me.whoami`
|
|
35
|
+
- Auth AS endpoints under `/api/auth/oauth/*` (not catalog product ops)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: alphafox-exchange
|
|
3
|
+
description: Exchange connectors list and connection management via Public API.
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Exchange connectors
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
alphafox api GET /api/v1/exchange-connectors
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Writes that create/disable connectors may be `high-risk-write` — use `--dry-run` / `--yes`.
|
|
14
|
+
|
|
15
|
+
## operationIds
|
|
16
|
+
|
|
17
|
+
- `exchange_connectors.list`
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: alphafox-market
|
|
3
|
+
description: Market data and spread-radar readonly queries.
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Market
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
alphafox api GET /api/v1/market/symbols
|
|
11
|
+
alphafox api GET /api/v1/spread-radar/pairs
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Prefer readonly scopes. No mock success if upstream fails.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: alphafox-notification
|
|
3
|
+
description: Notification channels and subscriptions.
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Notification
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
alphafox api GET /api/v1/notification/channels
|
|
11
|
+
alphafox api GET /api/v1/notification/subscriptions
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## operationIds
|
|
15
|
+
|
|
16
|
+
- `notification.channels.list`
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: alphafox-strategy
|
|
3
|
+
description: Strategy definitions, chats, and backtests via public operationIds.
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Strategy / Chat / Backtest
|
|
8
|
+
|
|
9
|
+
## Read
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
alphafox schema trading.strategy_definitions.list
|
|
13
|
+
alphafox api GET /api/v1/trading/strategy-definitions
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Write (ordinary)
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
alphafox api POST /api/v1/chats --body '{"strategyGenerationMode":"simple"}'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Requires auth. Sends `Idempotency-Key` when available.
|
|
23
|
+
|
|
24
|
+
## Long-running backtest
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
alphafox api POST /api/v1/backtests --body '{...}'
|
|
28
|
+
alphafox api GET /api/v1/backtests/{backtestId}
|
|
29
|
+
alphafox api GET /api/v1/backtests/{backtestId}/stream
|
|
30
|
+
alphafox api POST /api/v1/backtests/{backtestId}/cancel --body '{}'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## operationIds
|
|
34
|
+
|
|
35
|
+
- `trading.strategy_definitions.list`
|
|
36
|
+
- `chats.create`
|
|
37
|
+
- `backtests.create` / `backtests.byId.get` / `backtests.byId.stream` / `backtests.byId.cancel`
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: alphafox-trading
|
|
3
|
+
description: Traders list and high-risk start/stop with confirmation gates.
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Trading
|
|
8
|
+
|
|
9
|
+
## Read
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
alphafox api GET /api/v1/trading/traders
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## High-risk write
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
alphafox api POST /api/v1/trading/traders/{traderId}/start --body '{}' --dry-run
|
|
19
|
+
alphafox api POST /api/v1/trading/traders/{traderId}/start --body '{}' --yes
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Without `--yes`, CLI exits `10` with `confirmation_required`.
|
|
23
|
+
|
|
24
|
+
## operationIds
|
|
25
|
+
|
|
26
|
+
- `trading.traders.list`
|
|
27
|
+
- `trading.traders.byId.start`
|
|
28
|
+
- `trading.traders.byId.stop`
|