dsh-learning-assistant 0.0.2 → 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/README.md +41 -7
- package/assets/collect/README.md +55 -0
- package/assets/skills/course-inbox-sync.md +182 -0
- package/assets/skills/course-material-digest.md +173 -0
- package/assets/skills/one-to-one-tutor.md +320 -0
- package/assets/tools/pdf/pdf-render.ps1 +30 -0
- package/assets/tools/pptx-digest.py +99 -0
- package/assets/tools/pptx-map.py +98 -0
- package/assets/tools/pptx-media.py +101 -0
- package/assets/tools/qq-group-msg.py +258 -0
- package/assets/tools/qq-group-sync.py +265 -0
- package/docs//345/215/217/344/275/234/345/274/200/345/217/221.md +18 -10
- package/lib/client.js +110 -0
- package/lib/{index.d.mts → index.d.ts} +3 -1
- package/lib/index.js +392 -0
- package/package.json +8 -7
- package/src/client/settings.tsx +6 -4
- package/src/index.ts +36 -11
- package/src/practice/learn/api.mjs +393 -0
- package/src/practice/learn/cli.mjs +175 -0
- package/src/practice/learn/curriculum.mjs +292 -0
- package/src/practice/learn/handoff.mjs +73 -0
- package/src/practice/learn/jsonschema.mjs +171 -0
- package/src/practice/learn/mapping.mjs +90 -0
- package/src/practice/learn/progress.mjs +247 -0
- package/src/practice/learn/schema/curriculum.schema.json +88 -0
- package/src/practice/learn/schema/handoff.schema.json +56 -0
- package/src/practice/learn/schema/node-practice-map.schema.json +28 -0
- package/src/practice/learn/schema/progress.schema.json +66 -0
- package/src/practice/learn/schemas.mjs +53 -0
- package/src/practice/learn/store.mjs +247 -0
- package/src/practice/public/app.js +883 -0
- package/src/practice/public/index.html +19 -0
- package/src/practice/public/ink.js +349 -0
- package/src/practice/public/learn.css +20 -0
- package/src/practice/public/learn.js +329 -0
- package/src/practice/public/style.css +326 -0
- package/src/practice/public/vendor/katex/contrib/auto-render.min.js +1 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/src/practice/public/vendor/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/src/practice/public/vendor/katex/katex.min.css +1 -0
- package/src/practice/public/vendor/katex/katex.min.js +1 -0
- package/src/practice//346/234/215/345/212/241.mjs +443 -0
- package/src/practice//346/240/241/351/252/214/351/242/230/347/233/256.mjs +114 -0
- package/src/practice//347/255/211/345/276/205/346/217/220/344/272/244.mjs +100 -0
- package/src/practice-service.ts +99 -0
- package/src/practice-tool.ts +91 -0
- package/src/skills.ts +156 -0
- package/lib/client.d.mts +0 -10
- package/lib/client.mjs +0 -87
- package/lib/index.mjs +0 -29
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 练习台服务管理(板块③,宿主半)。
|
|
3
|
+
*
|
|
4
|
+
* 「按需起服务」:不常驻。`ensure()` 先探测目标端口是否已有健康的练习台
|
|
5
|
+
* (学习区手工部署的也算),有就收编复用;没有才拉起随包的 服务.mjs 子进程
|
|
6
|
+
* (`--data-root` 指向配置的数据根目录)。`stop()` 只停自己拉起的进程。
|
|
7
|
+
*
|
|
8
|
+
* 服务脚本随 npm 包的 `src/practice/` 分发(files 含 src/),用 import.meta 相对定位,
|
|
9
|
+
* 开发仓(lib/ 构建)与安装包两种布局都成立。
|
|
10
|
+
*
|
|
11
|
+
* @module dsh-learning-assistant/practice-service
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { spawn, type ChildProcess } from 'node:child_process'
|
|
15
|
+
import { join } from 'node:path'
|
|
16
|
+
import { fileURLToPath } from 'node:url'
|
|
17
|
+
|
|
18
|
+
/** 随包服务脚本的绝对路径(lib/index.mjs → ../src/practice/服务.mjs = 包根/src/practice/)。 */
|
|
19
|
+
const SERVER_SCRIPT = fileURLToPath(new URL('../src/practice/服务.mjs', import.meta.url))
|
|
20
|
+
|
|
21
|
+
/** 单例状态:本插件生命周期内最多持有一个子进程。 */
|
|
22
|
+
let child: ChildProcess | undefined
|
|
23
|
+
let owned = false
|
|
24
|
+
let runningPort = 0
|
|
25
|
+
let runningRoot = ''
|
|
26
|
+
|
|
27
|
+
/** /api/health 探测:返回是否已有健康的练习台在跑。 */
|
|
28
|
+
async function healthy(port: number): Promise<boolean> {
|
|
29
|
+
try {
|
|
30
|
+
const r = await fetch(`http://127.0.0.1:${port}/api/health`, { signal: AbortSignal.timeout(1500) })
|
|
31
|
+
const j = (await r.json()) as { ok?: unknown }
|
|
32
|
+
return r.ok && j.ok === true
|
|
33
|
+
} catch {
|
|
34
|
+
return false
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** 等服务起来(最多 ~8s),起来即返回 true。 */
|
|
39
|
+
async function waitUp(port: number): Promise<boolean> {
|
|
40
|
+
for (let i = 0; i < 40; i++) {
|
|
41
|
+
if (await healthy(port)) return true
|
|
42
|
+
await new Promise(s => setTimeout(s, 200))
|
|
43
|
+
}
|
|
44
|
+
return false
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 确保练习台在跑并返回入口地址。
|
|
49
|
+
* @param port - 配置的端口。
|
|
50
|
+
* @param dataRoot - 数据根目录(= 服务的工作区/数据基目录)。
|
|
51
|
+
* @returns 状态与入口 URL。
|
|
52
|
+
*/
|
|
53
|
+
export async function ensurePractice(port: number, dataRoot: string): Promise<{
|
|
54
|
+
url: string
|
|
55
|
+
adopted: boolean
|
|
56
|
+
started: boolean
|
|
57
|
+
}> {
|
|
58
|
+
if (await healthy(port)) {
|
|
59
|
+
runningPort = port
|
|
60
|
+
runningRoot = dataRoot
|
|
61
|
+
return { url: `http://127.0.0.1:${port}/`, adopted: true, started: false }
|
|
62
|
+
}
|
|
63
|
+
if (!child || owned === false) {
|
|
64
|
+
child = spawn(process.execPath, [SERVER_SCRIPT, String(port), '--data-root', dataRoot], {
|
|
65
|
+
cwd: fileURLToPath(new URL('../src/practice/', import.meta.url)),
|
|
66
|
+
env: {
|
|
67
|
+
...process.env,
|
|
68
|
+
LEARN_DATA_BASE: dataRoot,
|
|
69
|
+
LEARN_WORKSPACE: dataRoot,
|
|
70
|
+
LEARN_PRACTICE_DIR: join(dataRoot, '练习台'),
|
|
71
|
+
},
|
|
72
|
+
stdio: 'ignore',
|
|
73
|
+
windowsHide: true,
|
|
74
|
+
})
|
|
75
|
+
child.on('exit', () => { child = undefined; owned = false })
|
|
76
|
+
owned = true
|
|
77
|
+
}
|
|
78
|
+
const up = await waitUp(port)
|
|
79
|
+
if (!up) throw new Error(`练习台服务没能启动(端口 ${port})。可能被其他程序占用且不是练习台。`)
|
|
80
|
+
runningPort = port
|
|
81
|
+
runningRoot = dataRoot
|
|
82
|
+
return { url: `http://127.0.0.1:${port}/`, adopted: false, started: true }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** 停掉本插件拉起的进程(收编的不停)。 */
|
|
86
|
+
export function stopPractice(): boolean {
|
|
87
|
+
if (child && owned) {
|
|
88
|
+
try { child.kill() } catch { /* 已退出 */ }
|
|
89
|
+
child = undefined
|
|
90
|
+
owned = false
|
|
91
|
+
return true
|
|
92
|
+
}
|
|
93
|
+
return false
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** 当前状态快照(给工具与设置页)。 */
|
|
97
|
+
export function practiceStatus(): { running: boolean; owned: boolean; port: number; root: string } {
|
|
98
|
+
return { running: runningPort > 0, owned, port: runningPort, root: runningRoot }
|
|
99
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 「练习台」工具(板块③):让模型按需起练习台并把入口地址报给用户。
|
|
3
|
+
*
|
|
4
|
+
* 动作:
|
|
5
|
+
* - open:确保服务在跑(已有健康实例则收编复用),返回入口 URL。
|
|
6
|
+
* - status:报告服务运行状态与数据根。
|
|
7
|
+
* - stop:停掉本插件拉起的服务进程(收编的不停)。
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-learning-assistant/practice-tool
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { defineTool, type ToolDefinition } from '@deepseek-ai/dsh-tools'
|
|
13
|
+
import { ensurePractice, stopPractice, practiceStatus } from './practice-service.ts'
|
|
14
|
+
|
|
15
|
+
/** 构建工具定义。 */
|
|
16
|
+
export function practiceTool(dataRoot: () => string, port: () => number): ToolDefinition {
|
|
17
|
+
return defineTool({
|
|
18
|
+
name: 'practice_desk',
|
|
19
|
+
description:
|
|
20
|
+
'学习助手练习台:本地答题网页(题库 JSON + 白板手写 + 成绩记录)。'
|
|
21
|
+
+ 'action=open 确保服务在跑并返回入口 URL(给用户在 DSH 右侧栏浏览器打开);'
|
|
22
|
+
+ 'action=status 报告运行状态;action=stop 停掉本插件拉起的服务(收编的外部实例不停)。'
|
|
23
|
+
+ '数据落在数据根目录的 练习台/ 与 学习助手数据/ 下;教学流程见 one-to-one-tutor 技能。',
|
|
24
|
+
parameters: {
|
|
25
|
+
action: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
enum: ['open', 'status', 'stop'],
|
|
28
|
+
description: 'open=确保服务在跑并返回入口;status=只看状态;stop=停本插件拉起的进程。',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
output: {
|
|
32
|
+
schema: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
properties: {
|
|
36
|
+
action: { type: 'string', required: true, enum: ['open', 'status', 'stop'] },
|
|
37
|
+
url: { type: 'string' },
|
|
38
|
+
running: { type: 'boolean', required: true },
|
|
39
|
+
owned: { type: 'boolean', required: true },
|
|
40
|
+
started: { type: 'boolean' },
|
|
41
|
+
adopted: { type: 'boolean' },
|
|
42
|
+
stopped: { type: 'boolean' },
|
|
43
|
+
port: { type: 'integer' },
|
|
44
|
+
dataRoot: { type: 'string', required: true },
|
|
45
|
+
message: { type: 'string', required: true },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
render: (_args, value) => [{ type: 'text', text: value.message }],
|
|
49
|
+
},
|
|
50
|
+
isConcurrencySafe: () => false,
|
|
51
|
+
async execute(args) {
|
|
52
|
+
const action = args.action ?? 'open'
|
|
53
|
+
if (action === 'status') {
|
|
54
|
+
const st = practiceStatus()
|
|
55
|
+
const message = st.running
|
|
56
|
+
? `练习台运行中(端口 ${st.port}${st.owned ? ',本插件拉起' : ',外部实例'})`
|
|
57
|
+
: '练习台未运行'
|
|
58
|
+
return { action, running: st.running, owned: st.owned, port: st.port, dataRoot: dataRoot(), message }
|
|
59
|
+
}
|
|
60
|
+
if (action === 'stop') {
|
|
61
|
+
const stopped = stopPractice()
|
|
62
|
+
const st = practiceStatus()
|
|
63
|
+
return {
|
|
64
|
+
action,
|
|
65
|
+
running: st.running, owned: st.owned, stopped,
|
|
66
|
+
dataRoot: dataRoot(),
|
|
67
|
+
message: stopped
|
|
68
|
+
? '练习台(本插件拉起的实例)已停止。'
|
|
69
|
+
: '没有本插件拉起的练习台进程在跑(外部实例不动)。',
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// open
|
|
73
|
+
const r = await ensurePractice(port(), dataRoot())
|
|
74
|
+
const st = practiceStatus()
|
|
75
|
+
const how = r.started
|
|
76
|
+
? '已启动随包服务'
|
|
77
|
+
: r.adopted && st.owned
|
|
78
|
+
? '随包服务已在运行(插件加载时预热)'
|
|
79
|
+
: r.adopted
|
|
80
|
+
? '检测到已有健康实例(可能是学习区手工部署),直接复用'
|
|
81
|
+
: '已在运行'
|
|
82
|
+
return {
|
|
83
|
+
action,
|
|
84
|
+
url: r.url, started: r.started, adopted: r.adopted,
|
|
85
|
+
running: true, owned: st.owned,
|
|
86
|
+
dataRoot: dataRoot(),
|
|
87
|
+
message: `练习台${how}。入口:${r.url}(让用户在 DSH 右侧栏「浏览器」tab 打开)。数据根:${dataRoot()}`,
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
}
|
package/src/skills.ts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 内嵌技能提供者(板块②)。
|
|
3
|
+
*
|
|
4
|
+
* 把学习区验证过的三个技能随插件分发:正文在 `assets/skills/`,
|
|
5
|
+
* 用 `ctx.skills.registerProvider` 注册成一个 bundled provider。
|
|
6
|
+
* 形状照抄 dsh-visualize 的 `src/skill.ts`(BUNDLED_SKILL_RANK + locator + resourceBase)。
|
|
7
|
+
*
|
|
8
|
+
* 优先级策略:rank 取 700(> 宿主 BUNDLED_SKILL_RANK=600)。同层重复名 rank 小者胜,
|
|
9
|
+
* 我们故意排在文件系统提供者之后,让用户工作区(project/user 层)的同名技能继续覆盖;
|
|
10
|
+
* 只有当部署环境没有同名技能时,这里的内嵌版才生效。
|
|
11
|
+
*
|
|
12
|
+
* 每个 skill 的正文按需读盘,并自动追加一节「插件环境附录」:把 dataRoot、
|
|
13
|
+
* 练习台地址等部署事实写进去,让技能正文保持「不含本机值」的可分发状态。
|
|
14
|
+
*
|
|
15
|
+
* @module dsh-learning-assistant/skills
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { readFile } from 'node:fs/promises'
|
|
19
|
+
import { fileURLToPath } from 'node:url'
|
|
20
|
+
import {
|
|
21
|
+
type SkillCandidate,
|
|
22
|
+
type SkillDefinition,
|
|
23
|
+
type SkillProvider,
|
|
24
|
+
} from '@deepseek-ai/dsh-skill'
|
|
25
|
+
|
|
26
|
+
/** Provider 名,注册到 ctx.skills 时对外可见。 */
|
|
27
|
+
export const PROVIDER_NAME = 'dsh-learning-assistant'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 内嵌 rank。宿主文件系统提供者用 BUNDLED_SKILL_RANK(600);我们取 700 排在它后面,
|
|
31
|
+
* 用户工作区的同名技能(project/user 层)按层级合并规则天然优先。
|
|
32
|
+
*/
|
|
33
|
+
export const EMBEDDED_SKILL_RANK = 700
|
|
34
|
+
|
|
35
|
+
/** 部署事实,正文附录要用。 */
|
|
36
|
+
export interface SkillEnv {
|
|
37
|
+
/** 数据根目录(题库/答卷/进度/采集产物都落这里)。 */
|
|
38
|
+
dataRoot: string
|
|
39
|
+
/** 练习台入口地址(如 http://127.0.0.1:18800/)。 */
|
|
40
|
+
practiceUrl: string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** assets/skills/ 目录(lib/ 上一级的 assets)。 */
|
|
44
|
+
const SKILL_DIR = fileURLToPath(new URL('../assets/skills/', import.meta.url))
|
|
45
|
+
|
|
46
|
+
/** 一个内嵌技能的静态元数据。 */
|
|
47
|
+
interface EmbeddedSkill {
|
|
48
|
+
name: string
|
|
49
|
+
description: string
|
|
50
|
+
whenToUse?: string
|
|
51
|
+
file: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** 三个内嵌技能。description 即路由摘要,措辞与学习区原版保持同源。 */
|
|
55
|
+
const SKILLS: readonly EmbeddedSkill[] = [
|
|
56
|
+
{
|
|
57
|
+
name: 'one-to-one-tutor',
|
|
58
|
+
description: '一对一家教教学模式:先基于「知识整理」已有材料备课,再按知识点逐轮讲解,每轮只讲一个知识点,并把快速检查与易/中/难三道分层练习出成选择题写进练习台网页,用户作答、提交后自动把成绩送回来批改,批改通过才进入下一知识点。',
|
|
59
|
+
whenToUse: '用户说「开始教我」「进入教学模式」「带我学某某内容」「一对一辅导我」等要求开始教学时使用;也适用于出易中难分层练习、批改作答、按掌握度推进复习的场景。整理课件用 course-material-digest。',
|
|
60
|
+
file: 'one-to-one-tutor.md',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'course-material-digest',
|
|
64
|
+
description: '把大学课程原始资料(PPT / PDF)整理成知识材料:思维导图、分节详解、公式速查表、考点分布。核心纪律:读原始文件(读图),不读 OCR;宁可少写,不许猜。整理课件、做思维导图、提炼知识点、复习提纲时使用。',
|
|
65
|
+
whenToUse: '用户提到「整理课件 / 做思维导图 / 知识点整理 / 复习提纲 / 这门课的 PPT / 教材」,或要把课程原始文件变成可复习的知识材料时。',
|
|
66
|
+
file: 'course-material-digest.md',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'course-inbox-sync',
|
|
70
|
+
description: '跨平台课程资料同步 + 作业 DDL 提醒:扫描 QQ/微信/企业微信已落盘的附件与群文件,与「知识整理」比对找出未整理资料并补齐;从附件正文抽取作业截止时间并提醒。五层流水线:采集 → 比对 → 补做 → 台账 → DDL。',
|
|
71
|
+
whenToUse: '用户说「更新学习进度」「同步课程资料」「看看有没有新课件」「作业 DDL 提醒」「跨平台收件箱」时使用。',
|
|
72
|
+
file: 'course-inbox-sync.md',
|
|
73
|
+
},
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
const INVOCATION = { modelInvocable: true, userInvocable: true } as const
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 组装一节「插件环境附录」,追加到技能正文末尾。
|
|
80
|
+
* @param env - 部署事实(dataRoot / practiceUrl)。
|
|
81
|
+
* @param skillName - 技能名(附录按技能微调内容)。
|
|
82
|
+
* @returns 附录 markdown(带标题)。
|
|
83
|
+
*/
|
|
84
|
+
function envAppendix(env: SkillEnv, skillName: string): string {
|
|
85
|
+
const lines: string[] = [
|
|
86
|
+
'',
|
|
87
|
+
'---',
|
|
88
|
+
'',
|
|
89
|
+
'## 插件环境附录(由 dsh-learning-assistant 自动追加)',
|
|
90
|
+
'',
|
|
91
|
+
`> 本节是**本机部署事实**,优先级高于正文里的默认值。`,
|
|
92
|
+
`- 数据根目录(题库/答卷/笔迹/收件箱/进度/采集产物):\`${env.dataRoot}\``,
|
|
93
|
+
`- 练习台入口:\`${env.practiceUrl}\``,
|
|
94
|
+
]
|
|
95
|
+
if (skillName === 'one-to-one-tutor') {
|
|
96
|
+
lines.push(
|
|
97
|
+
`- 题目 JSON 落盘:\`${env.dataRoot}\\_题库\\<科目>\\<练习id>.json\`(校验/探针脚本与练习台服务脚本随插件 assets 提供)`,
|
|
98
|
+
`- 上面的 \`curl\` 示例中的答卷路径前缀按数据根改写;record 字段以答卷 JSON 里的实际路径为准。`,
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
if (skillName === 'course-material-digest') {
|
|
102
|
+
lines.push(
|
|
103
|
+
`- 工具脚本:随插件 assets 的 \`tools\\pptx-digest.py\` / \`tools\\pptx-media.py\` / \`tools\\pptx-map.py\` / \`tools\\pdf\\pdf-render.ps1\``,
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
if (skillName === 'course-inbox-sync') {
|
|
107
|
+
lines.push(
|
|
108
|
+
`- 采集脚本:随插件 assets 的 \`tools\\qq-group-sync.py\` / \`tools\\qq-group-msg.py\` / \`tools\\im-collect\\wecom_collect.py\``,
|
|
109
|
+
`- 群号白名单、NapCat 端点与令牌、下载根、企微 Cache 根:见插件设置「资料整理」分区,配置后即成上述脚本的 --config/环境变量。`,
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
return lines.join('\n')
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 构建内嵌 provider。
|
|
117
|
+
* @param env - 读取部署事实(每次 get 都读,配置热改即生效)。
|
|
118
|
+
* @returns 可注册到 ctx.skills 的 provider。
|
|
119
|
+
*/
|
|
120
|
+
export function learningSkillProvider(env: () => SkillEnv): SkillProvider {
|
|
121
|
+
const candidates: SkillCandidate[] = SKILLS.map((s, i) => ({
|
|
122
|
+
name: s.name,
|
|
123
|
+
description: s.description,
|
|
124
|
+
...(s.whenToUse ? { whenToUse: s.whenToUse } : {}),
|
|
125
|
+
invocation: INVOCATION,
|
|
126
|
+
provider: PROVIDER_NAME,
|
|
127
|
+
source: 'bundled',
|
|
128
|
+
resourceBase: { kind: 'directory', path: SKILL_DIR },
|
|
129
|
+
rank: EMBEDDED_SKILL_RANK,
|
|
130
|
+
locator: i,
|
|
131
|
+
}))
|
|
132
|
+
return {
|
|
133
|
+
name: PROVIDER_NAME,
|
|
134
|
+
list: () => Promise.resolve(candidates),
|
|
135
|
+
async get(candidate): Promise<SkillDefinition | undefined> {
|
|
136
|
+
const meta = SKILLS[candidate.locator as number]
|
|
137
|
+
if (!meta || candidate.name !== meta.name) return undefined
|
|
138
|
+
let body: string
|
|
139
|
+
try {
|
|
140
|
+
body = await readFile(new URL(`../assets/skills/${meta.file}`, import.meta.url), 'utf8')
|
|
141
|
+
} catch {
|
|
142
|
+
return undefined
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
name: meta.name,
|
|
146
|
+
description: meta.description,
|
|
147
|
+
...(meta.whenToUse ? { whenToUse: meta.whenToUse } : {}),
|
|
148
|
+
invocation: INVOCATION,
|
|
149
|
+
provider: PROVIDER_NAME,
|
|
150
|
+
source: 'bundled',
|
|
151
|
+
resourceBase: { kind: 'directory', path: SKILL_DIR },
|
|
152
|
+
content: body + envAppendix(env(), meta.name),
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
}
|
|
156
|
+
}
|
package/lib/client.d.mts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
declare const name = "dsh-learning-assistant";
|
|
3
|
-
/** 只要 slot 注册表;其余能力(locale、configForms)在页面里按需查找。 */
|
|
4
|
-
declare const inject: string[];
|
|
5
|
-
/**
|
|
6
|
-
* 注册设置页分区。
|
|
7
|
-
* @param ctx - 客户端根上下文。
|
|
8
|
-
*/
|
|
9
|
-
declare function apply(ctx: Context): void;
|
|
10
|
-
export { apply, inject, name };
|
package/lib/client.mjs
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
// src/client/settings.tsx
|
|
4
|
-
/** 设置对话框里的分区 id。 */
|
|
5
|
-
const SECTION_ID = "dsh-learning-assistant";
|
|
6
|
-
/** 三个板块,顺序即页面顺序。 */
|
|
7
|
-
const TABS = [
|
|
8
|
-
{
|
|
9
|
-
id: "material",
|
|
10
|
-
label: "资料整理"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
id: "teach",
|
|
14
|
-
label: "知识整理与讲解"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
id: "data",
|
|
18
|
-
label: "学习助手数据"
|
|
19
|
-
}
|
|
20
|
-
];
|
|
21
|
-
/**
|
|
22
|
-
* 三分区页面。
|
|
23
|
-
* @returns 设置页内容。
|
|
24
|
-
*/
|
|
25
|
-
function LearningAssistantSection() {
|
|
26
|
-
const [active, setActive] = useState(TABS[0].id);
|
|
27
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
28
|
-
style: {
|
|
29
|
-
display: "flex",
|
|
30
|
-
flexDirection: "column",
|
|
31
|
-
gap: 12
|
|
32
|
-
},
|
|
33
|
-
children: [
|
|
34
|
-
/* @__PURE__ */ jsx("nav", {
|
|
35
|
-
style: {
|
|
36
|
-
display: "flex",
|
|
37
|
-
gap: 8,
|
|
38
|
-
borderBottom: "1px solid var(--dsh-border, #e5e7eb)"
|
|
39
|
-
},
|
|
40
|
-
children: TABS.map((tab) => /* @__PURE__ */ jsx("button", {
|
|
41
|
-
onClick: () => setActive(tab.id),
|
|
42
|
-
style: {
|
|
43
|
-
padding: "6px 10px",
|
|
44
|
-
border: "none",
|
|
45
|
-
background: "none",
|
|
46
|
-
cursor: "pointer",
|
|
47
|
-
fontWeight: active === tab.id ? 600 : 400,
|
|
48
|
-
borderBottom: active === tab.id ? "2px solid currentColor" : "2px solid transparent"
|
|
49
|
-
},
|
|
50
|
-
children: tab.label
|
|
51
|
-
}, tab.id))
|
|
52
|
-
}),
|
|
53
|
-
active === "material" && /* @__PURE__ */ jsxs("section", { children: [
|
|
54
|
-
/* @__PURE__ */ jsx("h3", { children: "资料整理" }),
|
|
55
|
-
/* @__PURE__ */ jsx("p", { children: "QQ(NapCat)已通;企业微信走 UIA 采集;微信 4.x 待社区适配。" }),
|
|
56
|
-
/* @__PURE__ */ jsx("p", { children: "白名单:只采集下面配置里点名的群。" })
|
|
57
|
-
] }),
|
|
58
|
-
active === "teach" && /* @__PURE__ */ jsxs("section", { children: [/* @__PURE__ */ jsx("h3", { children: "知识整理与讲解" }), /* @__PURE__ */ jsx("p", { children: "按学科选择讲解方案(粒度、是否先出导图、例题风格),可自建方案。" })] }),
|
|
59
|
-
active === "data" && /* @__PURE__ */ jsxs("section", { children: [/* @__PURE__ */ jsx("h3", { children: "学习助手数据" }), /* @__PURE__ */ jsx("p", { children: "课程计划、学习历史、作答记录;练习台在此打开。" })] })
|
|
60
|
-
]
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* 注册设置页分区。
|
|
65
|
-
* @param ctx - 客户端根上下文。
|
|
66
|
-
*/
|
|
67
|
-
function registerSettingsSection(ctx) {
|
|
68
|
-
const slots = ctx.slots;
|
|
69
|
-
slots.inject("settings.section", () => slots.register({
|
|
70
|
-
name: "settings.section",
|
|
71
|
-
id: SECTION_ID,
|
|
72
|
-
order: 96,
|
|
73
|
-
label: () => "学习助手"
|
|
74
|
-
}, LearningAssistantSection));
|
|
75
|
-
}
|
|
76
|
-
// src/client/index.tsx
|
|
77
|
-
const name = "dsh-learning-assistant";
|
|
78
|
-
/** 只要 slot 注册表;其余能力(locale、configForms)在页面里按需查找。 */
|
|
79
|
-
const inject = ["slots"];
|
|
80
|
-
/**
|
|
81
|
-
* 注册设置页分区。
|
|
82
|
-
* @param ctx - 客户端根上下文。
|
|
83
|
-
*/
|
|
84
|
-
function apply(ctx) {
|
|
85
|
-
registerSettingsSection(ctx);
|
|
86
|
-
}
|
|
87
|
-
export { apply, inject, name };
|
package/lib/index.mjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import z from "@deepseek-ai/schemastery";
|
|
2
|
-
// src/index.ts
|
|
3
|
-
/** Cordis 插件名,与 package.json 的 name、cordis.patch.yml 的 entry id 一致。 */
|
|
4
|
-
const name = "dsh-learning-assistant";
|
|
5
|
-
/** 需要宿主提供的服务:工具注册表、技能注册表、文件系统接缝。 */
|
|
6
|
-
const inject = [
|
|
7
|
-
"tools",
|
|
8
|
-
"skills",
|
|
9
|
-
"fs"
|
|
10
|
-
];
|
|
11
|
-
/** Loader 校验的配置 schema。 */
|
|
12
|
-
const Config = z.object({
|
|
13
|
-
dataRoot: z.string().default("").description("数据根目录 / Data root"),
|
|
14
|
-
practiceDeskPort: z.natural().default(18800).description("练习台端口 / Practice desk port"),
|
|
15
|
-
collectGroups: z.object({
|
|
16
|
-
qq: z.array(z.string()).default([]).description("QQ 群号白名单"),
|
|
17
|
-
wecom: z.array(z.string()).default([]).description("企微群名白名单")
|
|
18
|
-
}).default({
|
|
19
|
-
qq: [],
|
|
20
|
-
wecom: []
|
|
21
|
-
})
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* 注册全部能力。
|
|
25
|
-
* @param ctx - 注册上下文。
|
|
26
|
-
* @param config - 已校验的部署配置。
|
|
27
|
-
*/
|
|
28
|
-
function apply(ctx, config) {}
|
|
29
|
-
export { Config, apply, inject, name };
|