hex-audit 0.7.0 → 0.8.0
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/CLAUDE.md +137 -77
- package/DEMO.md +40 -117
- package/README.md +200 -402
- package/dashboard/.next/BUILD_ID +1 -1
- package/dashboard/.next/app-build-manifest.json +56 -101
- package/dashboard/.next/app-path-routes-manifest.json +1 -1
- package/dashboard/.next/build-manifest.json +9 -9
- package/dashboard/.next/next-server.js.nft.json +1 -1
- package/dashboard/.next/prerender-manifest.json +1 -1
- package/dashboard/.next/react-loadable-manifest.json +436 -15
- package/dashboard/.next/routes-manifest.json +1 -1
- package/dashboard/.next/server/app/_not-found/page.js +1 -1
- package/dashboard/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/dashboard/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dashboard/.next/server/app/api/code/route.js +1 -1
- package/dashboard/.next/server/app/api/code/route.js.nft.json +1 -1
- package/dashboard/.next/server/app/api/comments/route.js +1 -0
- package/dashboard/.next/server/app/api/comments/route.js.nft.json +1 -0
- package/dashboard/.next/server/app/api/diagrams/[name]/export/route.js +1 -0
- package/dashboard/.next/server/app/api/diagrams/[name]/export/route.js.nft.json +1 -0
- package/dashboard/.next/server/app/api/diagrams/[name]/resolve/route.js +1 -0
- package/dashboard/.next/server/app/api/diagrams/[name]/resolve/route.js.nft.json +1 -0
- package/dashboard/.next/server/app/api/diagrams/[name]/route.js +1 -0
- package/dashboard/.next/server/app/api/diagrams/[name]/route.js.nft.json +1 -0
- package/dashboard/.next/server/app/api/figures/[name]/route.js +1 -0
- package/dashboard/.next/server/app/api/figures/[name]/route.js.nft.json +1 -0
- package/dashboard/.next/server/app/api/focus/route.js +1 -0
- package/dashboard/.next/server/app/api/focus/route.js.nft.json +1 -0
- package/dashboard/.next/server/app/api/github-status/route.js +1 -1
- package/dashboard/.next/server/app/api/invariants/[id]/route.js +1 -0
- package/dashboard/.next/server/app/api/invariants/[id]/route.js.nft.json +1 -0
- package/dashboard/.next/server/app/api/issues/[id]/revert-auto/route.js +1 -0
- package/dashboard/.next/server/app/api/issues/[id]/revert-auto/route.js.nft.json +1 -0
- package/dashboard/.next/server/app/api/nav/route.js +1 -0
- package/dashboard/.next/server/app/api/nav/route.js.nft.json +1 -0
- package/dashboard/.next/server/app/api/notes/done/route.js +1 -1
- package/dashboard/.next/server/app/api/notes/done/route.js.nft.json +1 -1
- package/dashboard/.next/server/app/api/notes/lead/route.js +1 -1
- package/dashboard/.next/server/app/api/notes/lead/route.js.nft.json +1 -1
- package/dashboard/.next/server/app/api/notes/question/route.js +1 -1
- package/dashboard/.next/server/app/api/notes/question/route.js.nft.json +1 -1
- package/dashboard/.next/server/app/api/notes/record/route.js +3 -3
- package/dashboard/.next/server/app/api/notes/route.js +2 -2
- package/dashboard/.next/server/app/api/palette/route.js +1 -0
- package/dashboard/.next/server/app/api/palette/route.js.nft.json +1 -0
- package/dashboard/.next/server/app/api/progress/route.js +1 -1
- package/dashboard/.next/server/app/api/progress/route.js.nft.json +1 -1
- package/dashboard/.next/server/app/api/watch/route.js +2 -2
- package/dashboard/.next/server/app/api/watch/route.js.nft.json +1 -1
- package/dashboard/.next/server/app/api/xref/route.js +1 -0
- package/dashboard/.next/server/app/changes/page.js +1 -20
- package/dashboard/.next/server/app/changes/page.js.nft.json +1 -1
- package/dashboard/.next/server/app/changes/page_client-reference-manifest.js +1 -1
- package/dashboard/.next/server/app/excalidraw-assets/[...path]/route.js +1 -0
- package/dashboard/.next/server/app/issues/page.js +5 -28
- package/dashboard/.next/server/app/issues/page.js.nft.json +1 -1
- package/dashboard/.next/server/app/issues/page_client-reference-manifest.js +1 -1
- package/dashboard/.next/server/app/model/page.js +1 -0
- package/dashboard/.next/server/app/{calls → model}/page.js.nft.json +1 -1
- package/dashboard/.next/server/app/model/page_client-reference-manifest.js +1 -0
- package/dashboard/.next/server/app/page.js +1 -20
- package/dashboard/.next/server/app/page.js.nft.json +1 -1
- package/dashboard/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dashboard/.next/server/app/report/page.js +1 -1
- package/dashboard/.next/server/app/report/page.js.nft.json +1 -1
- package/dashboard/.next/server/app/report/page_client-reference-manifest.js +1 -1
- package/dashboard/.next/server/app/review/page.js +1 -0
- package/dashboard/.next/server/app/{access → review}/page.js.nft.json +1 -1
- package/dashboard/.next/server/app/review/page_client-reference-manifest.js +1 -0
- package/dashboard/.next/server/app-paths-manifest.json +19 -16
- package/dashboard/.next/server/chunks/310.js +4 -0
- package/dashboard/.next/server/chunks/370.js +1 -0
- package/dashboard/.next/server/chunks/42.js +1 -1
- package/dashboard/.next/server/chunks/624.js +14 -0
- package/dashboard/.next/server/chunks/645.js +1 -1
- package/dashboard/.next/server/chunks/649.js +1 -1
- package/dashboard/.next/server/chunks/653.js +1 -0
- package/dashboard/.next/server/functions-config-manifest.json +1 -1
- package/dashboard/.next/server/middleware-build-manifest.js +1 -1
- package/dashboard/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/dashboard/.next/server/pages/500.html +1 -1
- package/dashboard/.next/server/pages/_error.js +1 -1
- package/dashboard/.next/server/server-reference-manifest.js +1 -1
- package/dashboard/.next/server/server-reference-manifest.json +1 -1
- package/dashboard/.next/static/chunks/0bbe10ee.8e7ffa06d2170dfe.js +84 -0
- package/dashboard/.next/static/chunks/1026.0ef689a305302427.js +1 -0
- package/dashboard/.next/static/chunks/1164.34eb76767ebea46f.js +8 -0
- package/dashboard/.next/static/chunks/119.a9a79633900a235f.js +5 -0
- package/dashboard/.next/static/chunks/1291.6c486c9b1d4b1b3a.js +1 -0
- package/dashboard/.next/static/chunks/139.4691848fc5a46253.js +10 -0
- package/dashboard/.next/static/chunks/145.1bf74fecdb4022e3.js +11 -0
- package/dashboard/.next/static/chunks/1517.8e7075f78e22b3a0.js +8 -0
- package/dashboard/.next/static/chunks/165.6f174060a0ce2db4.js +6 -0
- package/dashboard/.next/static/chunks/1741.5c370b7702d2eb40.js +8 -0
- package/dashboard/.next/static/chunks/1e36816c.5748c83adc8a6bd6.js +108 -0
- package/dashboard/.next/static/chunks/2061.eab75b3c1dfa068a.js +1 -0
- package/dashboard/.next/static/chunks/2148.3ce718f62d1b2f7c.js +10 -0
- package/dashboard/.next/static/chunks/217-1d5b680ffd10e3f9.js +1 -0
- package/dashboard/.next/static/chunks/2208.fb884379aa3ae968.js +1 -0
- package/dashboard/.next/static/chunks/2276.112c7855333fca5f.js +6 -0
- package/dashboard/.next/static/chunks/2374-8c6f137938f8518a.js +1 -0
- package/dashboard/.next/static/chunks/2445.18a86507d2996b95.js +1 -0
- package/dashboard/.next/static/chunks/2712.15dd8577973baf22.js +10 -0
- package/dashboard/.next/static/chunks/2759.533dec5317e0a1d1.js +1 -0
- package/dashboard/.next/static/chunks/2812.62b213bef580b69a.js +1 -0
- package/dashboard/.next/static/chunks/2895.bb57cacb7aaf42a1.js +9 -0
- package/dashboard/.next/static/chunks/2972.e5a9251b538dcf19.js +9 -0
- package/dashboard/.next/static/chunks/3206.8d9a10db2b04b93f.js +1 -0
- package/dashboard/.next/static/chunks/3485.36766504793b7237.js +9 -0
- package/dashboard/.next/static/chunks/3725.de9376dc994735d4.js +9 -0
- package/dashboard/.next/static/chunks/3774.1df377928e8387f7.js +9 -0
- package/dashboard/.next/static/chunks/3963.39d72b3875dfe2e9.js +13 -0
- package/dashboard/.next/static/chunks/4013.73884b23bfaebdde.js +11 -0
- package/dashboard/.next/static/chunks/4117.278aff1fa23fd36e.js +6 -0
- package/dashboard/.next/static/chunks/4210.cc8594110017c579.js +11 -0
- package/dashboard/.next/static/chunks/4282.28485875540886cc.js +7 -0
- package/dashboard/.next/static/chunks/4318.a2f469a88d88f6d0.js +8 -0
- package/dashboard/.next/static/chunks/4363.8999a6e727c48003.js +1 -0
- package/dashboard/.next/static/chunks/4641.e03d118fffebd580.js +5 -0
- package/dashboard/.next/static/chunks/483.a910dab7734a1074.js +8 -0
- package/dashboard/.next/static/chunks/4926.76693f542e9cc062.js +6 -0
- package/dashboard/.next/static/chunks/4938.03f6d04dabf38745.js +10 -0
- package/dashboard/.next/static/chunks/5112.0757c2b0c285e62e.js +1 -0
- package/dashboard/.next/static/chunks/5199.c83ea7efb0eec705.js +11 -0
- package/dashboard/.next/static/chunks/530.849957a8907eb288.js +1 -0
- package/dashboard/.next/static/chunks/5424.4e8ca0711a32bccf.js +7 -0
- package/dashboard/.next/static/chunks/55.a593a78be9714679.js +1 -0
- package/dashboard/.next/static/chunks/5535.6cd0bd8d368d8902.js +4 -0
- package/dashboard/.next/static/chunks/5626.7d4e93d7acbeffc9.js +10 -0
- package/dashboard/.next/static/chunks/5775.a0d7c1b1e89b9a93.js +9 -0
- package/dashboard/.next/static/chunks/6118.266956b3333b1d7a.js +9 -0
- package/dashboard/.next/static/chunks/6121.a2e6d93720b1205e.js +77 -0
- package/dashboard/.next/static/chunks/6853.d3ad43614e8ca0ab.js +1 -0
- package/dashboard/.next/static/chunks/6951.02a3a158d02158c9.js +5 -0
- package/dashboard/.next/static/chunks/6970.013f24568c87d918.js +11 -0
- package/dashboard/.next/static/chunks/7013.39d41e82b37be63b.js +9 -0
- package/dashboard/.next/static/chunks/7107.1c5412197912b8ed.js +8 -0
- package/dashboard/.next/static/chunks/7508.dd60e2d06d149f5f.js +9 -0
- package/dashboard/.next/static/chunks/7524.0fde4c61553d1491.js +3 -0
- package/dashboard/.next/static/chunks/7834-47f318a04a05688f.js +1 -0
- package/dashboard/.next/static/chunks/8317.d0b3eddef4cae0d5.js +1 -0
- package/dashboard/.next/static/chunks/838.2b2aa006519ba44c.js +10 -0
- package/dashboard/.next/static/chunks/8398.924fd8f4c83417c0.js +7 -0
- package/dashboard/.next/static/chunks/8428b36f.8ac4e67061c01307.js +34 -0
- package/dashboard/.next/static/chunks/8514.85ccbbea8ab21d04.js +5 -0
- package/dashboard/.next/static/chunks/8538.5f7ebe76c4b63162.js +1 -0
- package/dashboard/.next/static/chunks/8687.9406baa8b5601fd0.js +1 -0
- package/dashboard/.next/static/chunks/8721.47346e2cb6412376.js +10 -0
- package/dashboard/.next/static/chunks/8770.4f544bd1a6f03a62.js +8 -0
- package/dashboard/.next/static/chunks/8812.3d96fd54dba566f8.js +9 -0
- package/dashboard/.next/static/chunks/8962.d22aa67a97970dd8.js +1 -0
- package/dashboard/.next/static/chunks/8986.b327224b83f4399a.js +5 -0
- package/dashboard/.next/static/chunks/9271.5f66c19a8ee1ff36.js +10 -0
- package/dashboard/.next/static/chunks/9282.f8d01442bab4c0da.js +2 -0
- package/dashboard/.next/static/chunks/9366.0ec24a0791b9b00f.js +1 -0
- package/dashboard/.next/static/chunks/9707.5cd7d2ee933a4af5.js +6 -0
- package/dashboard/.next/static/chunks/9716.15fffc0b0038601d.js +4 -0
- package/dashboard/.next/static/chunks/9791.e3b3f5a367f63c8a.js +1 -0
- package/dashboard/.next/static/chunks/9820.8c1efad5260e8137.js +1 -0
- package/dashboard/.next/static/chunks/985.50150e9eaa4bde33.js +39 -0
- package/dashboard/.next/static/chunks/997.56901b86e1b8a87b.js +8 -0
- package/dashboard/.next/static/chunks/app/changes/page-f8a860034221cad4.js +1 -0
- package/dashboard/.next/static/chunks/app/issues/page-da4da93188c414a6.js +1 -0
- package/dashboard/.next/static/chunks/app/layout-27a9da4610423c1e.js +1 -0
- package/dashboard/.next/static/chunks/app/model/page-9680e22fdd6ddb81.js +1 -0
- package/dashboard/.next/static/chunks/app/page-0e67750d99fb2836.js +1 -0
- package/dashboard/.next/static/chunks/app/report/page-b56b1db9b9dcf2b6.js +1 -0
- package/dashboard/.next/static/chunks/app/review/page-3ef69f0e0badd333.js +1 -0
- package/dashboard/.next/static/chunks/c75e29e3.d91220f782934d80.js +1 -0
- package/dashboard/.next/static/chunks/{main-cc3a889b25e9aa68.js → main-9c95a7ffedc7afb4.js} +1 -1
- package/dashboard/.next/static/chunks/webpack-6da70e4f9fcf1799.js +1 -0
- package/dashboard/.next/static/css/ceafd91ca8dd753d.css +3 -0
- package/dashboard/.next/static/css/e4aad1f9c715b79a.css +1 -0
- package/dashboard/.next/static/media/Assistant-Bold.c8f39f24.woff2 +0 -0
- package/dashboard/.next/static/media/Assistant-Medium.1e75d8e6.woff2 +0 -0
- package/dashboard/.next/static/media/Assistant-Regular.7acbabb8.woff2 +0 -0
- package/dashboard/.next/static/media/Assistant-SemiBold.167acbf8.woff2 +0 -0
- package/dashboard/app/api/code/route.ts +26 -20
- package/dashboard/app/api/comments/route.ts +158 -0
- package/dashboard/app/api/diagrams/[name]/export/route.ts +26 -0
- package/dashboard/app/api/diagrams/[name]/resolve/route.ts +25 -0
- package/dashboard/app/api/diagrams/[name]/route.ts +37 -0
- package/dashboard/app/api/figures/[name]/route.ts +15 -0
- package/dashboard/app/api/focus/route.ts +35 -0
- package/dashboard/app/api/invariants/[id]/route.ts +35 -0
- package/dashboard/app/api/issues/[id]/revert-auto/route.ts +18 -0
- package/dashboard/app/api/nav/route.ts +120 -0
- package/dashboard/app/api/palette/route.ts +68 -0
- package/dashboard/app/api/progress/route.ts +54 -23
- package/dashboard/app/api/xref/route.ts +30 -0
- package/dashboard/app/changes/ChangesClient.tsx +730 -356
- package/dashboard/app/changes/page.tsx +27 -19
- package/dashboard/app/excalidraw-assets/[...path]/route.ts +56 -0
- package/dashboard/app/globals.css +231 -77
- package/dashboard/app/issues/BoardClient.tsx +817 -0
- package/dashboard/app/issues/page.tsx +27 -272
- package/dashboard/app/layout.tsx +32 -17
- package/dashboard/app/model/ModelClient.tsx +1303 -0
- package/dashboard/app/model/page.tsx +98 -0
- package/dashboard/app/page.tsx +191 -277
- package/dashboard/app/report/ReportClient.tsx +147 -74
- package/dashboard/app/report/page.tsx +25 -14
- package/dashboard/app/review/ReviewClient.tsx +1180 -0
- package/dashboard/app/review/page.tsx +93 -0
- package/dashboard/components/AutoRefresh.tsx +22 -19
- package/dashboard/components/CodeComments.tsx +303 -0
- package/dashboard/components/CodeNav.tsx +523 -0
- package/dashboard/components/CodeReference.tsx +92 -99
- package/dashboard/components/CodeViewer.tsx +526 -0
- package/dashboard/components/CommandPalette.tsx +141 -66
- package/dashboard/components/DiagramCanvas.tsx +275 -0
- package/dashboard/components/DianeNote.tsx +244 -0
- package/dashboard/components/LiveStatus.tsx +30 -68
- package/dashboard/components/MarkdownRenderer.tsx +34 -32
- package/dashboard/components/RecordButton.tsx +132 -0
- package/dashboard/components/ui/Button.tsx +39 -0
- package/dashboard/components/ui/Chip.tsx +37 -0
- package/dashboard/components/ui/EmptyState.tsx +31 -0
- package/dashboard/components/ui/Icons.tsx +126 -0
- package/dashboard/components/ui/Inspector.tsx +122 -0
- package/dashboard/components/ui/Kbd.tsx +15 -0
- package/dashboard/components/ui/ListRow.tsx +92 -0
- package/dashboard/components/ui/LocalTime.tsx +14 -0
- package/dashboard/components/ui/ProgressRing.tsx +54 -0
- package/dashboard/components/ui/ResizeHandle.tsx +93 -0
- package/dashboard/components/ui/RiskMeter.tsx +27 -0
- package/dashboard/components/ui/SearchField.tsx +55 -0
- package/dashboard/components/ui/SegmentedControl.tsx +71 -0
- package/dashboard/components/ui/SeverityDot.tsx +57 -0
- package/dashboard/components/ui/Sidebar.tsx +236 -0
- package/dashboard/components/ui/SplitView.tsx +122 -0
- package/dashboard/components/ui/StateGlyph.tsx +66 -0
- package/dashboard/components/ui/Toast.tsx +91 -0
- package/dashboard/lib/api.ts +17 -0
- package/dashboard/lib/cn.ts +4 -0
- package/dashboard/lib/data.ts +2 -21
- package/dashboard/lib/finding-markdown.ts +1 -1
- package/dashboard/lib/focus.ts +42 -0
- package/dashboard/lib/hotkeys.ts +41 -0
- package/dashboard/lib/inline-markdown.test.ts +11 -0
- package/dashboard/lib/live.ts +32 -0
- package/dashboard/lib/pane-width.ts +36 -0
- package/dashboard/lib/server/board.ts +229 -0
- package/dashboard/lib/server/diagrams.ts +191 -0
- package/dashboard/lib/server/safe-path.ts +28 -0
- package/dashboard/lib/server/workspace.ts +113 -0
- package/dashboard/lib/server/xref.ts +42 -0
- package/dashboard/lib/solidity.test.ts +37 -0
- package/dashboard/lib/solidity.ts +191 -0
- package/dashboard/lib/source.ts +28 -0
- package/dashboard/lib/types.ts +164 -0
- package/dashboard/lib/url.ts +18 -0
- package/dashboard/lib/watcher.ts +31 -22
- package/dashboard/tailwind.config.ts +6 -3
- package/dist/analysis/code-model.d.ts.map +1 -1
- package/dist/analysis/code-model.js +4 -1
- package/dist/analysis/code-model.js.map +1 -1
- package/dist/analysis/diff.d.ts +12 -1
- package/dist/analysis/diff.d.ts.map +1 -1
- package/dist/analysis/diff.js +143 -0
- package/dist/analysis/diff.js.map +1 -1
- package/dist/commands/analyze.d.ts.map +1 -1
- package/dist/commands/analyze.js +17 -48
- package/dist/commands/analyze.js.map +1 -1
- package/dist/commands/claude.d.ts.map +1 -1
- package/dist/commands/claude.js +5 -0
- package/dist/commands/claude.js.map +1 -1
- package/dist/commands/dashboard.d.ts.map +1 -1
- package/dist/commands/dashboard.js +10 -2
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/diagram.d.ts +3 -0
- package/dist/commands/diagram.d.ts.map +1 -0
- package/dist/commands/diagram.js +71 -0
- package/dist/commands/diagram.js.map +1 -0
- package/dist/commands/diff.d.ts +4 -5
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +56 -17
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +5 -18
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/facts.d.ts +23 -0
- package/dist/commands/facts.d.ts.map +1 -0
- package/dist/commands/facts.js +121 -0
- package/dist/commands/facts.js.map +1 -0
- package/dist/commands/fix-review.d.ts +9 -0
- package/dist/commands/fix-review.d.ts.map +1 -0
- package/dist/commands/fix-review.js +367 -0
- package/dist/commands/fix-review.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +51 -47
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/issue.d.ts.map +1 -1
- package/dist/commands/issue.js +151 -2
- package/dist/commands/issue.js.map +1 -1
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +11 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/model.d.ts +4 -0
- package/dist/commands/model.d.ts.map +1 -0
- package/dist/commands/model.js +275 -0
- package/dist/commands/model.js.map +1 -0
- package/dist/commands/note.d.ts.map +1 -1
- package/dist/commands/note.js +31 -1
- package/dist/commands/note.js.map +1 -1
- package/dist/commands/review.d.ts +4 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +164 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/core/comments.d.ts +59 -0
- package/dist/core/comments.d.ts.map +1 -0
- package/dist/core/comments.js +263 -0
- package/dist/core/comments.js.map +1 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +0 -1
- package/dist/core/config.js.map +1 -1
- package/dist/core/dedup.d.ts +56 -0
- package/dist/core/dedup.d.ts.map +1 -0
- package/dist/core/dedup.js +208 -0
- package/dist/core/dedup.js.map +1 -0
- package/dist/core/errors.d.ts +1 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +0 -15
- package/dist/core/errors.js.map +1 -1
- package/dist/core/external-tools.d.ts +0 -14
- package/dist/core/external-tools.d.ts.map +1 -1
- package/dist/core/external-tools.js +2 -52
- package/dist/core/external-tools.js.map +1 -1
- package/dist/core/fix-review.d.ts +54 -0
- package/dist/core/fix-review.d.ts.map +1 -0
- package/dist/core/fix-review.js +98 -0
- package/dist/core/fix-review.js.map +1 -0
- package/dist/core/fuzz-sync.d.ts +93 -0
- package/dist/core/fuzz-sync.d.ts.map +1 -0
- package/dist/core/fuzz-sync.js +516 -0
- package/dist/core/fuzz-sync.js.map +1 -0
- package/dist/core/git.d.ts +7 -0
- package/dist/core/git.d.ts.map +1 -1
- package/dist/core/git.js +42 -0
- package/dist/core/git.js.map +1 -1
- package/dist/core/issues.d.ts +32 -1
- package/dist/core/issues.d.ts.map +1 -1
- package/dist/core/issues.js +135 -3
- package/dist/core/issues.js.map +1 -1
- package/dist/core/mcp-config.d.ts +12 -0
- package/dist/core/mcp-config.d.ts.map +1 -0
- package/dist/core/mcp-config.js +29 -0
- package/dist/core/mcp-config.js.map +1 -0
- package/dist/core/model.d.ts +38 -0
- package/dist/core/model.d.ts.map +1 -0
- package/dist/core/model.js +160 -0
- package/dist/core/model.js.map +1 -0
- package/dist/core/notes.d.ts +2 -0
- package/dist/core/notes.d.ts.map +1 -1
- package/dist/core/notes.js +13 -3
- package/dist/core/notes.js.map +1 -1
- package/dist/core/review.d.ts +47 -0
- package/dist/core/review.d.ts.map +1 -1
- package/dist/core/review.js +177 -1
- package/dist/core/review.js.map +1 -1
- package/dist/core/rules.d.ts +12 -0
- package/dist/core/rules.d.ts.map +1 -0
- package/dist/core/rules.js +66 -0
- package/dist/core/rules.js.map +1 -0
- package/dist/core/schema.d.ts +4817 -2245
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +452 -113
- package/dist/core/schema.js.map +1 -1
- package/dist/core/scope.d.ts +8 -0
- package/dist/core/scope.d.ts.map +1 -0
- package/dist/core/scope.js +18 -0
- package/dist/core/scope.js.map +1 -0
- package/dist/diagrams/build.d.ts +18 -0
- package/dist/diagrams/build.d.ts.map +1 -0
- package/dist/diagrams/build.js +135 -0
- package/dist/diagrams/build.js.map +1 -0
- package/dist/diagrams/excalidraw.d.ts +27 -0
- package/dist/diagrams/excalidraw.d.ts.map +1 -0
- package/dist/diagrams/excalidraw.js +219 -0
- package/dist/diagrams/excalidraw.js.map +1 -0
- package/dist/diagrams/layout.d.ts +48 -0
- package/dist/diagrams/layout.d.ts.map +1 -0
- package/dist/diagrams/layout.js +686 -0
- package/dist/diagrams/layout.js.map +1 -0
- package/dist/facts/build.d.ts +23 -0
- package/dist/facts/build.d.ts.map +1 -0
- package/dist/facts/build.js +112 -0
- package/dist/facts/build.js.map +1 -0
- package/dist/facts/extract.d.ts +53 -0
- package/dist/facts/extract.d.ts.map +1 -0
- package/dist/facts/extract.js +635 -0
- package/dist/facts/extract.js.map +1 -0
- package/dist/facts/fallback.d.ts +7 -0
- package/dist/facts/fallback.d.ts.map +1 -0
- package/dist/facts/fallback.js +156 -0
- package/dist/facts/fallback.js.map +1 -0
- package/dist/facts/implementations.d.ts +29 -0
- package/dist/facts/implementations.d.ts.map +1 -0
- package/dist/facts/implementations.js +43 -0
- package/dist/facts/implementations.js.map +1 -0
- package/dist/facts/query.d.ts +35 -0
- package/dist/facts/query.d.ts.map +1 -0
- package/dist/facts/query.js +157 -0
- package/dist/facts/query.js.map +1 -0
- package/dist/facts/xref.d.ts +53 -0
- package/dist/facts/xref.d.ts.map +1 -0
- package/dist/facts/xref.js +282 -0
- package/dist/facts/xref.js.map +1 -0
- package/dist/index.js +14 -16
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts +3 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +400 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/skills/ai-audit/SKILL.md +16 -6
- package/dist/skills/ai-audit/UPSTREAM.md +9 -4
- package/dist/skills/ai-audit/references/hex-board.md +34 -46
- package/dist/skills/diane.md +26 -12
- package/dist/skills/fix-review.md +58 -0
- package/dist/skills/fuzz/LICENSE +21 -0
- package/dist/skills/fuzz/SKILL.md +655 -0
- package/dist/skills/fuzz/UPSTREAM.md +119 -0
- package/dist/skills/fuzz/agents/implementers/global-property-implementer.md +81 -0
- package/dist/skills/fuzz/agents/implementers/specific-property-implementer.md +121 -0
- package/dist/skills/fuzz/agents/invariant-discovery/adversarial-profit-maximizer.md +123 -0
- package/dist/skills/fuzz/agents/invariant-discovery/conservation-auditor.md +92 -0
- package/dist/skills/fuzz/agents/invariant-discovery/protocol-type-specialist.md +173 -0
- package/dist/skills/fuzz/agents/invariant-discovery/roundtrip-rounding-analyst.md +164 -0
- package/dist/skills/fuzz/agents/invariant-discovery/state-transition-mapper.md +92 -0
- package/dist/skills/fuzz/agents/invariant-discovery/synthesizer.md +261 -0
- package/dist/skills/fuzz/agents/protocol-analyzer.md +80 -0
- package/dist/skills/fuzz/agents/report-writer.md +135 -0
- package/dist/skills/fuzz/references/handler-patterns.md +222 -0
- package/dist/skills/fuzz/references/hex-invariants.md +102 -0
- package/dist/skills/fuzz/references/property-generation.md +149 -0
- package/dist/skills/fuzz/references/selection-policy.md +49 -0
- package/dist/skills/fuzz/references/setup-playbook.md +92 -0
- package/dist/skills/fuzz/references/template-map.md +121 -0
- package/dist/skills/fuzz/scripts/ensure_foundry.sh +125 -0
- package/dist/skills/fuzz/scripts/estimate_cost.js +157 -0
- package/dist/skills/fuzz/scripts/extract_abis.js +303 -0
- package/dist/skills/fuzz/scripts/fizz_sync.js +692 -0
- package/dist/skills/fuzz/scripts/generate_handlers.js +370 -0
- package/dist/skills/fuzz/scripts/generate_suite.js +254 -0
- package/dist/skills/fuzz/scripts/lib/log-viewer.js +332 -0
- package/dist/skills/fuzz/scripts/run_echidna.js +192 -0
- package/dist/skills/fuzz/scripts/run_medusa.js +329 -0
- package/dist/skills/fuzz/scripts/select_functions.js +637 -0
- package/dist/skills/fuzz/scripts/setup_fuzz_profile.sh +142 -0
- package/dist/skills/fuzz/templates/Actor.sol +63 -0
- package/dist/skills/fuzz/templates/Base.sol +121 -0
- package/dist/skills/fuzz/templates/FoundryTester.sol +29 -0
- package/dist/skills/fuzz/templates/FuzzTester.sol +11 -0
- package/dist/skills/fuzz/templates/Properties.sol +17 -0
- package/dist/skills/fuzz/templates/README.md +56 -0
- package/dist/skills/fuzz/templates/Snapshots.sol +26 -0
- package/dist/skills/fuzz/templates/echidna.yaml +18 -0
- package/dist/skills/fuzz/templates/handlers/Handlers.sol +13 -0
- package/dist/skills/fuzz/templates/medusa.json +93 -0
- package/dist/skills/fuzz/templates/utils/Clamp.sol +223 -0
- package/dist/skills/fuzz/templates/utils/DecimalPrinter.sol +63 -0
- package/dist/skills/fuzz/templates/utils/Deployer.sol +17 -0
- package/dist/skills/fuzz/templates/utils/EnumerableSet.sol +206 -0
- package/dist/skills/fuzz/templates/utils/Hevm.sol +62 -0
- package/dist/skills/fuzz/templates/utils/Logger.sol +619 -0
- package/dist/skills/fuzz/templates/utils/Math.sol +52 -0
- package/dist/skills/fuzz/templates/utils/MockERC20.sol +279 -0
- package/dist/skills/fuzz/templates/utils/PropertiesAsserts.sol +238 -0
- package/dist/skills/fuzz/templates/utils/StringUtils.sol +85 -0
- package/dist/skills/fuzz-convert/SKILL.md +249 -0
- package/dist/skills/fuzz-sync/SKILL.md +342 -0
- package/dist/skills/generate-poc.md +8 -26
- package/dist/skills/generate-report.md +17 -5
- package/dist/skills/ingest-aa-report.md +11 -30
- package/dist/skills/init-audit/SKILL.md +155 -0
- package/dist/skills/init-audit/references/agents/conformance-checker.md +36 -0
- package/dist/skills/init-audit/references/agents/contract-reader.md +59 -0
- package/dist/skills/init-audit/references/agents/diagram-composer.md +48 -0
- package/dist/skills/init-audit/references/agents/docs-extractor.md +26 -0
- package/dist/skills/init-audit/references/agents/prior-audit.md +32 -0
- package/dist/skills/init-audit/references/agents/regression-checker.md +28 -0
- package/dist/skills/init-audit/references/agents/skeptic.md +31 -0
- package/dist/skills/init-audit/references/agents/standards-checker.md +39 -0
- package/dist/skills/init-audit/references/agents/synthesizer.md +50 -0
- package/dist/skills/prevalidate.md +62 -0
- package/dist/skills/sync-issues.md +11 -25
- package/dist/skills/validate-all-findings.md +2 -2
- package/dist/skills/validate-finding.md +25 -24
- package/dist/skills/write-finding.md +6 -5
- package/dist/types/index.d.ts +16 -12
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +5 -4
- package/dashboard/.next/server/app/access/page.js +0 -1
- package/dashboard/.next/server/app/access/page_client-reference-manifest.js +0 -1
- package/dashboard/.next/server/app/api/flows/route.js +0 -1
- package/dashboard/.next/server/app/api/mermaid/route.js +0 -1
- package/dashboard/.next/server/app/calls/page.js +0 -1
- package/dashboard/.next/server/app/calls/page_client-reference-manifest.js +0 -1
- package/dashboard/.next/server/app/conformance/page.js +0 -1
- package/dashboard/.next/server/app/conformance/page.js.nft.json +0 -1
- package/dashboard/.next/server/app/conformance/page_client-reference-manifest.js +0 -1
- package/dashboard/.next/server/app/diagram/page.js +0 -1
- package/dashboard/.next/server/app/diagram/page.js.nft.json +0 -1
- package/dashboard/.next/server/app/diagram/page_client-reference-manifest.js +0 -1
- package/dashboard/.next/server/app/flows/page.js +0 -1
- package/dashboard/.next/server/app/flows/page.js.nft.json +0 -1
- package/dashboard/.next/server/app/flows/page_client-reference-manifest.js +0 -1
- package/dashboard/.next/server/app/functions/page.js +0 -1
- package/dashboard/.next/server/app/functions/page.js.nft.json +0 -1
- package/dashboard/.next/server/app/functions/page_client-reference-manifest.js +0 -1
- package/dashboard/.next/server/app/notes/page.js +0 -22
- package/dashboard/.next/server/app/notes/page.js.nft.json +0 -1
- package/dashboard/.next/server/app/notes/page_client-reference-manifest.js +0 -1
- package/dashboard/.next/server/app/progress/page.js +0 -1
- package/dashboard/.next/server/app/progress/page.js.nft.json +0 -1
- package/dashboard/.next/server/app/progress/page_client-reference-manifest.js +0 -1
- package/dashboard/.next/server/app/stats/page.js +0 -1
- package/dashboard/.next/server/app/stats/page.js.nft.json +0 -1
- package/dashboard/.next/server/app/stats/page_client-reference-manifest.js +0 -1
- package/dashboard/.next/server/chunks/530.js +0 -1
- package/dashboard/.next/server/chunks/622.js +0 -3
- package/dashboard/.next/server/chunks/665.js +0 -13
- package/dashboard/.next/server/chunks/939.js +0 -1
- package/dashboard/.next/static/chunks/3017.4a5312e3c20a173f.js +0 -1
- package/dashboard/.next/static/chunks/7397-37adf76cad543297.js +0 -1
- package/dashboard/.next/static/chunks/7973.e34032723285a616.js +0 -79
- package/dashboard/.next/static/chunks/8452-6d77fa353402422c.js +0 -13
- package/dashboard/.next/static/chunks/8928-fc049decdfbdaa6d.js +0 -1
- package/dashboard/.next/static/chunks/app/access/page-f8403cbdfc1c176b.js +0 -1
- package/dashboard/.next/static/chunks/app/calls/page-41f20d01e12382ef.js +0 -1
- package/dashboard/.next/static/chunks/app/changes/page-82bf8b6f48cdc506.js +0 -1
- package/dashboard/.next/static/chunks/app/conformance/page-6bb8e3b372e38098.js +0 -1
- package/dashboard/.next/static/chunks/app/diagram/page-469cd7a6f183efba.js +0 -1
- package/dashboard/.next/static/chunks/app/flows/page-7872dd9141ba0b07.js +0 -1
- package/dashboard/.next/static/chunks/app/functions/page-5847bcb77a8e7edf.js +0 -1
- package/dashboard/.next/static/chunks/app/issues/page-1ffc64fe40439002.js +0 -1
- package/dashboard/.next/static/chunks/app/layout-6c6d2a0fd7c989d3.js +0 -1
- package/dashboard/.next/static/chunks/app/notes/page-8bcaa52304500098.js +0 -1
- package/dashboard/.next/static/chunks/app/page-d63800ddb072b77b.js +0 -1
- package/dashboard/.next/static/chunks/app/progress/page-e26554f655a62eef.js +0 -1
- package/dashboard/.next/static/chunks/app/report/page-18c04fb2f193b020.js +0 -1
- package/dashboard/.next/static/chunks/app/stats/page-67ff59fd69bed651.js +0 -1
- package/dashboard/.next/static/chunks/webpack-4de0e79bdd6a0418.js +0 -1
- package/dashboard/.next/static/css/1112cea2260b3926.css +0 -3
- package/dashboard/app/access/AccessClient.tsx +0 -402
- package/dashboard/app/access/ReadOnlyFunctions.tsx +0 -114
- package/dashboard/app/access/page.tsx +0 -125
- package/dashboard/app/api/flows/route.ts +0 -32
- package/dashboard/app/api/mermaid/route.ts +0 -25
- package/dashboard/app/calls/CallsClient.tsx +0 -170
- package/dashboard/app/calls/page.tsx +0 -57
- package/dashboard/app/conformance/ConformanceTable.tsx +0 -214
- package/dashboard/app/conformance/page.tsx +0 -186
- package/dashboard/app/diagram/page.tsx +0 -65
- package/dashboard/app/flows/page.tsx +0 -102
- package/dashboard/app/functions/FunctionsClient.tsx +0 -167
- package/dashboard/app/functions/page.tsx +0 -178
- package/dashboard/app/issues/IssuesBoardClient.tsx +0 -813
- package/dashboard/app/notes/NotesClient.tsx +0 -706
- package/dashboard/app/notes/page.tsx +0 -47
- package/dashboard/app/progress/ProgressClient.tsx +0 -354
- package/dashboard/app/progress/page.tsx +0 -127
- package/dashboard/app/stats/StatsClient.tsx +0 -452
- package/dashboard/app/stats/page.tsx +0 -50
- package/dashboard/components/ConfidenceBadge.tsx +0 -53
- package/dashboard/components/DashboardLayout.tsx +0 -510
- package/dashboard/components/FilterableTable.tsx +0 -293
- package/dashboard/components/MermaidViewer.tsx +0 -267
- package/dashboard/components/NotYetGenerated.tsx +0 -32
- package/dashboard/components/SeverityBadge.tsx +0 -28
- package/dashboard/components/SignalBars.tsx +0 -27
- package/dashboard/components/SortableTable.tsx +0 -122
- package/dashboard/lib/conformance-tokens.ts +0 -49
- package/dist/skills/init-audit.md +0 -386
- /package/dashboard/.next/server/app/api/{flows → xref}/route.js.nft.json +0 -0
- /package/dashboard/.next/server/app/{api/mermaid → excalidraw-assets/[...path]}/route.js.nft.json +0 -0
- /package/dashboard/.next/static/{z5XBev05xDAkDrxWxAjNu → bGV1ry1vvIbM5b506eVBR}/_buildManifest.js +0 -0
- /package/dashboard/.next/static/{z5XBev05xDAkDrxWxAjNu → bGV1ry1vvIbM5b506eVBR}/_ssgManifest.js +0 -0
- /package/dashboard/.next/static/chunks/{3205-47d09be47325709f.js → 3205-fd963acf2fdfd080.js} +0 -0
- /package/dashboard/.next/static/chunks/{3924-88d849290406ee6f.js → 3924-f1f85ccc7d59d7ab.js} +0 -0
- /package/dashboard/.next/static/chunks/{618f8807-69fc7bb97c2b87c1.js → 618f8807-fbb1466bc29c17c6.js} +0 -0
- /package/dashboard/.next/static/chunks/{7498-d1814d68ba346d13.js → 7498-7cf464d8af69cd0a.js} +0 -0
- /package/dashboard/.next/static/chunks/app/_not-found/{page-c299b935209993df.js → page-5ff5d54b6fd6f17e.js} +0 -0
|
@@ -0,0 +1,1180 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { LocalTime } from '@/components/ui/LocalTime';
|
|
4
|
+
import Link from 'next/link';
|
|
5
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { useRouter, useSearchParams } from 'next/navigation';
|
|
7
|
+
import { SplitView, Toolbar } from '@/components/ui/SplitView';
|
|
8
|
+
import { Inspector, InspectorSection } from '@/components/ui/Inspector';
|
|
9
|
+
import { ListGroupLabel, ListRow } from '@/components/ui/ListRow';
|
|
10
|
+
import { SearchField } from '@/components/ui/SearchField';
|
|
11
|
+
import { SegmentedControl, type Segment } from '@/components/ui/SegmentedControl';
|
|
12
|
+
import { StateGlyph, STATE_LABEL } from '@/components/ui/StateGlyph';
|
|
13
|
+
import { SeverityDot } from '@/components/ui/SeverityDot';
|
|
14
|
+
import { RiskMeter } from '@/components/ui/RiskMeter';
|
|
15
|
+
import { Button } from '@/components/ui/Button';
|
|
16
|
+
import { Kbd } from '@/components/ui/Kbd';
|
|
17
|
+
import { EmptyState } from '@/components/ui/EmptyState';
|
|
18
|
+
import { useToast } from '@/components/ui/Toast';
|
|
19
|
+
import { IconChevron } from '@/components/ui/Icons';
|
|
20
|
+
import { CodeViewer, type CodeViewerHandle } from '@/components/CodeViewer';
|
|
21
|
+
import { useCodeComments } from '@/components/CodeComments';
|
|
22
|
+
import { CodeReference } from '@/components/CodeReference';
|
|
23
|
+
import type { CodeNavHandlers, NavTarget, XrefDecl } from '@/components/CodeNav';
|
|
24
|
+
import { DianeNote } from '@/components/DianeNote';
|
|
25
|
+
import { MarkdownRenderer } from '@/components/MarkdownRenderer';
|
|
26
|
+
import { RecordButton } from '@/components/RecordButton';
|
|
27
|
+
import { useHotkeys } from '@/lib/hotkeys';
|
|
28
|
+
import { setFocus } from '@/lib/focus';
|
|
29
|
+
import { replaceQuery } from '@/lib/url';
|
|
30
|
+
import { sendJson } from '@/lib/api';
|
|
31
|
+
import { cn } from '@/lib/cn';
|
|
32
|
+
import type { CardRef, ContractNoteView, ReviewRow, ReviewState } from '@/lib/types';
|
|
33
|
+
|
|
34
|
+
export interface FnDetail {
|
|
35
|
+
signature: string;
|
|
36
|
+
kind: string;
|
|
37
|
+
visibility: string;
|
|
38
|
+
mutability: string;
|
|
39
|
+
modifiers: string[];
|
|
40
|
+
calls: string[];
|
|
41
|
+
called_by: string[];
|
|
42
|
+
/** Caller id → the caller's lines that make the call. */
|
|
43
|
+
called_at?: Record<string, number[]>;
|
|
44
|
+
external_calls: Array<{ target: string; member: string; kind: string; line: number }>;
|
|
45
|
+
reads: string[];
|
|
46
|
+
writes: string[];
|
|
47
|
+
emits: string[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface FnLabel {
|
|
51
|
+
id: string;
|
|
52
|
+
contract: string;
|
|
53
|
+
name: string;
|
|
54
|
+
file: string;
|
|
55
|
+
line_start: number;
|
|
56
|
+
line_end: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type Filter = 'all' | 'unread' | 'questioned' | 'changed' | 'blind';
|
|
60
|
+
|
|
61
|
+
/** A position that is not a review-map function: an interface, library code, a state variable. */
|
|
62
|
+
interface FileLoc {
|
|
63
|
+
file: string;
|
|
64
|
+
start: number;
|
|
65
|
+
end: number;
|
|
66
|
+
key?: string;
|
|
67
|
+
name: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** One step of the walked flow (the code header's trail). */
|
|
71
|
+
interface TrailEntry {
|
|
72
|
+
label: string;
|
|
73
|
+
via?: string;
|
|
74
|
+
url: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const shortLabel = (t: { key?: string; name: string }) =>
|
|
78
|
+
(t.key ?? t.name).replace(/\(.*$/, '').split('.').pop() ?? t.name;
|
|
79
|
+
|
|
80
|
+
interface Override {
|
|
81
|
+
state: ReviewState;
|
|
82
|
+
note?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function ReviewClient({
|
|
86
|
+
rows,
|
|
87
|
+
blindSpots,
|
|
88
|
+
details,
|
|
89
|
+
labels,
|
|
90
|
+
cards,
|
|
91
|
+
notes,
|
|
92
|
+
diffMode,
|
|
93
|
+
generalNote,
|
|
94
|
+
pendingSessions,
|
|
95
|
+
}: {
|
|
96
|
+
rows: ReviewRow[];
|
|
97
|
+
blindSpots: string[];
|
|
98
|
+
details: Record<string, FnDetail>;
|
|
99
|
+
labels: Record<string, FnLabel>;
|
|
100
|
+
cards: Record<string, CardRef>;
|
|
101
|
+
notes: Record<string, ContractNoteView>;
|
|
102
|
+
diffMode: boolean;
|
|
103
|
+
generalNote: string;
|
|
104
|
+
pendingSessions: number;
|
|
105
|
+
}) {
|
|
106
|
+
const router = useRouter();
|
|
107
|
+
const params = useSearchParams();
|
|
108
|
+
const toast = useToast();
|
|
109
|
+
|
|
110
|
+
// Optimistic marks, dropped whenever fresh rows arrive from the server.
|
|
111
|
+
const [overrides, setOverrides] = useState<Record<string, Override>>({});
|
|
112
|
+
useEffect(() => setOverrides({}), [rows]);
|
|
113
|
+
|
|
114
|
+
const live: ReviewRow[] = useMemo(
|
|
115
|
+
() =>
|
|
116
|
+
rows.map((r) =>
|
|
117
|
+
overrides[r.id]
|
|
118
|
+
? { ...r, state: overrides[r.id].state, note: overrides[r.id].note ?? r.note }
|
|
119
|
+
: r,
|
|
120
|
+
),
|
|
121
|
+
[rows, overrides],
|
|
122
|
+
);
|
|
123
|
+
const byId = useMemo(() => new Map(live.map((r) => [r.id, r])), [live]);
|
|
124
|
+
|
|
125
|
+
const [filter, setFilter] = useState<Filter>('all');
|
|
126
|
+
const [query, setQuery] = useState('');
|
|
127
|
+
const [showGeneral, setShowGeneral] = useState(false);
|
|
128
|
+
|
|
129
|
+
const initial = useCallback((): string | null => {
|
|
130
|
+
const fn = params.get('fn');
|
|
131
|
+
if (fn && rows.some((r) => r.id === fn)) return fn;
|
|
132
|
+
const contract = params.get('contract');
|
|
133
|
+
if (contract) {
|
|
134
|
+
const first = rows.find((r) => r.contract === contract);
|
|
135
|
+
if (first) return first.id;
|
|
136
|
+
}
|
|
137
|
+
return blindSpots[0] ?? rows[0]?.id ?? null;
|
|
138
|
+
}, [params, rows, blindSpots]);
|
|
139
|
+
|
|
140
|
+
const parseAt = (): FileLoc | null => {
|
|
141
|
+
const m = /^(.*):(\d+)-(\d+)$/.exec(params.get('at') ?? '');
|
|
142
|
+
if (!m) return null;
|
|
143
|
+
return {
|
|
144
|
+
file: m[1],
|
|
145
|
+
start: Number(m[2]),
|
|
146
|
+
end: Number(m[3]),
|
|
147
|
+
...(params.get('key') ? { key: params.get('key')! } : {}),
|
|
148
|
+
name: params.get('name') ?? m[1],
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
const [fileLoc, setFileLoc] = useState<FileLoc | null>(parseAt);
|
|
152
|
+
const [selectedId, setSelectedId] = useState<string | null>(() => (parseAt() ? null : initial()));
|
|
153
|
+
const [focusLine, setFocusLine] = useState<number | null>(
|
|
154
|
+
() => Number(params.get('line')) || null,
|
|
155
|
+
);
|
|
156
|
+
// The URL is the location: ⌘K, links, Back/Forward and navigation jumps all go through it.
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
setFocusLine(Number(params.get('line')) || null);
|
|
159
|
+
const at = parseAt();
|
|
160
|
+
if (at) {
|
|
161
|
+
setFileLoc(at);
|
|
162
|
+
setSelectedId(null);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
setFileLoc(null);
|
|
166
|
+
if (params.get('fn') || params.get('contract')) setSelectedId(initial());
|
|
167
|
+
}, [params]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
168
|
+
|
|
169
|
+
const selected = selectedId ? (byId.get(selectedId) ?? null) : null;
|
|
170
|
+
|
|
171
|
+
// ── Walking flows: every jump is a history entry; the trail shows the path. ──
|
|
172
|
+
const [trail, setTrail] = useState<TrailEntry[]>([]);
|
|
173
|
+
const [pos, setPos] = useState(0);
|
|
174
|
+
const viewer = useRef<CodeViewerHandle | null>(null);
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
const st = window.history.state as { hexTrail?: TrailEntry[]; hexPos?: number } | null;
|
|
177
|
+
if (st?.hexTrail?.length) {
|
|
178
|
+
setTrail(st.hexTrail);
|
|
179
|
+
setPos(st.hexPos ?? 0);
|
|
180
|
+
}
|
|
181
|
+
const onPop = (e: PopStateEvent) => {
|
|
182
|
+
const s2 = e.state as { hexTrail?: TrailEntry[]; hexPos?: number } | null;
|
|
183
|
+
if (s2?.hexTrail) {
|
|
184
|
+
setTrail(s2.hexTrail);
|
|
185
|
+
setPos(s2.hexPos ?? 0);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
window.addEventListener('popstate', onPop);
|
|
189
|
+
return () => window.removeEventListener('popstate', onPop);
|
|
190
|
+
}, []);
|
|
191
|
+
/** Start the trail over at the current location (a pick from the list). */
|
|
192
|
+
const resetTrail = (entry: TrailEntry) => {
|
|
193
|
+
setTrail([entry]);
|
|
194
|
+
setPos(0);
|
|
195
|
+
// Our own state object (no Next markers): Next then copies its internals in
|
|
196
|
+
// and syncs useSearchParams with the URL, on this call and on Back/Forward.
|
|
197
|
+
window.history.replaceState({ hexTrail: [entry], hexPos: 0 }, '', entry.url);
|
|
198
|
+
};
|
|
199
|
+
// The first location seeds the trail.
|
|
200
|
+
useEffect(() => {
|
|
201
|
+
if (trail.length) return;
|
|
202
|
+
const label = selected ? selected.name : fileLoc ? shortLabel(fileLoc) : null;
|
|
203
|
+
if (label) resetTrail({ label, url: window.location.pathname + window.location.search });
|
|
204
|
+
}, [selected?.id, fileLoc?.file]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
205
|
+
|
|
206
|
+
const open = useCallback(
|
|
207
|
+
(t: NavTarget) => {
|
|
208
|
+
const row = t.key ? byId.get(t.key) : undefined;
|
|
209
|
+
const url = new URL(window.location.href);
|
|
210
|
+
for (const k of ['fn', 'at', 'key', 'name', 'line', 'contract']) url.searchParams.delete(k);
|
|
211
|
+
if (row) url.searchParams.set('fn', row.id);
|
|
212
|
+
else {
|
|
213
|
+
url.searchParams.set('at', `${t.file}:${t.line_start}-${t.line_end}`);
|
|
214
|
+
if (t.key) url.searchParams.set('key', t.key);
|
|
215
|
+
url.searchParams.set('name', t.name);
|
|
216
|
+
}
|
|
217
|
+
if (t.line) url.searchParams.set('line', String(t.line));
|
|
218
|
+
const entry: TrailEntry = {
|
|
219
|
+
label: row ? row.name : shortLabel(t),
|
|
220
|
+
...(t.via ? { via: t.via.replace(/\(.*$/, '').split('.')[0] } : {}),
|
|
221
|
+
url: url.pathname + url.search,
|
|
222
|
+
};
|
|
223
|
+
const next = [...trail.slice(0, pos + 1), entry];
|
|
224
|
+
window.history.pushState({ hexTrail: next, hexPos: next.length - 1 }, '', entry.url);
|
|
225
|
+
setTrail(next);
|
|
226
|
+
setPos(next.length - 1);
|
|
227
|
+
// Apply right away; the URL effect will agree once Next syncs the params.
|
|
228
|
+
setFocusLine(t.line ?? null);
|
|
229
|
+
if (row) {
|
|
230
|
+
setFileLoc(null);
|
|
231
|
+
setSelectedId(row.id);
|
|
232
|
+
} else {
|
|
233
|
+
setFileLoc({
|
|
234
|
+
file: t.file,
|
|
235
|
+
start: t.line_start,
|
|
236
|
+
end: t.line_end,
|
|
237
|
+
...(t.key ? { key: t.key } : {}),
|
|
238
|
+
name: t.name,
|
|
239
|
+
});
|
|
240
|
+
setSelectedId(null);
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
[byId, trail, pos],
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
const nav: CodeNavHandlers = useMemo(
|
|
247
|
+
() => ({ open, stateOf: (key: string) => byId.get(key)?.state }),
|
|
248
|
+
[open, byId],
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
useEffect(() => {
|
|
252
|
+
if (!selected) return;
|
|
253
|
+
replaceQuery({ fn: selected.id, contract: null, at: null, key: null, name: null });
|
|
254
|
+
setFocus({
|
|
255
|
+
ref: selected.id,
|
|
256
|
+
kind: 'function',
|
|
257
|
+
label: `${selected.contract}.${details[selected.id]?.signature ?? selected.name}`,
|
|
258
|
+
file: selected.file,
|
|
259
|
+
line_start: selected.line_start,
|
|
260
|
+
line_end: selected.line_end,
|
|
261
|
+
});
|
|
262
|
+
}, [selected?.id]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
263
|
+
|
|
264
|
+
// ── List: filter + search, grouped by contract (blind spots keep their rank) ──
|
|
265
|
+
const visible = useMemo(() => {
|
|
266
|
+
const q = query.trim().toLowerCase();
|
|
267
|
+
let list: ReviewRow[];
|
|
268
|
+
if (filter === 'blind')
|
|
269
|
+
list = blindSpots.map((id) => byId.get(id)).filter((r): r is ReviewRow => Boolean(r));
|
|
270
|
+
else
|
|
271
|
+
list = live.filter((r) =>
|
|
272
|
+
filter === 'unread'
|
|
273
|
+
? r.state === 'unread'
|
|
274
|
+
: filter === 'questioned'
|
|
275
|
+
? r.state === 'questioned'
|
|
276
|
+
: filter === 'changed'
|
|
277
|
+
? r.diff_depth !== undefined
|
|
278
|
+
: true,
|
|
279
|
+
);
|
|
280
|
+
if (q) {
|
|
281
|
+
list = list.filter((r) =>
|
|
282
|
+
`${r.contract}.${r.name} ${details[r.id]?.signature ?? ''}`.toLowerCase().includes(q),
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
return list;
|
|
286
|
+
}, [live, byId, filter, query, blindSpots, details]);
|
|
287
|
+
|
|
288
|
+
const groups = useMemo(() => {
|
|
289
|
+
if (filter === 'blind') return [{ contract: null as string | null, rows: visible }];
|
|
290
|
+
const m = new Map<string, ReviewRow[]>();
|
|
291
|
+
for (const r of visible) m.set(r.contract, [...(m.get(r.contract) ?? []), r]);
|
|
292
|
+
return Array.from(m.entries()).map(([contract, rs]) => ({
|
|
293
|
+
contract: contract as string | null,
|
|
294
|
+
rows: rs,
|
|
295
|
+
}));
|
|
296
|
+
}, [visible, filter]);
|
|
297
|
+
|
|
298
|
+
const order = useMemo(() => groups.flatMap((g) => g.rows.map((r) => r.id)), [groups]);
|
|
299
|
+
|
|
300
|
+
const listRef = useRef<HTMLDivElement>(null);
|
|
301
|
+
const select = useCallback(
|
|
302
|
+
(id: string) => {
|
|
303
|
+
setSelectedId(id);
|
|
304
|
+
setFileLoc(null);
|
|
305
|
+
setFocusLine(null);
|
|
306
|
+
const row = rows.find((r) => r.id === id);
|
|
307
|
+
if (row) resetTrail({ label: row.name, url: `/review?fn=${encodeURIComponent(id)}` });
|
|
308
|
+
requestAnimationFrame(() =>
|
|
309
|
+
listRef.current
|
|
310
|
+
?.querySelector<HTMLElement>(`[data-id="${CSS.escape(id)}"]`)
|
|
311
|
+
?.scrollIntoView({ block: 'nearest' }),
|
|
312
|
+
);
|
|
313
|
+
},
|
|
314
|
+
[rows],
|
|
315
|
+
); // eslint-disable-line react-hooks/exhaustive-deps
|
|
316
|
+
|
|
317
|
+
const step = (d: 1 | -1) => {
|
|
318
|
+
if (!order.length) return;
|
|
319
|
+
const i = selectedId ? order.indexOf(selectedId) : -1;
|
|
320
|
+
const next = order[Math.max(0, Math.min(order.length - 1, i === -1 ? 0 : i + d))];
|
|
321
|
+
if (next) select(next);
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
// ── Marking ──
|
|
325
|
+
const noteRef = useRef<HTMLTextAreaElement>(null);
|
|
326
|
+
const mark = useCallback(
|
|
327
|
+
async (row: ReviewRow, state: ReviewState, note?: string, opts: { silent?: boolean } = {}) => {
|
|
328
|
+
const prev: Override = { state: row.state, note: row.note };
|
|
329
|
+
setOverrides((o) => ({ ...o, [row.id]: { state, note } }));
|
|
330
|
+
try {
|
|
331
|
+
await sendJson('/api/progress', { ids: [row.id], state, ...(note ? { note } : {}) });
|
|
332
|
+
if (!opts.silent) {
|
|
333
|
+
toast({
|
|
334
|
+
message:
|
|
335
|
+
state === 'unread'
|
|
336
|
+
? `${row.name} marked unread`
|
|
337
|
+
: `${row.name} marked ${STATE_LABEL[state].toLowerCase()}`,
|
|
338
|
+
action: {
|
|
339
|
+
label: 'Undo',
|
|
340
|
+
onClick: () => {
|
|
341
|
+
setOverrides((o) => ({ ...o, [row.id]: prev }));
|
|
342
|
+
void sendJson('/api/progress', {
|
|
343
|
+
ids: [row.id],
|
|
344
|
+
state: prev.state,
|
|
345
|
+
...(prev.note ? { note: prev.note } : {}),
|
|
346
|
+
}).then(() => router.refresh());
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
router.refresh();
|
|
352
|
+
} catch (err) {
|
|
353
|
+
setOverrides((o) => ({ ...o, [row.id]: prev }));
|
|
354
|
+
toast({ message: (err as Error).message, tone: 'error' });
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
[router, toast],
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
const toggle = (state: ReviewState) => {
|
|
361
|
+
if (!selected) return;
|
|
362
|
+
if (state === 'questioned' && selected.state !== 'questioned') {
|
|
363
|
+
void mark(selected, 'questioned', selected.note);
|
|
364
|
+
requestAnimationFrame(() => noteRef.current?.focus());
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
void mark(
|
|
368
|
+
selected,
|
|
369
|
+
selected.state === state ? 'unread' : state,
|
|
370
|
+
state === 'questioned' ? selected.note : undefined,
|
|
371
|
+
);
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
useHotkeys({
|
|
375
|
+
j: () => step(1),
|
|
376
|
+
k: () => step(-1),
|
|
377
|
+
ArrowDown: (e) => {
|
|
378
|
+
e.preventDefault();
|
|
379
|
+
step(1);
|
|
380
|
+
},
|
|
381
|
+
ArrowUp: (e) => {
|
|
382
|
+
e.preventDefault();
|
|
383
|
+
step(-1);
|
|
384
|
+
},
|
|
385
|
+
r: () => toggle('read'),
|
|
386
|
+
c: () => toggle('cleared'),
|
|
387
|
+
q: () => toggle('questioned'),
|
|
388
|
+
e: (e) => {
|
|
389
|
+
if (selected?.state === 'questioned') {
|
|
390
|
+
e.preventDefault();
|
|
391
|
+
noteRef.current?.focus();
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
// ── Totals (local, so marks show instantly) ──
|
|
397
|
+
const totals = useMemo(() => {
|
|
398
|
+
const total = live.reduce((s, r) => s + r.nsloc, 0);
|
|
399
|
+
const cleared = live.filter((r) => r.state === 'cleared').reduce((s, r) => s + r.nsloc, 0);
|
|
400
|
+
return { total, cleared, pct: total ? Math.round((cleared * 100) / total) : 0 };
|
|
401
|
+
}, [live]);
|
|
402
|
+
|
|
403
|
+
const segments: Segment<Filter>[] = [
|
|
404
|
+
{ value: 'all', label: 'All' },
|
|
405
|
+
{ value: 'unread', label: 'Unread' },
|
|
406
|
+
{ value: 'questioned', label: 'Questioned' },
|
|
407
|
+
...(diffMode ? [{ value: 'changed' as const, label: 'Changed' }] : []),
|
|
408
|
+
{ value: 'blind', label: 'Blind spots' },
|
|
409
|
+
];
|
|
410
|
+
|
|
411
|
+
const contractStats = useMemo(() => {
|
|
412
|
+
const m = new Map<string, { cleared: number; total: number }>();
|
|
413
|
+
for (const r of live) {
|
|
414
|
+
const s = m.get(r.contract) ?? { cleared: 0, total: 0 };
|
|
415
|
+
s.total++;
|
|
416
|
+
if (r.state === 'cleared') s.cleared++;
|
|
417
|
+
m.set(r.contract, s);
|
|
418
|
+
}
|
|
419
|
+
return m;
|
|
420
|
+
}, [live]);
|
|
421
|
+
|
|
422
|
+
const toolbar = (
|
|
423
|
+
<Toolbar
|
|
424
|
+
title="Review"
|
|
425
|
+
meta={
|
|
426
|
+
<span className="inline-flex items-center gap-2.5">
|
|
427
|
+
<span className="relative inline-block h-1 w-20 overflow-hidden rounded-full bg-surface-3 align-middle">
|
|
428
|
+
<span
|
|
429
|
+
className="absolute inset-y-0 left-0 rounded-full"
|
|
430
|
+
style={{
|
|
431
|
+
width: `${totals.pct}%`,
|
|
432
|
+
background: 'var(--success)',
|
|
433
|
+
transition: 'width 400ms var(--ease-out)',
|
|
434
|
+
}}
|
|
435
|
+
/>
|
|
436
|
+
</span>
|
|
437
|
+
<span className="tabular-nums">{totals.pct}% cleared</span>
|
|
438
|
+
</span>
|
|
439
|
+
}
|
|
440
|
+
>
|
|
441
|
+
<Button variant="ghost" onClick={() => setShowGeneral((v) => !v)} aria-expanded={showGeneral}>
|
|
442
|
+
General note
|
|
443
|
+
<IconChevron
|
|
444
|
+
className={cn(
|
|
445
|
+
'h-3.5 w-3.5 transition-transform duration-200',
|
|
446
|
+
showGeneral && 'rotate-90',
|
|
447
|
+
)}
|
|
448
|
+
/>
|
|
449
|
+
</Button>
|
|
450
|
+
<RecordButton contract={selected?.contract ?? 'general'} pending={pendingSessions} />
|
|
451
|
+
</Toolbar>
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
// What the code pane shows: the selected function, or a file position.
|
|
455
|
+
const view = selected
|
|
456
|
+
? { file: selected.file, start: selected.line_start, end: selected.line_end, key: selected.id }
|
|
457
|
+
: fileLoc
|
|
458
|
+
? { file: fileLoc.file, start: fileLoc.start, end: fileLoc.end, key: fileLoc.key }
|
|
459
|
+
: null;
|
|
460
|
+
const callers = selected ? details[selected.id]?.called_by.length : undefined;
|
|
461
|
+
|
|
462
|
+
const list = (
|
|
463
|
+
<>
|
|
464
|
+
<div className="space-y-2 border-b border-border-subtle p-3">
|
|
465
|
+
<SearchField value={query} onChange={setQuery} placeholder="Search functions" />
|
|
466
|
+
<SegmentedControl
|
|
467
|
+
segments={segments}
|
|
468
|
+
value={filter}
|
|
469
|
+
onChange={setFilter}
|
|
470
|
+
ariaLabel="Filter functions"
|
|
471
|
+
size="sm"
|
|
472
|
+
fill
|
|
473
|
+
/>
|
|
474
|
+
</div>
|
|
475
|
+
<div ref={listRef} className="min-h-0 flex-1 overflow-y-auto px-2 pb-6 pt-1">
|
|
476
|
+
{visible.length === 0 ? (
|
|
477
|
+
<p className="px-3 py-8 text-center text-body text-text-tertiary">
|
|
478
|
+
{query
|
|
479
|
+
? 'No functions match.'
|
|
480
|
+
: filter === 'questioned'
|
|
481
|
+
? 'Nothing is questioned.'
|
|
482
|
+
: 'Nothing here.'}
|
|
483
|
+
</p>
|
|
484
|
+
) : (
|
|
485
|
+
groups.map((g) => (
|
|
486
|
+
<div key={g.contract ?? 'blind'}>
|
|
487
|
+
{g.contract && (
|
|
488
|
+
<ListGroupLabel
|
|
489
|
+
trailing={`${contractStats.get(g.contract)?.cleared ?? 0}/${contractStats.get(g.contract)?.total ?? 0}`}
|
|
490
|
+
>
|
|
491
|
+
{g.contract}
|
|
492
|
+
</ListGroupLabel>
|
|
493
|
+
)}
|
|
494
|
+
{g.rows.map((r) => (
|
|
495
|
+
<ListRow
|
|
496
|
+
key={r.id}
|
|
497
|
+
data-id={r.id}
|
|
498
|
+
dense
|
|
499
|
+
selected={r.id === selectedId}
|
|
500
|
+
onClick={() => select(r.id)}
|
|
501
|
+
leading={<StateGlyph state={r.state} />}
|
|
502
|
+
title={filter === 'blind' ? `${r.contract}.${r.name}` : r.name}
|
|
503
|
+
trailing={<RiskMeter risk={r.risk} />}
|
|
504
|
+
/>
|
|
505
|
+
))}
|
|
506
|
+
</div>
|
|
507
|
+
))
|
|
508
|
+
)}
|
|
509
|
+
</div>
|
|
510
|
+
</>
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
return (
|
|
514
|
+
<SplitView
|
|
515
|
+
toolbar={
|
|
516
|
+
<>
|
|
517
|
+
{toolbar}
|
|
518
|
+
{showGeneral && (
|
|
519
|
+
<div className="fade-in max-h-[38vh] shrink-0 overflow-y-auto border-b border-border-subtle bg-surface-1 px-6 py-4">
|
|
520
|
+
{generalNote.trim() ? (
|
|
521
|
+
<div className="max-w-3xl">
|
|
522
|
+
<MarkdownRenderer content={generalNote} />
|
|
523
|
+
</div>
|
|
524
|
+
) : (
|
|
525
|
+
<p className="text-body text-text-tertiary">
|
|
526
|
+
No protocol-wide notes yet. Record a narration with nothing selected, then run{' '}
|
|
527
|
+
<code className="font-mono text-caption">/diane</code>.
|
|
528
|
+
</p>
|
|
529
|
+
)}
|
|
530
|
+
</div>
|
|
531
|
+
)}
|
|
532
|
+
</>
|
|
533
|
+
}
|
|
534
|
+
list={list}
|
|
535
|
+
listWidth={312}
|
|
536
|
+
inspector={
|
|
537
|
+
selected ? (
|
|
538
|
+
<FunctionInspector
|
|
539
|
+
row={selected}
|
|
540
|
+
detail={details[selected.id]}
|
|
541
|
+
labels={labels}
|
|
542
|
+
reviewable={byId}
|
|
543
|
+
cards={cards}
|
|
544
|
+
note={notes[selected.contract]}
|
|
545
|
+
onOpen={open}
|
|
546
|
+
onToggle={toggle}
|
|
547
|
+
onSaveNote={(n) => void mark(selected, 'questioned', n, { silent: true })}
|
|
548
|
+
noteRef={noteRef}
|
|
549
|
+
/>
|
|
550
|
+
) : fileLoc ? (
|
|
551
|
+
<DeclInspector loc={fileLoc} reviewable={byId} onOpen={open} />
|
|
552
|
+
) : undefined
|
|
553
|
+
}
|
|
554
|
+
>
|
|
555
|
+
{view ? (
|
|
556
|
+
<>
|
|
557
|
+
<div className="flex h-10 shrink-0 items-center gap-1 border-b border-border-subtle pl-2 pr-4">
|
|
558
|
+
<Trail trail={trail} pos={pos} />
|
|
559
|
+
<span className="ml-auto shrink-0 truncate pl-3 font-mono text-caption text-text-tertiary">
|
|
560
|
+
{view.file}:{view.start}
|
|
561
|
+
</span>
|
|
562
|
+
{view.key && (callers ?? 0) > 0 && (
|
|
563
|
+
<Button
|
|
564
|
+
size="sm"
|
|
565
|
+
variant="ghost"
|
|
566
|
+
className="ml-1"
|
|
567
|
+
title="Callers and call sites (⇧F12)"
|
|
568
|
+
onClick={() => viewer.current?.showUsages(view.key!)}
|
|
569
|
+
>
|
|
570
|
+
{details[selected?.id ?? '']?.kind === 'modifier' ? 'Guards' : 'Called by'}{' '}
|
|
571
|
+
{callers}
|
|
572
|
+
</Button>
|
|
573
|
+
)}
|
|
574
|
+
</div>
|
|
575
|
+
<div className="min-h-0 flex-1">
|
|
576
|
+
<CommentedCode
|
|
577
|
+
file={view.file}
|
|
578
|
+
range={{ start: view.start, end: view.end }}
|
|
579
|
+
focusLine={focusLine}
|
|
580
|
+
nav={nav}
|
|
581
|
+
currentKey={view.key}
|
|
582
|
+
handle={viewer}
|
|
583
|
+
onSelectRange={(start, end) => {
|
|
584
|
+
setFocus({
|
|
585
|
+
ref: `${view.file}:${start}-${end}`,
|
|
586
|
+
kind: 'code_range',
|
|
587
|
+
label: `${view.file}:${start}-${end}`,
|
|
588
|
+
file: view.file,
|
|
589
|
+
line_start: start,
|
|
590
|
+
line_end: end,
|
|
591
|
+
});
|
|
592
|
+
}}
|
|
593
|
+
/>
|
|
594
|
+
</div>
|
|
595
|
+
</>
|
|
596
|
+
) : (
|
|
597
|
+
<EmptyState sentence="Pick a function on the left to read it here." />
|
|
598
|
+
)}
|
|
599
|
+
</SplitView>
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/** Back, forward, and the path walked so far (older steps are clickable). */
|
|
604
|
+
function Trail({ trail, pos }: { trail: TrailEntry[]; pos: number }) {
|
|
605
|
+
const btn =
|
|
606
|
+
'flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-text-tertiary hover:bg-surface-2 hover:text-text-primary disabled:pointer-events-none disabled:opacity-30';
|
|
607
|
+
const shown = trail.slice(Math.max(0, pos - 4), Math.min(trail.length, pos + 3));
|
|
608
|
+
const offset = Math.max(0, pos - 4);
|
|
609
|
+
return (
|
|
610
|
+
<div className="flex min-w-0 items-center gap-0.5">
|
|
611
|
+
<button
|
|
612
|
+
type="button"
|
|
613
|
+
className={btn}
|
|
614
|
+
disabled={pos === 0}
|
|
615
|
+
onClick={() => window.history.back()}
|
|
616
|
+
aria-label="Back"
|
|
617
|
+
title="Back (Alt+←)"
|
|
618
|
+
>
|
|
619
|
+
<IconChevron className="h-3.5 w-3.5 rotate-180" />
|
|
620
|
+
</button>
|
|
621
|
+
<button
|
|
622
|
+
type="button"
|
|
623
|
+
className={btn}
|
|
624
|
+
disabled={pos >= trail.length - 1}
|
|
625
|
+
onClick={() => window.history.forward()}
|
|
626
|
+
aria-label="Forward"
|
|
627
|
+
title="Forward (Alt+→)"
|
|
628
|
+
>
|
|
629
|
+
<IconChevron className="h-3.5 w-3.5" />
|
|
630
|
+
</button>
|
|
631
|
+
<nav aria-label="Flow" className="ml-1 flex min-w-0 items-center gap-1 overflow-hidden">
|
|
632
|
+
{offset > 0 && <span className="text-caption text-text-tertiary">…</span>}
|
|
633
|
+
{shown.map((t, i) => {
|
|
634
|
+
const at = offset + i;
|
|
635
|
+
return (
|
|
636
|
+
<span key={at} className="flex min-w-0 items-center gap-1">
|
|
637
|
+
{i > 0 && <IconChevron className="h-3 w-3 shrink-0 text-text-tertiary" />}
|
|
638
|
+
<button
|
|
639
|
+
type="button"
|
|
640
|
+
disabled={at === pos}
|
|
641
|
+
onClick={() => window.history.go(at - pos)}
|
|
642
|
+
className={cn(
|
|
643
|
+
'truncate rounded px-1 font-mono text-caption',
|
|
644
|
+
at === pos
|
|
645
|
+
? 'text-text-primary'
|
|
646
|
+
: at < pos
|
|
647
|
+
? 'text-text-secondary hover:text-text-primary'
|
|
648
|
+
: 'text-text-tertiary hover:text-text-secondary',
|
|
649
|
+
)}
|
|
650
|
+
>
|
|
651
|
+
{t.label}
|
|
652
|
+
</button>
|
|
653
|
+
{t.via && (
|
|
654
|
+
<span className="shrink-0 text-caption text-text-tertiary">via {t.via}</span>
|
|
655
|
+
)}
|
|
656
|
+
</span>
|
|
657
|
+
);
|
|
658
|
+
})}
|
|
659
|
+
</nav>
|
|
660
|
+
</div>
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/** The code pane with the auditor's comments (one hook per open file) and navigation. */
|
|
665
|
+
function CommentedCode({
|
|
666
|
+
file,
|
|
667
|
+
range,
|
|
668
|
+
onSelectRange,
|
|
669
|
+
focusLine,
|
|
670
|
+
nav,
|
|
671
|
+
currentKey,
|
|
672
|
+
handle,
|
|
673
|
+
}: {
|
|
674
|
+
file: string;
|
|
675
|
+
range: { start: number; end: number };
|
|
676
|
+
onSelectRange: (start: number, end: number) => void;
|
|
677
|
+
focusLine: number | null;
|
|
678
|
+
nav: CodeNavHandlers;
|
|
679
|
+
currentKey?: string;
|
|
680
|
+
handle: React.MutableRefObject<CodeViewerHandle | null>;
|
|
681
|
+
}) {
|
|
682
|
+
const comments = useCodeComments(file);
|
|
683
|
+
return (
|
|
684
|
+
<CodeViewer
|
|
685
|
+
file={file}
|
|
686
|
+
range={range}
|
|
687
|
+
onSelectRange={onSelectRange}
|
|
688
|
+
comments={comments}
|
|
689
|
+
nav={nav}
|
|
690
|
+
focusLine={focusLine}
|
|
691
|
+
currentKey={currentKey}
|
|
692
|
+
handle={handle}
|
|
693
|
+
/>
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
const DECL_KIND: Record<string, string> = {
|
|
698
|
+
contract: 'Contract',
|
|
699
|
+
interface: 'Interface',
|
|
700
|
+
library: 'Library',
|
|
701
|
+
function: 'Function',
|
|
702
|
+
modifier: 'Modifier',
|
|
703
|
+
state_var: 'State variable',
|
|
704
|
+
event: 'Event',
|
|
705
|
+
error: 'Error',
|
|
706
|
+
struct: 'Struct',
|
|
707
|
+
enum: 'Enum',
|
|
708
|
+
type: 'Type',
|
|
709
|
+
constant: 'Constant',
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
interface NavSite {
|
|
713
|
+
from?: string;
|
|
714
|
+
fromName?: string;
|
|
715
|
+
fromStart?: number;
|
|
716
|
+
fromEnd?: number;
|
|
717
|
+
file: string;
|
|
718
|
+
line: number;
|
|
719
|
+
code: string;
|
|
720
|
+
kind: string;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/** A declaration that is not in the review map: what it is, where it runs, who uses it. */
|
|
724
|
+
function DeclInspector({
|
|
725
|
+
loc,
|
|
726
|
+
reviewable,
|
|
727
|
+
onOpen,
|
|
728
|
+
}: {
|
|
729
|
+
loc: FileLoc;
|
|
730
|
+
reviewable: Map<string, ReviewRow>;
|
|
731
|
+
onOpen: (t: NavTarget) => void;
|
|
732
|
+
}) {
|
|
733
|
+
const [data, setData] = useState<{
|
|
734
|
+
decl: XrefDecl | null;
|
|
735
|
+
impls: Array<{ id: string; by: string; decl: XrefDecl | null }>;
|
|
736
|
+
sites: NavSite[];
|
|
737
|
+
} | null>(null);
|
|
738
|
+
useEffect(() => {
|
|
739
|
+
setData(null);
|
|
740
|
+
if (!loc.key) return;
|
|
741
|
+
let live = true;
|
|
742
|
+
void fetch(`/api/nav?key=${encodeURIComponent(loc.key)}`)
|
|
743
|
+
.then((r) => r.json())
|
|
744
|
+
.then((d) => live && setData(d))
|
|
745
|
+
.catch(() => live && setData(null));
|
|
746
|
+
return () => {
|
|
747
|
+
live = false;
|
|
748
|
+
};
|
|
749
|
+
}, [loc.key]);
|
|
750
|
+
useEffect(() => {
|
|
751
|
+
setFocus({
|
|
752
|
+
ref: `${loc.file}:${loc.start}-${loc.end}`,
|
|
753
|
+
kind: 'code_range',
|
|
754
|
+
label: loc.key ?? `${loc.file}:${loc.start}-${loc.end}`,
|
|
755
|
+
file: loc.file,
|
|
756
|
+
line_start: loc.start,
|
|
757
|
+
line_end: loc.end,
|
|
758
|
+
});
|
|
759
|
+
}, [loc.file, loc.start, loc.end, loc.key]);
|
|
760
|
+
|
|
761
|
+
const d = data?.decl;
|
|
762
|
+
const goSite = (s: NavSite) =>
|
|
763
|
+
onOpen({
|
|
764
|
+
...(s.from ? { key: s.from } : {}),
|
|
765
|
+
name: s.fromName ?? s.file,
|
|
766
|
+
file: s.file,
|
|
767
|
+
line_start: s.fromStart ?? s.line,
|
|
768
|
+
line_end: s.fromEnd ?? s.line,
|
|
769
|
+
line: s.line,
|
|
770
|
+
});
|
|
771
|
+
const groups: Array<[string, NavSite[]]> = [];
|
|
772
|
+
for (const [label, kinds] of [
|
|
773
|
+
['Written by', ['write']],
|
|
774
|
+
['Read by', ['read']],
|
|
775
|
+
[d?.kind === 'modifier' ? 'Guards' : d?.kind === 'function' ? 'Called by' : 'Used in', null],
|
|
776
|
+
] as Array<[string, string[] | null]>) {
|
|
777
|
+
const list = (data?.sites ?? []).filter((s) =>
|
|
778
|
+
kinds ? kinds.includes(s.kind) : !['write', 'read'].includes(s.kind),
|
|
779
|
+
);
|
|
780
|
+
if (list.length) groups.push([label, list]);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
return (
|
|
784
|
+
<Inspector
|
|
785
|
+
eyebrow={`${d ? DECL_KIND[d.kind] : 'Code'}${d?.contract ? ` · ${d.contract}` : ''}${d && !d.in_scope ? ' · out of scope' : ''}`}
|
|
786
|
+
title={d?.name ?? loc.name}
|
|
787
|
+
subtitle={d?.signature ? <span className="font-mono">{d.signature}</span> : undefined}
|
|
788
|
+
>
|
|
789
|
+
<InspectorSection label="Where">
|
|
790
|
+
<CodeReference file={loc.file} lineStart={loc.start} lineEnd={loc.end} />
|
|
791
|
+
{d?.doc && <p className="mt-2 text-body text-text-secondary">{d.doc}</p>}
|
|
792
|
+
</InspectorSection>
|
|
793
|
+
{(data?.impls.length ?? 0) > 0 && (
|
|
794
|
+
<InspectorSection label="Runs in">
|
|
795
|
+
<ul>
|
|
796
|
+
{data!.impls.map((i) => (
|
|
797
|
+
<li key={i.id}>
|
|
798
|
+
<button
|
|
799
|
+
type="button"
|
|
800
|
+
onClick={() =>
|
|
801
|
+
i.decl &&
|
|
802
|
+
onOpen({
|
|
803
|
+
key: i.id,
|
|
804
|
+
name: `${i.decl.contract ?? ''}.${i.decl.name}`,
|
|
805
|
+
file: i.decl.file,
|
|
806
|
+
line_start: i.decl.line_start,
|
|
807
|
+
line_end: i.decl.line_end,
|
|
808
|
+
line: i.decl.line,
|
|
809
|
+
via: loc.key,
|
|
810
|
+
})
|
|
811
|
+
}
|
|
812
|
+
className="-mx-1.5 flex w-[calc(100%+12px)] items-center gap-2 rounded-md px-1.5 py-1 text-left hover:bg-surface-2"
|
|
813
|
+
>
|
|
814
|
+
{reviewable.get(i.id) ? (
|
|
815
|
+
<StateGlyph state={reviewable.get(i.id)!.state} className="h-3 w-3" />
|
|
816
|
+
) : (
|
|
817
|
+
<span className="h-3 w-3 shrink-0" />
|
|
818
|
+
)}
|
|
819
|
+
<span className="min-w-0 flex-1 truncate text-body text-text-primary">
|
|
820
|
+
{i.decl ? `${i.decl.contract}.${i.decl.name}` : i.id}
|
|
821
|
+
</span>
|
|
822
|
+
<span className="shrink-0 text-caption text-text-tertiary">
|
|
823
|
+
{i.by === 'signature' ? 'same signature' : 'override'}
|
|
824
|
+
</span>
|
|
825
|
+
</button>
|
|
826
|
+
</li>
|
|
827
|
+
))}
|
|
828
|
+
</ul>
|
|
829
|
+
</InspectorSection>
|
|
830
|
+
)}
|
|
831
|
+
{groups.map(([label, list]) => (
|
|
832
|
+
<InspectorSection
|
|
833
|
+
key={label}
|
|
834
|
+
label={label}
|
|
835
|
+
trailing={<span className="text-caption text-text-tertiary">{list.length}</span>}
|
|
836
|
+
>
|
|
837
|
+
<ul>
|
|
838
|
+
{list.map((s, i) => (
|
|
839
|
+
<li key={i}>
|
|
840
|
+
<button
|
|
841
|
+
type="button"
|
|
842
|
+
onClick={() => goSite(s)}
|
|
843
|
+
className="-mx-1.5 flex w-[calc(100%+12px)] items-center gap-2 rounded-md px-1.5 py-1 text-left hover:bg-surface-2"
|
|
844
|
+
>
|
|
845
|
+
{s.from && reviewable.get(s.from) ? (
|
|
846
|
+
<StateGlyph state={reviewable.get(s.from)!.state} className="h-3 w-3" />
|
|
847
|
+
) : (
|
|
848
|
+
<span className="h-3 w-3 shrink-0" />
|
|
849
|
+
)}
|
|
850
|
+
<span className="min-w-0 flex-1 truncate text-body text-text-primary">
|
|
851
|
+
{s.fromName ?? s.file}
|
|
852
|
+
</span>
|
|
853
|
+
<span className="shrink-0 text-caption text-text-tertiary">line {s.line}</span>
|
|
854
|
+
</button>
|
|
855
|
+
</li>
|
|
856
|
+
))}
|
|
857
|
+
</ul>
|
|
858
|
+
</InspectorSection>
|
|
859
|
+
))}
|
|
860
|
+
{!loc.key && <p className="text-body text-text-tertiary">A position in {loc.file}.</p>}
|
|
861
|
+
</Inspector>
|
|
862
|
+
);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// ─── Inspector ──────────────────────────────────────────────────────
|
|
866
|
+
|
|
867
|
+
function FunctionInspector({
|
|
868
|
+
row,
|
|
869
|
+
detail,
|
|
870
|
+
labels,
|
|
871
|
+
reviewable,
|
|
872
|
+
cards,
|
|
873
|
+
note,
|
|
874
|
+
onOpen,
|
|
875
|
+
onToggle,
|
|
876
|
+
onSaveNote,
|
|
877
|
+
noteRef,
|
|
878
|
+
}: {
|
|
879
|
+
row: ReviewRow;
|
|
880
|
+
detail?: FnDetail;
|
|
881
|
+
labels: Record<string, FnLabel>;
|
|
882
|
+
reviewable: Map<string, ReviewRow>;
|
|
883
|
+
cards: Record<string, CardRef>;
|
|
884
|
+
note?: ContractNoteView;
|
|
885
|
+
onOpen: (t: NavTarget) => void;
|
|
886
|
+
onToggle: (s: ReviewState) => void;
|
|
887
|
+
onSaveNote: (n: string) => void;
|
|
888
|
+
noteRef: React.RefObject<HTMLTextAreaElement>;
|
|
889
|
+
}) {
|
|
890
|
+
const [draft, setDraft] = useState(row.note ?? '');
|
|
891
|
+
useEffect(() => setDraft(row.note ?? ''), [row.id, row.note]);
|
|
892
|
+
|
|
893
|
+
const vis = detail
|
|
894
|
+
? [
|
|
895
|
+
row.is_entry_point ? 'Entry point' : detail.visibility,
|
|
896
|
+
detail.mutability !== 'nonpayable' ? detail.mutability : null,
|
|
897
|
+
]
|
|
898
|
+
: [];
|
|
899
|
+
|
|
900
|
+
return (
|
|
901
|
+
<Inspector
|
|
902
|
+
eyebrow={
|
|
903
|
+
<span>
|
|
904
|
+
{row.contract} · {vis.filter(Boolean).join(' · ')}
|
|
905
|
+
</span>
|
|
906
|
+
}
|
|
907
|
+
title={row.name}
|
|
908
|
+
subtitle={<span className="font-mono">{detail?.signature ?? row.name}</span>}
|
|
909
|
+
actions={
|
|
910
|
+
<div className="w-full space-y-3">
|
|
911
|
+
<div className="flex items-center gap-2">
|
|
912
|
+
<StateButton active={row.state === 'read'} onClick={() => onToggle('read')} k="r">
|
|
913
|
+
Read
|
|
914
|
+
</StateButton>
|
|
915
|
+
<StateButton
|
|
916
|
+
active={row.state === 'questioned'}
|
|
917
|
+
onClick={() => onToggle('questioned')}
|
|
918
|
+
k="q"
|
|
919
|
+
>
|
|
920
|
+
Question
|
|
921
|
+
</StateButton>
|
|
922
|
+
{row.state === 'cleared' ? (
|
|
923
|
+
<StateButton active onClick={() => onToggle('cleared')} k="c">
|
|
924
|
+
Cleared
|
|
925
|
+
</StateButton>
|
|
926
|
+
) : (
|
|
927
|
+
<Button
|
|
928
|
+
variant="primary"
|
|
929
|
+
onClick={() => onToggle('cleared')}
|
|
930
|
+
className="flex-1"
|
|
931
|
+
title="Clear (c)"
|
|
932
|
+
>
|
|
933
|
+
Clear
|
|
934
|
+
</Button>
|
|
935
|
+
)}
|
|
936
|
+
</div>
|
|
937
|
+
<p className="flex flex-wrap items-center gap-x-3 gap-y-1 text-caption text-text-tertiary">
|
|
938
|
+
<span className="inline-flex items-center gap-1">
|
|
939
|
+
<Kbd>r</Kbd> read
|
|
940
|
+
</span>
|
|
941
|
+
<span className="inline-flex items-center gap-1">
|
|
942
|
+
<Kbd>q</Kbd> question
|
|
943
|
+
</span>
|
|
944
|
+
<span className="inline-flex items-center gap-1">
|
|
945
|
+
<Kbd>c</Kbd> clear
|
|
946
|
+
</span>
|
|
947
|
+
<span className="inline-flex items-center gap-1">
|
|
948
|
+
<Kbd>j</Kbd>
|
|
949
|
+
<Kbd>k</Kbd> move
|
|
950
|
+
</span>
|
|
951
|
+
</p>
|
|
952
|
+
{row.state === 'questioned' && (
|
|
953
|
+
<textarea
|
|
954
|
+
ref={noteRef}
|
|
955
|
+
value={draft}
|
|
956
|
+
onChange={(e) => setDraft(e.target.value)}
|
|
957
|
+
onBlur={() => draft.trim() !== (row.note ?? '') && onSaveNote(draft.trim())}
|
|
958
|
+
onKeyDown={(e) => {
|
|
959
|
+
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey))
|
|
960
|
+
(e.target as HTMLTextAreaElement).blur();
|
|
961
|
+
if (e.key === 'Escape') (e.target as HTMLTextAreaElement).blur();
|
|
962
|
+
}}
|
|
963
|
+
rows={2}
|
|
964
|
+
placeholder="What's the question?"
|
|
965
|
+
className="fade-in w-full resize-y rounded-md border border-border-subtle bg-surface-0 px-2.5 py-2 text-body text-text-primary placeholder:text-text-tertiary focus:border-border-emphasis focus:outline-none"
|
|
966
|
+
/>
|
|
967
|
+
)}
|
|
968
|
+
{row.by && row.state !== 'unread' && (
|
|
969
|
+
<p className="text-caption text-text-tertiary">
|
|
970
|
+
{STATE_LABEL[row.state]} by {row.by}
|
|
971
|
+
{row.updated_at ? ' · ' : ''}
|
|
972
|
+
{row.updated_at && <LocalTime iso={row.updated_at} />}
|
|
973
|
+
</p>
|
|
974
|
+
)}
|
|
975
|
+
</div>
|
|
976
|
+
}
|
|
977
|
+
>
|
|
978
|
+
{row.risk_reasons.length > 0 && (
|
|
979
|
+
<InspectorSection label="Why it matters">
|
|
980
|
+
<p className="text-body text-text-secondary">
|
|
981
|
+
{capitalize(row.risk_reasons.join(', '))}.
|
|
982
|
+
</p>
|
|
983
|
+
<p className="mt-1 text-caption text-text-tertiary">
|
|
984
|
+
{row.nsloc} nSLOC ·{' '}
|
|
985
|
+
{row.ai_seen ? 'an /ai-audit scan raised something here' : 'no /ai-audit coverage yet'}
|
|
986
|
+
</p>
|
|
987
|
+
</InspectorSection>
|
|
988
|
+
)}
|
|
989
|
+
|
|
990
|
+
{row.cards.length > 0 && (
|
|
991
|
+
<InspectorSection label="Cards">
|
|
992
|
+
<ul className="space-y-1">
|
|
993
|
+
{row.cards.map((id) => {
|
|
994
|
+
const c = cards[id];
|
|
995
|
+
return (
|
|
996
|
+
<li key={id}>
|
|
997
|
+
<Link
|
|
998
|
+
href={`/issues?card=${encodeURIComponent(id)}`}
|
|
999
|
+
className="-mx-1.5 flex items-center gap-2 rounded-md px-1.5 py-1 text-body text-text-primary hover:bg-surface-2"
|
|
1000
|
+
>
|
|
1001
|
+
{c && <SeverityDot severity={c.severity} label={false} />}
|
|
1002
|
+
<span className="min-w-0 flex-1 truncate">{c?.title ?? id}</span>
|
|
1003
|
+
<span className="shrink-0 text-caption text-text-tertiary">{id}</span>
|
|
1004
|
+
</Link>
|
|
1005
|
+
</li>
|
|
1006
|
+
);
|
|
1007
|
+
})}
|
|
1008
|
+
</ul>
|
|
1009
|
+
</InspectorSection>
|
|
1010
|
+
)}
|
|
1011
|
+
|
|
1012
|
+
{detail && (
|
|
1013
|
+
<>
|
|
1014
|
+
<RefList
|
|
1015
|
+
label={detail.kind === 'modifier' ? 'Guards' : 'Called by'}
|
|
1016
|
+
ids={detail.called_by}
|
|
1017
|
+
at={detail.called_at}
|
|
1018
|
+
labels={labels}
|
|
1019
|
+
reviewable={reviewable}
|
|
1020
|
+
onOpen={onOpen}
|
|
1021
|
+
/>
|
|
1022
|
+
<RefList
|
|
1023
|
+
label="Calls"
|
|
1024
|
+
ids={detail.calls}
|
|
1025
|
+
labels={labels}
|
|
1026
|
+
reviewable={reviewable}
|
|
1027
|
+
onOpen={onOpen}
|
|
1028
|
+
/>
|
|
1029
|
+
{(detail.modifiers.length > 0 || detail.external_calls.length > 0) && (
|
|
1030
|
+
<InspectorSection label="Guards and external calls">
|
|
1031
|
+
{detail.modifiers.length > 0 && (
|
|
1032
|
+
<p className="text-body text-text-secondary">
|
|
1033
|
+
Modifiers{' '}
|
|
1034
|
+
<span className="font-mono text-caption text-text-primary">
|
|
1035
|
+
{detail.modifiers.join(', ')}
|
|
1036
|
+
</span>
|
|
1037
|
+
</p>
|
|
1038
|
+
)}
|
|
1039
|
+
{detail.external_calls.map((c, i) => (
|
|
1040
|
+
<p key={i} className="flex items-baseline justify-between gap-2 text-body">
|
|
1041
|
+
<span className="truncate font-mono text-caption text-text-primary">
|
|
1042
|
+
{c.target}.{c.member}
|
|
1043
|
+
</span>
|
|
1044
|
+
<span className="shrink-0 text-caption text-text-tertiary">
|
|
1045
|
+
{c.kind === 'low_level' ? 'low-level · ' : ''}line {c.line}
|
|
1046
|
+
</span>
|
|
1047
|
+
</p>
|
|
1048
|
+
))}
|
|
1049
|
+
</InspectorSection>
|
|
1050
|
+
)}
|
|
1051
|
+
{(detail.reads.length > 0 || detail.writes.length > 0) && (
|
|
1052
|
+
<InspectorSection label="State">
|
|
1053
|
+
{detail.writes.length > 0 && <VarLine label="Writes" vars={detail.writes} />}
|
|
1054
|
+
{detail.reads.length > 0 && <VarLine label="Reads" vars={detail.reads} />}
|
|
1055
|
+
</InspectorSection>
|
|
1056
|
+
)}
|
|
1057
|
+
</>
|
|
1058
|
+
)}
|
|
1059
|
+
|
|
1060
|
+
{note && <DianeNote note={note} fnId={row.id} fnName={row.name} />}
|
|
1061
|
+
</Inspector>
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
function capitalize(s: string): string {
|
|
1066
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
function StateButton({
|
|
1070
|
+
active,
|
|
1071
|
+
onClick,
|
|
1072
|
+
k,
|
|
1073
|
+
children,
|
|
1074
|
+
}: {
|
|
1075
|
+
active: boolean;
|
|
1076
|
+
onClick: () => void;
|
|
1077
|
+
k: string;
|
|
1078
|
+
children: React.ReactNode;
|
|
1079
|
+
}) {
|
|
1080
|
+
return (
|
|
1081
|
+
<Button
|
|
1082
|
+
variant="secondary"
|
|
1083
|
+
onClick={onClick}
|
|
1084
|
+
aria-pressed={active}
|
|
1085
|
+
title={`${active ? 'Undo' : ''} (${k})`.trim()}
|
|
1086
|
+
className={cn('flex-1', active && 'border-border-emphasis bg-surface-3')}
|
|
1087
|
+
>
|
|
1088
|
+
{children}
|
|
1089
|
+
</Button>
|
|
1090
|
+
);
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
function VarLine({ label, vars }: { label: string; vars: string[] }) {
|
|
1094
|
+
return (
|
|
1095
|
+
<p className="flex gap-3 py-0.5 text-body">
|
|
1096
|
+
<span className="w-14 shrink-0 text-text-tertiary">{label}</span>
|
|
1097
|
+
<span className="min-w-0 flex-1 break-words font-mono text-caption leading-6 text-text-primary">
|
|
1098
|
+
{vars.map((v) => v.split('.').slice(1).join('.') || v).join(', ')}
|
|
1099
|
+
</span>
|
|
1100
|
+
</p>
|
|
1101
|
+
);
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
/** Callers or callees; each row opens its code in the main pane (a step in the flow). */
|
|
1105
|
+
function RefList({
|
|
1106
|
+
label,
|
|
1107
|
+
ids,
|
|
1108
|
+
at,
|
|
1109
|
+
labels,
|
|
1110
|
+
reviewable,
|
|
1111
|
+
onOpen,
|
|
1112
|
+
}: {
|
|
1113
|
+
label: string;
|
|
1114
|
+
ids: string[];
|
|
1115
|
+
/** Caller id → its lines that make the call: "Called by" rows land on the call. */
|
|
1116
|
+
at?: Record<string, number[]>;
|
|
1117
|
+
labels: Record<string, FnLabel>;
|
|
1118
|
+
reviewable: Map<string, ReviewRow>;
|
|
1119
|
+
onOpen: (t: NavTarget) => void;
|
|
1120
|
+
}) {
|
|
1121
|
+
const [all, setAll] = useState(false);
|
|
1122
|
+
if (ids.length === 0) return null;
|
|
1123
|
+
const shown = all ? ids : ids.slice(0, 6);
|
|
1124
|
+
return (
|
|
1125
|
+
<InspectorSection
|
|
1126
|
+
label={label}
|
|
1127
|
+
trailing={<span className="text-caption text-text-tertiary">{ids.length}</span>}
|
|
1128
|
+
>
|
|
1129
|
+
<ul>
|
|
1130
|
+
{shown.map((id) => {
|
|
1131
|
+
const l = labels[id];
|
|
1132
|
+
const r = reviewable.get(id);
|
|
1133
|
+
const lines = at?.[id] ?? [];
|
|
1134
|
+
return (
|
|
1135
|
+
<li key={id}>
|
|
1136
|
+
<button
|
|
1137
|
+
type="button"
|
|
1138
|
+
onClick={() =>
|
|
1139
|
+
l &&
|
|
1140
|
+
onOpen({
|
|
1141
|
+
key: id,
|
|
1142
|
+
name: `${l.contract}.${l.name}`,
|
|
1143
|
+
file: l.file,
|
|
1144
|
+
line_start: l.line_start,
|
|
1145
|
+
line_end: l.line_end,
|
|
1146
|
+
...(lines[0] ? { line: lines[0] } : {}),
|
|
1147
|
+
})
|
|
1148
|
+
}
|
|
1149
|
+
className="-mx-1.5 flex w-[calc(100%+12px)] items-center gap-2 rounded-md px-1.5 py-1 text-left hover:bg-surface-2"
|
|
1150
|
+
>
|
|
1151
|
+
{r ? (
|
|
1152
|
+
<StateGlyph state={r.state} className="h-3 w-3" />
|
|
1153
|
+
) : (
|
|
1154
|
+
<span className="h-3 w-3 shrink-0" />
|
|
1155
|
+
)}
|
|
1156
|
+
<span className="min-w-0 flex-1 truncate text-body text-text-primary">
|
|
1157
|
+
{l ? `${l.contract}.${l.name}` : id}
|
|
1158
|
+
</span>
|
|
1159
|
+
{lines.length > 0 && (
|
|
1160
|
+
<span className="shrink-0 text-caption tabular-nums text-text-tertiary">
|
|
1161
|
+
line {lines.join(', ')}
|
|
1162
|
+
</span>
|
|
1163
|
+
)}
|
|
1164
|
+
</button>
|
|
1165
|
+
</li>
|
|
1166
|
+
);
|
|
1167
|
+
})}
|
|
1168
|
+
</ul>
|
|
1169
|
+
{ids.length > 6 && !all && (
|
|
1170
|
+
<button
|
|
1171
|
+
type="button"
|
|
1172
|
+
onClick={() => setAll(true)}
|
|
1173
|
+
className="mt-1 text-caption text-text-secondary hover:text-text-primary"
|
|
1174
|
+
>
|
|
1175
|
+
Show {ids.length - 6} more
|
|
1176
|
+
</button>
|
|
1177
|
+
)}
|
|
1178
|
+
</InspectorSection>
|
|
1179
|
+
);
|
|
1180
|
+
}
|