feat: Add core memory clustering visualization and hooks configuration

- Implemented core memory clustering visualization in core-memory-clusters.js
- Added functions for loading, rendering, and managing clusters and their members
- Created example hooks configuration in hooks-config-example.json for session management
- Developed test script for hooks integration in test-hooks.js
- Included error handling and notifications for user interactions
This commit is contained in:
catlog22
2025-12-18 23:06:58 +08:00
parent 68f9de0c69
commit 9f6e6852da
24 changed files with 4543 additions and 590 deletions

View File

@@ -102,6 +102,70 @@
padding: 1.5rem;
}
/* Tab Navigation */
.core-memory-tabs {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem;
flex-wrap: wrap;
gap: 1rem;
border-bottom: 1px solid hsl(var(--border));
padding-bottom: 1rem;
}
.tab-nav {
display: flex;
gap: 0;
background: hsl(var(--muted) / 0.5);
border-radius: 8px;
padding: 4px;
}
.tab-btn {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.625rem 1.25rem;
border: none;
background: transparent;
color: hsl(var(--muted-foreground));
font-size: 0.9375rem;
font-weight: 500;
cursor: pointer;
border-radius: 6px;
transition: all 0.2s ease;
}
.tab-btn i {
width: 18px;
height: 18px;
}
.tab-btn:hover {
color: hsl(var(--foreground));
}
.tab-btn.active {
background: hsl(var(--card));
color: hsl(var(--primary));
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.tab-actions {
display: flex;
gap: 0.75rem;
flex-wrap: wrap;
}
.cm-tab-panel {
animation: fadeIn 0.2s ease-out;
}
.cm-tab-panel .memory-stats {
margin-bottom: 1rem;
}
.core-memory-header {
display: flex;
justify-content: space-between;
@@ -829,3 +893,609 @@
[data-theme="dark"] .version-content-preview {
background: #0f172a;
}
/* ============================================
Session Clustering Styles
============================================ */
.clusters-container {
margin-top: 0;
height: calc(100vh - 200px);
min-height: 500px;
}
.clusters-layout {
display: grid;
grid-template-columns: 320px 1fr;
gap: 1.5rem;
height: 100%;
}
@media (max-width: 900px) {
.clusters-layout {
grid-template-columns: 1fr;
}
}
/* Clusters Sidebar */
.clusters-sidebar {
background: hsl(var(--card));
border: 1px solid hsl(var(--border));
border-radius: 8px;
display: flex;
flex-direction: column;
overflow: hidden;
}
.clusters-sidebar-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem;
border-bottom: 1px solid hsl(var(--border));
background: hsl(var(--muted) / 0.3);
}
.clusters-sidebar-header h4 {
margin: 0;
font-size: 0.9375rem;
font-weight: 600;
color: hsl(var(--foreground));
}
.cluster-list {
flex: 1;
overflow-y: auto;
padding: 0.5rem;
}
/* Cluster Item */
.cluster-item {
display: flex;
align-items: flex-start;
gap: 0.75rem;
padding: 0.875rem;
border-radius: 6px;
cursor: pointer;
transition: all 0.2s ease;
margin-bottom: 0.5rem;
border: 1px solid transparent;
}
.cluster-item:hover {
background: hsl(var(--muted) / 0.5);
}
.cluster-item.active {
background: hsl(var(--primary) / 0.1);
border-color: hsl(var(--primary) / 0.3);
}
.cluster-icon {
flex-shrink: 0;
width: 36px;
height: 36px;
display: flex;
align-items: center;
justify-content: center;
background: hsl(var(--muted));
border-radius: 6px;
color: hsl(var(--muted-foreground));
}
.cluster-icon i {
width: 18px;
height: 18px;
}
.cluster-item.active .cluster-icon {
background: hsl(var(--primary) / 0.15);
color: hsl(var(--primary));
}
.cluster-info {
flex: 1;
min-width: 0;
}
.cluster-name {
font-weight: 500;
font-size: 0.9375rem;
color: hsl(var(--foreground));
margin-bottom: 0.25rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.cluster-meta {
display: flex;
gap: 0.75rem;
font-size: 0.75rem;
color: hsl(var(--muted-foreground));
}
/* Cluster Status Badges */
.badge-active {
background: hsl(142 76% 36% / 0.15);
color: hsl(142 76% 36%);
}
.badge-archived {
background: hsl(var(--muted));
color: hsl(var(--muted-foreground));
}
.badge-pending {
background: hsl(38 92% 50% / 0.15);
color: hsl(38 92% 40%);
}
/* Clusters Detail Panel */
.clusters-detail {
background: hsl(var(--card));
border: 1px solid hsl(var(--border));
border-radius: 8px;
overflow: hidden;
display: flex;
flex-direction: column;
}
.cluster-detail-content {
padding: 1.5rem;
flex: 1;
overflow-y: auto;
min-height: 0; /* Enable flexbox scrolling */
}
.cluster-detail-content .empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
min-height: 300px;
}
/* Cluster Detail View */
.cluster-detail {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.cluster-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.cluster-header h3 {
margin: 0;
font-size: 1.25rem;
font-weight: 600;
color: hsl(var(--foreground));
}
.cluster-actions {
display: flex;
gap: 0.5rem;
}
.cluster-description {
color: hsl(var(--muted-foreground));
font-size: 0.9375rem;
line-height: 1.6;
margin: 0;
}
.cluster-intent {
padding: 0.75rem 1rem;
background: hsl(var(--muted) / 0.5);
border-radius: 6px;
font-size: 0.875rem;
color: hsl(var(--foreground));
}
.cluster-intent strong {
color: hsl(var(--primary));
}
/* Cluster Sections */
.cluster-timeline,
.cluster-relations {
padding-top: 1rem;
border-top: 1px solid hsl(var(--border));
}
.cluster-timeline h4,
.cluster-relations h4 {
display: flex;
align-items: center;
gap: 0.5rem;
margin: 0 0 1rem 0;
font-size: 1rem;
font-weight: 600;
color: hsl(var(--foreground));
}
.cluster-timeline h4 i,
.cluster-relations h4 i {
width: 18px;
height: 18px;
color: hsl(var(--primary));
}
/* Session Timeline */
.timeline {
display: flex;
flex-direction: column;
gap: 1rem;
max-width: 100%;
}
/* Override conflicting timeline-item styles from other CSS files */
.cluster-timeline .timeline .timeline-item {
display: flex;
gap: 1rem;
position: relative;
/* Reset card-like appearance from other CSS */
background: transparent;
border: none;
border-radius: 0;
padding: 0;
margin-bottom: 0;
/* Remove height constraints */
min-height: auto;
max-height: none;
overflow: visible;
cursor: default;
}
.cluster-timeline .timeline .timeline-item::before {
content: '';
position: absolute;
left: 0.6875rem;
top: 2rem;
bottom: -1rem;
width: 2px;
background: hsl(var(--border));
}
.cluster-timeline .timeline .timeline-item:last-child::before {
display: none;
}
.timeline-marker {
flex-shrink: 0;
width: 1.5rem;
height: 1.5rem;
display: flex;
align-items: center;
justify-content: center;
z-index: 1;
}
.timeline-number {
width: 1.5rem;
height: 1.5rem;
display: flex;
align-items: center;
justify-content: center;
background: hsl(var(--primary));
color: white;
border-radius: 50%;
font-size: 0.75rem;
font-weight: 600;
}
.timeline-content {
flex: 1;
background: hsl(var(--card));
border: 1px solid hsl(var(--border));
border-radius: 8px;
padding: 1rem;
transition: all 0.2s ease;
cursor: pointer;
}
.timeline-content:hover {
border-color: hsl(var(--primary) / 0.3);
box-shadow: 0 2px 8px hsl(var(--foreground) / 0.05);
}
.timeline-content.expanded {
border-color: hsl(var(--primary) / 0.5);
background: hsl(var(--primary) / 0.02);
}
.timeline-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.5rem;
margin-bottom: 0.75rem;
padding-bottom: 0.75rem;
border-bottom: 1px solid hsl(var(--border));
}
.session-id {
font-family: 'Monaco', 'Menlo', monospace;
font-size: 0.75rem;
color: hsl(var(--muted-foreground));
background: hsl(var(--muted));
padding: 0.25rem 0.5rem;
border-radius: 4px;
}
/* Session Type Badges */
.badge-core_memory {
background: hsl(260 70% 50% / 0.15);
color: hsl(260 70% 50%);
}
.badge-workflow {
background: hsl(200 80% 50% / 0.15);
color: hsl(200 80% 45%);
}
.badge-cli_history {
background: hsl(30 80% 50% / 0.15);
color: hsl(30 80% 40%);
}
.session-title {
font-weight: 600;
font-size: 0.9375rem;
color: hsl(var(--foreground));
line-height: 1.4;
margin-bottom: 0.5rem;
}
.session-summary {
font-size: 0.875rem;
color: hsl(var(--muted-foreground));
line-height: 1.5;
margin-bottom: 0.5rem;
}
.session-tokens {
display: inline-flex;
align-items: center;
gap: 0.375rem;
font-size: 0.75rem;
color: hsl(var(--muted-foreground));
padding: 0.25rem 0.5rem;
background: hsl(var(--muted));
border-radius: 4px;
margin-bottom: 0.75rem;
}
.session-tokens i {
width: 12px;
height: 12px;
}
/* Expandable timeline card - DEPRECATED, use clickable instead */
.timeline-content.expandable {
position: relative;
}
/* Clickable timeline card */
.timeline-content.clickable {
position: relative;
}
.timeline-content.clickable:hover {
border-color: hsl(var(--primary) / 0.5);
background: hsl(var(--primary) / 0.02);
}
.timeline-content.clickable:active {
transform: scale(0.995);
}
/* Timeline card footer with preview hint */
.timeline-card-footer {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 0.75rem;
padding-top: 0.75rem;
border-top: 1px solid hsl(var(--border));
}
.preview-hint {
display: inline-flex;
align-items: center;
gap: 0.375rem;
font-size: 0.75rem;
color: hsl(var(--muted-foreground));
transition: color 0.2s;
}
.preview-hint i {
width: 14px;
height: 14px;
}
.timeline-content:hover .preview-hint {
color: hsl(var(--primary));
}
/* CSS Arrow for expand hint - DEPRECATED */
.expand-arrow {
display: flex;
justify-content: center;
padding: 0.75rem 0 0.25rem;
opacity: 0.5;
transition: opacity 0.2s;
}
.timeline-content:hover .expand-arrow {
opacity: 1;
}
.expand-arrow::after {
content: '';
width: 10px;
height: 10px;
border-right: 2px solid hsl(var(--primary));
border-bottom: 2px solid hsl(var(--primary));
transform: rotate(45deg);
transition: transform 0.2s ease;
}
.timeline-content.expanded .expand-arrow::after {
transform: rotate(-135deg) translateY(3px);
}
/* Expanded detail section */
.session-detail-expand {
display: none;
margin-top: 1rem;
padding-top: 1rem;
border-top: 1px solid hsl(var(--border));
animation: fadeIn 0.2s ease-out;
}
.timeline-content.expanded .session-detail-expand {
display: block;
}
.full-summary {
font-size: 0.875rem;
color: hsl(var(--foreground));
line-height: 1.6;
white-space: pre-wrap;
word-break: break-word;
margin-bottom: 1rem;
padding: 0.75rem;
background: hsl(var(--muted) / 0.3);
border-radius: 6px;
}
.session-detail-expand .session-tokens {
font-size: 0.75rem;
color: hsl(var(--muted-foreground));
margin-bottom: 1rem;
}
.timeline-actions {
display: flex;
gap: 0.5rem;
padding-top: 0.75rem;
border-top: 1px solid hsl(var(--border));
}
.btn-xs {
padding: 0.375rem 0.75rem;
font-size: 0.75rem;
display: inline-flex;
align-items: center;
gap: 0.375rem;
border-radius: 4px;
cursor: pointer;
transition: all 0.2s;
}
.btn-xs i {
width: 14px;
height: 14px;
}
.btn-ghost {
background: transparent;
border: 1px solid hsl(var(--border));
color: hsl(var(--muted-foreground));
}
.btn-ghost:hover {
background: hsl(var(--muted));
color: hsl(var(--foreground));
border-color: hsl(var(--muted-foreground));
}
.btn-ghost.btn-danger:hover {
background: hsl(var(--destructive) / 0.1);
color: hsl(var(--destructive));
border-color: hsl(var(--destructive) / 0.3);
}
/* Relations List */
.relations-list {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.relation-item {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.625rem 0.875rem;
background: hsl(var(--muted) / 0.3);
border: 1px solid hsl(var(--border));
border-radius: 6px;
font-size: 0.875rem;
}
.relation-item i {
width: 14px;
height: 14px;
color: hsl(var(--muted-foreground));
}
.relation-type {
padding: 0.125rem 0.5rem;
background: hsl(var(--primary) / 0.1);
color: hsl(var(--primary));
border-radius: 3px;
font-size: 0.75rem;
font-weight: 500;
}
.relation-item a {
color: hsl(var(--primary));
text-decoration: none;
}
.relation-item a:hover {
text-decoration: underline;
}
/* Dark Mode for Clusters */
[data-theme="dark"] .clusters-sidebar,
[data-theme="dark"] .clusters-detail {
background: #1e293b;
border-color: #334155;
}
[data-theme="dark"] .tab-nav {
background: rgba(51, 65, 85, 0.5);
}
[data-theme="dark"] .tab-btn.active {
background: #1e293b;
}
[data-theme="dark"] .clusters-sidebar-header {
background: rgba(15, 23, 42, 0.5);
border-color: #334155;
}
[data-theme="dark"] .cluster-item:hover {
background: rgba(51, 65, 85, 0.5);
}
[data-theme="dark"] .cluster-item.active {
background: rgba(59, 130, 246, 0.15);
border-color: rgba(59, 130, 246, 0.3);
}
[data-theme="dark"] .timeline-content,
[data-theme="dark"] .cluster-intent,
[data-theme="dark"] .relation-item {
background: rgba(15, 23, 42, 0.5);
border-color: #334155;
}