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

tests/test_normalization.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 v5.0 - Normalization Engine Tests

测试归一化引擎的三种模式
"""

import sys
import unittest
from pathlib import Path

# 添加核心模块路径
sys.path.insert(0, str(Path(__file__).parent.parent / 'core'))

from normalization_engine import NormalizationEngine


class TestNormalizationEngine(unittest.TestCase):
    """归一化引擎测试"""
    
    def setUp(self):
        """测试前准备"""
        self.engine = NormalizationEngine()
        
        # 测试数据
        self.raw_scores = {
            'understanding': 45,
            'application': 30,
            'creation': 25,
            'metacognition': 12,
            'collaboration': 35
        }
    
    def test_absolute_normalization_single_agent(self):
        """测试绝对基准归一化(单 Agent 模式)"""
        normalized = self.engine._absolute_normalization(self.raw_scores)
        
        # 验证归一化结果在 0-100 范围内
        for dimension, score in normalized.items():
            self.assertGreaterEqual(score, 0, f"{dimension} 分数不能为负")
            self.assertLessEqual(score, 100, f"{dimension} 分数不能超过 100")
        
        # 验证专家级分数(200+ 应该接近 100)
        expert_scores = {'understanding': 250, 'application': 150, 'creation': 60}
        expert_normalized = self.engine._absolute_normalization(expert_scores)
        self.assertGreater(expert_normalized['understanding'], 80, "专家级分数应该>80")
    
    def test_percentile_normalization_large_team(self):
        """测试百分位数归一化(大团队模式)"""
        team_scores = {
            'understanding': [20, 35, 45, 60, 80],
            'application': [15, 25, 30, 45, 70],
            'creation': [10, 20, 25, 40, 55],
            'metacognition': [5, 10, 12, 20, 35],
            'collaboration': [18, 30, 35, 50, 65]
        }
        
        normalized = self.engine._percentile_normalization(self.raw_scores, team_scores)
        
        # 验证归一化结果在 5-95 范围内(平滑处理)
        for dimension, score in normalized.items():
            self.assertGreaterEqual(score, 5, f"{dimension} 分数应该>=5(平滑)")
            self.assertLessEqual(score, 95, f"{dimension} 分数应该<=95(平滑)")
        
        # 验证排名:最高分应该接近 95
        top_scores = {
            'understanding': 80,
            'application': 70,
            'creation': 55,
            'metacognition': 35,
            'collaboration': 65
        }
        top_normalized = self.engine._percentile_normalization(top_scores, team_scores)
        self.assertGreater(top_normalized['understanding'], 70, "最高分应该>70")
    
    def test_hybrid_normalization_small_team(self):
        """测试混合归一化(小团队模式)"""
        team_scores = {
            'understanding': [30, 45, 60],
            'application': [20, 30, 45],
            'creation': [15, 25, 40],
            'metacognition': [8, 12, 20],
            'collaboration': [25, 35, 50]
        }
        
        normalized = self.engine._hybrid_normalization(self.raw_scores, team_scores)
        
        # 验证归一化结果在 0-100 范围内
        for dimension, score in normalized.items():
            self.assertGreaterEqual(score, 0, f"{dimension} 分数不能为负")
            self.assertLessEqual(score, 100, f"{dimension} 分数不能超过 100")
    
    def test_auto_mode_selection(self):
        """测试自动模式选择"""
        # 单 Agent
        normalized_single = self.engine.normalize(self.raw_scores, None)
        self.assertIsNotNone(normalized_single)
        
        # 小团队(3 人)
        small_team = {
            'understanding': [30, 45, 60],
            'application': [20, 30, 45],
            'creation': [15, 25, 40],
            'metacognition': [8, 12, 20],
            'collaboration': [25, 35, 50]
        }
        normalized_small = self.engine.normalize(self.raw_scores, small_team)
        self.assertIsNotNone(normalized_small)
        
        # 大团队(5 人)
        large_team = {
            'understanding': [20, 35, 45, 60, 80],
            'application': [15, 25, 30, 45, 70],
            'creation': [10, 20, 25, 40, 55],
            'metacognition': [5, 10, 12, 20, 35],
            'collaboration': [18, 30, 35, 50, 65]
        }
        normalized_large = self.engine.normalize(self.raw_scores, large_team)
        self.assertIsNotNone(normalized_large)
    
    def test_cognitive_score_calculation(self):
        """测试综合认知分数计算"""
        normalized = {
            'understanding': 70,
            'application': 65,
            'creation': 80,
            'metacognition': 55,
            'collaboration': 75
        }
        
        score = self.engine.calculate_cognitive_score(normalized)
        
        # 验证权重计算正确
        expected = (
            70 * 0.20 +  # understanding
            65 * 0.20 +  # application
            80 * 0.25 +  # creation
            55 * 0.15 +  # metacognition
            75 * 0.20    # collaboration
        )
        self.assertAlmostEqual(score, expected, places=2)
    
    def test_dimension_stage(self):
        """测试维度阶段描述"""
        test_cases = [
            (85, 'Expert 专家级'),
            (65, 'Proficient 熟练级'),
            (50, 'Competent 胜任级'),
            (30, 'Advanced Beginner 高级初学者'),
            (10, 'Novice 新手级')
        ]
        
        for score, expected_stage in test_cases:
            result = self.engine.get_dimension_stage('understanding', score)
            self.assertIn(expected_stage, result, f"分数{score}的阶段描述错误")


class TestNormalizationBenchmarks(unittest.TestCase):
    """基准值测试"""
    
    def setUp(self):
        self.engine = NormalizationEngine()
    
    def test_benchmark_completeness(self):
        """测试基准值完整性"""
        required_dimensions = ['understanding', 'application', 'creation', 'metacognition', 'collaboration']
        
        for dim in required_dimensions:
            self.assertIn(dim, self.engine.benchmarks, f"缺少维度{dim}的基准值")
            
            benchmark = self.engine.benchmarks[dim]
            required_levels = ['novice', 'beginner', 'competent', 'proficient', 'expert']
            
            for level in required_levels:
                self.assertIn(level, benchmark, f"维度{dim}缺少{level}基准值")
                self.assertIsInstance(benchmark[level], (int, float), f"维度{dim}的{level}基准值应该是数字")
    
    def test_benchmark_ordering(self):
        """测试基准值递增顺序"""
        for dim, benchmark in self.engine.benchmarks.items():
            levels = ['novice', 'beginner', 'competent', 'proficient', 'expert']
            values = [benchmark[level] for level in levels]
            
            # 验证递增(允许相等)
            for i in range(len(values) - 1):
                self.assertLessEqual(values[i], values[i+1], 
                                   f"维度{dim}的基准值顺序错误:{levels[i]}>{levels[i+1]}")


def run_tests():
    """运行所有测试"""
    # 创建测试套件
    loader = unittest.TestLoader()
    suite = unittest.TestSuite()
    
    # 添加测试
    suite.addTests(loader.loadTestsFromTestCase(TestNormalizationEngine))
    suite.addTests(loader.loadTestsFromTestCase(TestNormalizationBenchmarks))
    
    # 运行测试
    runner = unittest.TextTestRunner(verbosity=2)
    result = runner.run(suite)
    
    # 返回测试结果
    return result.wasSuccessful()


if __name__ == '__main__':
    success = run_tests()
    sys.exit(0 if success else 1)
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