KeiSeiKit-1.0/_blocks/stack-swift-spm.md
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

1.5 KiB

STACK — Swift SPM executable (macOS)

Use for platform-native macOS UI. Requires some non-obvious incantations to avoid silent failures.

Info.plist embed — each arg prefixed with -Xlinker:

.unsafeFlags([
  "-Xlinker", "-sectcreate",
  "-Xlinker", "__TEXT",
  "-Xlinker", "__info_plist",
  "-Xlinker", "/abs/path/Info.plist",
])

Relative paths silently fail. NSPrincipalClass=NSApplication in Info.plist MANDATORY — without it the binary runs as a console tool, no menubar, no events.

Codesign: codesign --force --sign - <path>/MyApp.app — ad-hoc signature is enough for local use; Gatekeeper flags unsigned .app bundles as damaged.

Menubar lifecycle (mandatory dance):

  1. NSApp.setActivationPolicy(.regular) at launch
  2. Create NSStatusItem via NSStatusBar.system.statusItem(withLength: .variable)
  3. NSApp.setActivationPolicy(.accessory) AFTER status item is attached

Skip any step → icon never appears, no error, silent failure.

Broken / forbidden:

  • MenuBarExtra (SwiftUI) — does NOT work with SPM executables. Use NSStatusItem + SwiftUI popover.
  • Notch overflow (MacBook Pro 14/16 M1+) — new status items hidden behind notch. Verify visibility post-install.

LaunchAgent hygiene (learned from a real disk-bloat incident): a duplicate LaunchAgent or a chatty sync daemon without log-silencing can fill the disk with tens of GB of log chatter. Check launchctl list before adding a LaunchAgent, and keep LaunchAgent stdout/stderr → /dev/null.