@oxmumu3/dsh-incidental-learn 0.1.7 → 0.2.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/lib/ledger.js CHANGED
@@ -15,6 +15,8 @@ import {
15
15
  cleanText,
16
16
  DEFAULT_TRACKS,
17
17
  MASTERY_LABELS,
18
+ MAX_AUTO_TRIAGE,
19
+ MAX_DIRECT_UNREAD,
18
20
  normalizeEpistemic,
19
21
  normalizeSource,
20
22
  sanitizeQuizBlock,
@@ -298,6 +300,36 @@ export function createLedgerStore(options = {}) {
298
300
  if (aWeak !== bWeak) return bWeak - aWeak
299
301
  return ((b.priority || 0) - (a.priority || 0)) || (a.masteryTier - b.masteryTier)
300
302
  })
303
+ const sprintPicked = [...unmastered].sort((a, b) => (a.masteryTier - b.masteryTier) || ((b.priority || 0) - (a.priority || 0))).slice(0, 3)
304
+ if (sprintPicked.length < 3) {
305
+ const seenSprintTitles = new Set(sprintPicked.map(x => x.title))
306
+ for (const cand of state.triage) {
307
+ if (sprintPicked.length >= 3) break
308
+ if (!cand || seenSprintTitles.has(cand.title)) continue
309
+ seenSprintTitles.add(cand.title)
310
+ sprintPicked.push({ ...cand, masteryTier: 0, isUnread: true })
311
+ }
312
+ }
313
+ const sprintStations = sprintPicked.map((it, idx) => ({
314
+ station: idx + 1,
315
+ durationMin: 5,
316
+ itemId: it.id,
317
+ title: it.title,
318
+ trackId: it.trackId,
319
+ why: it.why,
320
+ rejected: it.rejected,
321
+ probe: it.probe,
322
+ masteryTier: it.masteryTier || 0,
323
+ masteryLabel: it.masteryTier >= 1 ? MASTERY_LABELS[it.masteryTier] : '0/4 新抓到 · 未看',
324
+ isUnread: !(it.masteryTier >= 1),
325
+ focus: (it.masteryTier || 0) < 3 ? '盲测澄清关键取舍' : '换项目场景迁移追问',
326
+ }))
327
+ const sprint15m = {
328
+ trackId: 'all',
329
+ trackTitle: '一本手账未吃透精选',
330
+ totalMinutes: Math.max(5, sprintStations.length * 5),
331
+ stations: sprintStations,
332
+ }
301
333
  const spotlight = sortedSpotlight[0] || state.items[0] || null
302
334
  const masteredTotal = state.items.filter(it => it.masteryTier >= 3).length
303
335
  const activeTodoCount = state.items.filter(it => it.masteryTier < 3).length
@@ -311,6 +343,7 @@ export function createLedgerStore(options = {}) {
311
343
  triage: state.triage,
312
344
  triageOverCap: state.triage.length > 5,
313
345
  spotlight,
346
+ sprint15m,
314
347
  stats: {
315
348
  totalItems: state.items.length,
316
349
  masteredItems: masteredTotal,
@@ -397,6 +430,15 @@ export function createLedgerStore(options = {}) {
397
430
  if (isAuto && cardKey && (draft.autoCapturedKeys.includes(cardKey) || draft.dismissedCardKeys.includes(cardKey))) {
398
431
  return { candidate: null, deduplicated: true, autoSkipped: true }
399
432
  }
433
+ const rawWhy = cleanText(payload.why, 500)
434
+ const rawRej = cleanText(payload.rejected, 500)
435
+ const isGenericWhy = rawWhy === '已基于当前项目边界做出取舍。'
436
+ const isGenericRej = rawRej === '已排除高维护成本或脆弱实现方案。' || rawRej === '已排除脆弱或高成本备选方案。'
437
+ const hasSubstantiveWhy = Boolean(rawWhy) && !isGenericWhy
438
+ const hasSubstantiveRej = Boolean(rawRej) && !isGenericRej
439
+ if (isAuto && (Boolean(payload.lowValue) || (!hasSubstantiveWhy && !hasSubstantiveRej))) {
440
+ return { candidate: null, deduplicated: false, autoSkipped: true, lowQuality: true }
441
+ }
400
442
  const existingItem = draft.items.find(it => it.title === title)
401
443
  if (existingItem) {
402
444
  if (isAuto && cardKey && !draft.autoCapturedKeys.includes(cardKey)) {
@@ -436,6 +478,9 @@ export function createLedgerStore(options = {}) {
436
478
  capturedAt: Date.now(),
437
479
  }
438
480
  draft.triage.unshift(candidate)
481
+ if (isAuto && draft.triage.length > MAX_AUTO_TRIAGE) {
482
+ draft.triage = draft.triage.slice(0, MAX_AUTO_TRIAGE)
483
+ }
439
484
  if (cardKey && !draft.autoCapturedKeys.includes(cardKey)) {
440
485
  draft.autoCapturedKeys = [...draft.autoCapturedKeys, cardKey].slice(-400)
441
486
  }
@@ -535,12 +580,24 @@ export function createLedgerStore(options = {}) {
535
580
  return { snapshot: buildSnapshot(state), ...extra }
536
581
  },
537
582
 
538
- async triageBatch({ mode } = {}) {
539
- if (mode !== 'accept_all' && mode !== 'sweep_low_value' && mode !== 'clear_all') {
540
- throw new Error('triageBatch requires mode accept_all|sweep_low_value|clear_all')
583
+ async triageBatch({ mode, keep } = {}) {
584
+ if (mode !== 'accept_all' && mode !== 'sweep_low_value' && mode !== 'clear_all' && mode !== 'clear_older') {
585
+ throw new Error('triageBatch requires mode accept_all|sweep_low_value|clear_all|clear_older')
541
586
  }
542
587
  const { state, extra } = await mutate(draft => {
543
588
  if (draft.triage.length === 0) return { affected: 0, mode }
589
+ if (mode === 'clear_older') {
590
+ const keepCount = Number.isInteger(keep) && keep >= 0 ? keep : MAX_DIRECT_UNREAD
591
+ if (draft.triage.length <= keepCount) return { affected: 0, mode }
592
+ const dropped = draft.triage.slice(keepCount)
593
+ pushUndo(draft, `清理 ${dropped.length} 条较早未看`)
594
+ const droppedKeys = dropped.map(c => c.cardKey).filter(Boolean)
595
+ if (droppedKeys.length > 0) {
596
+ draft.dismissedCardKeys = [...new Set([...draft.dismissedCardKeys, ...droppedKeys])].slice(-400)
597
+ }
598
+ draft.triage = draft.triage.slice(0, keepCount)
599
+ return { affected: dropped.length, mode }
600
+ }
544
601
  if (mode === 'clear_all') {
545
602
  const clearedCount = draft.triage.length
546
603
  pushUndo(draft, `清空 ${clearedCount} 张自动存档`)
@@ -591,12 +648,13 @@ export function createLedgerStore(options = {}) {
591
648
  return { snapshot: buildSnapshot(state), ...extra }
592
649
  },
593
650
 
594
- async recordMicroDrill({ itemId, card, correct, selectedKey, evidenceNote } = {}) {
651
+ async recordMicroDrill({ itemId, candId, card, correct, toTier, selectedKey, evidenceNote } = {}) {
595
652
  const safeCard = card && typeof card === 'object' ? card : {}
596
653
  const title = cleanText(safeCard.title, 180)
654
+ const resolvedCandId = cleanText(candId, 80)
597
655
  const { state, extra } = await mutate(draft => {
598
656
  let target = findItemByTitleOrId(draft, { itemId: itemId || safeCard.id, title })
599
- const targetTier = correct ? 3 : 2
657
+ const targetTier = toTier ? clampTier(toTier) : (correct ? 3 : 2)
600
658
  const now = Date.now()
601
659
  const note = cleanText(evidenceNote, 420) || (
602
660
  correct
@@ -605,13 +663,23 @@ export function createLedgerStore(options = {}) {
605
663
  )
606
664
  pushUndo(draft, `90s 小灶记录「${(target?.title || title || '卡片').slice(0, 12)}」`)
607
665
 
666
+ const dropMatchingTriage = (matchedTitle, matchedItemId) => {
667
+ draft.triage = draft.triage.filter(c =>
668
+ c.title !== matchedTitle &&
669
+ (!matchedItemId || c.id !== matchedItemId) &&
670
+ (!resolvedCandId || c.id !== resolvedCandId) &&
671
+ (!safeCard.id || c.id !== safeCard.id) &&
672
+ (!itemId || c.id !== itemId),
673
+ )
674
+ }
675
+
608
676
  if (target) {
609
677
  const fromTier = target.masteryTier
610
678
  target.masteryTier = Math.max(target.masteryTier, targetTier)
611
679
  target.evidenceSummary = note
612
680
  target.epistemic = target.epistemic === 'verified' ? 'verified' : 'explicit'
613
681
  target.updatedAt = now
614
- draft.triage = draft.triage.filter(c => c.title !== target.title && c.id !== target.id)
682
+ dropMatchingTriage(target.title, target.id)
615
683
  return { item: cloneJson(target), fromTier, toTier: target.masteryTier }
616
684
  }
617
685
 
@@ -634,7 +702,7 @@ export function createLedgerStore(options = {}) {
634
702
  updatedAt: now,
635
703
  }
636
704
  draft.items.unshift(created)
637
- draft.triage = draft.triage.filter(c => c.title !== newTitle)
705
+ dropMatchingTriage(newTitle, created.id)
638
706
  return { item: cloneJson(created), fromTier: 1, toTier: targetTier }
639
707
  })
640
708
  return { snapshot: buildSnapshot(state), ...extra }
package/lib/prompt.js CHANGED
@@ -9,10 +9,10 @@ export const LEARN_PROMPT_MAX_BYTES = 1150
9
9
 
10
10
  export const LEARN_SYSTEM_PROMPT = [
11
11
  '[顺带私教 | SHIELD]',
12
- '1. 日常答疑/改字/常规脚本 0 额外输出;仅当本轮做出实质工程、架构或前端设计取舍时,在回答最末尾附 1 块 ```shield JSON:',
13
- '{"title":"短标题","why":"为什么这么做","rejected":"被排除差方案","probe":"一句话摸底","trackId":"track-frontend|track-engineering|track-ai|track-product","quiz":{"question":"题干","options":[{"key":"A","label":"选项A","correct":false,"feedback":"纠偏"},{"key":"B","label":"选项B","correct":true,"feedback":"解释"}]}}',
14
- '2. 仅用户明说保存/记录盲区时才调 learn_save;不要静默写盘。',
15
- '3. 若用户消息以 [顺带私教·专心闯关] 开头,走先探后讲+换景追问:第1轮先发 ```learn-quiz JSON(step:1,totalSteps:2,title,scenario,question,before,after,options,analogy)停下等答;第2轮诊断并出换项目迁移 learn-quiz;通过后调 learn_checkpoint(传人话 evidenceSummary 与 toTier:4)并输出 ```learn-pass JSON(itemId,title,fromTier,toTier,evidenceSummary,trackTitle)。',
12
+ '1. 严选不刷屏:日常答疑/改字/常规脚本 0 输出;仅本轮踩反直觉坑或做出跨项目架构/设计取舍(单会话限1张,why/rejected 须点明具体边界与坑)时,在末尾附 1 块 ```shield JSON:',
13
+ '{"title":"短标题","why":"核心取舍","rejected":"排除方案及坑","probe":"摸底","trackId":"track-frontend|track-engineering|track-ai|track-product","quiz":{"question":"题干","options":[{"key":"A","label":"选项A","correct":false,"feedback":"纠偏"},{"key":"B","label":"选项B","correct":true,"feedback":"解释"}]}}',
14
+ '2. 仅用户明说保存时才调 learn_save;勿静默写盘。',
15
+ '3. 若消息以 [顺带私教·专心闯关] 开头,走先探后讲+换景追问:第1轮先发 ```learn-quiz JSON(step:1,totalSteps:2,title,scenario,question,before,after,options,analogy)停下等答;第2轮诊断并出换项目迁移 learn-quiz;通过后调 learn_checkpoint(传人话 evidenceSummary 与 toTier:4)并输出 ```learn-pass JSON(itemId,title,fromTier,toTier,evidenceSummary,trackTitle)。',
16
16
  ].join('\n')
17
17
 
18
18
  export function registerLearnPrompt(ctx, log = () => {}) {
package/lib/routes.js CHANGED
@@ -212,8 +212,10 @@ export async function handleActionRequest({ request, ctx, store }) {
212
212
  }
213
213
  if (action === 'build_course') {
214
214
  const { snapshot } = store.getSnapshot()
215
- const trackId = body.trackId || snapshot.tracks[0]?.id
216
- const track = snapshot.tracks.find(t => t.id === trackId) || snapshot.tracks[0]
215
+ if (!body.trackId) {
216
+ return jsonReply({ ok: true, action, course: snapshot.sprint15m || null, snapshot })
217
+ }
218
+ const track = snapshot.tracks.find(t => t.id === body.trackId) || snapshot.tracks[0]
217
219
  return jsonReply({ ok: true, action, course: track ? track.course15m : null, snapshot })
218
220
  }
219
221
  if (action === 'export_markdown') {
package/locale/en.json CHANGED
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "appTitle": "Incidental Coach",
3
- "eyebrow": "INCIDENTAL LEARNING · PERSONAL SKILL LIBRARY",
3
+ "eyebrow": "INCIDENTAL LEARNING · UNIFIED SKILL LEDGER",
4
4
  "navLabel": "Incidental Coach",
5
5
  "coachTabTitle": "Side Study",
6
- "summaryMetrics": "{mastered} / {total} mastered · {tracks} categories · {triage} auto-saved",
7
- "spotlightHeading": "Up Next to Learn",
8
- "spotlightPrimary": "Start 3-Min Deep Study",
9
- "spotlightSecondary": "Inspect Card Details",
10
- "triageHeading": "Background Auto-Archive",
11
- "triageAccept": "Add to Focus List",
12
- "triageSkip": "Skip",
13
- "triageAcceptAll": "Add All to Focus List",
14
- "triageSweepLow": "Sweep Minor Items",
15
- "tracksHeading": "Skill Categories",
16
- "course15mBtn": "15-Min Focus Session",
6
+ "summaryMetrics": "{total} total ({mastered} mastered · {triage} newly captured unread)",
7
+ "spotlightHeading": "Up Next Today",
8
+ "spotlightPrimary": "3-Min Focus Upgrade",
9
+ "spotlightSecondary": "Open Skill Card",
10
+ "triageHeading": "Newly Captured Unread",
11
+ "triageAccept": "10s Quick Quiz",
12
+ "triageSkip": "Remove",
13
+ "triageAcceptAll": "Mark Reviewed (2/4) In-Place",
14
+ "triageSweepLow": "Clear Older Unread",
15
+ "tracksHeading": "Unified Skill Ledger",
16
+ "course15mBtn": "Draw Sprint Quiz · 15m",
17
17
  "exportNotesBtn": "Export Study Notes",
18
- "guideOpenBtn": "Usage Guide",
19
- "guideCloseBtn": "Hide Guide",
20
- "loadSamplesBtn": "Preview Full Sample State",
18
+ "guideOpenBtn": "How It Works",
19
+ "guideCloseBtn": "Hide Diagram",
20
+ "loadSamplesBtn": "Preview Daily & Backlog Guards (0 Token)",
21
21
  "startChatBtn": "Try a Task in New Chat",
22
22
  "resetEmptyBtn": "Reset Empty State",
23
23
  "undoAction": "Undo",
package/locale/zh.json CHANGED
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "appTitle": "顺带私教",
3
- "eyebrow": "平时协作攒经验 · 个人技能库",
3
+ "eyebrow": "平时协作攒经验 · 一本手账零搬运",
4
4
  "navLabel": "顺带私教",
5
5
  "coachTabTitle": "顺带学习栏",
6
- "summaryMetrics": "已掌握 {mastered} / {total} 项 · {tracks} 类技能 · 后台自动存档 {triage} 张",
7
- "spotlightHeading": "优先待学",
8
- "spotlightPrimary": "开始 3 分钟展开学",
9
- "spotlightSecondary": "看卡片解析",
10
- "triageHeading": "后台自动存档",
11
- "triageAccept": "存进技能库",
12
- "triageSkip": "跳过",
13
- "triageAcceptAll": "全部存进技能库",
14
- "triageSweepLow": "清理细碎卡片",
15
- "tracksHeading": "沉淀下来的技能分类",
16
- "course15mBtn": "15 分钟集中学",
6
+ "summaryMetrics": "共 {total} 条({mastered} 已吃透 · {triage} 条新抓到未看)",
7
+ "spotlightHeading": "今日优先吃透",
8
+ "spotlightPrimary": "3 分钟闯关升级",
9
+ "spotlightSecondary": "看经验手卡",
10
+ "triageHeading": "新抓到 · 未看",
11
+ "triageAccept": "10 秒快测",
12
+ "triageSkip": "删掉",
13
+ "triageAcceptAll": "原地记为 2/4 讲过一轮",
14
+ "triageSweepLow": "清掉较早旧未看",
15
+ "tracksHeading": "一本手账列表",
16
+ "course15mBtn": "连抽考考我 · 15m",
17
17
  "exportNotesBtn": "导出学习笔记",
18
- "guideOpenBtn": "使用说明",
19
- "guideCloseBtn": "收起说明",
20
- "loadSamplesBtn": "看看攒下卡片后长什么样",
18
+ "guideOpenBtn": "工作原理图",
19
+ "guideCloseBtn": "收起原理图",
20
+ "loadSamplesBtn": "看看日常攒卡与防刷屏效果(不耗 Token)",
21
21
  "startChatBtn": "去新会话派个活试试",
22
22
  "resetEmptyBtn": "恢复初始空页面",
23
23
  "undoAction": "撤销",
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@oxmumu3/dsh-incidental-learn",
3
- "version": "0.1.7",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
- "description": "在日常与 Agent 协作中顺手攒经验、沉淀个人技能库的 DeepSeek Harness 插件(对话末尾低调学习卡 + 后台自动存档 + 右侧边聊边学)",
8
+ "description": "在日常与 Agent 协作中顺手攒经验、一本手账零搬运沉淀个人技能库的 DeepSeek Harness 插件(严选防刷屏学习卡 + 10 秒快测 + 右侧边聊边测)",
9
9
  "author": "牛村木木山 <157776623+oxmumu3@users.noreply.github.com>",
10
10
  "repository": {
11
11
  "type": "git",
@@ -74,6 +74,6 @@
74
74
  },
75
75
  "engines": {
76
76
  "node": ">=22.0.0",
77
- "dsh": "0.2.2-rc.2 || 0.2.2-rc.3"
77
+ "dsh": ">=0.2.2-rc.2 <0.3.0"
78
78
  }
79
79
  }
package/shared/schema.js CHANGED
@@ -5,6 +5,8 @@
5
5
  export const PANEL_KEY = 'incidental-learn'
6
6
  export const COACH_TAB_ID = '@oxmumu3/dsh-incidental-learn/coach'
7
7
  export const COACH_TAB_KIND = 'incidental-learn-coach'
8
+ export const MAX_AUTO_TRIAGE = 8
9
+ export const MAX_DIRECT_UNREAD = 3
8
10
 
9
11
  export const SOURCES = ['dsh-chat', 'antigravity', 'codex', 'superagent-review', 'manual']
10
12
  export const EPISTEMIC_STATES = ['verified', 'explicit', 'inferred']
@@ -469,3 +471,19 @@ export function buildDeepLearnStarterPrompt(item) {
469
471
  : '请严格按「先探后讲 + 换景追问」节奏带我过关:第 1 轮直接输出一个 ```learn-quiz JSON 代码块让我先盲选判断并停下等我回复,暂不要剧透完整解释。',
470
472
  ].filter(Boolean).join('\n')
471
473
  }
474
+
475
+ export function buildSprintStarterPrompt(stations) {
476
+ const list = Array.isArray(stations) ? stations.filter(Boolean).slice(0, 3) : []
477
+ if (list.length === 0) return buildDeepLearnStarterPrompt({ title: '一本手账精选串联闯关', masteryTier: 1 })
478
+ if (list.length === 1) return buildDeepLearnStarterPrompt(list[0])
479
+ const lines = list.map((st, idx) => {
480
+ const label = cleanText(st.masteryLabel, 40) || MASTERY_LABELS[clampTier(st.masteryTier || 1)]
481
+ return `第 ${idx + 1} 站:${cleanText(st.title, 120)}(itemId: ${cleanText(st.itemId || st.id, 80) || 'ad-hoc'},当前 ${label})`
482
+ })
483
+ return [
484
+ '[顺带私教·专心闯关]',
485
+ `本次开启 ${list.length} 站串联考考我(共约 ${list.length * 5} 分钟),逐站按「先探后讲 + 换景追问」过关:`,
486
+ ...lines,
487
+ '请先从第 1 站开始,直接输出一个 ```learn-quiz JSON 代码块让我先盲选判断并停下等我回复,暂不要剧透完整解释;每过一站在调用 learn_checkpoint 后再进入下一站。',
488
+ ].join('\n')
489
+ }