# Kiok

Experience-driven memory for AI agents. Store lessons learned during tasks and retrieve them via full-text search.

## Install

```sh
cargo install kiok
```

## Quick Start

```sh
# Register an agent
kiok agent create my-feature

# Save a lesson
kiok save my-feature --lesson "Batch inserts need explicit transaction" --context "DB migration"

# Search past lessons
kiok search my-feature --query "transaction"

# List all lessons
kiok memories my-feature

# Forget a lesson
kiok forget <id>
```

## Claude Integration

Use the `prime` command with a [SessionStart hook](https://docs.anthropic.com/en/docs/claude-code/hooks) to inject past experiences at the start of each session:

```jsonc
// ~/.claude/settings.json
{
  "hooks": {
    "SessionStart": [{ "command": "kiok prime" }]
  }
}
```

## Library Usage

```rust
use kiok::{init_db, KiokStore};

let conn = init_db("/path/to/kiok.db").unwrap();
let store = KiokStore::new(conn);

store.create_agent("my-agent").unwrap();
store.save_experience("my-agent", "lesson text", Some("context")).unwrap();

let results = store.search_experiences("my-agent", "lesson", 3).unwrap();
```

## Desktop App (Tauri)

GUI로 agent/experience를 브라우징하고 검색할 수 있는 데스크톱 앱.

### 실행

```sh
# 의존성 설치
pnpm install

# 개발 모드 (hot-reload)
pnpm tauri dev

# 프로덕션 빌드 (.app / .dmg)
pnpm tauri build
```

> Rust 툴체인(`rustup`)과 [Tauri v2 prerequisites](https://v2.tauri.app/start/prerequisites/) 필요.

### 기능

- 왼쪽 사이드바에서 agent 선택
- 선택한 agent의 experience 목록 표시
- 검색창에서 FTS5 전문 검색

## Data

All data is stored in `~/.kiok/kiok.db` (SQLite with FTS5). CLI와 Desktop App이 동일한 DB를 공유합니다.

## License

MIT
