@peaske7/readit 0.3.0-rc.0 → 0.3.0-rc.2
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/README.md +3 -3
- 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-DQnkwSaB.js +36 -0
- package/dist/assets/array-Bjz-wYpJ.js +1 -0
- package/dist/assets/blockDiagram-DXYQGD6D-UB6_S1lm.js +132 -0
- package/dist/assets/c4Diagram-AHTNJAMY-sn3k2GND.js +10 -0
- package/dist/assets/channel-D9wPw2fQ.js +1 -0
- package/dist/assets/chunk-2KRD3SAO-DaFfaCGO.js +1 -0
- package/dist/assets/chunk-336JU56O-C8siO5Of.js +2 -0
- package/dist/assets/chunk-426QAEUC-BB478m3j.js +1 -0
- package/dist/assets/chunk-4BX2VUAB-DRuTD7x5.js +1 -0
- package/dist/assets/chunk-4TB4RGXK-_l6jvVAY.js +206 -0
- package/dist/assets/chunk-55IACEB6-BExiaAoD.js +1 -0
- package/dist/assets/chunk-5FUZZQ4R-HOSFTxuG.js +62 -0
- package/dist/assets/chunk-5PVQY5BW-BRVNNRAX.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-CSvKh9DT.js +1 -0
- package/dist/assets/chunk-ENJZ2VHE-QApb5cYr.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-agBjBxsW.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-HGUtT2Q9.js +231 -0
- package/dist/assets/chunk-QZHKN3VN-8Lcg9gti.js +1 -0
- package/dist/assets/chunk-U2HBQHQK-BFYYQeuC.js +70 -0
- package/dist/assets/chunk-X2U36JSP-p8ehTP6s.js +1 -0
- package/dist/assets/chunk-XPW4576I-Bqbompq4.js +32 -0
- package/dist/assets/chunk-YZCP3GAM-HIMez9pG.js +1 -0
- package/dist/assets/chunk-ZZ45TVLE-DRIE_0bu.js +1 -0
- package/dist/assets/classDiagram-6PBFFD2Q-BawhEeUl.js +1 -0
- package/dist/assets/classDiagram-v2-HSJHXN6E-CLNjgH9n.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-Dxbob2Lr.js +1 -0
- package/dist/assets/dagre-KV5264BT-BuvpNxMw.js +4 -0
- package/dist/assets/defaultLocale-BwmRmqJp.js +1 -0
- package/dist/assets/diagram-5BDNPKRD-DQLsxwwt.js +10 -0
- package/dist/assets/diagram-G4DWMVQ6-Jv9Eefw4.js +24 -0
- package/dist/assets/diagram-MMDJMWI5-D-0YgNhU.js +43 -0
- package/dist/assets/diagram-TYMM5635-BHwO7zQG.js +24 -0
- package/dist/assets/dist-BNz65Ibc.js +1 -0
- package/dist/assets/erDiagram-SMLLAGMA-BjZGGBJz.js +85 -0
- package/dist/assets/flowDiagram-DWJPFMVM-CFbFUm_m.js +162 -0
- package/dist/assets/ganttDiagram-T4ZO3ILL-CXk4TcBi.js +292 -0
- package/dist/assets/gitGraph-7Q5UKJZL-BGFRt2qs.js +1 -0
- package/dist/assets/gitGraphDiagram-UUTBAWPF-C8yZOxjo.js +106 -0
- package/dist/assets/graphlib-DGcD9J2L.js +1 -0
- package/dist/assets/index-D-m0LiFI.js +14 -0
- package/dist/assets/index-DANHO6J0.css +2 -0
- package/dist/assets/info-OMHHGYJF-DI6-Z9vh.js +1 -0
- package/dist/assets/infoDiagram-42DDH7IO-p-PXDra2.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-BrIoEvtb.js +70 -0
- package/dist/assets/journeyDiagram-VCZTEJTY-aZpvKa9g.js +139 -0
- package/dist/assets/kanban-definition-6JOO6SKY-CoOAY9ji.js +89 -0
- package/dist/assets/katex-5SGEXwpi.js +261 -0
- package/dist/assets/line-4MF1lR4d.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-DREsY2u4.js +4 -0
- package/dist/assets/mermaid.core-8ysLpTJi.js +11 -0
- package/dist/assets/mindmap-definition-QFDTVHPH-CsqUJCMn.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-k0Br4NDS.js +30 -0
- package/dist/assets/quadrantDiagram-34T5L4WZ-Be9oCSza.js +7 -0
- package/dist/assets/radar-PYXPWWZC-CsdZBH3M.js +1 -0
- package/dist/assets/requirementDiagram-MS252O5E-8ECT7dEs.js +84 -0
- package/dist/assets/rough.esm-BoTisKeL.js +1 -0
- package/dist/assets/sankeyDiagram-XADWPNL6-CoKpeJJ0.js +10 -0
- package/dist/assets/sequenceDiagram-FGHM5R23-BTT2fFxG.js +157 -0
- package/dist/assets/src-CrmkjRpa.js +1 -0
- package/dist/assets/stateDiagram-FHFEXIEX-CIF47NYe.js +1 -0
- package/dist/assets/stateDiagram-v2-QKLJ7IA2-Cy1rmPfG.js +1 -0
- package/dist/assets/timeline-definition-GMOUNBTQ-Bes4B58n.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-3wx2huKk.js +34 -0
- package/dist/assets/wardley-RL74JXVD-AgyXyBN5.js +1 -0
- package/dist/assets/wardleyDiagram-NUSXRM2D-DzViT1Yx.js +20 -0
- package/dist/assets/xychartDiagram-5P7HB3ND-BO_dbU0r.js +7 -0
- package/{index.html → dist/index.html} +2 -1
- package/dist/index.js +2625 -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,694 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import type { CommentFile } from "../schema";
|
|
3
|
-
import { COMMENT_FILE_LARGE } from "./__fixtures__/bench-data";
|
|
4
|
-
|
|
5
|
-
vi.mock("node:os", () => ({
|
|
6
|
-
homedir: () => "/home/testuser",
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
computeHash,
|
|
11
|
-
createComment,
|
|
12
|
-
getCommentPath,
|
|
13
|
-
getLineHint,
|
|
14
|
-
getLineNumber,
|
|
15
|
-
parseCommentFile,
|
|
16
|
-
serializeComments,
|
|
17
|
-
truncateSelection,
|
|
18
|
-
} = await import("./comment-storage");
|
|
19
|
-
|
|
20
|
-
describe("getCommentPath", () => {
|
|
21
|
-
it("handles absolute path", () => {
|
|
22
|
-
const result = getCommentPath("/home/user/doc.md");
|
|
23
|
-
expect(result).toBe(
|
|
24
|
-
"/home/testuser/.readit/comments/home/user/doc.comments.md",
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("handles deep nesting", () => {
|
|
29
|
-
const result = getCommentPath("/a/b/c/d/e/f.md");
|
|
30
|
-
expect(result).toBe(
|
|
31
|
-
"/home/testuser/.readit/comments/a/b/c/d/e/f.comments.md",
|
|
32
|
-
);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("handles root path", () => {
|
|
36
|
-
const result = getCommentPath("/file.md");
|
|
37
|
-
expect(result).toBe("/home/testuser/.readit/comments/file.comments.md");
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("handles files with spaces in path", () => {
|
|
41
|
-
const result = getCommentPath("/path/to/my file.md");
|
|
42
|
-
expect(result).toBe(
|
|
43
|
-
"/home/testuser/.readit/comments/path/to/my file.comments.md",
|
|
44
|
-
);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
describe("computeHash", () => {
|
|
49
|
-
it("returns 16 character hash", () => {
|
|
50
|
-
const hash = computeHash("test content");
|
|
51
|
-
expect(hash).toHaveLength(16);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("returns consistent hash for same content", () => {
|
|
55
|
-
const hash1 = computeHash("hello world");
|
|
56
|
-
const hash2 = computeHash("hello world");
|
|
57
|
-
expect(hash1).toBe(hash2);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("returns different hash for different content", () => {
|
|
61
|
-
const hash1 = computeHash("hello");
|
|
62
|
-
const hash2 = computeHash("world");
|
|
63
|
-
expect(hash1).not.toBe(hash2);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("handles empty string", () => {
|
|
67
|
-
const hash = computeHash("");
|
|
68
|
-
expect(hash).toHaveLength(16);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("handles unicode content", () => {
|
|
72
|
-
const hash = computeHash("こんにちは");
|
|
73
|
-
expect(hash).toHaveLength(16);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe("getLineNumber", () => {
|
|
78
|
-
it("returns 1 for first line", () => {
|
|
79
|
-
expect(getLineNumber("abc\ndef", 0)).toBe(1);
|
|
80
|
-
expect(getLineNumber("abc\ndef", 2)).toBe(1);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("returns 2 for second line", () => {
|
|
84
|
-
expect(getLineNumber("abc\ndef", 4)).toBe(2);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("returns 1 for end of first line", () => {
|
|
88
|
-
expect(getLineNumber("abc\ndef", 3)).toBe(1);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("returns 1 for empty content", () => {
|
|
92
|
-
expect(getLineNumber("", 0)).toBe(1);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("handles many lines", () => {
|
|
96
|
-
const content = Array(100).fill("line").join("\n");
|
|
97
|
-
expect(getLineNumber(content, 0)).toBe(1); // Start of line 1
|
|
98
|
-
expect(getLineNumber(content, 250)).toBe(51); // After 50 newlines = line 51
|
|
99
|
-
expect(getLineNumber(content, 495)).toBe(100); // Start of line 100
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("handles offset beyond content length", () => {
|
|
103
|
-
const line = getLineNumber("abc\ndef", 1000);
|
|
104
|
-
expect(line).toBe(2);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
describe("getLineHint", () => {
|
|
109
|
-
it("returns single line hint for same line", () => {
|
|
110
|
-
const content = "line one\nline two\nline three";
|
|
111
|
-
expect(getLineHint(content, 0, 4)).toBe("L1");
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("returns range hint for multiple lines", () => {
|
|
115
|
-
const content = "line one\nline two\nline three";
|
|
116
|
-
expect(getLineHint(content, 0, 20)).toBe("L1-L3");
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
describe("parseCommentFile", () => {
|
|
121
|
-
it("returns empty result for empty file", () => {
|
|
122
|
-
const result = parseCommentFile("");
|
|
123
|
-
expect(result.comments).toEqual([]);
|
|
124
|
-
expect(result.source).toBe("");
|
|
125
|
-
expect(result.hash).toBe("");
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("parses front matter only", () => {
|
|
129
|
-
const content = `---
|
|
130
|
-
source: /path/to/doc.md
|
|
131
|
-
hash: abc123def456
|
|
132
|
-
version: 1
|
|
133
|
-
---`;
|
|
134
|
-
const result = parseCommentFile(content);
|
|
135
|
-
expect(result.source).toBe("/path/to/doc.md");
|
|
136
|
-
expect(result.hash).toBe("abc123def456");
|
|
137
|
-
expect(result.version).toBe(1);
|
|
138
|
-
expect(result.comments).toEqual([]);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("parses single comment", () => {
|
|
142
|
-
const content = `---
|
|
143
|
-
source: /path/to/doc.md
|
|
144
|
-
hash: abc123def456
|
|
145
|
-
version: 1
|
|
146
|
-
---
|
|
147
|
-
|
|
148
|
-
<!-- c:12345678|L42|2024-12-24T10:30:00Z -->
|
|
149
|
-
> selected text here
|
|
150
|
-
|
|
151
|
-
This is my comment.
|
|
152
|
-
|
|
153
|
-
---
|
|
154
|
-
`;
|
|
155
|
-
const result = parseCommentFile(content);
|
|
156
|
-
expect(result.comments).toHaveLength(1);
|
|
157
|
-
expect(result.comments[0].id).toBe("12345678");
|
|
158
|
-
expect(result.comments[0].selectedText).toBe("selected text here");
|
|
159
|
-
expect(result.comments[0].comment).toBe("This is my comment.");
|
|
160
|
-
expect(result.comments[0].lineHint).toBe("L42");
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it("parses multiple comments", () => {
|
|
164
|
-
const content = `---
|
|
165
|
-
source: /path/to/doc.md
|
|
166
|
-
hash: abc123def456
|
|
167
|
-
version: 1
|
|
168
|
-
---
|
|
169
|
-
|
|
170
|
-
<!-- c:11111111|L10|2024-12-24T10:00:00Z -->
|
|
171
|
-
> first selection
|
|
172
|
-
|
|
173
|
-
First comment.
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
<!-- c:22222222|L20|2024-12-24T11:00:00Z -->
|
|
178
|
-
> second selection
|
|
179
|
-
|
|
180
|
-
Second comment.
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
<!-- c:33333333|L30|2024-12-24T12:00:00Z -->
|
|
185
|
-
> third selection
|
|
186
|
-
|
|
187
|
-
Third comment.
|
|
188
|
-
|
|
189
|
-
---
|
|
190
|
-
`;
|
|
191
|
-
const result = parseCommentFile(content);
|
|
192
|
-
expect(result.comments).toHaveLength(3);
|
|
193
|
-
expect(result.comments[0].id).toBe("11111111");
|
|
194
|
-
expect(result.comments[1].id).toBe("22222222");
|
|
195
|
-
expect(result.comments[2].id).toBe("33333333");
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it("parses multiline blockquote", () => {
|
|
199
|
-
const content = `---
|
|
200
|
-
source: /test.md
|
|
201
|
-
hash: abc
|
|
202
|
-
version: 1
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
<!-- c:12345678|L42|2024-12-24T10:30:00Z -->
|
|
206
|
-
> line one
|
|
207
|
-
> line two
|
|
208
|
-
> line three
|
|
209
|
-
|
|
210
|
-
Comment here.
|
|
211
|
-
|
|
212
|
-
---
|
|
213
|
-
`;
|
|
214
|
-
const result = parseCommentFile(content);
|
|
215
|
-
expect(result.comments[0].selectedText).toBe(
|
|
216
|
-
"line one\nline two\nline three",
|
|
217
|
-
);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it("skips blocks without metadata", () => {
|
|
221
|
-
const content = `---
|
|
222
|
-
source: /test.md
|
|
223
|
-
hash: abc
|
|
224
|
-
version: 1
|
|
225
|
-
---
|
|
226
|
-
|
|
227
|
-
> Just a blockquote without metadata
|
|
228
|
-
|
|
229
|
-
Some text.
|
|
230
|
-
|
|
231
|
-
---
|
|
232
|
-
|
|
233
|
-
<!-- c:12345678|L42|2024-12-24T10:30:00Z -->
|
|
234
|
-
> valid selection
|
|
235
|
-
|
|
236
|
-
Valid comment.
|
|
237
|
-
|
|
238
|
-
---
|
|
239
|
-
`;
|
|
240
|
-
const result = parseCommentFile(content);
|
|
241
|
-
expect(result.comments).toHaveLength(1);
|
|
242
|
-
expect(result.comments[0].id).toBe("12345678");
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it("handles malformed metadata gracefully", () => {
|
|
246
|
-
const content = `---
|
|
247
|
-
source: /test.md
|
|
248
|
-
hash: abc
|
|
249
|
-
version: 1
|
|
250
|
-
---
|
|
251
|
-
|
|
252
|
-
<!-- c:bad-format -->
|
|
253
|
-
> some text
|
|
254
|
-
|
|
255
|
-
Comment.
|
|
256
|
-
|
|
257
|
-
---
|
|
258
|
-
`;
|
|
259
|
-
const result = parseCommentFile(content);
|
|
260
|
-
expect(result.comments).toHaveLength(0);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
it("parses anchorPrefix when present", () => {
|
|
264
|
-
const content = `---
|
|
265
|
-
source: /test.md
|
|
266
|
-
hash: abc
|
|
267
|
-
version: 1
|
|
268
|
-
---
|
|
269
|
-
|
|
270
|
-
<!-- c:12345678|L42|2024-12-24T10:30:00Z -->
|
|
271
|
-
<!-- anchor:first 200 chars of original text -->
|
|
272
|
-
> truncated display text...
|
|
273
|
-
|
|
274
|
-
Comment here.
|
|
275
|
-
|
|
276
|
-
---
|
|
277
|
-
`;
|
|
278
|
-
const result = parseCommentFile(content);
|
|
279
|
-
expect(result.comments).toHaveLength(1);
|
|
280
|
-
expect(result.comments[0].anchorPrefix).toBe(
|
|
281
|
-
"first 200 chars of original text",
|
|
282
|
-
);
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
it("parses comment without anchorPrefix", () => {
|
|
286
|
-
const content = `---
|
|
287
|
-
source: /test.md
|
|
288
|
-
hash: abc
|
|
289
|
-
version: 1
|
|
290
|
-
---
|
|
291
|
-
|
|
292
|
-
<!-- c:12345678|L42|2024-12-24T10:30:00Z -->
|
|
293
|
-
> short selected text
|
|
294
|
-
|
|
295
|
-
Comment here.
|
|
296
|
-
|
|
297
|
-
---
|
|
298
|
-
`;
|
|
299
|
-
const result = parseCommentFile(content);
|
|
300
|
-
expect(result.comments).toHaveLength(1);
|
|
301
|
-
expect(result.comments[0].anchorPrefix).toBeUndefined();
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
describe("serializeComments", () => {
|
|
306
|
-
it("serializes empty array to front matter only", () => {
|
|
307
|
-
const file: CommentFile = {
|
|
308
|
-
source: "/path/to/doc.md",
|
|
309
|
-
hash: "abc123def456",
|
|
310
|
-
version: 1,
|
|
311
|
-
comments: [],
|
|
312
|
-
};
|
|
313
|
-
const result = serializeComments(file);
|
|
314
|
-
expect(result).toContain("source: /path/to/doc.md");
|
|
315
|
-
expect(result).toContain("hash: abc123def456");
|
|
316
|
-
expect(result).toContain("version: 1");
|
|
317
|
-
expect(result).not.toContain("<!-- c:");
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
it("serializes single comment", () => {
|
|
321
|
-
const file: CommentFile = {
|
|
322
|
-
source: "/test.md",
|
|
323
|
-
hash: "abc",
|
|
324
|
-
version: 1,
|
|
325
|
-
comments: [
|
|
326
|
-
{
|
|
327
|
-
id: "12345678",
|
|
328
|
-
selectedText: "selected text",
|
|
329
|
-
comment: "My comment",
|
|
330
|
-
lineHint: "L42",
|
|
331
|
-
createdAt: "2026-05-09T00:00:00Z",
|
|
332
|
-
startOffset: 100,
|
|
333
|
-
endOffset: 113,
|
|
334
|
-
},
|
|
335
|
-
],
|
|
336
|
-
};
|
|
337
|
-
const result = serializeComments(file);
|
|
338
|
-
expect(result).toContain("<!-- c:12345678|L42|2026-05-09T00:00:00Z -->");
|
|
339
|
-
expect(result).toContain("> selected text");
|
|
340
|
-
expect(result).toContain("My comment");
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
it("serializes multiline selected text", () => {
|
|
344
|
-
const file: CommentFile = {
|
|
345
|
-
source: "/test.md",
|
|
346
|
-
hash: "abc",
|
|
347
|
-
version: 1,
|
|
348
|
-
comments: [
|
|
349
|
-
{
|
|
350
|
-
id: "12345678",
|
|
351
|
-
selectedText: "line one\nline two",
|
|
352
|
-
comment: "Comment",
|
|
353
|
-
lineHint: "L42-L43",
|
|
354
|
-
startOffset: 100,
|
|
355
|
-
endOffset: 120,
|
|
356
|
-
},
|
|
357
|
-
],
|
|
358
|
-
};
|
|
359
|
-
const result = serializeComments(file);
|
|
360
|
-
expect(result).toContain("> line one");
|
|
361
|
-
expect(result).toContain("> line two");
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
it("serializes anchorPrefix when present", () => {
|
|
365
|
-
const file: CommentFile = {
|
|
366
|
-
source: "/test.md",
|
|
367
|
-
hash: "abc",
|
|
368
|
-
version: 1,
|
|
369
|
-
comments: [
|
|
370
|
-
{
|
|
371
|
-
id: "12345678",
|
|
372
|
-
selectedText: "truncated text...",
|
|
373
|
-
comment: "Comment",
|
|
374
|
-
lineHint: "L42",
|
|
375
|
-
startOffset: 100,
|
|
376
|
-
endOffset: 500,
|
|
377
|
-
anchorPrefix: "first 200 chars of original text",
|
|
378
|
-
},
|
|
379
|
-
],
|
|
380
|
-
};
|
|
381
|
-
const result = serializeComments(file);
|
|
382
|
-
expect(result).toContain(
|
|
383
|
-
"<!-- anchor:first 200 chars of original text -->",
|
|
384
|
-
);
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
it("does not serialize anchor when anchorPrefix is undefined", () => {
|
|
388
|
-
const file: CommentFile = {
|
|
389
|
-
source: "/test.md",
|
|
390
|
-
hash: "abc",
|
|
391
|
-
version: 1,
|
|
392
|
-
comments: [
|
|
393
|
-
{
|
|
394
|
-
id: "12345678",
|
|
395
|
-
selectedText: "short text",
|
|
396
|
-
comment: "Comment",
|
|
397
|
-
lineHint: "L42",
|
|
398
|
-
startOffset: 100,
|
|
399
|
-
endOffset: 110,
|
|
400
|
-
},
|
|
401
|
-
],
|
|
402
|
-
};
|
|
403
|
-
const result = serializeComments(file);
|
|
404
|
-
expect(result).not.toContain("<!-- anchor:");
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
it("roundtrip: parse(serialize(file)) equals original", () => {
|
|
408
|
-
const original: CommentFile = {
|
|
409
|
-
source: "/test.md",
|
|
410
|
-
hash: "abc123def456",
|
|
411
|
-
version: 1,
|
|
412
|
-
comments: [
|
|
413
|
-
{
|
|
414
|
-
id: "12345678",
|
|
415
|
-
selectedText: "selected text",
|
|
416
|
-
comment: "My comment",
|
|
417
|
-
lineHint: "L42",
|
|
418
|
-
startOffset: 100,
|
|
419
|
-
endOffset: 113,
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
id: "87654321",
|
|
423
|
-
selectedText: "another\nmultiline\nselection",
|
|
424
|
-
comment: "Another comment with\n\nmultiple paragraphs.",
|
|
425
|
-
lineHint: "L50-L52",
|
|
426
|
-
startOffset: 200,
|
|
427
|
-
endOffset: 230,
|
|
428
|
-
},
|
|
429
|
-
],
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
const serialized = serializeComments(original);
|
|
433
|
-
const parsed = parseCommentFile(serialized);
|
|
434
|
-
|
|
435
|
-
expect(parsed.source).toBe(original.source);
|
|
436
|
-
expect(parsed.hash).toBe(original.hash);
|
|
437
|
-
expect(parsed.version).toBe(original.version);
|
|
438
|
-
expect(parsed.comments).toHaveLength(original.comments.length);
|
|
439
|
-
|
|
440
|
-
for (let i = 0; i < original.comments.length; i++) {
|
|
441
|
-
expect(parsed.comments[i].id).toBe(original.comments[i].id);
|
|
442
|
-
expect(parsed.comments[i].selectedText).toBe(
|
|
443
|
-
original.comments[i].selectedText,
|
|
444
|
-
);
|
|
445
|
-
expect(parsed.comments[i].lineHint).toBe(original.comments[i].lineHint);
|
|
446
|
-
}
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
it("roundtrip: survives a markdown horizontal rule inside a comment body", () => {
|
|
450
|
-
const original: CommentFile = {
|
|
451
|
-
source: "/test.md",
|
|
452
|
-
hash: "abc123",
|
|
453
|
-
version: 1,
|
|
454
|
-
comments: [
|
|
455
|
-
{
|
|
456
|
-
id: "aaaaaaaa",
|
|
457
|
-
selectedText: "first selected",
|
|
458
|
-
comment: "before\n\n---\n\nafter",
|
|
459
|
-
lineHint: "L1",
|
|
460
|
-
startOffset: 0,
|
|
461
|
-
endOffset: 14,
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
id: "bbbbbbbb",
|
|
465
|
-
selectedText: "second selected",
|
|
466
|
-
comment: "second body",
|
|
467
|
-
lineHint: "L5",
|
|
468
|
-
startOffset: 50,
|
|
469
|
-
endOffset: 65,
|
|
470
|
-
},
|
|
471
|
-
],
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
const serialized = serializeComments(original);
|
|
475
|
-
const parsed = parseCommentFile(serialized);
|
|
476
|
-
|
|
477
|
-
expect(parsed.comments).toHaveLength(2);
|
|
478
|
-
expect(parsed.comments[0].id).toBe("aaaaaaaa");
|
|
479
|
-
expect(parsed.comments[1].id).toBe("bbbbbbbb");
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
it("roundtrip: preserves anchorPrefix through serialize/parse", () => {
|
|
483
|
-
const original: CommentFile = {
|
|
484
|
-
source: "/test.md",
|
|
485
|
-
hash: "abc123",
|
|
486
|
-
version: 1,
|
|
487
|
-
comments: [
|
|
488
|
-
{
|
|
489
|
-
id: "12345678",
|
|
490
|
-
selectedText: "truncated text\n...\nend of text",
|
|
491
|
-
comment: "Comment on long selection",
|
|
492
|
-
lineHint: "L42",
|
|
493
|
-
startOffset: 100,
|
|
494
|
-
endOffset: 2000,
|
|
495
|
-
anchorPrefix: "first 200 chars of the original long text",
|
|
496
|
-
},
|
|
497
|
-
],
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
const serialized = serializeComments(original);
|
|
501
|
-
const parsed = parseCommentFile(serialized);
|
|
502
|
-
|
|
503
|
-
expect(parsed.comments[0].anchorPrefix).toBe(
|
|
504
|
-
original.comments[0].anchorPrefix,
|
|
505
|
-
);
|
|
506
|
-
});
|
|
507
|
-
});
|
|
508
|
-
|
|
509
|
-
describe("createComment", () => {
|
|
510
|
-
it("creates comment with generated ID", () => {
|
|
511
|
-
const comment = createComment(
|
|
512
|
-
"text",
|
|
513
|
-
"comment",
|
|
514
|
-
10,
|
|
515
|
-
20,
|
|
516
|
-
"some content\nmore lines",
|
|
517
|
-
);
|
|
518
|
-
expect(comment.id).toHaveLength(8);
|
|
519
|
-
expect(comment.selectedText).toBe("text");
|
|
520
|
-
expect(comment.comment).toBe("comment");
|
|
521
|
-
expect(comment.startOffset).toBe(10);
|
|
522
|
-
expect(comment.endOffset).toBe(20);
|
|
523
|
-
});
|
|
524
|
-
|
|
525
|
-
it("generates line hint based on offsets", () => {
|
|
526
|
-
const content = "line one\nline two\nline three";
|
|
527
|
-
const comment = createComment("two", "comment", 14, 17, content);
|
|
528
|
-
expect(comment.lineHint).toBe("L2");
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
it("truncates very long selections", () => {
|
|
532
|
-
const longText = "a".repeat(2000);
|
|
533
|
-
const comment = createComment(longText, "comment", 0, 2000, longText);
|
|
534
|
-
expect(comment.selectedText.length).toBeLessThan(1010);
|
|
535
|
-
expect(comment.selectedText).toContain("...");
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
it("does not set anchorPrefix for short selections", () => {
|
|
539
|
-
const comment = createComment("short text", "comment", 0, 10, "short text");
|
|
540
|
-
expect(comment.anchorPrefix).toBeUndefined();
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
it("sets anchorPrefix for truncated selections", () => {
|
|
544
|
-
const longText = "x".repeat(2000);
|
|
545
|
-
const comment = createComment(longText, "comment", 0, 2000, longText);
|
|
546
|
-
expect(comment.anchorPrefix).toBeDefined();
|
|
547
|
-
expect(comment.anchorPrefix).toHaveLength(200);
|
|
548
|
-
expect(comment.anchorPrefix).toBe("x".repeat(200));
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
it("anchorPrefix preserves first 200 chars of original text", () => {
|
|
552
|
-
const prefix = "PREFIX_";
|
|
553
|
-
const middle = "m".repeat(1500);
|
|
554
|
-
const suffix = "_SUFFIX";
|
|
555
|
-
const longText = prefix + middle + suffix;
|
|
556
|
-
const comment = createComment(
|
|
557
|
-
longText,
|
|
558
|
-
"comment",
|
|
559
|
-
0,
|
|
560
|
-
longText.length,
|
|
561
|
-
longText,
|
|
562
|
-
);
|
|
563
|
-
expect(comment.anchorPrefix?.startsWith("PREFIX_")).toBe(true);
|
|
564
|
-
expect(comment.anchorPrefix).toHaveLength(200);
|
|
565
|
-
});
|
|
566
|
-
});
|
|
567
|
-
|
|
568
|
-
describe("truncateSelection", () => {
|
|
569
|
-
it("returns short text unchanged", () => {
|
|
570
|
-
expect(truncateSelection("short text")).toBe("short text");
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
it("returns text at exactly max length unchanged", () => {
|
|
574
|
-
const exactLength = "a".repeat(1000);
|
|
575
|
-
expect(truncateSelection(exactLength)).toBe(exactLength);
|
|
576
|
-
});
|
|
577
|
-
|
|
578
|
-
it("truncates text over 1000 chars", () => {
|
|
579
|
-
const longText = "a".repeat(2000);
|
|
580
|
-
const result = truncateSelection(longText);
|
|
581
|
-
expect(result.length).toBeLessThan(1010);
|
|
582
|
-
expect(result).toContain("\n...\n");
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
it("preserves start and end of text", () => {
|
|
586
|
-
const start = "START".repeat(100);
|
|
587
|
-
const end = "END".repeat(100);
|
|
588
|
-
const longText = start + "middle".repeat(100) + end;
|
|
589
|
-
const result = truncateSelection(longText);
|
|
590
|
-
expect(result.startsWith("START")).toBe(true);
|
|
591
|
-
expect(result.endsWith("END")).toBe(true);
|
|
592
|
-
});
|
|
593
|
-
});
|
|
594
|
-
|
|
595
|
-
describe("parseCommentFile cross-runtime format", () => {
|
|
596
|
-
it("parses 2-field marker (legacy TS-written files)", () => {
|
|
597
|
-
const content = `---
|
|
598
|
-
source: /test.md
|
|
599
|
-
hash: abc
|
|
600
|
-
version: 1
|
|
601
|
-
---
|
|
602
|
-
|
|
603
|
-
<!-- c:abcd1234|L5 -->
|
|
604
|
-
> selected text
|
|
605
|
-
some comment
|
|
606
|
-
|
|
607
|
-
---
|
|
608
|
-
`;
|
|
609
|
-
const parsed = parseCommentFile(content);
|
|
610
|
-
expect(parsed.comments).toHaveLength(1);
|
|
611
|
-
expect(parsed.comments[0].id).toBe("abcd1234");
|
|
612
|
-
expect(parsed.comments[0].lineHint).toBe("L5");
|
|
613
|
-
expect(parsed.comments[0].createdAt).toBeUndefined();
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
it("parses 3-field marker (Go-written files)", () => {
|
|
617
|
-
const content = `---
|
|
618
|
-
source: /test.md
|
|
619
|
-
hash: abc
|
|
620
|
-
version: 1
|
|
621
|
-
---
|
|
622
|
-
|
|
623
|
-
<!-- c:abcd1234|L5|2026-05-09T12:34:56.789Z -->
|
|
624
|
-
> selected text
|
|
625
|
-
some comment
|
|
626
|
-
|
|
627
|
-
---
|
|
628
|
-
`;
|
|
629
|
-
const parsed = parseCommentFile(content);
|
|
630
|
-
expect(parsed.comments).toHaveLength(1);
|
|
631
|
-
expect(parsed.comments[0].createdAt).toBe("2026-05-09T12:34:56.789Z");
|
|
632
|
-
});
|
|
633
|
-
|
|
634
|
-
it("serializeComments writes 3-field marker", () => {
|
|
635
|
-
const file: CommentFile = {
|
|
636
|
-
source: "/test.md",
|
|
637
|
-
hash: "abc",
|
|
638
|
-
version: 1,
|
|
639
|
-
comments: [
|
|
640
|
-
{
|
|
641
|
-
id: "abcd1234",
|
|
642
|
-
selectedText: "selected",
|
|
643
|
-
comment: "body",
|
|
644
|
-
lineHint: "L1",
|
|
645
|
-
createdAt: "2026-05-09T00:00:00Z",
|
|
646
|
-
startOffset: 0,
|
|
647
|
-
endOffset: 8,
|
|
648
|
-
},
|
|
649
|
-
],
|
|
650
|
-
};
|
|
651
|
-
const serialized = serializeComments(file);
|
|
652
|
-
expect(serialized).toContain("<!-- c:abcd1234|L1|2026-05-09T00:00:00Z -->");
|
|
653
|
-
});
|
|
654
|
-
});
|
|
655
|
-
|
|
656
|
-
describe("parseCommentFile version check", () => {
|
|
657
|
-
it("accepts current version", () => {
|
|
658
|
-
const content = `---
|
|
659
|
-
source: /test.md
|
|
660
|
-
hash: abc
|
|
661
|
-
version: 1
|
|
662
|
-
---`;
|
|
663
|
-
expect(() => parseCommentFile(content)).not.toThrow();
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
it("throws on unsupported future version", () => {
|
|
667
|
-
const content = `---
|
|
668
|
-
source: /test.md
|
|
669
|
-
hash: abc
|
|
670
|
-
version: 99
|
|
671
|
-
---`;
|
|
672
|
-
expect(() => parseCommentFile(content)).toThrow(/requires readit v99/);
|
|
673
|
-
});
|
|
674
|
-
|
|
675
|
-
it("includes current version in error message", () => {
|
|
676
|
-
const content = `---
|
|
677
|
-
source: /test.md
|
|
678
|
-
hash: abc
|
|
679
|
-
version: 99
|
|
680
|
-
---`;
|
|
681
|
-
expect(() => parseCommentFile(content)).toThrow(/supports format v1/);
|
|
682
|
-
});
|
|
683
|
-
});
|
|
684
|
-
|
|
685
|
-
describe("performance", () => {
|
|
686
|
-
it("parseCommentFile with 50 comments completes within 50ms (100 iterations)", () => {
|
|
687
|
-
const start = performance.now();
|
|
688
|
-
for (let i = 0; i < 100; i++) {
|
|
689
|
-
parseCommentFile(COMMENT_FILE_LARGE);
|
|
690
|
-
}
|
|
691
|
-
const elapsed = performance.now() - start;
|
|
692
|
-
expect(elapsed).toBeLessThan(50);
|
|
693
|
-
});
|
|
694
|
-
});
|