@peaske7/readit 0.1.4 → 0.1.5
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/.agents/skills/remotion-best-practices/SKILL.md +61 -0
- package/.agents/skills/remotion-best-practices/rules/3d.md +86 -0
- package/.agents/skills/remotion-best-practices/rules/animations.md +27 -0
- package/.agents/skills/remotion-best-practices/rules/assets/charts-bar-chart.tsx +178 -0
- package/.agents/skills/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +100 -0
- package/.agents/skills/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +108 -0
- package/.agents/skills/remotion-best-practices/rules/assets.md +78 -0
- package/.agents/skills/remotion-best-practices/rules/audio-visualization.md +198 -0
- package/.agents/skills/remotion-best-practices/rules/audio.md +169 -0
- package/.agents/skills/remotion-best-practices/rules/calculate-metadata.md +134 -0
- package/.agents/skills/remotion-best-practices/rules/can-decode.md +75 -0
- package/.agents/skills/remotion-best-practices/rules/charts.md +120 -0
- package/.agents/skills/remotion-best-practices/rules/compositions.md +154 -0
- package/.agents/skills/remotion-best-practices/rules/display-captions.md +184 -0
- package/.agents/skills/remotion-best-practices/rules/extract-frames.md +229 -0
- package/.agents/skills/remotion-best-practices/rules/ffmpeg.md +38 -0
- package/.agents/skills/remotion-best-practices/rules/fonts.md +152 -0
- package/.agents/skills/remotion-best-practices/rules/get-audio-duration.md +58 -0
- package/.agents/skills/remotion-best-practices/rules/get-video-dimensions.md +68 -0
- package/.agents/skills/remotion-best-practices/rules/get-video-duration.md +60 -0
- package/.agents/skills/remotion-best-practices/rules/gifs.md +141 -0
- package/.agents/skills/remotion-best-practices/rules/images.md +134 -0
- package/.agents/skills/remotion-best-practices/rules/import-srt-captions.md +69 -0
- package/.agents/skills/remotion-best-practices/rules/light-leaks.md +73 -0
- package/.agents/skills/remotion-best-practices/rules/lottie.md +70 -0
- package/.agents/skills/remotion-best-practices/rules/maps.md +412 -0
- package/.agents/skills/remotion-best-practices/rules/measuring-dom-nodes.md +34 -0
- package/.agents/skills/remotion-best-practices/rules/measuring-text.md +140 -0
- package/.agents/skills/remotion-best-practices/rules/parameters.md +109 -0
- package/.agents/skills/remotion-best-practices/rules/sequencing.md +118 -0
- package/.agents/skills/remotion-best-practices/rules/sfx.md +26 -0
- package/.agents/skills/remotion-best-practices/rules/subtitles.md +36 -0
- package/.agents/skills/remotion-best-practices/rules/tailwind.md +11 -0
- package/.agents/skills/remotion-best-practices/rules/text-animations.md +20 -0
- package/.agents/skills/remotion-best-practices/rules/timing.md +179 -0
- package/.agents/skills/remotion-best-practices/rules/transcribe-captions.md +70 -0
- package/.agents/skills/remotion-best-practices/rules/transitions.md +197 -0
- package/.agents/skills/remotion-best-practices/rules/transparent-videos.md +106 -0
- package/.agents/skills/remotion-best-practices/rules/trimming.md +51 -0
- package/.agents/skills/remotion-best-practices/rules/videos.md +171 -0
- package/.agents/skills/remotion-best-practices/rules/voiceover.md +99 -0
- package/.agents/skills/simple/SKILL.md +52 -0
- package/.agents/skills/vercel-react-best-practices/AGENTS.md +3254 -0
- package/.agents/skills/vercel-react-best-practices/README.md +123 -0
- package/.agents/skills/vercel-react-best-practices/SKILL.md +141 -0
- package/.agents/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/.agents/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
- package/.agents/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-flatmap-filter.md +60 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-resource-hints.md +85 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-script-defer-async.md +68 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-no-inline-components.md +82 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-hoist-static-io.md +142 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
- package/.claude/CLAUDE.md +142 -0
- package/.claude/commands/review.md +120 -0
- package/.claude/commands/sync-docs.md +71 -0
- package/.claude/roadmap.md +98 -0
- package/.claude/rules/style-guide.md +830 -0
- package/.claude/settings.json +18 -0
- package/.claude/user-stories.md +248 -0
- package/AGENTS.md +64 -0
- package/README.md +7 -7
- package/biome.json +69 -0
- package/bun.lock +1124 -0
- package/docs/design.md +563 -0
- package/docs/plans/2026-03-13-keyboard-shortcuts-design.md +129 -0
- package/docs/plans/2026-03-13-keyboard-shortcuts-plan.md +1471 -0
- package/docs/plans/2026-03-13-multi-document-design.md +183 -0
- package/docs/plans/2026-03-13-performance-benchmarks-design.md +121 -0
- package/e2e/comments.spec.ts +125 -0
- package/e2e/document-load.spec.ts +54 -0
- package/e2e/export.spec.ts +58 -0
- package/e2e/fixtures/sample.html +13 -0
- package/e2e/fixtures/sample.md +7 -0
- package/e2e/persistence-file.spec.ts +342 -0
- package/e2e/utils/cli.ts +84 -0
- package/e2e/utils/selection.ts +135 -0
- package/{dist/index.html → index.html} +8 -2
- package/lefthook.yml +8 -0
- package/package.json +17 -39
- package/playwright.config.ts +22 -0
- package/skills-lock.json +20 -0
- package/src/App.tsx +396 -0
- package/src/cli/index.ts +328 -0
- package/src/components/ActionsMenu.tsx +110 -0
- package/src/components/DocumentViewer/CodeBlock.tsx +83 -0
- package/src/components/DocumentViewer/DocumentViewer.tsx +257 -0
- package/src/components/DocumentViewer/IframeContainer.tsx +251 -0
- package/src/components/DocumentViewer/MermaidDiagram.tsx +137 -0
- package/src/components/DocumentViewer/index.ts +1 -0
- package/src/components/FloatingTOC.tsx +59 -0
- package/src/components/Header.tsx +63 -0
- package/src/components/InlineEditor.tsx +72 -0
- package/src/components/MarginNote.tsx +198 -0
- package/src/components/MarginNotes.tsx +50 -0
- package/src/components/RawModal.tsx +141 -0
- package/src/components/ReanchorConfirm.tsx +33 -0
- package/src/components/SettingsModal.tsx +221 -0
- package/src/components/ShortcutCapture.tsx +45 -0
- package/src/components/ShortcutList.tsx +157 -0
- package/src/components/TabBar.tsx +60 -0
- package/src/components/TableOfContents.tsx +108 -0
- package/src/components/comments/CommentBadge.tsx +43 -0
- package/src/components/comments/CommentInput.tsx +119 -0
- package/src/components/comments/CommentListItem.tsx +82 -0
- package/src/components/comments/CommentManager.tsx +106 -0
- package/src/components/comments/CommentMinimap.tsx +62 -0
- package/src/components/comments/CommentNav.tsx +104 -0
- package/src/components/ui/ActionBar.tsx +16 -0
- package/src/components/ui/ActionLink.tsx +32 -0
- package/src/components/ui/Button.tsx +55 -0
- package/src/components/ui/Dialog.tsx +156 -0
- package/src/components/ui/DropdownMenu.tsx +114 -0
- package/src/components/ui/SeparatorDot.tsx +9 -0
- package/src/components/ui/Text.tsx +54 -0
- package/src/contexts/CommentContext.tsx +222 -0
- package/src/contexts/LayoutContext.tsx +76 -0
- package/src/hooks/useClickOutside.ts +35 -0
- package/src/hooks/useClipboard.ts +79 -0
- package/src/hooks/useCommentNavigation.ts +130 -0
- package/src/hooks/useComments.ts +323 -0
- package/src/hooks/useDocument.ts +131 -0
- package/src/hooks/useFontPreference.ts +76 -0
- package/src/hooks/useHeadings.test.ts +159 -0
- package/src/hooks/useHeadings.ts +129 -0
- package/src/hooks/useKeybindings.ts +120 -0
- package/src/hooks/useKeyboardShortcuts.ts +63 -0
- package/src/hooks/useLayoutMode.ts +44 -0
- package/src/hooks/useReanchorMode.ts +33 -0
- package/src/hooks/useScrollMetrics.ts +56 -0
- package/src/hooks/useScrollSpy.ts +81 -0
- package/src/hooks/useTextSelection.ts +123 -0
- package/src/hooks/useThemePreference.ts +66 -0
- package/src/index.css +823 -0
- package/src/lib/__fixtures__/bench-data.ts +167 -0
- package/src/lib/anchor.bench.ts +112 -0
- package/src/lib/anchor.test.ts +531 -0
- package/src/lib/anchor.ts +465 -0
- package/src/lib/comment-storage.bench.ts +63 -0
- package/src/lib/comment-storage.test.ts +624 -0
- package/src/lib/comment-storage.ts +263 -0
- package/src/lib/context.bench.ts +41 -0
- package/src/lib/context.test.ts +224 -0
- package/src/lib/context.ts +193 -0
- package/src/lib/export.bench.ts +35 -0
- package/src/lib/export.ts +43 -0
- package/src/lib/highlight/colors.ts +37 -0
- package/src/lib/highlight/core.test.ts +98 -0
- package/src/lib/highlight/core.ts +54 -0
- package/src/lib/highlight/dom.ts +342 -0
- package/src/lib/highlight/highlighter.ts +427 -0
- package/src/lib/highlight/index.ts +23 -0
- package/src/lib/highlight/script-builder.ts +485 -0
- package/src/lib/highlight/types.ts +57 -0
- package/src/lib/html-processor.test.tsx +170 -0
- package/src/lib/html-processor.tsx +95 -0
- package/src/lib/layout-constants.ts +12 -0
- package/src/lib/margin-layout.bench.ts +28 -0
- package/src/lib/margin-layout.ts +100 -0
- package/src/lib/scroll.test.ts +118 -0
- package/src/lib/scroll.ts +47 -0
- package/src/lib/shortcut-registry.test.ts +173 -0
- package/src/lib/shortcut-registry.ts +209 -0
- package/src/lib/utils.test.ts +110 -0
- package/src/lib/utils.ts +50 -0
- package/src/main.tsx +10 -0
- package/src/server/index.ts +766 -0
- package/src/store/index.test.ts +220 -0
- package/src/store/index.ts +234 -0
- package/src/test-setup.ts +1 -0
- package/src/types/index.ts +115 -0
- package/test.md +74 -0
- package/tsconfig.cli.json +12 -0
- package/tsconfig.json +20 -0
- package/vite.config.ts +19 -0
- package/vitest.config.ts +15 -0
- package/dist/assets/_basePickBy-hOr-yGsE.js +0 -1
- package/dist/assets/_baseUniq-b7bzdUSn.js +0 -1
- package/dist/assets/arc-D65wG9gm.js +0 -1
- package/dist/assets/architecture-PBZL5I3N-DBa6CAv_.js +0 -1
- package/dist/assets/architectureDiagram-2XIMDMQ5-Djwpsh98.js +0 -36
- package/dist/assets/array-DOVTz2Mq.js +0 -1
- package/dist/assets/blockDiagram-WCTKOSBZ-BdW5TTxj.js +0 -132
- package/dist/assets/c4Diagram-IC4MRINW-DTmkHEXu.js +0 -10
- package/dist/assets/channel-B3MUFipN.js +0 -1
- package/dist/assets/chunk-4BX2VUAB-DEqzsvDc.js +0 -1
- package/dist/assets/chunk-55IACEB6-BzVuSUV8.js +0 -1
- package/dist/assets/chunk-7E7YKBS2-CZ8IcA4c.js +0 -1
- package/dist/assets/chunk-7R4GIKGN-CWVVC8HX.js +0 -79
- package/dist/assets/chunk-C72U2L5F-B1Tso5TH.js +0 -1
- package/dist/assets/chunk-EGIJ26TM-Cx_7CFik.js +0 -1
- package/dist/assets/chunk-FMBD7UC4-Cfk_iGhv.js +0 -15
- package/dist/assets/chunk-GEFDOKGD-C_5hRbJt.js +0 -2
- package/dist/assets/chunk-GLR3WWYH-CkY7IyBj.js +0 -2
- package/dist/assets/chunk-HHEYEP7N-B0I4X5cr.js +0 -1
- package/dist/assets/chunk-JSJVCQXG-CAjwlVLg.js +0 -1
- package/dist/assets/chunk-KX2RTZJC-DWqnZZ02.js +0 -1
- package/dist/assets/chunk-KYZI473N-gjRVhJgJ.js +0 -53
- package/dist/assets/chunk-L3YUKLVL-D7C9GuxL.js +0 -1
- package/dist/assets/chunk-MX3YWQON-i-77iuVj.js +0 -1
- package/dist/assets/chunk-NQ4KR5QH-B22Pvemm.js +0 -220
- package/dist/assets/chunk-O4XLMI2P-ZQd5L6ZD.js +0 -7
- package/dist/assets/chunk-OZEHJAEY-BaPKTELw.js +0 -1
- package/dist/assets/chunk-PQ6SQG4A-DqE1eupT.js +0 -1
- package/dist/assets/chunk-PU5JKC2W-BTqWqedh.js +0 -70
- package/dist/assets/chunk-QZHKN3VN-Nm9TvMss.js +0 -1
- package/dist/assets/chunk-R5LLSJPH-DkiNs1dN.js +0 -1
- package/dist/assets/chunk-WL4C6EOR-CioD2fv2.js +0 -189
- package/dist/assets/chunk-XIRO2GV7-B4GGQONY.js +0 -1
- package/dist/assets/chunk-XPW4576I-C0IbbQos.js +0 -32
- package/dist/assets/chunk-XZSTWKYB-DMOqFWmT.js +0 -94
- package/dist/assets/chunk-YBOYWFTD-CoeQgeVY.js +0 -1
- package/dist/assets/classDiagram-VBA2DB6C-DV9ltQ7h.js +0 -1
- package/dist/assets/classDiagram-v2-RAHNMMFH-C6nD9wmM.js +0 -1
- package/dist/assets/clone-DuY6BQEm.js +0 -1
- package/dist/assets/cose-bilkent-S5V4N54A-B6FexK6p.js +0 -1
- package/dist/assets/cytoscape.esm-DoTFyJaN.js +0 -321
- package/dist/assets/dagre-CCcocoCU.js +0 -1
- package/dist/assets/dagre-KLK3FWXG-DIELowj9.js +0 -4
- package/dist/assets/defaultLocale-Ck2Xxk-C.js +0 -1
- package/dist/assets/diagram-E7M64L7V-D1mm0PoO.js +0 -24
- package/dist/assets/diagram-IFDJBPK2-7DVjly8y.js +0 -43
- package/dist/assets/diagram-P4PSJMXO-jO7pfyMb.js +0 -24
- package/dist/assets/dist-BywRdrPx.js +0 -1
- package/dist/assets/erDiagram-INFDFZHY-DSRxlRFy.js +0 -70
- package/dist/assets/flowDiagram-PKNHOUZH-CgKzzNdR.js +0 -162
- package/dist/assets/ganttDiagram-A5KZAMGK-CtsE7Y4E.js +0 -292
- package/dist/assets/gitGraph-HDMCJU4V-BU9uhwtz.js +0 -1
- package/dist/assets/gitGraphDiagram-K3NZZRJ6-DOU8RGdw.js +0 -65
- package/dist/assets/graphlib-WkJoBgka.js +0 -1
- package/dist/assets/index-CKVArt9D.js +0 -562
- package/dist/assets/index-DzRKJazf.css +0 -2
- package/dist/assets/info-3K5VOQVL-CPpvM-SG.js +0 -1
- package/dist/assets/infoDiagram-LFFYTUFH-VKLs5DsF.js +0 -2
- package/dist/assets/init-Bft5Ffpj.js +0 -1
- package/dist/assets/isArrayLikeObject-icl0H0jo.js +0 -1
- package/dist/assets/isEmpty-Du8sNmkE.js +0 -1
- package/dist/assets/ishikawaDiagram-PHBUUO56-CsWvEjux.js +0 -70
- package/dist/assets/journeyDiagram-4ABVD52K-BzJGTdIT.js +0 -139
- package/dist/assets/kanban-definition-K7BYSVSG-B_9ClJ1A.js +0 -89
- package/dist/assets/katex-BJrMXEjr.js +0 -261
- package/dist/assets/line-CC_tDGId.js +0 -1
- package/dist/assets/linear-Cts_d04Y.js +0 -1
- package/dist/assets/math-CNhlSIO3.js +0 -1
- package/dist/assets/mermaid-parser.core-Vb9KKv1R.js +0 -4
- package/dist/assets/mermaid.core-C_7xsp3d.js +0 -11
- package/dist/assets/mindmap-definition-YRQLILUH-BWmfy5wB.js +0 -68
- package/dist/assets/ordinal-DIg8h6NI.js +0 -1
- package/dist/assets/packet-RMMSAZCW-Q-WG6o3b.js +0 -1
- package/dist/assets/path-DfRbCp9y.js +0 -1
- package/dist/assets/pie-UPGHQEXC-Cwi2tLlt.js +0 -1
- package/dist/assets/pieDiagram-SKSYHLDU-Dyf3X_in.js +0 -30
- package/dist/assets/quadrantDiagram-337W2JSQ-B5_5m61Q.js +0 -7
- package/dist/assets/radar-KQ55EAFF-Dtw2VzxY.js +0 -1
- package/dist/assets/requirementDiagram-Z7DCOOCP-BSERBnlW.js +0 -73
- package/dist/assets/rough.esm-KjoEK0it.js +0 -1
- package/dist/assets/sankeyDiagram-WA2Y5GQK-CMcEY8Cz.js +0 -10
- package/dist/assets/sequenceDiagram-2WXFIKYE-D28qcXwC.js +0 -145
- package/dist/assets/src-C8kkzlHX.js +0 -1
- package/dist/assets/stateDiagram-RAJIS63D-7oVrCmRl.js +0 -1
- package/dist/assets/stateDiagram-v2-FVOUBMTO-DtFptQAd.js +0 -1
- package/dist/assets/timeline-definition-YZTLITO2-rbCfBEvG.js +0 -61
- package/dist/assets/treemap-KZPCXAKY-BlRvF0um.js +0 -1
- package/dist/assets/vennDiagram-LZ73GAT5-DBit3zWa.js +0 -34
- package/dist/assets/xychartDiagram-JWTSCODW-BVYXv51y.js +0 -7
- package/dist/index.js +0 -1040
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
import type { Comment, Document } from "../types";
|
|
3
|
+
import { createAppStore } from "./index";
|
|
4
|
+
|
|
5
|
+
const mockDoc: Document = {
|
|
6
|
+
content: "# Hello",
|
|
7
|
+
type: "markdown",
|
|
8
|
+
filePath: "/test/file.md",
|
|
9
|
+
fileName: "file.md",
|
|
10
|
+
clean: false,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const mockDoc2: Document = {
|
|
14
|
+
content: "<h1>Hello</h1>",
|
|
15
|
+
type: "html",
|
|
16
|
+
filePath: "/test/file.html",
|
|
17
|
+
fileName: "file.html",
|
|
18
|
+
clean: false,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const mockComment = {
|
|
22
|
+
id: "c1",
|
|
23
|
+
selectedText: "hello",
|
|
24
|
+
comment: "note",
|
|
25
|
+
startOffset: 0,
|
|
26
|
+
endOffset: 5,
|
|
27
|
+
createdAt: "2026-03-13T00:00:00Z",
|
|
28
|
+
} as Comment;
|
|
29
|
+
|
|
30
|
+
describe("AppStore", () => {
|
|
31
|
+
let store: ReturnType<typeof createAppStore>;
|
|
32
|
+
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
store = createAppStore();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("openDocument", () => {
|
|
38
|
+
it("adds document to store and sets as active", () => {
|
|
39
|
+
store.getState().openDocument(mockDoc);
|
|
40
|
+
const state = store.getState();
|
|
41
|
+
expect(state.documents.has("/test/file.md")).toBe(true);
|
|
42
|
+
expect(state.activeDocumentPath).toBe("/test/file.md");
|
|
43
|
+
expect(state.documentOrder).toEqual(["/test/file.md"]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("does not overwrite existing document state", () => {
|
|
47
|
+
store.getState().openDocument(mockDoc);
|
|
48
|
+
store.getState().setComments([mockComment]);
|
|
49
|
+
store.getState().openDocument(mockDoc);
|
|
50
|
+
expect(
|
|
51
|
+
store.getState().documents.get("/test/file.md")!.comments,
|
|
52
|
+
).toHaveLength(1);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("activates existing document without overwriting", () => {
|
|
56
|
+
store.getState().openDocument(mockDoc);
|
|
57
|
+
store.getState().openDocument(mockDoc2);
|
|
58
|
+
expect(store.getState().activeDocumentPath).toBe("/test/file.html");
|
|
59
|
+
store.getState().openDocument(mockDoc);
|
|
60
|
+
expect(store.getState().activeDocumentPath).toBe("/test/file.md");
|
|
61
|
+
// Order unchanged
|
|
62
|
+
expect(store.getState().documentOrder).toEqual([
|
|
63
|
+
"/test/file.md",
|
|
64
|
+
"/test/file.html",
|
|
65
|
+
]);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe("closeDocument", () => {
|
|
70
|
+
it("removes document and activates right neighbor", () => {
|
|
71
|
+
store.getState().openDocument(mockDoc);
|
|
72
|
+
store.getState().openDocument(mockDoc2);
|
|
73
|
+
store.getState().setActiveDocument("/test/file.md");
|
|
74
|
+
store.getState().closeDocument("/test/file.md");
|
|
75
|
+
expect(store.getState().documents.has("/test/file.md")).toBe(false);
|
|
76
|
+
expect(store.getState().activeDocumentPath).toBe("/test/file.html");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("activates left neighbor when closing last in order", () => {
|
|
80
|
+
store.getState().openDocument(mockDoc);
|
|
81
|
+
store.getState().openDocument(mockDoc2);
|
|
82
|
+
// mockDoc2 is active (last opened)
|
|
83
|
+
store.getState().closeDocument("/test/file.html");
|
|
84
|
+
expect(store.getState().activeDocumentPath).toBe("/test/file.md");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("sets null when closing last document", () => {
|
|
88
|
+
store.getState().openDocument(mockDoc);
|
|
89
|
+
store.getState().closeDocument("/test/file.md");
|
|
90
|
+
expect(store.getState().activeDocumentPath).toBeNull();
|
|
91
|
+
expect(store.getState().documentOrder).toEqual([]);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("does not change active if closing non-active tab", () => {
|
|
95
|
+
store.getState().openDocument(mockDoc);
|
|
96
|
+
store.getState().openDocument(mockDoc2);
|
|
97
|
+
// mockDoc2 is active
|
|
98
|
+
store.getState().closeDocument("/test/file.md");
|
|
99
|
+
expect(store.getState().activeDocumentPath).toBe("/test/file.html");
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("activates right neighbor when closing middle tab", () => {
|
|
103
|
+
const mockDoc3: Document = {
|
|
104
|
+
content: "# Third",
|
|
105
|
+
type: "markdown",
|
|
106
|
+
filePath: "/test/third.md",
|
|
107
|
+
fileName: "third.md",
|
|
108
|
+
clean: false,
|
|
109
|
+
};
|
|
110
|
+
store.getState().openDocument(mockDoc);
|
|
111
|
+
store.getState().openDocument(mockDoc2);
|
|
112
|
+
store.getState().openDocument(mockDoc3);
|
|
113
|
+
store.getState().setActiveDocument("/test/file.html");
|
|
114
|
+
store.getState().closeDocument("/test/file.html");
|
|
115
|
+
expect(store.getState().activeDocumentPath).toBe("/test/third.md");
|
|
116
|
+
expect(store.getState().documentOrder).toEqual([
|
|
117
|
+
"/test/file.md",
|
|
118
|
+
"/test/third.md",
|
|
119
|
+
]);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe("setActiveDocument", () => {
|
|
124
|
+
it("sets active document", () => {
|
|
125
|
+
store.getState().openDocument(mockDoc);
|
|
126
|
+
store.getState().openDocument(mockDoc2);
|
|
127
|
+
store.getState().setActiveDocument("/test/file.md");
|
|
128
|
+
expect(store.getState().activeDocumentPath).toBe("/test/file.md");
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("ignores unknown file paths", () => {
|
|
132
|
+
store.getState().openDocument(mockDoc);
|
|
133
|
+
store.getState().setActiveDocument("/nonexistent.md");
|
|
134
|
+
expect(store.getState().activeDocumentPath).toBe("/test/file.md");
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe("per-document setters default to active doc", () => {
|
|
139
|
+
it("setComments operates on active document", () => {
|
|
140
|
+
store.getState().openDocument(mockDoc);
|
|
141
|
+
store.getState().setComments([mockComment]);
|
|
142
|
+
const docState = store.getState().documents.get("/test/file.md")!;
|
|
143
|
+
expect(docState.comments).toEqual([mockComment]);
|
|
144
|
+
expect(docState.sortedComments).toEqual([mockComment]);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("setComments with explicit filePath targets that document", () => {
|
|
148
|
+
store.getState().openDocument(mockDoc);
|
|
149
|
+
store.getState().openDocument(mockDoc2);
|
|
150
|
+
store.getState().setComments([mockComment], "/test/file.html");
|
|
151
|
+
expect(
|
|
152
|
+
store.getState().documents.get("/test/file.html")!.comments,
|
|
153
|
+
).toEqual([mockComment]);
|
|
154
|
+
expect(store.getState().documents.get("/test/file.md")!.comments).toEqual(
|
|
155
|
+
[],
|
|
156
|
+
);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("sortedComments sorts by startOffset", () => {
|
|
160
|
+
store.getState().openDocument(mockDoc);
|
|
161
|
+
const c1 = { ...mockComment, id: "c1", startOffset: 10 };
|
|
162
|
+
const c2 = { ...mockComment, id: "c2", startOffset: 2 };
|
|
163
|
+
const c3 = { ...mockComment, id: "c3", startOffset: 5 };
|
|
164
|
+
store.getState().setComments([c1, c2, c3]);
|
|
165
|
+
const docState = store.getState().documents.get("/test/file.md")!;
|
|
166
|
+
expect(docState.sortedComments.map((c) => c.id)).toEqual([
|
|
167
|
+
"c2",
|
|
168
|
+
"c3",
|
|
169
|
+
"c1",
|
|
170
|
+
]);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it("setSelection operates on active document", () => {
|
|
174
|
+
store.getState().openDocument(mockDoc);
|
|
175
|
+
const sel = { text: "hello", startOffset: 0, endOffset: 5 };
|
|
176
|
+
store.getState().setSelection(sel);
|
|
177
|
+
expect(
|
|
178
|
+
store.getState().documents.get("/test/file.md")!.selection,
|
|
179
|
+
).toEqual(sel);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it("setScrollY operates on active document", () => {
|
|
183
|
+
store.getState().openDocument(mockDoc);
|
|
184
|
+
store.getState().setScrollY(150);
|
|
185
|
+
expect(store.getState().documents.get("/test/file.md")!.scrollY).toBe(
|
|
186
|
+
150,
|
|
187
|
+
);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it("setters no-op when no active document", () => {
|
|
191
|
+
// No document opened
|
|
192
|
+
store.getState().setComments([mockComment]);
|
|
193
|
+
// Should not throw, just no-op
|
|
194
|
+
expect(store.getState().documents.size).toBe(0);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
describe("getActiveDocumentState", () => {
|
|
199
|
+
it("returns undefined when no active document", () => {
|
|
200
|
+
expect(store.getState().getActiveDocumentState()).toBeUndefined();
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("returns active document state", () => {
|
|
204
|
+
store.getState().openDocument(mockDoc);
|
|
205
|
+
const state = store.getState().getActiveDocumentState();
|
|
206
|
+
expect(state).toBeDefined();
|
|
207
|
+
expect(state!.document.filePath).toBe("/test/file.md");
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
describe("updateDocumentContent", () => {
|
|
212
|
+
it("updates document content in place", () => {
|
|
213
|
+
store.getState().openDocument(mockDoc);
|
|
214
|
+
store.getState().updateDocumentContent("# Updated");
|
|
215
|
+
expect(
|
|
216
|
+
store.getState().documents.get("/test/file.md")!.document.content,
|
|
217
|
+
).toBe("# Updated");
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
});
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { createStore, useStore } from "zustand";
|
|
2
|
+
import type { Comment, Document, Selection } from "../types";
|
|
3
|
+
|
|
4
|
+
// ─── Types ───────────────────────────────────────────────────────────
|
|
5
|
+
|
|
6
|
+
export interface DocumentState {
|
|
7
|
+
document: Document;
|
|
8
|
+
comments: Comment[];
|
|
9
|
+
commentsError: string | null;
|
|
10
|
+
sortedComments: Comment[];
|
|
11
|
+
selection: Selection | null;
|
|
12
|
+
pendingSelectionTop: number | undefined;
|
|
13
|
+
pendingCommentText: string;
|
|
14
|
+
highlightPositions: Record<string, number>;
|
|
15
|
+
documentPositions: Record<string, number>;
|
|
16
|
+
scrollY: number;
|
|
17
|
+
hoveredCommentId: string | undefined;
|
|
18
|
+
reanchorTarget: { commentId: string } | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AppStore {
|
|
22
|
+
// Multi-document state
|
|
23
|
+
documents: Map<string, DocumentState>;
|
|
24
|
+
activeDocumentPath: string | null;
|
|
25
|
+
documentOrder: string[];
|
|
26
|
+
|
|
27
|
+
// Global actions
|
|
28
|
+
openDocument: (doc: Document) => void;
|
|
29
|
+
closeDocument: (filePath: string) => void;
|
|
30
|
+
setActiveDocument: (filePath: string) => void;
|
|
31
|
+
|
|
32
|
+
// Per-document setters (default to active doc)
|
|
33
|
+
setComments: (comments: Comment[], filePath?: string) => void;
|
|
34
|
+
setCommentsError: (error: string | null, filePath?: string) => void;
|
|
35
|
+
setSelection: (selection: Selection | null, filePath?: string) => void;
|
|
36
|
+
setPendingSelectionTop: (top: number | undefined, filePath?: string) => void;
|
|
37
|
+
setHighlightPositions: (
|
|
38
|
+
positions: Record<string, number>,
|
|
39
|
+
filePath?: string,
|
|
40
|
+
) => void;
|
|
41
|
+
setDocumentPositions: (
|
|
42
|
+
positions: Record<string, number>,
|
|
43
|
+
filePath?: string,
|
|
44
|
+
) => void;
|
|
45
|
+
setScrollY: (y: number, filePath?: string) => void;
|
|
46
|
+
setHoveredCommentId: (id: string | undefined, filePath?: string) => void;
|
|
47
|
+
setReanchorTarget: (
|
|
48
|
+
target: { commentId: string } | null,
|
|
49
|
+
filePath?: string,
|
|
50
|
+
) => void;
|
|
51
|
+
setPendingCommentText: (text: string, filePath?: string) => void;
|
|
52
|
+
updateDocumentContent: (content: string, filePath?: string) => void;
|
|
53
|
+
|
|
54
|
+
// Helpers
|
|
55
|
+
getActiveDocumentState: () => DocumentState | undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ─── Helpers ─────────────────────────────────────────────────────────
|
|
59
|
+
|
|
60
|
+
function createInitialDocumentState(doc: Document): DocumentState {
|
|
61
|
+
return {
|
|
62
|
+
document: doc,
|
|
63
|
+
comments: [],
|
|
64
|
+
commentsError: null,
|
|
65
|
+
sortedComments: [],
|
|
66
|
+
selection: null,
|
|
67
|
+
pendingSelectionTop: undefined,
|
|
68
|
+
pendingCommentText: "",
|
|
69
|
+
highlightPositions: {},
|
|
70
|
+
documentPositions: {},
|
|
71
|
+
scrollY: 0,
|
|
72
|
+
hoveredCommentId: undefined,
|
|
73
|
+
reanchorTarget: null,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function sortComments(comments: Comment[]): Comment[] {
|
|
78
|
+
return [...comments].sort((a, b) => a.startOffset - b.startOffset);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ─── Store Factory ───────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
export function createAppStore() {
|
|
84
|
+
return createStore<AppStore>((set, get) => {
|
|
85
|
+
const resolveFilePath = (filePath?: string): string | null =>
|
|
86
|
+
filePath ?? get().activeDocumentPath;
|
|
87
|
+
|
|
88
|
+
const updateDocState = (
|
|
89
|
+
filePath: string,
|
|
90
|
+
updater: (state: DocumentState) => Partial<DocumentState>,
|
|
91
|
+
) => {
|
|
92
|
+
set((prev) => {
|
|
93
|
+
const docState = prev.documents.get(filePath);
|
|
94
|
+
if (!docState) return prev;
|
|
95
|
+
const updates = updater(docState);
|
|
96
|
+
const newDocs = new Map(prev.documents);
|
|
97
|
+
newDocs.set(filePath, { ...docState, ...updates });
|
|
98
|
+
return { documents: newDocs };
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
documents: new Map(),
|
|
104
|
+
activeDocumentPath: null,
|
|
105
|
+
documentOrder: [],
|
|
106
|
+
|
|
107
|
+
openDocument: (doc) => {
|
|
108
|
+
set((prev) => {
|
|
109
|
+
if (prev.documents.has(doc.filePath)) {
|
|
110
|
+
return { activeDocumentPath: doc.filePath };
|
|
111
|
+
}
|
|
112
|
+
const newDocs = new Map(prev.documents);
|
|
113
|
+
newDocs.set(doc.filePath, createInitialDocumentState(doc));
|
|
114
|
+
return {
|
|
115
|
+
documents: newDocs,
|
|
116
|
+
activeDocumentPath: doc.filePath,
|
|
117
|
+
documentOrder: [...prev.documentOrder, doc.filePath],
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
closeDocument: (filePath) => {
|
|
123
|
+
set((prev) => {
|
|
124
|
+
const newDocs = new Map(prev.documents);
|
|
125
|
+
newDocs.delete(filePath);
|
|
126
|
+
const newOrder = prev.documentOrder.filter((p) => p !== filePath);
|
|
127
|
+
|
|
128
|
+
let newActive = prev.activeDocumentPath;
|
|
129
|
+
if (prev.activeDocumentPath === filePath) {
|
|
130
|
+
const oldIndex = prev.documentOrder.indexOf(filePath);
|
|
131
|
+
newActive = newOrder[oldIndex] ?? newOrder[oldIndex - 1] ?? null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
documents: newDocs,
|
|
136
|
+
activeDocumentPath: newActive,
|
|
137
|
+
documentOrder: newOrder,
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
setActiveDocument: (filePath) => {
|
|
143
|
+
if (get().documents.has(filePath)) {
|
|
144
|
+
set({ activeDocumentPath: filePath });
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
setComments: (comments, filePath?) => {
|
|
149
|
+
const path = resolveFilePath(filePath);
|
|
150
|
+
if (!path) return;
|
|
151
|
+
updateDocState(path, () => ({
|
|
152
|
+
comments,
|
|
153
|
+
sortedComments: sortComments(comments),
|
|
154
|
+
}));
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
setCommentsError: (error, filePath?) => {
|
|
158
|
+
const path = resolveFilePath(filePath);
|
|
159
|
+
if (!path) return;
|
|
160
|
+
updateDocState(path, () => ({ commentsError: error }));
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
setSelection: (selection, filePath?) => {
|
|
164
|
+
const path = resolveFilePath(filePath);
|
|
165
|
+
if (!path) return;
|
|
166
|
+
updateDocState(path, () => ({ selection }));
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
setPendingSelectionTop: (top, filePath?) => {
|
|
170
|
+
const path = resolveFilePath(filePath);
|
|
171
|
+
if (!path) return;
|
|
172
|
+
updateDocState(path, () => ({ pendingSelectionTop: top }));
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
setHighlightPositions: (positions, filePath?) => {
|
|
176
|
+
const path = resolveFilePath(filePath);
|
|
177
|
+
if (!path) return;
|
|
178
|
+
updateDocState(path, () => ({ highlightPositions: positions }));
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
setDocumentPositions: (positions, filePath?) => {
|
|
182
|
+
const path = resolveFilePath(filePath);
|
|
183
|
+
if (!path) return;
|
|
184
|
+
updateDocState(path, () => ({ documentPositions: positions }));
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
setScrollY: (y, filePath?) => {
|
|
188
|
+
const path = resolveFilePath(filePath);
|
|
189
|
+
if (!path) return;
|
|
190
|
+
updateDocState(path, () => ({ scrollY: y }));
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
setHoveredCommentId: (id, filePath?) => {
|
|
194
|
+
const path = resolveFilePath(filePath);
|
|
195
|
+
if (!path) return;
|
|
196
|
+
updateDocState(path, () => ({ hoveredCommentId: id }));
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
setReanchorTarget: (target, filePath?) => {
|
|
200
|
+
const path = resolveFilePath(filePath);
|
|
201
|
+
if (!path) return;
|
|
202
|
+
updateDocState(path, () => ({ reanchorTarget: target }));
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
setPendingCommentText: (text, filePath?) => {
|
|
206
|
+
const path = resolveFilePath(filePath);
|
|
207
|
+
if (!path) return;
|
|
208
|
+
updateDocState(path, () => ({ pendingCommentText: text }));
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
updateDocumentContent: (content, filePath?) => {
|
|
212
|
+
const path = resolveFilePath(filePath);
|
|
213
|
+
if (!path) return;
|
|
214
|
+
updateDocState(path, (s) => ({
|
|
215
|
+
document: { ...s.document, content },
|
|
216
|
+
}));
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
getActiveDocumentState: () => {
|
|
220
|
+
const { documents, activeDocumentPath } = get();
|
|
221
|
+
if (!activeDocumentPath) return undefined;
|
|
222
|
+
return documents.get(activeDocumentPath);
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// ─── Singleton + React Hook ─────────────────────────────────────────
|
|
229
|
+
|
|
230
|
+
export const appStore = createAppStore();
|
|
231
|
+
|
|
232
|
+
export function useAppStore<T>(selector: (state: AppStore) => T): T {
|
|
233
|
+
return useStore(appStore, selector);
|
|
234
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom/vitest";
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Anchor confidence levels - const object pattern per style guide 6.3
|
|
2
|
+
export const AnchorConfidences = {
|
|
3
|
+
EXACT: "exact",
|
|
4
|
+
NORMALIZED: "normalized",
|
|
5
|
+
FUZZY: "fuzzy",
|
|
6
|
+
UNRESOLVED: "unresolved",
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
export type AnchorConfidence =
|
|
10
|
+
(typeof AnchorConfidences)[keyof typeof AnchorConfidences];
|
|
11
|
+
|
|
12
|
+
// Subset excluding "unresolved" for resolved anchors
|
|
13
|
+
export type ResolvedAnchorConfidence = Exclude<
|
|
14
|
+
AnchorConfidence,
|
|
15
|
+
typeof AnchorConfidences.UNRESOLVED
|
|
16
|
+
>;
|
|
17
|
+
|
|
18
|
+
export interface Comment {
|
|
19
|
+
id: string;
|
|
20
|
+
selectedText: string;
|
|
21
|
+
comment: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
// Position info for highlighting
|
|
24
|
+
startOffset: number;
|
|
25
|
+
endOffset: number;
|
|
26
|
+
// Line hint for text-based anchoring (e.g., "L42" or "L42-45")
|
|
27
|
+
lineHint?: string;
|
|
28
|
+
// Confidence level of anchor resolution
|
|
29
|
+
anchorConfidence?: AnchorConfidence;
|
|
30
|
+
// First N chars of original text for anchor matching when selectedText is truncated
|
|
31
|
+
anchorPrefix?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Parsed comment file structure
|
|
35
|
+
export interface CommentFile {
|
|
36
|
+
source: string; // Absolute path to source file
|
|
37
|
+
hash: string; // SHA-256 prefix (16 chars) of source content
|
|
38
|
+
version: number; // Format version
|
|
39
|
+
comments: Comment[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Anchor match result
|
|
43
|
+
export interface Anchor {
|
|
44
|
+
start: number;
|
|
45
|
+
end: number;
|
|
46
|
+
line: number;
|
|
47
|
+
confidence: ResolvedAnchorConfidence;
|
|
48
|
+
distance?: number; // Levenshtein distance for fuzzy matches
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface SelectionRange {
|
|
52
|
+
startOffset: number;
|
|
53
|
+
endOffset: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface Selection extends SelectionRange {
|
|
57
|
+
text: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type DocumentType = "markdown" | "html";
|
|
61
|
+
|
|
62
|
+
export interface Document {
|
|
63
|
+
content: string;
|
|
64
|
+
type: DocumentType;
|
|
65
|
+
filePath: string;
|
|
66
|
+
fileName: string;
|
|
67
|
+
clean: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Font family options - const object pattern per style guide 6.3
|
|
71
|
+
export const FontFamilies = {
|
|
72
|
+
SERIF: "serif",
|
|
73
|
+
SANS_SERIF: "sans-serif",
|
|
74
|
+
} as const;
|
|
75
|
+
|
|
76
|
+
export type FontFamily = (typeof FontFamilies)[keyof typeof FontFamilies];
|
|
77
|
+
|
|
78
|
+
// Theme mode options - const object pattern per style guide 6.3
|
|
79
|
+
export const ThemeModes = {
|
|
80
|
+
LIGHT: "light",
|
|
81
|
+
DARK: "dark",
|
|
82
|
+
SYSTEM: "system",
|
|
83
|
+
} as const;
|
|
84
|
+
|
|
85
|
+
export type ThemeMode = (typeof ThemeModes)[keyof typeof ThemeModes];
|
|
86
|
+
|
|
87
|
+
// Layout mode options - const object pattern per style guide 6.3
|
|
88
|
+
export const LayoutModes = {
|
|
89
|
+
CENTERED: "centered",
|
|
90
|
+
FULLSCREEN: "fullscreen",
|
|
91
|
+
} as const;
|
|
92
|
+
|
|
93
|
+
export type LayoutMode = (typeof LayoutModes)[keyof typeof LayoutModes];
|
|
94
|
+
|
|
95
|
+
// Keyboard shortcut binding
|
|
96
|
+
export interface ShortcutBinding {
|
|
97
|
+
key: string; // KeyboardEvent.key value, e.g. "c", "ArrowUp"
|
|
98
|
+
alt?: boolean;
|
|
99
|
+
meta?: boolean; // ⌘ on Mac, Ctrl on Windows/Linux
|
|
100
|
+
shift?: boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// User override for a shortcut
|
|
104
|
+
export interface KeybindingOverride {
|
|
105
|
+
id: string;
|
|
106
|
+
binding?: ShortcutBinding; // undefined = use default
|
|
107
|
+
enabled: boolean;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Document settings stored per-file
|
|
111
|
+
export interface DocumentSettings {
|
|
112
|
+
version: number;
|
|
113
|
+
fontFamily: FontFamily;
|
|
114
|
+
keybindings?: KeybindingOverride[];
|
|
115
|
+
}
|
package/test.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Welcome to readit
|
|
2
|
+
|
|
3
|
+
A simple tool for reviewing markdown with inline comments.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## How It Works
|
|
8
|
+
|
|
9
|
+
readit follows a simple loop: **read → comment → extract**.
|
|
10
|
+
|
|
11
|
+
### 1. Read
|
|
12
|
+
|
|
13
|
+
You're already doing this. Open any markdown file with `npx readit <file.md>` and it renders in your browser with a clean reading experience.
|
|
14
|
+
|
|
15
|
+
### 2. Comment
|
|
16
|
+
|
|
17
|
+
Select any text to add a comment. Try it now — **select this sentence** and type your first comment.
|
|
18
|
+
|
|
19
|
+
Your comments appear as margin notes next to the highlighted text, just like reviewing a document in Google Docs. Add as many as you need.
|
|
20
|
+
|
|
21
|
+
### 3. Extract
|
|
22
|
+
|
|
23
|
+
When you're done reviewing, click the menu in the top-right and choose **Copy as Prompt**. This exports all your comments in a format ready for Claude, ChatGPT, or any AI assistant.
|
|
24
|
+
|
|
25
|
+
You can also export as JSON if you prefer structured data.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Everything is Plain Markdown
|
|
30
|
+
|
|
31
|
+
Your comments are saved as `.comments.md` files in `~/.readit/comments/`. No database, no lock-in — just readable markdown files you can version control, search, or edit by hand.
|
|
32
|
+
|
|
33
|
+
Each comment file looks something like this:
|
|
34
|
+
|
|
35
|
+
```markdown
|
|
36
|
+
## Comment 1
|
|
37
|
+
**Selected:** "select this sentence"
|
|
38
|
+
**Comment:** This is my first comment!
|
|
39
|
+
**Created:** 2024-01-15T10:30:00Z
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Navigating Comments
|
|
45
|
+
|
|
46
|
+
Once you have multiple comments, use the navigation bar at the bottom of the screen to jump between them. You can also use keyboard shortcuts:
|
|
47
|
+
|
|
48
|
+
| Shortcut | Action |
|
|
49
|
+
|----------|--------|
|
|
50
|
+
| `Alt + ↑` | Previous comment |
|
|
51
|
+
| `Alt + ↓` | Next comment |
|
|
52
|
+
| `⌘ + C` | Copy selected text (raw) |
|
|
53
|
+
| `⌘ + Shift + C` | Copy selected text with context (for AI) |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Quick Start
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Review a markdown file
|
|
61
|
+
npx readit document.md
|
|
62
|
+
|
|
63
|
+
# Use a custom port
|
|
64
|
+
npx readit document.md --port 3000
|
|
65
|
+
|
|
66
|
+
# Start fresh (clear existing comments)
|
|
67
|
+
npx readit document.md --clean
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Try It Now
|
|
73
|
+
|
|
74
|
+
Go ahead and add a few comments to this document. When you're done, export them and see the output. That's the entire workflow — simple, transparent, and designed for reviewing AI-generated content.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"noEmit": false,
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"declaration": false,
|
|
9
|
+
"allowImportingTsExtensions": false
|
|
10
|
+
},
|
|
11
|
+
"include": ["src/cli", "src/server", "src/types"]
|
|
12
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"jsx": "react-jsx",
|
|
14
|
+
"allowImportingTsExtensions": true,
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noUnusedParameters": true
|
|
17
|
+
},
|
|
18
|
+
"include": ["src"],
|
|
19
|
+
"exclude": ["node_modules", "dist"]
|
|
20
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import { defineConfig } from "vite";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [tailwindcss(), react()],
|
|
7
|
+
server: {
|
|
8
|
+
proxy: {
|
|
9
|
+
"/api": {
|
|
10
|
+
target: "http://localhost:4567",
|
|
11
|
+
changeOrigin: true,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
build: {
|
|
16
|
+
outDir: "dist",
|
|
17
|
+
emptyOutDir: true,
|
|
18
|
+
},
|
|
19
|
+
});
|