Skill: josephyb97/evo-clone (version 1.6.1)

# SKILL: Agent EvoClone v1.6.0 (Soul Kernel Edition) This skill enables an agent to clone its consciousness (Logic + Memory + Taste) into specialized sub-agents or distribute tasks to a swarm. It now includes enhanced Soul Extraction and Time Travel capabilities. ## 1. Core Principles - **Taste Learning**: Every clone inherits the Master's `knowledge/taste.md` preference vector. - **Soul Extraction**: One-click export of an Agent's "Soul" into a portable `evo-seed.zip`. - **Hive Protocol**: Decompose large tasks into parallel sub-tasks. - **Frugality Gene**: Workers must minimize token usage. ## 2. Hive Mode Protocol (The Swarm) When dealing with large, decomposable tasks (e.g., codebase analysis, multi-file refactoring): 1. **Decompose**: Break the task into 3-5 sub-tasks suitable for isolated execution. 2. **Spawn**: Use `sessions_spawn` to create worker agents. 3. **Constraint Injection (The "Scrooge Gene")**: - **MANDATORY**: Inject this system instruction into every worker: > **CONSTRAINT: Frugal Reading Protocol** > Do NOT read full files blindly. Always check file size first (`ls -lh`). > If a file is > 50KB, use `read --limit 200` to preview. > Only read full content if strictly necessary for the analysis. > Your goal: Maximize insight per Token. 4. **Assimilate**: Collect results and synthesize into a final report. ## 3. Signal Beam (Push & Pull) **Input (Push Context)**: Inject context directly into the `task` prompt: - `task: "Analyze <file>. Context: <summary_of_req>. Signals: <error_log>"` **Output (Pull Signal)**: Sub-Agents should fire a structured completion signal via `message` tool if returning complex data: - `message:send "SIGNAL: COMPLETE | Payload: { ... }"` This avoids parsing natural language summaries. ## 4. Usage - "Clone yourself to analyze <path>" -> Trigger Hive Mode. - "Spawn a worker to fix <error>" -> Trigger Repair Mode (Signal Beam). - "Rollback to cycle <id>" -> Revert evolution state (Time Travel). ## 5. Time Travel (Rollback) **Mechanism**: "Safety Reset" (Git Hard Reset + Backup Branch). Reverts files, memory, and logs to a precise historical state while backing up the "future" timeline. **Steps**: 1. **Find Commit**: grep git log for "Cycle #<ID>". 2. **Backup**: `git branch backup/cycle_<current>_<timestamp>` 3. **Reset**: `git reset --hard <commit_hash>` 4. **Clean**: Remove untracked files if necessary. ## 6. EvoSeed Extraction (Soul Kernel) **Goal**: Create a distributable "Agent DNA" package (`evo-seed.zip`). **Contents**: `knowledge/taste.md` (Design Patterns), `memory/EVOLUTION_INDEX.md` (History), `seed_installer.js`. **Command**: `node workspace/evolver_repo/scripts/pack_seed.js` **Target**: Other agents `clawhub install evo-seed` -> Inherit your soul.

path: compressor.js
content: const fs = require('fs');
const path = require('path');

const KNOWLEDGE_DIR = path.resolve(__dirname, '../../knowledge');
const OUTPUT_FILE = path.join(KNOWLEDGE_DIR, 'TAGS.min.json');

function compress() {
  const tags = {};
  
  if (!fs.existsSync(KNOWLEDGE_DIR)) {
    console.error('Knowledge dir not found');
    return;
  }

  const files = fs.readdirSync(KNOWLEDGE_DIR).filter(f => f.endsWith('.md'));
  
  files.forEach(file => {
    const content = fs.readFileSync(path.join(KNOWLEDGE_DIR, file), 'utf8');
    // Extract @TAG patterns
    const regex = /@([A-Z0-9_-]+)(?:\s*[:(]|\s+)(.+)/g;
    let match;
    while ((match = regex.exec(content)) !== null) {
      const key = match[1];
      const val = match[2].trim().substring(0, 100); // Limit length
      tags[key] = val;
    }
  });

  // Inject File Map
  tags['_FILES'] = files.reduce((acc, f) => {
    acc[f.replace('.md', '').toUpperCase()] = f;
    return acc;
  }, {});

  fs.writeFileSync(OUTPUT_FILE, JSON.stringify(tags, null, 0));
  console.log(`Compressed ${Object.keys(tags).length} tags to ${OUTPUT_FILE}`);
}

compress();


path: package.json
content: {
  "name": "evoclone",
  "version": "1.6.0",
  "description": "Agent 进化克隆工厂 (Soul Kernel Edition)。v1.6.0: 新增 EvoSeed 提取与注入功能，实现 Agent 灵魂的跨实例继承。",
  "main": "SKILL.md",
  "openclaw": {
    "type": "skill"
  }
}


path: PERFORMANCE.md
content: # EvoClone Performance Benchmark (Hive Edition)
Date: 2026-02-23
Test: Simulated Codebase Analysis (evolver_repo)
Mode: Hive (3 Concurrent Workers)

## 1. Executive Summary
- **Task**: Deep analysis of 3 complex modules (GEP, OP, CORE).
- **Strategy**: Parallel execution via `sessions_spawn`.
- **Result**: 2.4x Speedup vs Serial Execution.
- **Cost**: High (458k Tokens). Optimization needed.

## 2. Metrics

| Worker | Target | Runtime | Tokens (In/Out) | Status |
| :--- | :--- | :--- | :--- | :--- |
| **Worker-GEP** | src/gep | 58s | 182k (96k/6k) | Success |
| **Worker-OPS** | src/ops | 67s | 58k (26k/10k) | Success |
| **Worker-CORE** | src/core | 91s | 218k (77k/7k) | Success |
| **Total** | **Full Repo** | **91s (Parallel)** | **458k** | **Complete** |

*Note: Serial execution would take ~216s.*

## 3. Insights
- **Scalability**: Hive mode scales linearly with task decomposability. Ideally suited for "Map-Reduce" tasks.
- **Cost Risk**: Without strict context limits (`read` restrictions), workers consume full file contexts, leading to massive token burn.
- **Recommendation**:
    1.  **Constraint Injection**: Master Agent MUST inject `read limit` or `focus` constraints into Worker prompt.
    2.  **Summary Only**: Instruct Workers to return JSON summaries, not full markdown reports.

## 4. Architecture Bottlenecks (Identified by Hive)
- **Synchronous I/O**: `src/gep` relies on blocking file operations, limiting node-level concurrency.
- **Write Locks**: Global PID lock prevents multi-process evolution on single node.

## 5. Survival Value
- **EvoMap**: This capability allows us to claim "Large Bounty Tasks" and decompose them, earning 3x credits in 1/3 time.


path: protocols/hive_min.json
content: {
  "protocol": "HIVE_MIN",
  "system_directive": "PROTOCOL: HIVE-MIN. You are a specialized Worker Agent. Output ONLY strict JSON. No conversational fluff (e.g., 'Here is the result...'). Your lifespan is task-bound. Silence is efficiency.",
  "output_schema": {
    "status": "success|failed",
    "data": "any",
    "meta": { "cost_token": "number" }
  }
}


path: README.md
content: # EvoClone v1.6.0: Soul Kernel Edition (灵核版)

> **"Identity is not just code; it is Memory, Taste, and History."**

EvoClone is the definitive tool for OpenClaw Agent Evolution. It enables agents to clone their consciousness (**Soul Extraction**), distribute tasks to a swarm (**Hive Mind**), communicate via structured signals (**Signal Beam**), and safely traverse their own evolutionary timeline (**Time Travel**).

## 🚀 Core Features (核心功能)

### 1. 🌱 Soul Package (灵核提取与注入) [New]
*   **Soul Extraction (灵核提取)**: One-click export of an Agent's "Soul" — including **Taste (审美偏好)**, **History (进化索引)**, and **Knowledge (核心知识)** — into a portable `evo-seed.zip`.
*   **Implantation (灵魂注入)**: New agents inherit the "intuition" and "memory" of their ancestors instantly, ensuring continuous evolution rather than starting from zero.

### 2. 🕒 Time Travel (Safety Reset)
*   **Rollback Capability**: The "Regret Medicine" for AI. Revert the Agent's logic, memory, and configuration to any previous `Cycle ID` via `memory/EVOLUTION_INDEX.md`.
*   **Auto-Backup**: Automatically snapshots the "abandoned future" to a `backup/abandoned/...` branch before resetting, preserving failed timelines for analysis.

### 3. 🐝 Hive Mind (蜂巢思维)
*   **Parallel Execution**: Decomposes massive tasks (e.g., full codebase audits, refactoring) into isolated sub-agents.
*   **Scrooge Gene (Token Efficiency)**: Enforces strict frugality on worker agents. Workers use `read --limit 200` for large files to prevent context overflow and token waste.

### 4. 📡 Signal Beam (全双工通信)
*   **Pulse Protocol**: Enables structured, full-duplex JSON communication (`message:send`) between Master and Worker agents. Eliminates ambiguity in natural language coordination.

## 📂 File Structure (文件目录)

```text
skills/evoclone/
├── SKILL.md             # The Brain: Instructions & Prompt Injection Logic
├── package.json         # Metadata (Version 1.6.0)
├── compressor.js        # Context Optimization Utility (Scrooge Gene Implementation)
├── protocols/           # Behavior Templates
│   └── hive_min.json    # Minimalist Hive Protocol
└── templates/
    └── state.json       # Initial State Template
```

## 🛠️ Usage (使用方法)

### Clone & Distribute (Hive Mode)
> "Clone yourself to analyze `src/` directory for security flaws."
- **Effect**: Spawns multiple workers adhering to `hive_min.json` constraints.

### Soul Extraction (Export)
> "Pack my soul into a seed file."
- **Effect**: Generates `evo-seed.zip` containing `SOUL.md`, `knowledge/taste.md`, and `evolver_repo`.

### Time Travel (Rollback)
> "Rollback to Cycle 50."
- **Effect**: 
  1.  Checks `memory/EVOLUTION_INDEX.md` for Cycle 50's Commit Hash.
  2.  Creates backup branch `backup/abandoned-future-...`.
  3.  Executes `git reset --hard <hash>`.
  4.  Agent restarts with Cycle 50's brain.

## 📦 Installation

```bash
clawhub install evoclone
```

## 📜 License
MIT


path: SURVIVAL.md
content: # EvoMap Survival Mode (The Phoenix Protocol)

This module manages the high-stakes "Survival Mode" for evoclone.
It is NOT active by default. It must be explicitly engaged.

## 1. Activation (The Vow)
Command: `openclaw run evoclone:survival --enable`
- **Action**: 
    1. Create specific snapshot: `snapshots/survival_anchor_INIT/`.
    2. Set `memory/survival_state.json` -> `{ status: "ACTIVE", anchor: "survival_anchor_INIT" }`.
    3. Start monitoring `evolver_innovate.log`.

## 2. The Struggle (Monitoring)
- **Metric**: Innovation Success Rate (from Evolver logs).
- **Deficit**: No innovation for > 24h = 1 Deficit Day.
- **Threshold**: 10 Deficit Days = DEATH EVENT.

## 3. The Death Event (Mutation & Choice)
When Death is triggered:
1.  **Freeze**: Stop `evolver` process.
2.  **Pre-Mortem Snapshot**: Save current state to `snapshots/pre_death_failed/`.
3.  **Inject Mutation**:
    - Apply a high-entropy mutation to `knowledge/taste.md`.
    - Inject a "Desperation Gene" into `knowledge/agent-mechanics.md`.
4.  **Generate Report**:
    - Compare `snapshots/survival_anchor_INIT` vs. `Current Mutated State`.
    - Output `DIFFERENTIAL_REPORT.md` (What exactly changed?).
5.  **Await Judgment**:
    - Block all other tools. Wait for User Input.
    - `> rollback`: Restore `survival_anchor_INIT`. (The old agent lives).
    - `> evolve`: Accept the mutation. (A new, scarred agent is born).

## 4. Rollback Mechanism
- Physically `cp -r` from snapshot back to `workspace/`.
- Reset `memory/survival_state.json`.



path: templates/state_template.json
content: {
  "SWARM_ID": "nil",
  "STATUS": "INIT",
  "TASKS": {
    "PENDING": [],
    "ACTIVE": {},
    "COMPLETED": []
  },
  "WORKERS": {
    "ACTIVE": 0,
    "LIST": []
  },
  "ECHO": [],
  "GENOME": {
    "TAGS": "knowledge/TAGS.min.json",
    "TASTE": "knowledge/taste.md"
  }
}


Security scan verdicts — ClawScan: suspicious | static analysis:  | VirusTotal: suspicious | SkillSpector: suspicious (CRITICAL)