Parfii-bot
d32ca0bc28
fix(v0.19): audit hardening — 3 security HIGH + 3 critic HIGH + 2 critic MEDIUM
...
Closes consolidated findings from wave-audit (critic + security + architect):
SECURITY HIGH:
H1 path escape — Brain::load rejects absolute mcp_server paths +
any containing '..'; canonicalize + starts_with(root) assertion;
new Error::PathEscape variant.
H2 brain name validation + clobber refuse — regex ^[a-z][a-z0-9_-]{0,63}$
enforced at Brain::load; adapters refuse to overwrite existing
mcpServers[name] with NameConflict (unless same content).
H3 symlink reject at canonicalize — std::fs::symlink_metadata()
called before canonicalize; Error::BrainIsSymlink with resolved
target path; prevents USB → $HOME pivot.
CRITIC HIGH:
#1 rusqlite dep deleted (zero uses in src/, pulls C toolchain).
#3 BrainPaths memory/artifacts/manifests now Option<String>
(only mcp_server required; schema no longer lies about contract).
CRITIC MEDIUM:
#1 _primitives/_rust/keisei/src/paths.rs (new, 23 LOC) — SSoT for
$KEISEI_HOME/$HOME resolver; config.rs and claude_code.rs
delegate instead of duplicating 7-line block.
#2 canonicalize error preserves io::Error via new Error::BrainLoad
{ path, source } with #[source] attribute.
#5 fsx::write_atomic_json rewrite via tempfile::NamedTempFile
+ persist — Windows-safe, cross-fs-fallback handling.
New module split (Constructor Pattern): brain.rs (104 → 122) now a
thin orchestrator over brain_validate.rs (108 LOC) which owns
symlink-reject / canonicalize-root / read-manifest / validate-schema
/ validate-name / check-relative-in-root / canonicalize-in-root.
Deps: regex = { workspace = true }, tempfile = "3" (runtime).
Workspace-level regex = "1.10" added.
MANIFEST.toml [primitive.keisei] deps updated.
Tests: 11 pre-existing + 5 adversarial:
- manifest_with_absolute_mcp_server_rejected — proves /usr/bin/python3
CANNOT land in settings.json (PathEscape + marker absent asserts)
- manifest_with_parent_traversal_rejected — ../../etc/passwd rejected
- manifest_with_invalid_name_rejected — 'claude-ide!' rejected
- brain_path_is_symlink_rejected — USB → $HOME pivot blocked
- attach_refuses_to_clobber_existing_mcp_entry — NameConflict on diff
All 16 pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 16:36:11 +08:00
Parfii-bot
e6cab72587
feat(v0.19): multi-client adapters + detach/mount/list-adapters + schema v2
...
Extends keisei CLI from single-client (v0.18) to multi-client exobrain:
new subcommands detach/mount/list-adapters, 3 new adapters (Cursor,
Continue, Zed), schema v2 for ~/.claude/keisei-attached.toml with
[[attachments]] array (v1 backward-compat via untagged serde).
New subcommands:
detach — iterate marker attachments, call adapter.detach() on each,
then delete marker. Real strip of mcpServers entry per adapter.
mount <brain> — auto-attach to ALL detected clients in one call.
list-adapters — tabular status (name / detected / config path).
New adapters (each <130 LOC mirrors claude_code.rs pattern):
adapters/cursor.rs — .cursor/mcp.json project-local, fallback
~/.cursor/mcp.json global.
adapters/continue_adapter.rs — ~/.continue/config.json with
experimental.modelContextProtocolServers key.
adapters/zed.rs — ~/.config/zed/settings.json (Linux) or
~/Library/Application Support/Zed/settings.json (macOS) with
context_servers key. Zed schema marked [UNVERIFIED] pending docs.
Schema v2 (~/.claude/keisei-attached.toml):
[[attachments]]
client_type = "claude-code"
config_path = "/Users/.../.claude/settings.json"
[[attachments]]
client_type = "cursor"
config_path = "/Users/.../proj/.cursor/mcp.json"
v1 marker migration: untagged serde accepts legacy client_type=string,
upgrades to single-entry attachments[] on next write.
Tests: 5 (v0.18) + 6 new = 11 integration tests, all pass:
- attach_then_status_happy_path
- attach_missing_manifest_errors
- attach_unsupported_schema_errors
- status_without_attach_is_clean
- attach_writes_marker_with_expected_fields
- mount_with_claude_code_only_detected (new)
- mount_with_no_client_detected (new)
- detach_round_trip (new)
- detach_preserves_other_mcp_servers (new)
- list_adapters_prints_expected_rows (new)
- schema_v1_to_v2_migration (new)
Known issues (defer to follow-up commit):
- CRITIC HIGH#1: rusqlite declared but unused
- CRITIC HIGH#3: BrainPaths fields required but only mcp_server used
- SECURITY H1/H2/H3: brain path/name not validated before writing
into client config — will be addressed before tagging v0.19.0
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 16:04:45 +08:00
Parfii-bot
e53ad26243
Merge feat/v0.18-keisei-cli-mvp — exobrain attach/status CLI
2026-04-22 15:52:59 +08:00
Parfii-bot
3bb9ba7911
feat(v0.18): keisei CLI MVP — exobrain attach/status
...
Phase 3 of exobrain architecture. Ships the entry-point CLI
that mounts a portable brain (memory + artifacts + manifests +
mcp-server) into an AI client via one command.
MVP scope: 2 subcommands (attach, status), 1 adapter (claude-code).
detach + mount + multi-client deferred to v1.0.
New Rust crate _primitives/_rust/keisei/ — 10 src files + 1 tests
(Constructor Pattern: all files <150 LOC, all fns <=23 LOC).
main.rs (53 LOC) — clap dispatch
error.rs (36 LOC) — thiserror enum (BrainNotFound,
UnsupportedSchema, NoClientDetected, Io/Toml/Json #[from])
brain.rs (103 LOC) — Brain::load() reads brain/manifest.toml
schema_v1 (name, created, paths.{memory,artifacts,manifests,
mcp_server})
adapter.rs (38 LOC) — ClientAdapter trait (detect/attach/
detach/config_path) + registry
adapters/claude_code.rs (121 LOC) — writes MCP server entry
into ~/.claude/settings.json via merge_mcp_entry (23 LOC,
mirrors jq-merge pattern from install/lib-hooks.sh)
attach.rs (44 LOC) — load brain, detect client, call adapter,
write SSoT ~/.claude/keisei-attached.toml
status.rs (62 LOC) — read SSoT, print brain name/path/client/
timestamp + health check (mcp_server binary exists?)
config.rs (97 LOC) — KeiseiAttached TOML struct + KEISEI_HOME
env hook for test isolation
tests/integration.rs (142 LOC) — 5 cases via tempfile + Mutex
env guard: happy-path, missing-manifest, unsupported-schema,
no-attach-state, marker-field verification
Workspace: keisei added to _primitives/_rust/Cargo.toml members.
MANIFEST.toml: [primitive.keisei] rust kind, kei-ledger-style
deps (rusqlite bundled, stub for future artifact reads), added
to full profile (standalone opt-in via --add=keisei).
README Rust crates table gains 1 row; count marker untouched.
CHANGELOG [Unreleased] bullet added.
Usage:
keisei attach /path/to/brain # mounts into current Claude Code
keisei status # shows mounted brain + health
Next (v0.18 follow-ups): detach impl, cursor/continue adapters,
list-adapters subcommand.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 15:52:40 +08:00
Parfii-bot
e67ade47c8
feat(v0.18): kei-mcp-server single-binary compile — 5-platform via bun
...
Phase 1 of exobrain architecture. Ships TS MCP server as a static
binary so users on machines without Node can run KeiSeiKit (USB /
flashdrive / air-gapped scenarios).
.github/workflows/release.yml (+62 LOC) — new build-mcp-binary job:
- 5-target matrix: darwin arm64/x64, linux arm64/x64, windows x64
- bun build --compile, linux arm64 continue-on-error (ARM runners
less reliable)
- Artifact kei-mcp-server-<os>-<arch>[.exe] + sha256
- release job now needs [build-release, build-mcp-binary]
install/lib-rust.sh (+50 LOC) — have_prebuilt_mcp_server() +
report_mcp_server_binary_status(); KEI_SKIP_MCP_BUILD=1 env
flag skips bun/npm install when a prebuilt binary is present.
File 165 LOC (<200 limit).
_ts_packages/packages/mcp-server/package.json — scripts.build:native
+ 5 per-target aliases (macos-arm, macos-x64, linux-x64,
linux-arm, win-x64) for local dev.
_ts_packages/packages/mcp-server/BUILD.md (NEW, 52 LOC) — local
compile guide per platform + Gatekeeper/code-sign notes +
cites bun docs [VERIFIED: https://bun.sh/docs/bundler/executables ].
README.md pre-built-binaries section gains 'MCP server binary'
subsection (download, chmod +x, xattr -d com.apple.quarantine for
macOS, UAC note for Windows).
CHANGELOG.md [Unreleased] bullet added.
Output size: ~90 MB per binary (bundled bun runtime). Acceptable
trade for zero-dep USB distribution.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 15:52:36 +08:00
Parfii-bot
d97afb63ec
feat(v0.16): CHANGELOG + tag-driven release workflow
...
Keep-a-Changelog format. 12 sections: [Unreleased] + 11 real
releases v0.8.0..v0.15.0, every bullet with real git SHA pulled
via git log --no-merges. 150 LOC.
.github/workflows/release.yml — 3 jobs, triggered on tag push:
build-release: 4-platform matrix
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu (continue-on-error)
- x86_64-apple-darwin
- aarch64-apple-darwin
Builds entire _primitives/_rust workspace, emits tar.gz +
sha256 per target via portable executable-discovery loop.
release: downloads artifacts, runs local
kei-changelog --from <prev-tag> --to <tag>, publishes via
softprops/action-gh-release@v2.
npm-publish: graceful skip when NPM_TOKEN secret absent
(steps.have_token.outputs.present gate + || warning wrap
so one failing package doesn't kill the job).
Companion install support: install/lib-rust.sh gains
have_prebuilt_binaries() + KEI_SKIP_RUST_BUILD=1 guard (shipped
as part of install-split bundle). Users can download tarball
instead of compiling Rust from source.
release.yml validated via yaml.safe_load: 3 jobs parse cleanly,
matrix expands 4-wide, jobs = [build-release, release, npm-publish].
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 15:10:00 +08:00