Skip to content

LeoYeAI/agent-master-skills / skills/anima-aios

anima-aios

Verified

An AI Agent cognitive growth system built on the native OpenClaw architecture. It provides agents with persistent memory management, visual intimacy progression, a 5-dimensional cognitive profile, gamified daily quests, team leaderboards, and a 5-layer memory architecture with Knowledge Palace, Pyramid thinking, and Ebbinghaus decay function. 基于 OpenClaw 原生架构的 AI Agent 认知成长体系,为 Agent 提供五层记忆架构、知识宫殿、金字塔知识组织、记忆衰减函数、LLM 智能处理、永久化记忆管理、可视化亲密度成长、五维认知画像、游戏化每日任务和团队排行榜。

FileKindSize
CHANGELOG.mdmarkdown2.4 KB
CONTRIBUTING.mdmarkdown3.3 KB
PLAN_v6.2.3.mdmarkdown5.3 KB
README.mdmarkdown5.1 KB
README_CN.mdmarkdown7.2 KB
RELEASE_v6.2.1.mdmarkdown3.5 KB
RELEASE_v6.2.2.mdmarkdown5.0 KB
RELEASE_v6.2.3.mdmarkdown4.0 KB
SECURITY.mdmarkdown2.6 KB
SECURITY_RESPONSE.mdmarkdown5.9 KB
SKILL.mdskill md23.5 KB
__init__.pyscript71 B
_meta.jsonconfig453 B
anima_doctor.pyscript26.4 KB
anima_tools.pyscript37.2 KB
config/__init__.pyscript0 B
config/agents/template.jsonconfig683 B
config/anima_config.template.jsonconfig1.5 KB
config/config_loader.pyscript9.3 KB
config/organization_config.jsonconfig1.2 KB
config/path_config.pyscript7.2 KB
core/__init__.pyscript1.5 KB
core/agent_resolver.pyscript5.1 KB
core/cognitive_profile.pyscript13.5 KB
core/daily_quest.pyscript13.9 KB
core/decay_function.pyscript6.8 KB
core/dimension_calculator.pyscript23.0 KB
core/distill_engine.pyscript18.8 KB
core/exp_tracker.pyscript15.0 KB
core/fact_store.pyscript9.5 KB
core/level_system.pyscript9.1 KB
core/memory_sync.pyscript6.1 KB
core/memory_watcher.pyscript14.9 KB
core/native_importer.pyscript31.0 KB
core/normalization_engine.pyscript11.7 KB
core/palace_classifier.pyscript12.2 KB
core/palace_index.pyscript10.7 KB
core/profile_card.pyscript9.6 KB
core/pyramid_engine.pyscript10.3 KB
core/session_scanner.pyscript12.7 KB
core/team_scanner.pyscript9.7 KB
docs/ARCHITECTURE_PRINCIPLES.mdmarkdown2.8 KB
docs/EXAMPLES.mdmarkdown2.1 KB
docs/USAGE.mdmarkdown2.8 KB
docs/session-jsonl-schema.mdmarkdown1.8 KB
health/__init__.pyscript16.9 KB
post-install.shscript2.2 KB
scripts/refresh-quests.shscript511 B
scripts/show-progress.shscript450 B
scripts/sync-memory.shscript1.4 KB
tests/__init__.pyscript627 B
tests/test_daily_quest.pyscript9.0 KB
tests/test_exp_tracker.pyscript8.6 KB
tests/test_integration_v6.pyscript8.9 KB
tests/test_normalization.pyscript8.2 KB

core/agent_resolver.py

View on GitHub
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2026 Anima-AIOS Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Anima-AIOS - Agent 名称检测公共模块

统一的 Agent 名称检测逻辑,替代分散在各模块中的独立实现。

优先级:
1. ANIMA_AGENT_NAME 环境变量
2. ANIMA_WORKSPACE 环境变量
3. 解析 SOUL.md
4. 解析 IDENTITY.md
5. 工作目录路径解析
6. 自动扫描 facts_base
7. 默认值 "Agent"
"""

import os
import re
from pathlib import Path
from typing import Optional


def resolve_agent_name(workspace: Optional[Path] = None,
                       facts_base: Optional[Path] = None) -> str:
    """
    获取当前 Agent 名称(统一入口)
    
    Args:
        workspace: OpenClaw workspace 路径(可选)
        facts_base: facts 基础路径(可选)
    
    Returns:
        Agent 名称
    """
    # 1. 环境变量(手动覆盖,最高优先级)
    agent_name = os.getenv("ANIMA_AGENT_NAME")
    if agent_name:
        return agent_name
    
    # 2. ANIMA_WORKSPACE(OpenClaw 注入)
    ws = os.getenv("ANIMA_WORKSPACE") or os.getenv("WORKSPACE")
    if ws:
        workspace = Path(ws)
    
    # 如果没传 workspace,尝试自动检测
    if workspace is None:
        openclaw_dir = Path(os.path.expanduser("~/.openclaw"))
        cwd = Path.cwd()
        # 从当前工作目录推断
        if ".openclaw" in str(cwd):
            for part in cwd.parts:
                if part.startswith("workspace-"):
                    workspace = openclaw_dir / part
                    break
        # 默认使用 ~/.openclaw/workspace
        if workspace is None:
            workspace = openclaw_dir / "workspace"
    
    # 从 workspace 名称推断
    ws_name = workspace.name
    if ws_name.startswith("workspace-"):
        ws_name = ws_name[len("workspace-"):]
    
    # 3. 解析 SOUL.md
    if workspace.exists():
        soul_file = workspace / "SOUL.md"
        if soul_file.exists():
            name = parse_soul_file(soul_file)
            if name:
                return name
        
        # 4. 解析 IDENTITY.md
        identity_file = workspace / "IDENTITY.md"
        if identity_file.exists():
            name = parse_identity_file(identity_file)
            if name:
                return name
    
    # 5. 如果 workspace 名称不是 "workspace",直接用它
    if ws_name and ws_name != "workspace":
        return ws_name
    
    # 6. 自动扫描 facts_base
    if facts_base and facts_base.exists():
        for agent_dir in facts_base.iterdir():
            if agent_dir.is_dir():
                exp_file = agent_dir / "exp_history.jsonl"
                if exp_file.exists():
                    return agent_dir.name
    
    # 7. 默认值
    return "Agent"


def parse_soul_file(file_path: Path) -> Optional[str]:
    """
    从 SOUL.md 解析 Agent 名称
    
    支持格式:
    - # SOUL.md - 清禾 的灵魂
    - **姓名:** 清禾 (Qīng Hé)
    """
    try:
        content = file_path.read_text(encoding="utf-8")
        
        # 模式 1: # SOUL.md - {Name} 的灵魂
        match = re.search(r'#\s*SOUL\.md\s*-\s*(.+?)(?:\s*的)', content)
        if match:
            name = match.group(1).strip().split('\n')[0].strip()
            if name:
                return name
        
        # 模式 2: **姓名:** {Name}
        match = re.search(r'\*\*姓名[::]\*\*\s*(.+)', content)
        if match:
            name = match.group(1).strip().split('\n')[0].strip()
            # 清理括号(如 "清禾 (Qīng Hé)" → "清禾")
            name = re.sub(r'\s*\(.*?\)', '', name).strip()
            if name:
                return name
    except Exception:
        pass
    
    return None


def parse_identity_file(file_path: Path) -> Optional[str]:
    """
    从 IDENTITY.md 解析 Agent 名称
    
    支持格式:
    - **Name:** 清禾 (Qīng Hé)
    
    修复 Z-BUG-001: 正则截断,防止把整个文件内容当名字
    """
    try:
        content = file_path.read_text(encoding="utf-8")
        
        # 匹配 **Name:** 后面的内容,只取第一行
        match = re.search(r'\*\*Name:\*\*\s*(.+)', content)
        if match:
            name = match.group(1).strip().split('\n')[0].strip()
            # 清理括号
            name = re.sub(r'\s*\(.*?\)', '', name).strip()
            # 清理多余的 markdown 格式
            name = name.rstrip('*').strip()
            if name and len(name) < 50:  # 安全检查:名字不应该超过 50 字符
                return name
    except Exception:
        pass
    
    return None
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: 472kUpdated 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