@peaske7/readit 0.3.0-rc.0 → 0.3.0-rc.1
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/dist/.vite/manifest.json +1111 -0
- package/dist/assets/_basePickBy-BMMA4Tou.js +1 -0
- package/dist/assets/_baseUniq-D40qku1I.js +1 -0
- package/dist/assets/arc-Ckg65iy8.js +1 -0
- package/dist/assets/architecture-YZFGNWBL-Dv3EY0zV.js +1 -0
- package/dist/assets/architectureDiagram-Q4EWVU46-ClRss4cm.js +36 -0
- package/dist/assets/array-Bjz-wYpJ.js +1 -0
- package/dist/assets/blockDiagram-DXYQGD6D-CBcFvoK1.js +132 -0
- package/dist/assets/c4Diagram-AHTNJAMY-D4d3ZLam.js +10 -0
- package/dist/assets/channel-D9EJxDy_.js +1 -0
- package/dist/assets/chunk-2KRD3SAO-DaFfaCGO.js +1 -0
- package/dist/assets/chunk-336JU56O-yLEQoF0v.js +2 -0
- package/dist/assets/chunk-426QAEUC-Uyzd4wAA.js +1 -0
- package/dist/assets/chunk-4BX2VUAB-DRuTD7x5.js +1 -0
- package/dist/assets/chunk-4TB4RGXK-3xbpIi_o.js +206 -0
- package/dist/assets/chunk-55IACEB6-BExiaAoD.js +1 -0
- package/dist/assets/chunk-5FUZZQ4R-DatVvHnF.js +62 -0
- package/dist/assets/chunk-5PVQY5BW-BKgvrGh8.js +2 -0
- package/dist/assets/chunk-67CJDMHE-DMt8LNEX.js +1 -0
- package/dist/assets/chunk-7N4EOEYR-CzLGefVf.js +1 -0
- package/dist/assets/chunk-AA7GKIK3-B6GFAk4U.js +1 -0
- package/dist/assets/chunk-BSJP7CBP-BK29yehL.js +1 -0
- package/dist/assets/chunk-CIAEETIT-D7hBXImP.js +1 -0
- package/dist/assets/chunk-Dlc7tRH4.js +1 -0
- package/dist/assets/chunk-EDXVE4YY-PYJdlmyH.js +1 -0
- package/dist/assets/chunk-ENJZ2VHE-DUHKBv6x.js +10 -0
- package/dist/assets/chunk-FMBD7UC4-2FWyCCAV.js +15 -0
- package/dist/assets/chunk-FOC6F5B3-DKFHrt4K.js +1 -0
- package/dist/assets/chunk-ICPOFSXX-Bh__D0ec.js +122 -0
- package/dist/assets/chunk-K5T4RW27-D51O7IkG.js +94 -0
- package/dist/assets/chunk-KGLVRYIC-DMHSCH4T.js +1 -0
- package/dist/assets/chunk-LIHQZDEY-C2aANxt9.js +1 -0
- package/dist/assets/chunk-ORNJ4GCN-Db_37NRX.js +1 -0
- package/dist/assets/chunk-OYMX7WX6-BltXOJLJ.js +231 -0
- package/dist/assets/chunk-QZHKN3VN-8Lcg9gti.js +1 -0
- package/dist/assets/chunk-U2HBQHQK-ByS6tilY.js +70 -0
- package/dist/assets/chunk-X2U36JSP-Bm-4Gqg_.js +1 -0
- package/dist/assets/chunk-XPW4576I-Bqbompq4.js +32 -0
- package/dist/assets/chunk-YZCP3GAM-CsC0imPb.js +1 -0
- package/dist/assets/chunk-ZZ45TVLE-CG-CqfPC.js +1 -0
- package/dist/assets/classDiagram-6PBFFD2Q-Jy1uFUk4.js +1 -0
- package/dist/assets/classDiagram-v2-HSJHXN6E-ChiLl3rR.js +1 -0
- package/dist/assets/clone-BBjvuERA.js +1 -0
- package/dist/assets/cose-bilkent-S5V4N54A-q90QeGKv.js +1 -0
- package/dist/assets/cytoscape.esm-BfXff3fb.js +321 -0
- package/dist/assets/dagre-KV5264BT-BQWiLFJB.js +4 -0
- package/dist/assets/dagre-nn_aIZ2E.js +1 -0
- package/dist/assets/defaultLocale-BwmRmqJp.js +1 -0
- package/dist/assets/diagram-5BDNPKRD-CJa7Y97H.js +10 -0
- package/dist/assets/diagram-G4DWMVQ6-tVQGBWfY.js +24 -0
- package/dist/assets/diagram-MMDJMWI5-CpimFldm.js +43 -0
- package/dist/assets/diagram-TYMM5635-D11WQVgy.js +24 -0
- package/dist/assets/dist-BNz65Ibc.js +1 -0
- package/dist/assets/erDiagram-SMLLAGMA-C2bLd0jS.js +85 -0
- package/dist/assets/flowDiagram-DWJPFMVM-Kw3fOOLT.js +162 -0
- package/dist/assets/ganttDiagram-T4ZO3ILL-fyMhyE2X.js +292 -0
- package/dist/assets/gitGraph-7Q5UKJZL-BGFRt2qs.js +1 -0
- package/dist/assets/gitGraphDiagram-UUTBAWPF-D4JoiOvg.js +106 -0
- package/dist/assets/graphlib-DGcD9J2L.js +1 -0
- package/dist/assets/index-Cow3qpoq.css +2 -0
- package/dist/assets/index-DUf7okYi.js +14 -0
- package/dist/assets/info-OMHHGYJF-DI6-Z9vh.js +1 -0
- package/dist/assets/infoDiagram-42DDH7IO-D1ZkeMBy.js +2 -0
- package/dist/assets/init-TPm5RB77.js +1 -0
- package/dist/assets/isArrayLikeObject-69BLnVNM.js +1 -0
- package/dist/assets/isEmpty-DUS28g5f.js +1 -0
- package/dist/assets/ishikawaDiagram-UXIWVN3A-Dv8hzjZB.js +70 -0
- package/dist/assets/journeyDiagram-VCZTEJTY-COeB7F5r.js +139 -0
- package/dist/assets/kanban-definition-6JOO6SKY-BbYmxCYU.js +89 -0
- package/dist/assets/katex-5SGEXwpi.js +261 -0
- package/dist/assets/line-_v2NGEdn.js +1 -0
- package/dist/assets/linear-CXMqTN8N.js +1 -0
- package/dist/assets/mermaid-config-C8a4L22x.js +1 -0
- package/dist/assets/mermaid-parser.core-CFmphzPP.js +4 -0
- package/dist/assets/mermaid.core-DnHAupTp.js +11 -0
- package/dist/assets/mindmap-definition-QFDTVHPH-D7_lIep7.js +96 -0
- package/dist/assets/ordinal-D7l-8DAO.js +1 -0
- package/dist/assets/packet-4T2RLAQJ-DidW3JFc.js +1 -0
- package/dist/assets/path-BVpCanzE.js +1 -0
- package/dist/assets/pie-ZZUOXDRM-Bff2e5hg.js +1 -0
- package/dist/assets/pieDiagram-DEJITSTG-DDvYHCT_.js +30 -0
- package/dist/assets/quadrantDiagram-34T5L4WZ-DcLcIrdi.js +7 -0
- package/dist/assets/radar-PYXPWWZC-CsdZBH3M.js +1 -0
- package/dist/assets/requirementDiagram-MS252O5E-DLX6ld7D.js +84 -0
- package/dist/assets/rough.esm-BoTisKeL.js +1 -0
- package/dist/assets/sankeyDiagram-XADWPNL6-D-1GtsHM.js +10 -0
- package/dist/assets/sequenceDiagram-FGHM5R23-Bwxs0YQg.js +157 -0
- package/dist/assets/src-CrmkjRpa.js +1 -0
- package/dist/assets/stateDiagram-FHFEXIEX-DW7rOcnQ.js +1 -0
- package/dist/assets/stateDiagram-v2-QKLJ7IA2-Jm-24vQ2.js +1 -0
- package/dist/assets/timeline-definition-GMOUNBTQ-DVdHyzxS.js +120 -0
- package/dist/assets/treeView-SZITEDCU-DPKseaET.js +1 -0
- package/dist/assets/treemap-W4RFUUIX-DH-7GZe_.js +1 -0
- package/dist/assets/vennDiagram-DHZGUBPP-DJaC6xmI.js +34 -0
- package/dist/assets/wardley-RL74JXVD-AgyXyBN5.js +1 -0
- package/dist/assets/wardleyDiagram-NUSXRM2D-CTKERPKv.js +20 -0
- package/dist/assets/xychartDiagram-5P7HB3ND-BuExiLXc.js +7 -0
- package/{index.html → dist/index.html} +2 -1
- package/dist/index.js +2539 -0
- package/package.json +11 -1
- package/.agents/skills/remotion-best-practices/SKILL.md +0 -61
- package/.agents/skills/remotion-best-practices/rules/3d.md +0 -86
- package/.agents/skills/remotion-best-practices/rules/animations.md +0 -27
- package/.agents/skills/remotion-best-practices/rules/assets/charts-bar-chart.tsx +0 -178
- package/.agents/skills/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +0 -100
- package/.agents/skills/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +0 -108
- package/.agents/skills/remotion-best-practices/rules/assets.md +0 -78
- package/.agents/skills/remotion-best-practices/rules/audio-visualization.md +0 -198
- package/.agents/skills/remotion-best-practices/rules/audio.md +0 -169
- package/.agents/skills/remotion-best-practices/rules/calculate-metadata.md +0 -134
- package/.agents/skills/remotion-best-practices/rules/can-decode.md +0 -75
- package/.agents/skills/remotion-best-practices/rules/charts.md +0 -120
- package/.agents/skills/remotion-best-practices/rules/compositions.md +0 -154
- package/.agents/skills/remotion-best-practices/rules/display-captions.md +0 -184
- package/.agents/skills/remotion-best-practices/rules/extract-frames.md +0 -229
- package/.agents/skills/remotion-best-practices/rules/ffmpeg.md +0 -38
- package/.agents/skills/remotion-best-practices/rules/fonts.md +0 -152
- package/.agents/skills/remotion-best-practices/rules/get-audio-duration.md +0 -58
- package/.agents/skills/remotion-best-practices/rules/get-video-dimensions.md +0 -68
- package/.agents/skills/remotion-best-practices/rules/get-video-duration.md +0 -60
- package/.agents/skills/remotion-best-practices/rules/gifs.md +0 -141
- package/.agents/skills/remotion-best-practices/rules/images.md +0 -134
- package/.agents/skills/remotion-best-practices/rules/import-srt-captions.md +0 -69
- package/.agents/skills/remotion-best-practices/rules/light-leaks.md +0 -73
- package/.agents/skills/remotion-best-practices/rules/lottie.md +0 -70
- package/.agents/skills/remotion-best-practices/rules/maps.md +0 -412
- package/.agents/skills/remotion-best-practices/rules/measuring-dom-nodes.md +0 -34
- package/.agents/skills/remotion-best-practices/rules/measuring-text.md +0 -140
- package/.agents/skills/remotion-best-practices/rules/parameters.md +0 -109
- package/.agents/skills/remotion-best-practices/rules/sequencing.md +0 -118
- package/.agents/skills/remotion-best-practices/rules/sfx.md +0 -26
- package/.agents/skills/remotion-best-practices/rules/subtitles.md +0 -36
- package/.agents/skills/remotion-best-practices/rules/tailwind.md +0 -11
- package/.agents/skills/remotion-best-practices/rules/text-animations.md +0 -20
- package/.agents/skills/remotion-best-practices/rules/timing.md +0 -179
- package/.agents/skills/remotion-best-practices/rules/transcribe-captions.md +0 -70
- package/.agents/skills/remotion-best-practices/rules/transitions.md +0 -197
- package/.agents/skills/remotion-best-practices/rules/transparent-videos.md +0 -106
- package/.agents/skills/remotion-best-practices/rules/trimming.md +0 -51
- package/.agents/skills/remotion-best-practices/rules/videos.md +0 -171
- package/.agents/skills/remotion-best-practices/rules/voiceover.md +0 -99
- package/.agents/skills/simple/SKILL.md +0 -52
- package/.agents/skills/vercel-react-best-practices/AGENTS.md +0 -3254
- package/.agents/skills/vercel-react-best-practices/README.md +0 -123
- package/.agents/skills/vercel-react-best-practices/SKILL.md +0 -141
- package/.agents/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +0 -55
- package/.agents/skills/vercel-react-best-practices/rules/advanced-init-once.md +0 -42
- package/.agents/skills/vercel-react-best-practices/rules/advanced-use-latest.md +0 -39
- package/.agents/skills/vercel-react-best-practices/rules/async-api-routes.md +0 -38
- package/.agents/skills/vercel-react-best-practices/rules/async-defer-await.md +0 -80
- package/.agents/skills/vercel-react-best-practices/rules/async-dependencies.md +0 -51
- package/.agents/skills/vercel-react-best-practices/rules/async-parallel.md +0 -28
- package/.agents/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +0 -99
- package/.agents/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +0 -59
- package/.agents/skills/vercel-react-best-practices/rules/bundle-conditional.md +0 -31
- package/.agents/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +0 -49
- package/.agents/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +0 -35
- package/.agents/skills/vercel-react-best-practices/rules/bundle-preload.md +0 -50
- package/.agents/skills/vercel-react-best-practices/rules/client-event-listeners.md +0 -74
- package/.agents/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +0 -71
- package/.agents/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +0 -48
- package/.agents/skills/vercel-react-best-practices/rules/client-swr-dedup.md +0 -56
- package/.agents/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +0 -107
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-function-results.md +0 -80
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-property-access.md +0 -28
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-storage.md +0 -70
- package/.agents/skills/vercel-react-best-practices/rules/js-combine-iterations.md +0 -32
- package/.agents/skills/vercel-react-best-practices/rules/js-early-exit.md +0 -50
- package/.agents/skills/vercel-react-best-practices/rules/js-flatmap-filter.md +0 -60
- package/.agents/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +0 -45
- package/.agents/skills/vercel-react-best-practices/rules/js-index-maps.md +0 -37
- package/.agents/skills/vercel-react-best-practices/rules/js-length-check-first.md +0 -49
- package/.agents/skills/vercel-react-best-practices/rules/js-min-max-loop.md +0 -82
- package/.agents/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +0 -24
- package/.agents/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +0 -57
- package/.agents/skills/vercel-react-best-practices/rules/rendering-activity.md +0 -26
- package/.agents/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +0 -47
- package/.agents/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +0 -40
- package/.agents/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +0 -38
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +0 -46
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +0 -82
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +0 -30
- package/.agents/skills/vercel-react-best-practices/rules/rendering-resource-hints.md +0 -85
- package/.agents/skills/vercel-react-best-practices/rules/rendering-script-defer-async.md +0 -68
- package/.agents/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +0 -28
- package/.agents/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +0 -75
- package/.agents/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +0 -39
- package/.agents/skills/vercel-react-best-practices/rules/rerender-dependencies.md +0 -45
- package/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +0 -40
- package/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state.md +0 -29
- package/.agents/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +0 -74
- package/.agents/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +0 -58
- package/.agents/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +0 -38
- package/.agents/skills/vercel-react-best-practices/rules/rerender-memo.md +0 -44
- package/.agents/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +0 -45
- package/.agents/skills/vercel-react-best-practices/rules/rerender-no-inline-components.md +0 -82
- package/.agents/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +0 -35
- package/.agents/skills/vercel-react-best-practices/rules/rerender-transitions.md +0 -40
- package/.agents/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +0 -73
- package/.agents/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +0 -73
- package/.agents/skills/vercel-react-best-practices/rules/server-auth-actions.md +0 -96
- package/.agents/skills/vercel-react-best-practices/rules/server-cache-lru.md +0 -41
- package/.agents/skills/vercel-react-best-practices/rules/server-cache-react.md +0 -76
- package/.agents/skills/vercel-react-best-practices/rules/server-dedup-props.md +0 -65
- package/.agents/skills/vercel-react-best-practices/rules/server-hoist-static-io.md +0 -142
- package/.agents/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +0 -83
- package/.agents/skills/vercel-react-best-practices/rules/server-serialization.md +0 -38
- package/.claude/CLAUDE.md +0 -184
- package/.claude/commands/review.md +0 -120
- package/.claude/commands/sync-docs.md +0 -71
- package/.claude/roadmap.md +0 -121
- package/.claude/rules/style-guide.md +0 -830
- package/.claude/settings.json +0 -18
- package/.claude/user-stories.md +0 -333
- package/AGENTS.md +0 -68
- package/Makefile +0 -32
- package/biome.json +0 -79
- package/bun.lock +0 -854
- package/bunfig.toml +0 -2
- package/docs/design.md +0 -563
- package/docs/perf-baseline.md +0 -130
- package/docs/plans/2026-03-13-client-mode-design.md +0 -86
- package/docs/plans/2026-03-13-client-mode-plan.md +0 -605
- package/docs/plans/2026-03-13-keyboard-shortcuts-design.md +0 -129
- package/docs/plans/2026-03-13-keyboard-shortcuts-plan.md +0 -1471
- package/docs/plans/2026-03-13-multi-document-design.md +0 -183
- package/docs/plans/2026-03-13-performance-benchmarks-design.md +0 -121
- package/docs/superpowers/plans/2026-03-26-surgical-pruning.md +0 -1176
- package/docs/superpowers/specs/2026-03-27-go-server-rewrite-design.md +0 -284
- package/e2e/comments.spec.ts +0 -81
- package/e2e/document-load.spec.ts +0 -32
- package/e2e/export.spec.ts +0 -58
- package/e2e/fixtures/sample.md +0 -7
- package/e2e/perf/add-comment.spec.ts +0 -116
- package/e2e/perf/fixtures/generate.ts +0 -327
- package/e2e/perf/initial-load.spec.ts +0 -49
- package/e2e/perf/perf.setup.ts +0 -23
- package/e2e/perf/perf.teardown.ts +0 -9
- package/e2e/perf/screenshot-final.png +0 -0
- package/e2e/perf/scroll.spec.ts +0 -39
- package/e2e/perf/tab-switch.spec.ts +0 -69
- package/e2e/perf/text-selection.spec.ts +0 -119
- package/e2e/perf/utils/metrics.ts +0 -350
- package/e2e/perf/utils/perf-cli.ts +0 -86
- package/e2e/persistence-file.spec.ts +0 -357
- package/e2e/utils/cli.ts +0 -84
- package/e2e/utils/selection.ts +0 -79
- package/go/cmd/readit/main.go +0 -416
- package/go/go.mod +0 -20
- package/go/go.sum +0 -41
- package/go/internal/server/anchor.go +0 -302
- package/go/internal/server/anchor_test.go +0 -111
- package/go/internal/server/comments.go +0 -390
- package/go/internal/server/documents.go +0 -113
- package/go/internal/server/embed.go +0 -17
- package/go/internal/server/headings.go +0 -33
- package/go/internal/server/headings_test.go +0 -75
- package/go/internal/server/htmltext.go +0 -123
- package/go/internal/server/markdown.go +0 -157
- package/go/internal/server/markdown_bench_test.go +0 -42
- package/go/internal/server/markdown_test.go +0 -79
- package/go/internal/server/server.go +0 -453
- package/go/internal/server/server_bench_test.go +0 -122
- package/go/internal/server/settings.go +0 -110
- package/go/internal/server/sse.go +0 -140
- package/go/internal/server/storage.go +0 -275
- package/go/internal/server/storage_test.go +0 -152
- package/go/internal/server/template.go +0 -66
- package/go/internal/server/types.go +0 -101
- package/go/internal/server/watcher.go +0 -74
- package/lefthook.yml +0 -8
- package/nvim-readit/lua/readit/health.lua +0 -64
- package/nvim-readit/lua/readit/init.lua +0 -463
- package/nvim-readit/plugin/readit.lua +0 -19
- package/playwright.config.ts +0 -34
- package/skills-lock.json +0 -20
- package/src/App.svelte +0 -890
- package/src/cli.ts +0 -881
- package/src/components/ActionsMenu.svelte +0 -95
- package/src/components/CommentBadge.svelte +0 -67
- package/src/components/CommentErrorBanner.svelte +0 -33
- package/src/components/CommentInput.svelte +0 -75
- package/src/components/CommentListItem.svelte +0 -95
- package/src/components/CommentManager.svelte +0 -129
- package/src/components/CommentNav.svelte +0 -109
- package/src/components/DocumentViewer.svelte +0 -233
- package/src/components/FloatingComment.svelte +0 -107
- package/src/components/Header.svelte +0 -76
- package/src/components/InlineEditor.svelte +0 -72
- package/src/components/MarginNote.svelte +0 -167
- package/src/components/MarginNotesContainer.svelte +0 -33
- package/src/components/MermaidEnhancer.svelte +0 -218
- package/src/components/MermaidModal.svelte +0 -67
- package/src/components/RawModal.svelte +0 -126
- package/src/components/ReanchorConfirm.svelte +0 -30
- package/src/components/SettingsModal.svelte +0 -220
- package/src/components/ShortcutCapture.svelte +0 -82
- package/src/components/ShortcutList.svelte +0 -145
- package/src/components/TabBar.svelte +0 -52
- package/src/components/TableOfContents.svelte +0 -125
- package/src/components/ui/ActionLink.svelte +0 -40
- package/src/components/ui/Button.svelte +0 -53
- package/src/components/ui/Dialog.svelte +0 -97
- package/src/components/ui/DropdownMenu.svelte +0 -85
- package/src/components/ui/DropdownMenuItem.svelte +0 -38
- package/src/components/ui/DropdownMenuSeparator.svelte +0 -11
- package/src/components/ui/Text.svelte +0 -42
- package/src/env.d.ts +0 -6
- package/src/index.css +0 -859
- package/src/lib/__fixtures__/bench-data.ts +0 -114
- package/src/lib/anchor.bench.ts +0 -91
- package/src/lib/anchor.test.ts +0 -527
- package/src/lib/anchor.ts +0 -381
- package/src/lib/comment-storage.bench.ts +0 -49
- package/src/lib/comment-storage.test.ts +0 -694
- package/src/lib/comment-storage.ts +0 -226
- package/src/lib/export.bench.ts +0 -21
- package/src/lib/export.ts +0 -36
- package/src/lib/fetch-or-throw.test.ts +0 -59
- package/src/lib/fetch-or-throw.ts +0 -12
- package/src/lib/headings.test.ts +0 -103
- package/src/lib/headings.ts +0 -44
- package/src/lib/highlight/core.test.ts +0 -93
- package/src/lib/highlight/dom.ts +0 -187
- package/src/lib/highlight/highlight-registry.ts +0 -221
- package/src/lib/highlight/highlight.bench.ts +0 -92
- package/src/lib/highlight/highlighter.ts +0 -247
- package/src/lib/highlight/resolver.ts +0 -38
- package/src/lib/highlight/types.ts +0 -17
- package/src/lib/html-text.test.ts +0 -162
- package/src/lib/html-text.ts +0 -161
- package/src/lib/i18n/en.ts +0 -124
- package/src/lib/i18n/index.ts +0 -3
- package/src/lib/i18n/ja.ts +0 -126
- package/src/lib/i18n/translations.ts +0 -27
- package/src/lib/i18n/types.ts +0 -130
- package/src/lib/key-lock.test.ts +0 -104
- package/src/lib/key-lock.ts +0 -23
- package/src/lib/margin-layout.bench.ts +0 -61
- package/src/lib/margin-layout.ts +0 -71
- package/src/lib/markdown-renderer.test.ts +0 -154
- package/src/lib/markdown-renderer.ts +0 -178
- package/src/lib/mermaid-config.ts +0 -38
- package/src/lib/mermaid-renderer.ts +0 -162
- package/src/lib/mermaid-worker.ts +0 -60
- package/src/lib/positions.ts +0 -157
- package/src/lib/shortcut-registry.ts +0 -244
- package/src/lib/utils.ts +0 -15
- package/src/main.ts +0 -16
- package/src/schema.ts +0 -92
- package/src/server.ts +0 -1216
- package/src/stores/app.svelte.ts +0 -231
- package/src/stores/locale.svelte.ts +0 -46
- package/src/stores/settings.svelte.ts +0 -90
- package/src/stores/shortcuts.svelte.ts +0 -104
- package/src/stores/ui.svelte.ts +0 -12
- package/src/template.ts +0 -104
- package/src/test-setup.ts +0 -48
- package/svelte.config.js +0 -5
- package/test.md +0 -74
- package/tsconfig.cli.json +0 -12
- package/tsconfig.json +0 -20
- package/vite.config.ts +0 -47
- package/vitest.config.ts +0 -15
- package/vscode-readit/.mcp.json +0 -7
- package/vscode-readit/.vscodeignore +0 -7
- package/vscode-readit/bun.lock +0 -78
- package/vscode-readit/icon.svg +0 -10
- package/vscode-readit/package.json +0 -110
- package/vscode-readit/src/extension.ts +0 -117
- package/vscode-readit/src/server-manager.ts +0 -272
- package/vscode-readit/src/webview-provider.ts +0 -204
- package/vscode-readit/tsconfig.json +0 -20
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import * as crypto from "node:crypto";
|
|
2
|
-
import * as os from "node:os";
|
|
3
|
-
import * as path from "node:path";
|
|
4
|
-
import type { Comment, CommentFile } from "../schema";
|
|
5
|
-
|
|
6
|
-
const FORMAT_VERSION = 1;
|
|
7
|
-
const HASH_LENGTH = 16;
|
|
8
|
-
const MAX_SELECTION_LENGTH = 1000;
|
|
9
|
-
const TRUNCATION_MARKER = "\n...\n";
|
|
10
|
-
const ANCHOR_PREFIX_LENGTH = 200;
|
|
11
|
-
|
|
12
|
-
export function truncateSelection(text: string): string {
|
|
13
|
-
if (text.length <= MAX_SELECTION_LENGTH) {
|
|
14
|
-
return text;
|
|
15
|
-
}
|
|
16
|
-
const half = Math.floor(
|
|
17
|
-
(MAX_SELECTION_LENGTH - TRUNCATION_MARKER.length) / 2,
|
|
18
|
-
);
|
|
19
|
-
return text.slice(0, half) + TRUNCATION_MARKER + text.slice(-half);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function getCommentPath(sourcePath: string): string {
|
|
23
|
-
const absolute = path.resolve(sourcePath);
|
|
24
|
-
const normalized = absolute.replace(/^\//, "").replace(/^[A-Z]:[\\/]/, "");
|
|
25
|
-
const ext = path.extname(normalized);
|
|
26
|
-
const withoutExt = normalized.slice(0, -ext.length || undefined);
|
|
27
|
-
|
|
28
|
-
return path.join(
|
|
29
|
-
os.homedir(),
|
|
30
|
-
".readit",
|
|
31
|
-
"comments",
|
|
32
|
-
`${withoutExt}.comments.md`,
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function computeHash(content: string): string {
|
|
37
|
-
return crypto
|
|
38
|
-
.createHash("sha256")
|
|
39
|
-
.update(content)
|
|
40
|
-
.digest("hex")
|
|
41
|
-
.slice(0, HASH_LENGTH);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function getLineNumber(content: string, offset: number): number {
|
|
45
|
-
if (offset <= 0 || content.length === 0) return 1;
|
|
46
|
-
const clampedOffset = Math.min(offset, content.length);
|
|
47
|
-
return content.slice(0, clampedOffset).split("\n").length;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function getLineHint(
|
|
51
|
-
content: string,
|
|
52
|
-
startOffset: number,
|
|
53
|
-
endOffset: number,
|
|
54
|
-
): string {
|
|
55
|
-
const startLine = getLineNumber(content, startOffset);
|
|
56
|
-
const endLine = getLineNumber(content, endOffset);
|
|
57
|
-
return startLine === endLine ? `L${startLine}` : `L${startLine}-L${endLine}`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function parseCommentFile(content: string): CommentFile {
|
|
61
|
-
const result: CommentFile = {
|
|
62
|
-
source: "",
|
|
63
|
-
hash: "",
|
|
64
|
-
version: FORMAT_VERSION,
|
|
65
|
-
comments: [],
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
if (!content.trim()) {
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const frontMatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
73
|
-
if (frontMatterMatch) {
|
|
74
|
-
const frontMatter = frontMatterMatch[1];
|
|
75
|
-
const sourceMatch = frontMatter.match(/^source:\s*(.+)$/m);
|
|
76
|
-
const hashMatch = frontMatter.match(/^hash:\s*(.+)$/m);
|
|
77
|
-
const versionMatch = frontMatter.match(/^version:\s*(\d+)$/m);
|
|
78
|
-
|
|
79
|
-
if (sourceMatch) result.source = sourceMatch[1].trim();
|
|
80
|
-
if (hashMatch) result.hash = hashMatch[1].trim();
|
|
81
|
-
if (versionMatch) result.version = Number.parseInt(versionMatch[1], 10);
|
|
82
|
-
|
|
83
|
-
if (result.version > FORMAT_VERSION) {
|
|
84
|
-
throw new Error(
|
|
85
|
-
`Comment file requires readit v${result.version} or higher. ` +
|
|
86
|
-
`Current version supports format v${FORMAT_VERSION}.`,
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const bodyContent = content.replace(/^---\n[\s\S]*?\n---\n*/, "");
|
|
92
|
-
|
|
93
|
-
const markerRe = /<!--\s*c:[^|]+\|[^|>\s]+(?:\|[^>]*)?\s*-->/g;
|
|
94
|
-
const markerStarts: number[] = [];
|
|
95
|
-
for (const m of bodyContent.matchAll(markerRe)) {
|
|
96
|
-
if (m.index !== undefined) markerStarts.push(m.index);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
for (let i = 0; i < markerStarts.length; i++) {
|
|
100
|
-
const start = markerStarts[i];
|
|
101
|
-
const end =
|
|
102
|
-
i + 1 < markerStarts.length ? markerStarts[i + 1] : bodyContent.length;
|
|
103
|
-
const block = bodyContent
|
|
104
|
-
.slice(start, end)
|
|
105
|
-
.replace(/\n+---\s*$/, "")
|
|
106
|
-
.trim();
|
|
107
|
-
if (!block) continue;
|
|
108
|
-
const comment = parseCommentBlock(block);
|
|
109
|
-
if (comment) {
|
|
110
|
-
result.comments.push(comment);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return result;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function parseCommentBlock(block: string): Comment | undefined {
|
|
118
|
-
const metadataMatch = block.match(
|
|
119
|
-
/<!--\s*c:([^|]+)\|([^|>\s]+)(?:\|([^>]*))?\s*-->/,
|
|
120
|
-
);
|
|
121
|
-
if (!metadataMatch) {
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const [, id, lineHint, createdAtRaw] = metadataMatch;
|
|
126
|
-
const createdAt = createdAtRaw?.trim() || undefined;
|
|
127
|
-
|
|
128
|
-
const anchorMatch = block.match(/<!--\s*anchor:(.+?)\s*-->/);
|
|
129
|
-
const anchorPrefix = anchorMatch ? anchorMatch[1] : undefined;
|
|
130
|
-
|
|
131
|
-
const blockquoteMatch = block.match(/^>\s*(.+(?:\n>\s*.+)*)$/m);
|
|
132
|
-
if (!blockquoteMatch) {
|
|
133
|
-
return undefined;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const selectedText = blockquoteMatch[1]
|
|
137
|
-
.split("\n")
|
|
138
|
-
.map((line) => line.replace(/^>\s*/, ""))
|
|
139
|
-
.join("\n");
|
|
140
|
-
|
|
141
|
-
const afterBlockquote = block.slice(
|
|
142
|
-
block.indexOf(blockquoteMatch[0]) + blockquoteMatch[0].length,
|
|
143
|
-
);
|
|
144
|
-
const commentBody = afterBlockquote.trim();
|
|
145
|
-
|
|
146
|
-
return {
|
|
147
|
-
id,
|
|
148
|
-
selectedText,
|
|
149
|
-
comment: commentBody,
|
|
150
|
-
lineHint,
|
|
151
|
-
createdAt,
|
|
152
|
-
anchorPrefix,
|
|
153
|
-
startOffset: 0,
|
|
154
|
-
endOffset: 0,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export function serializeComments(file: CommentFile): string {
|
|
159
|
-
const lines: string[] = [];
|
|
160
|
-
|
|
161
|
-
lines.push("---");
|
|
162
|
-
lines.push(`source: ${file.source}`);
|
|
163
|
-
lines.push(`hash: ${file.hash}`);
|
|
164
|
-
lines.push(`version: ${file.version}`);
|
|
165
|
-
lines.push("---");
|
|
166
|
-
lines.push("");
|
|
167
|
-
|
|
168
|
-
for (const comment of file.comments) {
|
|
169
|
-
lines.push(serializeComment(comment));
|
|
170
|
-
lines.push("");
|
|
171
|
-
lines.push("---");
|
|
172
|
-
lines.push("");
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return lines.join("\n");
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function serializeComment(comment: Comment): string {
|
|
179
|
-
const lines: string[] = [];
|
|
180
|
-
|
|
181
|
-
const lineHint = comment.lineHint || "L0";
|
|
182
|
-
const createdAt = comment.createdAt || new Date().toISOString();
|
|
183
|
-
lines.push(`<!-- c:${comment.id}|${lineHint}|${createdAt} -->`);
|
|
184
|
-
|
|
185
|
-
if (comment.anchorPrefix) {
|
|
186
|
-
lines.push(`<!-- anchor:${comment.anchorPrefix} -->`);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const quotedLines = comment.selectedText
|
|
190
|
-
.split("\n")
|
|
191
|
-
.map((line) => `> ${line}`);
|
|
192
|
-
lines.push(...quotedLines);
|
|
193
|
-
|
|
194
|
-
if (comment.comment) {
|
|
195
|
-
lines.push("");
|
|
196
|
-
lines.push(comment.comment);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return lines.join("\n");
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export function createComment(
|
|
203
|
-
selectedText: string,
|
|
204
|
-
commentText: string,
|
|
205
|
-
startOffset: number,
|
|
206
|
-
endOffset: number,
|
|
207
|
-
sourceContent: string,
|
|
208
|
-
): Comment {
|
|
209
|
-
const id = crypto.randomUUID().slice(0, 8);
|
|
210
|
-
const lineHint = getLineHint(sourceContent, startOffset, endOffset);
|
|
211
|
-
|
|
212
|
-
const needsTruncation = selectedText.length > MAX_SELECTION_LENGTH;
|
|
213
|
-
|
|
214
|
-
return {
|
|
215
|
-
id,
|
|
216
|
-
selectedText: truncateSelection(selectedText),
|
|
217
|
-
comment: commentText,
|
|
218
|
-
startOffset,
|
|
219
|
-
endOffset,
|
|
220
|
-
lineHint,
|
|
221
|
-
createdAt: new Date().toISOString(),
|
|
222
|
-
anchorPrefix: needsTruncation
|
|
223
|
-
? selectedText.slice(0, ANCHOR_PREFIX_LENGTH)
|
|
224
|
-
: undefined,
|
|
225
|
-
};
|
|
226
|
-
}
|
package/src/lib/export.bench.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { bench, describe } from "vitest";
|
|
2
|
-
import { COMMENTS_10, COMMENTS_50 } from "./__fixtures__/bench-data";
|
|
3
|
-
import { formatComment, generatePrompt } from "./export";
|
|
4
|
-
|
|
5
|
-
describe("formatComment", () => {
|
|
6
|
-
const comment = COMMENTS_10[0];
|
|
7
|
-
|
|
8
|
-
bench("single comment", () => {
|
|
9
|
-
formatComment(comment);
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
describe("generatePrompt", () => {
|
|
14
|
-
bench("10 comments", () => {
|
|
15
|
-
generatePrompt(COMMENTS_10, "benchmark.md");
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
bench("50 comments", () => {
|
|
19
|
-
generatePrompt(COMMENTS_50, "benchmark.md");
|
|
20
|
-
});
|
|
21
|
-
});
|
package/src/lib/export.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Comment, Document } from "../schema";
|
|
2
|
-
|
|
3
|
-
export function formatComment(c: Comment): string {
|
|
4
|
-
const line = c.lineHint ? `[${c.lineHint}] ` : "";
|
|
5
|
-
return `${line}"${c.selectedText}"\n${c.comment}`;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function generatePrompt(comments: Comment[], fileName: string): string {
|
|
9
|
-
return `# Review Comments for ${fileName}\n\n${comments.map(formatComment).join("\n\n---\n\n")}`;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function exportCommentsAsJson(
|
|
13
|
-
comments: Comment[],
|
|
14
|
-
document: Document,
|
|
15
|
-
): void {
|
|
16
|
-
const data = {
|
|
17
|
-
filePath: document.filePath,
|
|
18
|
-
fileName: document.fileName,
|
|
19
|
-
exportedAt: new Date().toISOString(),
|
|
20
|
-
comments: comments.map((c) => ({
|
|
21
|
-
selectedText: c.selectedText,
|
|
22
|
-
comment: c.comment,
|
|
23
|
-
lineHint: c.lineHint,
|
|
24
|
-
})),
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const blob = new Blob([JSON.stringify(data, null, 2)], {
|
|
28
|
-
type: "application/json",
|
|
29
|
-
});
|
|
30
|
-
const url = URL.createObjectURL(blob);
|
|
31
|
-
const a = window.document.createElement("a");
|
|
32
|
-
a.href = url;
|
|
33
|
-
a.download = `${document.fileName}-comments.json`;
|
|
34
|
-
a.click();
|
|
35
|
-
URL.revokeObjectURL(url);
|
|
36
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { fetchOrThrow } from "./fetch-or-throw";
|
|
3
|
-
|
|
4
|
-
function mockFetch(response: Response) {
|
|
5
|
-
return vi.spyOn(globalThis, "fetch").mockResolvedValue(response);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
afterEach(() => {
|
|
9
|
-
vi.restoreAllMocks();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
describe("fetchOrThrow", () => {
|
|
13
|
-
it("returns response on 2xx", async () => {
|
|
14
|
-
mockFetch(new Response("ok", { status: 200 }));
|
|
15
|
-
const res = await fetchOrThrow("/api", {}, "fallback");
|
|
16
|
-
expect(res.ok).toBe(true);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("throws body.error when response is not ok and body has error field", async () => {
|
|
20
|
-
mockFetch(
|
|
21
|
-
new Response(JSON.stringify({ error: "EACCES: permission denied" }), {
|
|
22
|
-
status: 500,
|
|
23
|
-
headers: { "Content-Type": "application/json" },
|
|
24
|
-
}),
|
|
25
|
-
);
|
|
26
|
-
await expect(fetchOrThrow("/api", {}, "fallback")).rejects.toThrow(
|
|
27
|
-
"EACCES: permission denied",
|
|
28
|
-
);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("falls back to statusText when body is not JSON", async () => {
|
|
32
|
-
mockFetch(
|
|
33
|
-
new Response("not json", { status: 500, statusText: "Server Error" }),
|
|
34
|
-
);
|
|
35
|
-
await expect(fetchOrThrow("/api", {}, "fallback")).rejects.toThrow(
|
|
36
|
-
"Server Error",
|
|
37
|
-
);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("falls back to fallback message when statusText is empty", async () => {
|
|
41
|
-
mockFetch(new Response("", { status: 500, statusText: "" }));
|
|
42
|
-
await expect(fetchOrThrow("/api", {}, "fallback message")).rejects.toThrow(
|
|
43
|
-
"fallback message",
|
|
44
|
-
);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("falls back to statusText when body is JSON but lacks error field", async () => {
|
|
48
|
-
mockFetch(
|
|
49
|
-
new Response(JSON.stringify({ ok: false }), {
|
|
50
|
-
status: 500,
|
|
51
|
-
statusText: "Internal Error",
|
|
52
|
-
headers: { "Content-Type": "application/json" },
|
|
53
|
-
}),
|
|
54
|
-
);
|
|
55
|
-
await expect(fetchOrThrow("/api", {}, "fallback")).rejects.toThrow(
|
|
56
|
-
"Internal Error",
|
|
57
|
-
);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export async function fetchOrThrow(
|
|
2
|
-
url: string,
|
|
3
|
-
init: RequestInit,
|
|
4
|
-
fallback: string,
|
|
5
|
-
): Promise<Response> {
|
|
6
|
-
const response = await fetch(url, init);
|
|
7
|
-
if (!response.ok) {
|
|
8
|
-
const body = await response.json().catch(() => null);
|
|
9
|
-
throw new Error(body?.error || response.statusText || fallback);
|
|
10
|
-
}
|
|
11
|
-
return response;
|
|
12
|
-
}
|
package/src/lib/headings.test.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { parseMarkdownHeadings } from "./headings";
|
|
3
|
-
|
|
4
|
-
describe("parseMarkdownHeadings", () => {
|
|
5
|
-
it("extracts basic headings", () => {
|
|
6
|
-
const content = `# Heading 1
|
|
7
|
-
## Heading 2
|
|
8
|
-
### Heading 3`;
|
|
9
|
-
|
|
10
|
-
expect(parseMarkdownHeadings(content)).toEqual([
|
|
11
|
-
{ id: "heading-1", text: "Heading 1", level: 1 },
|
|
12
|
-
{ id: "heading-2", text: "Heading 2", level: 2 },
|
|
13
|
-
{ id: "heading-3", text: "Heading 3", level: 3 },
|
|
14
|
-
]);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("handles duplicate headings", () => {
|
|
18
|
-
const content = `## Section
|
|
19
|
-
## Section
|
|
20
|
-
## Section`;
|
|
21
|
-
|
|
22
|
-
expect(parseMarkdownHeadings(content)).toEqual([
|
|
23
|
-
{ id: "section", text: "Section", level: 2 },
|
|
24
|
-
{ id: "section-1", text: "Section", level: 2 },
|
|
25
|
-
{ id: "section-2", text: "Section", level: 2 },
|
|
26
|
-
]);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("ignores headings inside fenced code blocks", () => {
|
|
30
|
-
const content = `# Real Heading
|
|
31
|
-
|
|
32
|
-
\`\`\`bash
|
|
33
|
-
# This is a comment, not a heading
|
|
34
|
-
echo "hello"
|
|
35
|
-
\`\`\`
|
|
36
|
-
|
|
37
|
-
## Another Real Heading`;
|
|
38
|
-
|
|
39
|
-
expect(parseMarkdownHeadings(content)).toEqual([
|
|
40
|
-
{ id: "real-heading", text: "Real Heading", level: 1 },
|
|
41
|
-
{ id: "another-real-heading", text: "Another Real Heading", level: 2 },
|
|
42
|
-
]);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("ignores headings inside triple-tilde code blocks", () => {
|
|
46
|
-
const content = `# Real Heading
|
|
47
|
-
|
|
48
|
-
~~~python
|
|
49
|
-
# Python comment
|
|
50
|
-
def foo():
|
|
51
|
-
pass
|
|
52
|
-
~~~
|
|
53
|
-
|
|
54
|
-
## Another Real Heading`;
|
|
55
|
-
|
|
56
|
-
expect(parseMarkdownHeadings(content)).toEqual([
|
|
57
|
-
{ id: "real-heading", text: "Real Heading", level: 1 },
|
|
58
|
-
{ id: "another-real-heading", text: "Another Real Heading", level: 2 },
|
|
59
|
-
]);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("handles multiple code blocks", () => {
|
|
63
|
-
const content = `# Introduction
|
|
64
|
-
|
|
65
|
-
\`\`\`bash
|
|
66
|
-
# Comment 1
|
|
67
|
-
\`\`\`
|
|
68
|
-
|
|
69
|
-
## Methods
|
|
70
|
-
|
|
71
|
-
\`\`\`python
|
|
72
|
-
# Comment 2
|
|
73
|
-
\`\`\`
|
|
74
|
-
|
|
75
|
-
## Results`;
|
|
76
|
-
|
|
77
|
-
expect(parseMarkdownHeadings(content)).toEqual([
|
|
78
|
-
{ id: "introduction", text: "Introduction", level: 1 },
|
|
79
|
-
{ id: "methods", text: "Methods", level: 2 },
|
|
80
|
-
{ id: "results", text: "Results", level: 2 },
|
|
81
|
-
]);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("handles code block with language specifier", () => {
|
|
85
|
-
const content = `# Setup
|
|
86
|
-
|
|
87
|
-
\`\`\`bash
|
|
88
|
-
# Use a custom port
|
|
89
|
-
npx readit document.md --port 3000
|
|
90
|
-
\`\`\`
|
|
91
|
-
|
|
92
|
-
## Usage`;
|
|
93
|
-
|
|
94
|
-
expect(parseMarkdownHeadings(content)).toEqual([
|
|
95
|
-
{ id: "setup", text: "Setup", level: 1 },
|
|
96
|
-
{ id: "usage", text: "Usage", level: 2 },
|
|
97
|
-
]);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it("returns empty array for empty content", () => {
|
|
101
|
-
expect(parseMarkdownHeadings("")).toEqual([]);
|
|
102
|
-
});
|
|
103
|
-
});
|
package/src/lib/headings.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export interface Heading {
|
|
2
|
-
id: string;
|
|
3
|
-
text: string;
|
|
4
|
-
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function slugify(text: string): string {
|
|
8
|
-
return text
|
|
9
|
-
.toLowerCase()
|
|
10
|
-
.trim()
|
|
11
|
-
.replace(/[^\w\s-]/g, "")
|
|
12
|
-
.replace(/\s+/g, "-")
|
|
13
|
-
.replace(/-+/g, "-");
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function stripCodeBlocks(content: string): string {
|
|
17
|
-
let result = content.replace(/^(`{3,}|~{3,}).*$[\s\S]*?^\1\s*$/gm, "");
|
|
18
|
-
result = result.replace(/(?:^|\n\n)((?:(?:[ ]{4}|\t).+\n?)+)/g, "\n\n");
|
|
19
|
-
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function parseMarkdownHeadings(content: string): Heading[] {
|
|
24
|
-
const headings: Heading[] = [];
|
|
25
|
-
const seenIds = new Map<string, number>();
|
|
26
|
-
const contentWithoutCode = stripCodeBlocks(content);
|
|
27
|
-
|
|
28
|
-
const regex = /^(#{1,6})\s+(.+)$/gm;
|
|
29
|
-
let match = regex.exec(contentWithoutCode);
|
|
30
|
-
|
|
31
|
-
while (match !== null) {
|
|
32
|
-
const level = match[1].length as 1 | 2 | 3 | 4 | 5 | 6;
|
|
33
|
-
const text = match[2].trim();
|
|
34
|
-
const baseId = slugify(text);
|
|
35
|
-
const count = seenIds.get(baseId) ?? 0;
|
|
36
|
-
const id = count > 0 ? `${baseId}-${count}` : baseId;
|
|
37
|
-
seenIds.set(baseId, count + 1);
|
|
38
|
-
|
|
39
|
-
headings.push({ id, text, level });
|
|
40
|
-
match = regex.exec(contentWithoutCode);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return headings;
|
|
44
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { findTextPosition } from "./resolver";
|
|
3
|
-
|
|
4
|
-
describe("findTextPosition", () => {
|
|
5
|
-
it("finds single occurrence", () => {
|
|
6
|
-
const result = findTextPosition("hello world", "world");
|
|
7
|
-
expect(result).toEqual({ start: 6, end: 11 });
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("finds text at start", () => {
|
|
11
|
-
const result = findTextPosition("hello world", "hello");
|
|
12
|
-
expect(result).toEqual({ start: 0, end: 5 });
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("returns null for no match", () => {
|
|
16
|
-
expect(findTextPosition("hello", "xyz")).toBeUndefined();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("returns null for empty selectedText", () => {
|
|
20
|
-
expect(findTextPosition("hello world", "")).toBeUndefined();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("returns null for empty textContent", () => {
|
|
24
|
-
expect(findTextPosition("", "hello")).toBeUndefined();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("returns null for both empty", () => {
|
|
28
|
-
expect(findTextPosition("", "")).toBeUndefined();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe("multiple occurrences", () => {
|
|
32
|
-
it("finds closest occurrence to hint (before)", () => {
|
|
33
|
-
const text = "the cat and the dog and the bird";
|
|
34
|
-
|
|
35
|
-
const result = findTextPosition(text, "the", 10);
|
|
36
|
-
expect(result?.start).toBe(12);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("finds closest occurrence to hint (after)", () => {
|
|
40
|
-
const text = "the cat and the dog and the bird";
|
|
41
|
-
|
|
42
|
-
const result = findTextPosition(text, "the", 30);
|
|
43
|
-
expect(result?.start).toBe(24);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("finds first occurrence when hint is 0", () => {
|
|
47
|
-
const text = "the cat and the dog and the bird";
|
|
48
|
-
const result = findTextPosition(text, "the", 0);
|
|
49
|
-
expect(result?.start).toBe(0);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("finds first occurrence when no hint provided", () => {
|
|
53
|
-
const text = "the cat and the dog and the bird";
|
|
54
|
-
const result = findTextPosition(text, "the");
|
|
55
|
-
expect(result?.start).toBe(0);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("handles exact match at hint position", () => {
|
|
59
|
-
const text = "abc abc abc";
|
|
60
|
-
const result = findTextPosition(text, "abc", 4);
|
|
61
|
-
expect(result?.start).toBe(4);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe("edge cases", () => {
|
|
66
|
-
it("handles single character search", () => {
|
|
67
|
-
const result = findTextPosition("hello", "l");
|
|
68
|
-
expect(result).toEqual({ start: 2, end: 3 });
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("handles overlapping matches (returns first)", () => {
|
|
72
|
-
const result = findTextPosition("aaa", "aa");
|
|
73
|
-
expect(result).toEqual({ start: 0, end: 2 });
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("handles multiline content", () => {
|
|
77
|
-
const text = "line one\nline two\nline three";
|
|
78
|
-
const result = findTextPosition(text, "two");
|
|
79
|
-
expect(result).toEqual({ start: 14, end: 17 });
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("handles unicode", () => {
|
|
83
|
-
const text = "こんにちは世界";
|
|
84
|
-
const result = findTextPosition(text, "世界");
|
|
85
|
-
expect(result).toEqual({ start: 5, end: 7 });
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("is case sensitive", () => {
|
|
89
|
-
const result = findTextPosition("Hello World", "hello");
|
|
90
|
-
expect(result).toBeUndefined();
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
});
|