chore(sleep): English-only across the engine, plugins, and docs

Remove every non-ASCII/CJK character for a professional open-source repo:
  - harvest.py: drop hardcoded Chinese feedback phrases; add an env-based
    extensibility hook (SKILLOPT_SLEEP_NEG_FEEDBACK / _POS_FEEDBACK) so any
    locale can be added without baking one in. Verified with a German example.
  - rollout.py / consolidate.py: English comments.
  - README.md section heading + anchor, CONTROLLABLE_DREAMING.md, plugin.json,
    marketplace.json (also fixed stale path skillopt-sleep-plugin ->
    plugins/claude-code), SKILL.md: English only.
  - Remove the internal WAKE_UP_SUMMARY.md note (not user-facing, not referenced).

Verified: zero CJK chars remain anywhere; 29 tests pass.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
This commit is contained in:
Yifan Yang
2026-06-08 14:31:52 +00:00
parent f9db99853b
commit dae974a5e3
9 changed files with 25 additions and 130 deletions
+2 -2
View File
@@ -7,7 +7,7 @@
---
## News 🔥🔥🔥
- **[2026-06-08]** 😴 **SkillOpt-Sleep is here — plugins for Claude Code, Codex, and Copilot.** Give your local coding agent a nightly *sleep cycle*: it reviews your past sessions offline, replays your recurring tasks, and consolidates validated long-term memory + skills behind a held-out gate —越用越好用. Validated on the public [gbrain-evals](https://github.com/garrytan/gbrain-evals) `skillopt-v1` benchmark with **real Claude and Codex** (deficient skills 0.00 → 1.00 on held-out, all 4 seeds). It's an **open-source tool decoupled from the paper code**. See [`plugins/`](plugins/) and the [SkillOpt-Sleep section](#-skillopt-sleep--越用越好用-the-deployment-time-companion) below.
- **[2026-06-08]** 😴 **SkillOpt-Sleep is here — plugins for Claude Code, Codex, and Copilot.** Give your local coding agent a nightly *sleep cycle*: it reviews your past sessions offline, replays your recurring tasks, and consolidates validated long-term memory + skills behind a held-out gate, so it gets better the more you use it. Validated on the public [gbrain-evals](https://github.com/garrytan/gbrain-evals) `skillopt-v1` benchmark with **real Claude and Codex** (deficient skills 0.00 → 1.00 on held-out, all 4 seeds). It's an **open-source tool decoupled from the paper code**. See [`plugins/`](plugins/) and the [SkillOpt-Sleep section](#-skillopt-sleep--the-deployment-time-companion) below.
- **[2026-06-03]** 🎉 **[gbrain](https://github.com/garrytan/gbrain), [gbrain-evals](https://github.com/garrytan/gbrain-evals/blob/main/docs/benchmarks/2026-06-03-skillopt.md), and [darwin-skill](https://github.com/alchaincyf/darwin-skill) have all integrated SkillOpt.**
- **[2026-06-02]** 🎉 **SkillOpt [v0.1.0](https://github.com/microsoft/SkillOpt/releases/tag/v0.1.0) is now available on [PyPI](https://pypi.org/project/skillopt/)!** Install with `pip install skillopt`. This initial release includes the full training loop (rollout → reflect → aggregate → select → update → evaluate), multi-backend support (OpenAI / Azure / Claude / Qwen / MiniMax), six built-in benchmarks, and WebUI dashboard.
@@ -51,7 +51,7 @@ https://github.com/user-attachments/assets/eb12d3bc-371c-467f-904d-91b61f339ed7
---
## 😴 SkillOpt-Sleep — 越用越好用, the deployment-time companion
## 😴 SkillOpt-Sleep — the deployment-time companion
SkillOpt (above) trains a skill offline on a benchmark. **SkillOpt-Sleep**
applies the same discipline to *your own daily usage*: it gives a local coding
+3 -2
View File
@@ -6,7 +6,7 @@ added in the four-stage refactor and how they map to the user's design.
## The mental model
> Sleep = an offline "脑补推演" (imagination rollout). Re-run the user's real
> Sleep = an offline imagination rollout. Re-run the user's real
> tasks (and dream-augmented variants) many times, look at what went well vs
> badly, distil durable rules, and keep only what survives a real-task check —
> unless the user opts out of that check.
@@ -68,7 +68,8 @@ Every rollout records its `tokens` and `latency_ms`.
`multi_objective_reward(w_acc, w_tokens, w_latency)` is a weighted reward so a
skill can be optimised to be **cheaper and faster**, not only more accurate
(cost terms normalised against a reference; default weights = accuracy-only, so
existing behaviour is unchanged). This turns "越用越好用" into "越用越准、越省、越快".
existing behaviour is unchanged). This turns "gets better the more you use it"
into "more accurate, cheaper, and faster the more you use it".
## 7. User preferences as a prior
-116
View File
@@ -1,116 +0,0 @@
# Wake-up summary — SkillOpt-Sleep (built overnight, 2026-06-07)
你睡觉时我离线把第一版做完了。下面是 TL;DR、怎么跑、关键决定、以及等你醒来要回答的问题。
## TL;DR — what exists now
A working **Claude Code plugin + Python engine** that gives your local Claude
agent a nightly **sleep cycle**: it reviews your past sessions offline, replays
recurring tasks on your own budget, and consolidates what it learns into
**validated** memory (`CLAUDE.md`) and skills (`SKILL.md`) — keeping a change
only if it improves a held-out replay score, and only after you adopt it.
It fuses the three things you gave me:
- **SkillOpt** → the gate. I reuse `skillopt.evaluation.gate.evaluate_gate` verbatim; nightly edits are bounded and validation-gated, exactly like the paper.
- **Claude Dreams** → the safety model. Offline consolidation over past sessions; the input is never mutated; output is staged and reviewed, then adopted or discarded.
- **Agent Sleep paper** → the framing. Nightly replay turns short-term episodes into long-term competence; cross-night `slow_memory` is the long-term store.
**It is proven to work** (deterministically, no API spend):
- researcher persona: held-out **0.33 → 1.00**
- programmer persona: held-out **0.32 → 1.00**
- the gate **rejects an injected harmful edit** in both runs
- 13 stdlib tests pass, including full cycle → stage → **adopt-with-backup**, and parsing of your **real** on-disk transcripts.
## Where it lives
- **Worktree:** `/home/azureuser/yifan/Code_workspace/my_repo/SkillOpt-sleep`
- **Branch:** `feat/claude-code-sleep-plugin` (2 commits, **NOT pushed**)
- Your fork's `main` was fast-forwarded locally to microsoft `upstream/main`
(it was 40 behind; now 0/0). `origin` (GitHub) untouched — nothing pushed.
```
skillopt/sleep/ # the engine (import-light, py>=3.10)
harvest.py mine.py replay.py backend.py consolidate.py
memory.py staging.py cycle.py state.py config.py types.py __main__.py
experiments/ personas.py run_experiment.py
skillopt-sleep-plugin/ # the Claude Code plugin
.claude-plugin/plugin.json commands/sleep.md skills/skillopt-sleep/SKILL.md
hooks/ scripts/sleep.sh scripts/install-cron.sh README.md
tests/test_sleep_engine.py # 13 tests, stdlib unittest
docs/superpowers/specs/2026-06-07-...-design.md # full design + open questions
docs/sleep/experiment_results.md # recorded proof output
```
## Try it yourself in 60 seconds (no API spend)
```bash
cd /home/azureuser/yifan/Code_workspace/my_repo/SkillOpt-sleep
# 1) deterministic proof it improves + gate blocks regressions
python3.12 -m skillopt.sleep.experiments.run_experiment --persona researcher --assert-improves
python3.12 -m skillopt.sleep.experiments.run_experiment --persona programmer --assert-improves
# 2) see it mine YOUR real recent sessions (read-only)
python3.12 -m skillopt.sleep harvest --project /home/azureuser/yifan/Code_workspace --scope invoked
# 3) full run on this project (mock backend, stages a proposal, touches nothing live)
python3.12 -m skillopt.sleep run --project "$(pwd)" --scope invoked --backend mock
python3.12 -m skillopt.sleep status --project "$(pwd)"
# 4) all tests
python3.12 -m unittest tests.test_sleep_engine
```
(The `python3.12` is because the repo needs ≥3.10 and this box's default
`python3` is 3.8. The plugin's `scripts/sleep.sh` auto-picks a good interpreter.)
## Key decisions I made (so you can veto them)
1. **Reused the real SkillOpt gate**, didn't reinvent it. `consolidate.py`
imports `skillopt.evaluation.gate`. That module imports cleanly without
`openai`; the heavy optimizer/reflect modules (which need `openai`) are only
touched by the future real-API path, so the mock path is dependency-free.
2. **Two backends.** `mock` = deterministic, no key, used for tests + the
acceptance experiment. `anthropic` = real lift via your `claude` CLI / SDK
(wired but Phase-3-shallow). Default is `mock` so nothing spends money
without you asking.
3. **Review-gated adoption by default.** A night **stages** `proposed_CLAUDE.md`
/ `proposed_SKILL.md` + a `report.md` into `<project>/.skillopt-sleep/staging/<date>/`
and changes **nothing live** until `/sleep adopt` (which backs up first).
`--auto-adopt` exists for power users but is off.
4. **Edits live in a protected, marked block** inside SKILL.md/CLAUDE.md, so the
cycle never clobbers your hand-written content.
5. **Phase boundary I hit honestly:** mining your *real* free-text transcripts
yields tasks with no exact checkable reference, so on real data the mock
judge can't score lift (night → reject, 0 lift — correct, not a bug). Real
lift on real transcripts needs the **LLM miner + judge (Phase 3)** to attach
checkable references. The deterministic *proof* runs on persona fixtures that
do have exact refs. This is documented, not hidden.
## What I deliberately did NOT do
- **Did not push** anything (you said offline only).
- **Did not** spend your `ANTHROPIC_API_KEY` — every run above is `mock`.
(Your key IS set; if you want, I can run the `--backend anthropic` demo next.)
- **Did not** build the Codex version (you deferred it; architecture keeps the
backend pluggable).
- **Did not** touch your live `~/.claude/CLAUDE.md` or `~/.claude/skills/*`.
## 5 questions for you (from the design doc)
1. **Adopt policy:** keep default *review-gated*, or enable `auto_adopt` on your machine?
2. **Scope:** harvest only the invoked project, or *all* projects in `~/.claude/projects`?
3. **Real-API demo:** want me to spend live budget on the `--backend anthropic` persona demo to show genuine (non-mock) lift?
4. **Skill target:** evolve a *new* managed `skillopt-sleep-learned` skill (current default), or also edit your existing hand-written skills?
5. **Paper:** make this a SkillOpt arXiv section/figure — "deployment-time continual skill optimization = SkillOpt gate ⊕ Dream consolidation ⊕ Sleep"? I think it's a strong story: SkillOpt provides the *safe update rule* that Dreams/Sleep lack.
## Suggested next steps (when you're back)
- **Phase 3** (highest value): real `AnthropicBackend` miner+judge so it lifts on
your *actual* transcripts, not just personas; + `fresh` worktree replay.
- Wire `slow_memory` cross-night consolidation (state.py already stores it).
- `pip install pytest openai anthropic` in this env if you want the upstream
test suite + real backend to run here (3 upstream tests currently error only
because `pytest` isn't installed — unrelated to this branch).
Everything is committed on the branch. Nothing is pushed. Sleep well 😴
@@ -9,7 +9,7 @@
"plugins": [
{
"name": "skillopt-sleep",
"description": "Nightly offline self-evolution: harvest your past Claude Code sessions, replay recurring tasks on your own API budget, and consolidate what the agent learns into validated CLAUDE.md memory and SKILL.md skills behind a held-out gate, staged for your review.越用越好用. Synthesizes SkillOpt (validation-gated skill optimization), Claude Dreams (offline memory consolidation), and agent sleep/consolidation.",
"description": "Nightly offline self-evolution: harvest your past Claude Code sessions, replay recurring tasks on your own API budget, and consolidate what the agent learns into validated CLAUDE.md memory and SKILL.md skills, behind a held-out gate, staged for your review. Synthesizes SkillOpt (validation-gated skill optimization), Claude Dreams (offline memory consolidation), and agent sleep/consolidation.",
"author": {
"name": "Yifan Yang"
},
@@ -17,7 +17,7 @@
"source": {
"source": "git-subdir",
"url": "https://github.com/microsoft/SkillOpt.git",
"path": "skillopt-sleep-plugin",
"path": "plugins/claude-code",
"ref": "main"
},
"homepage": "https://github.com/microsoft/SkillOpt"
@@ -1,6 +1,6 @@
{
"name": "skillopt-sleep",
"description": "Give your local Claude agent a nightly 'sleep cycle': it reviews your past sessions offline, replays recurring tasks on your own API budget, and consolidates what it learns into validated memory (CLAUDE.md) and skills (SKILL.md).越用越好用 — gets better the more you use it. Synthesizes SkillOpt (validation-gated skill optimization), Claude Dreams (offline memory consolidation), and agent sleep/consolidation.",
"description": "Give your local Claude agent a nightly 'sleep cycle': it reviews your past sessions offline, replays recurring tasks on your own API budget, and consolidates what it learns into validated memory (CLAUDE.md) and skills (SKILL.md) so it gets better the more you use it. Synthesizes SkillOpt (validation-gated skill optimization), Claude Dreams (offline memory consolidation), and agent sleep/consolidation.",
"version": "0.1.0",
"author": {
"name": "Yifan Yang",
@@ -1,6 +1,6 @@
---
name: skillopt-sleep
description: "Use when the user wants their Claude agent to self-improve from past usage, asks about a nightly/offline 'sleep' or 'dream' cycle, memory/skill consolidation, or says things like '让 agent 越用越好用', 'review my past sessions', 'learn my preferences', 'consolidate what you learned', 'run the sleep cycle', or wants to schedule offline self-optimization. Drives the skillopt_sleep engine: harvest past sessions mine recurring tasks replay offline consolidate validated CLAUDE.md/SKILL.md behind a held-out gate."
description: "Use when the user wants their Claude agent to self-improve from past usage, asks about a nightly/offline 'sleep' or 'dream' cycle, memory/skill consolidation, or says things like 'make my agent better the more I use it', 'review my past sessions', 'learn my preferences', 'consolidate what you learned', 'run the sleep cycle', or wants to schedule offline self-optimization. Drives the skillopt_sleep engine: harvest past sessions -> mine recurring tasks -> replay offline -> consolidate validated CLAUDE.md/SKILL.md behind a held-out gate."
---
# SkillOpt-Sleep: offline self-evolution for a local Claude agent
@@ -24,7 +24,7 @@ It synthesizes three ideas:
## When to use this skill
Trigger when the user wants any of:
- "make my agent learn from how I use it" / "越用越好用" / "remember my preferences across sessions"
- "make my agent learn from how I use it" / "get better the more I use it" / "remember my preferences across sessions"
- a nightly/scheduled or on-demand **offline self-improvement / dream / sleep** run
- to **review past sessions/trajectories** and distill recurring tasks
- to **consolidate** feedback into `CLAUDE.md` or a managed skill
+1 -1
View File
@@ -126,7 +126,7 @@ def consolidate(
if evolve_skill:
if rollouts_k > 1:
# multi-rollout contrastive reflection: run each train task K times
# and distill a rule from the good-vs-bad contrast (the "脑补" signal).
# and distill a rule from the good-vs-bad contrast (the imagination signal).
from skillopt_sleep.rollout import multi_rollout, contrastive_reflect
sets = [multi_rollout(backend, t, cand_skill, cand_memory, k=rollouts_k)
for t in train_tasks]
+12 -2
View File
@@ -23,20 +23,30 @@ from skillopt_sleep.types import SessionDigest
# Heuristic phrases that signal the user (dis)approving of prior output.
# English-only by default. Users whose sessions are in another language can add
# their own phrases via the SKILLOPT_SLEEP_NEG_FEEDBACK / _POS_FEEDBACK env vars
# (comma-separated), so the capability is extensible without hardcoding locales.
_NEGATIVE_FEEDBACK = (
"still broken", "still not", "still wrong", "doesn't work", "does not work",
"not working", "that's wrong", "thats wrong", "incorrect", "wrong",
"no,", "nope", "fix it", "didn't", "did not", "broken", "error again",
"still failing", "still fails", "not fixed", "revert", "undo",
"不对", "还是不对", "还是不行", "不行", "错了", "有问题", "没修好",
)
_POSITIVE_FEEDBACK = (
"thanks", "thank you", "perfect", "great", "works now", "fixed",
"that works", "lgtm", "looks good", "nice", "awesome", "correct",
"完美", "可以了", "好的", "搞定", "对了", "正确", "谢谢",
)
def _extra_phrases(env_var: str) -> tuple:
raw = os.environ.get(env_var, "")
return tuple(p.strip().lower() for p in raw.split(",") if p.strip())
_NEGATIVE_FEEDBACK = _NEGATIVE_FEEDBACK + _extra_phrases("SKILLOPT_SLEEP_NEG_FEEDBACK")
_POSITIVE_FEEDBACK = _POSITIVE_FEEDBACK + _extra_phrases("SKILLOPT_SLEEP_POS_FEEDBACK")
def _iter_jsonl(path: str) -> Iterable[Dict[str, Any]]:
try:
with open(path, encoding="utf-8") as f:
+2 -2
View File
@@ -1,6 +1,6 @@
"""SkillOpt-Sleep — multi-rollout + contrastive reflection ("脑补推演" core).
"""SkillOpt-Sleep — multi-rollout + contrastive reflection (the imagination core).
The user's insight: let the agent re-run the SAME task many times, then look at
The core idea: let the agent re-run the SAME task many times, then look at
which rollouts went well vs badly and distill a rule from the *contrast*. This
is a much stronger learning signal than a single failure, and it is the essence
of the offline "dream/imagination" process — train-time rollouts are synthetic,