@optima-chat/dev-skills 0.7.24 → 0.7.26
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/.claude/skills/grant-credits/SKILL.md +105 -0
- package/.claude/skills/grant-subscription/SKILL.md +118 -0
- package/bin/cli.js +16 -11
- package/dist/bin/helpers/generate-test-token.js +0 -0
- package/dist/bin/helpers/query-db.js +0 -0
- package/dist/bin/helpers/show-env.js +0 -0
- package/package.json +1 -1
- package/.claude/settings.local.json +0 -51
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "grant-credits"
|
|
3
|
+
description: "当用户请求赠送 credits、充值积分、grant credits、加 credits、奖励积分、补偿 credits、推荐奖励时,使用此技能。支持 Stage、Prod 两个环境。"
|
|
4
|
+
allowed-tools: ["Bash"]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 赠送 Credits
|
|
8
|
+
|
|
9
|
+
当你需要为用户赠送额外 credits 时,使用这个场景。
|
|
10
|
+
|
|
11
|
+
## 执行方式:使用 CLI 工具
|
|
12
|
+
|
|
13
|
+
**重要**:使用 `optima-grant-credits` CLI 工具:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
optima-grant-credits <email> --amount <n> [options]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**为什么使用 CLI 工具**:
|
|
20
|
+
- 自动通过 email 查找 userId(跨 user-auth 数据库)
|
|
21
|
+
- 自动处理 SSH 隧道和数据库连接
|
|
22
|
+
- 不会影响现有订阅和 credits(纯追加)
|
|
23
|
+
- 一条命令完成操作
|
|
24
|
+
|
|
25
|
+
## 适用情况
|
|
26
|
+
|
|
27
|
+
- 赠送额外 credits(奖励、补偿、推广等)
|
|
28
|
+
- 推荐奖励 credits
|
|
29
|
+
- 运营活动发放 credits
|
|
30
|
+
- 客户补偿
|
|
31
|
+
|
|
32
|
+
## 快速操作
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# 赠送 100 bonus credits,Stage 环境(默认)
|
|
36
|
+
optima-grant-credits user@example.com --amount 100
|
|
37
|
+
|
|
38
|
+
# 赠送 500 bonus credits,Prod 环境
|
|
39
|
+
optima-grant-credits user@example.com --amount 500 --env prod
|
|
40
|
+
|
|
41
|
+
# 推荐奖励 credits
|
|
42
|
+
optima-grant-credits user@example.com --amount 200 --type referral --env prod
|
|
43
|
+
|
|
44
|
+
# 自定义描述
|
|
45
|
+
optima-grant-credits user@example.com --amount 300 --description "客户补偿 - 服务中断" --env prod
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 参数说明
|
|
49
|
+
|
|
50
|
+
| 参数 | 说明 | 默认值 |
|
|
51
|
+
|------|------|--------|
|
|
52
|
+
| `<email>` | 用户邮箱(必填) | - |
|
|
53
|
+
| `--amount <n>` | Credits 数量(必填,>=1) | - |
|
|
54
|
+
| `--type <type>` | 类型:bonus, referral | bonus |
|
|
55
|
+
| `--description <text>` | 描述(可选) | Auto-generated |
|
|
56
|
+
| `--env <env>` | 环境:stage, prod | stage |
|
|
57
|
+
|
|
58
|
+
## 与 grant-subscription 的区别
|
|
59
|
+
|
|
60
|
+
| | grant-credits | grant-subscription |
|
|
61
|
+
|---|---|---|
|
|
62
|
+
| 作用 | 追加 credits | 开通/切换订阅计划 |
|
|
63
|
+
| 现有 credits | 不影响 | 清零后重新授予 |
|
|
64
|
+
| 现有订阅 | 不影响 | 取消旧的,创建新的 |
|
|
65
|
+
| Token quota | 不影响 | 按计划更新 |
|
|
66
|
+
| 适用场景 | 奖励、补偿、推广 | 开通会员、升级计划 |
|
|
67
|
+
|
|
68
|
+
## 常见使用场景
|
|
69
|
+
|
|
70
|
+
### 场景 1:奖励 credits
|
|
71
|
+
|
|
72
|
+
**用户请求**:"给 xxx@gmail.com 加 200 credits"
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
optima-grant-credits xxx@gmail.com --amount 200 --env prod
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 场景 2:推荐奖励
|
|
79
|
+
|
|
80
|
+
**用户请求**:"xxx 推荐了新用户,给他 referral 奖励 300"
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
optima-grant-credits xxx@gmail.com --amount 300 --type referral --env prod
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 场景 3:客户补偿
|
|
87
|
+
|
|
88
|
+
**用户请求**:"服务出了问题,补偿 xxx 500 credits"
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
optima-grant-credits xxx@gmail.com --amount 500 --description "服务中断补偿" --env prod
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 安全提醒
|
|
95
|
+
|
|
96
|
+
1. **Stage 优先**:默认操作 Stage 环境
|
|
97
|
+
2. **Prod 谨慎**:操作 Prod 前确认邮箱和数量
|
|
98
|
+
3. **纯追加**:不会影响现有 credits 和订阅
|
|
99
|
+
4. **无过期**:bonus/referral credits 默认不设过期时间
|
|
100
|
+
|
|
101
|
+
## 相关命令
|
|
102
|
+
|
|
103
|
+
- `optima-grant-credits` - 赠送 credits(主要方式)
|
|
104
|
+
- `optima-grant-subscription` - 开通订阅计划
|
|
105
|
+
- `optima-query-db` - 查询数据库验证结果
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "grant-subscription"
|
|
3
|
+
description: "当用户请求开通会员、赠送订阅、grant subscription、开通 Pro/Starter/Enterprise、升级计划、给用户开会员时,使用此技能。支持 Stage、Prod 两个环境。"
|
|
4
|
+
allowed-tools: ["Bash"]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 开通/赠送订阅
|
|
8
|
+
|
|
9
|
+
当你需要为用户开通会员计划时,使用这个场景。
|
|
10
|
+
|
|
11
|
+
## 执行方式:使用 CLI 工具
|
|
12
|
+
|
|
13
|
+
**重要**:无论用户使用 `/grant-subscription` 命令还是直接请求开通会员,都应该使用 `optima-grant-subscription` CLI 工具:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
optima-grant-subscription <email> [options]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**为什么使用 CLI 工具**:
|
|
20
|
+
- 自动通过 email 查找 userId(跨 user-auth 数据库)
|
|
21
|
+
- 自动处理 SSH 隧道和数据库连接
|
|
22
|
+
- 自动取消旧订阅、清零旧 credits
|
|
23
|
+
- 自动按 plan 配置授予 credits 和 token quota
|
|
24
|
+
- 一条命令完成所有操作
|
|
25
|
+
|
|
26
|
+
## 适用情况
|
|
27
|
+
|
|
28
|
+
- 给用户开通/赠送 Pro、Starter、Enterprise 等会员
|
|
29
|
+
- 升级用户的计划
|
|
30
|
+
- 为企业客户定制订阅
|
|
31
|
+
- 处理用户会员相关请求
|
|
32
|
+
|
|
33
|
+
## 快速操作
|
|
34
|
+
|
|
35
|
+
### 基本使用
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# 开通 Pro(默认),Stage 环境(默认)
|
|
39
|
+
optima-grant-subscription user@example.com
|
|
40
|
+
|
|
41
|
+
# 开通 Pro,Prod 环境
|
|
42
|
+
optima-grant-subscription user@example.com --env prod
|
|
43
|
+
|
|
44
|
+
# 开通 Starter,3 个月
|
|
45
|
+
optima-grant-subscription user@example.com --plan starter --months 3
|
|
46
|
+
|
|
47
|
+
# 开通 Enterprise,Prod 环境
|
|
48
|
+
optima-grant-subscription user@example.com --plan enterprise --env prod
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 参数说明
|
|
52
|
+
|
|
53
|
+
| 参数 | 说明 | 默认值 |
|
|
54
|
+
|------|------|--------|
|
|
55
|
+
| `<email>` | 用户邮箱(必填) | - |
|
|
56
|
+
| `--plan <id>` | 计划:trial, starter, pro, enterprise | pro |
|
|
57
|
+
| `--months <n>` | 时长(月) | 1 |
|
|
58
|
+
| `--env <env>` | 环境:stage, prod | stage |
|
|
59
|
+
|
|
60
|
+
### 计划配置
|
|
61
|
+
|
|
62
|
+
| Plan | Credits/月 | Session Token | Weekly Token |
|
|
63
|
+
|------|-----------|---------------|--------------|
|
|
64
|
+
| trial | 20 | 400K | 1M |
|
|
65
|
+
| starter | 500 | 2M | 10M |
|
|
66
|
+
| pro | 2,000 | 8M | 40M |
|
|
67
|
+
| enterprise | 10,000 | 16M | 80M |
|
|
68
|
+
|
|
69
|
+
## 常见使用场景
|
|
70
|
+
|
|
71
|
+
### 场景 1:给用户开通 Pro 会员
|
|
72
|
+
|
|
73
|
+
**用户请求**:"帮 xxx@gmail.com 开通 Pro"
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
optima-grant-subscription xxx@gmail.com --plan pro --env prod
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 场景 2:企业客户定制
|
|
80
|
+
|
|
81
|
+
**用户请求**:"给企业客户开 Enterprise,6 个月"
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
optima-grant-subscription client@company.com --plan enterprise --months 6 --env prod
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 场景 3:升级到 Starter
|
|
88
|
+
|
|
89
|
+
**用户请求**:"把这个用户升级到 Starter"
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
optima-grant-subscription user@example.com --plan starter --env prod
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## 执行流程
|
|
96
|
+
|
|
97
|
+
工具会自动完成以下步骤:
|
|
98
|
+
|
|
99
|
+
1. 通过 email 在 user-auth 数据库查找 userId
|
|
100
|
+
2. 加载对应 plan 的配置(credits、token 限额等)
|
|
101
|
+
3. 取消该用户的所有活跃订阅
|
|
102
|
+
4. 清零旧的 credits
|
|
103
|
+
5. 创建新订阅(设置到期时间)
|
|
104
|
+
6. 授予对应 credits
|
|
105
|
+
7. 更新 token quota 限额
|
|
106
|
+
|
|
107
|
+
## 安全提醒
|
|
108
|
+
|
|
109
|
+
1. **Stage 优先**:默认操作 Stage 环境
|
|
110
|
+
2. **Prod 谨慎**:操作 Prod 前确认用户邮箱正确
|
|
111
|
+
3. **不可逆**:旧订阅和 credits 会被清除
|
|
112
|
+
4. **确认 email**:执行前务必确认邮箱地址无误
|
|
113
|
+
|
|
114
|
+
## 相关命令
|
|
115
|
+
|
|
116
|
+
- `optima-grant-subscription` - 开通订阅(主要方式)
|
|
117
|
+
- `optima-grant-credits` - 单独赠送 credits
|
|
118
|
+
- `optima-query-db` - 查询数据库验证结果
|
package/bin/cli.js
CHANGED
|
@@ -29,25 +29,30 @@ switch (command) {
|
|
|
29
29
|
log('\n📦 Optima Dev Skills', 'blue');
|
|
30
30
|
log('\nClaude Code skills for Optima development team\n', 'cyan');
|
|
31
31
|
|
|
32
|
-
log('
|
|
33
|
-
log('
|
|
34
|
-
log('
|
|
35
|
-
log('
|
|
36
|
-
log('
|
|
37
|
-
log('
|
|
32
|
+
log('Available Commands:', 'yellow');
|
|
33
|
+
log(' optima-query-db <service> "<sql>" [env] Query database', 'cyan');
|
|
34
|
+
log(' optima-show-env <service> [env] Show service env vars', 'cyan');
|
|
35
|
+
log(' optima-generate-test-token [--env production] Generate test token', 'cyan');
|
|
36
|
+
log(' optima-grant-credits <email> --amount <n> [--env] Grant credits to user', 'cyan');
|
|
37
|
+
log(' optima-grant-subscription <email> --plan <p> [--env] Grant subscription', 'cyan');
|
|
38
|
+
log(' /logs <service> [lines] [env] View service logs (skill)', 'cyan');
|
|
39
|
+
log(' /restart-ecs <service> [env] Restart ECS service (skill)', 'cyan');
|
|
38
40
|
|
|
39
41
|
log('\nSupported Services:', 'yellow');
|
|
40
42
|
log(' commerce-backend user-auth mcp-host agentic-chat optima-logistics', 'cyan');
|
|
41
|
-
log(' optima-scout billing browser-backend optima-generation', 'cyan');
|
|
43
|
+
log(' session-gateway optima-scout billing browser-backend optima-generation', 'cyan');
|
|
42
44
|
|
|
43
45
|
log('\nEnvironments:', 'yellow');
|
|
44
46
|
log(' stage (default) prod', 'cyan');
|
|
45
47
|
|
|
46
|
-
log('\
|
|
47
|
-
log('
|
|
48
|
-
log(' optima-
|
|
48
|
+
log('\nExamples:', 'yellow');
|
|
49
|
+
log(' /logs commerce-backend 100 prod', 'cyan');
|
|
50
|
+
log(' optima-query-db user-auth "SELECT COUNT(*) FROM users" prod', 'cyan');
|
|
51
|
+
log(' optima-grant-credits user@example.com --amount 5000 --env prod', 'cyan');
|
|
49
52
|
|
|
50
|
-
log('\
|
|
53
|
+
log('\nMore Info:', 'yellow');
|
|
54
|
+
log(' optima-dev-skills --version Show version', 'cyan');
|
|
55
|
+
log(' <command> --help Show command help', 'cyan');
|
|
51
56
|
log(' https://github.com/Optima-Chat/optima-dev-skills\n', 'cyan');
|
|
52
57
|
break;
|
|
53
58
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"permissions": {
|
|
3
|
-
"allow": [
|
|
4
|
-
"WebSearch",
|
|
5
|
-
"WebFetch(domain:code.claude.com)",
|
|
6
|
-
"WebFetch(domain:platform.claude.com)",
|
|
7
|
-
"WebFetch(domain:github.com)",
|
|
8
|
-
"Bash(gh repo view:*)",
|
|
9
|
-
"Bash(gh repo clone:*)",
|
|
10
|
-
"Bash(gh repo list:*)",
|
|
11
|
-
"Read(//private/tmp/optima-docs/**)",
|
|
12
|
-
"Read(//tmp/optima-docs/**)",
|
|
13
|
-
"Bash(git init:*)",
|
|
14
|
-
"Bash(gh repo create:*)",
|
|
15
|
-
"Read(//private/tmp/optima-workspace/**)",
|
|
16
|
-
"Read(//tmp/optima-workspace/**)",
|
|
17
|
-
"Read(//tmp/optima-workspace/.claude/commands/**)",
|
|
18
|
-
"Bash(git add:*)",
|
|
19
|
-
"Bash(git push:*)",
|
|
20
|
-
"Bash(find:*)",
|
|
21
|
-
"Bash(git commit:*)",
|
|
22
|
-
"Bash(aws logs get-log-events:*)",
|
|
23
|
-
"Bash(npm install:*)",
|
|
24
|
-
"Bash(optima-dev-skills:*)",
|
|
25
|
-
"Bash(optima-generate-test-token:*)",
|
|
26
|
-
"Bash(optima-query-db:*)",
|
|
27
|
-
"Bash(gh variable set:*)",
|
|
28
|
-
"Bash(npm publish:*)",
|
|
29
|
-
"Bash(python3:*)",
|
|
30
|
-
"Bash(gh api:*)",
|
|
31
|
-
"Bash(curl -s http://auth.optima.chat/openapi.json)",
|
|
32
|
-
"Bash(curl -s https://auth.optima.chat/openapi.json)",
|
|
33
|
-
"Bash(cat:*)",
|
|
34
|
-
"Bash(node /Users/verypro/optima-dev-skills/scripts/install.js:*)",
|
|
35
|
-
"Bash(aws logs tail:*)",
|
|
36
|
-
"Bash(grep:*)",
|
|
37
|
-
"Bash(npm view:*)",
|
|
38
|
-
"Bash(npm version:*)",
|
|
39
|
-
"Bash(git checkout:*)",
|
|
40
|
-
"Bash(git pull:*)",
|
|
41
|
-
"Bash(node scripts/install.js:*)",
|
|
42
|
-
"Bash(gh issue:*)",
|
|
43
|
-
"Bash(npm run:*)",
|
|
44
|
-
"Bash(gh pr:*)",
|
|
45
|
-
"Bash(node:*)",
|
|
46
|
-
"Bash(echo \"exit: $?\")"
|
|
47
|
-
],
|
|
48
|
-
"deny": [],
|
|
49
|
-
"ask": []
|
|
50
|
-
}
|
|
51
|
-
}
|