@oxmumu3/dsh-incidental-learn 0.0.0-stage → 0.1.4
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/LICENSE +21 -0
- package/README.md +66 -2
- package/bin/incidental-learn-cli.mjs +118 -0
- package/client.js +2968 -0
- package/cordis.patch.yml +4 -0
- package/index.js +77 -0
- package/lib/ledger.js +724 -0
- package/lib/prompt.js +54 -0
- package/lib/routes.js +256 -0
- package/lib/tools.js +233 -0
- package/locale/en.json +68 -0
- package/locale/zh.json +68 -0
- package/package.json +77 -4
- package/shared/schema.js +448 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 牛村木木山 <157776623+oxmumu3@users.noreply.github.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,67 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 顺带私教 (`@oxmumu3/dsh-incidental-learn`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> 作者:`牛村木木山 <157776623+oxmumu3@users.noreply.github.com>`
|
|
4
|
+
> 适用宿主:`DeepSeek Harness >=0.2.2-rc.2 || 0.2.2-rc.3`
|
|
5
|
+
|
|
6
|
+
把日常跟 Agent 协作干活中遇到的真实工程、架构与前端设计取舍顺手攒下来,沉淀为个人技能库:平时干活零打扰,仅在值得留心的回合末尾附上一条低调柔和灰的可折起「顺带学习卡」(带「附 · 顺带补充(非本轮主回复)」分隔与默认折起 1 行摘要条,不抢主回答的风头);忙时完全不用点按钮,系统在后台自动存档;有空时点击「在右侧边聊边学」在右侧顺带学习栏不扰动主对话草稿完成一题点拨,或点「开始 3 分钟展开学」深入闯关并沉淀跨 Agent 共享技能库。
|
|
7
|
+
|
|
8
|
+
## 在 DeepSeek Harness 中安装
|
|
9
|
+
|
|
10
|
+
### 方式一:创造模式一句话安装(推荐)
|
|
11
|
+
|
|
12
|
+
1. 在 DeepSeek Harness 新建会话,点顶部「标准模式」下拉,切到「创造模式」。
|
|
13
|
+
2. 复制下面这句话发给 Agent,弹出授权时点「允许」:
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
请通过插件管理器,从 npm 官方源安装并启用 @oxmumu3/dsh-incidental-learn@0.1.4。完成后请核对版本和启用状态,再带我打开左侧「顺带私教」。
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 方式二:插件管理页直接添加
|
|
20
|
+
|
|
21
|
+
进入「插件 -> 添加插件」,填入 `@oxmumu3/dsh-incidental-learn@0.1.4`(桌面端内置包管理器默认对刚发布未满 24 小时的版本启用发布年龄策略,填写带精确版本号的包名可直接装入最新版),安装后点击「立即启用」。
|
|
22
|
+
|
|
23
|
+
## 架构概览
|
|
24
|
+
|
|
25
|
+
1. **五格客户端槽位 (`client.js`)**:
|
|
26
|
+
- `sidebar.panellist` + `main` (`key: 'incidental-learn'`):840px 单栏个人技能库、三步图文使用说明(0/0 空态直出、积累后可通过顶栏「使用说明」收放)、默认折叠的「效果预览」(`details` + `toolbar`) 与「后台自动存档」清单、15 分钟集中学、原生 `<dialog closedby="any">` 过关详情窗与零 Token 示例预览入口。
|
|
27
|
+
- `conversation.chat.markdown.fence` (`shield` / `learn-quiz` / `learn-pass`):独立于 `foldCompletedTurns`,流式阶段平稳占位,定稿后就地交互;其中 `shield` 以「附 · 顺带补充」引导线 + 默认折叠柔和灰折起条呈现,未展开也同样静默写入后台存档。选项作答内置草稿保护(非空不覆盖)与空闲直发(`useInput` + `inputActions`)。
|
|
28
|
+
- `sidebarRightTabs` + `sidebar.right.pane.tab` (`id: '@oxmumu3/dsh-incidental-learn/coach'`, `kind: 'incidental-learn-coach'`):右侧「顺带学习栏」边聊边学,独立升级掌握度至 `3/4 能复述`。
|
|
29
|
+
- `conversation.input.right`:顶部输入栏轻提醒胶囊(`顺带学习 · 已存 N 张`)。
|
|
30
|
+
- `tool.call.toolview`:`learn_save`、`learn_checkpoint`、`learn_triage` 紧凑单行执行回执。
|
|
31
|
+
2. **宿主侧能力 (`index.js` + `lib/`)**:
|
|
32
|
+
- 原子多进程共享账本 (`$DSH_HOME/incidental-learn/ledger.json`):支持 `mtimeMs` 外部变更合并、临时文件 + `renameSync` 原子落盘及 15 步撤销栈。
|
|
33
|
+
- 静态字节预算 `systemPrompt.section`(<= 1150 UTF-8 字节),仅在 `learn_board` 工具可见时注入。
|
|
34
|
+
- 4 个同源工具:`learn_board`、`learn_save`、`learn_checkpoint`、`learn_triage`。
|
|
35
|
+
- `/api/incidental_learn/view` 与 `/api/incidental_learn/action` 同源路由(带 CSRF/Origin、Content-Type 与包体上限校验)。
|
|
36
|
+
3. **跨 Agent CLI 桥 (`bin/incidental-learn-cli.mjs`)**:
|
|
37
|
+
- 供 Antigravity、Codex、Claude Code 或 Super Agent 验收脚本向同一份 `ledger.json` 追加候选卡片或导出笔记:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
dsh-incidental-learn add \
|
|
41
|
+
--source antigravity \
|
|
42
|
+
--track track-frontend \
|
|
43
|
+
--title "@container 必须放在多列规则之后" \
|
|
44
|
+
--why "@container 查询本身不增加选择器优先级,需放在基础网格规则之后才能在窄宽下覆盖列数" \
|
|
45
|
+
--rejected "用全局 @media 查询猜测宿主分屏宽度" \
|
|
46
|
+
--probe "如果在父面板同时使用 grid-template-columns 和 @container,谁写在前面会怎样?"
|
|
47
|
+
|
|
48
|
+
dsh-incidental-learn status
|
|
49
|
+
dsh-incidental-learn export --out ./study-notes.md
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 本地开发与四层门禁验证
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm run build # 将 shared/schema.js 与 src-client/* 编译为单文件 client.js
|
|
56
|
+
npm run check:client # 校验包名、零 ESM export、五格槽位挂载与完整卸载
|
|
57
|
+
npm test # 原子账本并发、CLI、HTTP 安全校验、工具 Schema、Prompt 字节预算与词典一致性
|
|
58
|
+
npm run pack:release # 生成可重现 .tgz 与 .sha256
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 安装到 DeepSeek Harness Desktop
|
|
62
|
+
|
|
63
|
+
建议在退出当前运行的桌面端后通过官方 `dsh plugin` 安装离线包:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
dsh plugin --profile desktop add ./oxmumu3-dsh-incidental-learn-0.1.4.tgz
|
|
67
|
+
```
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Cross-Agent CLI bridge for @oxmumu3/dsh-incidental-learn (`顺带私教`).
|
|
3
|
+
// Lets Antigravity, Codex, Claude Code, and SuperAgent push blind-spot candidates or
|
|
4
|
+
// export study notes directly to $DSH_HOME/incidental-learn/ledger.json.
|
|
5
|
+
|
|
6
|
+
import fs from 'node:fs'
|
|
7
|
+
import path from 'node:path'
|
|
8
|
+
import { createLedgerStore } from '../lib/ledger.js'
|
|
9
|
+
|
|
10
|
+
function parseArgs(argv) {
|
|
11
|
+
const args = [...argv]
|
|
12
|
+
const command = args.shift() || 'status'
|
|
13
|
+
const flags = {}
|
|
14
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
15
|
+
const token = args[i]
|
|
16
|
+
if (!token.startsWith('--')) continue
|
|
17
|
+
const key = token.slice(2)
|
|
18
|
+
const next = args[i + 1]
|
|
19
|
+
if (next !== undefined && !next.startsWith('--')) {
|
|
20
|
+
flags[key] = next
|
|
21
|
+
i += 1
|
|
22
|
+
} else {
|
|
23
|
+
flags[key] = true
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return { command, flags }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function usage() {
|
|
30
|
+
console.log([
|
|
31
|
+
'Usage: dsh-incidental-learn <command> [options]',
|
|
32
|
+
'',
|
|
33
|
+
'Commands:',
|
|
34
|
+
' add Append a candidate card (or explicit item with --explicit)',
|
|
35
|
+
' --title <text> --why <text> [--rejected <text>] [--probe <text>]',
|
|
36
|
+
' [--source antigravity|codex|dsh-chat|superagent-review|manual]',
|
|
37
|
+
' [--track track-frontend|track-harness|track-growth] [--explicit]',
|
|
38
|
+
' status Print ledger summary [--json]',
|
|
39
|
+
' export Export study notes [--track <id>] [--out <path>]',
|
|
40
|
+
'',
|
|
41
|
+
'Common option: [--dsh-home <dir>]',
|
|
42
|
+
].join('\n'))
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function main() {
|
|
46
|
+
const { command, flags } = parseArgs(process.argv.slice(2))
|
|
47
|
+
if (command === '--help' || command === '-h' || flags.help) {
|
|
48
|
+
usage()
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const store = createLedgerStore({ dshHome: flags['dsh-home'] })
|
|
53
|
+
store.ensureInitialized()
|
|
54
|
+
|
|
55
|
+
if (command === 'add') {
|
|
56
|
+
if (!flags.title) {
|
|
57
|
+
console.error('Error: --title is required')
|
|
58
|
+
process.exitCode = 1
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
const payload = {
|
|
62
|
+
title: String(flags.title),
|
|
63
|
+
why: flags.why ? String(flags.why) : '',
|
|
64
|
+
rejected: flags.rejected ? String(flags.rejected) : '',
|
|
65
|
+
probe: flags.probe ? String(flags.probe) : '',
|
|
66
|
+
source: flags.source ? String(flags.source) : 'manual',
|
|
67
|
+
trackId: flags.track ? String(flags.track) : 'track-harness',
|
|
68
|
+
epistemic: flags.explicit ? 'explicit' : 'inferred',
|
|
69
|
+
}
|
|
70
|
+
const res = flags.explicit
|
|
71
|
+
? await store.saveExplicitItem(payload)
|
|
72
|
+
: await store.captureCandidate(payload)
|
|
73
|
+
console.log(JSON.stringify({
|
|
74
|
+
ok: true,
|
|
75
|
+
mode: flags.explicit ? 'explicit' : 'candidate',
|
|
76
|
+
ledgerFile: store.ledgerFile,
|
|
77
|
+
stats: res.snapshot.stats,
|
|
78
|
+
record: res.item || res.candidate,
|
|
79
|
+
}, null, 2))
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (command === 'status') {
|
|
84
|
+
const { snapshot } = store.getSnapshot()
|
|
85
|
+
if (flags.json) {
|
|
86
|
+
console.log(JSON.stringify({ ok: true, ledgerFile: store.ledgerFile, snapshot }, null, 2))
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
console.log(`账本文件: ${store.ledgerFile}`)
|
|
90
|
+
console.log(`已内化 ${snapshot.stats.masteredItems} / ${snapshot.stats.totalItems} 项 · 待分诊 ${snapshot.stats.triageCount} 条`)
|
|
91
|
+
for (const tr of snapshot.tracks) {
|
|
92
|
+
console.log(`- ${tr.title}: ${tr.masteredCount}/${tr.totalCount}`)
|
|
93
|
+
}
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (command === 'export') {
|
|
98
|
+
const exported = store.exportMarkdown({ trackId: flags.track ? String(flags.track) : undefined })
|
|
99
|
+
if (flags.out) {
|
|
100
|
+
const target = path.resolve(String(flags.out))
|
|
101
|
+
fs.mkdirSync(path.dirname(target), { recursive: true })
|
|
102
|
+
fs.writeFileSync(target, exported.markdown, 'utf8')
|
|
103
|
+
console.log(JSON.stringify({ ok: true, filePath: target, bytes: Buffer.byteLength(exported.markdown, 'utf8') }, null, 2))
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
console.log(JSON.stringify({ ok: true, filePath: exported.filePath, bytes: Buffer.byteLength(exported.markdown, 'utf8') }, null, 2))
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
console.error(`Unknown command: ${command}`)
|
|
111
|
+
usage()
|
|
112
|
+
process.exitCode = 1
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
main().catch(err => {
|
|
116
|
+
console.error(err instanceof Error ? err.message : String(err))
|
|
117
|
+
process.exitCode = 1
|
|
118
|
+
})
|