KeiSeiKit-1.0/skills/sleep-setup/phase-3b-deep-sleep.md

3.9 KiB

Phase 3b — Deep-sleep NREM configuration (v0.13.0)

Collect three pure-click decisions for Phase C (system consolidation): cadence, fork mode, store backend. All three are AskUserQuestion batches — zero free text (frequency "custom" is the single exception).

3b.1 — Deep-sleep cadence

Emit ONE AskUserQuestion:

{
  "questions": [
    {
      "question": "How often should deep-sleep run (system consolidation — detect conflicts across rules, hooks, blocks, memory)?",
      "header": "Deep-sleep cadence",
      "multiSelect": false,
      "options": [
        {"label": "Never (disable)",                 "description": "Phase C skipped forever"},
        {"label": "Every 14 days (low-load)",        "description": "Minimal churn; rare consolidation"},
        {"label": "Every 7 days (Recommended)",      "description": "Weekly Sunday — default"},
        {"label": "Every 3 days",                     "description": "Tighter loop for active refactors"},
        {"label": "Every day (heavy-load only)",     "description": "May be overkill for most users"},
        {"label": "Custom (N days, free-text)",      "description": "Enter integer on next prompt"}
      ]
    }
  ]
}

Store as DEEP_SLEEP_CRON_DAYS:

  • Never → 0
  • Every 14 → 14
  • Every 7 → 7
  • Every 3 → 3
  • Every day → 1
  • Custom → emit follow-up freeText prompt, parse integer, clamp to 1..=90. Reject non-integer with retry.

3b.2 — Fork output mode

Emit ONE AskUserQuestion:

{
  "questions": [
    {
      "question": "Fork output with applied changes?",
      "header": "Deep-sleep fork",
      "multiSelect": false,
      "options": [
        {"label": "Plan only (Recommended)",  "description": "Read markdown in the morning; decide by hand"},
        {"label": "Plan + fork branch",       "description": "Also generate deep-sleep/YYYY-MM-DD branch for git review"}
      ]
    }
  ]
}

Store as DEEP_SLEEP_WITH_FORK ∈ {0, 1}.

3b.3 — Memory-repo backend

Emit ONE AskUserQuestion:

{
  "questions": [
    {
      "question": "Memory-repo backend?",
      "header": "Store backend",
      "multiSelect": false,
      "options": [
        {"label": "GitHub private (simplest)",   "description": "github.com with deploy key or PAT"},
        {"label": "Forgejo self-hosted",          "description": "Same wire protocol; different base URL"},
        {"label": "Gitea self-hosted",            "description": "Same wire protocol as Forgejo"},
        {"label": "Filesystem only (no remote)",  "description": "Local .git; no push; survives laptop only"},
        {"label": "S3-compatible (R2/MinIO/AWS)", "description": "Object storage — MVP stub in v0.13.0"}
      ]
    }
  ]
}

Store as STORE_BACKEND ∈ {github, forgejo, gitea, filesystem, s3}.

3b.4 — Write store config

Call kei-store init <STORE_BACKEND> --url <REPO_URL> which writes ~/.claude/agents/_primitives/store-config.toml with:

[active]
backend = "<STORE_BACKEND>"
local_path = "~/.claude/memory/sync-repo"

[<STORE_BACKEND>]
url = "<REPO_URL>"
ssh_key_env = "KEI_MEMORY_SSH_KEY"
pat_env = "KEI_MEMORY_PAT"

Secrets (SSH key path, PAT) remain in ~/.claude/secrets/.env per RULE 0.8. The config file stores only env-var NAMES.

For filesystem backend skip the URL step entirely (no remote). For s3 also prompt for endpoint, bucket, region via three free-text fields (one-off — unavoidable; S3 has no SSH-like default).

3b.5 — Verify-criterion

  • DEEP_SLEEP_CRON_DAYS ∈ {0,1,3,7,14, or 1..=90} for custom.
  • DEEP_SLEEP_WITH_FORK ∈ {0, 1}.
  • STORE_BACKEND ∈ {github, forgejo, gitea, filesystem, s3}.
  • ~/.claude/agents/_primitives/store-config.toml exists and has the active backend set.
  • Exactly THREE AskUserQuestion batches in this phase (plus one follow-up free-text iff the user picked Custom for cadence, and up to three free-text fields iff S3 was picked).