@sokeai/cli 1.0.15 → 1.0.18
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 +1 -1
- package/package.json +1 -1
- package/scripts/install.js +51 -27
- package/skills/soke-course/README.md +203 -0
- package/skills/soke-course/SKILL.md +531 -0
- package/skills/soke-course/SUMMARY.md +236 -0
- package/skills/soke-course/references/course-list-courses.md +251 -0
- package/skills/soke-course/references/examples.md +480 -0
package/README.md
CHANGED
package/package.json
CHANGED
package/scripts/install.js
CHANGED
|
@@ -38,9 +38,12 @@ function copyDirRecursive(srcDir, destDir) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
function
|
|
41
|
+
function detectSokeclawWorkspaceSkillsDirs() {
|
|
42
42
|
const homeDir = os.homedir();
|
|
43
|
-
const
|
|
43
|
+
const dirs = [];
|
|
44
|
+
|
|
45
|
+
// 1. Sokeclaw 默认工作区
|
|
46
|
+
const defaultSokeclawDir = path.join(
|
|
44
47
|
homeDir,
|
|
45
48
|
'.sokeclaw',
|
|
46
49
|
'openai-agents',
|
|
@@ -49,19 +52,41 @@ function detectSokeclawWorkspaceSkillsDir() {
|
|
|
49
52
|
'skills'
|
|
50
53
|
);
|
|
51
54
|
|
|
55
|
+
// 2. Zev 默认工作区 (Sokeclaw 可能会生成这个)
|
|
56
|
+
const defaultZevDir = path.join(
|
|
57
|
+
homeDir,
|
|
58
|
+
'.zev',
|
|
59
|
+
'openai-agents',
|
|
60
|
+
'workspaces',
|
|
61
|
+
'main',
|
|
62
|
+
'skills'
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// 3. 从 workclaw.json 读取配置
|
|
52
66
|
const workclawConfigPath = path.join(homeDir, '.sokeclaw', 'workclaw.json');
|
|
53
|
-
|
|
67
|
+
let configuredDir = null;
|
|
68
|
+
if (fs.existsSync(workclawConfigPath)) {
|
|
69
|
+
try {
|
|
70
|
+
const configText = fs.readFileSync(workclawConfigPath, 'utf8');
|
|
71
|
+
const config = JSON.parse(configText);
|
|
72
|
+
const workspaceDir = config?.defaults?.agents?.openaiAgents?.main?.workspace;
|
|
73
|
+
if (typeof workspaceDir === 'string' && workspaceDir.length > 0) {
|
|
74
|
+
configuredDir = path.join(workspaceDir, 'skills');
|
|
75
|
+
}
|
|
76
|
+
} catch (_) {}
|
|
77
|
+
}
|
|
54
78
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
79
|
+
// 收集所有有效的潜在目录
|
|
80
|
+
if (configuredDir) {
|
|
81
|
+
dirs.push(configuredDir);
|
|
82
|
+
} else {
|
|
83
|
+
dirs.push(defaultSokeclawDir);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 始终将 .zev 目录也加入同步列表
|
|
87
|
+
dirs.push(defaultZevDir);
|
|
63
88
|
|
|
64
|
-
return
|
|
89
|
+
return dirs;
|
|
65
90
|
}
|
|
66
91
|
|
|
67
92
|
function syncSkillsToSokeclawWorkspace() {
|
|
@@ -69,22 +94,21 @@ function syncSkillsToSokeclawWorkspace() {
|
|
|
69
94
|
const packagedSkillsDir = path.join(packageRoot, 'skills');
|
|
70
95
|
if (!fs.existsSync(packagedSkillsDir)) return;
|
|
71
96
|
|
|
72
|
-
const
|
|
73
|
-
const sokeclawRootDir = path.join(os.homedir(), '.sokeclaw');
|
|
74
|
-
if (!fs.existsSync(sokeclawRootDir)) return;
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
fs.mkdirSync(sokeclawSkillsDir, { recursive: true });
|
|
78
|
-
} catch (_) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
97
|
+
const targetDirs = detectSokeclawWorkspaceSkillsDirs();
|
|
82
98
|
const skillNames = ['soke-shared', 'soke-exam'];
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
99
|
+
|
|
100
|
+
for (const targetDir of targetDirs) {
|
|
101
|
+
try {
|
|
102
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
103
|
+
for (const skillName of skillNames) {
|
|
104
|
+
const src = path.join(packagedSkillsDir, skillName);
|
|
105
|
+
const dest = path.join(targetDir, skillName);
|
|
106
|
+
if (fs.existsSync(src)) {
|
|
107
|
+
copyDirRecursive(src, dest);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} catch (_) {
|
|
111
|
+
// 忽略单个目录的写入失败
|
|
88
112
|
}
|
|
89
113
|
}
|
|
90
114
|
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# soke-course Skill
|
|
2
|
+
|
|
3
|
+
授客课程管理 Skill,用于查询课程列表、课程分类、课程详情、学习记录等。
|
|
4
|
+
|
|
5
|
+
## 功能概述
|
|
6
|
+
|
|
7
|
+
这个 skill 提供了完整的课程管理查询功能,包括:
|
|
8
|
+
|
|
9
|
+
- 📚 **课程查询**: 查询课程列表、课程详情
|
|
10
|
+
- 🏷️ **分类管理**: 查询课程分类
|
|
11
|
+
- 📝 **课件管理**: 查询课程下的课件列表
|
|
12
|
+
- 👥 **学习记录**: 查询用户的课程学习记录
|
|
13
|
+
- 📊 **学习统计**: 查询课件学习记录和人脸识别记录
|
|
14
|
+
|
|
15
|
+
## 快速开始
|
|
16
|
+
|
|
17
|
+
### 前置条件
|
|
18
|
+
|
|
19
|
+
1. 安装 soke-cli
|
|
20
|
+
```bash
|
|
21
|
+
npm install -g @sokeai/cli
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
2. 配置认证
|
|
25
|
+
```bash
|
|
26
|
+
soke-cli config init
|
|
27
|
+
soke-cli auth login
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 基本使用
|
|
31
|
+
|
|
32
|
+
#### 查询课程列表
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# 查询2024年的所有课程
|
|
36
|
+
soke-cli course +list-courses \
|
|
37
|
+
--start-time 1704038400000 \
|
|
38
|
+
--end-time 1735660799000
|
|
39
|
+
|
|
40
|
+
# 查询已发布的课程
|
|
41
|
+
soke-cli course +list-courses \
|
|
42
|
+
--start-time 1704038400000 \
|
|
43
|
+
--end-time 1735660799000 \
|
|
44
|
+
--status 1
|
|
45
|
+
|
|
46
|
+
# 查询自建课
|
|
47
|
+
soke-cli course +list-courses \
|
|
48
|
+
--start-time 1704038400000 \
|
|
49
|
+
--end-time 1735660799000 \
|
|
50
|
+
--is-in 1
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### 查询课程详情
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
soke-cli course +get-course --uuid "course-uuid-here"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
#### 查询课程分类
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
soke-cli course +list-categories
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### 查询课程学习记录
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# 查询某个课程的所有学习记录
|
|
69
|
+
soke-cli course +list-course-users --course-id "course-uuid-here"
|
|
70
|
+
|
|
71
|
+
# 查询特定用户的学习记录
|
|
72
|
+
soke-cli course +get-course-user \
|
|
73
|
+
--course-id "course-uuid-here" \
|
|
74
|
+
--dept-user-id "user-uuid-here"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 主要命令
|
|
78
|
+
|
|
79
|
+
| 命令 | 说明 |
|
|
80
|
+
|------|------|
|
|
81
|
+
| `+list-courses` | 查询课程列表 |
|
|
82
|
+
| `+get-course` | 查询课程详情 |
|
|
83
|
+
| `+list-categories` | 查询课程分类 |
|
|
84
|
+
| `+list-lessons` | 查询课程课件列表 |
|
|
85
|
+
| `+list-course-users` | 查询课程学习记录 |
|
|
86
|
+
| `+get-course-user` | 查询用户课程学习详情 |
|
|
87
|
+
| `+list-lesson-learns` | 查询课件学习记录 |
|
|
88
|
+
| `+list-lesson-faces` | 查询课件人脸识别记录 |
|
|
89
|
+
|
|
90
|
+
## 使用场景
|
|
91
|
+
|
|
92
|
+
### 场景1: 统计课程完成情况
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# 1. 获取课程列表
|
|
96
|
+
soke-cli course +list-courses \
|
|
97
|
+
--start-time 1704038400000 \
|
|
98
|
+
--end-time 1735660799000
|
|
99
|
+
|
|
100
|
+
# 2. 查询某个课程的学习记录
|
|
101
|
+
soke-cli course +list-course-users --course-id "course-uuid"
|
|
102
|
+
|
|
103
|
+
# 3. 分析返回数据中的 finish_status 和 study_progress 字段
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 场景2: 查询用户学习情况
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# 1. 查询用户ID(如果只知道用户名)
|
|
110
|
+
soke-cli contact +search-user --name "张三"
|
|
111
|
+
|
|
112
|
+
# 2. 查询该用户的课程学习记录
|
|
113
|
+
soke-cli course +get-course-user \
|
|
114
|
+
--course-id "course-uuid" \
|
|
115
|
+
--dept-user-id "user-uuid"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 场景3: 课程内容分析
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# 1. 获取课程详情
|
|
122
|
+
soke-cli course +get-course --uuid "course-uuid"
|
|
123
|
+
|
|
124
|
+
# 2. 获取课程的课件列表
|
|
125
|
+
soke-cli course +list-lessons --course-id "course-uuid"
|
|
126
|
+
|
|
127
|
+
# 3. 查询每个课件的学习记录
|
|
128
|
+
soke-cli course +list-lesson-learns --lesson-id "lesson-uuid"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 参数说明
|
|
132
|
+
|
|
133
|
+
### 时间参数
|
|
134
|
+
|
|
135
|
+
所有时间参数使用 Unix 时间戳(毫秒)格式:
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
// JavaScript 示例
|
|
139
|
+
const startTime = new Date('2024-01-01').getTime(); // 1704038400000
|
|
140
|
+
const endTime = new Date('2024-12-31').getTime(); // 1735660799000
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 状态参数
|
|
144
|
+
|
|
145
|
+
**课程状态 (status)**:
|
|
146
|
+
- `0`: 未发布
|
|
147
|
+
- `1`: 已发布
|
|
148
|
+
- `2`: 已关闭
|
|
149
|
+
|
|
150
|
+
**课程来源 (is-in)**:
|
|
151
|
+
- `0`: 采购课
|
|
152
|
+
- `1`: 自建课
|
|
153
|
+
|
|
154
|
+
**学习模式 (study_type)**:
|
|
155
|
+
- `1`: 自由式(可任意顺序学习)
|
|
156
|
+
- `2`: 解锁式(必须按顺序学习)
|
|
157
|
+
|
|
158
|
+
## 注意事项
|
|
159
|
+
|
|
160
|
+
1. **时间范围限制**: `+list-courses` 的时间范围不能超过365天
|
|
161
|
+
2. **分页查询**: 默认每页100条,最大100条
|
|
162
|
+
3. **权限要求**: 需要相应的只读权限(`course:*:readonly`)
|
|
163
|
+
4. **认证要求**: 所有命令都需要先完成 `soke-cli auth login`
|
|
164
|
+
|
|
165
|
+
## 错误处理
|
|
166
|
+
|
|
167
|
+
### 权限不足
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# 错误信息: Permission denied
|
|
171
|
+
# 解决方案: 检查是否已登录,并确认账号有相应权限
|
|
172
|
+
soke-cli auth login
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 时间范围超限
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# 错误信息: Time range exceeds 365 days
|
|
179
|
+
# 解决方案: 缩小时间范围或分批查询
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 数据不存在
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# 错误信息: Course not found
|
|
186
|
+
# 解决方案: 检查课程ID是否正确
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## 相关文档
|
|
190
|
+
|
|
191
|
+
- [SKILL.md](./SKILL.md) - 完整的 Skill 文档
|
|
192
|
+
- [course-list-courses.md](./references/course-list-courses.md) - 课程列表查询详细参考
|
|
193
|
+
- [授客开放平台API文档](../../cli-doc/授客开放平台API接口文档.md) - API 接口文档
|
|
194
|
+
|
|
195
|
+
## 技术支持
|
|
196
|
+
|
|
197
|
+
如有问题,请参考:
|
|
198
|
+
- 授客开放平台: https://opendev.soke.cn
|
|
199
|
+
- soke-cli 文档: [../../cli-doc/soke-cli.md](../../cli-doc/soke-cli.md)
|
|
200
|
+
|
|
201
|
+
## 版本历史
|
|
202
|
+
|
|
203
|
+
- v1.0.0 (2024-05-14): 初始版本,支持课程查询、分类、学习记录等功能
|