@oxmumu3/dsh-incidental-learn 0.1.6 → 0.1.8

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/client.js CHANGED
@@ -449,16 +449,33 @@ function parseLearnPassFence(code) {
449
449
  }
450
450
  }
451
451
 
452
+ function inferTrackIdFromTopic(text) {
453
+ const s = String(text || '')
454
+ if (/css|flex|grid|container|dialog|布局|样式|动画|前端|界面|颜色|主题|弹窗|悬浮|分屏|按钮|组件/i.test(s)) {
455
+ return 'track-frontend'
456
+ }
457
+ if (/prompt|agent|token|mcp|tool|llm|模型|提示词|上下文|多智能体|围栏/i.test(s)) {
458
+ return 'track-ai'
459
+ }
460
+ if (/增长|转化|标题|留存|分发|引导|文案|小红书|公众号|首屏|定位|用户|产品/i.test(s)) {
461
+ return 'track-product'
462
+ }
463
+ return 'track-engineering'
464
+ }
465
+
452
466
  function buildDeepLearnStarterPrompt(item) {
453
467
  const safe = item && typeof item === 'object' ? item : {}
454
468
  const tierLabel = MASTERY_LABELS[clampTier(safe.masteryTier || 1)]
469
+ const isAdHoc = !safe.rejected && !safe.probe
455
470
  return [
456
471
  '[顺带私教·专心闯关]',
457
472
  `知识点:${cleanText(safe.title, 140) || '当前盲区'}(itemId: ${cleanText(safe.id, 80) || 'ad-hoc'},当前掌握度:${tierLabel})`,
458
473
  safe.why ? `背景取舍:${cleanText(safe.why, 220)}` : '',
459
474
  safe.rejected ? `曾经对比过的坑:${cleanText(safe.rejected, 180)}` : '',
460
475
  safe.probe ? `摸底种子:${cleanText(safe.probe, 180)}` : '',
461
- '请严格按「先探后讲 + 换景追问」节奏带我过关:第 1 轮直接输出一个 ```learn-quiz JSON 代码块让我先盲选判断并停下等我回复,暂不要剧透完整解释。',
476
+ isAdHoc
477
+ ? '这是我主动发起的专心学习主题(若涉及当前工作区代码,可先快速只读扫一眼关键实现)。请严格按「先探后讲 + 换景追问」节奏带我一对一闯关:第 1 轮直接输出一个 ```learn-quiz JSON 代码块让我先盲选判断并停下等我回复,暂不要剧透完整解释。'
478
+ : '请严格按「先探后讲 + 换景追问」节奏带我过关:第 1 轮直接输出一个 ```learn-quiz JSON 代码块让我先盲选判断并停下等我回复,暂不要剧透完整解释。',
462
479
  ].filter(Boolean).join('\n')
463
480
  }
464
481
 
@@ -523,8 +540,9 @@ const ILP_CSS = [
523
540
 
524
541
  // Zero-specificity resets scoped strictly inside plugin containers (never *)
525
542
  ':where(.ilp-wb,.ilp-fence,.ilp-drawer,.ilp-dialog,.ilp-pill) [hidden]{display:none!important}',
526
- ':where(.ilp-wb,.ilp-fence,.ilp-drawer,.ilp-dialog) :is(div,section,article,main,aside,header,footer,button,input,textarea,pre,code,details,summary){box-sizing:border-box}',
543
+ ':where(.ilp-wb,.ilp-fence,.ilp-drawer,.ilp-dialog) :is(div,section,article,main,aside,header,footer,form,label,button,input,select,textarea,pre,code,details,summary){box-sizing:border-box}',
527
544
  ':where(.ilp-wb,.ilp-fence,.ilp-drawer,.ilp-dialog) :is(h1,h2,h3,h4,p,ul,ol,pre){margin:0}',
545
+ ':where(.ilp-wb) :is(input,select){font:inherit;color:inherit}',
528
546
  ':where(.ilp-wb,.ilp-fence,.ilp-drawer,.ilp-dialog) button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer;text-align:left}',
529
547
  '.ilp-wb :is(h1,h2,h3){text-wrap:balance}',
530
548
  '.ilp-wb :is(p,li){text-wrap:pretty}',
@@ -692,6 +710,20 @@ const ILP_CSS = [
692
710
  '.ilp-spot-probe{font-size:12.5px;color:var(--ilp-ink2);padding:8px 11px;border-radius:var(--ilp-r-sm);background:var(--ilp-sub);border:1px solid var(--ilp-line);overflow-wrap:anywhere}',
693
711
  '.ilp-spot-acts{display:flex;flex-direction:column;align-items:stretch;gap:8px;min-width:168px}',
694
712
 
713
+ // Direct Focused Study Launcher (always reachable without prior triage acceptance)
714
+ '.ilp-direct-box{border-radius:var(--ilp-r-lg);border:1px solid var(--ilp-line);background:var(--ilp-panel);padding:16px 18px;display:flex;flex-direction:column;gap:10px;min-width:0}',
715
+ '.ilp-direct-box.is-hero{border-color:var(--ilp-line2);padding:18px 20px}',
716
+ '.ilp-direct-head{display:flex;align-items:baseline;justify-content:space-between;flex-wrap:wrap;gap:4px 12px;min-width:0}',
717
+ '.ilp-direct-title{font-size:14.5px;font-weight:600;color:var(--ilp-ink)}',
718
+ '.ilp-direct-sub{font-size:12px;color:var(--ilp-ink3);overflow-wrap:anywhere}',
719
+ '.ilp-direct-row{display:flex;align-items:center;gap:8px;min-width:0}',
720
+ '.ilp-direct-input{flex:1 1 0%;min-width:0;min-height:35px;padding:6px 11px;border-radius:var(--ilp-r-btn);border:1px solid var(--ilp-line2);background:var(--ilp-bg);color:var(--ilp-ink);font-size:13px;line-height:1.4}',
721
+ '.ilp-direct-input::placeholder{color:var(--ilp-ink3)}',
722
+ '.ilp-direct-ws{max-width:180px;min-height:35px;padding:6px 10px;border-radius:var(--ilp-r-btn);border:1px solid var(--ilp-line2);background:var(--ilp-bg);color:var(--ilp-ink2);font-size:12px}',
723
+ '.ilp-direct-chips{display:flex;flex-wrap:wrap;align-items:center;gap:6px;min-width:0}',
724
+ '.ilp-chip-btn{display:inline-flex;align-items:center;min-height:25px;padding:3px 10px;border-radius:999px;border:1px solid var(--ilp-line);background:var(--ilp-sub);color:var(--ilp-ink2);font-size:11.5px;line-height:1.3}',
725
+ '@media (hover:hover){.ilp-chip-btn:hover:not(:disabled){background:var(--ilp-hover);border-color:var(--ilp-line2);color:var(--ilp-ink)}}',
726
+
695
727
  // Collapsible Background Auto-Archive Inbox
696
728
  '.ilp-triage-box{border-radius:var(--ilp-r-md);border:1px solid var(--ilp-line);background:var(--ilp-panel);overflow:hidden;min-width:0}',
697
729
  '.ilp-triage-head{width:100%;padding:12px 16px;display:flex;align-items:center;justify-content:space-between;gap:10px;background:var(--ilp-panel);min-width:0}',
@@ -699,12 +731,14 @@ const ILP_CSS = [
699
731
  '.ilp-triage-head-left{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0}',
700
732
  '.ilp-triage-body{border-top:1px solid var(--ilp-line);display:flex;flex-direction:column}',
701
733
  '.ilp-triage-batch{padding:10px 16px;background:var(--ilp-wait-bg);border-bottom:1px solid var(--ilp-line);display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px 12px}',
734
+ '.ilp-triage-subbar{padding:9px 16px;background:var(--ilp-sub);border-bottom:1px solid var(--ilp-line);display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px 12px;font-size:12px;color:var(--ilp-ink2)}',
702
735
  '.ilp-triage-row{padding:12px 16px;border-bottom:1px solid var(--ilp-line);display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px 14px;min-width:0}',
703
736
  '.ilp-triage-row:last-child{border-bottom:0}',
704
737
  '.ilp-triage-info{flex:1 1 280px;min-width:0;display:flex;flex-direction:column;gap:4px}',
705
738
  '.ilp-triage-title{font-weight:500;font-size:13px;overflow-wrap:anywhere}',
706
739
  '.ilp-triage-why{font-size:12px;color:var(--ilp-ink2);overflow-wrap:anywhere}',
707
- '.ilp-triage-acts{display:flex;align-items:center;gap:6px;flex-shrink:0}',
740
+ '.ilp-triage-acts{display:flex;align-items:center;flex-wrap:wrap;gap:6px;flex-shrink:0}',
741
+ '.ilp-empty-tracks-note{font-size:12px;color:var(--ilp-ink3);padding:2px 2px;overflow-wrap:anywhere}',
708
742
 
709
743
  // Accordion Capability Tracks
710
744
  '.ilp-tracks{display:flex;flex-direction:column;gap:10px;min-width:0}',
@@ -859,8 +893,14 @@ const ILP_CSS = [
859
893
  ' .ilp-sim-sep{display:none}',
860
894
  ' .ilp-spot-card{grid-template-columns:minmax(0,1fr);padding:18px}',
861
895
  ' .ilp-spot-acts{flex-direction:row;flex-wrap:wrap;min-width:0}',
896
+ ' .ilp-direct-row{flex-direction:column;align-items:stretch}',
897
+ ' .ilp-direct-input{flex:none;width:100%}',
898
+ ' .ilp-direct-ws{max-width:none}',
862
899
  ' .ilp-course-grid{grid-template-columns:minmax(0,1fr)}',
863
900
  '}',
901
+ '@media (pointer:coarse){',
902
+ ' .ilp-direct-input,.ilp-direct-ws{font-size:16px}',
903
+ '}',
864
904
  '@container ilpwb (max-width:660px){',
865
905
  ' .ilp-wb-inner{padding:48px 14px 48px}',
866
906
  '}',
@@ -878,7 +918,7 @@ const ILP_CSS = [
878
918
 
879
919
  // Forced Colors High-Contrast Fallbacks
880
920
  '@media (forced-colors:active){',
881
- ' .ilp-btn,.ilp-sim-btn,.ilp-quiet-btn,.ilp-source-badge,.ilp-badge-card,.ilp-tag,.ilp-onb-step,.ilp-sim-disclosure,.ilp-strip-details,.ilp-mini-win,.ilp-mini-embed,.ilp-toast,dialog.ilp-dialog{border:1px solid ButtonBorder}',
921
+ ' .ilp-btn,.ilp-sim-btn,.ilp-quiet-btn,.ilp-source-badge,.ilp-badge-card,.ilp-tag,.ilp-onb-step,.ilp-sim-disclosure,.ilp-strip-details,.ilp-mini-win,.ilp-mini-embed,.ilp-toast,.ilp-direct-box,.ilp-direct-input,.ilp-direct-ws,.ilp-chip-btn,dialog.ilp-dialog{border:1px solid ButtonBorder}',
882
922
  ' .ilp-btn.solid{background:Highlight;color:HighlightText;border-color:Highlight}',
883
923
  ' .ilp-sim-btn[aria-pressed="true"],.ilp-quiet-btn[aria-pressed="true"]{outline:2px solid Highlight;outline-offset:1px}',
884
924
  ' .ilp-sim-sep{border-left-color:ButtonBorder}',
@@ -943,6 +983,7 @@ var AUTO_CAPTURED_KEYS = new Set()
943
983
 
944
984
  function createClientLedgerBridge() {
945
985
  var snapshot = null
986
+ var workspaces = []
946
987
  var loading = false
947
988
  var error = null
948
989
  var listeners = new Set()
@@ -950,13 +991,14 @@ function createClientLedgerBridge() {
950
991
 
951
992
  function emit() {
952
993
  listeners.forEach(function (fn) {
953
- try { fn({ snapshot: snapshot, loading: loading, error: error }) } catch (_e) {}
994
+ try { fn({ snapshot: snapshot, workspaces: workspaces, loading: loading, error: error }) } catch (_e) {}
954
995
  })
955
996
  }
956
997
 
957
- function setSnapshot(next) {
998
+ function setSnapshot(next, nextWorkspaces) {
958
999
  if (!next) return
959
1000
  snapshot = next
1001
+ if (Array.isArray(nextWorkspaces)) workspaces = nextWorkspaces
960
1002
  versionSeen = next.version
961
1003
  error = null
962
1004
  loading = false
@@ -969,8 +1011,9 @@ function createClientLedgerBridge() {
969
1011
  return fetchJson(VIEW_URL + qs, { headers: { Accept: 'application/json' } })
970
1012
  .then(function (res) {
971
1013
  if (!res.unchanged && res.snapshot) {
972
- setSnapshot(res.snapshot)
1014
+ setSnapshot(res.snapshot, res.workspaces)
973
1015
  } else {
1016
+ if (Array.isArray(res.workspaces)) workspaces = res.workspaces
974
1017
  loading = false
975
1018
  error = null
976
1019
  emit()
@@ -987,7 +1030,7 @@ function createClientLedgerBridge() {
987
1030
 
988
1031
  function runAction(action, payload) {
989
1032
  return postLearnAction(action, payload).then(function (res) {
990
- if (res && res.snapshot) setSnapshot(res.snapshot)
1033
+ if (res && res.snapshot) setSnapshot(res.snapshot, res.workspaces)
991
1034
  return res
992
1035
  })
993
1036
  }
@@ -998,7 +1041,7 @@ function createClientLedgerBridge() {
998
1041
  }
999
1042
 
1000
1043
  return {
1001
- getState: function () { return { snapshot: snapshot, loading: loading, error: error } },
1044
+ getState: function () { return { snapshot: snapshot, workspaces: workspaces, loading: loading, error: error } },
1002
1045
  refresh: refresh,
1003
1046
  runAction: runAction,
1004
1047
  subscribe: subscribe,
@@ -1072,10 +1115,10 @@ function hashCardKey(parsed, fallbackSeed) {
1072
1115
  return 'card-' + Math.abs(hVal).toString(36)
1073
1116
  }
1074
1117
 
1075
- function openDeepLearnSession(ctx, item) {
1118
+ function openDeepLearnSession(ctx, item, preferredWorkspaceId) {
1076
1119
  var prompt = buildDeepLearnStarterPrompt(item)
1077
1120
  return postLearnAction('ensure_practice_workspace', {}).then(function (res) {
1078
- var wsId = res && res.workspace && res.workspace.workspaceId
1121
+ var wsId = preferredWorkspaceId || (res && res.workspace && res.workspace.workspaceId)
1079
1122
  var layout = getHostService(ctx, 'layout')
1080
1123
  var uiWorkspace = getHostService(ctx, 'uiWorkspace')
1081
1124
  var sessions = getHostService(ctx, 'sessions')
@@ -1242,7 +1285,7 @@ function openStarterChatSession(ctx) {
1242
1285
  }
1243
1286
  var uiWorkspace = getHostService(ctx, 'uiWorkspace')
1244
1287
  var sessions = getHostService(ctx, 'sessions')
1245
- var conv = getHostService(ctx, 'conversations')
1288
+ var conv = getHostService(ctx, 'conversation') || getHostService(ctx, 'conversations')
1246
1289
  var starterPrompt = '帮我检查一下当前项目的结构与改动方案,如果遇到值得留心的工程、架构或前端设计经验,干完顺手附一张顺带学习卡。'
1247
1290
  return postLearnAction('ensure_practice_workspace', {}).catch(function () { return null }).then(function (res) {
1248
1291
  var wsId = (res && res.workspace && res.workspace.workspaceId) || undefined
@@ -1287,16 +1330,16 @@ var SIM_OUTCOMES = {
1287
1330
  takeaway: '手头刚好有空时点一下,在右边花一两分钟直接把这条经验学明白。',
1288
1331
  },
1289
1332
  save: {
1290
- chatBadge: '已加入重点',
1333
+ chatBadge: '已存技能库',
1291
1334
  chatBadgeClass: 'ilp-tag run',
1292
1335
  collapsed: false,
1293
1336
  wbTitle: '顺带私教里',
1294
- wbBadge: '标为重点待学',
1337
+ wbBadge: '已存进技能库',
1295
1338
  wbBadgeClass: 'ilp-tag run',
1296
- wbHeading: '直接放进「重点学习清单」',
1297
- wbLine1: '觉得这条经验很实用,但眼下正忙,先标上重点',
1298
- wbLine2: '下次点进顺带私教时优先排在前面,方便集中去学',
1299
- takeaway: '适合眼下没空细看、但觉得这条经验很值钱,先标成重点留着集中学。',
1339
+ wbHeading: '直接放进「个人技能库」',
1340
+ wbLine1: '觉得这条经验很实用,先正式存进对应分类里',
1341
+ wbLine2: '下次点进顺带私教时优先排在前面,方便随时开练',
1342
+ takeaway: '适合眼下没空细看、但确定值得留下慢慢消化的实用经验。',
1300
1343
  },
1301
1344
  dismiss: {
1302
1345
  chatBadge: '已收起卡片',
@@ -1470,7 +1513,7 @@ function makeVisualGuideComponent(React) {
1470
1513
  ),
1471
1514
  h('div', { className: 'ilp-wf-btn-row' },
1472
1515
  h('span', { className: 'ilp-wf-mini-btn' }, '展开学习'),
1473
- h('span', { className: 'ilp-wf-mini-btn' }, '加入重点'),
1516
+ h('span', { className: 'ilp-wf-mini-btn' }, '存技能库'),
1474
1517
  h('span', { className: 'ilp-wf-mini-btn' }, '已掌握'),
1475
1518
  ),
1476
1519
  ),
@@ -1619,7 +1662,7 @@ function makeVisualGuideComponent(React) {
1619
1662
  },
1620
1663
  h('div', { className: 'ilp-sim-group', role: 'group', 'aria-label': '学习卡操作按钮' },
1621
1664
  makeSimToolbarButton('coach', '当场展开学', ''),
1622
- makeSimToolbarButton('save', '加入重点学', ''),
1665
+ makeSimToolbarButton('save', '存进技能库', ''),
1623
1666
  makeSimToolbarButton('dismiss', '已掌握,收起', ''),
1624
1667
  ),
1625
1668
  h('span', { role: 'separator', 'aria-orientation': 'vertical', className: 'ilp-sim-sep' }),
@@ -1648,7 +1691,7 @@ function makeVisualGuideComponent(React) {
1648
1691
  ),
1649
1692
  h('div', { className: 'ilp-mini-embed-pills' },
1650
1693
  h('span', { className: 'ilp-mini-pill' + (simMode === 'coach' ? ' is-hi' : '') }, '在右侧边聊边学'),
1651
- h('span', { className: 'ilp-mini-pill' + (simMode === 'save' ? ' is-hi' : '') }, '加入重点学'),
1694
+ h('span', { className: 'ilp-mini-pill' + (simMode === 'save' ? ' is-hi' : '') }, '存进技能库'),
1652
1695
  h('span', { className: 'ilp-mini-pill' + (simMode === 'dismiss' ? ' is-hi' : '') }, '已掌握,收起'),
1653
1696
  ),
1654
1697
  ),
@@ -1710,10 +1753,22 @@ function makeWorkbenchComponent(React, ctx, bridge) {
1710
1753
  var triageOpen = triageOpenTuple[0]
1711
1754
  var setTriageOpen = triageOpenTuple[1]
1712
1755
 
1713
- var expandedTrackTuple = React.useState({ 'track-frontend': true })
1756
+ var expandedTrackTuple = React.useState({})
1714
1757
  var expandedTracks = expandedTrackTuple[0]
1715
1758
  var setExpandedTracks = expandedTrackTuple[1]
1716
1759
 
1760
+ var directTopicTuple = React.useState('')
1761
+ var directTopic = directTopicTuple[0]
1762
+ var setDirectTopic = directTopicTuple[1]
1763
+
1764
+ var selectedWsTuple = React.useState('')
1765
+ var selectedWsId = selectedWsTuple[0]
1766
+ var setSelectedWsId = selectedWsTuple[1]
1767
+
1768
+ var startingDirectTuple = React.useState(false)
1769
+ var startingDirect = startingDirectTuple[0]
1770
+ var setStartingDirect = startingDirectTuple[1]
1771
+
1717
1772
  var courseOpenTuple = React.useState(false)
1718
1773
  var courseOpen = courseOpenTuple[0]
1719
1774
  var setCourseOpen = courseOpenTuple[1]
@@ -1769,25 +1824,74 @@ function makeWorkbenchComponent(React, ctx, bridge) {
1769
1824
  }
1770
1825
  } else {
1771
1826
  autoOpenedTriageRef.current = false
1827
+ if (currentTriageLen === 0 && triageOpen) {
1828
+ setTriageOpen(false)
1829
+ }
1772
1830
  }
1773
- }, [currentStats.totalItems, currentTriageLen])
1831
+ }, [currentStats.totalItems, currentTriageLen, triageOpen])
1774
1832
 
1775
1833
  function showToast(text, canUndo) {
1776
1834
  setToast({ text: text, canUndo: !!canUndo })
1777
1835
  }
1778
1836
 
1779
- function toggleTrack(id) {
1837
+ function toggleTrack(id, currentlyOpen) {
1780
1838
  setExpandedTracks(function (prev) {
1781
1839
  var next = Object.assign({}, prev)
1782
- next[id] = !prev[id]
1840
+ next[id] = !currentlyOpen
1783
1841
  return next
1784
1842
  })
1785
1843
  }
1786
1844
 
1845
+ var workspaces = Array.isArray(bridgeState.workspaces) ? bridgeState.workspaces : []
1846
+ var effectiveWsId = selectedWsId || (workspaces[0] && workspaces[0].id) || undefined
1847
+
1848
+ var DIRECT_TOPICS = [
1849
+ '复盘当前工作区刚改过的关键取舍',
1850
+ '前端自适应布局与原生组件避坑',
1851
+ '接口边界、并发写盘与架构取舍',
1852
+ 'Agent 提示词省流与工具设计',
1853
+ ]
1854
+
1855
+ function handleStartDirectStudy(e) {
1856
+ if (e && e.preventDefault) e.preventDefault()
1857
+ if (startingDirect) return
1858
+ var topicTitle = directTopic.trim() || '结合当前工作区最近一次关键改动,挑一个核心取舍带我专心闯关'
1859
+ setStartingDirect(true)
1860
+ bridge.runAction('save_explicit', {
1861
+ payload: {
1862
+ title: topicTitle,
1863
+ trackId: inferTrackIdFromTopic(topicTitle),
1864
+ source: 'manual',
1865
+ epistemic: 'explicit',
1866
+ why: '由顺带私教工作台主动发起专心学习,通过一问一答闯关沉淀证据。',
1867
+ },
1868
+ }).then(function (res) {
1869
+ var item = (res && res.item) || { title: topicTitle }
1870
+ setDirectTopic('')
1871
+ return openDeepLearnSession(ctx, item, effectiveWsId)
1872
+ }).then(function () {
1873
+ setStartingDirect(false)
1874
+ }).catch(function (err) {
1875
+ setStartingDirect(false)
1876
+ showToast('开启专心学习失败:' + err.message, false)
1877
+ })
1878
+ }
1879
+
1880
+ function handleDrillTriage(cand) {
1881
+ if (!cand) return
1882
+ bridge.runAction('triage_item', { id: cand.id, decision: 'accept' }).then(function (res) {
1883
+ var item = (res && res.item) || cand
1884
+ return openDeepLearnSession(ctx, item, effectiveWsId)
1885
+ }).catch(function (err) {
1886
+ showToast('开启专心学习失败:' + err.message, false)
1887
+ })
1888
+ }
1889
+
1787
1890
  function handleLoadSamples() {
1788
1891
  bridge.runAction('load_sample_pack', {}).then(function () {
1789
1892
  setIsPreviewSamples(true)
1790
1893
  setGuideOpen(false)
1894
+ setTriageOpen(false)
1791
1895
  showToast('已载入多 Agent 演示样本', true)
1792
1896
  }).catch(function (err) {
1793
1897
  showToast('加载失败:' + err.message, false)
@@ -1801,6 +1905,8 @@ function makeWorkbenchComponent(React, ctx, bridge) {
1801
1905
  setCourseOpen(false)
1802
1906
  setExportInfo(null)
1803
1907
  setTriageOpen(false)
1908
+ setDirectTopic('')
1909
+ setExpandedTracks({})
1804
1910
  autoOpenedTriageRef.current = false
1805
1911
  showToast('已清空恢复空台账', true)
1806
1912
  }).catch(function () {})
@@ -1808,14 +1914,14 @@ function makeWorkbenchComponent(React, ctx, bridge) {
1808
1914
 
1809
1915
  function handleStartDeepDrill(item) {
1810
1916
  if (!item) return
1811
- openDeepLearnSession(ctx, item).catch(function (err) {
1917
+ openDeepLearnSession(ctx, item, effectiveWsId).catch(function (err) {
1812
1918
  showToast('打开闯关会话失败:' + err.message, false)
1813
1919
  })
1814
1920
  }
1815
1921
 
1816
1922
  function handleTriageOne(id, decision) {
1817
1923
  bridge.runAction('triage_item', { id: id, decision: decision }).then(function (res) {
1818
- showToast(decision === 'accept' ? '已收入能力路线' : '已略过该候选', !!(res && res.snapshot && res.snapshot.canUndo))
1924
+ showToast(decision === 'accept' ? '已存进个人技能库' : '已删掉该存档', !!(res && res.snapshot && res.snapshot.canUndo))
1819
1925
  }).catch(function (err) {
1820
1926
  showToast('操作失败:' + err.message, false)
1821
1927
  })
@@ -1824,7 +1930,10 @@ function makeWorkbenchComponent(React, ctx, bridge) {
1824
1930
  function handleTriageBatch(mode) {
1825
1931
  bridge.runAction('triage_batch', { mode: mode }).then(function (res) {
1826
1932
  var count = (res && res.affected) || 0
1827
- showToast(mode === 'accept_all' ? ('已一键收入 ' + count + ' 条候选') : ('已清理 ' + count + ' 条低价值候选'), true)
1933
+ var msg = mode === 'clear_all'
1934
+ ? ('已清空 ' + count + ' 张自动存档')
1935
+ : (mode === 'accept_all' ? ('已一键存进 ' + count + ' 条技能') : ('已清理 ' + count + ' 条低价值存档'))
1936
+ showToast(msg, true)
1828
1937
  }).catch(function (err) {
1829
1938
  showToast('批量处理失败:' + err.message, false)
1830
1939
  })
@@ -1886,12 +1995,67 @@ function makeWorkbenchComponent(React, ctx, bridge) {
1886
1995
  )
1887
1996
  }
1888
1997
 
1889
- var stats = snap.stats || { masteredItems: 0, totalItems: 0, trackCount: 3, triageCount: 0 }
1998
+ var stats = snap.stats || { masteredItems: 0, totalItems: 0, trackCount: 4, triageCount: 0 }
1890
1999
  var tracks = snap.tracks || []
2000
+ var populatedTracks = tracks.filter(function (t) { return t.items && t.items.length > 0 })
2001
+ var emptyTrackNames = tracks.filter(function (t) { return !t.items || t.items.length === 0 }).map(function (t) { return t.title })
2002
+ var firstPopTrackId = populatedTracks[0] ? populatedTracks[0].id : ''
1891
2003
  var triage = snap.triage || []
1892
2004
  var spotlight = snap.spotlight
1893
2005
  var isCompletelyEmpty = stats.totalItems === 0 && triage.length === 0
1894
2006
 
2007
+ function renderDirectStudyBox(isHero) {
2008
+ return h('form', {
2009
+ className: 'ilp-direct-box' + (isHero ? ' is-hero' : ''),
2010
+ 'data-testid': 'ilp-direct-study',
2011
+ onSubmit: handleStartDirectStudy,
2012
+ },
2013
+ h('div', { className: 'ilp-direct-head' },
2014
+ h('span', { className: 'ilp-direct-title' }, '直接开启专心学习(1 对 1 闯关对话)'),
2015
+ h('span', { className: 'ilp-direct-sub' }, '不必先挑旧存档;填一个现在想弄懂的问题或直接点选下方主题,一键跳进专心学习对话。'),
2016
+ ),
2017
+ h('div', { className: 'ilp-direct-row' },
2018
+ h('input', {
2019
+ type: 'text',
2020
+ className: 'ilp-direct-input',
2021
+ 'data-testid': 'ilp-direct-topic-input',
2022
+ 'aria-label': '输入想专心学习的主题',
2023
+ placeholder: '例如:复盘当前项目刚改的权限边界 / CSS 容器查询先后顺序(留空也可直接开练)',
2024
+ value: directTopic,
2025
+ onChange: function (e) { setDirectTopic(e.target.value) },
2026
+ }),
2027
+ workspaces.length > 0 ? h('select', {
2028
+ className: 'ilp-direct-ws',
2029
+ 'data-testid': 'ilp-direct-ws-select',
2030
+ 'aria-label': '选择学习关联的工作区',
2031
+ value: effectiveWsId || '',
2032
+ onChange: function (e) { setSelectedWsId(e.target.value) },
2033
+ },
2034
+ workspaces.map(function (ws) {
2035
+ return h('option', { key: ws.id, value: ws.id }, ws.name || ws.id)
2036
+ }),
2037
+ ) : null,
2038
+ h('button', {
2039
+ type: 'submit',
2040
+ className: 'ilp-btn ' + (isHero ? 'solid' : 'line'),
2041
+ 'data-testid': 'ilp-direct-start-btn',
2042
+ disabled: startingDirect,
2043
+ }, startingDirect ? '正在开启…' : '开始专心学'),
2044
+ ),
2045
+ h('div', { className: 'ilp-direct-chips' },
2046
+ DIRECT_TOPICS.map(function (chip, idx) {
2047
+ return h('button', {
2048
+ key: String(idx),
2049
+ type: 'button',
2050
+ className: 'ilp-chip-btn',
2051
+ 'data-testid': 'ilp-direct-chip-' + idx,
2052
+ onClick: function () { setDirectTopic(chip) },
2053
+ }, chip)
2054
+ }),
2055
+ ),
2056
+ )
2057
+ }
2058
+
1895
2059
  return h('div', { className: 'ilp-wb', 'data-testid': 'ilp-workbench' },
1896
2060
  h('div', { className: 'ilp-wb-inner' },
1897
2061
  // Calm Header
@@ -1967,11 +2131,7 @@ function makeWorkbenchComponent(React, ctx, bridge) {
1967
2131
  }))
1968
2132
  : null,
1969
2133
 
1970
- stats.totalItems === 0 && triage.length > 0 ? h('div', { className: 'ilp-onb-triage-tip', 'data-testid': 'ilp-empty-triage-tip' },
1971
- '个人技能库目前 0 项,但下方已自动帮你接住平时对话里出现的顺带学习卡:点「加入重点学」就开始跟踪练习,点「跳过」则直接清掉。',
1972
- ) : null,
1973
-
1974
- // Single Spotlight Hero Card
2134
+ // Single Spotlight Hero Card (when accumulated items > 0) vs Direct Study Hero (when 0 items)
1975
2135
  spotlight ? h('section', { className: 'ilp-spot-card', 'data-testid': 'ilp-spotlight' },
1976
2136
  h('div', { className: 'ilp-spot-main' },
1977
2137
  h('div', { className: 'ilp-spot-eyebrow' },
@@ -2003,6 +2163,8 @@ function makeWorkbenchComponent(React, ctx, bridge) {
2003
2163
  ),
2004
2164
  ) : null,
2005
2165
 
2166
+ renderDirectStudyBox(!isCompletelyEmpty && !spotlight),
2167
+
2006
2168
  // 1-Line Default-Collapsed Background Auto-Archive
2007
2169
  triage.length > 0 ? h('section', { className: 'ilp-triage-box', 'data-testid': 'ilp-triage-box' },
2008
2170
  h('button', {
@@ -2014,28 +2176,44 @@ function makeWorkbenchComponent(React, ctx, bridge) {
2014
2176
  },
2015
2177
  h('span', { className: 'ilp-triage-head-left' },
2016
2178
  h('span', { className: 'ilp-tag ' + (snap.triageOverCap ? 'wait' : 'outline') }, '后台自动存档 · ' + triage.length + ' 张'),
2017
- h('span', { className: 'ilp-summary' }, snap.triageOverCap ? '待看卡片超过 5 张,建议批量清理或全部加入' : '平时对话里先放着没点的学习卡,都自动帮你存在这里'),
2179
+ h('span', { className: 'ilp-summary' }, snap.triageOverCap ? '待看卡片超过 5 张,可批量清理、全部存进技能库或一键清空' : '平时对话先放着没点的卡片;想练直接点「拿这张去练」,不要的可点「删掉」'),
2018
2180
  ),
2019
2181
  h('span', { className: 'ilp-btn ghost xs' }, triageOpen ? '收起' : '展开查看'),
2020
2182
  ),
2021
2183
  triageOpen ? h('div', { className: 'ilp-triage-body' },
2022
- triage.length > 5 ? h('div', { className: 'ilp-triage-batch', 'data-testid': 'ilp-triage-batch' },
2023
- h('span', { style: { fontSize: '12px', fontWeight: 600 } }, '整理提醒:后台共自动存了 ' + triage.length + ' 张待看卡片'),
2024
- h('div', { style: { display: 'flex', gap: '6px', flexWrap: 'wrap' } },
2025
- h('button', {
2026
- type: 'button',
2027
- className: 'ilp-btn line xs',
2028
- 'data-testid': 'ilp-batch-sweep-low',
2029
- onClick: function () { handleTriageBatch('sweep_low_value') },
2030
- }, '清理细碎卡片'),
2031
- h('button', {
2032
- type: 'button',
2033
- className: 'ilp-btn solid xs',
2034
- 'data-testid': 'ilp-batch-accept-all',
2035
- onClick: function () { handleTriageBatch('accept_all') },
2036
- }, '全部加入重点学'),
2037
- ),
2038
- ) : null,
2184
+ triage.length > 5
2185
+ ? h('div', { className: 'ilp-triage-batch', 'data-testid': 'ilp-triage-batch' },
2186
+ h('span', { style: { fontSize: '12px', fontWeight: 600 } }, '整理提醒:后台共自动存了 ' + triage.length + ' 张待看卡片'),
2187
+ h('div', { style: { display: 'flex', gap: '6px', flexWrap: 'wrap' } },
2188
+ h('button', {
2189
+ type: 'button',
2190
+ className: 'ilp-btn line xs',
2191
+ 'data-testid': 'ilp-batch-sweep-low',
2192
+ onClick: function () { handleTriageBatch('sweep_low_value') },
2193
+ }, '清理细碎卡片'),
2194
+ h('button', {
2195
+ type: 'button',
2196
+ className: 'ilp-btn solid xs',
2197
+ 'data-testid': 'ilp-batch-accept-all',
2198
+ onClick: function () { handleTriageBatch('accept_all') },
2199
+ }, '全部存进技能库'),
2200
+ h('button', {
2201
+ type: 'button',
2202
+ className: 'ilp-btn ghost xs',
2203
+ 'data-testid': 'ilp-triage-clear-all',
2204
+ onClick: function () { handleTriageBatch('clear_all') },
2205
+ }, '一键清空存档'),
2206
+ ),
2207
+ )
2208
+ : h('div', { className: 'ilp-triage-subbar' },
2209
+ h('span', null, '点「拿这张去练」直接新开一对一闯关对话;不想留的存档可直接删掉或一键清空。'),
2210
+ h('button', {
2211
+ type: 'button',
2212
+ className: 'ilp-btn ghost xs',
2213
+ 'data-testid': 'ilp-triage-clear-all',
2214
+ onClick: function () { handleTriageBatch('clear_all') },
2215
+ }, '一键清空存档'),
2216
+ ),
2039
2217
  triage.map(function (cand) {
2040
2218
  return h('div', { key: cand.id, className: 'ilp-triage-row', 'data-testid': 'ilp-triage-row-' + cand.id },
2041
2219
  h('div', { className: 'ilp-triage-info' },
@@ -2048,18 +2226,24 @@ function makeWorkbenchComponent(React, ctx, bridge) {
2048
2226
  cand.why ? h('div', { className: 'ilp-triage-why' }, cand.why) : null,
2049
2227
  ),
2050
2228
  h('div', { className: 'ilp-triage-acts' },
2229
+ h('button', {
2230
+ type: 'button',
2231
+ className: 'ilp-btn soft xs',
2232
+ 'data-testid': 'ilp-triage-drill-' + cand.id,
2233
+ onClick: function () { handleDrillTriage(cand) },
2234
+ }, '拿这张去练'),
2051
2235
  h('button', {
2052
2236
  type: 'button',
2053
2237
  className: 'ilp-btn line xs',
2054
2238
  'data-testid': 'ilp-triage-accept-' + cand.id,
2055
2239
  onClick: function () { handleTriageOne(cand.id, 'accept') },
2056
- }, '加入重点学'),
2240
+ }, '先存着'),
2057
2241
  h('button', {
2058
2242
  type: 'button',
2059
2243
  className: 'ilp-btn ghost xs',
2060
2244
  'data-testid': 'ilp-triage-skip-' + cand.id,
2061
2245
  onClick: function () { handleTriageOne(cand.id, 'skip') },
2062
- }, '跳过'),
2246
+ }, '删掉'),
2063
2247
  ),
2064
2248
  )
2065
2249
  }),
@@ -2107,17 +2291,19 @@ function makeWorkbenchComponent(React, ctx, bridge) {
2107
2291
  h('pre', { className: 'ilp-code-pre', style: { maxHeight: '160px', overflowY: 'auto' } }, exportInfo.markdown),
2108
2292
  ) : null,
2109
2293
 
2110
- // Accordion Skill Categories (Category 1 open by default; 2 & 3 collapsed)
2111
- tracks.length > 0 && !isCompletelyEmpty ? h('section', { className: 'ilp-tracks', 'data-testid': 'ilp-tracks' },
2294
+ // Populated Skill Categories ONLY (never render empty 0/0 clickable shells!)
2295
+ populatedTracks.length > 0 ? h('section', { className: 'ilp-tracks', 'data-testid': 'ilp-tracks' },
2112
2296
  h('div', { className: 'ilp-section-label' }, '沉淀下来的技能分类(可随时查看学习记录)'),
2113
- tracks.map(function (track) {
2114
- var isOpen = !!expandedTracks[track.id]
2297
+ populatedTracks.map(function (track) {
2298
+ var isOpen = Object.prototype.hasOwnProperty.call(expandedTracks, track.id)
2299
+ ? !!expandedTracks[track.id]
2300
+ : (track.id === firstPopTrackId)
2115
2301
  return h('div', { key: track.id, className: 'ilp-track', 'data-testid': 'ilp-track-' + track.id },
2116
2302
  h('button', {
2117
2303
  type: 'button',
2118
2304
  className: 'ilp-track-head',
2119
2305
  'aria-expanded': isOpen ? 'true' : 'false',
2120
- onClick: function () { toggleTrack(track.id) },
2306
+ onClick: function () { toggleTrack(track.id, isOpen) },
2121
2307
  },
2122
2308
  h('div', { className: 'ilp-track-meta' },
2123
2309
  h('span', { className: 'ilp-track-title' }, track.title),
@@ -2131,43 +2317,44 @@ function makeWorkbenchComponent(React, ctx, bridge) {
2131
2317
  ),
2132
2318
  ),
2133
2319
  isOpen ? h('div', { className: 'ilp-track-list' },
2134
- track.items.length === 0
2135
- ? h('div', { className: 'ilp-item-row' },
2136
- h('span', { className: 'ilp-summary' }, '该分类暂无条目,可在对话学习卡点「加入重点学」或从后台自动存档加入。'),
2137
- )
2138
- : track.items.map(function (item) {
2139
- return h('div', { key: item.id, className: 'ilp-item-row', 'data-testid': 'ilp-item-' + item.id },
2140
- h('div', { className: 'ilp-item-main' },
2141
- h('div', { className: 'ilp-item-badges' },
2142
- sourceTag(h, item.source),
2143
- epistemicTag(h, item.epistemic),
2144
- makeMasteryMeter(h, item.masteryTier),
2145
- ),
2146
- h('button', {
2147
- type: 'button',
2148
- className: 'ilp-item-title',
2149
- onClick: function () { setModalItem(item) },
2150
- }, item.title),
2151
- item.evidenceSummary ? h('p', { className: 'ilp-item-evidence' }, item.evidenceSummary) : null,
2152
- ),
2153
- h('div', { className: 'ilp-item-acts' },
2154
- h('button', {
2155
- type: 'button',
2156
- className: 'ilp-btn line xs',
2157
- onClick: function () { setModalItem(item) },
2158
- }, '学习记录'),
2159
- h('button', {
2160
- type: 'button',
2161
- className: 'ilp-btn soft xs',
2162
- onClick: function () { handleStartDeepDrill(item) },
2163
- }, '展开学'),
2164
- ),
2165
- )
2166
- }),
2320
+ track.items.map(function (item) {
2321
+ return h('div', { key: item.id, className: 'ilp-item-row', 'data-testid': 'ilp-item-' + item.id },
2322
+ h('div', { className: 'ilp-item-main' },
2323
+ h('div', { className: 'ilp-item-badges' },
2324
+ sourceTag(h, item.source),
2325
+ epistemicTag(h, item.epistemic),
2326
+ makeMasteryMeter(h, item.masteryTier),
2327
+ ),
2328
+ h('button', {
2329
+ type: 'button',
2330
+ className: 'ilp-item-title',
2331
+ onClick: function () { setModalItem(item) },
2332
+ }, item.title),
2333
+ item.evidenceSummary ? h('p', { className: 'ilp-item-evidence' }, item.evidenceSummary) : null,
2334
+ ),
2335
+ h('div', { className: 'ilp-item-acts' },
2336
+ h('button', {
2337
+ type: 'button',
2338
+ className: 'ilp-btn line xs',
2339
+ onClick: function () { setModalItem(item) },
2340
+ }, '学习记录'),
2341
+ h('button', {
2342
+ type: 'button',
2343
+ className: 'ilp-btn soft xs',
2344
+ onClick: function () { handleStartDeepDrill(item) },
2345
+ }, '展开学'),
2346
+ ),
2347
+ )
2348
+ }),
2167
2349
  ) : null,
2168
2350
  )
2169
2351
  }),
2170
- ) : null,
2352
+ emptyTrackNames.length > 0 ? h('p', { className: 'ilp-empty-tracks-note', 'data-testid': 'ilp-empty-tracks-note' },
2353
+ '其余待积累分类:' + emptyTrackNames.join(' · '),
2354
+ ) : null,
2355
+ ) : (!isCompletelyEmpty ? h('p', { className: 'ilp-empty-tracks-note', 'data-testid': 'ilp-empty-tracks-note' },
2356
+ '练过或存下的内容会自动按分类归档到这里;目前还没有已存记录。',
2357
+ ) : null),
2171
2358
 
2172
2359
  // Undo Toast (calm panel surface + green dot)
2173
2360
  toast ? h('div', { className: 'ilp-toast', role: 'status', 'data-testid': 'ilp-toast' },
@@ -2362,9 +2549,9 @@ function makeShieldFenceComponent(React, ctx, bridge, coachStore) {
2362
2549
  }).then(function (res) {
2363
2550
  setSavedLocal(true)
2364
2551
  if (res && res.created === false) {
2365
- setFeedback('已在重点清单中')
2552
+ setFeedback('已在技能库中')
2366
2553
  } else {
2367
- setFeedback('已标为重点待学,去顺带私教可复习')
2554
+ setFeedback('已存进个人技能库,去顺带私教可随时开练')
2368
2555
  }
2369
2556
  }).catch(function (err) {
2370
2557
  setFeedback('保存失败:' + err.message)
@@ -2425,7 +2612,7 @@ function makeShieldFenceComponent(React, ctx, bridge, coachStore) {
2425
2612
  'data-testid': 'ilp-shield-capture-btn',
2426
2613
  'aria-pressed': isCaptured ? 'true' : 'false',
2427
2614
  onClick: handleSaveDirect,
2428
- }, isCaptured ? '已在重点清单' : '加入重点学'),
2615
+ }, isCaptured ? '已存进技能库' : '存进技能库'),
2429
2616
  h('button', {
2430
2617
  type: 'button',
2431
2618
  className: 'ilp-quiet-btn is-ghost',
package/lib/ledger.js CHANGED
@@ -496,9 +496,12 @@ export function createLedgerStore(options = {}) {
496
496
  const idx = draft.triage.findIndex(c => c.id === id)
497
497
  if (idx < 0) return { found: false }
498
498
  const cand = draft.triage[idx]
499
- pushUndo(draft, decision === 'accept' ? `收入「${cand.title.slice(0, 12)}」` : `略过「${cand.title.slice(0, 12)}」`)
499
+ pushUndo(draft, decision === 'accept' ? `收入「${cand.title.slice(0, 12)}」` : `删掉「${cand.title.slice(0, 12)}」`)
500
500
  draft.triage.splice(idx, 1)
501
501
  let created = null
502
+ if (decision === 'skip' && cand.cardKey && !draft.dismissedCardKeys.includes(cand.cardKey)) {
503
+ draft.dismissedCardKeys = [...draft.dismissedCardKeys, cand.cardKey].slice(-400)
504
+ }
502
505
  if (decision === 'accept') {
503
506
  const targetTrack = normalizeTrackId(trackId || cand.trackId, draft.tracks)
504
507
  const existing = findItemByTitleOrId(draft, { title: cand.title })
@@ -533,11 +536,21 @@ export function createLedgerStore(options = {}) {
533
536
  },
534
537
 
535
538
  async triageBatch({ mode } = {}) {
536
- if (mode !== 'accept_all' && mode !== 'sweep_low_value') {
537
- throw new Error('triageBatch requires mode accept_all|sweep_low_value')
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')
538
541
  }
539
542
  const { state, extra } = await mutate(draft => {
540
- if (draft.triage.length === 0) return { affected: 0 }
543
+ if (draft.triage.length === 0) return { affected: 0, mode }
544
+ if (mode === 'clear_all') {
545
+ const clearedCount = draft.triage.length
546
+ pushUndo(draft, `清空 ${clearedCount} 张自动存档`)
547
+ const extraKeys = draft.triage.map(c => c.cardKey).filter(Boolean)
548
+ if (extraKeys.length > 0) {
549
+ draft.dismissedCardKeys = [...new Set([...draft.dismissedCardKeys, ...extraKeys])].slice(-400)
550
+ }
551
+ draft.triage = []
552
+ return { affected: clearedCount, mode }
553
+ }
541
554
  if (mode === 'sweep_low_value') {
542
555
  const lowCount = draft.triage.filter(c => c.lowValue).length
543
556
  const targets = lowCount > 0 ? draft.triage.filter(c => c.lowValue) : draft.triage.filter(c => c.epistemic === 'inferred').slice(2)
package/locale/zh.json CHANGED
@@ -8,9 +8,9 @@
8
8
  "spotlightPrimary": "开始 3 分钟展开学",
9
9
  "spotlightSecondary": "看卡片解析",
10
10
  "triageHeading": "后台自动存档",
11
- "triageAccept": "加入重点学",
11
+ "triageAccept": "存进技能库",
12
12
  "triageSkip": "跳过",
13
- "triageAcceptAll": "全部加入重点学",
13
+ "triageAcceptAll": "全部存进技能库",
14
14
  "triageSweepLow": "清理细碎卡片",
15
15
  "tracksHeading": "沉淀下来的技能分类",
16
16
  "course15mBtn": "15 分钟集中学",
@@ -50,7 +50,7 @@
50
50
  "shieldRejected": "避开的坑",
51
51
  "shieldProbe": "顺手想一下",
52
52
  "shieldBtnCoach": "在右侧边聊边学",
53
- "shieldBtnCapture": "加入重点学",
53
+ "shieldBtnCapture": "存进技能库",
54
54
  "shieldBtnDismiss": "已掌握,收起",
55
55
  "shieldCollapsed": "已掌握并收起 · 重新展开",
56
56
  "quizTag": "先探后讲",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxmumu3/dsh-incidental-learn",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -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
@@ -440,15 +440,32 @@ export function parseLearnPassFence(code) {
440
440
  }
441
441
  }
442
442
 
443
+ export function inferTrackIdFromTopic(text) {
444
+ const s = String(text || '')
445
+ if (/css|flex|grid|container|dialog|布局|样式|动画|前端|界面|颜色|主题|弹窗|悬浮|分屏|按钮|组件/i.test(s)) {
446
+ return 'track-frontend'
447
+ }
448
+ if (/prompt|agent|token|mcp|tool|llm|模型|提示词|上下文|多智能体|围栏/i.test(s)) {
449
+ return 'track-ai'
450
+ }
451
+ if (/增长|转化|标题|留存|分发|引导|文案|小红书|公众号|首屏|定位|用户|产品/i.test(s)) {
452
+ return 'track-product'
453
+ }
454
+ return 'track-engineering'
455
+ }
456
+
443
457
  export function buildDeepLearnStarterPrompt(item) {
444
458
  const safe = item && typeof item === 'object' ? item : {}
445
459
  const tierLabel = MASTERY_LABELS[clampTier(safe.masteryTier || 1)]
460
+ const isAdHoc = !safe.rejected && !safe.probe
446
461
  return [
447
462
  '[顺带私教·专心闯关]',
448
463
  `知识点:${cleanText(safe.title, 140) || '当前盲区'}(itemId: ${cleanText(safe.id, 80) || 'ad-hoc'},当前掌握度:${tierLabel})`,
449
464
  safe.why ? `背景取舍:${cleanText(safe.why, 220)}` : '',
450
465
  safe.rejected ? `曾经对比过的坑:${cleanText(safe.rejected, 180)}` : '',
451
466
  safe.probe ? `摸底种子:${cleanText(safe.probe, 180)}` : '',
452
- '请严格按「先探后讲 + 换景追问」节奏带我过关:第 1 轮直接输出一个 ```learn-quiz JSON 代码块让我先盲选判断并停下等我回复,暂不要剧透完整解释。',
467
+ isAdHoc
468
+ ? '这是我主动发起的专心学习主题(若涉及当前工作区代码,可先快速只读扫一眼关键实现)。请严格按「先探后讲 + 换景追问」节奏带我一对一闯关:第 1 轮直接输出一个 ```learn-quiz JSON 代码块让我先盲选判断并停下等我回复,暂不要剧透完整解释。'
469
+ : '请严格按「先探后讲 + 换景追问」节奏带我过关:第 1 轮直接输出一个 ```learn-quiz JSON 代码块让我先盲选判断并停下等我回复,暂不要剧透完整解释。',
453
470
  ].filter(Boolean).join('\n')
454
471
  }