@optima-chat/dev-skills 0.9.2 → 0.9.3
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/bin/helpers/billing-http.ts +11 -5
- package/bin/helpers/plugin/set-default.ts +3 -3
- package/bin/helpers/plugin/set-paid.ts +3 -3
- package/bin/helpers/plugin/show.ts +3 -3
- package/dist/bin/helpers/billing-http.js +13 -5
- package/dist/bin/helpers/plugin/set-default.js +2 -2
- package/dist/bin/helpers/plugin/set-paid.js +2 -2
- package/dist/bin/helpers/plugin/show.js +2 -2
- package/package.json +1 -1
|
@@ -17,6 +17,9 @@ const USER_AUTH_URLS: Record<string, string> = {
|
|
|
17
17
|
// #201: yzsgo.com 全量迁移 (2026-06-12), 旧 billing-cn.optima.chat 路由已下线
|
|
18
18
|
const CN_PROD_BILLING_URL = 'https://billing-api.yzsgo.com';
|
|
19
19
|
const CN_STAGE_BILLING_URL = 'https://billing-api.stage.optima.chat';
|
|
20
|
+
// cn skills (marketplace) registry — same hardcoded-cn-URL rationale as billing.
|
|
21
|
+
const CN_PROD_SKILLS_URL = 'https://skills.yzsgo.com';
|
|
22
|
+
const CN_STAGE_SKILLS_URL = 'https://skills.stage.optima.chat';
|
|
20
23
|
|
|
21
24
|
/**
|
|
22
25
|
* Validate the --env flag value at command entry, before any I/O.
|
|
@@ -36,11 +39,12 @@ export function validateEnv(env: string): 'stage' | 'prod' {
|
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
|
-
* Variant for commands that
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* Variant for commands that support all four envs (stage/prod/cn-prod/cn-stage)
|
|
43
|
+
* because they reach billing / skills / user-auth over HTTPS only — e.g.
|
|
44
|
+
* grant-balance, grant-subscription, entitlement, account, and optima-plugin
|
|
45
|
+
* (set-paid/set-default/show). Commands that resolve users via the AWS RDS SSH
|
|
46
|
+
* tunnel (which does not exist for cn — Aliyun VPC-internal RDS) stay on
|
|
47
|
+
* validateEnv so a cn typo fails fast instead of dying inside tunnel setup.
|
|
44
48
|
*/
|
|
45
49
|
export function validateEnvCnProd(env: string): 'stage' | 'prod' | 'cn-prod' | 'cn-stage' {
|
|
46
50
|
if (env !== 'stage' && env !== 'prod' && env !== 'cn-prod' && env !== 'cn-stage') {
|
|
@@ -95,6 +99,8 @@ function getBillingUrl(env: string): string {
|
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
function getSkillsUrl(env: string): string {
|
|
102
|
+
if (env === 'cn-prod') return CN_PROD_SKILLS_URL;
|
|
103
|
+
if (env === 'cn-stage') return CN_STAGE_SKILLS_URL;
|
|
98
104
|
if (skillsUrlCache[env]) return skillsUrlCache[env];
|
|
99
105
|
const url = fetchInfisicalSecret(env, '/shared-secrets/domain-urls', 'SKILLS_REGISTRY_URL');
|
|
100
106
|
skillsUrlCache[env] = url;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { callSkills,
|
|
1
|
+
import { callSkills, validateEnvCnProd } from '../billing-http';
|
|
2
2
|
import { confirmIfProd } from '../confirm-prompt';
|
|
3
3
|
|
|
4
4
|
interface SetDefaultArgs {
|
|
@@ -18,7 +18,7 @@ Required:
|
|
|
18
18
|
|
|
19
19
|
Optional:
|
|
20
20
|
--yes Skip prod confirmation prompt (no-op on stage)
|
|
21
|
-
--env stage|prod
|
|
21
|
+
--env <env> stage|prod|cn-prod|cn-stage (default: stage)
|
|
22
22
|
|
|
23
23
|
Note: no skill-sync broadcast — changes what NEW user syncs receive; does not
|
|
24
24
|
retroactively add/remove the plugin for existing users until their next sync.`);
|
|
@@ -45,7 +45,7 @@ retroactively add/remove the plugin for existing users until their next sync.`);
|
|
|
45
45
|
|
|
46
46
|
export async function runSetDefault(argv: string[]): Promise<void> {
|
|
47
47
|
const args = parseArgs(argv);
|
|
48
|
-
|
|
48
|
+
validateEnvCnProd(args.env);
|
|
49
49
|
|
|
50
50
|
await confirmIfProd(
|
|
51
51
|
args.env,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { callSkills,
|
|
1
|
+
import { callSkills, validateEnvCnProd } from '../billing-http';
|
|
2
2
|
import { confirmIfProd } from '../confirm-prompt';
|
|
3
3
|
|
|
4
4
|
interface SetPaidArgs {
|
|
@@ -18,7 +18,7 @@ Required:
|
|
|
18
18
|
|
|
19
19
|
Optional:
|
|
20
20
|
--yes Skip prod confirmation prompt (no-op on stage)
|
|
21
|
-
--env stage|prod
|
|
21
|
+
--env <env> stage|prod|cn-prod|cn-stage (default: stage)
|
|
22
22
|
|
|
23
23
|
Note: salesUrl is NOT settable here (skills PATCH is strict; salesUrl is
|
|
24
24
|
publish-time-only via plugin.json metadata). When isPaid=true and salesUrl is
|
|
@@ -46,7 +46,7 @@ null, the 402 falls back to sales.optima.onl.`);
|
|
|
46
46
|
|
|
47
47
|
export async function runSetPaid(argv: string[]): Promise<void> {
|
|
48
48
|
const args = parseArgs(argv);
|
|
49
|
-
|
|
49
|
+
validateEnvCnProd(args.env);
|
|
50
50
|
|
|
51
51
|
await confirmIfProd(
|
|
52
52
|
args.env,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { callSkills,
|
|
1
|
+
import { callSkills, validateEnvCnProd } from '../billing-http';
|
|
2
2
|
|
|
3
3
|
interface ShowArgs {
|
|
4
4
|
slug: string;
|
|
@@ -13,7 +13,7 @@ Required:
|
|
|
13
13
|
--slug <slug>
|
|
14
14
|
|
|
15
15
|
Optional:
|
|
16
|
-
--env stage|prod
|
|
16
|
+
--env <env> stage|prod|cn-prod|cn-stage (default: stage)
|
|
17
17
|
|
|
18
18
|
Note: reads the public GET /api/plugins/:slug — shows isPaid, salesUrl, and
|
|
19
19
|
descriptive fields, but NOT defaultForUser / status / trustLevel (public
|
|
@@ -36,7 +36,7 @@ endpoint omits them). Returns 404 for non-ACTIVE plugins.`);
|
|
|
36
36
|
|
|
37
37
|
export async function runShow(argv: string[]): Promise<void> {
|
|
38
38
|
const args = parseArgs(argv);
|
|
39
|
-
|
|
39
|
+
validateEnvCnProd(args.env);
|
|
40
40
|
const res = await callSkills(args.env, 'GET', `/api/plugins/${encodeURIComponent(args.slug)}`);
|
|
41
41
|
console.log(JSON.stringify(res.body, null, 2));
|
|
42
42
|
}
|
|
@@ -27,6 +27,9 @@ const USER_AUTH_URLS = {
|
|
|
27
27
|
// #201: yzsgo.com 全量迁移 (2026-06-12), 旧 billing-cn.optima.chat 路由已下线
|
|
28
28
|
const CN_PROD_BILLING_URL = 'https://billing-api.yzsgo.com';
|
|
29
29
|
const CN_STAGE_BILLING_URL = 'https://billing-api.stage.optima.chat';
|
|
30
|
+
// cn skills (marketplace) registry — same hardcoded-cn-URL rationale as billing.
|
|
31
|
+
const CN_PROD_SKILLS_URL = 'https://skills.yzsgo.com';
|
|
32
|
+
const CN_STAGE_SKILLS_URL = 'https://skills.stage.optima.chat';
|
|
30
33
|
/**
|
|
31
34
|
* Validate the --env flag value at command entry, before any I/O.
|
|
32
35
|
*
|
|
@@ -44,11 +47,12 @@ function validateEnv(env) {
|
|
|
44
47
|
return env;
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
47
|
-
* Variant for commands that
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
50
|
+
* Variant for commands that support all four envs (stage/prod/cn-prod/cn-stage)
|
|
51
|
+
* because they reach billing / skills / user-auth over HTTPS only — e.g.
|
|
52
|
+
* grant-balance, grant-subscription, entitlement, account, and optima-plugin
|
|
53
|
+
* (set-paid/set-default/show). Commands that resolve users via the AWS RDS SSH
|
|
54
|
+
* tunnel (which does not exist for cn — Aliyun VPC-internal RDS) stay on
|
|
55
|
+
* validateEnv so a cn typo fails fast instead of dying inside tunnel setup.
|
|
52
56
|
*/
|
|
53
57
|
function validateEnvCnProd(env) {
|
|
54
58
|
if (env !== 'stage' && env !== 'prod' && env !== 'cn-prod' && env !== 'cn-stage') {
|
|
@@ -100,6 +104,10 @@ function getBillingUrl(env) {
|
|
|
100
104
|
return url;
|
|
101
105
|
}
|
|
102
106
|
function getSkillsUrl(env) {
|
|
107
|
+
if (env === 'cn-prod')
|
|
108
|
+
return CN_PROD_SKILLS_URL;
|
|
109
|
+
if (env === 'cn-stage')
|
|
110
|
+
return CN_STAGE_SKILLS_URL;
|
|
103
111
|
if (skillsUrlCache[env])
|
|
104
112
|
return skillsUrlCache[env];
|
|
105
113
|
const url = (0, infisical_secrets_1.fetchInfisicalSecret)(env, '/shared-secrets/domain-urls', 'SKILLS_REGISTRY_URL');
|
|
@@ -13,7 +13,7 @@ Required:
|
|
|
13
13
|
|
|
14
14
|
Optional:
|
|
15
15
|
--yes Skip prod confirmation prompt (no-op on stage)
|
|
16
|
-
--env stage|prod
|
|
16
|
+
--env <env> stage|prod|cn-prod|cn-stage (default: stage)
|
|
17
17
|
|
|
18
18
|
Note: no skill-sync broadcast — changes what NEW user syncs receive; does not
|
|
19
19
|
retroactively add/remove the plugin for existing users until their next sync.`);
|
|
@@ -52,7 +52,7 @@ retroactively add/remove the plugin for existing users until their next sync.`);
|
|
|
52
52
|
}
|
|
53
53
|
async function runSetDefault(argv) {
|
|
54
54
|
const args = parseArgs(argv);
|
|
55
|
-
(0, billing_http_1.
|
|
55
|
+
(0, billing_http_1.validateEnvCnProd)(args.env);
|
|
56
56
|
await (0, confirm_prompt_1.confirmIfProd)(args.env, `Action: set defaultForUser=${args.default} on plugin '${args.slug}' (${args.env.toUpperCase()})`, args.yes);
|
|
57
57
|
console.log(`\n🔧 Setting defaultForUser=${args.default} on ${args.slug} (${args.env.toUpperCase()})...`);
|
|
58
58
|
const res = await (0, billing_http_1.callSkills)(args.env, 'PATCH', `/api/admin/plugins/${encodeURIComponent(args.slug)}`, { defaultForUser: args.default });
|
|
@@ -13,7 +13,7 @@ Required:
|
|
|
13
13
|
|
|
14
14
|
Optional:
|
|
15
15
|
--yes Skip prod confirmation prompt (no-op on stage)
|
|
16
|
-
--env stage|prod
|
|
16
|
+
--env <env> stage|prod|cn-prod|cn-stage (default: stage)
|
|
17
17
|
|
|
18
18
|
Note: salesUrl is NOT settable here (skills PATCH is strict; salesUrl is
|
|
19
19
|
publish-time-only via plugin.json metadata). When isPaid=true and salesUrl is
|
|
@@ -53,7 +53,7 @@ null, the 402 falls back to sales.optima.onl.`);
|
|
|
53
53
|
}
|
|
54
54
|
async function runSetPaid(argv) {
|
|
55
55
|
const args = parseArgs(argv);
|
|
56
|
-
(0, billing_http_1.
|
|
56
|
+
(0, billing_http_1.validateEnvCnProd)(args.env);
|
|
57
57
|
await (0, confirm_prompt_1.confirmIfProd)(args.env, `Action: set isPaid=${args.paid} on plugin '${args.slug}' (${args.env.toUpperCase()})`, args.yes);
|
|
58
58
|
console.log(`\n💰 Setting isPaid=${args.paid} on ${args.slug} (${args.env.toUpperCase()})...`);
|
|
59
59
|
const res = await (0, billing_http_1.callSkills)(args.env, 'PATCH', `/api/admin/plugins/${encodeURIComponent(args.slug)}`, { isPaid: args.paid });
|
|
@@ -10,7 +10,7 @@ Required:
|
|
|
10
10
|
--slug <slug>
|
|
11
11
|
|
|
12
12
|
Optional:
|
|
13
|
-
--env stage|prod
|
|
13
|
+
--env <env> stage|prod|cn-prod|cn-stage (default: stage)
|
|
14
14
|
|
|
15
15
|
Note: reads the public GET /api/plugins/:slug — shows isPaid, salesUrl, and
|
|
16
16
|
descriptive fields, but NOT defaultForUser / status / trustLevel (public
|
|
@@ -39,7 +39,7 @@ endpoint omits them). Returns 404 for non-ACTIVE plugins.`);
|
|
|
39
39
|
}
|
|
40
40
|
async function runShow(argv) {
|
|
41
41
|
const args = parseArgs(argv);
|
|
42
|
-
(0, billing_http_1.
|
|
42
|
+
(0, billing_http_1.validateEnvCnProd)(args.env);
|
|
43
43
|
const res = await (0, billing_http_1.callSkills)(args.env, 'GET', `/api/plugins/${encodeURIComponent(args.slug)}`);
|
|
44
44
|
console.log(JSON.stringify(res.body, null, 2));
|
|
45
45
|
}
|