feat(intelligence): add reflection config persistence and proactive personality suggestions
Config Persistence: - Save reflection config to localStorage - Load config on startup with fallback defaults - Auto-sync config changes to backend Proactive Personality Suggestions (P2): - Add check_personality_improvement to heartbeat engine - Detects user correction patterns (啰嗦/简洁, etc.) - Add check_learning_opportunities to heartbeat engine - Identifies learning opportunities from conversations - Both checks generate HeartbeatAlert when thresholds met These enhancements complete the self-evolution capability chain. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,39 @@ import {
|
||||
type ImprovementSuggestion,
|
||||
} from '../lib/intelligence-client';
|
||||
|
||||
// === Config Persistence ===
|
||||
|
||||
const REFLECTION_CONFIG_KEY = 'zclaw-reflection-config';
|
||||
|
||||
const DEFAULT_CONFIG: ReflectionConfig = {
|
||||
trigger_after_conversations: 5,
|
||||
allow_soul_modification: true,
|
||||
require_approval: true,
|
||||
use_llm: true,
|
||||
llm_fallback_to_rules: true,
|
||||
};
|
||||
|
||||
function loadConfig(): ReflectionConfig {
|
||||
try {
|
||||
const stored = localStorage.getItem(REFLECTION_CONFIG_KEY);
|
||||
if (stored) {
|
||||
const parsed = JSON.parse(stored);
|
||||
return { ...DEFAULT_CONFIG, ...parsed };
|
||||
}
|
||||
} catch {
|
||||
console.warn('[ReflectionLog] Failed to load config from localStorage');
|
||||
}
|
||||
return DEFAULT_CONFIG;
|
||||
}
|
||||
|
||||
function saveConfig(config: ReflectionConfig): void {
|
||||
try {
|
||||
localStorage.setItem(REFLECTION_CONFIG_KEY, JSON.stringify(config));
|
||||
} catch {
|
||||
console.warn('[ReflectionLog] Failed to save config to localStorage');
|
||||
}
|
||||
}
|
||||
|
||||
// === Types ===
|
||||
|
||||
interface ReflectionLogProps {
|
||||
@@ -385,11 +418,12 @@ export function ReflectionLog({
|
||||
const [expandedId, setExpandedId] = useState<string | null>(null);
|
||||
const [isReflecting, setIsReflecting] = useState(false);
|
||||
const [showConfig, setShowConfig] = useState(false);
|
||||
const [config, setConfig] = useState<ReflectionConfig>({
|
||||
trigger_after_conversations: 5,
|
||||
allow_soul_modification: true,
|
||||
require_approval: true,
|
||||
});
|
||||
const [config, setConfig] = useState<ReflectionConfig>(() => loadConfig());
|
||||
|
||||
// Persist config changes
|
||||
useEffect(() => {
|
||||
saveConfig(config);
|
||||
}, [config]);
|
||||
|
||||
// Load history and pending proposals
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user