skill-manager

Original🇨🇳 Chinese
Translated
1 scriptsChecked / no sensitive code detected

Provides unified configuration and log storage services for other skills, supporting data sharing and collaboration between skills

10installs
Added on

NPX Install

npx skill4agent add ewanyuan/cox-coding skill-manager

Tags

Translated version includes tags in frontmatter

SKILL.md Content (Chinese)

View Translation Comparison →

Skill Manager

Task Objectives

  • This Skill is used to: Provide unified configuration and log storage capabilities for other skills
  • Capabilities include:
    1. Store skill configuration information
    2. Store skill operation logs
    3. Query configurations and logs by skill name
    4. Manage stored data of all skills
  • Trigger condition: When actively referenced by other skills for data storage or retrieval

Usage Scenarios

Scenario 1: Skill stores its own configuration

When a skill needs to persist configuration information, call the Skill Manager for storage:
python
from skill_manager import SkillStorage

# 创建存储实例
storage = SkillStorage(data_path="/workspace/projects/skill-data.json")

# 存储配置
config = {
    "deploy_mode": "simple",
    "output_path": "/path/to/output.log",
    "timestamp": "2024-01-22 12:00:00"
}
storage.save_config("my-skill", config)

Scenario 2: Skill stores operation logs

When a skill needs to record operation logs, call the Skill Manager for storage:
python
from skill_manager import SkillStorage

storage = SkillStorage(data_path="/workspace/projects/skill-data.json")

logs = [
    {"time": "2024-01-22 12:00:00", "level": "INFO", "message": "开始执行"},
    {"time": "2024-01-22 12:05:00", "level": "INFO", "message": "执行完成"}
]
storage.save_logs("my-skill", logs)

Scenario 3: Skill reads data from other skills

When a skill needs to access configurations or logs of other skills:
python
from skill_manager import SkillStorage

storage = SkillStorage(data_path="/workspace/projects/skill-data.json")

# 读取其他技能的配置
other_config = storage.get_config("other-skill")

# 读取其他技能的日志
other_logs = storage.get_logs("other-skill")

Core Function Description

Functions Processable by Agents

  • API usage consultation: Explain how to use each function of the Skill Manager
  • Data format suggestions: Recommend appropriate data structures based on storage requirements
  • Data analysis: Analyze stored configurations and logs to identify patterns or issues
  • Storage management: View all stored skills and clean up expired data

Functions Implemented by Scripts

  • SkillStorage Class: Complete storage and retrieval API, see scripts/skill_manager.py
    • save_config(skill_name, config)
      : Store skill configuration
    • save_logs(skill_name, logs)
      : Store skill logs
    • save(skill_name, config, logs)
      : Store configuration and logs simultaneously
    • get_config(skill_name)
      : Retrieve skill configuration
    • get_logs(skill_name)
      : Retrieve skill logs
    • get_all()
      : Retrieve all skill data
    • list_skills()
      : List all stored skills
    • delete(skill_name)
      : Delete skill data

Data Storage Format

The Skill Manager uses a unified JSON format for data storage:
json
{
  "skill-name-1": {
    "config": {
      "key1": "value1",
      "key2": "value2"
    },
    "logs": [
      {"time": "2024-01-22 12:00:00", "message": "日志1"},
      {"time": "2024-01-22 12:05:00", "message": "日志2"}
    ],
    "last_updated": "2024-01-22 12:05:00"
  },
  "skill-name-2": {
    "config": {},
    "logs": [],
    "last_updated": "2024-01-22 12:10:00"
  }
}

Resource Index

  • Core Module: See scripts/skill_manager.py (Complete implementation of the SkillStorage class)
  • API Specification: See references/api_spec.md (Detailed API documentation and usage examples)

Notes

  • The Skill Manager is a service-type Skill that does not run actively and is called by other skills
  • It is recommended to use
    /workspace/projects/skill-data.json
    as the storage path for unified management
  • The data formats of configurations and logs are defined by the calling skills, and the Skill Manager only handles storage
  • Each storage operation updates the
    last_updated
    timestamp
  • Supports incremental updates and will not overwrite existing configurations or logs (unless explicitly specified to overwrite)

Best Practices

  • Use consistent naming conventions for skill names (e.g., lowercase letters with hyphens)
  • It is recommended to include necessary metadata in configuration data (such as creation time, version number, etc.)
  • It is recommended to include timestamps and log levels in log data
  • Regularly clean up unused skill data to prevent excessive storage file size
  • Read configurations when the skill starts and record logs during execution
  • Agents can assist in querying and analyzing stored data to identify skill collaboration opportunities

Usage Examples

Example 1: Skill integrates Skill Manager

python
import sys
sys.path.insert(0, '/workspace/projects/skill-manager/scripts')
from skill_manager import SkillStorage

# 初始化存储
storage = SkillStorage(data_path="/workspace/projects/skill-data.json")

# 存储技能配置
skill_config = {
    "mode": "production",
    "output_dir": "/workspace/output",
    "retry_count": 3
}
storage.save_config("my-awesome-skill", skill_config)

# 记录运行日志
execution_logs = [
    {"time": "2024-01-22 10:00:00", "level": "INFO", "message": "开始执行"},
    {"time": "2024-01-22 10:00:05", "level": "INFO", "message": "加载配置"},
    {"time": "2024-01-22 10:00:10", "level": "INFO", "message": "执行完成"}
]
storage.save_logs("my-awesome-skill", execution_logs)

Example 2: Query skill collaboration data

python
from skill_manager import SkillStorage

storage = SkillStorage(data_path="/workspace/projects/skill-data.json")

# 查看所有已存储的技能
all_skills = storage.list_skills()
print(f"已存储的技能: {all_skills}")

# 读取特定技能的配置
config = storage.get_config("dev-observability")
print(f"配置: {config}")

# 读取特定技能的日志
logs = storage.get_logs("dev-observability")
print(f"最近日志: {logs[-5:]}")

Example 3: Agent analyzes stored data

When an agent needs to analyze the collaboration of multiple skills:
  1. Read all skill data
  2. Analyze configuration associations between skills
  3. Identify shared dependencies or data
  4. Provide optimization suggestions
Agents can identify potential issues and optimization opportunities for skill combinations based on stored data.