2025-11-27 18:01:57 +08:00
|
|
|
import { useState } from "react";
|
|
|
|
|
import { Link, useLocation } from "react-router-dom";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
import {
|
|
|
|
|
Menu,
|
|
|
|
|
X,
|
|
|
|
|
LayoutDashboard,
|
|
|
|
|
FolderGit2,
|
|
|
|
|
Zap,
|
|
|
|
|
ListTodo,
|
|
|
|
|
Settings,
|
|
|
|
|
Trash2,
|
|
|
|
|
ChevronLeft,
|
|
|
|
|
ChevronRight,
|
2025-11-28 01:06:01 +08:00
|
|
|
Github,
|
2025-12-09 21:42:00 +08:00
|
|
|
UserCircle,
|
|
|
|
|
Shield,
|
feat(agent): implement comprehensive agent architecture with knowledge base and persistence layer
- Add database migrations for agent checkpoints and tree node tracking
- Implement core agent execution framework with executor, state management, and message handling
- Create knowledge base system with framework-specific modules (Django, FastAPI, Flask, Express, React, Supabase)
- Add vulnerability knowledge modules covering authentication, cryptography, injection, XSS, XXE, SSRF, path traversal, deserialization, and race conditions
- Introduce new agent tools: thinking tool, reporting tool, and agent-specific utilities
- Implement LLM memory compression and prompt caching for improved performance
- Add agent registry and persistence layer for checkpoint management
- Refactor agent implementations (analysis, recon, verification, orchestrator) with enhanced capabilities
- Remove legacy agent implementations (analysis_v2, react_agent)
- Update API endpoints for agent task creation and project management
- Add frontend components for agent task creation and enhanced audit UI
- Consolidate agent service architecture with improved separation of concerns
- This refactoring provides a scalable foundation for multi-agent collaboration with knowledge-driven decision making and state persistence
2025-12-12 15:27:12 +08:00
|
|
|
MessageSquare,
|
|
|
|
|
Bot
|
2025-11-27 18:01:57 +08:00
|
|
|
} from "lucide-react";
|
|
|
|
|
import routes from "@/app/routes";
|
2025-11-28 16:16:29 +08:00
|
|
|
import { version } from "../../../package.json";
|
2025-11-27 18:01:57 +08:00
|
|
|
|
|
|
|
|
// Icon mapping for routes
|
|
|
|
|
const routeIcons: Record<string, React.ReactNode> = {
|
|
|
|
|
"/": <LayoutDashboard className="w-5 h-5" />,
|
|
|
|
|
"/projects": <FolderGit2 className="w-5 h-5" />,
|
|
|
|
|
"/instant-analysis": <Zap className="w-5 h-5" />,
|
|
|
|
|
"/audit-tasks": <ListTodo className="w-5 h-5" />,
|
feat(agent): implement comprehensive agent architecture with knowledge base and persistence layer
- Add database migrations for agent checkpoints and tree node tracking
- Implement core agent execution framework with executor, state management, and message handling
- Create knowledge base system with framework-specific modules (Django, FastAPI, Flask, Express, React, Supabase)
- Add vulnerability knowledge modules covering authentication, cryptography, injection, XSS, XXE, SSRF, path traversal, deserialization, and race conditions
- Introduce new agent tools: thinking tool, reporting tool, and agent-specific utilities
- Implement LLM memory compression and prompt caching for improved performance
- Add agent registry and persistence layer for checkpoint management
- Refactor agent implementations (analysis, recon, verification, orchestrator) with enhanced capabilities
- Remove legacy agent implementations (analysis_v2, react_agent)
- Update API endpoints for agent task creation and project management
- Add frontend components for agent task creation and enhanced audit UI
- Consolidate agent service architecture with improved separation of concerns
- This refactoring provides a scalable foundation for multi-agent collaboration with knowledge-driven decision making and state persistence
2025-12-12 15:27:12 +08:00
|
|
|
"/agent-audit": <Bot className="w-5 h-5" />,
|
2025-12-09 21:42:00 +08:00
|
|
|
"/audit-rules": <Shield className="w-5 h-5" />,
|
|
|
|
|
"/prompts": <MessageSquare className="w-5 h-5" />,
|
2025-11-27 18:01:57 +08:00
|
|
|
"/admin": <Settings className="w-5 h-5" />,
|
|
|
|
|
"/recycle-bin": <Trash2 className="w-5 h-5" />,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
interface SidebarProps {
|
|
|
|
|
collapsed: boolean;
|
|
|
|
|
setCollapsed: (collapsed: boolean) => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function Sidebar({ collapsed, setCollapsed }: SidebarProps) {
|
|
|
|
|
const location = useLocation();
|
|
|
|
|
const [mobileOpen, setMobileOpen] = useState(false);
|
|
|
|
|
|
|
|
|
|
const visibleRoutes = routes.filter(route => route.visible !== false);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{/* Mobile Menu Button */}
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="sm"
|
2025-11-27 22:34:23 +08:00
|
|
|
className="fixed top-4 left-4 z-50 md:hidden terminal-btn-ghost text-black"
|
2025-11-27 18:01:57 +08:00
|
|
|
onClick={() => setMobileOpen(!mobileOpen)}
|
|
|
|
|
>
|
|
|
|
|
{mobileOpen ? <X className="w-5 h-5" /> : <Menu className="w-5 h-5" />}
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
{/* Overlay for mobile */}
|
|
|
|
|
{mobileOpen && (
|
|
|
|
|
<div
|
2025-11-27 21:33:51 +08:00
|
|
|
className="fixed inset-0 bg-black/50 backdrop-blur-sm z-40 md:hidden"
|
2025-11-27 18:01:57 +08:00
|
|
|
onClick={() => setMobileOpen(false)}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Sidebar */}
|
|
|
|
|
<aside
|
|
|
|
|
className={`
|
2025-11-27 21:33:51 +08:00
|
|
|
fixed top-0 left-0 h-screen bg-background
|
2025-11-27 22:34:23 +08:00
|
|
|
border-r border-border
|
2025-11-27 18:01:57 +08:00
|
|
|
z-40 transition-all duration-300 ease-in-out
|
|
|
|
|
${collapsed ? "w-20" : "w-64"}
|
|
|
|
|
${mobileOpen ? "translate-x-0" : "-translate-x-full md:translate-x-0"}
|
|
|
|
|
`}
|
|
|
|
|
>
|
2025-11-27 21:33:51 +08:00
|
|
|
<div className="flex flex-col h-full relative">
|
|
|
|
|
{/* Decorative Grid Background */}
|
|
|
|
|
<div className="absolute inset-0 bg-[linear-gradient(to_right,#80808012_1px,transparent_1px),linear-gradient(to_bottom,#80808012_1px,transparent_1px)] bg-[size:24px_24px] pointer-events-none" />
|
|
|
|
|
|
2025-11-27 18:01:57 +08:00
|
|
|
{/* Logo Section */}
|
2025-11-27 22:34:23 +08:00
|
|
|
<div className={`relative flex items-center h-[72px] border-b border-border bg-card z-10 ${collapsed ? 'px-3 justify-center' : 'px-4 pr-6'}`}>
|
2025-11-27 18:01:57 +08:00
|
|
|
<Link
|
|
|
|
|
to="/"
|
2025-11-27 22:34:23 +08:00
|
|
|
className={`flex items-center space-x-3 group transition-all duration-300 ${collapsed ? 'justify-center' : 'flex-1 min-w-0'}`}
|
2025-11-27 18:01:57 +08:00
|
|
|
onClick={() => setMobileOpen(false)}
|
|
|
|
|
>
|
2025-11-27 22:34:23 +08:00
|
|
|
<div className="relative flex-shrink-0 border border-primary bg-white p-1 shadow-sm rounded-sm overflow-hidden">
|
2025-12-08 21:35:09 +08:00
|
|
|
<img src="/logo_deepaudit.png" alt="DeepAudit" className="w-7 h-7 object-contain" />
|
2025-11-27 18:01:57 +08:00
|
|
|
</div>
|
2025-11-27 22:34:23 +08:00
|
|
|
<div className={`transition-all duration-300 ${collapsed ? 'w-0 opacity-0 overflow-hidden' : 'flex-1 min-w-0 opacity-100'}`}>
|
|
|
|
|
<span className="text-lg font-display font-bold text-black tracking-tighter uppercase whitespace-nowrap">
|
2025-12-08 21:35:09 +08:00
|
|
|
Deep<span className="text-primary">Audit</span>
|
2025-11-27 18:01:57 +08:00
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</Link>
|
|
|
|
|
|
2025-11-27 21:33:51 +08:00
|
|
|
{/* Collapse button for desktop */}
|
|
|
|
|
<button
|
2025-11-27 22:34:23 +08:00
|
|
|
className="hidden md:flex absolute -right-3 top-1/2 -translate-y-1/2 w-6 h-6 bg-card border border-border items-center justify-center hover:bg-primary hover:text-white transition-all shadow-sm rounded-sm"
|
2025-11-27 18:01:57 +08:00
|
|
|
onClick={() => setCollapsed(!collapsed)}
|
2025-11-27 22:34:23 +08:00
|
|
|
style={{ zIndex: 100 }}
|
2025-11-27 18:01:57 +08:00
|
|
|
>
|
|
|
|
|
{collapsed ? (
|
|
|
|
|
<ChevronRight className="w-3 h-3" />
|
|
|
|
|
) : (
|
|
|
|
|
<ChevronLeft className="w-3 h-3" />
|
|
|
|
|
)}
|
2025-11-27 21:33:51 +08:00
|
|
|
</button>
|
2025-11-27 18:01:57 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Navigation */}
|
2025-11-27 21:33:51 +08:00
|
|
|
<nav className="flex-1 overflow-y-auto py-6 px-3 z-10">
|
|
|
|
|
<div className="space-y-2">
|
2025-11-27 18:01:57 +08:00
|
|
|
{visibleRoutes.map((route) => {
|
|
|
|
|
const isActive = location.pathname === route.path;
|
|
|
|
|
return (
|
|
|
|
|
<Link
|
|
|
|
|
key={route.path}
|
|
|
|
|
to={route.path}
|
|
|
|
|
className={`
|
2025-11-27 21:33:51 +08:00
|
|
|
flex items-center space-x-3 px-3 py-3
|
2025-11-27 22:34:23 +08:00
|
|
|
transition-all duration-200 group relative rounded-sm
|
|
|
|
|
border
|
2025-11-27 18:01:57 +08:00
|
|
|
${isActive
|
2025-11-27 22:34:23 +08:00
|
|
|
? "bg-primary border-primary/30 shadow-md text-white"
|
|
|
|
|
: "bg-transparent border-transparent hover:border-border hover:bg-card hover:shadow-sm text-gray-600 hover:text-foreground"
|
2025-11-27 18:01:57 +08:00
|
|
|
}
|
|
|
|
|
`}
|
|
|
|
|
onClick={() => setMobileOpen(false)}
|
|
|
|
|
title={collapsed ? route.name : undefined}
|
|
|
|
|
>
|
|
|
|
|
{/* Icon */}
|
|
|
|
|
<span className={`
|
|
|
|
|
flex-shrink-0 transition-colors duration-200
|
2025-11-27 21:33:51 +08:00
|
|
|
${isActive ? "text-white" : "text-black group-hover:text-black"}
|
2025-11-27 18:01:57 +08:00
|
|
|
`}>
|
|
|
|
|
{routeIcons[route.path] || <LayoutDashboard className="w-5 h-5" />}
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
{/* Label */}
|
|
|
|
|
{!collapsed && (
|
2025-11-27 21:33:51 +08:00
|
|
|
<span className="font-mono font-bold tracking-tight uppercase text-sm">
|
2025-11-27 18:01:57 +08:00
|
|
|
{route.name}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
|
2025-11-27 21:33:51 +08:00
|
|
|
{/* Glitch Effect on Hover (Optional) */}
|
|
|
|
|
{!isActive && !collapsed && (
|
|
|
|
|
<span className="absolute right-2 opacity-0 group-hover:opacity-100 text-xs font-bold text-primary animate-pulse">
|
|
|
|
|
</>
|
|
|
|
|
</span>
|
2025-11-27 18:01:57 +08:00
|
|
|
)}
|
|
|
|
|
</Link>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
</nav>
|
|
|
|
|
|
2025-11-28 01:06:01 +08:00
|
|
|
{/* Footer with Account & GitHub Link */}
|
|
|
|
|
<div className="p-4 border-t border-border bg-card z-10 space-y-2">
|
|
|
|
|
{/* Account Link */}
|
|
|
|
|
<Link
|
|
|
|
|
to="/account"
|
|
|
|
|
className={`
|
|
|
|
|
flex items-center space-x-3 px-3 py-2.5 rounded-sm
|
|
|
|
|
transition-all duration-200 group
|
|
|
|
|
border
|
|
|
|
|
${location.pathname === '/account'
|
|
|
|
|
? "bg-primary border-primary/30 shadow-md text-white"
|
|
|
|
|
: "bg-transparent border-transparent hover:border-border hover:bg-card hover:shadow-sm text-gray-600 hover:text-foreground"
|
|
|
|
|
}
|
|
|
|
|
`}
|
|
|
|
|
onClick={() => setMobileOpen(false)}
|
|
|
|
|
title={collapsed ? "账号管理" : undefined}
|
|
|
|
|
>
|
|
|
|
|
<UserCircle className={`w-5 h-5 flex-shrink-0 ${location.pathname === '/account' ? 'text-white' : ''}`} />
|
|
|
|
|
{!collapsed && (
|
|
|
|
|
<span className="font-mono font-bold text-sm uppercase">账号管理</span>
|
|
|
|
|
)}
|
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
|
|
{/* GitHub Link */}
|
2025-11-27 18:01:57 +08:00
|
|
|
<a
|
2025-12-08 21:35:09 +08:00
|
|
|
href="https://github.com/lintsinghua/DeepAudit"
|
2025-11-27 18:01:57 +08:00
|
|
|
target="_blank"
|
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
|
className={`
|
2025-11-27 22:34:23 +08:00
|
|
|
flex items-center space-x-3 px-3 py-2.5 rounded-sm
|
|
|
|
|
text-foreground border border-transparent hover:border-border hover:shadow-sm hover:bg-muted
|
2025-11-27 18:01:57 +08:00
|
|
|
transition-all duration-200 group
|
|
|
|
|
`}
|
2025-11-27 21:33:51 +08:00
|
|
|
title={collapsed ? "GitHub 仓库" : undefined}
|
2025-11-27 18:01:57 +08:00
|
|
|
>
|
2025-11-27 21:33:51 +08:00
|
|
|
<Github className="w-5 h-5 flex-shrink-0" />
|
2025-11-27 18:01:57 +08:00
|
|
|
{!collapsed && (
|
|
|
|
|
<div className="flex flex-col">
|
2025-11-27 21:33:51 +08:00
|
|
|
<span className="font-mono font-bold text-sm uppercase">GitHub</span>
|
2025-11-28 16:16:29 +08:00
|
|
|
<span className="text-xs text-gray-500 font-mono">v{version}</span>
|
2025-11-27 18:01:57 +08:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</aside>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|