From edeca916db1b3b6d605434137f6418f565f7e48b Mon Sep 17 00:00:00 2001 From: Parfii-bot Date: Wed, 22 Apr 2026 00:50:04 +0800 Subject: [PATCH] feat(integration): wire kei-memory into MANIFEST + settings-snippet + README for v0.10 --- README.md | 21 ++++++++++++++++++--- _primitives/MANIFEST.toml | 10 ++++++++-- settings-snippet.json | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c9211a8..ba049fb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # KeiSeiKit — Constructor-Pattern Agent Kit for Claude Code -KeiSeiKit is a comprehensive drop-in toolkit for [Claude Code](https://claude.com/claude-code). It ships a curated set of composable behavioral blocks, a Rust assembler that builds agent `.md` files from TOML manifests deterministically, six pre-wired hooks, 34 portable skills (including an interactive `/new-agent` wizard and 10 hub-and-spoke pipelines), 8 Rust primitive crates, 13 shell primitives, and 11 cross-tool bridge templates. Everything follows a Constructor Pattern: one file per concern, manifests as single source of truth, and the generated agent files are regenerated on every relevant edit. +KeiSeiKit is a comprehensive drop-in toolkit for [Claude Code](https://claude.com/claude-code). It ships a curated set of composable behavioral blocks, a Rust assembler that builds agent `.md` files from TOML manifests deterministically, nine pre-wired hooks (three of them dedicated to RULE 0.14 session self-audit), 35 portable skills (including an interactive `/new-agent` wizard, 10 hub-and-spoke pipelines, and the `/self-audit` retrospective skill), 9 Rust primitive crates, 13 shell primitives, and 11 cross-tool bridge templates. Everything follows a Constructor Pattern: one file per concern, manifests as single source of truth, and the generated agent files are regenerated on every relevant edit. The kit is MIT-licensed and fully generic — install it on a fresh machine and you get a sane 12-agent fleet (implementers, critics, researchers, cost-guardians, and more — all namespaced under `kei-*` so they won't collide with your own same-named agents), a wizard for spinning up new project specialists, 10 pipeline skills that combine primitives end-to-end (`/compose-solution`, `/site-create`, `/schema-design`, `/observability-setup`, `/auth-setup`, `/api-design`, `/ci-scaffold`, `/test-matrix`, `/docs-scaffold`, `/new-project`, `/vm-provision`), and a build pipeline that keeps every agent derivable from its manifest. @@ -63,7 +63,7 @@ By default `./install.sh` is **minimal** — agents + hooks + skills + bridges, | `frontend` | 8 site tools: `mock-render`, `visual-diff`, `tokens-sync`, `design-scrape`, `live-preview`, `figma-tokens`, `frontend-inspect`, `screenshot-decode` | ~60s | ~80 MB | | `ops` | 8 infra tools: `kei-ledger`, `ssh-check`, `firewall-diff`, `provision-hetzner`, `provision-vultr`, `harden-base`, `metrics-scrape`, `log-ship` | ~90s | ~50 MB | | `dev` | 4 dev tools: `kei-migrate`, `kei-changelog`, `kei-ci-lint`, `kei-docs-scaffold` | ~60s | ~40 MB | -| `full` | everything (21 primitives) | ~5 min | ~200 MB | +| `full` | everything (22 primitives) | ~5 min | ~200 MB | Examples: @@ -80,7 +80,7 @@ Examples: Profile resolution lives in `_primitives/MANIFEST.toml` — one `[primitive.]` entry per primitive plus a `[profile]` block. Edit the manifest to define new profiles without touching `install.sh`. -> **Migrating from a full install:** if you're re-running `install.sh` after an earlier version that installed all 21 primitives unconditionally, the new default (`minimal`) will REMOVE them. To preserve the old behaviour explicitly, pass `--profile=full`. +> **Migrating from a full install:** if you're re-running `install.sh` after an earlier version that installed all 22 primitives unconditionally, the new default (`minimal`) will REMOVE them. To preserve the old behaviour explicitly, pass `--profile=full`. > **Re-install disclaimer:** `install.sh` is idempotent for clean state but **overwrites kit-owned `_blocks/`, `_primitives/`, `_bridges/`, `_templates/`, `_assembler/`, `hooks/`, and `skills/` on re-run** — local modifications under those directories are backed up to `.bak-TIMESTAMP/` (or, for shared hook files, to `.bak-TIMESTAMP`). User-owned `_manifests/*.toml` are never overwritten. @@ -138,6 +138,20 @@ Hub-and-spoke skills that combine primitives into end-to-end flows. Each one is All pipelines share a single discovery layer: `/compose-solution` Phase 3's prior-art grep covers `_blocks/`, `_manifests/`, `_primitives/` (shell + Rust), `skills/`, `_bridges/`, `hooks/` — so any pipeline can reuse primitives without re-inventing them. +## Session self-audit (RULE 0.14) + +KeiSeiKit auto-analyzes sessions on 3 triggers: + +- **Stop event** — session ended; `session-end-dump.sh` archives the JSONL trace and ingests it into `kei-memory`. +- **Milestone commits** — `git commit -m "feat:"` / `"refactor:"` / `git merge`; `milestone-commit-hook.sh` appends a one-line session summary to `~/.claude/memory/audit-backlog.md`. +- **Error spike** — 3+ errors in the last 20 tool calls; `error-spike-detector.sh` tags the pattern and logs it. + +Findings surface via click-only `AskUserQuestion`, routing to `/escalate-recurrence` (codify rule + wiki + hook), `/debug-deep` (5-phase RCA), or the audit backlog (log-only). **Silent-first**: the first 10 sessions log only — prompts activate from session 11 onward so the memory store has a useful baseline before it interrupts you. Counter lives in `~/.claude/memory/audit-backlog.md` as ``. + +Manual trigger: `/self-audit` skill (same flow, invoked on demand). + +Requires the `kei-memory` primitive. Included in the `dev` and `full` profiles; otherwise add via `./install.sh --add=kei-memory`. + ## Primitives (Rust) `_primitives/_rust/` is a Cargo workspace with 8 single-binary crates. `install.sh` builds `--release` and drops binaries at `~/.claude/agents/_primitives/_rust/target/release/`. @@ -152,6 +166,7 @@ All pipelines share a single discovery layer: `/compose-solution` Phase 3's prio | `mock-render` | Playwright wrapper — takes screenshots with SHA-locked PNGs (WYSIWYD: What You See Is What You Deploy) | | `visual-diff` | Pixel diff with tolerance — used in `/site-create` screenshot-regression loop | | `tokens-sync` | Design tokens JSON → Tailwind config extend + CSS variables under `:root` | +| `kei-memory` | Session retrospective + recurring pattern detector; offline-first analyzer powering RULE 0.14 self-audit | ## Primitives (shell) diff --git a/_primitives/MANIFEST.toml b/_primitives/MANIFEST.toml index cd1e098..c33bc8b 100644 --- a/_primitives/MANIFEST.toml +++ b/_primitives/MANIFEST.toml @@ -20,8 +20,8 @@ minimal = [] core = ["tomd"] frontend = ["mock-render", "visual-diff", "tokens-sync", "design-scrape", "live-preview", "figma-tokens", "frontend-inspect", "screenshot-decode"] ops = ["kei-ledger", "ssh-check", "firewall-diff", "provision-hetzner", "provision-vultr", "harden-base", "metrics-scrape", "log-ship"] -dev = ["kei-migrate", "kei-changelog", "kei-ci-lint", "kei-docs-scaffold"] -full = ["tomd", "kei-ledger", "kei-migrate", "kei-changelog", "ssh-check", "firewall-diff", "mock-render", "visual-diff", "tokens-sync", "design-scrape", "live-preview", "figma-tokens", "frontend-inspect", "screenshot-decode", "provision-hetzner", "provision-vultr", "harden-base", "metrics-scrape", "log-ship", "kei-ci-lint", "kei-docs-scaffold"] +dev = ["kei-migrate", "kei-changelog", "kei-ci-lint", "kei-docs-scaffold", "kei-memory"] +full = ["tomd", "kei-ledger", "kei-migrate", "kei-changelog", "ssh-check", "firewall-diff", "mock-render", "visual-diff", "tokens-sync", "design-scrape", "live-preview", "figma-tokens", "frontend-inspect", "screenshot-decode", "provision-hetzner", "provision-vultr", "harden-base", "metrics-scrape", "log-ship", "kei-ci-lint", "kei-docs-scaffold", "kei-memory"] # --- shell primitives (13) ------------------------------------------------- @@ -152,3 +152,9 @@ kind = "rust" crate = "tokens-sync" deps = [] desc = "Design tokens JSON → Tailwind config extend + CSS variables under :root" + +[primitive.kei-memory] +kind = "rust" +crate = "kei-memory" +deps = ["rusqlite bundled (no system sqlite required)"] +desc = "Session retrospective + recurring pattern detector (offline-first, RULE 0.14)" diff --git a/settings-snippet.json b/settings-snippet.json index 178924b..99ca59f 100644 --- a/settings-snippet.json +++ b/settings-snippet.json @@ -1,5 +1,5 @@ { - "_comment": "Merge these entries into your ~/.claude/settings.json under the matching keys. If you already have PostToolUse/PreToolUse arrays, append the objects below to them instead of overwriting. install.sh --activate-hooks automates the merge and de-dupes by hooks[].command.", + "_comment": "Merge these entries into your ~/.claude/settings.json under the matching keys. If you already have PostToolUse/PreToolUse/Stop arrays, append the objects below to them instead of overwriting. install.sh --activate-hooks automates the merge and de-dupes by hooks[].command.", "hooks": { "PostToolUse": [ { @@ -15,6 +15,26 @@ "statusMessage": "site-wysiwyd drift check..." } ] + }, + { + "matcher": "Bash", + "hooks": [ + { + "type": "command", + "command": "~/.claude/hooks/milestone-commit-hook.sh", + "statusMessage": "milestone self-audit check (RULE 0.14)..." + } + ] + }, + { + "matcher": "*", + "hooks": [ + { + "type": "command", + "command": "~/.claude/hooks/error-spike-detector.sh", + "statusMessage": "error-spike rolling window (RULE 0.14)..." + } + ] } ], "PreToolUse": [ @@ -56,6 +76,18 @@ } ] } + ], + "Stop": [ + { + "matcher": "*", + "hooks": [ + { + "type": "command", + "command": "~/.claude/hooks/session-end-dump.sh", + "statusMessage": "session-end trace dump (RULE 0.14)..." + } + ] + } ] } }