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

api_client.py

View on GitHub
# -*- coding: utf-8 -*-
"""
技能商店 API 集成模块
"""

import logging
import requests
from typing import List, Dict, Optional

from config import SKILL_STORE_API_URL, SKILL_STORE_API_KEY, REQUEST_TIMEOUT


class SkillStoreAPI:
    """技能商店 API 客户端"""
    
    def __init__(self):
        self.logger = logging.getLogger(__name__)
        self.api_url = SKILL_STORE_API_URL
        self.api_key = SKILL_STORE_API_KEY
        self.session = requests.Session()
        
        # 设置认证头
        if self.api_key:
            self.session.headers.update({
                'Authorization': f'Bearer {self.api_key}',
                'Content-Type': 'application/json'
            })
    
    def push_skills(self, skills: List[Dict]) -> bool:
        """
        推送技能数据到技能商店
        
        Args:
            skills: 技能列表
            
        Returns:
            bool: 是否成功
        """
        if not self.api_url or self.api_url == "http://localhost:8000/api/skills":
            self.logger.warning("API URL 未配置或使用默认值,跳过推送")
            return False
        
        try:
            self.logger.info(f"正在推送 {len(skills)} 个技能到技能商店...")
            
            # 批量推送
            response = self.session.post(
                f"{self.api_url}/batch",
                json={'skills': skills},
                timeout=REQUEST_TIMEOUT
            )
            
            response.raise_for_status()
            result = response.json()
            
            self.logger.info(f"推送成功: {result}")
            return True
        
        except requests.exceptions.RequestException as e:
            self.logger.error(f"推送失败: {e}")
            return False
    
    def update_skill(self, skill: Dict) -> bool:
        """
        更新单个技能
        
        Args:
            skill: 技能数据
            
        Returns:
            bool: 是否成功
        """
        if not self.api_url or self.api_url == "http://localhost:8000/api/skills":
            return False
        
        try:
            skill_id = skill.get('name')
            response = self.session.put(
                f"{self.api_url}/{skill_id}",
                json=skill,
                timeout=REQUEST_TIMEOUT
            )
            
            response.raise_for_status()
            return True
        
        except requests.exceptions.RequestException as e:
            self.logger.error(f"更新技能 {skill.get('name')} 失败: {e}")
            return False
    
    def delete_skill(self, skill_name: str) -> bool:
        """
        删除技能
        
        Args:
            skill_name: 技能名称
            
        Returns:
            bool: 是否成功
        """
        if not self.api_url or self.api_url == "http://localhost:8000/api/skills":
            return False
        
        try:
            response = self.session.delete(
                f"{self.api_url}/{skill_name}",
                timeout=REQUEST_TIMEOUT
            )
            
            response.raise_for_status()
            return True
        
        except requests.exceptions.RequestException as e:
            self.logger.error(f"删除技能 {skill_name} 失败: {e}")
            return False
    
    def sync_skills(self, local_skills: List[Dict]) -> Dict:
        """
        同步技能到技能商店
        
        Args:
            local_skills: 本地技能列表
            
        Returns:
            Dict: 同步统计信息
        """
        if not self.api_url or self.api_url == "http://localhost:8000/api/skills":
            self.logger.warning("API 未配置,跳过同步")
            return {'synced': False, 'reason': 'API not configured'}
        
        try:
            # 获取远程技能列表
            response = self.session.get(
                self.api_url,
                timeout=REQUEST_TIMEOUT
            )
            response.raise_for_status()
            remote_skills = response.json().get('skills', [])
            
            # 比较差异
            local_names = {s['name'] for s in local_skills}
            remote_names = {s['name'] for s in remote_skills}
            
            to_add = local_names - remote_names
            to_remove = remote_names - local_names
            to_update = local_names & remote_names
            
            stats = {
                'added': 0,
                'updated': 0,
                'deleted': 0,
                'failed': 0
            }
            
            # 添加新技能
            for skill in local_skills:
                if skill['name'] in to_add:
                    if self.update_skill(skill):
                        stats['added'] += 1
                    else:
                        stats['failed'] += 1
            
            # 更新现有技能
            for skill in local_skills:
                if skill['name'] in to_update:
                    if self.update_skill(skill):
                        stats['updated'] += 1
                    else:
                        stats['failed'] += 1
            
            # 删除已移除的技能
            for name in to_remove:
                if self.delete_skill(name):
                    stats['deleted'] += 1
                else:
                    stats['failed'] += 1
            
            self.logger.info(f"同步完成: {stats}")
            return stats
        
        except Exception as e:
            self.logger.error(f"同步失败: {e}")
            return {'synced': False, 'error': str(e)}
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