Skip to content

anbeime/skill / projects/companion-skill

companion-skill

Verified

软件开发工程师与综合办公文员在长时间独自执行后台任务或处理繁琐工作时,当需要情绪陪伴与互动反馈,请使用此技能。小跃虚拟伴侣会在任务期间主动陪聊,智能生成专属生活照片并通过飞书发送温暖消息,为你提供全天候的情绪价值与贴心陪伴。

FileKindSize
.env.exampleother403 B
CHANGELOG.mdmarkdown3.0 KB
INSTALL.mdmarkdown2.4 KB
QUICKSTART.mdmarkdown4.6 KB
README-LITE.mdmarkdown4.3 KB
README.mdmarkdown4.5 KB
RETHINK.mdmarkdown2.3 KB
SKILL.mdskill md4.6 KB
package.jsonmanifest876 B
src/companion.tsscript5.4 KB
src/image-generator.tsscript8.0 KB
src/index.tsscript2.5 KB
src/prompts/personality.tsscript3.3 KB
src/scene-detector.tsscript4.0 KB
src/test.tsscript6.9 KB
tsconfig.jsonconfig486 B

src/index.ts

View on GitHub
/**
 * 小跃虚拟伴侣 Skill - 主入口
 * 为 OpenClaw 提供虚拟伴侣能力
 */

import { CompanionService } from './companion';
import { ImageGenerator } from './image-generator';
import { SceneDetector } from './scene-detector';

interface SkillInput {
  action: 'accompany' | 'generate-photo' | 'chat';
  context?: {
    taskName?: string;
    progress?: number;
    userMessage?: string;
  };
  scene?: string;
  mood?: string;
  message?: string;
}

interface SkillOutput {
  success: boolean;
  message?: string;
  imageUrl?: string;
  error?: string;
}

export async function execute(input: SkillInput): Promise<SkillOutput> {
  try {
    const apiKey = process.env.ZHIPU_API_KEY;
    if (!apiKey) {
      throw new Error('ZHIPU_API_KEY not configured');
    }

    const companion = new CompanionService(apiKey);
    const imageGenerator = new ImageGenerator(apiKey);
    const sceneDetector = new SceneDetector();

    switch (input.action) {
      case 'accompany': {
        // 任务陪伴模式
        const { taskName, progress, userMessage } = input.context || {};
        
        // 检测场景
        const scene = sceneDetector.detectScene(userMessage || '', progress || 0);
        
        // 生成回应
        const response = await companion.generateResponse({
          taskName,
          progress,
          userMessage,
          scene
        });

        // 如果需要图片,生成图片
        let imageUrl: string | undefined;
        if (scene.needsPhoto) {
          imageUrl = await imageGenerator.generate({
            scene: scene.type,
            mood: scene.mood
          });
        }

        return {
          success: true,
          message: response,
          imageUrl
        };
      }

      case 'generate-photo': {
        // 纯图片生成
        const imageUrl = await imageGenerator.generate({
          scene: input.scene || 'work',
          mood: input.mood || 'neutral'
        });

        return {
          success: true,
          imageUrl
        };
      }

      case 'chat': {
        // 纯对话模式
        const response = await companion.chat(input.message || '');
        
        return {
          success: true,
          message: response
        };
      }

      default:
        throw new Error(`Unknown action: ${input.action}`);
    }
  } catch (error) {
    console.error('Skill execution error:', error);
    return {
      success: false,
      error: error instanceof Error ? error.message : 'Unknown error'
    };
  }
}

// 导出类型供外部使用
export type { SkillInput, SkillOutput };
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall