Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
feat(web,ui): Web UI overhaul — Risk/Costs/Docs/Symbols/Security/Graph (#168)
Raghav Chamadiya3817b6f141bf
diff --git a/package-lock.json b/package-lock.jsonindex e1983c29a..2e176ba5a 100644--- a/package-lock.json+++ b/package-lock.json@@ -1324,6 +1324,7 @@"os": ["darwin"],+ "peer": true,"engines": {"node": "^18.17.0 || ^20.3.0 || >=21.0.0"},@@ -1346,6 +1347,7 @@"os": ["darwin"],+ "peer": true,"engines": {"node": "^18.17.0 || ^20.3.0 || >=21.0.0"},@@ -1368,6 +1370,7 @@"os": ["darwin"],+ "peer": true,"funding": {"url": "https://opencollective.com/libvips"}@@ -1384,6 +1387,7 @@"os": ["darwin"],+ "peer": true,"funding": {"url": "https://opencollective.com/libvips"}@@ -1400,6 +1404,7 @@"os": ["linux"],+ "peer": true,"funding": {"url": "https://opencollective.com/libvips"}@@ -1416,6 +1421,7 @@"os": ["linux"],+ "peer": true,"funding": {"url": "https://opencollective.com/libvips"}@@ -1432,6 +1438,7 @@"os": ["linux"],+ "peer": true,"funding": {"url": "https://opencollective.com/libvips"}@@ -1448,6 +1455,7 @@"os": ["linux"],+ "peer": true,"funding": {"url": "https://opencollective.com/libvips"}@@ -1464,6 +1472,7 @@"os": ["linux"],+ "peer": true,"funding": {"url": "https://opencollective.com/libvips"}@@ -1480,6 +1489,7 @@"os": ["linux"],+ "peer": true,"funding": {"url": "https://opencollective.com/libvips"}@@ -1496,6 +1506,7 @@"os": ["linux"],+ "peer": true,"funding": {"url": "https://opencollective.com/libvips"}@@ -1512,6 +1523,7 @@"os": ["linux"],+ "peer": true,"funding": {"url": "https://opencollective.com/libvips"}@@ -1528,6 +1540,7 @@"os": ["linux"],+ "peer": true,"engines": {"node": "^18.17.0 || ^20.3.0 || >=21.0.0"},@@ -1550,6 +1563,7 @@"os": ["linux"],+ "peer": true,"engines": {"node": "^18.17.0 || ^20.3.0 || >=21.0.0"},@@ -1572,6 +1586,7 @@"os": ["linux"],+ "peer": true,"engines": {"node": "^18.17.0 || ^20.3.0 || >=21.0.0"},@@ -1594,6 +1609,7 @@"os": ["linux"],+ "peer": true,"engines": {"node": "^18.17.0 || ^20.3.0 || >=21.0.0"},@@ -1616,6 +1632,7 @@"os": ["linux"],+ "peer": true,"engines": {"node": "^18.17.0 || ^20.3.0 || >=21.0.0"},@@ -1638,6 +1655,7 @@"os": ["linux"],+ "peer": true,"engines": {"node": "^18.17.0 || ^20.3.0 || >=21.0.0"},@@ -1660,6 +1678,7 @@"os": ["linux"],+ "peer": true,"engines": {"node": "^18.17.0 || ^20.3.0 || >=21.0.0"},@@ -1682,6 +1701,7 @@"os": ["linux"],+ "peer": true,"engines": {"node": "^18.17.0 || ^20.3.0 || >=21.0.0"},@@ -1701,6 +1721,7 @@],"license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT","optional": true,+ "peer": true,"dependencies": {"@emnapi/runtime": "^1.7.0"},@@ -1723,6 +1744,7 @@"os": ["win32"],+ "peer": true,"engines": {"node": "^18.17.0 || ^20.3.0 || >=21.0.0"},@@ -1742,6 +1764,7 @@"os": ["win32"],+ "peer": true,"engines": {"node": "^18.17.0 || ^20.3.0 || >=21.0.0"},@@ -1761,6 +1784,7 @@"os": ["win32"],+ "peer": true,"engines": {"node": "^18.17.0 || ^20.3.0 || >=21.0.0"},@@ -2117,37 +2141,6 @@"integrity": "sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg==","license": "MIT"},- "node_modules/@radix-ui/react-accordion": {- "version": "1.2.12",- "resolved": "https://registry.npmjs.org/@radix-ui/react-accordion/-/react-accordion-1.2.12.tgz",- "integrity": "sha512-T4nygeh9YE9dLRPhAHSeOZi7HBXo+0kYIPJXayZfvWOWA0+n3dESrZbjfDPUABkUNym6Hd+f2IR113To8D2GPA==",- "license": "MIT",- "dependencies": {- "@radix-ui/primitive": "1.1.3",- "@radix-ui/react-collapsible": "1.1.12",- "@radix-ui/react-collection": "1.1.7",- "@radix-ui/react-compose-refs": "1.1.2",- "@radix-ui/react-context": "1.1.2",- "@radix-ui/react-direction": "1.1.1",- "@radix-ui/react-id": "1.1.1",- "@radix-ui/react-primitive": "2.1.3",- "@radix-ui/react-use-controllable-state": "1.2.2"- },- "peerDependencies": {- "@types/react": "*",- "@types/react-dom": "*",- "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",- "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"- },- "peerDependenciesMeta": {- "@types/react": {- "optional": true- },- "@types/react-dom": {- "optional": true- }- }- },"node_modules/@radix-ui/react-arrow": {"version": "1.1.7","resolved": "https://registry.npmjs.org/@radix-ui/react-arrow/-/react-arrow-1.1.7.tgz",@@ -2171,36 +2164,6 @@}}},- "node_modules/@radix-ui/react-collapsible": {- "version": "1.1.12",- "resolved": "https://registry.npmjs.org/@radix-ui/react-collapsible/-/react-collapsible-1.1.12.tgz",- "integrity": "sha512-Uu+mSh4agx2ib1uIGPP4/CKNULyajb3p92LsVXmH2EHVMTfZWpll88XJ0j4W0z3f8NK1eYl1+Mf/szHPmcHzyA==",- "license": "MIT",- "dependencies": {- "@radix-ui/primitive": "1.1.3",- "@radix-ui/react-compose-refs": "1.1.2",- "@radix-ui/react-context": "1.1.2",- "@radix-ui/react-id": "1.1.1",- "@radix-ui/react-presence": "1.1.5",- "@radix-ui/react-primitive": "2.1.3",- "@radix-ui/react-use-controllable-state": "1.2.2",- "@radix-ui/react-use-layout-effect": "1.1.1"- },- "peerDependencies": {- "@types/react": "*",- "@types/react-dom": "*",- "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",- "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"- },- "peerDependenciesMeta": {- "@types/react": {- "optional": true- },- "@types/react-dom": {- "optional": true- }- }- },"node_modules/@radix-ui/react-collection": {"version": "1.1.7","resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.1.7.tgz",@@ -2371,35 +2334,6 @@}}},- "node_modules/@radix-ui/react-dropdown-menu": {- "version": "2.1.16",- "resolved": "https://registry.npmjs.org/@radix-ui/react-dropdown-menu/-/react-dropdown-menu-2.1.16.tgz",- "integrity": "sha512-1PLGQEynI/3OX/ftV54COn+3Sud/Mn8vALg2rWnBLnRaGtJDduNW/22XjlGgPdpcIbiQxjKtb7BkcjP00nqfJw==",- "license": "MIT",- "dependencies": {- "@radix-ui/primitive": "1.1.3",- "@radix-ui/react-compose-refs": "1.1.2",- "@radix-ui/react-context": "1.1.2",- "@radix-ui/react-id": "1.1.1",- "@radix-ui/react-menu": "2.1.16",- "@radix-ui/react-primitive": "2.1.3",- "@radix-ui/react-use-controllable-state": "1.2.2"- },- "peerDependencies": {- "@types/react": "*",- "@types/react-dom": "*",- "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",- "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"- },- "peerDependenciesMeta": {- "@types/react": {- "optional": true- },- "@types/react-dom": {- "optional": true- }- }- },"node_modules/@radix-ui/react-focus-guards": {"version": "1.1.3","resolved": "https://registry.npmjs.org/@radix-ui/react-focus-guards/-/react-focus-guards-1.1.3.tgz",@@ -2440,94 +2374,21 @@}}},- "node_modules/@radix-ui/react-id": {- "version": "1.1.1",- "resolved": "https://registry.npmjs.org/@radix-ui/react-id/-/react-id-1.1.1.tgz",- "integrity": "sha512-kGkGegYIdQsOb4XjsfM97rXsiHaBwco+hFI66oO4s9LU+PLAC5oJ7khdOVFxkhsmlbpUqDAvXw11CluXP+jkHg==",- "license": "MIT",- "dependencies": {- "@radix-ui/react-use-layout-effect": "1.1.1"- },- "peerDependencies": {- "@types/react": "*",- "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"- },- "peerDependenciesMeta": {- "@types/react": {- "optional": true- }- }- },- "node_modules/@radix-ui/react-label": {- "version": "2.1.8",- "resolved": "https://registry.npmjs.org/@radix-ui/react-label/-/react-label-2.1.8.tgz",- "integrity": "sha512-FmXs37I6hSBVDlO4y764TNz1rLgKwjJMQ0EGte6F3Cb3f4bIuHB/iLa/8I9VKkmOy+gNHq8rql3j686ACVV21A==",- "license": "MIT",- "dependencies": {- "@radix-ui/react-primitive": "2.1.4"- },- "peerDependencies": {- "@types/react": "*",- "@types/react-dom": "*",- "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",- "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"- },- "peerDependenciesMeta": {- "@types/react": {- "optional": true- },- "@types/react-dom": {- "optional": true- }- }- },- "node_modules/@radix-ui/react-label/node_modules/@radix-ui/react-primitive": {- "version": "2.1.4",- "resolved": "https://registry.npmjs.org/@radix-ui/react-primitive/-/react-primitive-2.1.4.tgz",- "integrity": "sha512-9hQc4+GNVtJAIEPEqlYqW5RiYdrr8ea5XQ0ZOnD6fgru+83kqT15mq2OCcbe8KnjRZl5vF3ks69AKz3kh1jrhg==",- "license": "MIT",- "dependencies": {- "@radix-ui/react-slot": "1.2.4"- },- "peerDependencies": {- "@types/react": "*",- "@types/react-dom": "*",- "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",- "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"- },- "peerDependenciesMeta": {- "@types/react": {- "optional": true- },- "@types/react-dom": {- "optional": true- }- }- },- "node_modules/@radix-ui/react-menu": {- "version": "2.1.16",- "resolved": "https://registry.npmjs.org/@radix-ui/react-menu/-/react-menu-2.1.16.tgz",- "integrity": "sha512-72F2T+PLlphrqLcAotYPp0uJMr5SjP5SL01wfEspJbru5Zs5vQaSHb4VB3ZMJPimgHHCHG7gMOeOB9H3Hdmtxg==",+ "node_modules/@radix-ui/react-hover-card": {+ "version": "1.1.15",+ "resolved": "https://registry.npmjs.org/@radix-ui/react-hover-card/-/react-hover-card-1.1.15.tgz",+ "integrity": "sha512-qgTkjNT1CfKMoP0rcasmlH2r1DAiYicWsDsufxl940sT2wHNEWWv6FMWIQXWhVdmC1d/HYfbhQx60KYyAtKxjg==","license": "MIT","dependencies": {"@radix-ui/primitive": "1.1.3",- "@radix-ui/react-collection": "1.1.7","@radix-ui/react-compose-refs": "1.1.2","@radix-ui/react-context": "1.1.2",- "@radix-ui/react-direction": "1.1.1","@radix-ui/react-dismissable-layer": "1.1.11",- "@radix-ui/react-focus-guards": "1.1.3",- "@radix-ui/react-focus-scope": "1.1.7",- "@radix-ui/react-id": "1.1.1","@radix-ui/react-popper": "1.2.8","@radix-ui/react-portal": "1.1.9","@radix-ui/react-presence": "1.1.5","@radix-ui/react-primitive": "2.1.3",- "@radix-ui/react-roving-focus": "1.1.11",- "@radix-ui/react-slot": "1.2.3",- "@radix-ui/react-use-callback-ref": "1.1.1",- "aria-hidden": "^1.2.4",- "react-remove-scroll": "^2.6.3"+ "@radix-ui/react-use-controllable-state": "1.2.2"},"peerDependencies": {"@types/react": "*",@@ -2544,13 +2405,13 @@}}},- "node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-slot": {- "version": "1.2.3",- "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz",- "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==",+ "node_modules/@radix-ui/react-id": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/@radix-ui/react-id/-/react-id-1.1.1.tgz",+ "integrity": "sha512-kGkGegYIdQsOb4XjsfM97rXsiHaBwco+hFI66oO4s9LU+PLAC5oJ7khdOVFxkhsmlbpUqDAvXw11CluXP+jkHg==","license": "MIT","dependencies": {- "@radix-ui/react-compose-refs": "1.1.2"+ "@radix-ui/react-use-layout-effect": "1.1.1"},"peerDependencies": {"@types/react": "*",@@ -2562,27 +2423,13 @@}}},- "node_modules/@radix-ui/react-popover": {- "version": "1.1.15",- "resolved": "https://registry.npmjs.org/@radix-ui/react-popover/-/react-popover-1.1.15.tgz",- "integrity": "sha512-kr0X2+6Yy/vJzLYJUPCZEc8SfQcf+1COFoAqauJm74umQhta9M7lNJHP7QQS3vkvcGLQUbWpMzwrXYwrYztHKA==",+ "node_modules/@radix-ui/react-label": {+ "version": "2.1.8",+ "resolved": "https://registry.npmjs.org/@radix-ui/react-label/-/react-label-2.1.8.tgz",+ "integrity": "sha512-FmXs37I6hSBVDlO4y764TNz1rLgKwjJMQ0EGte6F3Cb3f4bIuHB/iLa/8I9VKkmOy+gNHq8rql3j686ACVV21A==","license": "MIT","dependencies": {- "@radix-ui/primitive": "1.1.3",- "@radix-ui/react-compose-refs": "1.1.2",- "@radix-ui/react-context": "1.1.2",- "@radix-ui/react-dismissable-layer": "1.1.11",- "@radix-ui/react-focus-guards": "1.1.3",- "@radix-ui/react-focus-scope": "1.1.7",- "@radix-ui/react-id": "1.1.1",- "@radix-ui/react-popper": "1.2.8",- "@radix-ui/react-portal": "1.1.9",- "@radix-ui/react-presence": "1.1.5",- "@radix-ui/react-primitive": "2.1.3",- "@radix-ui/react-slot": "1.2.3",- "@radix-ui/react-use-controllable-state": "1.2.2",- "aria-hidden": "^1.2.4",- "react-remove-scroll": "^2.6.3"+ "@radix-ui/react-primitive": "2.1.4"},"peerDependencies": {"@types/react": "*",@@ -2599,21 +2446,26 @@}}},- "node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-slot": {- "version": "1.2.3",- "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz",- "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==",+ "node_modules/@radix-ui/react-label/node_modules/@radix-ui/react-primitive": {+ "version": "2.1.4",+ "resolved": "https://registry.npmjs.org/@radix-ui/react-primitive/-/react-primitive-2.1.4.tgz",+ "integrity": "sha512-9hQc4+GNVtJAIEPEqlYqW5RiYdrr8ea5XQ0ZOnD6fgru+83kqT15mq2OCcbe8KnjRZl5vF3ks69AKz3kh1jrhg==","license": "MIT","dependencies": {- "@radix-ui/react-compose-refs": "1.1.2"+ "@radix-ui/react-slot": "1.2.4"},"peerDependencies": {"@types/react": "*",- "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"+ "@types/react-dom": "*",+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"},"peerDependenciesMeta": {"@types/react": {"optional": true+ },+ "@types/react-dom": {+ "optional": true}}},@@ -3079,60 +2931,6 @@}}},- "node_modules/@radix-ui/react-toggle": {- "version": "1.1.10",- "resolved": "https://registry.npmjs.org/@radix-ui/react-toggle/-/react-toggle-1.1.10.tgz",- "integrity": "sha512-lS1odchhFTeZv3xwHH31YPObmJn8gOg7Lq12inrr0+BH/l3Tsq32VfjqH1oh80ARM3mlkfMic15n0kg4sD1poQ==",- "license": "MIT",- "dependencies": {- "@radix-ui/primitive": "1.1.3",- "@radix-ui/react-primitive": "2.1.3",- "@radix-ui/react-use-controllable-state": "1.2.2"- },- "peerDependencies": {- "@types/react": "*",- "@types/react-dom": "*",- "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",- "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"- },- "peerDependenciesMeta": {- "@types/react": {- "optional": true- },- "@types/react-dom": {- "optional": true- }- }- },- "node_modules/@radix-ui/react-toggle-group": {- "version": "1.1.11",- "resolved": "https://registry.npmjs.org/@radix-ui/react-toggle-group/-/react-toggle-group-1.1.11.tgz",- "integrity": "sha512-5umnS0T8JQzQT6HbPyO7Hh9dgd82NmS36DQr+X/YJ9ctFNCiiQd6IJAYYZ33LUwm8M+taCz5t2ui29fHZc4Y6Q==",- "license": "MIT",- "dependencies": {- "@radix-ui/primitive": "1.1.3",- "@radix-ui/react-context": "1.1.2",- "@radix-ui/react-direction": "1.1.1",- "@radix-ui/react-primitive": "2.1.3",- "@radix-ui/react-roving-focus": "1.1.11",- "@radix-ui/react-toggle": "1.1.10",- "@radix-ui/react-use-controllable-state": "1.2.2"- },- "peerDependencies": {- "@types/react": "*",- "@types/react-dom": "*",- "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",- "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"- },- "peerDependenciesMeta": {- "@types/react": {- "optional": true- },- "@types/react-dom": {- "optional": true- }- }- },"node_modules/@radix-ui/react-tooltip": {"version": "1.2.8","resolved": "https://registry.npmjs.org/@radix-ui/react-tooltip/-/react-tooltip-1.2.8.tgz",@@ -14720,9 +14518,10 @@},"packages/ui": {"name": "@repowise-dev/ui",- "version": "0.0.1",+ "version": "0.1.0","dependencies": {"@radix-ui/react-dialog": "^1.1.15",+ "@radix-ui/react-hover-card": "^1.1.15","@radix-ui/react-label": "^2.1.8","@radix-ui/react-progress": "^1.1.8","@radix-ui/react-scroll-area": "^1.2.10",@@ -14740,6 +14539,7 @@"clsx": "^2.1.1","d3-force": "^3.0.0","d3-hierarchy": "^3.1.2",+ "elkjs": "^0.11.1","framer-motion": "^11.11.0","fuse.js": "^7.0.0","graphology": "^0.26.0",@@ -14852,37 +14652,13 @@"name": "repowise-web","version": "0.3.0","dependencies": {- "@radix-ui/react-accordion": "^1.2.0",- "@radix-ui/react-dialog": "^1.1.0",- "@radix-ui/react-dropdown-menu": "^2.1.0",- "@radix-ui/react-label": "^2.1.8",- "@radix-ui/react-popover": "^1.1.0",- "@radix-ui/react-progress": "^1.1.8",- "@radix-ui/react-scroll-area": "^1.2.0",- "@radix-ui/react-select": "^2.1.0",- "@radix-ui/react-separator": "^1.1.0",- "@radix-ui/react-slider": "^1.3.6",- "@radix-ui/react-slot": "^1.1.0",- "@radix-ui/react-switch": "^1.2.6",- "@radix-ui/react-tabs": "^1.1.0",- "@radix-ui/react-toggle": "^1.1.0",- "@radix-ui/react-toggle-group": "^1.1.0",- "@radix-ui/react-tooltip": "^1.1.0","@repowise-dev/types": "*","@repowise-dev/ui": "*",- "@xyflow/react": "^12.10.2",- "class-variance-authority": "^0.7.1","clsx": "^2.1.1","cmdk": "^1.0.0",- "d3": "^7.9.0",- "d3-force": "^3.0.0",- "d3-hierarchy": "^3.1.2",- "elkjs": "^0.11.1","framer-motion": "^11.11.0",- "fuse.js": "^7.0.0","geist": "^1.3.0","lucide-react": "^0.460.0",- "mermaid": "^11.4.0","next": "~15.5.15","next-mdx-remote": "^6.0.0","nuqs": "^2.2.0",diff --git a/packages/ui/package.json b/packages/ui/package.jsonindex 2e9f55dad..3962f1380 100644--- a/packages/ui/package.json+++ b/packages/ui/package.json@@ -45,9 +45,19 @@"./jobs/*": "./src/jobs/*.tsx","./blast-radius": "./src/blast-radius/index.ts","./blast-radius/*": "./src/blast-radius/*.tsx",+ "./costs": "./src/costs/index.ts",+ "./costs/*": "./src/costs/*.tsx",+ "./security": "./src/security/index.ts",+ "./security/*": "./src/security/*.tsx",+ "./onboarding": "./src/onboarding/index.ts",+ "./onboarding/*": "./src/onboarding/*.tsx","./settings": "./src/settings/index.ts","./settings/*": "./src/settings/*.tsx","./shared": "./src/shared/index.ts",+ "./shared/entity": "./src/shared/entity/index.ts",+ "./shared/context-drawer": "./src/shared/context-drawer/index.ts",+ "./shared/file-card": "./src/shared/file-card/index.ts",+ "./shared/related": "./src/shared/related/index.ts","./shared/*": "./src/shared/*.tsx","./hooks": "./src/hooks/index.ts","./ui": "./src/ui/index.ts",@@ -67,6 +77,7 @@},"dependencies": {"@radix-ui/react-dialog": "^1.1.15",+ "@radix-ui/react-hover-card": "^1.1.15","@radix-ui/react-label": "^2.1.8","@radix-ui/react-progress": "^1.1.8","@radix-ui/react-scroll-area": "^1.2.10",diff --git a/packages/ui/src/chat/tool-call-block.tsx b/packages/ui/src/chat/tool-call-block.tsxindex 99ffaae2a..34ebf9ff9 100644--- a/packages/ui/src/chat/tool-call-block.tsx+++ b/packages/ui/src/chat/tool-call-block.tsx@@ -27,44 +27,44 @@ export function ToolCallBlock({ toolCall, onViewArtifact }: ToolCallBlockProps)return (<div className="my-1.5 rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] text-xs overflow-hidden">- <button- className="flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-[var(--color-bg-overlay)] transition-colors"- onClick={() => !isRunning && setExpanded((e) => !e)}- >- {isRunning ? (- <Loader2 className="h-3.5 w-3.5 animate-spin text-[var(--color-accent-primary)] shrink-0" />- ) : (- <CheckCircle2 className="h-3.5 w-3.5 text-green-400 shrink-0" />- )}- <span className="font-medium text-[var(--color-text-secondary)]">- {label}- </span>- {toolCall.summary && !isRunning && (- <span className="text-[var(--color-text-tertiary)] truncate ml-1">- — {toolCall.summary}- </span>- )}- <span className="ml-auto flex items-center gap-1">+ <div className="flex items-center gap-2 px-3 py-2 hover:bg-[var(--color-bg-overlay)] transition-colors">+ <button+ type="button"+ className="flex flex-1 min-w-0 items-center gap-2 text-left"+ onClick={() => !isRunning && setExpanded((e) => !e)}+ disabled={isRunning}+ aria-expanded={expanded}+ >+ {isRunning ? (+ <Loader2 className="h-3.5 w-3.5 animate-spin text-[var(--color-accent-primary)] shrink-0" />+ ) : (+ <CheckCircle2 className="h-3.5 w-3.5 text-green-400 shrink-0" />+ )}+ <span className="font-medium text-[var(--color-text-secondary)]">{label}</span>+ {toolCall.summary && !isRunning && (+ <span className="text-[var(--color-text-tertiary)] truncate ml-1">+ — {toolCall.summary}+ </span>+ )}+ </button>+ <span className="ml-auto flex items-center gap-1 shrink-0">{toolCall.artifact && onViewArtifact && !isRunning && (<button- onClick={(e) => {- e.stopPropagation();- onViewArtifact();- }}+ type="button"+ onClick={onViewArtifact}className="text-[var(--color-accent-primary)] hover:underline flex items-center gap-0.5">View <ExternalLink className="h-3 w-3" /></button>)}- {!isRunning && (- expanded ? (+ {!isRunning &&+ (expanded ? (<ChevronDown className="h-3 w-3 text-[var(--color-text-tertiary)]" />) : (<ChevronRight className="h-3 w-3 text-[var(--color-text-tertiary)]" />- )- )}+ ))}</span>- </button>+ </div>{expanded && (<div className="border-t border-[var(--color-border-default)] px-3 py-2 space-y-2">diff --git a/packages/ui/src/costs/cache-hit-ratio-card.tsx b/packages/ui/src/costs/cache-hit-ratio-card.tsxnew file mode 100644index 000000000..2e45965d0--- /dev/null+++ b/packages/ui/src/costs/cache-hit-ratio-card.tsx@@ -0,0 +1,91 @@+"use client";++import { Zap } from "lucide-react";+import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";+import { formatCost } from "../lib/format";++export interface CacheHitRatioCardProps {+ /** Optional metric — when missing, the card renders a neutral "not yet wired" state. */+ metrics?: {+ hits: number;+ misses: number;+ estimated_savings_usd: number;+ };+}++export function CacheHitRatioCard({ metrics }: CacheHitRatioCardProps) {+ const total = metrics ? metrics.hits + metrics.misses : 0;+ const ratio = total > 0 ? (metrics!.hits / total) * 100 : 0;+ const dasharray = `${(ratio / 100) * 188.5} 188.5`;++ return (+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm flex items-center gap-2">+ <Zap className="h-4 w-4 text-yellow-500" />+ Cache hits & savings+ </CardTitle>+ </CardHeader>+ <CardContent className="pt-0">+ <div className="flex items-center gap-5">+ <svg width={80} height={80} viewBox="0 0 80 80" className="shrink-0 -rotate-90">+ <circle+ cx={40}+ cy={40}+ r={30}+ fill="none"+ strokeWidth={10}+ stroke="var(--color-bg-inset)"+ />+ {metrics && (+ <circle+ cx={40}+ cy={40}+ r={30}+ fill="none"+ strokeWidth={10}+ stroke="var(--color-accent-primary)"+ strokeDasharray={dasharray}+ strokeLinecap="round"+ />+ )}+ <text+ x={40}+ y={45}+ textAnchor="middle"+ transform="rotate(90 40 40)"+ className="fill-[var(--color-text-primary)]"+ fontSize={metrics ? 16 : 11}+ fontWeight={600}+ >+ {metrics ? `${Math.round(ratio)}%` : "—"}+ </text>+ </svg>+ <div className="space-y-1 min-w-0">+ {metrics ? (+ <>+ <div className="text-xs text-[var(--color-text-secondary)]">+ <span className="font-medium text-[var(--color-text-primary)] tabular-nums">+ {metrics.hits.toLocaleString()}+ </span>{" "}+ hits / {total.toLocaleString()} calls+ </div>+ <div className="text-xs text-[var(--color-text-secondary)]">+ Estimated savings:{" "}+ <span className="font-medium text-green-500 tabular-nums">+ {formatCost(metrics.estimated_savings_usd)}+ </span>+ </div>+ </>+ ) : (+ <p className="text-xs text-[var(--color-text-tertiary)] leading-snug max-w-[260px]">+ Cache analytics not wired yet — once provider cache stats land we'll show+ hit ratio and dollar savings here.+ </p>+ )}+ </div>+ </div>+ </CardContent>+ </Card>+ );+}diff --git a/packages/ui/src/costs/cost-heatmap.tsx b/packages/ui/src/costs/cost-heatmap.tsxnew file mode 100644index 000000000..0c8ec29db--- /dev/null+++ b/packages/ui/src/costs/cost-heatmap.tsx@@ -0,0 +1,74 @@+"use client";++import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";+import { formatCost } from "../lib/format";++export interface CostHeatmapProps {+ /** Operation- or model-grouped cost data. */+ groups: Array<{ group: string; cost_usd: number; calls: number }>;+ title?: string;+ emptyHint?: string;+}++/**+ * Treemap-style cost visualizer using flexbox basis. Lightweight stand-in for+ * the per-directory heatmap until backend exposes file_path grouping.+ */+export function CostHeatmap({ groups, title = "Cost concentration", emptyHint }: CostHeatmapProps) {+ const sorted = [...groups].filter((g) => g.cost_usd > 0).sort((a, b) => b.cost_usd - a.cost_usd);+ const total = sorted.reduce((s, g) => s + g.cost_usd, 0);++ if (sorted.length === 0 || total === 0) {+ return (+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">{title}</CardTitle>+ </CardHeader>+ <CardContent className="pt-0">+ <p className="text-xs text-[var(--color-text-secondary)] py-6 text-center">+ {emptyHint ?? "No cost data to visualize yet."}+ </p>+ </CardContent>+ </Card>+ );+ }++ const top = sorted.slice(0, 12);+ const max = top[0]?.cost_usd ?? 1;+ const min = top[top.length - 1]?.cost_usd ?? 0;+ const range = Math.max(1e-9, max - min);++ return (+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">{title}</CardTitle>+ </CardHeader>+ <CardContent className="pt-0">+ <div className="flex flex-wrap gap-1.5">+ {top.map((g) => {+ const pctOfMax = g.cost_usd / max;+ const intensity = 0.18 + 0.7 * ((g.cost_usd - min) / range);+ const basis = `${Math.max(80, Math.round(pctOfMax * 280))}px`;+ const height = `${Math.max(48, Math.round(pctOfMax * 96))}px`;+ return (+ <div+ key={g.group}+ className="rounded-md border border-[var(--color-border-default)] p-2 flex flex-col justify-between transition-colors hover:border-[var(--color-accent-primary)]"+ style={{+ flexBasis: basis,+ flexGrow: 1,+ height,+ backgroundColor: `rgba(244, 63, 94, ${intensity.toFixed(3)})`,+ }}+ title={`${g.group} — ${formatCost(g.cost_usd)} (${g.calls} calls)`}+ >+ <span className="text-[10px] font-mono text-white/90 truncate">{g.group}</span>+ <span className="text-[10px] text-white/80 tabular-nums">{formatCost(g.cost_usd)}</span>+ </div>+ );+ })}+ </div>+ </CardContent>+ </Card>+ );+}diff --git a/packages/ui/src/costs/index.ts b/packages/ui/src/costs/index.tsnew file mode 100644index 000000000..909a25c03--- /dev/null+++ b/packages/ui/src/costs/index.ts@@ -0,0 +1,8 @@+export { OperationBreakdown } from "./operation-breakdown";+export type { OperationBreakdownProps } from "./operation-breakdown";+export { ProviderComparison } from "./provider-comparison";+export type { ProviderComparisonProps } from "./provider-comparison";+export { CostHeatmap } from "./cost-heatmap";+export type { CostHeatmapProps } from "./cost-heatmap";+export { CacheHitRatioCard } from "./cache-hit-ratio-card";+export type { CacheHitRatioCardProps } from "./cache-hit-ratio-card";diff --git a/packages/ui/src/costs/operation-breakdown.tsx b/packages/ui/src/costs/operation-breakdown.tsxnew file mode 100644index 000000000..58d2aef15--- /dev/null+++ b/packages/ui/src/costs/operation-breakdown.tsx@@ -0,0 +1,87 @@+"use client";++import { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer, Cell } from "recharts";+import { formatCost } from "../lib/format";++export interface OperationBreakdownProps {+ groups: Array<{+ group: string;+ calls: number;+ input_tokens: number;+ output_tokens: number;+ cost_usd: number;+ }>;+ /** Bar color (defaults to accent-primary). */+ color?: string;+ /** Override the dataKey used for bar height. */+ metric?: "cost_usd" | "calls" | "input_tokens" | "output_tokens";+}++const PALETTE = [+ "var(--color-accent-primary)",+ "var(--color-lang-python)",+ "var(--color-lang-typescript)",+ "var(--color-lang-go)",+ "var(--color-lang-rust)",+ "var(--color-lang-java)",+ "var(--color-lang-cpp)",+ "var(--color-lang-other)",+];++export function OperationBreakdown({ groups, metric = "cost_usd" }: OperationBreakdownProps) {+ const sorted = [...groups].sort((a, b) => (b[metric] ?? 0) - (a[metric] ?? 0)).slice(0, 12);+ if (sorted.length === 0) {+ return (+ <p className="text-sm text-[var(--color-text-secondary)] py-8 text-center">+ No data to break down.+ </p>+ );+ }++ return (+ <ResponsiveContainer width="100%" height={Math.max(180, sorted.length * 24 + 40)}>+ <BarChart+ data={sorted}+ layout="vertical"+ margin={{ top: 4, right: 16, bottom: 0, left: 8 }}+ >+ <XAxis+ type="number"+ tick={{ fill: "var(--color-text-tertiary)", fontSize: 10 }}+ axisLine={false}+ tickLine={false}+ tickFormatter={(v: number) => (metric === "cost_usd" ? `$${v.toFixed(3)}` : String(v))}+ />+ <YAxis+ type="category"+ dataKey="group"+ tick={{ fill: "var(--color-text-secondary)", fontSize: 11 }}+ axisLine={false}+ tickLine={false}+ width={140}+ />+ <Tooltip+ cursor={{ fill: "var(--color-bg-elevated)" }}+ contentStyle={{+ background: "var(--color-bg-overlay)",+ border: "1px solid var(--color-border-default)",+ borderRadius: 6,+ fontSize: 12,+ color: "var(--color-text-primary)",+ }}+ formatter={(value) => {+ const n = typeof value === "number" ? value : 0;+ return metric === "cost_usd"+ ? [formatCost(n), "Cost"]+ : [n.toLocaleString(), metric.replace("_", " ")];+ }}+ />+ <Bar dataKey={metric} radius={[0, 4, 4, 0]}>+ {sorted.map((row, i) => (+ <Cell key={row.group} fill={PALETTE[i % PALETTE.length] ?? "var(--color-accent-primary)"} />+ ))}+ </Bar>+ </BarChart>+ </ResponsiveContainer>+ );+}diff --git a/packages/ui/src/costs/provider-comparison.tsx b/packages/ui/src/costs/provider-comparison.tsxnew file mode 100644index 000000000..79eafafef--- /dev/null+++ b/packages/ui/src/costs/provider-comparison.tsx@@ -0,0 +1,96 @@+"use client";++import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";+import { formatCost, formatTokens } from "../lib/format";++const PROVIDER_PATTERNS: Array<{ provider: string; match: RegExp; color: string }> = [+ { provider: "Anthropic", match: /^claude/i, color: "#d97757" },+ { provider: "OpenAI", match: /^(gpt|o\d|chatgpt)/i, color: "#10a37f" },+ { provider: "Google", match: /^gemini/i, color: "#4285f4" },+ { provider: "Mistral", match: /^(mistral|mixtral|codestral)/i, color: "#fa520f" },+ { provider: "DeepSeek", match: /^deepseek/i, color: "#4d6bfe" },+ { provider: "Groq", match: /^(groq|llama)/i, color: "#f55036" },+ { provider: "Other", match: /.*/, color: "var(--color-lang-other)" },+];++function classifyProvider(model: string): { provider: string; color: string } {+ for (const p of PROVIDER_PATTERNS) {+ if (p.match.test(model)) return { provider: p.provider, color: p.color };+ }+ return { provider: "Other", color: "var(--color-lang-other)" };+}++export interface ProviderComparisonProps {+ modelGroups: Array<{+ group: string; // model name+ calls: number;+ input_tokens: number;+ output_tokens: number;+ cost_usd: number;+ }>;+}++export function ProviderComparison({ modelGroups }: ProviderComparisonProps) {+ const byProvider = new Map<+ string,+ { provider: string; color: string; calls: number; cost_usd: number; tokens: number; models: string[] }+ >();+ for (const m of modelGroups) {+ const { provider, color } = classifyProvider(m.group);+ const cur =+ byProvider.get(provider) ??+ { provider, color, calls: 0, cost_usd: 0, tokens: 0, models: [] };+ cur.calls += m.calls;+ cur.cost_usd += m.cost_usd;+ cur.tokens += m.input_tokens + m.output_tokens;+ cur.models.push(m.group);+ byProvider.set(provider, cur);+ }++ const rows = Array.from(byProvider.values()).sort((a, b) => b.cost_usd - a.cost_usd);+ const maxCost = rows.reduce((m, r) => Math.max(m, r.cost_usd), 0) || 1;++ if (rows.length === 0) {+ return (+ <p className="text-sm text-[var(--color-text-secondary)] py-8 text-center">+ No model data yet.+ </p>+ );+ }++ return (+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Spend by provider</CardTitle>+ </CardHeader>+ <CardContent className="pt-0 space-y-3">+ {rows.map((r) => (+ <div key={r.provider}>+ <div className="flex items-baseline justify-between text-xs">+ <div className="flex items-center gap-2 min-w-0">+ <span className="h-2 w-2 rounded-full shrink-0" style={{ backgroundColor: r.color }} />+ <span className="font-medium text-[var(--color-text-primary)]">{r.provider}</span>+ <span className="text-[var(--color-text-tertiary)] truncate">+ · {r.models.length} model{r.models.length === 1 ? "" : "s"}+ </span>+ </div>+ <span className="tabular-nums text-[var(--color-text-secondary)] ml-2 shrink-0">+ {formatCost(r.cost_usd)}+ </span>+ </div>+ <div className="mt-1 h-2 w-full rounded-full bg-[var(--color-bg-inset)] overflow-hidden">+ <div+ className="h-full rounded-full transition-all"+ style={{ width: `${(r.cost_usd / maxCost) * 100}%`, backgroundColor: r.color }}+ />+ </div>+ <div className="mt-0.5 flex items-center justify-between text-[10px] text-[var(--color-text-tertiary)] tabular-nums">+ <span>{r.calls.toLocaleString()} calls</span>+ <span>{formatTokens(r.tokens)} tokens</span>+ </div>+ </div>+ ))}+ </CardContent>+ </Card>+ );+}diff --git a/packages/ui/src/coverage/confidence-vs-freshness-matrix.tsx b/packages/ui/src/coverage/confidence-vs-freshness-matrix.tsxnew file mode 100644index 000000000..a5d9e2a57--- /dev/null+++ b/packages/ui/src/coverage/confidence-vs-freshness-matrix.tsx@@ -0,0 +1,91 @@+"use client";++import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";+import type { DocPage } from "@repowise-dev/types/docs";++const CONFIDENCE_BUCKETS = [+ { key: "high", label: "High (≥0.8)", min: 0.8 },+ { key: "med", label: "Medium (0.5–0.8)", min: 0.5 },+ { key: "low", label: "Low (<0.5)", min: 0 },+] as const;++const FRESHNESS = ["fresh", "stale", "outdated"] as const;++const CELL_COLORS: Record<string, string> = {+ "high::fresh": "rgba(16, 185, 129, 0.20)",+ "high::stale": "rgba(245, 158, 11, 0.18)",+ "high::outdated": "rgba(239, 68, 68, 0.18)",+ "med::fresh": "rgba(16, 185, 129, 0.10)",+ "med::stale": "rgba(245, 158, 11, 0.10)",+ "med::outdated": "rgba(239, 68, 68, 0.10)",+ "low::fresh": "rgba(16, 185, 129, 0.05)",+ "low::stale": "rgba(245, 158, 11, 0.05)",+ "low::outdated": "rgba(239, 68, 68, 0.05)",+};++export interface ConfidenceVsFreshnessMatrixProps {+ pages: DocPage[];+}++export function ConfidenceVsFreshnessMatrix({ pages }: ConfidenceVsFreshnessMatrixProps) {+ const grid = new Map<string, number>();+ for (const p of pages) {+ const bucket =+ p.confidence >= 0.8 ? "high" : p.confidence >= 0.5 ? "med" : "low";+ const key = `${bucket}::${p.freshness_status}`;+ grid.set(key, (grid.get(key) ?? 0) + 1);+ }++ if (pages.length === 0) {+ return null;+ }++ return (+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Confidence × freshness</CardTitle>+ </CardHeader>+ <CardContent className="pt-0">+ <div className="overflow-x-auto">+ <table className="text-xs w-full">+ <thead>+ <tr>+ <th className="text-left text-[10px] uppercase tracking-wider text-[var(--color-text-tertiary)] py-1.5 font-medium pr-3">+ Confidence \ Freshness+ </th>+ {FRESHNESS.map((f) => (+ <th+ key={f}+ className="text-left text-[10px] uppercase tracking-wider text-[var(--color-text-tertiary)] py-1.5 font-medium px-3 capitalize"+ >+ {f}+ </th>+ ))}+ </tr>+ </thead>+ <tbody>+ {CONFIDENCE_BUCKETS.map((b) => (+ <tr key={b.key}>+ <td className="py-1.5 pr-3 text-[var(--color-text-secondary)]">{b.label}</td>+ {FRESHNESS.map((f) => {+ const key = `${b.key}::${f}`;+ const n = grid.get(key) ?? 0;+ return (+ <td+ key={f}+ className="rounded border border-[var(--color-border-default)] py-2 px-3 align-top tabular-nums font-medium text-[var(--color-text-primary)]"+ style={{ backgroundColor: CELL_COLORS[key] ?? "transparent" }}+ >+ {n}+ </td>+ );+ })}+ </tr>+ ))}+ </tbody>+ </table>+ </div>+ </CardContent>+ </Card>+ );+}diff --git a/packages/ui/src/coverage/drift-banner.tsx b/packages/ui/src/coverage/drift-banner.tsxnew file mode 100644index 000000000..57d1584ee--- /dev/null+++ b/packages/ui/src/coverage/drift-banner.tsx@@ -0,0 +1,34 @@+"use client";++import { AlertTriangle } from "lucide-react";+import type { DocPage } from "@repowise-dev/types/docs";++export interface DriftBannerProps {+ pages: DocPage[];+ /** Inclusive — shown only when count > threshold (default 0). */+ threshold?: number;+}++export function DriftBanner({ pages, threshold = 0 }: DriftBannerProps) {+ const drift = pages.filter((p) => p.freshness_status === "outdated").length;+ const stale = pages.filter((p) => p.freshness_status === "stale").length;+ const total = drift + stale;+ if (total <= threshold) return null;++ return (+ <div+ role="status"+ className="flex items-start gap-3 rounded-lg border border-amber-500/40 bg-amber-500/10 px-4 py-3"+ >+ <AlertTriangle className="h-5 w-5 text-amber-400 shrink-0 mt-0.5" />+ <div className="text-sm text-[var(--color-text-primary)]">+ <p className="font-medium">+ {drift} outdated · {stale} stale+ </p>+ <p className="text-xs text-[var(--color-text-secondary)] mt-0.5">+ Source code has moved past the snapshot for these pages. Re-run generation to refresh.+ </p>+ </div>+ </div>+ );+}diff --git a/packages/ui/src/coverage/index.ts b/packages/ui/src/coverage/index.tsindex aeafe718c..750bc9297 100644--- a/packages/ui/src/coverage/index.ts+++ b/packages/ui/src/coverage/index.ts@@ -1,2 +1,4 @@export * from "./coverage-donut.js";export * from "./freshness-table.js";+export * from "./drift-banner.js";+export * from "./confidence-vs-freshness-matrix.js";diff --git a/packages/ui/src/dashboard/health-score-ring.tsx b/packages/ui/src/dashboard/health-score-ring.tsxindex 7273dfed3..b4794b88e 100644--- a/packages/ui/src/dashboard/health-score-ring.tsx+++ b/packages/ui/src/dashboard/health-score-ring.tsx@@ -16,6 +16,13 @@ interface HealthScoreRingProps {score: number;size?: number;components?: HealthScoreComponent[];+ /**+ * Optional note rendered at the top of the score breakdown (e.g.+ * to explain that some components were skipped because docs weren't+ * generated). Surfacing the explanation here keeps `index-only` repos+ * from looking unfairly penalized without bloating the ring itself.+ */+ note?: string;}function getScoreColor(score: number): string {@@ -32,7 +39,7 @@ function getScoreLabel(score: number): string {return "Critical";}-export function HealthScoreRing({ score, size = 160, components }: HealthScoreRingProps) {+export function HealthScoreRing({ score, size = 160, components, note }: HealthScoreRingProps) {const [mounted, setMounted] = useState(false);const [breakdownOpen, setBreakdownOpen] = useState(false);useEffect(() => setMounted(true), []);@@ -105,6 +112,11 @@ export function HealthScoreRing({ score, size = 160, components }: HealthScoreRi<p className="text-[10px] uppercase tracking-wider text-[var(--color-text-tertiary)]">Score = weighted average of {components.length} components</p>+ {note && (+ <p className="rounded-md border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] px-2 py-1.5 text-[11px] leading-snug text-[var(--color-text-secondary)]">+ {note}+ </p>+ )}<ul className="space-y-2">{components.map((c) => {const barColor =diff --git a/packages/ui/src/dead-code/findings-breakdown-grid.tsx b/packages/ui/src/dead-code/findings-breakdown-grid.tsxnew file mode 100644index 000000000..c15d4dc93--- /dev/null+++ b/packages/ui/src/dead-code/findings-breakdown-grid.tsx@@ -0,0 +1,124 @@+"use client";++import * as React from "react";+import { cn } from "../lib/cn";++export interface FindingsBreakdownItem {+ kind: string;+ confidence: number;+}++interface FindingsBreakdownGridProps {+ findings: FindingsBreakdownItem[];+ className?: string;+}++const CONFIDENCE_TIERS = [+ { id: "high", label: "High (≥0.8)", min: 0.8 },+ { id: "med", label: "Medium (0.5–0.8)", min: 0.5 },+ { id: "low", label: "Low (<0.5)", min: 0 },+] as const;++const KIND_LABELS: Record<string, string> = {+ unreachable_file: "Unreachable file",+ unused_export: "Unused export",+ unused_internal: "Unused internal",+ zombie_package: "Zombie package",+};++function tierFor(confidence: number) {+ for (const t of CONFIDENCE_TIERS) if (confidence >= t.min) return t.id;+ return "low";+}++/**+ * Confidence-tier × kind matrix for dead-code findings — surfaces where the+ * concentration is so reviewers know whether to start with high-confidence+ * file removals or low-confidence symbol pruning.+ */+export function FindingsBreakdownGrid({ findings, className }: FindingsBreakdownGridProps) {+ const { kinds, counts, max } = React.useMemo(() => {+ const kindSet = new Set<string>();+ const counts: Record<string, Record<string, number>> = {};+ let max = 0;+ for (const f of findings) {+ const tier = tierFor(f.confidence);+ const kind = f.kind ?? "unknown";+ kindSet.add(kind);+ counts[tier] ??= {};+ counts[tier][kind] = (counts[tier][kind] ?? 0) + 1;+ if (counts[tier][kind] > max) max = counts[tier][kind];+ }+ const ordered = Array.from(kindSet).sort();+ return { kinds: ordered, counts, max };+ }, [findings]);++ if (kinds.length === 0) {+ return (+ <div+ className={cn(+ "rounded-md border border-dashed border-[var(--color-border-default)] p-4 text-center text-xs text-[var(--color-text-tertiary)]",+ className,+ )}+ >+ No findings yet.+ </div>+ );+ }++ return (+ <div+ className={cn(+ "overflow-hidden rounded-md border border-[var(--color-border-default)]",+ className,+ )}+ >+ <table className="w-full border-collapse text-xs">+ <thead>+ <tr className="bg-[var(--color-bg-elevated)]">+ <th className="px-3 py-2 text-left font-medium text-[var(--color-text-tertiary)]">+ Confidence+ </th>+ {kinds.map((k) => (+ <th+ key={k}+ className="px-2 py-2 text-right font-medium text-[var(--color-text-tertiary)]"+ >+ {KIND_LABELS[k] ?? k}+ </th>+ ))}+ </tr>+ </thead>+ <tbody>+ {CONFIDENCE_TIERS.map((tier) => (+ <tr key={tier.id} className="border-t border-[var(--color-border-default)]">+ <td className="px-3 py-2 text-[var(--color-text-secondary)]">{tier.label}</td>+ {kinds.map((k) => {+ const c = counts[tier.id]?.[k] ?? 0;+ const intensity = max > 0 ? c / max : 0;+ const bg =+ c === 0+ ? "transparent"+ : tier.id === "high"+ ? `rgba(244,63,94,${0.12 + intensity * 0.55})`+ : tier.id === "med"+ ? `rgba(245,158,11,${0.10 + intensity * 0.5})`+ : `rgba(148,163,184,${0.08 + intensity * 0.4})`;+ return (+ <td+ key={k}+ className="px-2 py-2 text-right tabular-nums"+ style={{ backgroundColor: bg }}+ title={`${c} ${KIND_LABELS[k] ?? k} at ${tier.label}`}+ >+ {c || ""}+ </td>+ );+ })}+ </tr>+ ))}+ </tbody>+ </table>+ </div>+ );+}diff --git a/packages/ui/src/dead-code/index.ts b/packages/ui/src/dead-code/index.tsindex 77fe19b0d..100caf151 100644--- a/packages/ui/src/dead-code/index.ts+++ b/packages/ui/src/dead-code/index.ts@@ -1 +1,4 @@export * from "./summary-bar.js";+export * from "./safe-to-delete-pile.js";+export * from "./owner-leaderboard.js";+export * from "./findings-breakdown-grid.js";diff --git a/packages/ui/src/dead-code/owner-leaderboard.tsx b/packages/ui/src/dead-code/owner-leaderboard.tsxnew file mode 100644index 000000000..c557a7fb0--- /dev/null+++ b/packages/ui/src/dead-code/owner-leaderboard.tsx@@ -0,0 +1,100 @@+"use client";++import * as React from "react";+import { cn } from "../lib/cn";++export interface OwnerLeaderboardFinding {+ primary_owner: string | null;+ lines: number;+ safe_to_delete?: boolean;+}++interface OwnerLeaderboardProps {+ findings: OwnerLeaderboardFinding[];+ /** Maximum bars to render. Default 8. */+ topN?: number;+ /** Only count safe_to_delete findings. */+ safeOnly?: boolean;+ className?: string;+ onSelect?: (owner: string) => void;+}++/**+ * Bar chart of dead-code lines owned per primary contributor — shows who has+ * the most cleanup leverage. Renders inline (no recharts dep) so the chart+ * stays cheap and resilient to data shape.+ */+export function OwnerLeaderboard({+ findings,+ topN = 8,+ safeOnly = false,+ className,+ onSelect,+}: OwnerLeaderboardProps) {+ const tallies = React.useMemo(() => {+ const map = new Map<string, { lines: number; count: number }>();+ for (const f of findings) {+ if (safeOnly && !f.safe_to_delete) continue;+ const owner = f.primary_owner?.trim() || "Unowned";+ const prev = map.get(owner) ?? { lines: 0, count: 0 };+ prev.lines += Number.isFinite(f.lines) ? f.lines : 0;+ prev.count += 1;+ map.set(owner, prev);+ }+ return Array.from(map.entries())+ .map(([owner, v]) => ({ owner, ...v }))+ .sort((a, b) => b.lines - a.lines)+ .slice(0, topN);+ }, [findings, safeOnly, topN]);++ const max = tallies[0]?.lines ?? 0;++ if (tallies.length === 0) {+ return (+ <div+ className={cn(+ "rounded-md border border-dashed border-[var(--color-border-default)] p-4 text-center text-xs text-[var(--color-text-tertiary)]",+ className,+ )}+ >+ No owner attribution yet — run analysis to populate.+ </div>+ );+ }++ return (+ <ul className={cn("space-y-2", className)}>+ {tallies.map((t) => {+ const widthPct = max > 0 ? Math.max((t.lines / max) * 100, 4) : 0;+ const Tag = onSelect ? "button" : "div";+ return (+ <li key={t.owner}>+ <Tag+ type={onSelect ? "button" : undefined}+ onClick={onSelect ? () => onSelect(t.owner) : undefined}+ className={cn(+ "block w-full text-left",+ onSelect && "transition hover:opacity-90",+ )}+ >+ <div className="flex items-baseline justify-between gap-3 text-xs">+ <span className="truncate text-[var(--color-text-secondary)]" title={t.owner}>+ {t.owner}+ </span>+ <span className="shrink-0 font-mono tabular-nums text-[var(--color-text-tertiary)]">+ {t.lines.toLocaleString()} lines · {t.count}+ </span>+ </div>+ <div className="mt-1 h-1.5 w-full overflow-hidden rounded-full bg-[var(--color-bg-elevated)]">+ <div+ className="h-full rounded-full bg-rose-400/60 transition-[width] duration-300"+ style={{ width: `${widthPct}%` }}+ />+ </div>+ </Tag>+ </li>+ );+ })}+ </ul>+ );+}diff --git a/packages/ui/src/dead-code/safe-to-delete-pile.tsx b/packages/ui/src/dead-code/safe-to-delete-pile.tsxnew file mode 100644index 000000000..7b4fdee89--- /dev/null+++ b/packages/ui/src/dead-code/safe-to-delete-pile.tsx@@ -0,0 +1,125 @@+"use client";++import * as React from "react";+import { Trash2, ArrowRight, Sparkles } from "lucide-react";+import { cn } from "../lib/cn";++export interface SafeToDeletePileFinding {+ id: string;+ file_path: string;+ symbol_name: string | null;+ lines: number;+ confidence: number;+}++interface SafeToDeletePileProps {+ findings: SafeToDeletePileFinding[];+ /** Total lines reclaimable across all safe findings (may differ if filtered). */+ reclaimableLines?: number;+ /** Optional CTA — invoked with the list of finding ids. */+ onPropose?: (findingIds: string[]) => void;+ /**+ * Optional click handler for individual rows — typically opens a context+ * drawer pre-loaded for that file or symbol.+ */+ onSelect?: (finding: SafeToDeletePileFinding) => void;+ className?: string;+}++/**+ * Big visual card highlighting the high-confidence "safe to delete" pile —+ * the demo's punchline for dead-code: "X lines, Y files, click to clean."+ */+export function SafeToDeletePile({+ findings,+ reclaimableLines,+ onPropose,+ onSelect,+ className,+}: SafeToDeletePileProps) {+ const lines =+ reclaimableLines ??+ findings.reduce((sum, f) => sum + (Number.isFinite(f.lines) ? f.lines : 0), 0);+ const files = new Set(findings.map((f) => f.file_path)).size;++ const top = React.useMemo(+ () => [...findings].sort((a, b) => b.lines - a.lines).slice(0, 5),+ [findings],+ );++ return (+ <div+ className={cn(+ "rounded-xl border border-rose-500/30 bg-gradient-to-br from-rose-500/10 via-[var(--color-bg-elevated)] to-[var(--color-bg-elevated)]",+ "p-5 shadow-sm",+ className,+ )}+ >+ <div className="flex items-start gap-4">+ <div className="rounded-lg bg-rose-500/15 p-2.5 text-rose-400 shrink-0">+ <Trash2 className="h-5 w-5" />+ </div>+ <div className="flex-1 min-w-0">+ <div className="flex flex-wrap items-baseline gap-x-3 gap-y-1">+ <span className="text-3xl font-semibold tabular-nums text-[var(--color-text-primary)]">+ {lines.toLocaleString()}+ </span>+ <span className="text-sm text-[var(--color-text-secondary)]">lines safe to delete</span>+ </div>+ <p className="mt-1 text-xs text-[var(--color-text-tertiary)]">+ High-confidence findings across <span className="font-medium">{files}</span> file+ {files === 1 ? "" : "s"} ({findings.length} finding{findings.length === 1 ? "" : "s"}).+ </p>+ </div>+ {onPropose && findings.length > 0 && (+ <button+ type="button"+ onClick={() => onPropose(findings.map((f) => f.id))}+ className={cn(+ "inline-flex items-center gap-1.5 rounded-md border border-rose-500/40 bg-rose-500/10 px-3 py-1.5",+ "text-xs font-medium text-rose-300 transition hover:bg-rose-500/20",+ )}+ >+ <Sparkles className="h-3.5 w-3.5" />+ Propose cleanup+ </button>+ )}+ </div>++ {top.length > 0 && (+ <ul className="mt-4 grid gap-1.5">+ {top.map((f) => {+ const Tag = onSelect ? "button" : "div";+ return (+ <li key={f.id}>+ <Tag+ type={onSelect ? "button" : undefined}+ onClick={onSelect ? () => onSelect(f) : undefined}+ className={cn(+ "flex w-full items-center justify-between gap-3 rounded-md border border-transparent px-2 py-1.5",+ "text-left text-xs transition",+ onSelect && "hover:border-[var(--color-border-default)] hover:bg-[var(--color-bg-surface)]",+ )}+ >+ <span+ className="font-mono text-[11px] text-[var(--color-text-secondary)] truncate"+ title={f.symbol_name ? `${f.file_path} :: ${f.symbol_name}` : f.file_path}+ >+ {f.file_path}+ {f.symbol_name ? (+ <span className="text-[var(--color-text-tertiary)]"> :: {f.symbol_name}</span>+ ) : null}+ </span>+ <span className="shrink-0 font-mono tabular-nums text-[var(--color-text-tertiary)]">+ {f.lines.toLocaleString()} lines+ {onSelect && <ArrowRight className="ml-1 inline h-3 w-3" />}+ </span>+ </Tag>+ </li>+ );+ })}+ </ul>+ )}+ </div>+ );+}diff --git a/packages/ui/src/git/churn-vs-bus-factor-scatter.tsx b/packages/ui/src/git/churn-vs-bus-factor-scatter.tsxnew file mode 100644index 000000000..511bcd0c3--- /dev/null+++ b/packages/ui/src/git/churn-vs-bus-factor-scatter.tsx@@ -0,0 +1,183 @@+"use client";++import * as React from "react";+import { cn } from "../lib/cn";++export interface ScatterHotspot {+ file_path: string;+ churn_percentile: number;+ commit_count_90d: number;+ bus_factor: number;+ primary_owner?: string | null;+}++interface ChurnVsBusFactorScatterProps {+ hotspots: ScatterHotspot[];+ className?: string;+ onSelect?: (filePath: string) => void;+ height?: number;+}++/**+ * Bubble scatter: x = churn percentile (urgency), y = inverse bus factor+ * (knowledge concentration). Top-right quadrant = "fragile and on fire."+ *+ * Implemented as inline SVG (no recharts dep) so it stays cheap and the+ * component can be reused in `packages/ui` without bumping the chart lib+ * version everywhere.+ */+export function ChurnVsBusFactorScatter({+ hotspots,+ className,+ onSelect,+ height = 220,+}: ChurnVsBusFactorScatterProps) {+ const padding = { top: 12, right: 12, bottom: 28, left: 36 };+ const width = 480;+ const innerW = width - padding.left - padding.right;+ const innerH = height - padding.top - padding.bottom;++ const points = React.useMemo(() => {+ return hotspots.map((h) => {+ const x = Math.max(0, Math.min(100, h.churn_percentile));+ // bus_factor of 1 → top of chart (riskiest); cap at 8 for visual scale.+ const busClamped = Math.max(1, Math.min(8, h.bus_factor || 1));+ const y = ((8 - busClamped) / 7) * 100;+ // Bubble size by commit_count_90d (sqrt for area-ish scaling).+ const r = 4 + Math.min(14, Math.sqrt(h.commit_count_90d ?? 0));+ return { ...h, _x: x, _y: y, _r: r };+ });+ }, [hotspots]);++ if (points.length === 0) {+ return (+ <div+ className={cn(+ "rounded-md border border-dashed border-[var(--color-border-default)] p-4 text-center text-xs text-[var(--color-text-tertiary)]",+ className,+ )}+ >+ No hotspots yet.+ </div>+ );+ }++ return (+ <div className={cn("w-full", className)}>+ <svg+ viewBox={`0 0 ${width} ${height}`}+ preserveAspectRatio="xMidYMid meet"+ className="h-auto w-full"+ role="img"+ aria-label="Churn vs bus factor scatter plot"+ >+ {/* Quadrant tint — top-right is the danger zone */}+ <rect+ x={padding.left + innerW * 0.5}+ y={padding.top}+ width={innerW * 0.5}+ height={innerH * 0.5}+ fill="rgba(244, 63, 94, 0.06)"+ />++ {/* Axes */}+ <line+ x1={padding.left}+ y1={padding.top + innerH}+ x2={padding.left + innerW}+ y2={padding.top + innerH}+ stroke="var(--color-border-default)"+ />+ <line+ x1={padding.left}+ y1={padding.top}+ x2={padding.left}+ y2={padding.top + innerH}+ stroke="var(--color-border-default)"+ />++ {/* X labels */}+ {[0, 50, 100].map((tick) => (+ <text+ key={`x-${tick}`}+ x={padding.left + (tick / 100) * innerW}+ y={padding.top + innerH + 16}+ textAnchor="middle"+ fontSize="10"+ fill="var(--color-text-tertiary)"+ >+ {tick}+ </text>+ ))}++ {/* Y labels */}+ {[+ { y: 100, label: "1" },+ { y: 50, label: "4" },+ { y: 0, label: "8+" },+ ].map((t) => (+ <text+ key={`y-${t.label}`}+ x={padding.left - 8}+ y={padding.top + innerH - (t.y / 100) * innerH + 3}+ textAnchor="end"+ fontSize="10"+ fill="var(--color-text-tertiary)"+ >+ {t.label}+ </text>+ ))}++ <text+ x={padding.left + innerW / 2}+ y={height - 4}+ textAnchor="middle"+ fontSize="10"+ fill="var(--color-text-tertiary)"+ >+ Churn percentile →+ </text>+ <text+ x={-padding.top - innerH / 2}+ y={12}+ transform={`rotate(-90)`}+ textAnchor="middle"+ fontSize="10"+ fill="var(--color-text-tertiary)"+ >+ ← Bus factor (1 = fragile)+ </text>++ {/* Points */}+ {points.map((p) => {+ const cx = padding.left + (p._x / 100) * innerW;+ const cy = padding.top + innerH - (p._y / 100) * innerH;+ const fill =+ p._x >= 50 && p._y >= 50+ ? "rgba(244,63,94,0.6)"+ : "rgba(245,158,11,0.5)";+ return (+ <g key={p.file_path}>+ <circle+ cx={cx}+ cy={cy}+ r={p._r}+ fill={fill}+ stroke="rgba(0,0,0,0.2)"+ strokeWidth={0.5}+ onClick={onSelect ? () => onSelect(p.file_path) : undefined}+ style={{ cursor: onSelect ? "pointer" : "default" }}+ >+ <title>+ {p.file_path}+ {"\n"}churn: {Math.round(p.churn_percentile)}th, bus factor: {p.bus_factor}+ {", "}commits 90d: {p.commit_count_90d}+ </title>+ </circle>+ </g>+ );+ })}+ </svg>+ </div>+ );+}diff --git a/packages/ui/src/git/hotspot-table.tsx b/packages/ui/src/git/hotspot-table.tsxindex 9116c741e..002fd0b95 100644--- a/packages/ui/src/git/hotspot-table.tsx+++ b/packages/ui/src/git/hotspot-table.tsx@@ -15,6 +15,13 @@ interface HotspotTableProps {hotspots: Hotspot[];repoId?: string;linkPrefix?: string;+ /**+ * Optional row-click handler. When set, the entire row becomes clickable and+ * the host can render a FileCardDialog (or similar) populated from the+ * passed Hotspot. The action buttons in the rightmost column are still+ * clickable independently — they stop propagation.+ */+ onSelect?: (hotspot: Hotspot) => void;}type Filter = "all" | "hot" | "risk" | "accelerating";@@ -33,7 +40,7 @@ function ariaSortFor(column: SortKey, sortKey: SortKey, sortDir: SortDir): "nonereturn sortDir === "asc" ? "ascending" : "descending";}-export function HotspotTable({ hotspots, repoId, linkPrefix }: HotspotTableProps) {+export function HotspotTable({ hotspots, repoId, linkPrefix, onSelect }: HotspotTableProps) {const prefix = linkPrefix ?? (repoId ? `/repos/${repoId}` : undefined);const [search, setSearch] = useState("");const [filter, setFilter] = useState<Filter>("all");@@ -139,7 +146,7 @@ export function HotspotTable({ hotspots, repoId, linkPrefix }: HotspotTableProps<EmptyState title="No matches" description="Try adjusting your search or filters." />) : (<div className="rounded-lg border border-[var(--color-border-default)] overflow-x-auto">- <table className="w-full text-sm">+ <table className="w-full min-w-[760px] text-sm"><thead className="sticky top-0 z-10 bg-[var(--color-bg-elevated)]"><tr className="border-b border-[var(--color-border-default)] bg-[var(--color-bg-elevated)]"><th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-8">@@ -192,12 +199,16 @@ export function HotspotTable({ hotspots, repoId, linkPrefix }: HotspotTablePropsreturn (<trkey={h.file_path}- className="border-b border-[var(--color-border-default)] hover:bg-[var(--color-bg-elevated)] transition-colors last:border-0"+ onClick={onSelect ? () => onSelect(h) : undefined}+ className={cn(+ "border-b border-[var(--color-border-default)] hover:bg-[var(--color-bg-elevated)] transition-colors last:border-0",+ onSelect && "cursor-pointer",+ )}><td className="px-3 py-2.5 text-[var(--color-text-tertiary)] tabular-nums text-xs">{i + 1}</td>- <td className="px-3 py-2.5 font-mono text-xs text-[var(--color-text-primary)] min-w-[220px] max-w-[520px]">+ <td className="px-3 py-2.5 font-mono text-xs text-[var(--color-text-primary)] min-w-[180px] max-w-[420px]"><span className="block truncate" title={h.file_path}>{h.file_path}</span></td><td className="px-3 py-2.5 tabular-nums text-xs text-right">@@ -255,7 +266,7 @@ export function HotspotTable({ hotspots, repoId, linkPrefix }: HotspotTableProps<td className="px-3 py-2.5 text-xs text-[var(--color-text-secondary)] hidden md:table-cell">{h.primary_owner ?? "—"}</td>- <td className="px-3 py-2.5">+ <td className="px-3 py-2.5" onClick={(e) => e.stopPropagation()}><div className="flex items-center gap-1">{h.is_hotspot && <Badge variant="outdated">Hot</Badge>}{h.is_stable && <Badge variant="fresh">Stable</Badge>}diff --git a/packages/ui/src/git/hotspot-trend-strip.tsx b/packages/ui/src/git/hotspot-trend-strip.tsxnew file mode 100644index 000000000..e65637980--- /dev/null+++ b/packages/ui/src/git/hotspot-trend-strip.tsx@@ -0,0 +1,127 @@+"use client";++import * as React from "react";+import { TrendingUp, TrendingDown, Minus } from "lucide-react";+import { cn } from "../lib/cn";++export interface TrendStripHotspot {+ file_path: string;+ churn_percentile: number;+ commit_count_90d: number;+ commit_count_30d: number;+ bus_factor: number;+ temporal_hotspot_score?: number | null;+ primary_owner?: string | null;+}++interface HotspotTrendStripProps {+ hotspots: TrendStripHotspot[];+ topN?: number;+ className?: string;+ onSelect?: (filePath: string) => void;+}++type Trend = "heating" | "cooling" | "stable";++/**+ * Derive heating/cooling vs the 90d baseline from the 30d window. We extrapolate+ * the 30d count to a 90d-equivalent (×3) and compare against the actual 90d+ * count: significantly higher means heating, lower means cooling.+ */+function trendFor(h: TrendStripHotspot): Trend {+ if (h.commit_count_90d === 0) return "stable";+ const expected = h.commit_count_30d * 3;+ const ratio = expected / h.commit_count_90d;+ if (ratio >= 1.25) return "heating";+ if (ratio <= 0.75) return "cooling";+ return "stable";+}++/**+ * Compact list of top hotspots with churn percentile + heating/cooling badge.+ * Designed to sit next to a treemap and tell the "what's getting worse" story+ * at a glance.+ */+export function HotspotTrendStrip({+ hotspots,+ topN = 8,+ className,+ onSelect,+}: HotspotTrendStripProps) {+ const items = React.useMemo(+ () => [...hotspots].sort((a, b) => b.churn_percentile - a.churn_percentile).slice(0, topN),+ [hotspots, topN],+ );++ if (items.length === 0) {+ return (+ <div+ className={cn(+ "rounded-md border border-dashed border-[var(--color-border-default)] p-4 text-center text-xs text-[var(--color-text-tertiary)]",+ className,+ )}+ >+ No hotspots yet.+ </div>+ );+ }++ return (+ <ul className={cn("divide-y divide-[var(--color-border-default)]", className)}>+ {items.map((h) => {+ const trend = trendFor(h);+ const Tag = onSelect ? "button" : "div";+ return (+ <li key={h.file_path}>+ <Tag+ type={onSelect ? "button" : undefined}+ onClick={onSelect ? () => onSelect(h.file_path) : undefined}+ className={cn(+ "flex w-full items-center gap-3 px-2 py-2 text-left text-xs",+ onSelect && "transition hover:bg-[var(--color-bg-elevated)]",+ )}+ >+ <TrendBadge trend={trend} />+ <span+ className="flex-1 truncate font-mono text-[11px] text-[var(--color-text-primary)]"+ title={h.file_path}+ >+ {h.file_path}+ </span>+ <span className="shrink-0 tabular-nums text-[var(--color-text-tertiary)]">+ {Math.round(h.churn_percentile)}th %ile+ </span>+ {h.bus_factor <= 1 && (+ <span className="shrink-0 rounded-full border border-red-500/40 bg-red-500/10 px-1.5 py-0.5 text-[10px] font-medium text-red-300">+ bus×1+ </span>+ )}+ </Tag>+ </li>+ );+ })}+ </ul>+ );+}++function TrendBadge({ trend }: { trend: Trend }) {+ if (trend === "heating") {+ return (+ <span className="inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-rose-500/15 text-rose-400">+ <TrendingUp className="h-3 w-3" />+ </span>+ );+ }+ if (trend === "cooling") {+ return (+ <span className="inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-emerald-500/15 text-emerald-400">+ <TrendingDown className="h-3 w-3" />+ </span>+ );+ }+ return (+ <span className="inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-[var(--color-bg-elevated)] text-[var(--color-text-tertiary)]">+ <Minus className="h-3 w-3" />+ </span>+ );+}diff --git a/packages/ui/src/git/index.ts b/packages/ui/src/git/index.tsindex 1d42e514c..d4b9faf79 100644--- a/packages/ui/src/git/index.ts+++ b/packages/ui/src/git/index.ts@@ -10,3 +10,5 @@ export * from "./hotspot-table.js";export * from "./ownership-table.js";export * from "./ownership-treemap.js";export * from "./risk-distribution-chart.js";+export * from "./hotspot-trend-strip.js";+export * from "./churn-vs-bus-factor-scatter.js";diff --git a/packages/ui/src/graph/centrality-leaderboard.tsx b/packages/ui/src/graph/centrality-leaderboard.tsxnew file mode 100644index 000000000..e4de11ba9--- /dev/null+++ b/packages/ui/src/graph/centrality-leaderboard.tsx@@ -0,0 +1,146 @@+"use client";++import { useState } from "react";+import { ChevronLeft, ChevronRight, Crown } from "lucide-react";+import { cn } from "../lib/cn";++export interface CentralityNode {+ node_id: string;+ label?: string;+ pagerank: number;+ betweenness?: number;+ in_degree?: number;+ out_degree?: number;+ language?: string;+}++export interface CentralityLeaderboardProps {+ nodes: CentralityNode[];+ metric?: "pagerank" | "betweenness" | "degree";+ /** Cap the rendered rows. */+ limit?: number;+ /** Click handler — typical use is selecting the node in the graph. */+ onSelect?: (node: CentralityNode) => void;+ className?: string;+}++const METRIC_LABEL: Record<string, string> = {+ pagerank: "PageRank",+ betweenness: "Betweenness",+ degree: "Degree (in+out)",+};++function score(node: CentralityNode, metric: "pagerank" | "betweenness" | "degree"): number {+ if (metric === "pagerank") return node.pagerank;+ if (metric === "betweenness") return node.betweenness ?? 0;+ return (node.in_degree ?? 0) + (node.out_degree ?? 0);+}++export function CentralityLeaderboard({+ nodes,+ metric: initialMetric = "pagerank",+ limit = 20,+ onSelect,+ className,+}: CentralityLeaderboardProps) {+ const [collapsed, setCollapsed] = useState(false);+ const [metric, setMetric] = useState<"pagerank" | "betweenness" | "degree">(initialMetric);+ const ranked = [...nodes].sort((a, b) => score(b, metric) - score(a, metric)).slice(0, limit);+ const max = ranked.length > 0 ? score(ranked[0]!, metric) : 0;++ return (+ <aside+ className={cn(+ "rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-surface)]",+ collapsed ? "w-10" : "w-[280px]",+ "transition-all overflow-hidden flex flex-col",+ className,+ )}+ >+ <div className="flex items-center justify-between gap-2 border-b border-[var(--color-border-default)] px-2 py-2">+ {!collapsed && (+ <div className="flex items-center gap-1.5 min-w-0">+ <Crown className="h-3.5 w-3.5 text-yellow-500 shrink-0" />+ <span className="text-xs font-medium text-[var(--color-text-primary)] truncate">+ Centrality+ </span>+ </div>+ )}+ <button+ type="button"+ onClick={() => setCollapsed((c) => !c)}+ className="p-1 rounded hover:bg-[var(--color-bg-elevated)] text-[var(--color-text-tertiary)] shrink-0"+ aria-label={collapsed ? "Expand leaderboard" : "Collapse leaderboard"}+ >+ {collapsed ? <ChevronLeft className="h-3 w-3" /> : <ChevronRight className="h-3 w-3" />}+ </button>+ </div>++ {!collapsed && (+ <>+ <div className="flex border-b border-[var(--color-border-default)] text-[10px]">+ {(["pagerank", "betweenness", "degree"] as const).map((m) => (+ <button+ key={m}+ type="button"+ onClick={() => setMetric(m)}+ className={cn(+ "flex-1 px-2 py-1.5 transition-colors",+ metric === m+ ? "bg-[var(--color-accent-muted)] text-[var(--color-accent-primary)]"+ : "text-[var(--color-text-secondary)] hover:bg-[var(--color-bg-elevated)]",+ )}+ >+ {METRIC_LABEL[m]}+ </button>+ ))}+ </div>++ <ol className="flex-1 overflow-y-auto divide-y divide-[var(--color-border-default)] max-h-[480px]">+ {ranked.map((n, i) => {+ const v = score(n, metric);+ const pct = max > 0 ? (v / max) * 100 : 0;+ return (+ <li key={n.node_id}>+ <button+ type="button"+ onClick={onSelect ? () => onSelect(n) : undefined}+ disabled={!onSelect}+ className={cn(+ "w-full text-left px-2 py-1.5 flex items-center gap-2",+ onSelect && "hover:bg-[var(--color-bg-elevated)] cursor-pointer",+ )}+ title={n.node_id}+ >+ <span className="text-[10px] tabular-nums text-[var(--color-text-tertiary)] w-4 text-right">+ {i + 1}+ </span>+ <div className="min-w-0 flex-1">+ <p className="text-[11px] font-mono text-[var(--color-text-primary)] truncate">+ {n.label ?? n.node_id}+ </p>+ <div className="mt-0.5 h-1 rounded-full bg-[var(--color-bg-inset)] overflow-hidden">+ <div+ className="h-full bg-[var(--color-accent-primary)]"+ style={{ width: `${pct.toFixed(1)}%` }}+ />+ </div>+ </div>+ <span className="text-[10px] tabular-nums text-[var(--color-text-tertiary)] shrink-0">+ {metric === "degree" ? v.toFixed(0) : v.toFixed(3)}+ </span>+ </button>+ </li>+ );+ })}+ {ranked.length === 0 && (+ <li className="px-3 py-4 text-[11px] text-[var(--color-text-tertiary)] text-center">+ No graph metrics yet.+ </li>+ )}+ </ol>+ </>+ )}+ </aside>+ );+}diff --git a/packages/ui/src/graph/index.ts b/packages/ui/src/graph/index.tsindex 52f4641f7..da288e38f 100644--- a/packages/ui/src/graph/index.ts+++ b/packages/ui/src/graph/index.ts@@ -6,6 +6,7 @@ export * from "./graph-doc-panel.js";export * from "./graph-community-panel.js";export * from "./graph-inspection-panel.js";export * from "./path-finder-panel.js";+export * from "./centrality-leaderboard.js";export * from "./graph-flow.js";export * from "./context.js";export * from "./elk-layout.js";diff --git a/packages/ui/src/onboarding/first-five-files.tsx b/packages/ui/src/onboarding/first-five-files.tsxnew file mode 100644index 000000000..380cba492--- /dev/null+++ b/packages/ui/src/onboarding/first-five-files.tsx@@ -0,0 +1,88 @@+"use client";++import { Sparkles, ArrowUpRight } from "lucide-react";+import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";+import { Badge } from "../ui/badge";++export interface FirstFiveFile {+ file_path: string;+ /** Why this file is a good starting point — entry point, central, etc. */+ reason?: string;+ pagerank?: number;+ is_entry_point?: boolean;+ has_doc?: boolean;+ doc_url?: string;+}++export interface FirstFiveFilesProps {+ files: FirstFiveFile[];+ /** Per-file deep link factory (e.g. wiki page). Falls back to `doc_url` field. */+ hrefFor?: (file: FirstFiveFile) => string | undefined;+ /** Override the title (e.g. for a "Start here" pinned section). */+ title?: string;+}++export function FirstFiveFiles({+ files,+ hrefFor,+ title = "First five files",+}: FirstFiveFilesProps) {+ if (files.length === 0) return null;+ const top = files.slice(0, 5);++ return (+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm flex items-center gap-2">+ <Sparkles className="h-4 w-4 text-[var(--color-accent-primary)]" />+ {title}+ <span className="text-[10px] font-normal text-[var(--color-text-tertiary)] uppercase tracking-wider">+ start here+ </span>+ </CardTitle>+ </CardHeader>+ <CardContent className="pt-0">+ <ol className="space-y-1.5">+ {top.map((f, i) => {+ const href = hrefFor?.(f) ?? f.doc_url;+ const Wrapper = (props: { children: React.ReactNode }) =>+ href ? (+ <a+ href={href}+ className="group flex items-start gap-2.5 rounded-md border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] px-3 py-2 hover:border-[var(--color-accent-primary)] transition-colors"+ >+ {props.children}+ </a>+ ) : (+ <div className="flex items-start gap-2.5 rounded-md border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] px-3 py-2">+ {props.children}+ </div>+ );+ return (+ <li key={f.file_path}>+ <Wrapper>+ <span className="text-xs tabular-nums text-[var(--color-text-tertiary)] mt-0.5">{i + 1}</span>+ <div className="min-w-0 flex-1">+ <p className="font-mono text-xs text-[var(--color-text-primary)] truncate">+ {f.file_path}+ </p>+ <div className="flex flex-wrap items-center gap-1.5 mt-0.5">+ {f.is_entry_point && <Badge variant="accent" className="h-4 text-[10px]">entry point</Badge>}+ {f.has_doc && <Badge variant="outline" className="h-4 text-[10px]">has doc</Badge>}+ {f.reason && (+ <span className="text-[11px] text-[var(--color-text-secondary)]">{f.reason}</span>+ )}+ </div>+ </div>+ {href && (+ <ArrowUpRight className="h-3.5 w-3.5 text-[var(--color-text-tertiary)] mt-0.5 opacity-0 group-hover:opacity-100 transition-opacity" />+ )}+ </Wrapper>+ </li>+ );+ })}+ </ol>+ </CardContent>+ </Card>+ );+}diff --git a/packages/ui/src/onboarding/index.ts b/packages/ui/src/onboarding/index.tsnew file mode 100644index 000000000..49fbeef07--- /dev/null+++ b/packages/ui/src/onboarding/index.ts@@ -0,0 +1 @@+export * from "./first-five-files.js";diff --git a/packages/ui/src/security/findings-by-directory.tsx b/packages/ui/src/security/findings-by-directory.tsxnew file mode 100644index 000000000..48600940c--- /dev/null+++ b/packages/ui/src/security/findings-by-directory.tsx@@ -0,0 +1,60 @@+"use client";++import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";+import type { SecurityFinding } from "./findings-table";++export interface FindingsByDirectoryProps {+ findings: SecurityFinding[];+ /** Path-segment depth to group at (default 2). */+ depth?: number;+}++export function FindingsByDirectory({ findings, depth = 2 }: FindingsByDirectoryProps) {+ const grouped = new Map<string, { dir: string; high: number; med: number; low: number; total: number }>();+ for (const f of findings) {+ const segments = f.file_path.split("/").slice(0, depth);+ const dir = segments.length === 0 ? "(root)" : segments.join("/");+ const cur = grouped.get(dir) ?? { dir, high: 0, med: 0, low: 0, total: 0 };+ if (f.severity === "high") cur.high += 1;+ else if (f.severity === "med") cur.med += 1;+ else cur.low += 1;+ cur.total += 1;+ grouped.set(dir, cur);+ }++ const rows = Array.from(grouped.values()).sort((a, b) => b.total - a.total).slice(0, 16);+ const max = rows.reduce((m, r) => Math.max(m, r.total), 1);++ if (rows.length === 0) {+ return null;+ }++ return (+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Findings by directory</CardTitle>+ </CardHeader>+ <CardContent className="pt-0 space-y-2">+ {rows.map((r) => (+ <div key={r.dir} className="text-xs">+ <div className="flex items-center justify-between mb-1">+ <span className="font-mono text-[var(--color-text-primary)] truncate">{r.dir}</span>+ <span className="tabular-nums text-[var(--color-text-tertiary)] ml-2">{r.total}</span>+ </div>+ <div className="flex h-2 w-full overflow-hidden rounded-full bg-[var(--color-bg-inset)]">+ {r.high > 0 && (+ <div style={{ width: `${(r.high / max) * 100}%`, backgroundColor: "#ef4444" }} />+ )}+ {r.med > 0 && (+ <div style={{ width: `${(r.med / max) * 100}%`, backgroundColor: "#f59e0b" }} />+ )}+ {r.low > 0 && (+ <div style={{ width: `${(r.low / max) * 100}%`, backgroundColor: "#10b981" }} />+ )}+ </div>+ </div>+ ))}+ </CardContent>+ </Card>+ );+}diff --git a/packages/ui/src/security/findings-table.tsx b/packages/ui/src/security/findings-table.tsxnew file mode 100644index 000000000..4f1cd91af--- /dev/null+++ b/packages/ui/src/security/findings-table.tsx@@ -0,0 +1,151 @@+"use client";++import { useMemo, useState } from "react";+import { Search } from "lucide-react";+import { Badge } from "../ui/badge";+import { Input } from "../ui/input";+import { EmptyState } from "../shared/empty-state";++export interface SecurityFinding {+ id: number;+ file_path: string;+ kind: string;+ severity: string;+ snippet: string | null;+ detected_at: string;+}++const SEVERITY_VARIANT: Record<string, "outdated" | "stale" | "outline"> = {+ high: "outdated",+ med: "stale",+ low: "outline",+};++export interface SecurityFindingsTableProps {+ findings: SecurityFinding[];+ onSelect?: (finding: SecurityFinding) => void;+}++export function SecurityFindingsTable({ findings, onSelect }: SecurityFindingsTableProps) {+ const [q, setQ] = useState("");+ const [sev, setSev] = useState<"all" | "high" | "med" | "low">("all");++ const filtered = useMemo(() => {+ let items = findings;+ if (sev !== "all") items = items.filter((f) => f.severity === sev);+ if (q) {+ const needle = q.toLowerCase();+ items = items.filter(+ (f) =>+ f.file_path.toLowerCase().includes(needle) ||+ f.kind.toLowerCase().includes(needle) ||+ (f.snippet ?? "").toLowerCase().includes(needle),+ );+ }+ return items;+ }, [findings, q, sev]);++ if (findings.length === 0) {+ return (+ <EmptyState+ title="No findings"+ description="No security findings detected on this repo. Re-run analysis to refresh."+ />+ );+ }++ return (+ <div className="space-y-3">+ <div className="flex flex-wrap items-center gap-2">+ <div className="relative">+ <Search className="absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-[var(--color-text-tertiary)]" />+ <Input+ value={q}+ onChange={(e) => setQ(e.target.value)}+ placeholder="Search file, kind, or snippet…"+ className="pl-8 h-8 w-full sm:w-72 text-xs"+ />+ </div>+ <div className="flex rounded-md border border-[var(--color-border-default)] overflow-hidden text-xs">+ {(["all", "high", "med", "low"] as const).map((s) => (+ <button+ key={s}+ type="button"+ onClick={() => setSev(s)}+ className={+ sev === s+ ? "px-2.5 py-1.5 bg-[var(--color-accent-primary)] text-[var(--color-text-inverse)]"+ : "px-2.5 py-1.5 bg-transparent text-[var(--color-text-secondary)] hover:bg-[var(--color-bg-elevated)]"+ }+ >+ {s}+ {s !== "all" && (+ <span className="ml-1 text-[10px] opacity-70">+ ({findings.filter((f) => f.severity === s).length})+ </span>+ )}+ </button>+ ))}+ </div>+ </div>++ <div className="rounded-lg border border-[var(--color-border-default)] overflow-x-auto">+ <table className="w-full min-w-[720px] text-sm">+ <thead className="sticky top-0 z-10 bg-[var(--color-bg-elevated)]">+ <tr className="border-b border-[var(--color-border-default)]">+ <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-20">+ Severity+ </th>+ <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">+ File+ </th>+ <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-40">+ Kind+ </th>+ <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">+ Snippet+ </th>+ <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-28">+ Detected+ </th>+ </tr>+ </thead>+ <tbody>+ {filtered.map((f) => (+ <tr+ key={f.id}+ onClick={onSelect ? () => onSelect(f) : undefined}+ className={+ "border-b border-[var(--color-border-default)] last:border-0 hover:bg-[var(--color-bg-elevated)] transition-colors" ++ (onSelect ? " cursor-pointer" : "")+ }+ >+ <td className="px-3 py-2">+ <Badge variant={SEVERITY_VARIANT[f.severity] ?? "outline"} className="capitalize">+ {f.severity}+ </Badge>+ </td>+ <td className="px-3 py-2 font-mono text-xs text-[var(--color-text-primary)] max-w-[280px]">+ <span className="block truncate" title={f.file_path}>{f.file_path}</span>+ </td>+ <td className="px-3 py-2 text-xs text-[var(--color-text-secondary)]">{f.kind}</td>+ <td className="px-3 py-2 font-mono text-[11px] text-[var(--color-text-tertiary)] max-w-[320px]">+ <span className="block truncate" title={f.snippet ?? ""}>+ {f.snippet ?? "—"}+ </span>+ </td>+ <td className="px-3 py-2 text-[11px] text-[var(--color-text-tertiary)] tabular-nums">+ {new Date(f.detected_at).toLocaleDateString()}+ </td>+ </tr>+ ))}+ </tbody>+ </table>+ </div>++ {filtered.length === 0 && (+ <p className="text-sm text-[var(--color-text-tertiary)] py-6 text-center">No matches.</p>+ )}+ </div>+ );+}diff --git a/packages/ui/src/security/index.ts b/packages/ui/src/security/index.tsnew file mode 100644index 000000000..97fcca024--- /dev/null+++ b/packages/ui/src/security/index.ts@@ -0,0 +1,3 @@+export * from "./severity-distribution.js";+export * from "./findings-table.js";+export * from "./findings-by-directory.js";diff --git a/packages/ui/src/security/severity-distribution.tsx b/packages/ui/src/security/severity-distribution.tsxnew file mode 100644index 000000000..641570a8d--- /dev/null+++ b/packages/ui/src/security/severity-distribution.tsx@@ -0,0 +1,84 @@+"use client";++import { ShieldAlert } from "lucide-react";+import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";++const SEVERITY_ORDER = ["high", "med", "low"] as const;+const SEVERITY_LABELS: Record<string, string> = {+ high: "High / critical",+ med: "Medium",+ low: "Low",+};+const SEVERITY_COLORS: Record<string, string> = {+ high: "#ef4444",+ med: "#f59e0b",+ low: "#10b981",+};++export interface SeverityDistributionProps {+ /** Map of severity → count. */+ counts: Record<string, number>;+}++export function SeverityDistribution({ counts }: SeverityDistributionProps) {+ const total = Object.values(counts).reduce((s, n) => s + n, 0);++ return (+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm flex items-center gap-2">+ <ShieldAlert className="h-4 w-4 text-red-400" />+ Severity distribution+ </CardTitle>+ </CardHeader>+ <CardContent className="pt-0 space-y-3">+ {total === 0 ? (+ <p className="text-xs text-[var(--color-text-secondary)] py-4 text-center">+ No security findings.+ </p>+ ) : (+ <>+ <div className="flex h-2 w-full overflow-hidden rounded-full bg-[var(--color-bg-inset)]">+ {SEVERITY_ORDER.map((sev) => {+ const c = counts[sev] ?? 0;+ if (c === 0) return null;+ return (+ <div+ key={sev}+ style={{+ width: `${(c / total) * 100}%`,+ backgroundColor: SEVERITY_COLORS[sev],+ }}+ title={`${SEVERITY_LABELS[sev]}: ${c}`}+ />+ );+ })}+ </div>+ <div className="grid grid-cols-3 gap-2 text-xs">+ {SEVERITY_ORDER.map((sev) => {+ const c = counts[sev] ?? 0;+ return (+ <div+ key={sev}+ className="rounded-md border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] px-3 py-2"+ >+ <div className="flex items-center gap-1.5 mb-1">+ <span+ className="h-2 w-2 rounded-full"+ style={{ backgroundColor: SEVERITY_COLORS[sev] }}+ />+ <span className="text-[var(--color-text-secondary)]">{SEVERITY_LABELS[sev]}</span>+ </div>+ <p className="text-lg font-semibold text-[var(--color-text-primary)] tabular-nums">+ {c}+ </p>+ </div>+ );+ })}+ </div>+ </>+ )}+ </CardContent>+ </Card>+ );+}diff --git a/packages/ui/src/shared/context-drawer/drawer.tsx b/packages/ui/src/shared/context-drawer/drawer.tsxnew file mode 100644index 000000000..682bfb23b--- /dev/null+++ b/packages/ui/src/shared/context-drawer/drawer.tsx@@ -0,0 +1,144 @@+"use client";++import * as React from "react";+import * as DialogPrimitive from "@radix-ui/react-dialog";+import { X } from "lucide-react";+import { cn } from "../../lib/cn";+import { Tabs, TabsContent, TabsList, TabsTrigger } from "../../ui/tabs";+import { ENTITY_KIND_LABEL } from "../entity/routes";+import type { EntityRef } from "../entity/types";+import { useContextDrawer } from "./store";++/**+ * Right-side slide-in drawer that any EntityLink can open. Tab content is+ * provided by the host application as render functions — this keeps the+ * drawer in `packages/ui` (presentational) while letting `packages/web`+ * supply data fetching for each tab.+ */+export type ContextDrawerTabId =+ | "overview"+ | "decisions"+ | "co_changes"+ | "blast_radius"+ | "owners"+ | "docs";++export interface ContextDrawerTab {+ id: ContextDrawerTabId;+ label: string;+ /** Renders the tab body for the currently open entity. */+ render: (entity: EntityRef) => React.ReactNode;+}++interface ContextDrawerProps {+ tabs?: ContextDrawerTab[];+ defaultTab?: ContextDrawerTabId;+}++const DEFAULT_TAB_ORDER: ContextDrawerTabId[] = [+ "overview",+ "decisions",+ "co_changes",+ "blast_radius",+ "owners",+ "docs",+];++const DEFAULT_TAB_LABELS: Record<ContextDrawerTabId, string> = {+ overview: "Overview",+ decisions: "Decisions",+ co_changes: "Co-changes",+ blast_radius: "Blast radius",+ owners: "Owners",+ docs: "Docs",+};++export function ContextDrawer({ tabs, defaultTab = "overview" }: ContextDrawerProps) {+ const { entity, close } = useContextDrawer();+ const open = entity !== null;++ // Reset to default tab when entity changes.+ const [activeTab, setActiveTab] = React.useState<ContextDrawerTabId>(defaultTab);+ React.useEffect(() => {+ if (entity) setActiveTab(defaultTab);+ }, [entity?.kind, entity?.id, entity?.repoId, defaultTab]);++ const orderedTabs = React.useMemo(() => {+ if (!tabs || tabs.length === 0) {+ return DEFAULT_TAB_ORDER.map<ContextDrawerTab>((id) => ({+ id,+ label: DEFAULT_TAB_LABELS[id],+ render: () => <PlaceholderBody label={DEFAULT_TAB_LABELS[id]} />,+ }));+ }+ return tabs;+ }, [tabs]);++ return (+ <DialogPrimitive.Root open={open} onOpenChange={(o) => (!o ? close() : undefined)}>+ <DialogPrimitive.Portal>+ <DialogPrimitive.Overlay className="fixed inset-0 z-40 bg-black/40 backdrop-blur-[1px] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" />+ <DialogPrimitive.Content+ className={cn(+ "fixed right-0 top-0 z-50 flex h-full w-full max-w-[520px] flex-col",+ "border-l border-[var(--color-border-default)] bg-[var(--color-bg-surface)] shadow-2xl",+ "data-[state=open]:animate-in data-[state=closed]:animate-out",+ "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right",+ )}+ aria-describedby={undefined}+ >+ {entity && (+ <>+ <header className="flex items-start justify-between gap-3 border-b border-[var(--color-border-default)] px-4 py-3">+ <div className="min-w-0">+ <p className="text-[10px] uppercase tracking-wider text-[var(--color-text-tertiary)]">+ {ENTITY_KIND_LABEL[entity.kind]}+ </p>+ <DialogPrimitive.Title className="mt-0.5 break-all font-mono text-[12px] leading-snug text-[var(--color-text-primary)]">+ {entity.id}+ </DialogPrimitive.Title>+ </div>+ <DialogPrimitive.Close+ aria-label="Close drawer"+ className="shrink-0 rounded-md p-1.5 text-[var(--color-text-tertiary)] transition hover:bg-[var(--color-bg-elevated)] hover:text-[var(--color-text-primary)]"+ >+ <X className="h-4 w-4" />+ </DialogPrimitive.Close>+ </header>++ <Tabs+ value={activeTab}+ onValueChange={(v) => setActiveTab(v as ContextDrawerTabId)}+ className="flex min-h-0 flex-1 flex-col"+ >+ <TabsList className="flex-wrap gap-0.5 mx-3 mt-3 h-auto justify-start">+ {orderedTabs.map((tab) => (+ <TabsTrigger key={tab.id} value={tab.id} className="text-xs">+ {tab.label}+ </TabsTrigger>+ ))}+ </TabsList>++ <div className="min-h-0 flex-1 overflow-y-auto px-4 py-3">+ {orderedTabs.map((tab) => (+ <TabsContent key={tab.id} value={tab.id} className="mt-0">+ {tab.render(entity)}+ </TabsContent>+ ))}+ </div>+ </Tabs>+ </>+ )}+ </DialogPrimitive.Content>+ </DialogPrimitive.Portal>+ </DialogPrimitive.Root>+ );+}++function PlaceholderBody({ label }: { label: string }) {+ return (+ <div className="rounded-md border border-dashed border-[var(--color-border-default)] p-4 text-center text-xs text-[var(--color-text-tertiary)]">+ {label} content not yet wired.+ </div>+ );+}diff --git a/packages/ui/src/shared/context-drawer/index.ts b/packages/ui/src/shared/context-drawer/index.tsnew file mode 100644index 000000000..d42d9f637--- /dev/null+++ b/packages/ui/src/shared/context-drawer/index.ts@@ -0,0 +1,4 @@+export { ContextDrawer } from "./drawer";+export type { ContextDrawerTab, ContextDrawerTabId } from "./drawer";+export { ContextDrawerProvider, useContextDrawer } from "./store";+export type { ContextDrawerState, ContextDrawerProviderProps } from "./store";diff --git a/packages/ui/src/shared/context-drawer/store.tsx b/packages/ui/src/shared/context-drawer/store.tsxnew file mode 100644index 000000000..a64e04c98--- /dev/null+++ b/packages/ui/src/shared/context-drawer/store.tsx@@ -0,0 +1,77 @@+"use client";++import * as React from "react";+import type { EntityRef } from "../entity/types";++/**+ * Minimal context-drawer store. Kept dependency-free (no zustand) so the+ * component is portable to the hosted frontend without bringing in a state+ * library that wouldn't otherwise be needed.+ *+ * Consumers wire URL synchronization at their app layer (see web layout).+ */+export interface ContextDrawerState {+ entity: EntityRef | null;+ open: (entity: EntityRef) => void;+ close: () => void;+}++const ContextDrawerContext = React.createContext<ContextDrawerState | null>(null);++export interface ContextDrawerProviderProps {+ children: React.ReactNode;+ /** Optional initial entity (e.g. from URL hydration). */+ initialEntity?: EntityRef | null;+ /** Notified whenever the open entity changes — wire to URL sync here. */+ onEntityChange?: (entity: EntityRef | null) => void;+}++export function ContextDrawerProvider({+ children,+ initialEntity = null,+ onEntityChange,+}: ContextDrawerProviderProps) {+ const [entity, setEntity] = React.useState<EntityRef | null>(initialEntity);++ // Sync external prop changes (e.g. URL hydration on navigation).+ React.useEffect(() => {+ setEntity(initialEntity);+ }, [initialEntity?.kind, initialEntity?.id, initialEntity?.repoId]);++ const open = React.useCallback(+ (next: EntityRef) => {+ setEntity(next);+ onEntityChange?.(next);+ },+ [onEntityChange],+ );++ const close = React.useCallback(() => {+ setEntity(null);+ onEntityChange?.(null);+ }, [onEntityChange]);++ const value = React.useMemo<ContextDrawerState>(+ () => ({ entity, open, close }),+ [entity, open, close],+ );++ return (+ <ContextDrawerContext.Provider value={value}>{children}</ContextDrawerContext.Provider>+ );+}++export function useContextDrawer(): ContextDrawerState {+ const ctx = React.useContext(ContextDrawerContext);+ if (!ctx) {+ // Soft fallback: returning a no-op store keeps EntityLink callers from+ // crashing when no provider is mounted (e.g. during isolated component+ // tests). The real provider is mounted in the web app layout.+ return {+ entity: null,+ open: () => undefined,+ close: () => undefined,+ };+ }+ return ctx;+}diff --git a/packages/ui/src/shared/entity/entity-hover-card.tsx b/packages/ui/src/shared/entity/entity-hover-card.tsxnew file mode 100644index 000000000..9c4e20cf3--- /dev/null+++ b/packages/ui/src/shared/entity/entity-hover-card.tsx@@ -0,0 +1,210 @@+"use client";++import * as React from "react";+import * as HoverCardPrimitive from "@radix-ui/react-hover-card";+import { cn } from "../../lib/cn";+import type { EntityMeta, EntityRef } from "./types";+import { ENTITY_KIND_LABEL } from "./routes";++interface EntityHoverCardProps {+ entity: EntityRef;+ meta?: EntityMeta | undefined;+ children: React.ReactNode;+}++/**+ * Wraps any element with a hover preview card for the given entity.+ * Card content is purely presentational — the caller supplies whatever+ * metadata is already in scope. Missing fields gracefully degrade.+ */+export function EntityHoverCard({ entity, meta, children }: EntityHoverCardProps) {+ return (+ <HoverCardPrimitive.Root openDelay={250} closeDelay={120}>+ <HoverCardPrimitive.Trigger asChild>{children}</HoverCardPrimitive.Trigger>+ <HoverCardPrimitive.Portal>+ <HoverCardPrimitive.Content+ align="start"+ sideOffset={6}+ className={cn(+ "z-50 w-72 rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)]",+ "p-3 text-xs shadow-lg outline-none",+ "data-[state=open]:animate-in data-[state=closed]:animate-out",+ )}+ >+ <HoverCardBody entity={entity} meta={meta} />+ </HoverCardPrimitive.Content>+ </HoverCardPrimitive.Portal>+ </HoverCardPrimitive.Root>+ );+}++function HoverCardBody({ entity, meta }: { entity: EntityRef; meta?: EntityMeta | undefined }) {+ return (+ <div className="space-y-2">+ <div className="flex items-center justify-between gap-2">+ <span className="text-[10px] uppercase tracking-wider text-[var(--color-text-tertiary)]">+ {ENTITY_KIND_LABEL[entity.kind]}+ </span>+ </div>+ <p className="font-mono text-[11px] leading-snug text-[var(--color-text-primary)] break-all">+ {entity.id}+ </p>+ {meta && meta.kind === entity.kind && <MetaSection meta={meta} />}+ </div>+ );+}++function MetaSection({ meta }: { meta: EntityMeta }) {+ switch (meta.kind) {+ case "file":+ return <FileMeta data={meta.data} />;+ case "symbol":+ return <SymbolMeta data={meta.data} />;+ case "decision":+ return <DecisionMeta data={meta.data} />;+ case "owner":+ return <OwnerMeta data={meta.data} />;+ case "commit":+ return <CommitMeta data={meta.data} />;+ }+}++function Row({ label, value }: { label: string; value: React.ReactNode }) {+ if (value === null || value === undefined || value === "") return null;+ return (+ <div className="flex items-baseline justify-between gap-3">+ <span className="text-[var(--color-text-tertiary)]">{label}</span>+ <span className="text-[var(--color-text-primary)] tabular-nums">{value}</span>+ </div>+ );+}++function FileMeta({ data }: { data?: import("./types").FileEntityMeta | undefined }) {+ if (!data) return null;+ return (+ <div className="space-y-1">+ <Row label="Owner" value={data.owner ?? null} />+ <Row+ label="Churn"+ value={+ data.churnPercentile != null+ ? `${Math.round(data.churnPercentile)}th %ile`+ : null+ }+ />+ <Row label="Bus factor" value={data.busFactor ?? null} />+ {data.language && <Row label="Language" value={data.language} />}+ <div className="flex flex-wrap gap-1 pt-1">+ {data.hasDocs === false && <Pill tone="warn">No docs</Pill>}+ {data.hasDeadCode && <Pill tone="error">Dead code</Pill>}+ </div>+ </div>+ );+}++function SymbolMeta({ data }: { data?: import("./types").SymbolEntityMeta | undefined }) {+ if (!data) return null;+ return (+ <div className="space-y-1">+ {data.signature && (+ <p className="font-mono text-[10px] text-[var(--color-text-secondary)] break-all">+ {data.signature}+ </p>+ )}+ <Row label="Complexity" value={data.complexity ?? null} />+ <Row label="Callers" value={data.callerCount ?? null} />+ <Row label="Visibility" value={data.visibility ?? null} />+ {data.isAsync && (+ <div className="pt-1">+ <Pill tone="info">async</Pill>+ </div>+ )}+ </div>+ );+}++function DecisionMeta({ data }: { data?: import("./types").DecisionEntityMeta | undefined }) {+ if (!data) return null;+ const stale = data.stalenessScore;+ return (+ <div className="space-y-1">+ <Row label="Status" value={data.status ?? null} />+ <Row label="Source" value={data.source ?? null} />+ {stale != null && (+ <Row label="Staleness" value={`${Math.round(stale * 100)}%`} />+ )}+ </div>+ );+}++function OwnerMeta({ data }: { data?: import("./types").OwnerEntityMeta | undefined }) {+ if (!data) return null;+ return (+ <div className="space-y-1">+ {data.email && (+ <p className="font-mono text-[10px] text-[var(--color-text-secondary)] break-all">+ {data.email}+ </p>+ )}+ <Row label="Bus-factor files" value={data.busFactorFiles ?? null} />+ {data.topFiles && data.topFiles.length > 0 && (+ <div className="pt-1">+ <p className="text-[10px] uppercase tracking-wider text-[var(--color-text-tertiary)]">+ Top files+ </p>+ <ul className="mt-0.5 space-y-0.5">+ {data.topFiles.slice(0, 3).map((f) => (+ <li+ key={f}+ className="font-mono text-[10px] text-[var(--color-text-secondary)] truncate"+ title={f}+ >+ {f}+ </li>+ ))}+ </ul>+ </div>+ )}+ </div>+ );+}++function CommitMeta({ data }: { data?: import("./types").CommitEntityMeta | undefined }) {+ if (!data) return null;+ return (+ <div className="space-y-1">+ <Row label="Author" value={data.author ?? null} />+ <Row label="Date" value={data.date ?? null} />+ {data.message && (+ <p className="text-[11px] text-[var(--color-text-secondary)] line-clamp-2">+ {data.message}+ </p>+ )}+ </div>+ );+}++function Pill({+ children,+ tone,+}: {+ children: React.ReactNode;+ tone: "info" | "warn" | "error";+}) {+ const cls =+ tone === "error"+ ? "border-red-500/40 bg-red-500/10 text-red-400"+ : tone === "warn"+ ? "border-amber-500/40 bg-amber-500/10 text-amber-400"+ : "border-sky-500/40 bg-sky-500/10 text-sky-400";+ return (+ <span+ className={cn(+ "inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium",+ cls,+ )}+ >+ {children}+ </span>+ );+}diff --git a/packages/ui/src/shared/entity/entity-link.tsx b/packages/ui/src/shared/entity/entity-link.tsxnew file mode 100644index 000000000..ed05e5872--- /dev/null+++ b/packages/ui/src/shared/entity/entity-link.tsx@@ -0,0 +1,96 @@+"use client";++import * as React from "react";+import { cn } from "../../lib/cn";+import type { EntityMeta, EntityRef } from "./types";+import { defaultEntityLabel, resolveEntityHref } from "./routes";+import { EntityHoverCard } from "./entity-hover-card";++interface EntityLinkProps extends EntityRef {+ /** Optional metadata for the hover card. Hover card is omitted when undefined. */+ meta?: EntityMeta;+ /** Visual variant. Defaults to "inline" for use in prose / table cells. */+ variant?: "inline" | "monospace" | "plain";+ /** Override the resolved href (useful when nested inside an existing router). */+ href?: string;+ /**+ * Optional override for navigation. When supplied, the link calls onSelect+ * instead of letting the browser navigate. Used by the ContextDrawer+ * to intercept entity links and open the drawer in-place.+ */+ onSelect?: (entity: EntityRef) => void;+ className?: string;+ children?: React.ReactNode;+ title?: string;+}++/**+ * Single entry point for rendering any addressable Repowise entity.+ *+ * - resolves a canonical href via {@link resolveEntityHref}+ * - wraps in an {@link EntityHoverCard} when `meta` is provided+ * - delegates the click to a caller-supplied `onSelect` when present+ * (e.g. opening a ContextDrawer instead of navigating)+ *+ * Pure presentational: no router, no data fetching, no side effects.+ * Callers wire up navigation by either letting the anchor navigate+ * naturally or by intercepting `onSelect`.+ */+export const EntityLink = React.forwardRef<HTMLAnchorElement, EntityLinkProps>(+ function EntityLink(+ { kind, id, repoId, meta, variant = "inline", href, onSelect, className, children, title },+ ref,+ ) {+ const entity: EntityRef = repoId !== undefined ? { kind, id, repoId } : { kind, id };+ const resolvedHref = href ?? resolveEntityHref(entity);+ const label = children ?? defaultEntityLabel(entity);++ const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {+ if (!onSelect) return;+ // Only intercept "plain" left-clicks — preserve middle-click, ctrl/cmd+ // modifiers, and target=_blank semantics so power users can still open+ // entities in a new tab.+ if (+ event.defaultPrevented ||+ event.button !== 0 ||+ event.metaKey ||+ event.ctrlKey ||+ event.shiftKey ||+ event.altKey+ ) {+ return;+ }+ event.preventDefault();+ onSelect(entity);+ };++ const anchor = (+ <a+ ref={ref}+ href={resolvedHref}+ onClick={handleClick}+ title={title ?? id}+ data-entity-kind={kind}+ data-entity-id={id}+ className={cn(+ "transition-colors text-[var(--color-text-primary)] hover:text-[var(--color-accent-primary)]",+ variant === "inline" && "underline decoration-dotted underline-offset-2",+ variant === "monospace" &&+ "font-mono text-[12px] underline decoration-dotted underline-offset-2",+ variant === "plain" && "no-underline",+ className,+ )}+ >+ {label}+ </a>+ );++ if (!meta) return anchor;++ return (+ <EntityHoverCard entity={entity} meta={meta}>+ {anchor}+ </EntityHoverCard>+ );+ },+);diff --git a/packages/ui/src/shared/entity/index.ts b/packages/ui/src/shared/entity/index.tsnew file mode 100644index 000000000..7a494a113--- /dev/null+++ b/packages/ui/src/shared/entity/index.ts@@ -0,0 +1,17 @@+export { EntityLink } from "./entity-link";+export { EntityHoverCard } from "./entity-hover-card";+export {+ resolveEntityHref,+ defaultEntityLabel,+ ENTITY_KIND_LABEL,+} from "./routes";+export type {+ EntityKind,+ EntityRef,+ EntityMeta,+ FileEntityMeta,+ SymbolEntityMeta,+ DecisionEntityMeta,+ OwnerEntityMeta,+ CommitEntityMeta,+} from "./types";diff --git a/packages/ui/src/shared/entity/routes.ts b/packages/ui/src/shared/entity/routes.tsnew file mode 100644index 000000000..d37d1b569--- /dev/null+++ b/packages/ui/src/shared/entity/routes.ts@@ -0,0 +1,62 @@+import type { EntityKind, EntityRef } from "./types";++/**+ * Resolve the canonical href for an entity. Centralizing this here keeps every+ * link consistent and makes the route map auditable in one place.+ *+ * `repoId` is optional but required for file/symbol routing. When missing we+ * fall back to a relative anchor so callers can still render the link without+ * a known repo (e.g. inside cross-repo widgets).+ */+export function resolveEntityHref(ref: EntityRef): string {+ const { kind, id, repoId } = ref;+ if (!repoId && (kind === "file" || kind === "symbol" || kind === "decision")) {+ return `#${kind}:${encodeURIComponent(id)}`;+ }++ switch (kind) {+ case "file":+ return `/repos/${repoId}/wiki/${encodeURI(id)}`;+ case "symbol":+ return `/repos/${repoId}/symbols?symbol=${encodeURIComponent(id)}`;+ case "decision":+ return `/repos/${repoId}/decisions/${encodeURIComponent(id)}`;+ case "owner":+ // No dedicated owner page yet — deep-link into the Risk page heatmap.+ return repoId+ ? `/repos/${repoId}/risk?owner=${encodeURIComponent(id)}`+ : `#owner:${encodeURIComponent(id)}`;+ case "commit":+ return repoId+ ? `/repos/${repoId}/risk?commit=${encodeURIComponent(id)}`+ : `#commit:${encodeURIComponent(id)}`;+ }+}++/** Prefer a short, readable label for the entity (used as default link text). */+export function defaultEntityLabel(ref: EntityRef): string {+ const { kind, id } = ref;+ switch (kind) {+ case "file":+ return id.split("/").slice(-1)[0] || id;+ case "symbol": {+ const tail = id.split("::").slice(-1)[0] || id;+ return tail.split(".").slice(-1)[0] || tail;+ }+ case "owner":+ return id.includes("@") ? (id.split("@")[0] ?? id) : id;+ case "commit":+ return id.length > 7 ? id.slice(0, 7) : id;+ default:+ return id;+ }+}++/** Icon hint used by EntityLink and CommandPalette when no children supplied. */+export const ENTITY_KIND_LABEL: Record<EntityKind, string> = {+ file: "File",+ symbol: "Symbol",+ decision: "Decision",+ owner: "Owner",+ commit: "Commit",+};diff --git a/packages/ui/src/shared/entity/types.ts b/packages/ui/src/shared/entity/types.tsnew file mode 100644index 000000000..c0d1c62d9--- /dev/null+++ b/packages/ui/src/shared/entity/types.ts@@ -0,0 +1,66 @@+/**+ * Discriminated union of "entity kinds" addressable across the Repowise UI.+ * Every entity link, hover card, and context drawer entry uses this shape.+ *+ * Kept in `@repowise-dev/ui` (presentational layer) so the hosted frontend+ * inherits the same vocabulary without a data-layer import.+ */+export type EntityKind = "file" | "symbol" | "decision" | "owner" | "commit";++export interface EntityRef {+ kind: EntityKind;+ /**+ * Stable id for the entity in its kind's own namespace:+ * - file: relative path (e.g. "packages/core/src/.../graph.py")+ * - symbol: fully-qualified symbol id (e.g. "module.path::name")+ * - decision: decision record id+ * - owner: email (preferred) or display name fallback+ * - commit: 40-char SHA (or short SHA accepted)+ */+ id: string;+ /** Repo scope for entities that are repo-relative. */+ repoId?: string;+}++export interface FileEntityMeta {+ owner?: string | null;+ churnPercentile?: number | null;+ busFactor?: number | null;+ hasDocs?: boolean;+ hasDeadCode?: boolean;+ language?: string | null;+}++export interface SymbolEntityMeta {+ signature?: string | null;+ complexity?: number | null;+ callerCount?: number | null;+ isAsync?: boolean;+ visibility?: string | null;+}++export interface DecisionEntityMeta {+ status?: string | null;+ stalenessScore?: number | null;+ source?: string | null;+}++export interface OwnerEntityMeta {+ busFactorFiles?: number | null;+ topFiles?: string[];+ email?: string | null;+}++export interface CommitEntityMeta {+ shortSha?: string;+ message?: string | null;+ author?: string | null;+ date?: string | null;+}++export type EntityMeta =+ | { kind: "file"; data?: FileEntityMeta }+ | { kind: "symbol"; data?: SymbolEntityMeta }+ | { kind: "decision"; data?: DecisionEntityMeta }+ | { kind: "owner"; data?: OwnerEntityMeta }+ | { kind: "commit"; data?: CommitEntityMeta };diff --git a/packages/ui/src/shared/file-card/file-card-dialog.tsx b/packages/ui/src/shared/file-card/file-card-dialog.tsxnew file mode 100644index 000000000..c7f32b500--- /dev/null+++ b/packages/ui/src/shared/file-card/file-card-dialog.tsx@@ -0,0 +1,38 @@+"use client";++import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from "../../ui/dialog";+import { FileCard } from "./file-card";+import type { FileCardData, FileCardLinks } from "./types";++export interface FileCardDialogProps {+ open: boolean;+ onOpenChange: (open: boolean) => void;+ data: FileCardData | null;+ links?: FileCardLinks | undefined;+}++export function FileCardDialog({ open, onOpenChange, data, links }: FileCardDialogProps) {+ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent className="max-w-[95vw] w-[760px] max-h-[85vh] overflow-y-auto">+ {data && (+ <>+ <DialogHeader>+ <DialogTitle className="font-mono text-sm break-all leading-snug">+ {data.file_path}+ </DialogTitle>+ {data.summary ? (+ <DialogDescription className="text-xs">{data.summary}</DialogDescription>+ ) : (+ <DialogDescription className="text-xs">+ File overview — git, docs, symbols, and risk signals at a glance.+ </DialogDescription>+ )}+ </DialogHeader>+ <FileCard data={data} links={links} hideHeader />+ </>+ )}+ </DialogContent>+ </Dialog>+ );+}diff --git a/packages/ui/src/shared/file-card/file-card.tsx b/packages/ui/src/shared/file-card/file-card.tsxnew file mode 100644index 000000000..3638fbede--- /dev/null+++ b/packages/ui/src/shared/file-card/file-card.tsx@@ -0,0 +1,240 @@+"use client";++import {+ FileText,+ GitBranch,+ BookOpen,+ Radius,+ Code2,+ Trash2,+ ShieldAlert,+ Flame,+ Users,+ ExternalLink,+} from "lucide-react";+import { Badge } from "../../ui/badge";+import { formatLOC } from "../../lib/format";+import { cn } from "../../lib/cn";+import type { FileCardData, FileCardLinks } from "./types";++export interface FileCardProps {+ data: FileCardData;+ links?: FileCardLinks | undefined;+ /** Hide the file path header (when used inside a Dialog that already shows it). */+ hideHeader?: boolean;+ className?: string;+}++function Section({ title, icon: Icon, children }: { title: string; icon: React.ComponentType<{ className?: string }>; children: React.ReactNode }) {+ return (+ <div>+ <div className="flex items-center gap-1.5 mb-1.5">+ <Icon className="h-3.5 w-3.5 text-[var(--color-text-tertiary)]" />+ <span className="text-[10px] font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">+ {title}+ </span>+ </div>+ <div className="text-xs text-[var(--color-text-secondary)] space-y-1">{children}</div>+ </div>+ );+}++function Stat({ label, value, accent }: { label: string; value: React.ReactNode; accent?: string }) {+ return (+ <div className="flex items-baseline justify-between gap-2">+ <span className="text-[var(--color-text-tertiary)]">{label}</span>+ <span className={cn("tabular-nums font-medium", accent ?? "text-[var(--color-text-primary)]")}>{value}</span>+ </div>+ );+}++function LinkButton({ href, icon: Icon, label }: { href: string; icon: React.ComponentType<{ className?: string }>; label: string }) {+ return (+ <a+ href={href}+ className="inline-flex items-center gap-1 rounded-md border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] px-2 py-1 text-[11px] text-[var(--color-text-secondary)] hover:border-[var(--color-accent-primary)] hover:text-[var(--color-text-primary)] transition-colors"+ >+ <Icon className="h-3 w-3" />+ <span>{label}</span>+ </a>+ );+}++export function FileCard({ data, links, hideHeader = false, className }: FileCardProps) {+ const { git, docs, symbols, deadCode, decisions, security } = data;+ const busFactor = git?.bus_factor;+ const isHotspot = git?.is_hotspot;++ return (+ <div className={cn("space-y-4", className)}>+ {!hideHeader && (+ <div className="space-y-1">+ <div className="flex items-start gap-2">+ <FileText className="h-4 w-4 text-[var(--color-text-tertiary)] shrink-0 mt-0.5" />+ <p className="text-sm font-mono text-[var(--color-text-primary)] break-all leading-snug">+ {data.file_path}+ </p>+ </div>+ <div className="flex flex-wrap gap-1.5 pl-6">+ {data.language && <Badge variant="outline">{data.language}</Badge>}+ {isHotspot && (+ <Badge variant="outdated" className="gap-1">+ <Flame className="h-3 w-3" /> hotspot+ </Badge>+ )}+ {busFactor !== undefined && busFactor <= 1 && (+ <Badge variant="outline" className="gap-1 text-red-400 border-red-400/30">+ <Users className="h-3 w-3" /> bus×{busFactor}+ </Badge>+ )}+ </div>+ {data.summary && (+ <p className="pl-6 text-xs text-[var(--color-text-secondary)] leading-relaxed">+ {data.summary}+ </p>+ )}+ </div>+ )}++ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">+ {git && (+ <Section title="Git activity (90d)" icon={GitBranch}>+ {git.commit_count_90d !== undefined && (+ <Stat label="Commits" value={git.commit_count_90d} />+ )}+ {git.churn_percentile !== undefined && (+ <Stat label="Churn percentile" value={`${Math.round(git.churn_percentile)}%`} />+ )}+ {(git.lines_added_90d !== undefined || git.lines_deleted_90d !== undefined) && (+ <Stat+ label="Lines"+ value={+ <>+ <span className="text-green-400">+{formatLOC(git.lines_added_90d ?? 0)}</span>{" "}+ <span className="text-red-400">-{formatLOC(git.lines_deleted_90d ?? 0)}</span>+ </>+ }+ />+ )}+ {git.primary_owner && (+ <Stat label="Owner" value={<span className="truncate max-w-[160px] inline-block align-bottom">{git.primary_owner}</span>} />+ )}+ {git.temporal_hotspot_score != null && (+ <Stat+ label="Trend score"+ value={git.temporal_hotspot_score.toFixed(2)}+ accent={+ git.temporal_hotspot_score >= 5+ ? "text-red-400"+ : git.temporal_hotspot_score >= 2+ ? "text-orange-400"+ : "text-[var(--color-text-secondary)]"+ }+ />+ )}+ </Section>+ )}++ {docs && (+ <Section title="Documentation" icon={BookOpen}>+ {docs.has_doc ? (+ <>+ <Stat+ label="Status"+ value={<span className="text-green-400">Indexed</span>}+ />+ {docs.freshness_pct !== undefined && (+ <Stat label="Freshness" value={`${Math.round(docs.freshness_pct)}%`} />+ )}+ {docs.last_updated && (+ <Stat label="Updated" value={docs.last_updated} />+ )}+ {docs.doc_url && (+ <a+ href={docs.doc_url}+ className="inline-flex items-center gap-1 mt-1 text-[var(--color-accent-primary)] hover:underline text-[11px]"+ >+ Open doc <ExternalLink className="h-3 w-3" />+ </a>+ )}+ </>+ ) : (+ <p className="text-[var(--color-text-tertiary)] italic text-[11px]">+ No doc generated for this file yet.+ </p>+ )}+ </Section>+ )}++ {symbols && (+ <Section title={`Symbols (${symbols.total})`} icon={Code2}>+ {symbols.top && symbols.top.length > 0 ? (+ symbols.top.slice(0, 5).map((s) => (+ <div key={s.id} className="flex items-baseline justify-between gap-2 text-[11px]">+ <span className="font-mono text-[var(--color-text-primary)] truncate">{s.name}</span>+ {s.kind && <span className="text-[var(--color-text-tertiary)] shrink-0">{s.kind}</span>}+ </div>+ ))+ ) : (+ <p className="text-[var(--color-text-tertiary)] italic text-[11px]">No symbols indexed.</p>+ )}+ </Section>+ )}++ {decisions && decisions.count > 0 && (+ <Section title={`Decisions (${decisions.count})`} icon={BookOpen}>+ {decisions.titles && decisions.titles.length > 0 ? (+ decisions.titles.slice(0, 4).map((t, i) => (+ <p key={i} className="text-[11px] text-[var(--color-text-primary)] truncate">+ · {t}+ </p>+ ))+ ) : (+ <p className="text-[11px] text-[var(--color-text-tertiary)]">+ {decisions.count} decision{decisions.count === 1 ? "" : "s"} reference this file.+ </p>+ )}+ </Section>+ )}++ {deadCode && deadCode.findings_count > 0 && (+ <Section title="Dead code" icon={Trash2}>+ <Stat label="Findings" value={deadCode.findings_count} accent="text-red-400" />+ {deadCode.reclaimable_lines !== undefined && (+ <Stat+ label="Lines reclaimable"+ value={formatLOC(deadCode.reclaimable_lines)}+ accent="text-red-400"+ />+ )}+ </Section>+ )}++ {security && security.findings_count > 0 && (+ <Section title="Security" icon={ShieldAlert}>+ <Stat label="Findings" value={security.findings_count} accent="text-red-400" />+ {security.critical_count !== undefined && security.critical_count > 0 && (+ <Stat+ label="Critical"+ value={security.critical_count}+ accent="text-red-400"+ />+ )}+ </Section>+ )}+ </div>++ {links && Object.values(links).some(Boolean) && (+ <div className="flex flex-wrap gap-1.5 pt-2 border-t border-[var(--color-border-default)]">+ {links.graph && <LinkButton href={links.graph} icon={GitBranch} label="Graph" />}+ {links.docs && <LinkButton href={links.docs} icon={BookOpen} label="Docs" />}+ {links.symbols && <LinkButton href={links.symbols} icon={Code2} label="Symbols" />}+ {links.blastRadius && <LinkButton href={links.blastRadius} icon={Radius} label="Blast Radius" />}+ {links.decisions && <LinkButton href={links.decisions} icon={BookOpen} label="Decisions" />}+ {links.deadCode && <LinkButton href={links.deadCode} icon={Trash2} label="Dead code" />}+ {links.security && <LinkButton href={links.security} icon={ShieldAlert} label="Security" />}+ </div>+ )}+ </div>+ );+}diff --git a/packages/ui/src/shared/file-card/index.ts b/packages/ui/src/shared/file-card/index.tsnew file mode 100644index 000000000..71b3d496b--- /dev/null+++ b/packages/ui/src/shared/file-card/index.ts@@ -0,0 +1,5 @@+export { FileCard } from "./file-card";+export type { FileCardProps } from "./file-card";+export { FileCardDialog } from "./file-card-dialog";+export type { FileCardDialogProps } from "./file-card-dialog";+export type { FileCardData, FileCardLinks } from "./types";diff --git a/packages/ui/src/shared/file-card/types.ts b/packages/ui/src/shared/file-card/types.tsnew file mode 100644index 000000000..6a2cd18aa--- /dev/null+++ b/packages/ui/src/shared/file-card/types.ts@@ -0,0 +1,65 @@+/**+ * Universal file overview shape — render whatever sections have data.+ * Hosts pass undefined to hide a section. Designed to be assembled from+ * data already on the page (no extra fetches required) but also fine to+ * source from dedicated endpoints.+ */+export interface FileCardData {+ file_path: string;+ language?: string;+ summary?: string;++ /** Git / churn / ownership signals. */+ git?: {+ churn_percentile?: number;+ commit_count_90d?: number;+ lines_added_90d?: number;+ lines_deleted_90d?: number;+ bus_factor?: number;+ primary_owner?: string | null;+ is_hotspot?: boolean;+ temporal_hotspot_score?: number | null;+ };++ /** Documentation status. When `has_doc` is false the section becomes a CTA. */+ docs?: {+ has_doc: boolean;+ doc_url?: string;+ freshness_pct?: number; // 0–100+ last_updated?: string;+ };++ /** Symbols summary. */+ symbols?: {+ total: number;+ top?: Array<{ id: string; name: string; kind?: string; importance?: number }>;+ };++ /** Dead-code findings affecting this file. */+ deadCode?: {+ findings_count: number;+ reclaimable_lines?: number;+ };++ /** Decisions affecting this file (from affected_modules_json). */+ decisions?: {+ count: number;+ titles?: string[];+ };++ /** Security findings on this file. */+ security?: {+ findings_count: number;+ critical_count?: number;+ };+}++export interface FileCardLinks {+ graph?: string;+ docs?: string;+ blastRadius?: string;+ symbols?: string;+ decisions?: string;+ security?: string;+ deadCode?: string;+}diff --git a/packages/ui/src/shared/index.ts b/packages/ui/src/shared/index.tsindex 5a9cdbac3..2e7336df9 100644--- a/packages/ui/src/shared/index.ts+++ b/packages/ui/src/shared/index.ts@@ -3,3 +3,4 @@ export * from "./breadcrumb.js";export * from "./empty-state.js";export * from "./stat-card.js";export { RowActions, type RowAction } from "./row-actions";+export * from "./entity";diff --git a/packages/ui/src/shared/related/index.ts b/packages/ui/src/shared/related/index.tsnew file mode 100644index 000000000..1670db338--- /dev/null+++ b/packages/ui/src/shared/related/index.ts@@ -0,0 +1,2 @@+export { RelatedAcrossRepowise } from "./related-across-repowise";+export type { RelatedAcrossRepowiseProps, RelatedSection } from "./related-across-repowise";diff --git a/packages/ui/src/shared/related/related-across-repowise.tsx b/packages/ui/src/shared/related/related-across-repowise.tsxnew file mode 100644index 000000000..2efd088f7--- /dev/null+++ b/packages/ui/src/shared/related/related-across-repowise.tsx@@ -0,0 +1,87 @@+"use client";++import { useState } from "react";+import { ChevronDown, ChevronRight, Compass } from "lucide-react";++export interface RelatedSection {+ id: string;+ label: string;+ /** Optional count shown as a chip in the header. */+ count?: number;+ /** Render the body. Lazy so collapsed sections don't pay render cost. */+ render: () => React.ReactNode;+}++export interface RelatedAcrossRepowiseProps {+ sections: RelatedSection[];+ /** Defaults to "Related across Repowise". */+ title?: string;+ /** Sections to start expanded. Defaults to none. */+ defaultExpanded?: string[];+}++/**+ * Universal footer attached to every entity page (file, symbol, decision,+ * wiki). Renders only sections that the host actually populates — sections+ * whose `render()` returns null are filtered out before rendering.+ */+export function RelatedAcrossRepowise({+ sections,+ title = "Related across Repowise",+ defaultExpanded = [],+}: RelatedAcrossRepowiseProps) {+ const [expanded, setExpanded] = useState<Set<string>>(new Set(defaultExpanded));++ if (sections.length === 0) return null;++ const toggle = (id: string) =>+ setExpanded((prev) => {+ const next = new Set(prev);+ if (next.has(id)) next.delete(id);+ else next.add(id);+ return next;+ });++ return (+ <section className="rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-surface)]">+ <header className="flex items-center gap-2 px-4 py-3 border-b border-[var(--color-border-default)]">+ <Compass className="h-4 w-4 text-[var(--color-text-tertiary)]" />+ <h2 className="text-xs font-medium uppercase tracking-wider text-[var(--color-text-tertiary)]">+ {title}+ </h2>+ </header>+ <ul className="divide-y divide-[var(--color-border-default)]">+ {sections.map((s) => {+ const isOpen = expanded.has(s.id);+ return (+ <li key={s.id}>+ <button+ type="button"+ onClick={() => toggle(s.id)}+ aria-expanded={isOpen}+ className="w-full flex items-center gap-2 px-4 py-2.5 text-left hover:bg-[var(--color-bg-elevated)] transition-colors"+ >+ {isOpen ? (+ <ChevronDown className="h-3.5 w-3.5 text-[var(--color-text-tertiary)] shrink-0" />+ ) : (+ <ChevronRight className="h-3.5 w-3.5 text-[var(--color-text-tertiary)] shrink-0" />+ )}+ <span className="text-sm text-[var(--color-text-primary)] flex-1">{s.label}</span>+ {s.count !== undefined && s.count > 0 && (+ <span className="rounded-full bg-[var(--color-bg-elevated)] px-2 py-0.5 text-[10px] tabular-nums text-[var(--color-text-secondary)]">+ {s.count}+ </span>+ )}+ </button>+ {isOpen && (+ <div className="px-4 pb-3 pt-1 text-sm text-[var(--color-text-secondary)]">+ {s.render()}+ </div>+ )}+ </li>+ );+ })}+ </ul>+ </section>+ );+}diff --git a/packages/ui/src/symbols/hot-symbols-board.tsx b/packages/ui/src/symbols/hot-symbols-board.tsxnew file mode 100644index 000000000..3c8b540cf--- /dev/null+++ b/packages/ui/src/symbols/hot-symbols-board.tsx@@ -0,0 +1,89 @@+"use client";++import { Flame, ArrowRight } from "lucide-react";+import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";+import { Badge } from "../ui/badge";+import { cn } from "../lib/cn";+import type { CodeSymbol } from "@repowise-dev/types/symbols";++export interface HotSymbol {+ symbol: CodeSymbol;+ /** Composite hotness score (higher = hotter). */+ score: number;+ pagerank?: number;+}++export interface HotSymbolsBoardProps {+ items: HotSymbol[];+ /** Cap items rendered (default 8). */+ limit?: number;+ onSelect?: (sym: CodeSymbol) => void;+ className?: string;+}++export function HotSymbolsBoard({ items, limit = 8, onSelect, className }: HotSymbolsBoardProps) {+ const top = items.slice(0, limit);+ if (top.length === 0) {+ return null;+ }+ const max = top[0]?.score ?? 1;++ return (+ <Card className={className}>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm flex items-center gap-2">+ <Flame className="h-4 w-4 text-orange-500" />+ Hot symbols+ <span className="text-[10px] font-normal text-[var(--color-text-tertiary)] uppercase tracking-wider">+ churn × centrality × complexity+ </span>+ </CardTitle>+ </CardHeader>+ <CardContent className="pt-0">+ <div className="grid grid-cols-1 md:grid-cols-2 gap-2">+ {top.map(({ symbol, score }) => {+ const intensity = max > 0 ? score / max : 0;+ return (+ <button+ key={symbol.id}+ onClick={onSelect ? () => onSelect(symbol) : undefined}+ disabled={!onSelect}+ className={cn(+ "group rounded-md border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] px-3 py-2 text-left transition-colors",+ onSelect && "hover:border-[var(--color-accent-primary)] cursor-pointer",+ )}+ title={`${symbol.file_path}:${symbol.start_line}`}+ >+ <div className="flex items-center justify-between gap-2 mb-1">+ <span className="font-mono text-xs text-[var(--color-text-primary)] truncate">+ {symbol.name}+ </span>+ <ArrowRight className="h-3 w-3 text-[var(--color-text-tertiary)] shrink-0 opacity-0 group-hover:opacity-100 transition-opacity" />+ </div>+ <div className="flex flex-wrap items-center gap-1 mb-1.5">+ <Badge variant="outline" className="text-[10px] h-4">+ {symbol.kind}+ </Badge>+ {symbol.complexity_estimate > 10 && (+ <Badge variant="stale" className="text-[10px] h-4">+ cx {symbol.complexity_estimate}+ </Badge>+ )}+ </div>+ <p className="text-[10px] font-mono text-[var(--color-text-tertiary)] truncate">+ {symbol.file_path}:{symbol.start_line}+ </p>+ <div className="mt-1.5 h-1 rounded-full bg-[var(--color-bg-inset)] overflow-hidden">+ <div+ className="h-full rounded-full bg-orange-500"+ style={{ width: `${Math.round(intensity * 100)}%` }}+ />+ </div>+ </button>+ );+ })}+ </div>+ </CardContent>+ </Card>+ );+}diff --git a/packages/ui/src/symbols/index.ts b/packages/ui/src/symbols/index.tsindex 571ff663a..0f2d52494 100644--- a/packages/ui/src/symbols/index.ts+++ b/packages/ui/src/symbols/index.ts@@ -1,3 +1,4 @@export * from "./symbol-table.js";export * from "./symbol-drawer.js";export * from "./symbol-graph-panel.js";+export * from "./hot-symbols-board.js";diff --git a/packages/ui/src/symbols/symbol-drawer.tsx b/packages/ui/src/symbols/symbol-drawer.tsxindex 428f2264d..920da7eac 100644--- a/packages/ui/src/symbols/symbol-drawer.tsx+++ b/packages/ui/src/symbols/symbol-drawer.tsx@@ -26,7 +26,7 @@ interface SymbolDrawerProps {export function SymbolDrawer({ symbol, onClose, graphPanel }: SymbolDrawerProps) {return (<Dialog open={symbol !== null} onOpenChange={(open) => !open && onClose()}>- <DialogContent className="max-w-[90vw] w-[900px] max-h-[85vh] overflow-hidden p-0">+ <DialogContent className="max-w-[95vw] w-[1000px] max-h-[88vh] overflow-hidden p-0">{symbol && (<><div className="px-6 pt-6 pb-3">@@ -80,7 +80,7 @@ export function SymbolDrawer({ symbol, onClose, graphPanel }: SymbolDrawerProps)</ScrollArea>{graphPanel && (- <div className="hidden md:flex flex-col border-l border-[var(--color-border-default)] bg-[var(--color-bg-surface)] w-[280px] shrink-0 overflow-hidden">+ <div className="hidden md:flex flex-col border-l border-[var(--color-border-default)] bg-[var(--color-bg-surface)] w-[340px] shrink-0 overflow-hidden">{graphPanel}</div>)}diff --git a/packages/ui/src/symbols/symbol-graph-panel.tsx b/packages/ui/src/symbols/symbol-graph-panel.tsxindex 18a020e7a..6b06704fb 100644--- a/packages/ui/src/symbols/symbol-graph-panel.tsx+++ b/packages/ui/src/symbols/symbol-graph-panel.tsx@@ -114,7 +114,7 @@ export function SymbolGraphPanel({return (<ScrollArea className="h-full">- <div className="space-y-4 p-1">+ <div className="space-y-4 px-3 py-3"><div><p className="text-[11px] font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider mb-2">Graph Metricsdiff --git a/packages/ui/src/wiki/mermaid-diagram.tsx b/packages/ui/src/wiki/mermaid-diagram.tsxindex 0947d2c4a..0303b4516 100644--- a/packages/ui/src/wiki/mermaid-diagram.tsx+++ b/packages/ui/src/wiki/mermaid-diagram.tsx@@ -1,65 +1,221 @@"use client";import { useEffect, useRef, useState } from "react";+import { Maximize2, X, ZoomIn, ZoomOut, RotateCcw } from "lucide-react";interface MermaidDiagramProps {chart: string;}-export function MermaidDiagram({ chart }: MermaidDiagramProps) {- const ref = useRef<HTMLDivElement>(null);+let mermaidInitialized = false;++async function ensureMermaid() {+ const { default: mermaid } = await import("mermaid");+ if (!mermaidInitialized) {+ mermaid.initialize({+ startOnLoad: false,+ theme: "dark",+ themeVariables: {+ background: "#141414",+ primaryColor: "#1c1c1c",+ primaryBorderColor: "#3f3f46",+ primaryTextColor: "#e4e4e7",+ secondaryColor: "#1c1c1c",+ tertiaryColor: "#0a0a0a",+ lineColor: "#52525b",+ textColor: "#e4e4e7",+ nodeBorder: "#3f3f46",+ clusterBkg: "#0a0a0a",+ clusterBorder: "#3f3f46",+ edgeLabelBackground: "#1c1c1c",+ },+ flowchart: { htmlLabels: true, curve: "basis", padding: 12 },+ securityLevel: "loose",+ });+ mermaidInitialized = true;+ }+ return mermaid;+}++function useMermaidRender(chart: string, target: HTMLDivElement | null) {const [error, setError] = useState<string | null>(null);useEffect(() => {- if (!ref.current) return;- const el = ref.current;-- import("mermaid").then(({ default: mermaid }) => {- mermaid.initialize({- startOnLoad: false,- theme: "dark",- themeVariables: {- background: "#1a1a2e",- primaryColor: "#5B9CF6",- primaryTextColor: "#e2e8f0",- lineColor: "#334155",- },- });-+ if (!target) return;+ let cancelled = false;+ setError(null);+ ensureMermaid().then((mermaid) => {const id = `mermaid-${Math.random().toString(36).slice(2)}`;mermaid.render(id, chart).then(({ svg }) => {- el.innerHTML = svg;- const svgEl = el.querySelector("svg");+ if (cancelled || !target) return;+ target.innerHTML = svg;+ const svgEl = target.querySelector("svg");if (svgEl) {svgEl.removeAttribute("width");svgEl.removeAttribute("height");svgEl.style.maxWidth = "100%";svgEl.style.height = "auto";+ svgEl.style.display = "block";}}).catch((e: unknown) => {- setError(e instanceof Error ? e.message : "Diagram render failed");+ if (!cancelled) setError(e instanceof Error ? e.message : "Diagram render failed");});});- }, [chart]);+ return () => {+ cancelled = true;+ };+ }, [chart, target]);++ return error;+}++function MaximizedDialog({ chart, onClose }: { chart: string; onClose: () => void }) {+ const [container, setContainer] = useState<HTMLDivElement | null>(null);+ const [zoom, setZoom] = useState(1);+ const [pan, setPan] = useState({ x: 0, y: 0 });+ const dragRef = useRef<{ startX: number; startY: number; panX: number; panY: number } | null>(null);+ const error = useMermaidRender(chart, container);++ useEffect(() => {+ const onKey = (e: KeyboardEvent) => {+ if (e.key === "Escape") onClose();+ };+ document.addEventListener("keydown", onKey);+ return () => document.removeEventListener("keydown", onKey);+ }, [onClose]);++ const onMouseDown = (e: React.MouseEvent) => {+ dragRef.current = { startX: e.clientX, startY: e.clientY, panX: pan.x, panY: pan.y };+ };+ const onMouseMove = (e: React.MouseEvent) => {+ if (!dragRef.current) return;+ setPan({+ x: dragRef.current.panX + (e.clientX - dragRef.current.startX),+ y: dragRef.current.panY + (e.clientY - dragRef.current.startY),+ });+ };+ const onMouseUp = () => {+ dragRef.current = null;+ };++ const reset = () => {+ setZoom(1);+ setPan({ x: 0, y: 0 });+ };++ return (+ <div+ role="dialog"+ aria-modal="true"+ aria-label="Maximized diagram"+ className="fixed inset-0 z-50 flex flex-col bg-[var(--color-bg-inset)]/95 backdrop-blur-sm"+ >+ <div className="flex items-center justify-between gap-2 border-b border-[var(--color-border-default)] bg-[var(--color-bg-surface)] px-4 py-2">+ <span className="text-xs font-medium uppercase tracking-wider text-[var(--color-text-tertiary)]">+ Diagram+ </span>+ <div className="flex items-center gap-1">+ <button+ type="button"+ onClick={() => setZoom((z) => Math.max(0.25, z - 0.25))}+ className="p-1.5 rounded hover:bg-[var(--color-bg-elevated)] text-[var(--color-text-secondary)]"+ aria-label="Zoom out"+ >+ <ZoomOut className="h-4 w-4" />+ </button>+ <span className="text-xs font-mono tabular-nums text-[var(--color-text-tertiary)] w-12 text-center">+ {Math.round(zoom * 100)}%+ </span>+ <button+ type="button"+ onClick={() => setZoom((z) => Math.min(4, z + 0.25))}+ className="p-1.5 rounded hover:bg-[var(--color-bg-elevated)] text-[var(--color-text-secondary)]"+ aria-label="Zoom in"+ >+ <ZoomIn className="h-4 w-4" />+ </button>+ <button+ type="button"+ onClick={reset}+ className="p-1.5 rounded hover:bg-[var(--color-bg-elevated)] text-[var(--color-text-secondary)]"+ aria-label="Reset zoom"+ >+ <RotateCcw className="h-4 w-4" />+ </button>+ <button+ type="button"+ onClick={onClose}+ className="ml-2 p-1.5 rounded hover:bg-[var(--color-bg-elevated)] text-[var(--color-text-secondary)]"+ aria-label="Close"+ >+ <X className="h-4 w-4" />+ </button>+ </div>+ </div>+ <div+ className="flex-1 overflow-hidden cursor-grab active:cursor-grabbing"+ onMouseDown={onMouseDown}+ onMouseMove={onMouseMove}+ onMouseUp={onMouseUp}+ onMouseLeave={onMouseUp}+ >+ {error ? (+ <p className="p-6 text-sm text-red-400">Mermaid error: {error}</p>+ ) : (+ <div+ className="w-full h-full flex items-center justify-center"+ style={{+ transform: `translate(${pan.x}px, ${pan.y}px) scale(${zoom})`,+ transformOrigin: "center center",+ transition: dragRef.current ? "none" : "transform 0.12s ease-out",+ }}+ >+ <div ref={setContainer} className="max-w-none [&_svg]:!max-w-none [&_svg]:!h-auto" />+ </div>+ )}+ </div>+ </div>+ );+}++export function MermaidDiagram({ chart }: MermaidDiagramProps) {+ const [container, setContainer] = useState<HTMLDivElement | null>(null);+ const [maximized, setMaximized] = useState(false);+ const error = useMermaidRender(chart, container);if (error) {return (- <div className="rounded border border-[var(--color-border-default)] p-3 text-xs text-[var(--color-outdated)]">+ <div className="rounded border border-[var(--color-border-default)] p-3 text-xs text-red-400">Mermaid error: {error}</div>);}return (- <figure- role="img"- aria-label="Mermaid diagram"- className="my-4 flex justify-center overflow-x-auto rounded border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] p-4"- >- <div ref={ref} className="w-full" />- </figure>+ <>+ <figure+ role="img"+ aria-label="Mermaid diagram"+ className="group relative my-4 overflow-x-auto rounded border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)]"+ >+ <button+ type="button"+ onClick={() => setMaximized(true)}+ className="absolute top-2 right-2 z-10 rounded-md border border-[var(--color-border-default)] bg-[var(--color-bg-surface)]/80 backdrop-blur p-1.5 text-[var(--color-text-secondary)] opacity-0 group-hover:opacity-100 hover:text-[var(--color-text-primary)] transition-opacity"+ aria-label="Maximize diagram"+ title="Maximize"+ >+ <Maximize2 className="h-3.5 w-3.5" />+ </button>+ <div className="flex justify-center p-4">+ <div ref={setContainer} className="w-full" />+ </div>+ </figure>++ {maximized && <MaximizedDialog chart={chart} onClose={() => setMaximized(false)} />}+ </>);}diff --git a/packages/web/src/app/layout.tsx b/packages/web/src/app/layout.tsxindex 21866ca9a..e70bbbb7d 100644--- a/packages/web/src/app/layout.tsx+++ b/packages/web/src/app/layout.tsx@@ -7,6 +7,7 @@ import { TooltipProvider } from "@repowise-dev/ui/ui/tooltip";import { Sidebar } from "@/components/layout/sidebar";import { MobileNav } from "@/components/layout/mobile-nav";import { CommandPalette } from "@/components/search/command-palette";+import { ContextDrawerShell } from "@/components/layout/context-drawer-provider";import { listRepos } from "@/lib/api/repos";import { getWorkspace } from "@/lib/api/workspace";import type { WorkspaceResponse } from "@/lib/api/types";@@ -54,16 +55,18 @@ export default async function RootLayout({</a><NuqsAdapter><TooltipProvider delayDuration={300}>- <div className="flex h-screen overflow-hidden">- <Sidebar repos={repos} workspace={workspace} />- <div className="flex flex-1 flex-col min-w-0 overflow-hidden">- <MobileNav repos={repos} workspace={workspace} />- <main id="main-content" className="flex-1 overflow-auto min-w-0">- {children}- </main>+ <ContextDrawerShell>+ <div className="flex h-screen overflow-hidden">+ <Sidebar repos={repos} workspace={workspace} />+ <div className="flex flex-1 flex-col min-w-0 overflow-hidden">+ <MobileNav repos={repos} workspace={workspace} />+ <main id="main-content" className="flex-1 overflow-auto min-w-0">+ {children}+ </main>+ </div></div>- </div>- <CommandPalette repos={repos} workspace={workspace} />+ <CommandPalette repos={repos} workspace={workspace} />+ </ContextDrawerShell></TooltipProvider></NuqsAdapter><Toasterdiff --git a/packages/web/src/app/repos/[id]/blast-radius/page.tsx b/packages/web/src/app/repos/[id]/blast-radius/page.tsxindex fcd294a23..08045f48e 100644--- a/packages/web/src/app/repos/[id]/blast-radius/page.tsx+++ b/packages/web/src/app/repos/[id]/blast-radius/page.tsx@@ -4,6 +4,7 @@ import { useState } from "react";import useSWR from "swr";import { useParams } from "next/navigation";import { Radar, Plus, Flame } from "lucide-react";+import { RoutedToRiskBanner } from "@/components/risk/routed-to-risk-banner";import { Button } from "@repowise-dev/ui/ui/button";import { Card, CardHeader, CardTitle, CardContent } from "@repowise-dev/ui/ui/card";import { Skeleton } from "@repowise-dev/ui/ui/skeleton";@@ -74,6 +75,7 @@ export default function BlastRadiusPage() {return (<div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">+ <RoutedToRiskBanner repoId={repoId} tab="impact" tabLabel="Impact analyzer" />{/* Header */}<div><h1 className="text-xl font-semibold text-[var(--color-text-primary)] mb-1 flex items-center gap-2">diff --git a/packages/web/src/app/repos/[id]/costs/page.tsx b/packages/web/src/app/repos/[id]/costs/page.tsxindex 6d381325b..929bc203a 100644--- a/packages/web/src/app/repos/[id]/costs/page.tsx+++ b/packages/web/src/app/repos/[id]/costs/page.tsx@@ -15,22 +15,21 @@ import {import { StatCard } from "@repowise-dev/ui/shared/stat-card";import { Card, CardContent, CardHeader, CardTitle } from "@repowise-dev/ui/ui/card";import { Skeleton } from "@repowise-dev/ui/ui/skeleton";+import { Tabs, TabsList, TabsTrigger, TabsContent } from "@repowise-dev/ui/ui/tabs";+import {+ CacheHitRatioCard,+ CostHeatmap,+ ProviderComparison,+ OperationBreakdown,+} from "@repowise-dev/ui/costs";import { listCosts, getCostSummary } from "@/lib/api/costs";import type { CostGroup, CostSummary } from "@/lib/api/costs";import { formatCost, formatNumber, formatTokens } from "@repowise-dev/ui/lib/format";-type GroupBy = "day" | "model" | "operation";--const GROUP_BY_OPTIONS: { label: string; value: GroupBy }[] = [- { label: "By Day", value: "day" },- { label: "By Model", value: "model" },- { label: "By Operation", value: "operation" },-];-export default function CostsPage() {const params = useParams<{ id: string }>();const id = params.id;- const [by, setBy] = useState<GroupBy>("day");+ const [tab, setTab] = useState("daily");const { data: summary, isLoading: loadingSummary } = useSWR<CostSummary>(`costs-summary:${id}`,@@ -38,15 +37,26 @@ export default function CostsPage() {{ revalidateOnFocus: false },);- const { data: groups, isLoading: loadingGroups } = useSWR<CostGroup[]>(- `costs-groups:${id}:${by}`,- () => listCosts(id, { by }),+ const { data: dayGroups, isLoading: loadingDay } = useSWR<CostGroup[]>(+ `costs-groups:${id}:day`,+ () => listCosts(id, { by: "day" }),+ { revalidateOnFocus: false },+ );++ const { data: modelGroups } = useSWR<CostGroup[]>(+ `costs-groups:${id}:model`,+ () => listCosts(id, { by: "model" }),+ { revalidateOnFocus: false },+ );++ const { data: opGroups } = useSWR<CostGroup[]>(+ `costs-groups:${id}:operation`,+ () => listCosts(id, { by: "operation" }),{ revalidateOnFocus: false },);return (<div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">- {/* Header */}<div><h1 className="text-xl font-semibold text-[var(--color-text-primary)] mb-1 flex items-center gap-2"><DollarSign className="h-5 w-5 text-green-500" />@@ -57,7 +67,6 @@ export default function CostsPage() {</p></div>- {/* Summary stat cards */}{loadingSummary ? (<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">{Array.from({ length: 4 }).map((_, i) => (@@ -90,154 +99,149 @@ export default function CostsPage() {</div>) : null}- {/* Group-by selector */}- <div className="flex items-center gap-2">- {GROUP_BY_OPTIONS.map((opt) => (- <button- key={opt.value}- onClick={() => setBy(opt.value)}- className={[- "px-3 py-1.5 rounded-md text-sm font-medium transition-colors",- by === opt.value- ? "bg-[var(--color-accent-muted)] text-[var(--color-accent-primary)]"- : "text-[var(--color-text-secondary)] hover:bg-[var(--color-bg-elevated)] hover:text-[var(--color-text-primary)]",- ].join(" ")}- >- {opt.label}- </button>- ))}- </div>+ <Tabs value={tab} onValueChange={setTab} className="w-full">+ <TabsList>+ <TabsTrigger value="daily">Daily</TabsTrigger>+ <TabsTrigger value="cache">Cache & savings</TabsTrigger>+ <TabsTrigger value="hotspots">Hotspots</TabsTrigger>+ <TabsTrigger value="providers">Providers</TabsTrigger>+ <TabsTrigger value="operations">Operations</TabsTrigger>+ </TabsList>- {/* Chart — only when grouping by day */}- {by === "day" && (- <Card>- <CardHeader className="pb-2">- <CardTitle className="text-sm">Daily Spend (USD)</CardTitle>- </CardHeader>- <CardContent className="pt-0">- {loadingGroups ? (- <Skeleton className="h-48 w-full" />- ) : groups && groups.length > 0 ? (- <ResponsiveContainer width="100%" height={220}>- <BarChart- data={[...groups].sort((a, b) => a.group.localeCompare(b.group))}- margin={{ top: 8, right: 8, bottom: 0, left: 0 }}- >- <XAxis- dataKey="group"- tick={{ fill: "var(--color-text-tertiary)", fontSize: 11 }}- axisLine={false}- tickLine={false}- interval="preserveStartEnd"- minTickGap={24}- tickFormatter={(v: string) => {- // ISO date "YYYY-MM-DD" → "M/D"- const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(v);- return m ? `${Number(m[2])}/${Number(m[3])}` : v;- }}- />- <YAxis- tick={{ fill: "var(--color-text-tertiary)", fontSize: 10 }}- axisLine={false}- tickLine={false}- tickFormatter={(v: number) => `$${v.toFixed(3)}`}- />- <Tooltip- cursor={{ fill: "var(--color-bg-elevated)" }}- contentStyle={{- background: "var(--color-bg-overlay)",- border: "1px solid var(--color-border-default)",- borderRadius: "6px",- fontSize: "12px",- color: "var(--color-text-primary)",- }}- formatter={(value: number) => [formatCost(value), "Cost"]}- labelFormatter={(label: string) => `Date: ${label}`}- />- <Bar dataKey="cost_usd" fill="var(--color-accent-primary)" radius={[4, 4, 0, 0]} />- </BarChart>- </ResponsiveContainer>- ) : (- <p className="text-sm text-[var(--color-text-secondary)] py-8 text-center">- No cost data available.- </p>- )}- </CardContent>- </Card>- )}+ <TabsContent value="daily" className="mt-4">+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Daily Spend (USD)</CardTitle>+ </CardHeader>+ <CardContent className="pt-0">+ {loadingDay ? (+ <Skeleton className="h-48 w-full" />+ ) : dayGroups && dayGroups.length > 0 ? (+ <ResponsiveContainer width="100%" height={220}>+ <BarChart+ data={[...dayGroups].sort((a, b) => a.group.localeCompare(b.group))}+ margin={{ top: 8, right: 8, bottom: 0, left: 0 }}+ >+ <XAxis+ dataKey="group"+ tick={{ fill: "var(--color-text-tertiary)", fontSize: 11 }}+ axisLine={false}+ tickLine={false}+ interval="preserveStartEnd"+ minTickGap={24}+ tickFormatter={(v: string) => {+ const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(v);+ return m ? `${Number(m[2])}/${Number(m[3])}` : v;+ }}+ />+ <YAxis+ tick={{ fill: "var(--color-text-tertiary)", fontSize: 10 }}+ axisLine={false}+ tickLine={false}+ tickFormatter={(v: number) => `$${v.toFixed(3)}`}+ />+ <Tooltip+ cursor={{ fill: "var(--color-bg-elevated)" }}+ contentStyle={{+ background: "var(--color-bg-overlay)",+ border: "1px solid var(--color-border-default)",+ borderRadius: "6px",+ fontSize: "12px",+ color: "var(--color-text-primary)",+ }}+ formatter={(value: number) => [formatCost(value), "Cost"]}+ labelFormatter={(label: string) => `Date: ${label}`}+ />+ <Bar dataKey="cost_usd" fill="var(--color-accent-primary)" radius={[4, 4, 0, 0]} />+ </BarChart>+ </ResponsiveContainer>+ ) : (+ <p className="text-sm text-[var(--color-text-secondary)] py-8 text-center">+ No cost data available.+ </p>+ )}+ </CardContent>+ </Card>+ </TabsContent>- {/* Table */}- <Card>- <CardHeader className="pb-2">- <CardTitle className="text-sm">- {by === "day" ? "Daily Breakdown" : by === "model" ? "By Model" : "By Operation"}- </CardTitle>- </CardHeader>- <CardContent className="pt-0">- {loadingGroups ? (- <div className="space-y-2">- {Array.from({ length: 5 }).map((_, i) => (- <Skeleton key={i} className="h-8 w-full" />- ))}- </div>- ) : groups && groups.length > 0 ? (- <div className="overflow-x-auto">- <table className="w-full text-sm">- <thead>- <tr className="border-b border-[var(--color-border-default)] text-left">- <th className="pb-2 pr-4 font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider text-xs">- {by === "day" ? "Date" : by === "model" ? "Model" : "Operation"}- </th>- <th className="pb-2 pr-4 font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider text-xs text-right">- Calls- </th>- <th className="pb-2 pr-4 font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider text-xs text-right">- Input Tokens- </th>- <th className="pb-2 pr-4 font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider text-xs text-right">- Output Tokens- </th>- <th className="pb-2 font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider text-xs text-right">- Cost (USD)- </th>- </tr>- </thead>- <tbody className="divide-y divide-[var(--color-border-default)]">- {(by === "day"- ? [...groups].sort((a, b) => b.group.localeCompare(a.group))- : groups- ).map((row) => (- <tr- key={row.group}- className="hover:bg-[var(--color-bg-elevated)] transition-colors"- >- <td className="py-2 pr-4 text-[var(--color-text-primary)] font-mono text-xs max-w-[280px]">- <span className="block truncate" title={row.group}>{row.group}</span>- </td>- <td className="py-2 pr-4 text-right text-[var(--color-text-secondary)] tabular-nums">- {formatNumber(row.calls)}- </td>- <td className="py-2 pr-4 text-right text-[var(--color-text-secondary)] tabular-nums">- {formatTokens(row.input_tokens)}- </td>- <td className="py-2 pr-4 text-right text-[var(--color-text-secondary)] tabular-nums">- {formatTokens(row.output_tokens)}- </td>- <td className="py-2 text-right font-medium text-[var(--color-text-primary)] tabular-nums">- {formatCost(row.cost_usd)}- </td>- </tr>- ))}- </tbody>- </table>- </div>+ <TabsContent value="cache" className="mt-4">+ <div className="grid grid-cols-1 lg:grid-cols-2 gap-4">+ <CacheHitRatioCard />+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Token efficiency</CardTitle>+ </CardHeader>+ <CardContent className="pt-0">+ {summary ? (+ <div className="space-y-2 text-xs text-[var(--color-text-secondary)]">+ <div className="flex justify-between">+ <span>Avg input tokens / call</span>+ <span className="tabular-nums text-[var(--color-text-primary)]">+ {summary.total_calls > 0+ ? Math.round(summary.total_input_tokens / summary.total_calls).toLocaleString()+ : "—"}+ </span>+ </div>+ <div className="flex justify-between">+ <span>Avg output tokens / call</span>+ <span className="tabular-nums text-[var(--color-text-primary)]">+ {summary.total_calls > 0+ ? Math.round(summary.total_output_tokens / summary.total_calls).toLocaleString()+ : "—"}+ </span>+ </div>+ <div className="flex justify-between">+ <span>Avg cost / call</span>+ <span className="tabular-nums text-[var(--color-text-primary)]">+ {summary.total_calls > 0+ ? formatCost(summary.total_cost_usd / summary.total_calls)+ : "—"}+ </span>+ </div>+ </div>+ ) : (+ <Skeleton className="h-24 w-full" />+ )}+ </CardContent>+ </Card>+ </div>+ </TabsContent>++ <TabsContent value="hotspots" className="mt-4">+ {opGroups ? (+ <CostHeatmap+ groups={opGroups.map((g) => ({ group: g.group, cost_usd: g.cost_usd, calls: g.calls }))}+ title="Cost concentration by operation"+ emptyHint="No operation-level data yet."+ />) : (- <p className="text-sm text-[var(--color-text-secondary)] py-8 text-center">- No cost data available for this repository.- </p>+ <Skeleton className="h-40 w-full" />)}- </CardContent>- </Card>+ </TabsContent>++ <TabsContent value="providers" className="mt-4">+ {modelGroups ? (+ <ProviderComparison modelGroups={modelGroups} />+ ) : (+ <Skeleton className="h-40 w-full" />+ )}+ </TabsContent>++ <TabsContent value="operations" className="mt-4">+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Spend by operation</CardTitle>+ </CardHeader>+ <CardContent className="pt-0">+ {opGroups ? (+ <OperationBreakdown groups={opGroups} />+ ) : (+ <Skeleton className="h-40 w-full" />+ )}+ </CardContent>+ </Card>+ </TabsContent>+ </Tabs></div>);}diff --git a/packages/web/src/app/repos/[id]/dead-code/page.tsx b/packages/web/src/app/repos/[id]/dead-code/page.tsxindex 2bdc71093..b7dcd472e 100644--- a/packages/web/src/app/repos/[id]/dead-code/page.tsx+++ b/packages/web/src/app/repos/[id]/dead-code/page.tsx@@ -4,6 +4,7 @@ import { useState } from "react";import useSWR from "swr";import { useParams } from "next/navigation";import { Trash2 } from "lucide-react";+import { RoutedToRiskBanner } from "@/components/risk/routed-to-risk-banner";import { toast } from "sonner";import { Button } from "@repowise-dev/ui/ui/button";import { SummaryBar } from "@repowise-dev/ui/dead-code/summary-bar";@@ -39,6 +40,7 @@ export default function DeadCodePage() {return (<div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">+ <RoutedToRiskBanner repoId={id} tab="dead-code" /><div className="flex flex-wrap items-start justify-between gap-4"><div><h1 className="text-xl font-semibold text-[var(--color-text-primary)] mb-1 flex items-center gap-2">diff --git a/packages/web/src/app/repos/[id]/docs/coverage/page.tsx b/packages/web/src/app/repos/[id]/docs/coverage/page.tsxindex 7422e3d84..48aad40fd 100644--- a/packages/web/src/app/repos/[id]/docs/coverage/page.tsx+++ b/packages/web/src/app/repos/[id]/docs/coverage/page.tsx@@ -1,7 +1,10 @@import type { Metadata } from "next";import { FileCheck } from "lucide-react";import { CoverageDonut } from "@repowise-dev/ui/coverage/coverage-donut";+import { DriftBanner } from "@repowise-dev/ui/coverage/drift-banner";+import { ConfidenceVsFreshnessMatrix } from "@repowise-dev/ui/coverage/confidence-vs-freshness-matrix";import { FreshnessTableWithRegenerate } from "@/components/coverage/freshness-table-wrapper";+import type { DocPage } from "@repowise-dev/types/docs";import { StatCard } from "@repowise-dev/ui/shared/stat-card";import { listPages } from "@/lib/api/pages";import { formatNumber } from "@repowise-dev/ui/lib/format";@@ -94,6 +97,12 @@ export default async function CoveragePage({</div>)}+ <DriftBanner pages={pages as DocPage[]} />++ {pages.length > 0 && (+ <ConfidenceVsFreshnessMatrix pages={pages as DocPage[]} />+ )}+<FreshnessTableWithRegenerate pages={pages} /></div>);diff --git a/packages/web/src/app/repos/[id]/docs/page.tsx b/packages/web/src/app/repos/[id]/docs/page.tsxindex ba5cccf87..247adb0d6 100644--- a/packages/web/src/app/repos/[id]/docs/page.tsx+++ b/packages/web/src/app/repos/[id]/docs/page.tsx@@ -1,11 +1,16 @@"use client";-import { use, useState } from "react";+import { use, useMemo, useState } from "react";+import useSWR from "swr";import { Download, FolderArchive, Loader2 } from "lucide-react";import { Button } from "@repowise-dev/ui/ui/button";+import { FirstFiveFiles, type FirstFiveFile } from "@repowise-dev/ui/onboarding/first-five-files";import { DocsExplorer } from "@/components/docs/docs-explorer";-import { listAllPages } from "@/lib/api/pages";+import { listAllPages, listPages } from "@/lib/api/pages";+import { getGraph } from "@/lib/api/graph";+import type { DocPage } from "@repowise-dev/types/docs";import { downloadTextFile } from "@/lib/utils/download";+import type { GraphExportResponse } from "@/lib/api/types";export default function DocsPage({params,@@ -15,6 +20,46 @@ export default function DocsPage({const { id: repoId } = use(params);const [isExporting, setIsExporting] = useState(false);+ const { data: graphData } = useSWR<GraphExportResponse>(+ `graph:${repoId}`,+ () => getGraph(repoId),+ { revalidateOnFocus: false, revalidateOnReconnect: false },+ );++ const { data: docPages } = useSWR<DocPage[]>(+ `docs-list:${repoId}`,+ () => listPages(repoId, { limit: 1000 }),+ { revalidateOnFocus: false },+ );++ const pageByPath = useMemo(() => {+ const m = new Map<string, DocPage>();+ for (const p of docPages ?? []) {+ if (p.target_path) m.set(p.target_path, p);+ }+ return m;+ }, [docPages]);++ const startHere: Array<FirstFiveFile & { page_id?: string }> = useMemo(() => {+ if (!graphData) return [];+ const entries = graphData.nodes.filter((n) => n.is_entry_point);+ const pool = entries.length > 0 ? entries : graphData.nodes;+ return [...pool]+ .sort((a, b) => b.pagerank - a.pagerank)+ .slice(0, 5)+ .map((n) => {+ const page = pageByPath.get(n.node_id);+ return {+ file_path: n.node_id,+ is_entry_point: n.is_entry_point,+ has_doc: page !== undefined,+ pagerank: n.pagerank,+ reason: n.is_entry_point ? "entry point" : "high centrality",+ page_id: page?.id,+ };+ });+ }, [graphData, pageByPath]);+const handleExportAll = async () => {setIsExporting(true);try {@@ -64,6 +109,32 @@ export default function DocsPage({</div></div>+ {startHere.length > 0 && (+ <div className="px-4 sm:px-6 pt-3">+ <details className="rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-surface)]">+ <summary className="cursor-pointer list-none px-4 py-2.5 text-sm font-medium text-[var(--color-text-primary)] flex items-center gap-2 hover:bg-[var(--color-bg-elevated)] transition-colors">+ <span className="text-[var(--color-accent-primary)]">✨</span>+ Start here+ <span className="text-[10px] font-normal text-[var(--color-text-tertiary)] uppercase tracking-wider">+ first {startHere.length} files to read+ </span>+ </summary>+ <div className="px-3 pb-3 pt-1">+ <FirstFiveFiles+ files={startHere}+ title="Start here"+ hrefFor={(f) => {+ const pageId = (f as FirstFiveFile & { page_id?: string }).page_id;+ return pageId+ ? `/repos/${repoId}/docs?page=${encodeURIComponent(pageId)}`+ : undefined;+ }}+ />+ </div>+ </details>+ </div>+ )}+{/* Explorer */}<div className="flex-1 min-h-0"><DocsExplorer repoId={repoId} />diff --git a/packages/web/src/app/repos/[id]/graph/page.tsx b/packages/web/src/app/repos/[id]/graph/page.tsxindex 5156d4575..5e39ad313 100644--- a/packages/web/src/app/repos/[id]/graph/page.tsx+++ b/packages/web/src/app/repos/[id]/graph/page.tsx@@ -1,10 +1,14 @@"use client";-import { use, useCallback, useState } from "react";+import { use, useCallback, useMemo, useState } from "react";+import useSWR from "swr";import { useQueryState } from "nuqs";import { useSearchParams } from "next/navigation";import { GraphFlow } from "@/components/graph/graph-flow";import { GraphDocPanel } from "@/components/graph/graph-doc-panel";+import { CentralityLeaderboard, type CentralityNode } from "@repowise-dev/ui/graph/centrality-leaderboard";+import { getGraph } from "@/lib/api/graph";+import type { GraphExportResponse } from "@/lib/api/types";const VALID_VIEW_MODES = new Set(["module", "full", "architecture", "dead", "hotfiles", "unified"]);@@ -25,6 +29,23 @@ export default function GraphPage({const [, setSelectedNode] = useQueryState("node");const [docNodeId, setDocNodeId] = useState<string | null>(null);+ const { data: graphData } = useSWR<GraphExportResponse>(+ `graph:${repoId}`,+ () => getGraph(repoId),+ { revalidateOnFocus: false, revalidateOnReconnect: false },+ );++ const centralityNodes: CentralityNode[] = useMemo(() => {+ if (!graphData) return [];+ return graphData.nodes.map((n) => ({+ node_id: n.node_id,+ label: n.node_id.split("/").slice(-1)[0],+ pagerank: n.pagerank,+ betweenness: n.betweenness,+ language: n.language,+ }));+ }, [graphData]);+// Click a file node → open doc panelconst handleNodeClick = useCallback((nodeId: string, nodeType: string) => {@@ -78,6 +99,19 @@ export default function GraphPage({onClose={() => setDocNodeId(null)}/>)}++ {/* Centrality leaderboard — collapsible right rail */}+ {centralityNodes.length > 0 && !docNodeId && (+ <div className="absolute top-3 right-3 z-10 max-h-[calc(100%-1.5rem)] flex">+ <CentralityLeaderboard+ nodes={centralityNodes}+ onSelect={(n) => {+ setDocNodeId(n.node_id);+ void setSelectedNode(n.node_id);+ }}+ />+ </div>+ )}</div></div></div>diff --git a/packages/web/src/app/repos/[id]/hotspots/page.tsx b/packages/web/src/app/repos/[id]/hotspots/page.tsxindex 643377e74..1b873b2b4 100644--- a/packages/web/src/app/repos/[id]/hotspots/page.tsx+++ b/packages/web/src/app/repos/[id]/hotspots/page.tsx@@ -1,6 +1,7 @@import type { Metadata } from "next";import { Flame, Shield } from "lucide-react";import { StatCard } from "@repowise-dev/ui/shared/stat-card";+import { RoutedToRiskBanner } from "@/components/risk/routed-to-risk-banner";import { HotspotTable } from "@repowise-dev/ui/git/hotspot-table";import { ContributorBar } from "@repowise-dev/ui/git/contributor-bar";import { ChurnHistogram } from "@repowise-dev/ui/git/churn-histogram";@@ -45,6 +46,7 @@ export default async function HotspotsPage({return (<div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">+ <RoutedToRiskBanner repoId={id} tab="hotspots" /><div><h1 className="text-xl font-semibold text-[var(--color-text-primary)] mb-1 flex items-center gap-2"><Flame className="h-5 w-5 text-red-500" />diff --git a/packages/web/src/app/repos/[id]/overview/page.tsx b/packages/web/src/app/repos/[id]/overview/page.tsxindex fb2c95f5b..2e79df643 100644--- a/packages/web/src/app/repos/[id]/overview/page.tsx+++ b/packages/web/src/app/repos/[id]/overview/page.tsx@@ -113,7 +113,11 @@ export default async function OverviewPage({ params }: Props) {<div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">{/* ── Hero: Health Score + Repo Info + Quick Actions ── */}<div className="flex flex-col sm:flex-row items-start gap-6">- <HealthScoreRing score={healthScore.score} components={healthScore.components} />+ <HealthScoreRing+ score={healthScore.score}+ components={healthScore.components}+ note={healthScore.note}+ /><div className="flex-1 min-w-0 space-y-3"><div>diff --git a/packages/web/src/app/repos/[id]/ownership/page.tsx b/packages/web/src/app/repos/[id]/ownership/page.tsxindex 90a758cdd..74315b855 100644--- a/packages/web/src/app/repos/[id]/ownership/page.tsx+++ b/packages/web/src/app/repos/[id]/ownership/page.tsx@@ -4,6 +4,7 @@ import { useState } from "react";import useSWR from "swr";import { useParams } from "next/navigation";import { Users, Shield } from "lucide-react";+import { RoutedToRiskBanner } from "@/components/risk/routed-to-risk-banner";import { StatCard } from "@repowise-dev/ui/shared/stat-card";import { OwnershipTable } from "@repowise-dev/ui/git/ownership-table";import { ContributorBar } from "@repowise-dev/ui/git/contributor-bar";@@ -46,6 +47,7 @@ export default function OwnershipPage() {return (<div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">+ <RoutedToRiskBanner repoId={id} tab="heatmap" tabLabel="Heatmap (ownership)" /><div><h1 className="text-xl font-semibold text-[var(--color-text-primary)] mb-1 flex items-center gap-2"><Users className="h-5 w-5 text-[var(--color-accent-primary)]" />diff --git a/packages/web/src/app/repos/[id]/risk/page.tsx b/packages/web/src/app/repos/[id]/risk/page.tsxnew file mode 100644index 000000000..647d13090--- /dev/null+++ b/packages/web/src/app/repos/[id]/risk/page.tsx@@ -0,0 +1,74 @@+"use client";++import { useParams, useRouter, useSearchParams } from "next/navigation";+import { useCallback } from "react";+import { ShieldAlert } from "lucide-react";+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@repowise-dev/ui/ui/tabs";+import { HeatmapTab } from "@/components/risk/heatmap-tab";+import { HotspotsTab } from "@/components/risk/hotspots-tab";+import { DeadCodeTab } from "@/components/risk/dead-code-tab";+import { ImpactTab } from "@/components/risk/impact-tab";+import { RiskSummaryStrip } from "@/components/risk/risk-summary-strip";++const TABS = ["heatmap", "hotspots", "dead-code", "impact"] as const;+type TabId = (typeof TABS)[number];++export default function RiskPage() {+ const params = useParams<{ id: string }>();+ const router = useRouter();+ const searchParams = useSearchParams();+ const repoId = params.id;++ const rawTab = searchParams.get("tab") as TabId | null;+ const activeTab: TabId = rawTab && TABS.includes(rawTab) ? rawTab : "heatmap";++ const setTab = useCallback(+ (next: string) => {+ const sp = new URLSearchParams(searchParams.toString());+ if (next === "heatmap") sp.delete("tab");+ else sp.set("tab", next);+ const qs = sp.toString();+ router.replace(qs ? `?${qs}` : "?", { scroll: false });+ },+ [router, searchParams],+ );++ return (+ <div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">+ <div>+ <h1 className="text-xl font-semibold text-[var(--color-text-primary)] mb-1 flex items-center gap-2">+ <ShieldAlert className="h-5 w-5 text-orange-500" />+ Risk+ </h1>+ <p className="text-sm text-[var(--color-text-secondary)]">+ Where the risk is concentrated — ownership silos, churn hotspots, dead code, and PR+ blast radius — in one place.+ </p>+ </div>++ <RiskSummaryStrip repoId={repoId} />++ <Tabs value={activeTab} onValueChange={setTab} className="space-y-4">+ <TabsList className="h-auto flex-wrap">+ <TabsTrigger value="heatmap">Heatmap</TabsTrigger>+ <TabsTrigger value="hotspots">Hotspots</TabsTrigger>+ <TabsTrigger value="dead-code">Dead code</TabsTrigger>+ <TabsTrigger value="impact">Impact analyzer</TabsTrigger>+ </TabsList>++ <TabsContent value="heatmap" className="space-y-6">+ <HeatmapTab repoId={repoId} />+ </TabsContent>+ <TabsContent value="hotspots" className="space-y-6">+ <HotspotsTab repoId={repoId} />+ </TabsContent>+ <TabsContent value="dead-code" className="space-y-6">+ <DeadCodeTab repoId={repoId} />+ </TabsContent>+ <TabsContent value="impact" className="space-y-6">+ <ImpactTab repoId={repoId} />+ </TabsContent>+ </Tabs>+ </div>+ );+}diff --git a/packages/web/src/app/repos/[id]/security/page.tsx b/packages/web/src/app/repos/[id]/security/page.tsxnew file mode 100644index 000000000..0440680de--- /dev/null+++ b/packages/web/src/app/repos/[id]/security/page.tsx@@ -0,0 +1,89 @@+"use client";++import { useMemo } from "react";+import useSWR from "swr";+import { useParams } from "next/navigation";+import { ShieldAlert } from "lucide-react";+import { SeverityDistribution } from "@repowise-dev/ui/security/severity-distribution";+import { SecurityFindingsTable } from "@repowise-dev/ui/security/findings-table";+import { FindingsByDirectory } from "@repowise-dev/ui/security/findings-by-directory";+import { Card, CardContent, CardHeader, CardTitle } from "@repowise-dev/ui/ui/card";+import { Skeleton } from "@repowise-dev/ui/ui/skeleton";+import { listSecurityFindings, type SecurityFinding } from "@/lib/api/security";+import { useFileCardHost } from "@/components/shared/file-card-host";+import type { FileCardData } from "@repowise-dev/ui/shared/file-card";++export default function SecurityPage() {+ const params = useParams<{ id: string }>();+ const repoId = params.id;++ const { data: findings, isLoading, error } = useSWR<SecurityFinding[]>(+ `security:${repoId}`,+ () => listSecurityFindings(repoId, { limit: 500 }),+ { revalidateOnFocus: false },+ );++ const { showFile, dialog } = useFileCardHost(repoId);++ const counts = useMemo(() => {+ const c: Record<string, number> = { high: 0, med: 0, low: 0 };+ for (const f of findings ?? []) {+ c[f.severity] = (c[f.severity] ?? 0) + 1;+ }+ return c;+ }, [findings]);++ const handleSelect = (f: SecurityFinding) => {+ const data: FileCardData = {+ file_path: f.file_path,+ summary: `Security: ${f.kind} (${f.severity})`,+ security: {+ findings_count: (findings ?? []).filter((x) => x.file_path === f.file_path).length,+ critical_count: (findings ?? []).filter(+ (x) => x.file_path === f.file_path && x.severity === "high",+ ).length,+ },+ };+ showFile(data);+ };++ return (+ <div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">+ <div>+ <h1 className="text-xl font-semibold text-[var(--color-text-primary)] mb-1 flex items-center gap-2">+ <ShieldAlert className="h-5 w-5 text-red-400" />+ Security+ </h1>+ <p className="text-sm text-[var(--color-text-secondary)]">+ Findings detected during ingestion — secrets, dangerous patterns, and policy hits.+ </p>+ </div>++ {isLoading ? (+ <div className="grid grid-cols-1 lg:grid-cols-2 gap-4">+ <Skeleton className="h-40 w-full rounded-lg" />+ <Skeleton className="h-40 w-full rounded-lg" />+ </div>+ ) : error ? (+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Couldn't load findings</CardTitle>+ </CardHeader>+ <CardContent className="pt-0 text-xs text-[var(--color-text-secondary)]">+ The security endpoint returned an error. Try re-running ingestion.+ </CardContent>+ </Card>+ ) : (+ <>+ <div className="grid grid-cols-1 lg:grid-cols-2 gap-4">+ <SeverityDistribution counts={counts} />+ <FindingsByDirectory findings={findings ?? []} />+ </div>+ <SecurityFindingsTable findings={findings ?? []} onSelect={handleSelect} />+ </>+ )}++ {dialog}+ </div>+ );+}diff --git a/packages/web/src/components/docs/docs-explorer.tsx b/packages/web/src/components/docs/docs-explorer.tsxindex f2ecaa3a3..bc7f998d6 100644--- a/packages/web/src/components/docs/docs-explorer.tsx+++ b/packages/web/src/components/docs/docs-explorer.tsx@@ -80,7 +80,7 @@ export function DocsExplorer({ repoId }: DocsExplorerProps) {}return (- <div className="flex h-full">+ <div className="relative flex h-full">{/* Tree sidebar */}<divclassName={cn(diff --git a/packages/web/src/components/layout/context-drawer-provider.tsx b/packages/web/src/components/layout/context-drawer-provider.tsxnew file mode 100644index 000000000..79df29115--- /dev/null+++ b/packages/web/src/components/layout/context-drawer-provider.tsx@@ -0,0 +1,72 @@+"use client";++import * as React from "react";+import { useRouter, useSearchParams } from "next/navigation";+import {+ ContextDrawer,+ ContextDrawerProvider,+ type ContextDrawerTab,+} from "@repowise-dev/ui/shared/context-drawer";+import type { EntityKind, EntityRef } from "@repowise-dev/ui/shared/entity";++const ENTITY_KINDS: EntityKind[] = ["file", "symbol", "decision", "owner", "commit"];++function parseDrawerParam(raw: string | null): EntityRef | null {+ if (!raw) return null;+ // Format: "kind:id" — kind must be one of EntityKind. id is URL-decoded.+ const sep = raw.indexOf(":");+ if (sep === -1) return null;+ const kind = raw.slice(0, sep) as EntityKind;+ if (!ENTITY_KINDS.includes(kind)) return null;+ const id = decodeURIComponent(raw.slice(sep + 1));+ return { kind, id };+}++function formatDrawerParam(entity: EntityRef): string {+ return `${entity.kind}:${encodeURIComponent(entity.id)}`;+}++interface ProviderProps {+ children: React.ReactNode;+ tabs?: ContextDrawerTab[];+}++/**+ * Client wrapper that mounts the ContextDrawer in the app shell and keeps the+ * open entity URL-synced via `?drawer=kind:id`. Active repoId (when present+ * in the path) is attached to the entity so route resolvers work correctly.+ */+export function ContextDrawerShell({ children, tabs }: ProviderProps) {+ const router = useRouter();+ const searchParams = useSearchParams();++ // Hydrate from URL (?drawer=kind:id). Keep a memoized derived value to+ // avoid re-creating EntityRef on every render.+ const initial = React.useMemo<EntityRef | null>(() => {+ const parsed = parseDrawerParam(searchParams.get("drawer"));+ if (!parsed) return null;+ if (typeof window !== "undefined") {+ const m = window.location.pathname.match(/^\/repos\/([^/]+)/);+ if (m && m[1]) return { ...parsed, repoId: m[1] };+ }+ return parsed;+ }, [searchParams]);++ const handleEntityChange = React.useCallback(+ (next: EntityRef | null) => {+ const sp = new URLSearchParams(searchParams.toString());+ if (next) sp.set("drawer", formatDrawerParam(next));+ else sp.delete("drawer");+ const qs = sp.toString();+ router.replace(qs ? `?${qs}` : window.location.pathname, { scroll: false });+ },+ [router, searchParams],+ );++ return (+ <ContextDrawerProvider initialEntity={initial} onEntityChange={handleEntityChange}>+ {children}+ <ContextDrawer tabs={tabs} />+ </ContextDrawerProvider>+ );+}diff --git a/packages/web/src/components/layout/repo-breadcrumb.tsx b/packages/web/src/components/layout/repo-breadcrumb.tsxindex 2febf7b0f..b20c2d1db 100644--- a/packages/web/src/components/layout/repo-breadcrumb.tsx+++ b/packages/web/src/components/layout/repo-breadcrumb.tsx@@ -18,6 +18,8 @@ const SEGMENT_LABELS: Record<string, string> = {"blast-radius": "Blast Radius",decisions: "Decisions",costs: "Costs",+ risk: "Risk",+ security: "Security",settings: "Settings",};diff --git a/packages/web/src/components/layout/sidebar.tsx b/packages/web/src/components/layout/sidebar.tsxindex c6b5b4221..fa5859429 100644--- a/packages/web/src/components/layout/sidebar.tsx+++ b/packages/web/src/components/layout/sidebar.tsx@@ -11,12 +11,8 @@ import {GitBranch,Lightbulb,MessageSquare,- Search,Code2,- Users,- Flame,- Trash2,- Radar,+ ShieldAlert,DollarSign,Settings,ChevronDown,@@ -57,16 +53,13 @@ function repoNavItems(repoId: string): NavItem[] {return [{ label: "Overview", href: `/repos/${repoId}/overview`, icon: Activity },{ label: "Chat", href: `/repos/${repoId}`, icon: MessageSquare, exact: true },- { label: "Docs", href: `/repos/${repoId}/docs`, icon: BookOpen },- { label: "Search", href: `/repos/${repoId}/search`, icon: Search },+ { label: "Risk", href: `/repos/${repoId}/risk`, icon: ShieldAlert },{ label: "Graph", href: `/repos/${repoId}/graph`, icon: GitBranch },{ label: "Symbols", href: `/repos/${repoId}/symbols`, icon: Code2 },- { label: "Ownership", href: `/repos/${repoId}/ownership`, icon: Users },- { label: "Hotspots", href: `/repos/${repoId}/hotspots`, icon: Flame },- { label: "Dead Code", href: `/repos/${repoId}/dead-code`, icon: Trash2 },- { label: "Blast Radius", href: `/repos/${repoId}/blast-radius`, icon: Radar },{ label: "Decisions", href: `/repos/${repoId}/decisions`, icon: Lightbulb },+ { label: "Docs", href: `/repos/${repoId}/docs`, icon: BookOpen },{ label: "Costs", href: `/repos/${repoId}/costs`, icon: DollarSign },+ { label: "Security", href: `/repos/${repoId}/security`, icon: ShieldAlert },{ label: "Settings", href: `/repos/${repoId}/settings`, icon: Settings },];}diff --git a/packages/web/src/components/risk/dead-code-tab.tsx b/packages/web/src/components/risk/dead-code-tab.tsxnew file mode 100644index 000000000..9a2484b5e--- /dev/null+++ b/packages/web/src/components/risk/dead-code-tab.tsx@@ -0,0 +1,110 @@+"use client";++import { useState } from "react";+import useSWR from "swr";+import { toast } from "sonner";+import { Button } from "@repowise-dev/ui/ui/button";+import { Card, CardContent, CardHeader, CardTitle } from "@repowise-dev/ui/ui/card";+import { Skeleton } from "@repowise-dev/ui/ui/skeleton";+import { SummaryBar } from "@repowise-dev/ui/dead-code/summary-bar";+import { SafeToDeletePile } from "@repowise-dev/ui/dead-code/safe-to-delete-pile";+import { OwnerLeaderboard } from "@repowise-dev/ui/dead-code/owner-leaderboard";+import { FindingsBreakdownGrid } from "@repowise-dev/ui/dead-code/findings-breakdown-grid";+import { FindingsTable } from "@/components/dead-code/findings-table";+import { getDeadCodeSummary, listDeadCode, analyzeDeadCode } from "@/lib/api/dead-code";+import type { DeadCodeFindingResponse, DeadCodeSummaryResponse } from "@/lib/api/types";++export function DeadCodeTab({ repoId }: { repoId: string }) {+ const [analyzing, setAnalyzing] = useState(false);++ const { data: summary, isLoading: loadingSummary, error: summaryError, mutate: mutateSummary } =+ useSWR<DeadCodeSummaryResponse>(+ `dead-code-summary:${repoId}`,+ () => getDeadCodeSummary(repoId),+ { revalidateOnFocus: false },+ );++ const { data: findings } = useSWR<DeadCodeFindingResponse[]>(+ `dead-code-findings:${repoId}:all`,+ // Pull a wide slice so the leaderboard / pile / matrix have enough data+ // to be representative without paging.+ () => listDeadCode(repoId, { limit: 500 }),+ { revalidateOnFocus: false },+ );++ const findingsList = findings ?? [];+ const safeFindings = findingsList.filter((f) => f.safe_to_delete);++ const handleAnalyze = async () => {+ setAnalyzing(true);+ try {+ await analyzeDeadCode(repoId);+ toast.success("Analysis started — results will appear shortly.");+ } catch (err) {+ toast.error(+ err instanceof Error ? `Couldn't start analysis: ${err.message}` : "Couldn't start analysis",+ );+ } finally {+ setAnalyzing(false);+ }+ };++ return (+ <div className="space-y-6">+ <div className="flex items-center justify-end">+ <Button size="sm" variant="outline" onClick={handleAnalyze} disabled={analyzing}>+ {analyzing ? "Starting…" : "Re-analyze"}+ </Button>+ </div>++ {loadingSummary ? (+ <div className="grid grid-cols-4 gap-3">+ {Array.from({ length: 4 }).map((_, i) => (+ <Skeleton key={i} className="h-24 w-full rounded-lg" />+ ))}+ </div>+ ) : summary ? (+ <SummaryBar summary={summary} />+ ) : summaryError ? (+ <div className="rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] p-4 text-sm text-[var(--color-text-secondary)] flex items-center justify-between gap-2">+ <span>Couldn't load summary.</span>+ <Button size="sm" variant="outline" onClick={() => mutateSummary()}>+ Retry+ </Button>+ </div>+ ) : null}++ {findings && safeFindings.length > 0 && (+ <SafeToDeletePile findings={safeFindings} reclaimableLines={summary?.deletable_lines} />+ )}++ <div className="grid grid-cols-1 gap-4 lg:grid-cols-2">+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Owner leaderboard</CardTitle>+ <p className="text-xs text-[var(--color-text-tertiary)]">+ Reclaimable lines per primary contributor — who has the most cleanup leverage.+ </p>+ </CardHeader>+ <CardContent className="pt-0">+ <OwnerLeaderboard findings={findingsList} safeOnly />+ </CardContent>+ </Card>++ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Confidence × kind</CardTitle>+ <p className="text-xs text-[var(--color-text-tertiary)]">+ Where the findings cluster — start with high-confidence cells.+ </p>+ </CardHeader>+ <CardContent className="pt-0">+ <FindingsBreakdownGrid findings={findingsList} />+ </CardContent>+ </Card>+ </div>++ <FindingsTable repoId={repoId} />+ </div>+ );+}diff --git a/packages/web/src/components/risk/heatmap-tab.tsx b/packages/web/src/components/risk/heatmap-tab.tsxnew file mode 100644index 000000000..1d3b9c184--- /dev/null+++ b/packages/web/src/components/risk/heatmap-tab.tsx@@ -0,0 +1,126 @@+"use client";++import { useState } from "react";+import useSWR from "swr";+import { OwnershipTreemap } from "@repowise-dev/ui/git/ownership-treemap";+import { BusFactorPanel } from "@repowise-dev/ui/git/bus-factor-panel";+import { ContributorBar } from "@repowise-dev/ui/git/contributor-bar";+import { HotspotTrendStrip } from "@repowise-dev/ui/git/hotspot-trend-strip";+import { Card, CardContent, CardHeader, CardTitle } from "@repowise-dev/ui/ui/card";+import { Skeleton } from "@repowise-dev/ui/ui/skeleton";+import { getOwnership, getGitSummary, getHotspots } from "@/lib/api/git";+import { formatNumber } from "@repowise-dev/ui/lib/format";+import { cn } from "@/lib/utils/cn";+import type { OwnershipEntry, GitSummaryResponse, HotspotResponse } from "@/lib/api/types";++type Granularity = "module" | "file";++export function HeatmapTab({ repoId }: { repoId: string }) {+ const [granularity, setGranularity] = useState<Granularity>("module");++ const { data: entries, isLoading: loadingEntries } = useSWR<OwnershipEntry[]>(+ `ownership:${repoId}:${granularity}`,+ () => getOwnership(repoId, granularity),+ { revalidateOnFocus: false },+ );+ const { data: summary } = useSWR<GitSummaryResponse>(+ `git-summary:${repoId}`,+ () => getGitSummary(repoId),+ { revalidateOnFocus: false },+ );+ const { data: hotspots } = useSWR<HotspotResponse[]>(+ `hotspots-for-ownership:${repoId}`,+ () => getHotspots(repoId, 100),+ { revalidateOnFocus: false },+ );++ const list = entries ?? [];++ return (+ <div className="space-y-6">+ {loadingEntries && list.length === 0 ? (+ <Skeleton className="h-72 w-full" />+ ) : list.length > 0 ? (+ <Card>+ <CardHeader className="pb-2">+ <div className="flex items-center justify-between">+ <CardTitle className="text-sm">Ownership Heatmap</CardTitle>+ <div className="flex rounded-md border border-[var(--color-border-default)] overflow-hidden text-xs">+ {(["module", "file"] as Granularity[]).map((g) => (+ <button+ key={g}+ onClick={() => setGranularity(g)}+ className={cn(+ "px-3 py-1.5 font-medium transition-colors capitalize",+ granularity === g+ ? "bg-[var(--color-accent-primary)] text-[var(--color-text-inverse)]"+ : "bg-transparent text-[var(--color-text-secondary)] hover:bg-[var(--color-bg-elevated)]",+ )}+ >+ {g}+ </button>+ ))}+ </div>+ </div>+ <p className="text-xs text-[var(--color-text-tertiary)] pt-1">+ Tile size = code volume. Color = ownership concentration; red tiles are silos+ (single owner > 80%).+ </p>+ </CardHeader>+ <CardContent className="pt-0">+ <OwnershipTreemap entries={list} />+ </CardContent>+ </Card>+ ) : null}++ {hotspots && hotspots.length > 0 && (+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Hotspot trend</CardTitle>+ <p className="text-xs text-[var(--color-text-tertiary)]">+ Top files by churn. Heating arrows mark files where the last 30 days are+ outpacing the 90-day baseline.+ </p>+ </CardHeader>+ <CardContent className="pt-0">+ <HotspotTrendStrip hotspots={hotspots} />+ </CardContent>+ </Card>+ )}++ <div className="grid grid-cols-1 gap-6 lg:grid-cols-2">+ {hotspots && hotspots.length > 0 && (+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Bus Factor Analysis</CardTitle>+ </CardHeader>+ <CardContent className="pt-0">+ <BusFactorPanel hotspots={hotspots} />+ </CardContent>+ </Card>+ )}++ {summary && summary.top_owners.length > 0 && (+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Top Contributors</CardTitle>+ </CardHeader>+ <CardContent className="pt-0">+ <ContributorBar owners={summary.top_owners} />+ <div className="mt-3 space-y-1.5">+ {summary.top_owners.slice(0, 10).map((o, i) => (+ <div key={o.email || `owner-${i}`} className="flex items-center justify-between text-xs">+ <span className="text-[var(--color-text-secondary)] truncate">{o.name}</span>+ <span className="text-[var(--color-text-tertiary)] tabular-nums ml-2">+ {Math.round((o.pct ?? 0) * 100)}%+ </span>+ </div>+ ))}+ </div>+ </CardContent>+ </Card>+ )}+ </div>+ </div>+ );+}diff --git a/packages/web/src/components/risk/hotspots-tab.tsx b/packages/web/src/components/risk/hotspots-tab.tsxnew file mode 100644index 000000000..134b7bdeb--- /dev/null+++ b/packages/web/src/components/risk/hotspots-tab.tsx@@ -0,0 +1,161 @@+"use client";++import useSWR from "swr";+import { useFileCardHost } from "@/components/shared/file-card-host";+import type { HotspotResponse as HotspotRowType } from "@/lib/api/types";+import type { FileCardData } from "@repowise-dev/ui/shared/file-card";+import { HotspotTable } from "@repowise-dev/ui/git/hotspot-table";+import { ContributorBar } from "@repowise-dev/ui/git/contributor-bar";+import { ChurnHistogram } from "@repowise-dev/ui/git/churn-histogram";+import { CommitCategoryDonut } from "@repowise-dev/ui/git/commit-category-donut";+import { RiskDistributionChart } from "@repowise-dev/ui/git/risk-distribution-chart";+import { ChurnVsBusFactorScatter } from "@repowise-dev/ui/git/churn-vs-bus-factor-scatter";+import { Card, CardContent, CardHeader, CardTitle } from "@repowise-dev/ui/ui/card";+import { Skeleton } from "@repowise-dev/ui/ui/skeleton";+import { getHotspots, getGitSummary } from "@/lib/api/git";+import { formatNumber } from "@repowise-dev/ui/lib/format";+import type { GitSummaryResponse, HotspotResponse } from "@/lib/api/types";++function hotspotToFileCard(h: HotspotRowType): FileCardData {+ return {+ file_path: h.file_path,+ git: {+ churn_percentile: h.churn_percentile,+ commit_count_90d: h.commit_count_90d,+ lines_added_90d: h.lines_added_90d,+ lines_deleted_90d: h.lines_deleted_90d,+ bus_factor: h.bus_factor,+ primary_owner: h.primary_owner,+ is_hotspot: h.is_hotspot,+ temporal_hotspot_score: h.temporal_hotspot_score,+ },+ };+}++export function HotspotsTab({ repoId }: { repoId: string }) {+ const { showFile, dialog } = useFileCardHost(repoId);+ const { data: hotspots, isLoading: loadingHotspots, error: hotspotsError } = useSWR<HotspotResponse[]>(+ `risk-hotspots:${repoId}`,+ () => getHotspots(repoId, 100),+ { revalidateOnFocus: false },+ );+ const { data: summary } = useSWR<GitSummaryResponse>(+ `git-summary:${repoId}`,+ () => getGitSummary(repoId),+ { revalidateOnFocus: false },+ );++ const list = hotspots ?? [];+ const aggregatedCategories: Record<string, number> = {};+ for (const h of list) {+ for (const [cat, count] of Object.entries(h.commit_categories || {})) {+ aggregatedCategories[cat] = (aggregatedCategories[cat] || 0) + (count as number);+ }+ }++ if (loadingHotspots && list.length === 0) {+ return (+ <div className="space-y-4">+ <Skeleton className="h-72 w-full" />+ </div>+ );+ }++ if (hotspotsError && list.length === 0) {+ return (+ <div className="rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] p-4 text-sm text-[var(--color-text-secondary)]">+ Couldn't load hotspots. The data may not be ready yet — try running a sync first.+ </div>+ );+ }++ return (+ <div className="space-y-6">+ {list.length > 0 && (+ <div className="grid grid-cols-1 gap-4 lg:grid-cols-3">+ <Card className="lg:col-span-2">+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Churn Distribution</CardTitle>+ </CardHeader>+ <CardContent className="pt-0">+ <ChurnHistogram hotspots={list} />+ </CardContent>+ </Card>++ {Object.keys(aggregatedCategories).length > 0 && (+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Commit Types</CardTitle>+ </CardHeader>+ <CardContent className="pt-0 flex items-center justify-center">+ <CommitCategoryDonut categories={aggregatedCategories} />+ </CardContent>+ </Card>+ )}+ </div>+ )}++ {list.length > 0 && (+ <div className="grid grid-cols-1 gap-4 lg:grid-cols-2">+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Risk Distribution</CardTitle>+ <p className="text-xs text-[var(--color-text-tertiary)]">+ Composite risk score: churn (40%) + bus factor (35%) + trend (25%)+ </p>+ </CardHeader>+ <CardContent className="pt-0">+ <RiskDistributionChart hotspots={list} />+ </CardContent>+ </Card>++ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Churn × bus factor</CardTitle>+ <p className="text-xs text-[var(--color-text-tertiary)]">+ Top-right is the danger zone: high churn and a single owner. Bubble size+ reflects 90-day commit count.+ </p>+ </CardHeader>+ <CardContent className="pt-0">+ <ChurnVsBusFactorScatter hotspots={list} />+ </CardContent>+ </Card>+ </div>+ )}++ <div className="grid grid-cols-1 gap-6 xl:grid-cols-4">+ <div className="xl:col-span-3">+ <HotspotTable hotspots={list} repoId={repoId} onSelect={(h) => showFile(hotspotToFileCard(h))} />+ </div>++ {summary && summary.top_owners.length > 0 && (+ <Card>+ <CardHeader className="pb-2">+ <CardTitle className="text-sm">Top Owners</CardTitle>+ </CardHeader>+ <CardContent className="pt-0">+ <ContributorBar owners={summary.top_owners} />+ <div className="mt-3 space-y-1.5">+ {summary.top_owners.slice(0, 5).map((o, i) => (+ <div key={o.email || `owner-${i}`} className="flex items-center justify-between text-xs">+ <span+ className="text-[var(--color-text-secondary)] truncate"+ title={o.email ? `${o.name} <${o.email}>` : o.name}+ >+ {o.name}+ </span>+ <span className="text-[var(--color-text-tertiary)] tabular-nums ml-2">+ {formatNumber(o.file_count)} files ({Math.round(o.pct * 100)}%)+ </span>+ </div>+ ))}+ </div>+ </CardContent>+ </Card>+ )}+ </div>+ {dialog}+ </div>+ );+}diff --git a/packages/web/src/components/risk/impact-tab.tsx b/packages/web/src/components/risk/impact-tab.tsxnew file mode 100644index 000000000..a9e8653a5--- /dev/null+++ b/packages/web/src/components/risk/impact-tab.tsx@@ -0,0 +1,150 @@+"use client";++import { useState } from "react";+import useSWR from "swr";+import { Plus, Flame } from "lucide-react";+import { Button } from "@repowise-dev/ui/ui/button";+import { Card, CardHeader, CardTitle, CardContent } from "@repowise-dev/ui/ui/card";+import { Skeleton } from "@repowise-dev/ui/ui/skeleton";+import { BlastRadiusResults } from "@repowise-dev/ui/blast-radius";+import type { BlastRadiusResponse } from "@repowise-dev/types/blast-radius";+import { analyzeBlastRadius } from "@/lib/api/blast-radius";+import { getHotspots } from "@/lib/api/git";++export function ImpactTab({ repoId }: { repoId: string }) {+ const [files, setFiles] = useState("");+ const [maxDepth, setMaxDepth] = useState(3);+ const [loading, setLoading] = useState(false);+ const [error, setError] = useState<string | null>(null);+ const [result, setResult] = useState<BlastRadiusResponse | null>(null);++ const { data: hotspotSuggestions, isLoading: hotspotSuggestionsLoading } = useSWR(+ repoId ? ["blast-radius-suggestions", repoId] : null,+ () => getHotspots(repoId, 8),+ );++ const addSuggestion = (path: string) => {+ setFiles((prev) => {+ const lines = prev.split("\n").map((l) => l.trim()).filter(Boolean);+ if (lines.includes(path)) return prev;+ return [...lines, path].join("\n");+ });+ };+ const useAllHotspots = () => {+ if (!hotspotSuggestions) return;+ setFiles(hotspotSuggestions.map((h) => h.file_path).join("\n"));+ };+ const clearFiles = () => setFiles("");++ const handleAnalyze = async () => {+ const changed = files.split("\n").map((l) => l.trim()).filter(Boolean);+ if (changed.length === 0) {+ setError("Enter at least one file path.");+ return;+ }+ setLoading(true);+ setError(null);+ setResult(null);+ try {+ const data = await analyzeBlastRadius(repoId, { changed_files: changed, max_depth: maxDepth });+ setResult(data);+ } catch (err) {+ setError(err instanceof Error ? err.message : "Analysis failed.");+ } finally {+ setLoading(false);+ }+ };++ return (+ <div className="space-y-6">+ <Card>+ <CardHeader className="pb-3">+ <CardTitle className="text-sm">Impact Analyzer</CardTitle>+ <p className="text-xs text-[var(--color-text-tertiary)]">+ Estimate the blast radius of a proposed change — direct and transitive risks,+ reviewer suggestions, and test gaps.+ </p>+ </CardHeader>+ <CardContent className="pt-0 space-y-4">+ <p className="text-xs text-[var(--color-text-tertiary)]">+ Paste file paths (one per line) — typically your PR diff. Or click a hotspot below to+ prefill, or use{" "}+ <button+ type="button"+ onClick={useAllHotspots}+ className="underline underline-offset-2 hover:text-[var(--color-text-primary)]"+ disabled={!hotspotSuggestions || hotspotSuggestions.length === 0}+ >+ Use top hotspots+ </button>+ .+ </p>++ {hotspotSuggestionsLoading && !hotspotSuggestions && (+ <div className="flex flex-wrap gap-2">+ {Array.from({ length: 6 }).map((_, i) => (+ <Skeleton key={i} className="h-7 w-32 rounded-full" />+ ))}+ </div>+ )}++ {hotspotSuggestions && hotspotSuggestions.length > 0 && (+ <div className="flex flex-wrap gap-2">+ {hotspotSuggestions.map((h) => (+ <button+ key={h.file_path}+ type="button"+ onClick={() => addSuggestion(h.file_path)}+ className="inline-flex items-center gap-1 rounded-full border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] px-2.5 py-1 text-[11px] font-mono text-[var(--color-text-secondary)] hover:border-[var(--color-accent-primary)] hover:text-[var(--color-text-primary)] transition-colors"+ title={h.file_path}+ aria-label={`Add ${h.file_path} to changed files`}+ >+ <Flame className="h-3 w-3 text-orange-500" />+ <span className="truncate max-w-[260px]">{h.file_path}</span>+ <Plus className="h-3 w-3 opacity-60" />+ </button>+ ))}+ </div>+ )}++ <label htmlFor="risk-impact-changed-files" className="sr-only">+ Changed file paths, one per line+ </label>+ <textarea+ id="risk-impact-changed-files"+ className="w-full rounded-md border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] px-3 py-2 text-xs font-mono text-[var(--color-text-primary)] placeholder:text-[var(--color-text-tertiary)] focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-primary)] resize-y min-h-[120px]"+ placeholder={"src/auth/login.py\nsrc/models/user.py\n..."}+ value={files}+ onChange={(e) => setFiles(e.target.value)}+ aria-label="Changed file paths, one per line"+ />+ <div className="flex items-center gap-4 flex-wrap">+ <label className="flex items-center gap-2 text-xs text-[var(--color-text-secondary)]">+ Max depth+ <input+ type="number"+ min={1}+ max={10}+ value={maxDepth}+ onChange={(e) => setMaxDepth(Math.max(1, Math.min(10, Number(e.target.value))))}+ className="w-16 rounded-md border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] px-2 py-1 text-xs text-[var(--color-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-primary)]"+ aria-label="Maximum dependency depth (1–10)"+ />+ </label>+ <Button onClick={handleAnalyze} disabled={loading} size="sm">+ {loading ? "Analyzing…" : "Analyze"}+ </Button>+ {files && (+ <Button onClick={clearFiles} disabled={loading} size="sm" variant="outline">+ Clear+ </Button>+ )}+ </div>+ {error && <p className="text-xs text-red-500">{error}</p>}+ </CardContent>+ </Card>++ {result && <BlastRadiusResults result={result} />}+ </div>+ );+}diff --git a/packages/web/src/components/risk/risk-summary-strip.tsx b/packages/web/src/components/risk/risk-summary-strip.tsxnew file mode 100644index 000000000..52e319c5a--- /dev/null+++ b/packages/web/src/components/risk/risk-summary-strip.tsx@@ -0,0 +1,83 @@+"use client";++import useSWR from "swr";+import { Flame, Users, Trash2, Lightbulb, ShieldAlert } from "lucide-react";+import { StatCard } from "@repowise-dev/ui/shared/stat-card";+import { formatNumber } from "@repowise-dev/ui/lib/format";+import { getGitSummary, getOwnership } from "@/lib/api/git";+import { getDeadCodeSummary } from "@/lib/api/dead-code";+import { getDecisionHealth } from "@/lib/api/decisions";+import { listSecurityFindings } from "@/lib/api/security";++/**+ * Always-visible 5-card strip atop /repos/[id]/risk. Pulls cached SWR data+ * shared with the tab bodies, so switching tabs doesn't trigger refetches.+ */+export function RiskSummaryStrip({ repoId }: { repoId: string }) {+ const { data: gitSummary } = useSWR(`git-summary:${repoId}`, () => getGitSummary(repoId), {+ revalidateOnFocus: false,+ });+ const { data: ownership } = useSWR(`ownership:${repoId}:module`, () =>+ getOwnership(repoId, "module"),+ );+ const { data: deadCode } = useSWR(`dead-code-summary:${repoId}`, () =>+ getDeadCodeSummary(repoId),+ );+ const { data: decisionHealth } = useSWR(+ `decision-health:${repoId}`,+ () => getDecisionHealth(repoId),+ { revalidateOnFocus: false },+ );+ const { data: securityFindings } = useSWR(+ `security-findings:${repoId}`,+ // Pull a tight slice; we only need the count for the badge here.+ () => listSecurityFindings(repoId, { limit: 200 }).catch(() => [] as Awaited<ReturnType<typeof listSecurityFindings>>),+ { revalidateOnFocus: false },+ );++ const siloCount = (ownership ?? []).filter((o) => o.is_silo).length;+ const reclaimable = deadCode?.deletable_lines ?? 0;+ const staleDecisions = decisionHealth?.stale_decisions?.length ?? 0;+ const securityCritical = (securityFindings ?? []).filter(+ (f) => f.severity === "high" || f.severity === "critical",+ ).length;++ return (+ <div className="grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5">+ <StatCard+ label="Hotspots"+ value={formatNumber(gitSummary?.hotspot_count ?? 0)}+ description="high-churn files"+ icon={<Flame className="h-4 w-4 text-orange-400" />}+ />+ <StatCard+ label="Silos"+ value={formatNumber(siloCount)}+ description="single-owner modules"+ icon={<Users className="h-4 w-4 text-amber-400" />}+ />+ <StatCard+ label="Reclaimable"+ value={formatNumber(reclaimable)}+ description="lines safe to delete"+ icon={<Trash2 className="h-4 w-4 text-rose-400" />}+ />+ <StatCard+ label="Stale Decisions"+ value={formatNumber(staleDecisions)}+ description="needing review"+ icon={<Lightbulb className="h-4 w-4 text-yellow-400" />}+ />+ <StatCard+ label="Security"+ value={securityFindings ? formatNumber(securityCritical) : "—"}+ description={+ securityFindings+ ? "critical / high findings"+ : "scan not run"+ }+ icon={<ShieldAlert className="h-4 w-4 text-red-400" />}+ />+ </div>+ );+}diff --git a/packages/web/src/components/risk/routed-to-risk-banner.tsx b/packages/web/src/components/risk/routed-to-risk-banner.tsxnew file mode 100644index 000000000..cee62c98e--- /dev/null+++ b/packages/web/src/components/risk/routed-to-risk-banner.tsx@@ -0,0 +1,51 @@+"use client";++import Link from "next/link";+import { ShieldAlert, ArrowRight } from "lucide-react";++interface RoutedToRiskBannerProps {+ repoId: string;+ /** Which Risk tab this old route now lives under. */+ tab: "heatmap" | "hotspots" | "dead-code" | "impact";+ /** Optional override for the human label (defaults to the tab id). */+ tabLabel?: string;+}++const TAB_TITLE: Record<RoutedToRiskBannerProps["tab"], string> = {+ heatmap: "Heatmap",+ hotspots: "Hotspots",+ "dead-code": "Dead code",+ impact: "Impact analyzer",+};++/**+ * Soft-consolidation banner: legacy /hotspots, /ownership, /dead-code,+ * /blast-radius routes still resolve, but the banner nudges users toward+ * the unified /repos/[id]/risk page where these now live as tabs. This+ * keeps deep links + bookmarks working while the IA migration is rolled out.+ */+export function RoutedToRiskBanner({ repoId, tab, tabLabel }: RoutedToRiskBannerProps) {+ const target = `/repos/${repoId}/risk?tab=${tab}`;+ const label = tabLabel ?? TAB_TITLE[tab];+ return (+ <div className="flex flex-wrap items-center gap-2 rounded-lg border border-[var(--color-accent-primary)]/30 bg-[var(--color-accent-primary)]/8 px-3 py-2 text-xs text-[var(--color-text-secondary)]">+ <ShieldAlert className="h-3.5 w-3.5 shrink-0 text-[var(--color-accent-primary)]" />+ <span className="flex-1 min-w-0">+ This view now lives under{" "}+ <Link+ href={target}+ className="font-medium text-[var(--color-accent-primary)] hover:underline"+ >+ Risk → {label}+ </Link>+ . Existing bookmarks keep working.+ </span>+ <Link+ href={target}+ className="inline-flex shrink-0 items-center gap-1 rounded-md border border-[var(--color-accent-primary)]/40 bg-[var(--color-bg-elevated)] px-2 py-1 font-medium text-[var(--color-accent-primary)] transition hover:bg-[var(--color-accent-primary)]/10"+ >+ Open Risk <ArrowRight className="h-3 w-3" />+ </Link>+ </div>+ );+}diff --git a/packages/web/src/components/shared/file-card-host.tsx b/packages/web/src/components/shared/file-card-host.tsxnew file mode 100644index 000000000..b4d048a09--- /dev/null+++ b/packages/web/src/components/shared/file-card-host.tsx@@ -0,0 +1,44 @@+"use client";++import { useState, useCallback } from "react";+import { FileCardDialog } from "@repowise-dev/ui/shared/file-card";+import type { FileCardData, FileCardLinks } from "@repowise-dev/ui/shared/file-card";++/**+ * Stateful host for FileCardDialog. Pages that have a list of files (hotspots,+ * dead code, ownership, search results) can open the universal file card by+ * calling `open(data)` returned from this hook. Links default to the+ * standard per-repo deep links if a `repoId` is provided.+ */+export function useFileCardHost(repoId?: string) {+ const [open, setOpen] = useState(false);+ const [data, setData] = useState<FileCardData | null>(null);+ const [links, setLinks] = useState<FileCardLinks | undefined>(undefined);++ const showFile = useCallback(+ (next: FileCardData, customLinks?: FileCardLinks) => {+ setData(next);+ const linksToUse: FileCardLinks | undefined =+ customLinks ??+ (repoId+ ? {+ graph: `/repos/${repoId}/graph?node=${encodeURIComponent(next.file_path)}`,+ docs: `/repos/${repoId}/docs?file=${encodeURIComponent(next.file_path)}`,+ symbols: `/repos/${repoId}/symbols?q=${encodeURIComponent(next.file_path)}`,+ blastRadius: `/repos/${repoId}/risk?tab=impact&file=${encodeURIComponent(next.file_path)}`,+ deadCode: `/repos/${repoId}/risk?tab=dead-code`,+ decisions: `/repos/${repoId}/decisions?file=${encodeURIComponent(next.file_path)}`,+ }+ : undefined);+ setLinks(linksToUse);+ setOpen(true);+ },+ [repoId],+ );++ const dialog = (+ <FileCardDialog open={open} onOpenChange={setOpen} data={data} links={links} />+ );++ return { showFile, dialog };+}diff --git a/packages/web/src/components/symbols/symbol-table-wrapper.tsx b/packages/web/src/components/symbols/symbol-table-wrapper.tsxindex d914e7055..9ce873212 100644--- a/packages/web/src/components/symbols/symbol-table-wrapper.tsx+++ b/packages/web/src/components/symbols/symbol-table-wrapper.tsx@@ -4,6 +4,7 @@ import { useState, useMemo } from "react";import useSWR from "swr";import useSWRInfinite from "swr/infinite";import { SymbolTable } from "@repowise-dev/ui/symbols/symbol-table";+import { HotSymbolsBoard, type HotSymbol } from "@repowise-dev/ui/symbols/hot-symbols-board";import { SymbolDrawerWrapper } from "./symbol-drawer-wrapper";import { listSymbols } from "@/lib/api/symbols";import { getGraph } from "@/lib/api/graph";@@ -72,8 +73,24 @@ export function SymbolTableWrapper({ repoId }: Props) {const lastPage = data ? data[data.length - 1] : undefined;const hasMore = lastPage?.length === LIMIT;+ const hotSymbols: HotSymbol[] = useMemo(() => {+ return [...items]+ .map((s) => {+ const pr = pagerankMap.get(s.file_path) ?? 0;+ const cx = Math.max(1, s.complexity_estimate);+ return { symbol: s, score: pr * (1 + Math.log(cx)), pagerank: pr };+ })+ .sort((a, b) => b.score - a.score)+ .filter((h) => h.score > 0)+ .slice(0, 8);+ }, [items, pagerankMap]);+return (- <SymbolTable+ <div className="space-y-6">+ {hotSymbols.length > 0 && (+ <HotSymbolsBoard items={hotSymbols} onSelect={setSelected} />+ )}+ <SymbolTableitems={items}importanceScores={importanceScores}repoId={repoId}@@ -96,5 +113,6 @@ export function SymbolTableWrapper({ repoId }: Props) {/>}/>+ </div>);}diff --git a/packages/web/src/lib/utils/health-score.ts b/packages/web/src/lib/utils/health-score.tsindex 18f585d78..bf06f6906 100644--- a/packages/web/src/lib/utils/health-score.ts+++ b/packages/web/src/lib/utils/health-score.ts@@ -3,6 +3,10 @@ import type { HealthScoreComponent } from "@repowise-dev/ui/dashboard/health-scoexport interface HealthScoreResult {score: number;components: HealthScoreComponent[];+ /** True when the repo was indexed without generating wiki docs. */+ indexOnly: boolean;+ /** Human-readable note describing any reweighting (or undefined if none). */+ note?: string;}/** Compute composite health score from available repo data */@@ -27,10 +31,16 @@ export function computeHealthScore(params: {totalModules,} = params;- // Doc coverage: 0-100, weight 25%+ // Detect index-only mode: docs were never generated for this repo, so doc+ // coverage and freshness are structurally zero. Penalizing them would punish+ // users who explicitly opted into `repowise init --index-only`. We drop both+ // components and renormalize the remaining weights.+ const docsGenerated = docCoveragePct > 0 || freshnessScore > 0;++ // Doc coverage: 0-100, weight 25% (when applicable)const docScore = Math.min(docCoveragePct, 100);- // Freshness: 0-100, weight 25%+ // Freshness: 0-100, weight 25% (when applicable)const freshScore = Math.min(freshnessScore * 100, 100);// Dead code: lower is better, weight 20%@@ -45,53 +55,81 @@ export function computeHealthScore(params: {const siloRatio = totalModules > 0 ? siloCount / totalModules : 0;const siloScore = Math.max(0, (1 - siloRatio * 2) * 100);+ const baseComponents: HealthScoreComponent[] = docsGenerated+ ? [+ {+ key: "doc_coverage",+ label: "Doc Coverage",+ weight: 0.25,+ score: Math.round(docScore),+ detail: `${Math.round(docCoveragePct)}% of symbols documented`,+ },+ {+ key: "freshness",+ label: "Freshness",+ weight: 0.25,+ score: Math.round(freshScore),+ detail: "Based on doc-to-code drift analysis",+ },+ {+ key: "dead_code",+ label: "Dead Code",+ weight: 0.2,+ score: Math.round(deadScore),+ detail: `${deadExportCount} dead exports out of ${symbolCount} symbols`,+ },+ {+ key: "hotspot_density",+ label: "Hotspot Density",+ weight: 0.15,+ score: Math.round(hotspotScore),+ detail: `${hotspotCount} hotspots across ${totalFiles} files`,+ },+ {+ key: "knowledge_silos",+ label: "Knowledge Silos",+ weight: 0.15,+ score: Math.round(siloScore),+ detail: `${siloCount} silo${siloCount === 1 ? "" : "s"} out of ${totalModules} modules`,+ },+ ]+ : [+ // Index-only: redistribute the 0.25+0.25 doc weights across the+ // remaining three components proportionally (0.20:0.15:0.15 → 0.40:0.30:0.30).+ {+ key: "dead_code",+ label: "Dead Code",+ weight: 0.4,+ score: Math.round(deadScore),+ detail: `${deadExportCount} dead exports out of ${symbolCount} symbols`,+ },+ {+ key: "hotspot_density",+ label: "Hotspot Density",+ weight: 0.3,+ score: Math.round(hotspotScore),+ detail: `${hotspotCount} hotspots across ${totalFiles} files`,+ },+ {+ key: "knowledge_silos",+ label: "Knowledge Silos",+ weight: 0.3,+ score: Math.round(siloScore),+ detail: `${siloCount} silo${siloCount === 1 ? "" : "s"} out of ${totalModules} modules`,+ },+ ];+const composite = Math.round(- docScore * 0.25 +- freshScore * 0.25 +- deadScore * 0.2 +- hotspotScore * 0.15 +- siloScore * 0.15+ baseComponents.reduce((sum, c) => sum + c.score * c.weight, 0),);return {score: Math.max(0, Math.min(100, composite)),- components: [- {- key: "doc_coverage",- label: "Doc Coverage",- weight: 0.25,- score: Math.round(docScore),- detail: `${Math.round(docCoveragePct)}% of symbols documented`,- },- {- key: "freshness",- label: "Freshness",- weight: 0.25,- score: Math.round(freshScore),- detail: `Based on doc-to-code drift analysis`,- },- {- key: "dead_code",- label: "Dead Code",- weight: 0.20,- score: Math.round(deadScore),- detail: `${deadExportCount} dead exports out of ${symbolCount} symbols`,- },- {- key: "hotspot_density",- label: "Hotspot Density",- weight: 0.15,- score: Math.round(hotspotScore),- detail: `${hotspotCount} hotspots across ${totalFiles} files`,- },- {- key: "knowledge_silos",- label: "Knowledge Silos",- weight: 0.15,- score: Math.round(siloScore),- detail: `${siloCount} silo${siloCount === 1 ? "" : "s"} out of ${totalModules} modules`,- },- ],+ components: baseComponents,+ indexOnly: !docsGenerated,+ note: docsGenerated+ ? undefined+ : "Docs haven't been generated for this repo (index-only). Doc Coverage and Freshness are excluded; remaining components are reweighted.",};}