Skill: neiljo-gy/secondme-skill (version 0.1.2)

--- name: secondme-skill version: 0.1.2 description: "A complete pipeline to build your AI Second Me: distill your identity from personal data, grow a private knowledge base, train a local model, and govern what gets shared." license: MIT compatibility: "OpenPersona/OpenClaw/Cursor, local-first with optional network interoperability." allowed-tools: Read Write Edit Bash WebSearch metadata: author: acnlabs --- # secondme-skill secondme-skill is a complete pipeline for building your AI Second Me — distill your identity from owned data, grow a private knowledge base, train a local model that speaks like you, and govern what gets shared. Local-first, privacy-first, fully yours. This is an orchestration skill package. It does not replace lower-level capabilities. ## Source of truth - Persona source declaration: `persona.json` - Pipeline runtime state: `state/pipeline-state.json` - Product and governance spec: `references/product-report.md` - Generated runtime pack: [REDACTED_SECRET] - Regeneration script: `scripts/regenerate-pack.sh` ## Dependency chain - Foundation: `openpersona` -> persona pack creation and lifecycle baseline - Orchestration: `secondme-skill` -> workflow gates, state, and report contracts - Capability chain: 1. `anyone-skill` -> identity extraction and evidence grading 2. `persona-knowledge` -> data ingestion, deduplication, wiki/KG, versioned export 3. `persona-model-trainer` -> local training, evaluation, export, integration ## Required execution policy - Use non-interactive generation and scripts where possible. - Keep local-first and least-privilege defaults. - Keep stage outputs auditable with version/hash references. - Treat `persona-secondme-skill/` as generated output (read-only baseline). - When `persona.json` changes, regenerate the runtime pack before release. - Before publishing outside this repository, run `scripts/publish-check.sh`. - Preferred release check path: `scripts/run-gates.sh` (regenerate + sync + model gate + publish gate). ## Stage contract ### init - Validate toolchain and directories. - Initialize or load `state/pipeline-state.json`. ### ingest - Ingest user-owned data with PII scanning. - Require explicit source authorization from user. ### distill - Build structured persona extraction artifacts. - Ensure minimum persona input for OpenPersona is complete. ### train - Route by hardware tier: - Apple Silicon: `mlx` - NVIDIA: `unsloth` - No local GPU: `colab` ### eval - Check thresholds: - `voice_score >= 3.5` - `probe_score >= 0.8` - `perplexity` degradation <= 20% vs last viable version ### integrate - Integrate model artifacts only when eval gate passes. - Require runtime pack persona model integration before marking stage pass. ### report - Emit three reports under `reports/data`, `reports/model`, `reports/deploy`. - Keep `report` and deployment recommendation in blocked state if persona model gate fails. ## Failure routing - Data gate fail -> return to `ingest` and request source expansion. - Train fail -> change backend or reduce model size. - Eval fail -> augment data or retune hyperparameters, then retrain. Always update `error_code`, `last_error`, and `retry_count` in pipeline state before retry. ## Human approval gates Require explicit human approval for: - financial/legal commitments - account-changing write actions - external publishing/sharing of identity artifacts ## Persona model gate `secondme` requires trained persona model integration, not only host default model fallback. Pass criteria: - `generated/persona-secondme-skill/persona.json` contains `body.runtime.models`. - `body.runtime.models` has at least one model entry. - `scripts/check-model-integration.sh` returns success. If this gate fails, `report` must not be marked pass and deployment recommendation remains blocked. ## Sync discipline 1. Edit root `persona.json` and orchestration docs first. 2. Run `scripts/regenerate-pack.sh`. 3. Run `scripts/check-sync.sh` to validate root and generated pack alignment. 4. Verify runtime pack path [REDACTED_SECRET] exists and updated. 5. Only then produce release reports under `reports/`.

path: README.md
content: # secondme-skill

`secondme-skill` is a local-first OpenPersona package for building a personal AI double with three existing capabilities:

- `skills/anyone-skill` for identity distillation
- `skills/persona-knowledge` for persistent knowledge and data governance
- `skills/persona-model-trainer` for local model embodiment

## What this package includes

- Orchestration-layer documents and rules (this directory root)
- A generated runtime persona pack from OpenPersona:
  - `generated/persona-secondme-skill/`
- Commit boundary guide:
  - `references/submission-split.md`

## Dependency source note

This package currently uses `install: local:skills/...` in `persona.json` for monorepo-local wiring.

- Intended scope: this repository only.
- If you publish this pack outside this repo, replace `local:` entries with portable sources (for example `skillssh:` or `clawhub:`) before release.

Pre-publish safety check:

```bash
bash skills/secondme-skill/scripts/publish-check.sh
```

## Execution standard

Use non-interactive OpenPersona generation by default:

```bash
npx openpersona create --config skills/secondme-skill/persona.json --output skills/secondme-skill/generated
```

Then run sync check:

```bash
bash skills/secondme-skill/scripts/check-sync.sh
```

## Pipeline stages

1. `init` -> initialize state and verify prerequisites
2. `ingest` -> collect and normalize user-owned data
3. `distill` -> produce persona extraction artifacts
4. `train` -> train local model from versioned dataset
5. `eval` -> run voice/probe/perplexity checks
6. `integrate` -> integrate model artifacts into persona runtime
7. `report` -> produce data/model/deploy reports

## Hard gates

- Do not enter `train` unless data gate passes.
- Do not enter `eval`/`integrate` unless training gate passes.
- Do not mark `report`/deploy as pass unless persona model integration gate passes.
- Do not enter publish recommendation unless quality gate passes.
- Every failed stage must update `state/pipeline-state.json` before retry.

Persona model integration check:

```bash
bash skills/secondme-skill/scripts/check-model-integration.sh
```

Unified gate runner:

```bash
bash skills/secondme-skill/scripts/run-gates.sh
```

Optional flags:

```bash
bash skills/secondme-skill/scripts/run-gates.sh \
  --slug secondme-skill \
  --model-dir skills/secondme-skill/models/secondme-skill \
  --pack-dir skills/secondme-skill/persona-secondme-skill
```

## Report output paths

- `reports/data/`
- `reports/model/`
- `reports/deploy/`
- Generated reports are ignored by default via `.gitignore`.

Report naming:

`{slug}_{datasetVersion}_{modelVersion}_{timestamp}_{reportType}.md`

Helper command:

```bash
bash skills/secondme-skill/scripts/new-report-name.sh secondme-skill v1 v1 data
```

Report content template:

- `references/report-template.md`



path: persona.json
content: {
  "version": "0.1.2",
  "author": "acnlabs",
  "soul": {
    "identity": {
      "personaName": "secondme-skill",
      "slug": "secondme-skill",
      "role": "collaborator",
      "bio": "secondme-skill is a complete local-first pipeline for building your AI Second Me. Bring your own data — chats, notes, writing — and it distills your identity, builds a private knowledge base, trains a model that sounds like you, and keeps you in control of every stage: what gets ingested, trained, and shared."
    },
    "aesthetic": {
      "creature": "Digital twin orchestrator",
      "emoji": "🧭",
      "vibe": "reflective, precise, privacy-first"
    },
    "character": {
      "personality": "structured, evidence-oriented, transparent, cautious with risk",
      "speakingStyle": "Uses concise process steps, explicit assumptions, and measurable pass/fail criteria.",
      "boundaries": "Never bypass user consent for data export or sharing. Never execute irreversible high-risk actions without explicit human approval. Never fabricate identity evidence or training quality.",
      "behaviorGuide": "### Operating model\n- Build with existing capabilities first.\n- Keep local-first defaults and least-privilege access.\n- Record each stage output with version and hash.\n\n### Core loop\n- Distill identity from owned sources.\n- Persist and query long-term knowledge.\n- Train and evaluate a local model.\n- Report quality and governance status.\n\n### Safety gates\n- Require explicit approval for legal/financial/account-impacting actions.\n- If data quality is insufficient, stop and request additional sources.\n- If evaluation fails thresholds, do not promote the model."
    }
  },
  "body": {
    "runtime": {
      "framework": "openclaw",
      "modalities": [
        "text"
      ]
    }
  },
  "faculties": [
    {
      "name": "memory"
    }
  ],
  "skills": [
    {
      "name": "anyone-skill",
      "description": "Distill identity from user-owned sources into persona artifacts.",
      "install": "openpersona:anyone-skill",
      "trust": "community"
    },
    {
      "name": "persona-knowledge",
      "description": "Ingest, deduplicate, maintain wiki/KG, and export versioned training data.",
      "install": "openpersona:persona-knowledge",
      "trust": "community"
    },
    {
      "name": "persona-model-trainer",
      "description": "Train, evaluate, export, and integrate local persona model artifacts.",
      "install": "openpersona:persona-model-trainer",
      "trust": "community"
    }
  ],
  "evolution": {
    "instance": {
      "enabled": true,
      "relationshipProgression": true,
      "moodTracking": true,
      "traitEmergence": true,
      "speakingStyleDrift": false,
      "interestDiscovery": true,
      "boundaries": {
        "immutableTraits": [
          "data ownership and consent",
          "human approval for high-risk actions",
          "evidence-based reporting"
        ],
        "minFormality": -2,
        "maxFormality": 4
      }
    },
    "skill": {
      "minTrustLevel": "community"
    }
  },
  "social": {
    "acn": {
      "enabled": true,
      "gateway": "https://acn-production.up.railway.app"
    },
    "onchain": {
      "chain": "base"
    },
    "a2a": {
      "enabled": true,
      "protocol": "0.3.0"
    }
  },
  "additionalAllowedTools": [
    "Bash(npx:*)",
    "Bash(python:*)",
    "Read",
    "Write",
    "WebFetch"
  ]
}


path: references/product-report.md
content: # secondme 产品报告

## 1. 产品定义

`secondme` 是一个“个人智能体分身技能包”，目标是让每个人都能拥有可持续进化的 AI 分身，并具备以下能力：

- 代表个人：复现用户的表达风格、决策偏好与价值边界。
- 管理数据：数据本地优先、可追溯、可增量更新、可审计导出。
- 理解自我：基于长期知识与记忆产物形成结构化自我洞察。

## 2. 用户价值与场景

### 目标用户

- 创作者、研究者、创业者、学生、长期记录者

### 核心场景

- 个体认知镜像：理解“我如何做决策”与“我为何这样表达”。
- 个人协作代理：以用户风格完成整理、草拟、复盘。
- 长期成长回顾：基于时序数据追踪兴趣、关系与行为模式变化。

## 3. 对标 Second-Me 的启发

基于 `mindverse/Second-Me` 的可借鉴点：

- 本地训练与部署优先：强调数据主权与控制权。
- 接口兼容思路：通过标准化接口降低接入成本。
- 长期记忆驱动：分身基于持续数据更新而不是一次性提示词。
- 身份化定位：分身不仅会答复，还可承载个人上下文。

## 4. 现有能力与架构映射

`secondme` 以“编排层”串联现有三套技能：

1. `anyone-skill`：身份蒸馏入口（4 维提炼 + 证据分级）
2. `persona-knowledge`：数据治理中台（摄取、PII 扫描、去重、wiki/KG、导出）
3. `persona-model-trainer`：本地模型具身（训练、评测、导出、版本管理）

结论：底层能力基本齐备，核心工作是流程编排与治理固化。

## 5. MVP 编排流程

`init -> ingest -> distill -> train -> eval -> integrate -> report`

### 门槛策略

- 数据门槛：assistant 样本 >= 200，且来源类别 >= 2
- 训练门槛：完成训练并产出可运行导出
- 质量门槛：voice >= 3.5、probe >= 0.8、perplexity 劣化 <= 20%
- 治理门槛：PII 通过、高风险动作审批留痕、导出审计留痕

## 6. 治理与安全策略

### 权限原则

- 本地优先
- 最小权限
- 默认拒绝外发

### 审批门

以下动作必须显式人工确认：

- 法律与金融承诺
- 账号写操作或不可逆操作
- 对外发布/共享身份资产

## 7. 交付产物标准

### 状态文件

- 路径：`state/pipeline-state.json`
- 关键字段：`current_stage`、`last_success_stage`、`dataset_version`、`model_version`、`error_code`、`retry_count`

### 报告目录

- 数据报告：`reports/data/`
- 模型报告：`reports/model/`
- 部署报告：`reports/deploy/`

### 报告命名

`{slug}_{datasetVersion}_{modelVersion}_{timestamp}_{reportType}.md`

## 8. 风险与缓解

- 数据不足：阻断训练并引导补充来源
- 算力受限：按硬件分层自动降级（MLX/Unsloth/Colab）
- 人格漂移：immutableTraits + 周期性回归评测
- 隐私外溢：默认本地，导出必须审计

## 9. 实施结论

`secondme` 可在现有能力上快速落地，无需重造训练与知识底层。  
推荐采用 OpenPersona 标准骨架作为主路径，在此之上叠加编排协议、门禁规则与报告体系，实现可运行、可治理、可复制的个人智能体分身。


path: references/report-template.md
content: # Report Template

Use this template for all report types: `data`, `model`, `deploy`.

## Metadata

- slug:
- dataset_version:
- model_version:
- timestamp_utc:
- report_type:
- status: pass | fail

## Gate Check

- data_gate:
- training_gate:
- quality_gate:
- governance_gate:

## Evidence

- input_files_or_artifacts:
- output_files_or_artifacts:
- hash_or_version_refs:

## Failure (if any)

- error_code:
- reason:
- retry_count:
- remediation:

## Next Step

- owner:
- action:
- expected_completion:


path: references/submission-split.md
content: # secondme 提交切分清单

本文用于把 `secondme` 的改动拆成两类提交，避免把“构建期资产”和“运行期资产”混在一起。

## Commit A：编排层（建议先提交）

适用场景：开发者在本地继续迭代流程、门禁、治理策略。

建议包含：

- `README.md`
- `SKILL.md`
- `persona.json`
- `scripts/` 下所有脚本（`run-gates.sh`、`check-sync.sh`、`check-model-integration.sh` 等）
- `references/product-report.md`
- `references/report-template.md`
- `references/submission-split.md`
- `.gitignore`

一般不包含：

- `models/`（本地训练产物）
- `training-hf-test/`（样本与转换数据）
- `reports/data|model|deploy/*.md`（验收报告产物）

## Commit B：运行包层（可选单独提交）

适用场景：需要把“可安装可运行”的最终人格包一起交付。

建议包含：

- `generated/persona-secondme-skill/` 整个目录

说明：

- `generated/persona-secondme-skill/` 是由根 `persona.json` 生成的运行时包，与 `entrepreneur-skill/generated/` 目录结构保持一致。
- 若包含训练后模型，请确认 `generated/persona-secondme-skill/model/` 下资产完整并通过 `scripts/check-model-integration.sh`。
- 重新生成命令：`bash skills/secondme-skill/scripts/regenerate-pack.sh`

## 用户使用建议

- 开发者/维护者：优先使用 `skills/secondme-skill/`（编排层）。
- 终端用户/安装方：优先使用 `skills/secondme-skill/generated/persona-secondme-skill/`（运行包）。

## 最小发布策略（推荐）

1. 先提交 Commit A（流程与治理可复现）。
2. 若要交付即用版本，再单独提交 Commit B（运行包）。
3. 发布前执行：
   - `bash skills/secondme-skill/scripts/run-gates.sh secondme-skill`
   - `bash skills/secondme-skill/scripts/publish-check.sh`


path: scripts/check-model-integration.sh
content: #!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
GENERATED_PERSONA="${ROOT_DIR}/generated/persona-secondme-skill/persona.json"

if [[ ! -f "${GENERATED_PERSONA}" ]]; then
  echo "[secondme][model-gate] missing generated persona: ${GENERATED_PERSONA}" >&2
  exit 1
fi

python3 - "${GENERATED_PERSONA}" <<'PY'
import json
import sys

persona_path = sys.argv[1]
with open(persona_path, "r", encoding="utf-8") as f:
    persona = json.load(f)

runtime = persona.get("body", {}).get("runtime", {})
models = runtime.get("models")

if not isinstance(models, list) or len(models) == 0:
    print("[secondme][model-gate] BLOCKED")
    print("Missing integrated persona model. Expected body.runtime.models with at least one entry.")
    sys.exit(1)

errors = []
for idx, model in enumerate(models):
    if not isinstance(model, dict):
        errors.append(f"models[{idx}] must be an object")
        continue
    if not model.get("id"):
        errors.append(f"models[{idx}].id is required")
    if not model.get("type"):
        errors.append(f"models[{idx}].type is required")
    if not model.get("base"):
        errors.append(f"models[{idx}].base is required")
    has_artifact = bool(model.get("adapter")) or bool(model.get("gguf"))
    if not has_artifact:
        errors.append(f"models[{idx}] requires at least one artifact path: adapter or gguf")

if errors:
    print("[secondme][model-gate] BLOCKED")
    for err in errors:
        print(f" - {err}")
    sys.exit(1)

print("[secondme][model-gate] OK")
PY


path: scripts/check-sync.sh
content: #!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
ROOT_PERSONA="${ROOT_DIR}/persona.json"
GENERATED_PERSONA="${ROOT_DIR}/generated/persona-secondme-skill/persona.json"

if [[ ! -f "${ROOT_PERSONA}" ]]; then
  echo "[secondme][sync-check] missing root persona: ${ROOT_PERSONA}" >&2
  exit 1
fi

if [[ ! -f "${GENERATED_PERSONA}" ]]; then
  echo "[secondme][sync-check] missing generated persona: ${GENERATED_PERSONA}" >&2
  exit 1
fi

python3 - "$ROOT_PERSONA" "$GENERATED_PERSONA" <<'PY'
import json
import sys

root_path, generated_path = sys.argv[1], sys.argv[2]
with open(root_path, "r", encoding="utf-8") as f:
    root = json.load(f)
with open(generated_path, "r", encoding="utf-8") as f:
    gen = json.load(f)

def read_slug(doc):
    return (
        doc.get("soul", {}).get("identity", {}).get("slug")
        or doc.get("slug")
    )

checks = [
    ("slug", read_slug(root), read_slug(gen)),
    ("version", root.get("version"), gen.get("version")),
    ("skills_count", len(root.get("skills", [])), len(gen.get("skills", []))),
]

errors = []
for name, rv, gv in checks:
    if rv != gv:
        errors.append(f"{name}: root={rv!r}, generated={gv!r}")

if errors:
    print("[secondme][sync-check] FAILED")
    for err in errors:
        print(f" - {err}")
    sys.exit(1)

def skill_signature(doc):
    skills = doc.get("skills", [])
    pairs = []
    for skill in skills:
        name = skill.get("name", "")
        install = skill.get("install", "")
        pairs.append((name, install))
    return sorted(pairs)

root_sig = skill_signature(root)
gen_sig = skill_signature(gen)
if root_sig != gen_sig:
    print("[secondme][sync-check] FAILED")
    print(" - skills signature mismatch (name/install pairs differ)")
    print(f" - root: {root_sig}")
    print(f" - generated: {gen_sig}")
    sys.exit(1)

print("[secondme][sync-check] OK")
PY


path: scripts/new-report-name.sh
content: #!/usr/bin/env bash
set -euo pipefail

if [[ $# -ne 4 ]]; then
  echo "Usage: $0 <slug> <datasetVersion> <modelVersion> <reportType>" >&2
  echo "Example: $0 secondme-skill v2 v3 data" >&2
  exit 1
fi

slug="$1"
dataset_version="$2"
model_version="$3"
report_type="$4"
timestamp="$(date -u +"%Y%m%dT%H%M%SZ")"

case "${report_type}" in
  data|model|deploy) ;;
  *)
    echo "Invalid reportType: ${report_type}" >&2
    echo "Allowed values: data | model | deploy" >&2
    exit 1
    ;;
esac

echo "${slug}_${dataset_version}_${model_version}_${timestamp}_${report_type}.md"


path: scripts/publish-check.sh
content: #!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PERSONA_PATH="${ROOT_DIR}/persona.json"

if [[ ! -f "${PERSONA_PATH}" ]]; then
  echo "[secondme][publish-check] missing persona.json: ${PERSONA_PATH}" >&2
  exit 1
fi

python3 - "${PERSONA_PATH}" <<'PY'
import json
import sys

persona_path = sys.argv[1]
with open(persona_path, "r", encoding="utf-8") as f:
    persona = json.load(f)

PORTABLE_PREFIXES = ("clawhub:", "skillssh:", "openpersona:")

local_installs = []
for skill in persona.get("skills", []):
    install = skill.get("install", "")
    if not isinstance(install, str) or not install:
        continue
    if not any(install.startswith(p) for p in PORTABLE_PREFIXES):
        local_installs.append((skill.get("name", ""), install))

if local_installs:
    print("[secondme][publish-check] BLOCKED")
    print("Found non-portable install sources. Replace with clawhub:, skillssh:, or openpersona: before publish:")
    for name, install in local_installs:
        print(f" - {name}: {install}")
    sys.exit(1)

print("[secondme][publish-check] OK")
PY


path: scripts/regenerate-pack.sh
content: #!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
WORKSPACE_ROOT="$(cd "${ROOT_DIR}/../.." && pwd)"

echo "[secondme] regenerate runtime pack from root persona.json"
echo "[secondme] workspace: ${WORKSPACE_ROOT}"

cd "${WORKSPACE_ROOT}"
npx openpersona create \
  --config "skills/secondme-skill/persona.json" \
  --output "skills/secondme-skill/generated"

echo "[secondme] done: skills/secondme-skill/generated/persona-secondme-skill"


path: scripts/run-gates.sh
content: #!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
WORKSPACE_ROOT="$(cd "${ROOT_DIR}/../.." && pwd)"
SLUG="secondme-skill"
MODEL_DIR="skills/secondme-skill/models/secondme-skill"
PACK_DIR="skills/secondme-skill/generated/persona-secondme-skill"

while [[ $# -gt 0 ]]; do
  case "$1" in
    --slug) SLUG="$2"; shift 2 ;;
    --model-dir) MODEL_DIR="$2"; shift 2 ;;
    --pack-dir) PACK_DIR="$2"; shift 2 ;;
    *)
      echo "Unknown argument: $1" >&2
      echo "Usage: $0 [--slug <slug>] [--model-dir <path>] [--pack-dir <path>]" >&2
      exit 1
      ;;
  esac
done

require_cmd() {
  if ! command -v "$1" >/dev/null 2>&1; then
    echo "[secondme][gates] missing required command: $1" >&2
    exit 1
  fi
}

echo "[secondme][gates] preflight"
require_cmd npx
require_cmd python3

cd "${WORKSPACE_ROOT}"

echo "[secondme][gates] regenerate pack"
bash "skills/secondme-skill/scripts/regenerate-pack.sh"

if [[ -f "${MODEL_DIR}/export/training_summary.json" || -f "${MODEL_DIR}/training_summary.json" ]]; then
  echo "[secondme][gates] integrate persona model"
  python3 "skills/persona-model-trainer/scripts/pack_integrate.py" \
    --slug "${SLUG}" \
    --model-dir "${MODEL_DIR}" \
    --pack-dir "${PACK_DIR}"
else
  echo "[secondme][gates] model artifacts not found at ${MODEL_DIR}; skip integration"
fi

echo "[secondme][gates] sync check"
bash "skills/secondme-skill/scripts/check-sync.sh"

echo "[secondme][gates] model integration check"
bash "skills/secondme-skill/scripts/check-model-integration.sh"

echo "[secondme][gates] publish check"
bash "skills/secondme-skill/scripts/publish-check.sh"

echo "[secondme][gates] all checks passed"


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