Commit graph

26 commits

Author SHA1 Message Date
Parfii-bot
03d1dc7362 refactor(v0.16): split install.sh monolith (1238 LOC) into 17 cubes
Constructor Pattern (RULE ZERO). Zero behaviour change, zero flag
drift — all original CLI flags preserved verbatim.

Before: install.sh — 1238 LOC monolith
After:  install.sh — 138 LOC dispatcher (sources libs in order)
        install/lib-*.sh — 16 cubes, max 183 LOC (lib-menu)

Cubes:
  lib-log       21 LOC — logging primitives
  lib-backup    63 LOC — rollback trap + BACKUP_PAIRS
  lib-profile  115 LOC — MANIFEST.toml profile resolution
  lib-args      92 LOC — CLI parsing + --help heredoc
  lib-menu     183 LOC — whiptail/dialog/plain-text interactive picker
  lib-plan     150 LOC — dry-run --no-execute output
  lib-prereqs   91 LOC — hard + soft dependency checks
  lib-primitives 131 LOC — primitive copy + MANIFEST drive
  lib-rust     114 LOC — cargo workspace build + pre-built support
  lib-scaffold 144 LOC — agent/skill/block scaffolding
  lib-bridges   31 LOC — project-bridge install
  lib-hooks    104 LOC — settings.json jq merge
  lib-agents    77 LOC — assembled agent output
  lib-skills    23 LOC — skill copy
  lib-wizard    20 LOC — sleep-setup wizard invocation
  lib-summary   59 LOC — post-install summary

Invariants preserved:
  - macOS bash 3.2 compat (no associative arrays, no [[ ]], no ${,,})
  - rollback trap wired via setup_backup_trap early in dispatcher
  - jq-merge behaviour verbatim in lib-hooks
  - scoped Cargo.toml regeneration in lib-rust

Function LOC limits: largest non-heredoc fn 22 LOC (check_soft_prereqs).
Three functions kept >30 LOC because heredoc-dominated (print_help,
print_summary, profile_members); splitting would fragment logical unit.

62 unique function names across cubes, zero duplicates (grep-verified).

bash -n passes on all 17 files. Runtime smoke test deferred to user's
shell (bash-readonly sandbox constraint).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 15:09:35 +08:00
Parfii-bot
24c584ee50 fix: remove genesis-scan from public kit (internal tool, Bundle-only)
Per user decision: publishing the sensitive IP pattern blocklist via public
scanner is leak of the blocklist itself (attack surface). genesis-scan
remains in PROJECT-E (private); user-global
~/.claude/hooks/genesis-leak-guard.sh (runtime hook) separate.

Deleted:
- _primitives/_rust/genesis-scan/ (whole crate, 5 files)
- hooks/git-pre-commit-genesis.sh (scanner companion)

Modified:
- workspace Cargo.toml -1 member (24→23)
- MANIFEST.toml — removed [primitive.genesis-scan] + core/full profile refs
- .github/workflows/ci.yml — removed genesis-scan job
- README.md — 7 count/description edits (24→23 rust, 10→9 hooks, 37→36 full)
- install.sh — 5 edits (--help + menus)
- mcp-server tool-registry.ts + test — scanner removed from MCP surface
- kei-sleep-queue.sh — removed scan_prompt() pre-submit hook
- 2 sleep-on-it skill phases — removed genesis-scan references

Tests: 160 Rust (was 167, -7 genesis-scan tests as expected), 24 assembler unchanged.
2026-04-22 14:11:22 +08:00
Parfii-bot
a25796df76 docs(readme + install): reconcile all count drift (F4 RELEASE BLOCKER)
Disk reality:
- blocks: 73, manifests: 12, skills: 38 (was 34/35), hooks: 10 (was 6/9)
- shell primitives: 16 (13 opt-in + 3 always-copied)
- bridges: 11, rust crates: 24 (was 8/9/14), MANIFEST full profile: 37

Updated: README.md lines 31, 70, 94, 111, 119-125, 254, 307 and install.sh --help + whiptail.
2026-04-22 13:36:17 +08:00
Parfii-bot
3cead09520 feat(integration): Phase A incubation wired into trigger + install + README 2026-04-22 02:30:04 +08:00
Parfii-bot
aa77043477 feat(integration): --with-sleep-sync flag + README Cloud REM sync section 2026-04-22 01:34:42 +08:00
Parfii-bot
c436eb105d feat(integration): register genesis-scan in MANIFEST core+full + README + install.sh sizing 2026-04-22 01:01:56 +08:00
Parfii-bot
b1ce0609ee feat(install): interactive menu (whiptail/dialog/plain) + confirm screen + --yes/--no-execute
- TUI via whiptail (preferred) or dialog; plain-text fallback with zero deps
- Install Plan confirm screen: primitives, soft-deps status (✓/✗), estimates
- Skip menu on --profile/--add/--remove/--list or non-TTY (CI-safe)
- --yes skips confirm; --no-execute dry-run
- install.sh 844 → 1195 LOC, 10 new functions all <30 LOC
- README +8 LOC Interactive install section
2026-04-21 23:11:58 +08:00
Parfii-bot
67d6f5a15a feat(install): modular profiles + --add/--remove/--list incremental install
Default changed: ./install.sh now installs minimal (no primitives) — ~5s,
~2 MB. Old full behavior available via --profile=full.

Profiles: minimal / core / frontend / ops / dev / full.
Incremental: --add=name[,name] / --remove=name / --list.
Rust workspace scoped per install — only selected crates built.
2026-04-21 23:00:32 +08:00
Parfii-bot
7acacc8fb7 feat(install): copy _primitives/ + build Rust workspace; register agent-fork-logger + site-wysiwyd hooks 2026-04-21 21:33:11 +08:00
Parfii-bot
ab70b8344d fix(audit-l): agent count drift in install.sh and compose-solution
- L1: install.sh post-install banners '~14 generated agents' → '12 generated agents'
  (both the activated-path and the manual-merge-path copies).
- L2: skills/compose-solution/SKILL.md handoff reference '14 kit agents' → '12 kit agents'.
- L3: README /new-agent section rephrases 'via option-pickers' to call out that
  the 6 questions are grouped into multiple option-picker batches (two
  AskUserQuestion calls) rather than six separate prompts.
2026-04-21 20:10:04 +08:00
Parfii-bot
d155afc554 fix(audit-m): tomd cache path-salt; bridges respects rollback; rollback rm-rf guard; placeholder URLs; research skill role-tag note; stack frontend-gap doc
- M1 (RULE 0.4): replace fabricated URLs 'https://example.invalid/PROJECT-D'
  and 'https://…/PROJECT-D' with plain text ('user's personal CLI predecessor').
- M2: tomd-preread cache key = basename + mtime + 8-char shasum of full path,
  so two files with the same basename+mtime at different paths no longer
  collide. Portable shasum shim; falls back to 'nohash' if shasum absent.
- M3: install.sh --with-bridges gated on ROLLED_BACK=0 so bridges are NOT
  emitted into $PWD after an ERR-trap rollback.
- M4: rollback() guards rm -rf "$orig" behind an existence check.
- M5: skills/research/SKILL.md front-matter note — role tags like
  'web-researcher' / 'meta-critic' are ad-hoc prompt labels for the generic
  kei-researcher subagent, NOT separate manifests. Prevents fruitless
  grep in _manifests/.
- M6: README adds a 'Frontend-stack coverage gap' callout listing the
  planned-but-not-shipped frameworks (React-Vite, Vue-Nuxt, SvelteKit,
  Astro, Angular, plain-web).
- M7: no-hand-edit-agents.sh documents at case block that the GENERATED
  marker is the SOLE source of truth — legacy unmarked .md files pass
  silently by design; re-run the assembler to adopt them.
2026-04-21 20:09:24 +08:00
Parfii-bot
a23cde32a8 fix(audit-h2,h3): remove bare-name bypass in compose-solution phase-2; backup settings.json in activate_hooks
- phase-2-decompose.md: delete 'or researcher if that agent is present in the user's
  global fleet' clause that silently bypassed the kei-namespace. Replace with an
  explicit prefer-kei note warning that bare 'researcher' matches only the user's
  personal fleet and may have divergent handoffs.
- install.sh activate_hooks(): call backup_file "$target" on the merge path
  (after the 'create new' early-return) so ERR-trap rollback can restore the
  pre-merge settings.json. Previously an ERR in the jq-merge or mv left no
  backup pair to restore.
2026-04-21 20:07:42 +08:00
Parfii-bot
77184ca2ae fix(audit-h1): correct README counts — 4 hooks, 7 skills, 12 agents; document compose-solution + tomd-preread
- README line 3: 'three pre-wired hooks ... six portable skills' → 'four ... seven'
- README table row: hooks 3→4 (adds tomd-preread), skills 6→7 (adds compose-solution)
- README step 6: 'three hooks and six skills' → 'four hooks and seven skills'
- README pipeline paragraph: 'Three hooks enforce' → 'Four hooks enforce' + tomd-preread bullet
- install.sh post-install message: '3 hooks' → '4 hooks' (tomd-preread added)
2026-04-21 20:07:06 +08:00
Parfii-bot
d59fc2ba59 feat(install): install _primitives/ + soft pandoc warning
- install.sh:
  - mkdir $AGENTS_DIR/_primitives
  - copy *.sh + README.md from kit _primitives/ with backup_dir guard
  - chmod +x for the primitive scripts
  - extend hooks-copy loop to include tomd-preread.sh (skips if absent,
    preserving back-compat with kits that predate the primitive)
  - soft-warn (not hard-fail) if pandoc is missing — tomd primitive is
    opt-in and works without pandoc for CSV/code/JSON/images
- settings-snippet.json: add PreToolUse(Read) entry for tomd-preread.sh
  with statusMessage. New matcher block (no existing Read matcher).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 19:44:30 +08:00
Parfii-bot
7d14181044 Merge branch 'feat/project-bridges' — 11 cross-tool bridges + install.sh --with-bridges + wizard Phase 8
# Conflicts:
#	install.sh
2026-04-21 17:15:44 +08:00
Parfii-bot
3fca2427c1 feat(install): --with-bridges flag emits bridges into $PWD
- Copy _bridges/ into ~/.claude/agents/_bridges/ so new-agent
  skill Phase 8 can invoke the renderer from the user fleet dir
- Add --with-bridges flag: after agents/hooks/skills install,
  invoke _bridges/emit.sh "$PWD" to render 11 bridge files
- Guard: if $PWD is the KeiSeiKit source repo itself (detected
  via ./install.sh + ./_bridges), warn and skip — avoid
  polluting the kit's own working tree
- --help prints usage block; flag parser loop supports future
  --activate-hooks coexistence without refactor
2026-04-21 14:45:02 +08:00
Parfii-bot
69b06b8c0e fix(install): per-file backup for shared hooks dir
$HOOKS_DIR ($HOME/.claude/hooks) is shared with other kits. Backing up
the whole directory cumulatively bloats foreign hooks across re-runs.
Switch to backup_file per KeiSeiKit-owned hook so only the 3 files we
actually overwrite get a .bak-TIMESTAMP sibling. backup_dir remains for
KeiSeiKit-owned directories (_blocks, _templates, _assembler, skills).
2026-04-21 04:12:53 +08:00
Parfii-bot
4e9cbb01f1 fix(install): respect NO_COLOR and non-TTY output
say/warn/err now detect isatty(1) and the NO_COLOR env convention. When
stdout is redirected to a log file or NO_COLOR is set, ANSI escape codes
are suppressed. Interactive activation prompt also gated.
2026-04-21 04:12:11 +08:00
Parfii-bot
f04c9f38da fix(install): replace compgen with bash-3.2-portable glob check
compgen is unreliable on bash 3.2 (macOS stock). Replace with a simple
for-loop over the glob plus a file-existence test that breaks early.
2026-04-21 03:48:28 +08:00
Parfii-bot
5fa4bb9777 fix(install): try offline cargo build first, fall back to online
Offline build is attempted first so a fresh clone with a warm registry
cache can install without network. On failure, fall back to a regular
cargo build --release which will fetch from crates.io.
2026-04-21 03:46:32 +08:00
Parfii-bot
3c9e89e8c8 feat(install): optional --activate-hooks jq-merge into settings.json
Adds --activate-hooks flag for non-interactive hook activation, plus a
TTY prompt at end-of-install. Merge is jq-based, groups by matcher, and
de-dupes hook entries by command — idempotent across re-runs. Existing
user hooks on the same matcher are preserved. Non-TTY without the flag
keeps the manual instructions.
2026-04-21 03:35:55 +08:00
Parfii-bot
5f51822214 fix(install): trap ERR and roll back from .bak-* snapshots
If cargo build or any later step fails, the ERR trap walks the list of
backups created during this run and atomically swaps each .bak-TIMESTAMP
back onto its original. Idempotent via ROLLED_BACK guard. On success
nothing is rolled back — backups remain as the user's recovery copy.
2026-04-21 03:34:42 +08:00
Parfii-bot
8625fe791b fix(install): scaffold ~/.claude/memory dir + placeholder MEMORY.md
_blocks/memory-protocol.md references ~/.claude/memory/MEMORY.md, but the
installer previously only scaffolded agents/ hooks/ skills/ — so the first
agent that followed the block would fail reading a non-existent index.
Now mkdir -p ~/.claude/memory and, only when MEMORY.md is absent, write a
minimal placeholder (frontmatter + pointer to the block). User-edited
MEMORY.md is never overwritten.
2026-04-21 03:07:15 +08:00
Parfii-bot
16d4b48c77 fix(hooks): guard against missing jq; drop UUOC
All three hooks used `set -eu` + `cat | jq …`. Without jq installed, jq
would fail and `-e` would abort the hook → non-zero exit → Claude Code
refuses Edit/Write/Bash system-wide. Now each hook probes for jq BEFORE
`set -eu` and exits 0 silently if absent. Also dropped the useless `cat |`
pipe — `jq -r` reads stdin directly.

Companion: install.sh jq check upgraded from warn to hard `exit 1` because
without jq the hooks are dead weight; message states jq is required on
any machine that will activate the hooks.
2026-04-21 02:55:07 +08:00
Parfii-bot
b1a77f393a fix(install): backup existing agents dirs before clobber
Previously cp -f clobbered user-edited _blocks/, _templates/, _assembler/,
hooks/, and skills/ silently — violating the README's "idempotent" claim
on re-run. Now each of those targets is snapshotted to a timestamped
<target>.bak-$(date +%s)/ sibling before overwrite, but only when the
target actually contains regular files (freshly-mkdir'd scaffolds are
skipped). _manifests/ unchanged — already uses per-file skip-if-exists.
Kit source ($KIT_DIR) is never backed up.
2026-04-21 02:41:26 +08:00
denis
0b901cf2f9 feat: KeiSeiKit v0.1.0 — initial public release
Generic Constructor-Pattern agent kit for Claude Code. Zero personal data,
fully English, MIT-licensed.

Contents:
- 34 reusable blocks (baseline, rules, stack/deploy/domain/api/scraper)
- 14 cross-project agent manifests (code/ml/infra/researcher/critic/...)
- 6 portable skills (/new-agent, /research, /test-gen, /debug-deep, /pr-review, /refactor)
- Rust assembler (single binary, ~500 KB)
- 3 hooks (auto-reassemble, pre-commit validate, no-hand-edit)
- install.sh (idempotent, cargo-builds on first run)
- MIT LICENSE

All 6 sanity greps pass: 0 Russian text, 0 specific project names,
0 incident numbers, 0 user paths, 0 hardcoded IPs, 0 API keys.

cargo check + assemble --validate: both pass on 14 manifests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 23:58:34 +08:00