yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::cli::agent::LearnedKnowledgeService Class Reference

Manages persistent learned information across agent sessions. More...

#include <learned_knowledge_service.h>

Classes

struct  ConversationMemory
 
struct  ProjectContext
 
struct  ROMPattern
 
struct  Stats
 

Public Member Functions

 LearnedKnowledgeService ()
 
 LearnedKnowledgeService (const std::filesystem::path &data_dir)
 
absl::Status Initialize ()
 
absl::Status SaveAll ()
 
absl::Status SetPreference (const std::string &key, const std::string &value)
 
std::optional< std::string > GetPreference (const std::string &key) const
 
std::map< std::string, std::string > GetAllPreferences () const
 
absl::Status RemovePreference (const std::string &key)
 
absl::Status LearnPattern (const std::string &type, const std::string &rom_hash, const std::string &data, float confidence=1.0f)
 
std::vector< ROMPatternQueryPatterns (const std::string &type, const std::string &rom_hash="") const
 
absl::Status UpdatePatternConfidence (const std::string &type, const std::string &rom_hash, float new_confidence)
 
absl::Status SaveProjectContext (const std::string &project_name, const std::string &rom_hash, const std::string &context)
 
std::optional< ProjectContextGetProjectContext (const std::string &project_name) const
 
std::vector< ProjectContextGetAllProjects () const
 
absl::Status StoreConversationSummary (const std::string &topic, const std::string &summary, const std::vector< std::string > &key_facts)
 
std::vector< ConversationMemorySearchMemories (const std::string &query) const
 
std::vector< ConversationMemoryGetRecentMemories (int limit=10) const
 
absl::StatusOr< std::string > ExportToJSON () const
 
absl::Status ImportFromJSON (const std::string &json_data)
 
absl::Status ClearAll ()
 
Stats GetStats () const
 

Private Member Functions

absl::Status LoadPreferences ()
 
absl::Status LoadPatterns ()
 
absl::Status LoadProjects ()
 
absl::Status LoadMemories ()
 
absl::Status SavePreferences ()
 
absl::Status SavePatterns ()
 
absl::Status SaveProjects ()
 
absl::Status SaveMemories ()
 
std::string GenerateID () const
 

Private Attributes

std::filesystem::path data_dir_
 
std::filesystem::path prefs_file_
 
std::filesystem::path patterns_file_
 
std::filesystem::path projects_file_
 
std::filesystem::path memories_file_
 
std::map< std::string, std::string > preferences_
 
std::vector< ROMPatternpatterns_
 
std::vector< ProjectContextprojects_
 
std::vector< ConversationMemorymemories_
 
bool initialized_ = false
 

Detailed Description

Manages persistent learned information across agent sessions.

Stores:

  • User preferences (default palettes, favorite tools, etc.)
  • ROM patterns (frequently accessed rooms, sprite placements, etc.)
  • Project context (ROM-specific notes, goals, custom names)
  • Conversation memory (summaries of past discussions)

Definition at line 31 of file learned_knowledge_service.h.

Constructor & Destructor Documentation

◆ LearnedKnowledgeService() [1/2]

yaze::cli::agent::LearnedKnowledgeService::LearnedKnowledgeService ( )

Definition at line 37 of file learned_knowledge_service.cc.

References data_dir_, yaze::util::PlatformPaths::GetAppDataSubdirectory(), memories_file_, patterns_file_, prefs_file_, and projects_file_.

Here is the call graph for this function:

◆ LearnedKnowledgeService() [2/2]

yaze::cli::agent::LearnedKnowledgeService::LearnedKnowledgeService ( const std::filesystem::path &  data_dir)
explicit

Definition at line 53 of file learned_knowledge_service.cc.

Member Function Documentation

◆ Initialize()

absl::Status yaze::cli::agent::LearnedKnowledgeService::Initialize ( )

◆ SaveAll()

absl::Status yaze::cli::agent::LearnedKnowledgeService::SaveAll ( )

Definition at line 82 of file learned_knowledge_service.cc.

References SaveMemories(), SavePatterns(), SavePreferences(), and SaveProjects().

Referenced by ClearAll().

Here is the call graph for this function:

◆ SetPreference()

absl::Status yaze::cli::agent::LearnedKnowledgeService::SetPreference ( const std::string &  key,
const std::string &  value 
)

Set a user preference

Parameters
keyPreference key (e.g., "default_palette", "preferred_tool")
valuePreference value

Definition at line 100 of file learned_knowledge_service.cc.

References initialized_, preferences_, and SavePreferences().

Referenced by yaze::cli::agent::HandleLearnCommand().

Here is the call graph for this function:

◆ GetPreference()

std::optional< std::string > yaze::cli::agent::LearnedKnowledgeService::GetPreference ( const std::string &  key) const

Get a user preference

Parameters
keyPreference key
Returns
Value if exists, nullopt otherwise

Definition at line 110 of file learned_knowledge_service.cc.

References preferences_.

Referenced by yaze::cli::agent::HandleLearnCommand().

◆ GetAllPreferences()

std::map< std::string, std::string > yaze::cli::agent::LearnedKnowledgeService::GetAllPreferences ( ) const

List all preferences

Definition at line 119 of file learned_knowledge_service.cc.

References preferences_.

Referenced by yaze::cli::agent::HandleLearnCommand().

◆ RemovePreference()

absl::Status yaze::cli::agent::LearnedKnowledgeService::RemovePreference ( const std::string &  key)

Remove a preference

Definition at line 123 of file learned_knowledge_service.cc.

References initialized_, preferences_, and SavePreferences().

Here is the call graph for this function:

◆ LearnPattern()

absl::Status yaze::cli::agent::LearnedKnowledgeService::LearnPattern ( const std::string &  type,
const std::string &  rom_hash,
const std::string &  data,
float  confidence = 1.0f 
)

◆ QueryPatterns()

std::vector< LearnedKnowledgeService::ROMPattern > yaze::cli::agent::LearnedKnowledgeService::QueryPatterns ( const std::string &  type,
const std::string &  rom_hash = "" 
) const

Query patterns for a specific ROM

Parameters
typePattern type to query
rom_hashROM hash to filter by (empty = all ROMs)
Returns
Vector of matching patterns

Definition at line 155 of file learned_knowledge_service.cc.

References patterns_.

◆ UpdatePatternConfidence()

absl::Status yaze::cli::agent::LearnedKnowledgeService::UpdatePatternConfidence ( const std::string &  type,
const std::string &  rom_hash,
float  new_confidence 
)

Update pattern confidence/access count

Definition at line 171 of file learned_knowledge_service.cc.

References patterns_, and SavePatterns().

Here is the call graph for this function:

◆ SaveProjectContext()

absl::Status yaze::cli::agent::LearnedKnowledgeService::SaveProjectContext ( const std::string &  project_name,
const std::string &  rom_hash,
const std::string &  context 
)

◆ GetProjectContext()

std::optional< LearnedKnowledgeService::ProjectContext > yaze::cli::agent::LearnedKnowledgeService::GetProjectContext ( const std::string &  project_name) const

Get project context

Definition at line 227 of file learned_knowledge_service.cc.

References projects_.

◆ GetAllProjects()

std::vector< LearnedKnowledgeService::ProjectContext > yaze::cli::agent::LearnedKnowledgeService::GetAllProjects ( ) const

List all projects

Definition at line 237 of file learned_knowledge_service.cc.

References projects_.

Referenced by yaze::cli::agent::HandleLearnCommand().

◆ StoreConversationSummary()

absl::Status yaze::cli::agent::LearnedKnowledgeService::StoreConversationSummary ( const std::string &  topic,
const std::string &  summary,
const std::vector< std::string > &  key_facts 
)

◆ SearchMemories()

std::vector< LearnedKnowledgeService::ConversationMemory > yaze::cli::agent::LearnedKnowledgeService::SearchMemories ( const std::string &  query) const

Search conversation memories by topic/keyword

Definition at line 270 of file learned_knowledge_service.cc.

References memories_.

◆ GetRecentMemories()

std::vector< LearnedKnowledgeService::ConversationMemory > yaze::cli::agent::LearnedKnowledgeService::GetRecentMemories ( int  limit = 10) const

Get most recent conversation memories

Definition at line 292 of file learned_knowledge_service.cc.

References memories_.

Referenced by yaze::cli::agent::HandleLearnCommand().

◆ ExportToJSON()

absl::StatusOr< std::string > yaze::cli::agent::LearnedKnowledgeService::ExportToJSON ( ) const

Export all learned data to JSON

Definition at line 414 of file learned_knowledge_service.cc.

Referenced by yaze::cli::agent::HandleLearnCommand().

◆ ImportFromJSON()

absl::Status yaze::cli::agent::LearnedKnowledgeService::ImportFromJSON ( const std::string &  json_data)

Import learned data from JSON

Definition at line 418 of file learned_knowledge_service.cc.

Referenced by yaze::cli::agent::HandleLearnCommand().

◆ ClearAll()

absl::Status yaze::cli::agent::LearnedKnowledgeService::ClearAll ( )

Clear all learned data

Definition at line 423 of file learned_knowledge_service.cc.

References memories_, patterns_, preferences_, projects_, and SaveAll().

Referenced by yaze::cli::agent::HandleLearnCommand().

Here is the call graph for this function:

◆ GetStats()

◆ LoadPreferences()

absl::Status yaze::cli::agent::LearnedKnowledgeService::LoadPreferences ( )
private

Definition at line 651 of file learned_knowledge_service.cc.

Referenced by Initialize().

◆ LoadPatterns()

absl::Status yaze::cli::agent::LearnedKnowledgeService::LoadPatterns ( )
private

Definition at line 653 of file learned_knowledge_service.cc.

Referenced by Initialize().

◆ LoadProjects()

absl::Status yaze::cli::agent::LearnedKnowledgeService::LoadProjects ( )
private

Definition at line 655 of file learned_knowledge_service.cc.

Referenced by Initialize().

◆ LoadMemories()

absl::Status yaze::cli::agent::LearnedKnowledgeService::LoadMemories ( )
private

Definition at line 657 of file learned_knowledge_service.cc.

Referenced by Initialize().

◆ SavePreferences()

absl::Status yaze::cli::agent::LearnedKnowledgeService::SavePreferences ( )
private

Definition at line 652 of file learned_knowledge_service.cc.

Referenced by RemovePreference(), SaveAll(), and SetPreference().

◆ SavePatterns()

absl::Status yaze::cli::agent::LearnedKnowledgeService::SavePatterns ( )
private

Definition at line 654 of file learned_knowledge_service.cc.

Referenced by LearnPattern(), SaveAll(), and UpdatePatternConfidence().

◆ SaveProjects()

absl::Status yaze::cli::agent::LearnedKnowledgeService::SaveProjects ( )
private

Definition at line 656 of file learned_knowledge_service.cc.

Referenced by SaveAll(), and SaveProjectContext().

◆ SaveMemories()

absl::Status yaze::cli::agent::LearnedKnowledgeService::SaveMemories ( )
private

Definition at line 658 of file learned_knowledge_service.cc.

Referenced by SaveAll(), and StoreConversationSummary().

◆ GenerateID()

std::string yaze::cli::agent::LearnedKnowledgeService::GenerateID ( ) const
private

Definition at line 661 of file learned_knowledge_service.cc.

Member Data Documentation

◆ data_dir_

std::filesystem::path yaze::cli::agent::LearnedKnowledgeService::data_dir_
private

Definition at line 194 of file learned_knowledge_service.h.

Referenced by Initialize(), and LearnedKnowledgeService().

◆ prefs_file_

std::filesystem::path yaze::cli::agent::LearnedKnowledgeService::prefs_file_
private

Definition at line 195 of file learned_knowledge_service.h.

Referenced by LearnedKnowledgeService().

◆ patterns_file_

std::filesystem::path yaze::cli::agent::LearnedKnowledgeService::patterns_file_
private

Definition at line 196 of file learned_knowledge_service.h.

Referenced by LearnedKnowledgeService().

◆ projects_file_

std::filesystem::path yaze::cli::agent::LearnedKnowledgeService::projects_file_
private

Definition at line 197 of file learned_knowledge_service.h.

Referenced by LearnedKnowledgeService().

◆ memories_file_

std::filesystem::path yaze::cli::agent::LearnedKnowledgeService::memories_file_
private

Definition at line 198 of file learned_knowledge_service.h.

Referenced by LearnedKnowledgeService().

◆ preferences_

std::map<std::string, std::string> yaze::cli::agent::LearnedKnowledgeService::preferences_
private

◆ patterns_

std::vector<ROMPattern> yaze::cli::agent::LearnedKnowledgeService::patterns_
private

◆ projects_

std::vector<ProjectContext> yaze::cli::agent::LearnedKnowledgeService::projects_
private

◆ memories_

std::vector<ConversationMemory> yaze::cli::agent::LearnedKnowledgeService::memories_
private

◆ initialized_

bool yaze::cli::agent::LearnedKnowledgeService::initialized_ = false
private

The documentation for this class was generated from the following files: