mcp-docs.ts
typescript
sha256:73f24973678ceefd56628ee17c6d0535d86e33533828af6c63348f50941515ad
Merge branch 'fix/smoke-test-tag-label' into dev
Human
15 days ago
| 1 | /** |
| 2 | * mcp-docs.ts — interactive behaviour for the MCP reference page. |
| 3 | * |
| 4 | * - Real-time tool filter (search by name or description) |
| 5 | * - Copy-to-clipboard buttons |
| 6 | * - Sidebar active-link highlight on scroll |
| 7 | */ |
| 8 | |
| 9 | export function initMcpDocs(): void { |
| 10 | setupToolFilter(); |
| 11 | setupCopyButtons(); |
| 12 | setupSidebarHighlight(); |
| 13 | } |
| 14 | |
| 15 | // ── Tool filter ─────────────────────────────────────────────────────────────── |
| 16 | |
| 17 | function setupToolFilter(): void { |
| 18 | const input = document.getElementById('tool-filter') as HTMLInputElement | null; |
| 19 | const countEl = document.getElementById('tool-count'); |
| 20 | if (!input) return; |
| 21 | |
| 22 | const cards = Array.from(document.querySelectorAll<HTMLElement>('.tool-card')); |
| 23 | |
| 24 | input.addEventListener('input', () => { |
| 25 | const q = input.value.trim().toLowerCase(); |
| 26 | let visible = 0; |
| 27 | |
| 28 | cards.forEach((card) => { |
| 29 | const name = (card.dataset.toolName || '').toLowerCase(); |
| 30 | const desc = (card.dataset.toolDesc || '').toLowerCase(); |
| 31 | const match = !q || name.includes(q) || desc.includes(q); |
| 32 | card.hidden = !match; |
| 33 | if (match) visible++; |
| 34 | }); |
| 35 | |
| 36 | if (countEl) { |
| 37 | countEl.textContent = q |
| 38 | ? `${visible} / ${cards.length} tools` |
| 39 | : `${cards.length} tools`; |
| 40 | } |
| 41 | |
| 42 | // Show/hide section headings when all their tools are hidden |
| 43 | document.querySelectorAll<HTMLElement>('.docs-section').forEach((section) => { |
| 44 | const toolList = section.querySelector('.tool-list'); |
| 45 | if (!toolList) return; |
| 46 | const visibleInSection = Array.from(toolList.querySelectorAll<HTMLElement>('.tool-card')) |
| 47 | .some((c) => !c.hidden); |
| 48 | section.style.display = (q && !visibleInSection) ? 'none' : ''; |
| 49 | }); |
| 50 | }); |
| 51 | } |
| 52 | |
| 53 | // ── Copy buttons ────────────────────────────────────────────────────────────── |
| 54 | |
| 55 | function setupCopyButtons(): void { |
| 56 | document.querySelectorAll<HTMLButtonElement>('.copy-btn').forEach((btn) => { |
| 57 | btn.addEventListener('click', () => { |
| 58 | const text = btn.dataset.copy || ''; |
| 59 | navigator.clipboard.writeText(text).then(() => { |
| 60 | const orig = btn.innerHTML; |
| 61 | btn.innerHTML = `<svg width="11" height="11" style="color:#3fb950" aria-hidden="true"><use href="#icon-check"></use></svg>`; |
| 62 | setTimeout(() => { btn.innerHTML = orig; }, 1500); |
| 63 | }); |
| 64 | }); |
| 65 | }); |
| 66 | } |
| 67 | |
| 68 | // ── Sidebar active link on scroll ───────────────────────────────────────────── |
| 69 | |
| 70 | function setupSidebarHighlight(): void { |
| 71 | const links = Array.from(document.querySelectorAll<HTMLAnchorElement>('.docs-sidebar-link[href^="#"]')); |
| 72 | if (!links.length) return; |
| 73 | |
| 74 | const sections = links |
| 75 | .map((link) => { |
| 76 | const id = link.getAttribute('href')!.slice(1); |
| 77 | return { link, el: document.getElementById(id) }; |
| 78 | }) |
| 79 | .filter((s): s is { link: HTMLAnchorElement; el: HTMLElement } => !!s.el); |
| 80 | |
| 81 | const headerHeight = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--header-height') || '42', 10); |
| 82 | |
| 83 | const observer = new IntersectionObserver( |
| 84 | (entries) => { |
| 85 | entries.forEach((entry) => { |
| 86 | const match = sections.find((s) => s.el === entry.target); |
| 87 | if (match) { |
| 88 | if (entry.isIntersecting) { |
| 89 | links.forEach((l) => l.style.removeProperty('color')); |
| 90 | match.link.style.color = 'var(--text-primary)'; |
| 91 | } |
| 92 | } |
| 93 | }); |
| 94 | }, |
| 95 | { rootMargin: `-${headerHeight + 48}px 0px -60% 0px`, threshold: 0 }, |
| 96 | ); |
| 97 | |
| 98 | sections.forEach(({ el }) => observer.observe(el)); |
| 99 | } |
File History
12 commits
sha256:cfefc25a166c3c3eed8ea3529aee19ea350bc05f2954d007420e924133b7d8ce
chore: pivot to nightly channel — bump version to 0.2.0.dev…
Sonnet 5
patch
13 days ago
sha256:d035733f21ccff27735fddebfbbe0ed24565a32a22db8de5885402262671ecd2
chore: bump version to 0.2.0rc15 for musehub#113 fix release
Sonnet 4.6
patch
15 days ago
sha256:0032d6cfa33bc3c8367436ad768e7dd0e339b4332153160247da8266cb5fa352
Merge branch 'task/version-tags-phase3-server' into dev
Human
18 days ago
sha256:4669620efda9ff41c55bdefd1f7bfe1c239d468428744c84ead9957e5a003a53
merge: rescue snapshot-recovery hardening (c00aa21d) into d…
Opus 4.8
minor
⚠
30 days ago
sha256:a59da49c4611b970fc4b6ae48678ce4943261c213a07ddbd73ce9201df869b4a
fix: remove false-positive proposal_comments index drop fro…
Sonnet 4.6
patch
34 days ago
sha256:0a240d6dbff234f07d98a28a4a9a68db702f3f9ff9260196f24219bdb1c0b6f3
feat: render markdown mists as HTML with heading anchor links
Sonnet 4.6
patch
35 days ago
sha256:24a7d47486ebc4ebd1832830580e177ec6f877b48dced8c000e198cdec4ce9d6
Merge 'task/bump-version-rc12' into 'dev' — proposal: Bump …
Human
36 days ago
sha256:b9ff931d147e0114a1f17060f415b89ed551c170a91ff226c70437aa5c85f9ee
Merge 'task/bump-version-rc12' into 'dev' — proposal: Bump …
Human
36 days ago
sha256:d1122d21e73471879b460037b22c0b50fded7c423444a176f248428f75dac39c
Merge 'task/fix-issue-pagination-cursor' into 'dev' — propo…
Human
36 days ago
sha256:01e18975e73d2b3cd5b6db7929c895bef9aa6e0d4391dc5b2adfc548b41318dd
Merge 'feat/adding-debug-logs-to-staging' into 'dev' — prop…
Human
36 days ago
sha256:6b1949fc2797ca4c1936a637a4cbfec828ef56cf52398a2e74ca3c4f494e728f
fix: use wire_bytes not mpack_bytes_raw in compute_object_b…
Sonnet 4.6
patch
49 days ago
sha256:b99f2455dc346966d040133f5203297e6e3ef5803a93728a2c30568d0a0f7583
rename: delta_add → delta_upsert across wire format, models…
Sonnet 4.6
patch
51 days ago