Skip to content

anbeime/skill / projects/companion-simple

xiaoyue-companion

Verified

专为软件开发工程师与综合办公文员打造。当你在等待任务执行、工作疲惫或需要鼓励时,使用此技能通过智谱AI自动生成温暖对话回应与场景配图,一键获取专属情绪价值与虚拟陪伴,让AI助手更懂你。

FileKindSize
.gitignoreother603 B
API_INTEGRATION.mdmarkdown4.3 KB
DEMO-SUCCESS.mdmarkdown4.3 KB
DEPLOYMENT_CHECKLIST.mdmarkdown5.8 KB
DEPLOYMENT_GUIDE.mdmarkdown6.0 KB
FINAL-SUMMARY.mdmarkdown1.3 KB
PROJECT_SUMMARY.mdmarkdown5.3 KB
QUICKSTART.mdmarkdown4.8 KB
README-FINAL.mdmarkdown3.1 KB
README.mdmarkdown10.5 KB
SKILL.mdskill md6.6 KB
SUMMARY.mdmarkdown3.1 KB
USAGE-GUIDE.mdmarkdown5.9 KB
XIAOYI-README.mdmarkdown5.1 KB
api_client.pyscript5.5 KB
api_server_example.pyscript6.3 KB
config.pyscript859 B
crawler.pyscript4.6 KB
data/last_update.txtmarkdown26 B
data/local_skills.jsonconfig5.4 KB
data/skills.jsonconfig66.5 KB
data_manager.pyscript4.6 KB
docs/D盘tool目录整理完成报告.mdmarkdown15.8 KB
docs/技能数量差异分析报告.mdmarkdown7.0 KB
docs/技能清理与迁移指南.mdmarkdown14.6 KB
docs/技能管理数据库.mdmarkdown32.1 KB
docs/整理完成总结.mdmarkdown5.7 KB
main.pyscript5.0 KB
package-lock.jsonmanifest103 B
public/index-en.htmlother9.9 KB
public/index.htmlother11.1 KB
public/local-skills.htmlother8.4 KB
public/skills-en.htmlother16.7 KB
public/skills.htmlother28.0 KB
public/styles.cssother6.6 KB
requirements.txtmanifest140 B
run_once.batscript560 B
scheduler.pyscript4.2 KB
scripts/xiaoyi-chat.ps1script1.7 KB
scripts/xiaoyue-chat.jsscript2.8 KB
scripts/xiaoyue-chat.ps1script1.5 KB
scripts/xiaoyue-companion.shscript2.2 KB
setup_scheduled_task.ps1script1.0 KB
start_daemon.batscript771 B
templates/soul-injection.mdmarkdown1.8 KB
vercel.jsonconfig371 B
技能清单.mdmarkdown2.7 KB

data_manager.py

View on GitHub
# -*- coding: utf-8 -*-
"""
数据存储和管理模块
"""

import os
import json
import logging
from typing import List, Dict, Optional
from datetime import datetime

from config import DATA_DIR, SKILLS_JSON_PATH, LAST_UPDATE_PATH


class DataManager:
    """数据管理类"""
    
    def __init__(self):
        self.logger = logging.getLogger(__name__)
        self._ensure_directories()
    
    def _ensure_directories(self):
        """确保必要的目录存在"""
        os.makedirs(DATA_DIR, exist_ok=True)
        self.logger.info(f"数据目录已准备: {DATA_DIR}")
    
    def save_skills(self, skills: List[Dict]) -> bool:
        """保存技能数据到 JSON 文件"""
        try:
            with open(SKILLS_JSON_PATH, 'w', encoding='utf-8') as f:
                json.dump({
                    'skills': skills,
                    'total': len(skills),
                    'updated_at': datetime.now().isoformat()
                }, f, ensure_ascii=False, indent=2)
            
            self.logger.info(f"技能数据已保存到: {SKILLS_JSON_PATH}")
            return True
        except Exception as e:
            self.logger.error(f"保存技能数据失败: {e}")
            return False
    
    def load_skills(self) -> Optional[List[Dict]]:
        """从 JSON 文件加载技能数据"""
        if not os.path.exists(SKILLS_JSON_PATH):
            self.logger.warning("技能数据文件不存在")
            return None
        
        try:
            with open(SKILLS_JSON_PATH, 'r', encoding='utf-8') as f:
                data = json.load(f)
            
            skills = data.get('skills', [])
            self.logger.info(f"已加载 {len(skills)} 个技能")
            return skills
        except Exception as e:
            self.logger.error(f"加载技能数据失败: {e}")
            return None
    
    def save_update_time(self):
        """保存最后更新时间"""
        try:
            with open(LAST_UPDATE_PATH, 'w', encoding='utf-8') as f:
                f.write(datetime.now().isoformat())
            self.logger.info("更新时间已记录")
        except Exception as e:
            self.logger.error(f"保存更新时间失败: {e}")
    
    def get_last_update_time(self) -> Optional[datetime]:
        """获取最后更新时间"""
        if not os.path.exists(LAST_UPDATE_PATH):
            return None
        
        try:
            with open(LAST_UPDATE_PATH, 'r', encoding='utf-8') as f:
                time_str = f.read().strip()
            return datetime.fromisoformat(time_str)
        except Exception as e:
            self.logger.error(f"读取更新时间失败: {e}")
            return None
    
    def compare_skills(self, old_skills: List[Dict], new_skills: List[Dict]) -> Dict:
        """比较新旧技能数据,返回变更统计"""
        old_names = {s['name'] for s in old_skills}
        new_names = {s['name'] for s in new_skills}
        
        added = new_names - old_names
        removed = old_names - new_names
        
        # 检查描述或链接变更
        old_dict = {s['name']: s for s in old_skills}
        new_dict = {s['name']: s for s in new_skills}
        
        modified = []
        for name in old_names & new_names:
            if (old_dict[name]['description'] != new_dict[name]['description'] or
                old_dict[name]['link'] != new_dict[name]['link']):
                modified.append(name)
        
        changes = {
            'added': list(added),
            'removed': list(removed),
            'modified': modified,
            'total_old': len(old_skills),
            'total_new': len(new_skills)
        }
        
        self.logger.info(f"变更统计: 新增 {len(added)}, 删除 {len(removed)}, 修改 {len(modified)}")
        return changes
    
    def export_to_csv(self, skills: List[Dict], output_path: str) -> bool:
        """导出技能数据为 CSV 格式"""
        try:
            import csv
            
            with open(output_path, 'w', newline='', encoding='utf-8-sig') as f:
                if not skills:
                    return False
                
                fieldnames = ['name', 'description', 'link', 'category', 'source']
                writer = csv.DictWriter(f, fieldnames=fieldnames)
                
                writer.writeheader()
                for skill in skills:
                    writer.writerow({k: skill.get(k, '') for k in fieldnames})
            
            self.logger.info(f"CSV 导出成功: {output_path}")
            return True
        except Exception as e:
            self.logger.error(f"CSV 导出失败: {e}")
            return False
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall