@alphafox/cli 0.1.4 → 0.2.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.
Files changed (50) hide show
  1. package/dist/auth/browser-login.d.ts +30 -0
  2. package/dist/auth/browser-login.js +193 -0
  3. package/dist/auth/loopback-callback.d.ts +32 -0
  4. package/dist/auth/loopback-callback.js +175 -0
  5. package/dist/auth/open-browser.d.ts +15 -0
  6. package/dist/auth/open-browser.js +54 -0
  7. package/dist/auth/refresh.d.ts +27 -2
  8. package/dist/auth/refresh.js +52 -15
  9. package/dist/catalog/allowlist.d.ts +20 -4
  10. package/dist/catalog/allowlist.js +126 -25
  11. package/dist/catalog/command-tree.d.ts +34 -0
  12. package/dist/catalog/command-tree.js +117 -0
  13. package/dist/catalog/compatibility.d.ts +23 -0
  14. package/dist/catalog/compatibility.js +58 -0
  15. package/dist/catalog/generated/registry.json +6137 -0
  16. package/dist/catalog/generated/schemas.json +31036 -0
  17. package/dist/catalog/operations.d.ts +76 -3
  18. package/dist/catalog/operations.js +87 -213
  19. package/dist/commands/run.js +171 -153
  20. package/dist/config/profiles.js +3 -3
  21. package/dist/envelope.d.ts +3 -0
  22. package/dist/envelope.js +43 -3
  23. package/dist/http/client.js +35 -19
  24. package/dist/index.d.ts +12 -5
  25. package/dist/index.js +32 -1
  26. package/dist/keychain/linux-secret-service.d.ts +11 -0
  27. package/dist/keychain/linux-secret-service.js +93 -0
  28. package/dist/keychain/store.d.ts +20 -1
  29. package/dist/keychain/store.js +94 -6
  30. package/dist/keychain/windows-credential.d.ts +13 -0
  31. package/dist/keychain/windows-credential.js +176 -0
  32. package/dist/safety/confirmation.d.ts +10 -3
  33. package/dist/safety/confirmation.js +27 -4
  34. package/dist/version.d.ts +2 -2
  35. package/dist/version.js +3 -2
  36. package/docs/agents/domain.md +51 -0
  37. package/docs/agents/issue-tracker.md +156 -0
  38. package/docs/agents/triage-labels.md +18 -0
  39. package/docs/e2e-staging.md +76 -6
  40. package/docs/release-supply-chain.md +99 -26
  41. package/package.json +4 -2
  42. package/skills/account/SKILL.md +8 -6
  43. package/skills/admin/SKILL.md +9 -4
  44. package/skills/alphafox-shared/SKILL.md +23 -14
  45. package/skills/auth/SKILL.md +21 -6
  46. package/skills/exchange/SKILL.md +10 -3
  47. package/skills/market/SKILL.md +9 -4
  48. package/skills/notification/SKILL.md +8 -3
  49. package/skills/strategy/SKILL.md +15 -9
  50. package/skills/trading/SKILL.md +15 -5
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Embedded capability catalog (co-versioned with CLI).
3
- * Source of truth for full matrix lives in alphafox-contracts + parity-matrix-m0.md.
2
+ * CLI capability catalog generated from `@alphafoxai/contracts/public-api`.
3
+ * Do not hand-edit generated JSON; run `node scripts/generate-catalog.mjs`.
4
4
  */
5
+ import type { CompatibilityRange } from "./compatibility";
5
6
  export interface CatalogOperation {
6
7
  readonly operationId: string;
7
8
  readonly method: string;
@@ -9,26 +10,98 @@ export interface CatalogOperation {
9
10
  readonly role: string;
10
11
  readonly risk: "read" | "write" | "high-risk-write" | string;
11
12
  readonly scopes: readonly string[];
13
+ readonly auth?: string;
12
14
  readonly stream?: boolean;
15
+ readonly file?: boolean;
16
+ readonly pagination?: boolean;
17
+ readonly idempotent?: boolean;
18
+ readonly catchAll?: boolean;
13
19
  readonly mvp?: boolean;
20
+ readonly contractStatus?: string;
21
+ readonly requestBodySchema?: string | null;
22
+ readonly querySchema?: string | null;
23
+ readonly responseSchema?: string;
24
+ readonly errorSchema?: string;
14
25
  readonly description?: string;
15
26
  }
16
- export declare const CATALOG_VERSION = "2026-08-11";
27
+ export interface CatalogSource {
28
+ readonly package: string;
29
+ readonly export: string;
30
+ readonly contractsSha: string;
31
+ readonly registryVersion: string;
32
+ readonly contractVersion: string;
33
+ readonly scannedAt: string;
34
+ readonly totalOperations: number;
35
+ readonly cliOperations: number;
36
+ }
37
+ export interface OperationSchemaDocument {
38
+ readonly operationId: string;
39
+ readonly method: string;
40
+ readonly path: string;
41
+ readonly role: string;
42
+ readonly risk: string;
43
+ readonly auth: string;
44
+ readonly scopes: readonly string[];
45
+ readonly idempotent: boolean;
46
+ readonly pagination: boolean;
47
+ readonly stream: boolean;
48
+ readonly file: boolean;
49
+ readonly contractStatus: string;
50
+ readonly webZodContract: string;
51
+ readonly sharedContractRef: string;
52
+ readonly compatibility: CompatibilityRange;
53
+ readonly request: {
54
+ readonly contentType: string | null;
55
+ readonly path: Record<string, unknown>;
56
+ readonly query: Record<string, unknown> | null;
57
+ readonly body: Record<string, unknown> | null;
58
+ readonly pathParamNames: readonly string[];
59
+ };
60
+ readonly response: {
61
+ readonly contentType: string;
62
+ readonly success: Record<string, unknown>;
63
+ };
64
+ readonly error: {
65
+ readonly contentType: "application/problem+json" | string;
66
+ readonly schema: Record<string, unknown>;
67
+ };
68
+ }
69
+ export declare const CATALOG_SOURCE: CatalogSource;
70
+ export declare const CATALOG_VERSION: string;
17
71
  export declare const CATALOG_OPERATIONS: readonly CatalogOperation[];
72
+ export declare const COMPATIBILITY_RANGE: CompatibilityRange;
73
+ export declare function getCompatibilityRange(): CompatibilityRange;
18
74
  export declare function findCatalogOperation(operationId: string): CatalogOperation | undefined;
75
+ export declare function findCatalogOperationByRoute(method: string, path: string): CatalogOperation | undefined;
76
+ export declare function getOperationSchemaDocument(operationId: string): OperationSchemaDocument | undefined;
77
+ export declare function extractPathParamNames(template: string): string[];
19
78
  export declare function buildCapabilityManifest(): {
20
79
  contractVersion: string;
21
80
  registryVersion: string;
81
+ minCliVersion: string;
82
+ maxCliVersion: string;
83
+ openapi: string;
84
+ source: CatalogSource;
22
85
  operations: {
23
86
  operationId: string;
24
87
  method: string;
25
88
  path: string;
26
89
  role: string;
27
90
  risk: string;
91
+ auth: string;
28
92
  scopes: readonly string[];
29
93
  stream: boolean;
94
+ file: boolean;
95
+ pagination: boolean;
96
+ idempotent: boolean;
30
97
  mvp: boolean;
98
+ contractStatus: string;
99
+ requestBodySchema: string | null;
100
+ querySchema: string | null;
101
+ responseSchema: string;
102
+ errorSchema: string;
31
103
  }[];
32
104
  };
33
105
  /** Resolve path templates like /api/v1/backtests/{backtestId}. */
34
106
  export declare function resolveOperationPath(template: string, params: Record<string, string>): string;
107
+ export declare function checkGeneratedCatalogCompatibility(cliVersion: string): import("./compatibility").CompatibilityResult;
@@ -1,237 +1,105 @@
1
1
  "use strict";
2
2
  /**
3
- * Embedded capability catalog (co-versioned with CLI).
4
- * Source of truth for full matrix lives in alphafox-contracts + parity-matrix-m0.md.
3
+ * CLI capability catalog generated from `@alphafoxai/contracts/public-api`.
4
+ * Do not hand-edit generated JSON; run `node scripts/generate-catalog.mjs`.
5
5
  */
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
6
9
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.CATALOG_OPERATIONS = exports.CATALOG_VERSION = void 0;
10
+ exports.COMPATIBILITY_RANGE = exports.CATALOG_OPERATIONS = exports.CATALOG_VERSION = exports.CATALOG_SOURCE = void 0;
11
+ exports.getCompatibilityRange = getCompatibilityRange;
8
12
  exports.findCatalogOperation = findCatalogOperation;
13
+ exports.findCatalogOperationByRoute = findCatalogOperationByRoute;
14
+ exports.getOperationSchemaDocument = getOperationSchemaDocument;
15
+ exports.extractPathParamNames = extractPathParamNames;
9
16
  exports.buildCapabilityManifest = buildCapabilityManifest;
10
17
  exports.resolveOperationPath = resolveOperationPath;
11
- exports.CATALOG_VERSION = "2026-08-11";
12
- exports.CATALOG_OPERATIONS = [
13
- {
14
- operationId: "meta.get",
15
- method: "GET",
16
- path: "/api/v1/meta",
17
- role: "public",
18
- risk: "read",
19
- scopes: [],
20
- mvp: true,
21
- description: "Environment, commit SHA, contract version",
22
- },
23
- {
24
- operationId: "me.whoami",
25
- method: "GET",
26
- path: "/api/v1/me",
27
- role: "user",
28
- risk: "read",
29
- scopes: ["openid", "profile"],
30
- mvp: true,
31
- description: "Authenticated user identity",
32
- },
33
- {
34
- operationId: "trading.strategy_definitions.list",
35
- method: "GET",
36
- path: "/api/v1/trading/strategy-definitions",
37
- role: "user",
38
- risk: "read",
39
- scopes: ["openid", "profile", "trading:read"],
40
- mvp: true,
41
- },
42
- {
43
- operationId: "exchange_connectors.list",
44
- method: "GET",
45
- path: "/api/v1/exchange-connectors",
46
- role: "user",
47
- risk: "read",
48
- scopes: ["openid", "profile", "exchange-connectors:read"],
49
- mvp: true,
50
- },
51
- {
52
- operationId: "trading.traders.list",
53
- method: "GET",
54
- path: "/api/v1/trading/traders",
55
- role: "user",
56
- risk: "read",
57
- scopes: ["openid", "profile", "trading:read"],
58
- mvp: true,
59
- },
60
- {
61
- operationId: "chats.create",
62
- method: "POST",
63
- path: "/api/v1/chats",
64
- role: "user",
65
- risk: "write",
66
- scopes: ["openid", "profile", "chats:write"],
67
- mvp: true,
68
- },
69
- {
70
- operationId: "backtests.create",
71
- method: "POST",
72
- path: "/api/v1/backtests",
73
- role: "user",
74
- risk: "write",
75
- scopes: ["openid", "profile", "backtests:write"],
76
- mvp: true,
77
- },
78
- {
79
- operationId: "backtests.byId.get",
80
- method: "GET",
81
- path: "/api/v1/backtests/{backtestId}",
82
- role: "user",
83
- risk: "read",
84
- scopes: ["openid", "profile", "backtests:read"],
85
- mvp: true,
86
- },
87
- {
88
- operationId: "backtests.byId.stream",
89
- method: "GET",
90
- path: "/api/v1/backtests/{backtestId}/stream",
91
- role: "user",
92
- risk: "read",
93
- scopes: ["openid", "profile", "backtests:read"],
94
- stream: true,
95
- mvp: true,
96
- },
97
- {
98
- operationId: "backtests.byId.cancel",
99
- method: "POST",
100
- path: "/api/v1/backtests/{backtestId}/cancel",
101
- role: "user",
102
- risk: "write",
103
- scopes: ["openid", "profile", "backtests:write"],
104
- mvp: true,
105
- },
106
- {
107
- operationId: "trading.traders.byId.start",
108
- method: "POST",
109
- path: "/api/v1/trading/traders/{traderId}/start",
110
- role: "user",
111
- risk: "high-risk-write",
112
- scopes: ["openid", "profile", "trading:write", "trading:high-risk"],
113
- },
114
- {
115
- operationId: "trading.traders.byId.stop",
116
- method: "POST",
117
- path: "/api/v1/trading/traders/{traderId}/stop",
118
- role: "user",
119
- risk: "high-risk-write",
120
- scopes: ["openid", "profile", "trading:write", "trading:high-risk"],
121
- },
122
- {
123
- operationId: "wallet.get",
124
- method: "GET",
125
- path: "/api/v1/wallet",
126
- role: "user",
127
- risk: "read",
128
- scopes: ["openid", "profile", "wallet:read"],
129
- },
130
- {
131
- operationId: "notification.channels.list",
132
- method: "GET",
133
- path: "/api/v1/notification/channels",
134
- role: "user",
135
- risk: "read",
136
- scopes: ["openid", "profile", "notification:read"],
137
- },
138
- {
139
- operationId: "account.exchange_uids.list",
140
- method: "GET",
141
- path: "/api/v1/account/exchange-uids",
142
- role: "user",
143
- risk: "read",
144
- scopes: ["openid", "profile", "account:read"],
145
- },
146
- {
147
- operationId: "subscriptions.me.get",
148
- method: "GET",
149
- path: "/api/v1/subscriptions/me",
150
- role: "user",
151
- risk: "read",
152
- scopes: ["openid", "profile", "subscriptions:read"],
153
- },
154
- {
155
- operationId: "managed_wallets.list",
156
- method: "GET",
157
- path: "/api/v1/managed-wallets",
158
- role: "user",
159
- risk: "read",
160
- scopes: ["openid", "profile", "managed-wallets:read"],
161
- },
162
- {
163
- operationId: "strategy_plaza.publications.list",
164
- method: "GET",
165
- path: "/api/v1/strategy-plaza/publications",
166
- role: "user",
167
- risk: "read",
168
- scopes: ["openid", "profile", "strategy-plaza:read"],
169
- },
170
- {
171
- operationId: "spread_radar.pairs.list",
172
- method: "GET",
173
- path: "/api/v1/spread-radar/pairs",
174
- role: "user",
175
- risk: "read",
176
- scopes: ["openid", "profile", "spread-radar:read"],
177
- },
178
- {
179
- operationId: "trader_dna.report.get",
180
- method: "GET",
181
- path: "/api/v1/trader-dna/report",
182
- role: "user",
183
- risk: "read",
184
- scopes: ["openid", "profile", "trader-dna:read"],
185
- },
186
- {
187
- operationId: "platform_statistics.get",
188
- method: "GET",
189
- path: "/api/v1/platform-statistics",
190
- role: "user",
191
- risk: "read",
192
- scopes: ["openid", "profile", "platform-statistics:read"],
193
- },
194
- {
195
- operationId: "asr.transcribe",
196
- method: "POST",
197
- path: "/api/v1/asr/transcribe",
198
- role: "user",
199
- risk: "write",
200
- scopes: ["openid", "profile", "asr:write"],
201
- },
202
- {
203
- operationId: "lite.catalog_config.get",
204
- method: "GET",
205
- path: "/api/v1/lite/catalog-config",
206
- role: "user",
207
- risk: "read",
208
- scopes: ["openid", "profile", "lite:read"],
209
- },
210
- {
211
- operationId: "admin.users.list",
212
- method: "GET",
213
- path: "/api/v1/admin/users",
214
- role: "admin",
215
- risk: "read",
216
- scopes: ["openid", "profile", "admin:read"],
217
- },
218
- ];
18
+ exports.checkGeneratedCatalogCompatibility = checkGeneratedCatalogCompatibility;
19
+ const compatibility_1 = require("./compatibility");
20
+ const registry_json_1 = __importDefault(require("./generated/registry.json"));
21
+ const schemas_json_1 = __importDefault(require("./generated/schemas.json"));
22
+ const generated = registry_json_1.default;
23
+ const generatedSchemas = schemas_json_1.default;
24
+ exports.CATALOG_SOURCE = generated.source;
25
+ exports.CATALOG_VERSION = generated.compatibility.contractVersion;
26
+ exports.CATALOG_OPERATIONS = generated.operations;
27
+ exports.COMPATIBILITY_RANGE = generated.compatibility;
28
+ function getCompatibilityRange() {
29
+ return exports.COMPATIBILITY_RANGE;
30
+ }
219
31
  function findCatalogOperation(operationId) {
220
32
  return exports.CATALOG_OPERATIONS.find((op) => op.operationId === operationId);
221
33
  }
34
+ function findCatalogOperationByRoute(method, path) {
35
+ const verb = method.toUpperCase();
36
+ return exports.CATALOG_OPERATIONS.find((op) => op.method.toUpperCase() === verb &&
37
+ pathTemplateMatchesOp(op.path, path, Boolean(op.catchAll)));
38
+ }
39
+ function pathTemplateMatchesOp(template, actual, catchAll) {
40
+ const t = template.split("/").filter(Boolean);
41
+ const a = actual.split("/").filter(Boolean);
42
+ if (catchAll) {
43
+ if (a.length < t.length)
44
+ return false;
45
+ for (let i = 0; i < t.length; i += 1) {
46
+ const seg = t[i];
47
+ if (seg.startsWith("{") && seg.endsWith("}"))
48
+ continue;
49
+ if (seg !== a[i])
50
+ return false;
51
+ }
52
+ return true;
53
+ }
54
+ if (t.length !== a.length)
55
+ return false;
56
+ for (let i = 0; i < t.length; i += 1) {
57
+ const seg = t[i];
58
+ if (seg.startsWith("{") && seg.endsWith("}"))
59
+ continue;
60
+ if (seg !== a[i])
61
+ return false;
62
+ }
63
+ return true;
64
+ }
65
+ function getOperationSchemaDocument(operationId) {
66
+ return generatedSchemas[operationId];
67
+ }
68
+ function extractPathParamNames(template) {
69
+ const names = [];
70
+ const re = /\{([^}]+)\}/g;
71
+ let m;
72
+ while ((m = re.exec(template))) {
73
+ names.push(m[1]);
74
+ }
75
+ return names;
76
+ }
222
77
  function buildCapabilityManifest() {
223
78
  return {
224
- contractVersion: exports.CATALOG_VERSION,
225
- registryVersion: "1.0.0",
79
+ contractVersion: exports.COMPATIBILITY_RANGE.contractVersion,
80
+ registryVersion: exports.COMPATIBILITY_RANGE.registryVersion,
81
+ minCliVersion: exports.COMPATIBILITY_RANGE.minCliVersion,
82
+ maxCliVersion: exports.COMPATIBILITY_RANGE.maxCliVersion,
83
+ openapi: exports.COMPATIBILITY_RANGE.openapi,
84
+ source: exports.CATALOG_SOURCE,
226
85
  operations: exports.CATALOG_OPERATIONS.map((op) => ({
227
86
  operationId: op.operationId,
228
87
  method: op.method,
229
88
  path: op.path,
230
89
  role: op.role,
231
90
  risk: op.risk,
91
+ auth: op.auth ?? "bearer",
232
92
  scopes: op.scopes,
233
93
  stream: Boolean(op.stream),
94
+ file: Boolean(op.file),
95
+ pagination: Boolean(op.pagination),
96
+ idempotent: Boolean(op.idempotent),
234
97
  mvp: Boolean(op.mvp),
98
+ contractStatus: op.contractStatus ?? "envelope",
99
+ requestBodySchema: op.requestBodySchema ?? null,
100
+ querySchema: op.querySchema ?? null,
101
+ responseSchema: op.responseSchema ?? "JsonValue",
102
+ errorSchema: op.errorSchema ?? "ProblemDetails",
235
103
  })),
236
104
  };
237
105
  }
@@ -245,3 +113,9 @@ function resolveOperationPath(template, params) {
245
113
  return encodeURIComponent(value);
246
114
  });
247
115
  }
116
+ function checkGeneratedCatalogCompatibility(cliVersion) {
117
+ return (0, compatibility_1.checkCliCompatibility)({
118
+ cliVersion,
119
+ contractVersion: exports.COMPATIBILITY_RANGE.contractVersion,
120
+ }, exports.COMPATIBILITY_RANGE);
121
+ }