Skip to content

Commit 66be3fa

Browse files
authored
Merge pull request #9 from senna-lang/fix/init-hardening
feat(cli): harden and polish loci init command
2 parents 1f49b17 + d63c535 commit 66be3fa

14 files changed

Lines changed: 657 additions & 126 deletions

File tree

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Changelog
22

3+
## [0.2.0] - 2026-04-21
4+
5+
### Added
6+
7+
- `loci init --no-hooks` flag to skip automatic Claude Code hook registration.
8+
- `EmbedderSetupError` exception for environment-level embedder failures (distinguishes them from per-row errors).
9+
- SVG banner at the top of the README (`assets/banner.svg`, generated via Freeze).
10+
- `scripts/generate-banner.sh` to regenerate the banner from the live CLI output.
11+
12+
### Changed
13+
14+
- `loci init` now registers Claude Code hooks automatically at the end of setup — previously required a separate `loci hook install` step. Use `--no-hooks` to opt out.
15+
- Interactive prompts re-prompt on invalid input instead of silently falling back to a default. The "run distillation now?" prompt now accepts `y`/`n`/`yes`/`no` in addition to `1`/`2`.
16+
- Custom exchange counts are range-validated (`1..total`) and custom `min_chars` requires `>= 0`.
17+
- Startup banner uses the pagga half-block font with a blue vertical gradient.
18+
19+
### Fixed
20+
21+
- `loci init` cleans up `.codeatrium/` automatically if the execution phase fails or is interrupted (`KeyboardInterrupt`), so re-running is safe.
22+
- A single corrupt `.jsonl` no longer aborts the whole indexing loop — it logs a warning and continues.
23+
- `git_root()` catches `FileNotFoundError` when the `git` binary is missing.
24+
- `parse_exchanges` returns `[]` for missing files instead of raising.
25+
- Distillation failures from `sentence_transformers` import issues (e.g. numpy/pyarrow binary mismatch) now print a single friendly message with remediation hints instead of a full traceback followed by per-row error spam.
26+
327
## [0.1.0] - 2026-03-31
428

529
### Added

README.ja.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<p align="center">
2+
<img src="assets/banner.svg" alt="codeatrium — memory palace for AI coding agents" width="560">
3+
</p>
4+
15
# Codeatrium
26

37
[![CI](https://github.com/senna-lang/Codeatrium/actions/workflows/ci.yml/badge.svg)](https://github.com/senna-lang/Codeatrium/actions/workflows/ci.yml)
@@ -47,13 +51,12 @@ Python 3.11 以上が必要です。
4751
## クイックスタート
4852

4953
```bash
50-
# プロジェクトルートで初期化
54+
# プロジェクトルートで初期化(Claude Code フックも自動登録)
5155
loci init
52-
53-
# 自動インデックスのフックをインストール
54-
loci hook install
5556
```
5657

58+
`loci init` は DB 初期化・既存セッション検出・Claude Code フック登録をすべて一度に済ませます。`--no-hooks` を付けるとフック登録をスキップします。途中で失敗した場合は `.codeatrium/` が自動で掃除されるので、再実行して問題ありません。
59+
5760
`loci init` を実行すると、過去のセッションログが検出された場合に以下の質問が表示されます:
5861

5962
> [!IMPORTANT]
@@ -65,7 +68,9 @@ loci hook install
6568
- Distill last 50(直近の履歴のみ)
6669
- Distill all(全件、トークン消費あり)
6770
- Custom(件数を指定)
68-
3. **蒸留を今すぐ実行するか** — No を選ぶと次回セッション開始時に自動実行されます
71+
3. **蒸留を今すぐ実行するか**`1`/`2`/`y`/`n`/`yes`/`no` を受理。No を選ぶと次回セッション開始時に自動実行されます。
72+
73+
各プロンプトで無効な入力をした場合、サイレントにデフォルトへ倒れず再入力を求めます。
6974

7075
## エージェント向けインストラクション
7176

@@ -78,19 +83,19 @@ loci hook install
7883

7984
| コマンド | 説明 |
8085
|---------|------|
81-
| `loci init` | プロジェクトルートに `.codeatrium/` を初期化 |
86+
| `loci init` | `.codeatrium/` を初期化し Claude Code フックを登録(`--no-hooks` で省略可) |
8287
| `loci index` | 新しいセッションログをインデックス |
8388
| `loci distill [--limit N]` | 未蒸留の exchange を LLM で蒸留 |
8489
| `loci search "クエリ" --json` | セマンティック検索(エージェント向け) |
8590
| `loci context --symbol "名前" --json` | コードシンボル → 過去の会話 |
8691
| `loci show "<ref>" --json` | 会話原文を取得 |
8792
| `loci status` | インデックス状態を表示 |
8893
| `loci server start/stop/status` | 埋め込みサーバー管理 |
89-
| `loci hook install` | Claude Code の設定にフックを登録 |
94+
| `loci hook install` | フックを再登録(通常は `loci init` で済む) |
9095

9196
## 自動化(Claude Code フック)
9297

93-
`loci hook install` 後、すべて自動で動作します:
98+
`loci init`(または `loci hook install`後、すべて自動で動作します:
9499

95100
| フック | トリガー | コマンド |
96101
|--------|---------|---------|

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<p align="center">
2+
<img src="assets/banner.svg" alt="codeatrium — memory palace for AI coding agents" width="560">
3+
</p>
4+
15
# Codeatrium
26

37
[![CI](https://github.com/senna-lang/Codeatrium/actions/workflows/ci.yml/badge.svg)](https://github.com/senna-lang/Codeatrium/actions/workflows/ci.yml)
@@ -47,13 +51,12 @@ Requires Python 3.11+.
4751
## Quick Start
4852

4953
```bash
50-
# Initialize in project root
54+
# Initialize in project root (also registers Claude Code hooks)
5155
loci init
52-
53-
# Install hooks for automatic indexing
54-
loci hook install
5556
```
5657

58+
`loci init` now handles everything in one step — database setup, existing session detection, and Claude Code hook registration. Pass `--no-hooks` to skip hook registration. If init fails partway through, `.codeatrium/` is cleaned up automatically so re-running is safe.
59+
5760
When running `loci init`, if past session logs are detected, you'll be prompted with:
5861

5962
> [!IMPORTANT]
@@ -65,7 +68,9 @@ When running `loci init`, if past session logs are detected, you'll be prompted
6568
- Distill last 50 (recent history only)
6669
- Distill all (everything — high token cost)
6770
- Custom (specify a number)
68-
3. **Run distillation now?** — Choose No to defer to the next session start
71+
3. **Run distillation now?** — Accepts `1`/`2`/`y`/`n`/`yes`/`no`. Choose No to defer to the next session start.
72+
73+
Invalid input on any prompt re-prompts instead of silently falling back to a default.
6974

7075
## Agent Instructions
7176

@@ -78,19 +83,19 @@ Agent instructions are injected automatically — no manual setup required:
7883

7984
| Command | Description |
8085
|---------|-------------|
81-
| `loci init` | Initialize `.codeatrium/` in project root |
86+
| `loci init` | Initialize `.codeatrium/` and register Claude Code hooks (`--no-hooks` to skip) |
8287
| `loci index` | Index new session logs |
8388
| `loci distill [--limit N]` | Distill undistilled exchanges via LLM |
8489
| `loci search "query" --json` | Semantic search (agent-facing) |
8590
| `loci context --symbol "name" --json` | Code symbol → past conversations |
8691
| `loci show "<ref>" --json` | Retrieve verbatim conversation |
8792
| `loci status` | Show index state |
8893
| `loci server start/stop/status` | Embedding server management |
89-
| `loci hook install` | Register hooks in Claude Code settings |
94+
| `loci hook install` | Re-register hooks (normally already done by `loci init`) |
9095

9196
## Automation (Claude Code Hooks)
9297

93-
After `loci hook install`, everything runs automatically:
98+
After `loci init` (or `loci hook install`), everything runs automatically:
9499

95100
| Hook | Trigger | Command |
96101
|------|---------|---------|

assets/banner.svg

Lines changed: 15 additions & 0 deletions
Loading

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "codeatrium"
7-
version = "0.1.0"
7+
version = "0.2.0"
88
description = "Memory palace for AI coding agents — index sessions, recall code context in <0.2s"
99
readme = "README.md"
1010
license = { text = "MIT" }

scripts/generate-banner.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
# Regenerate assets/banner.svg from the live loci banner using Freeze.
3+
# Requires: brew install charmbracelet/tap/freeze
4+
#
5+
# Freeze embeds font glyphs as <path> elements so the rendering is
6+
# identical across GitHub, local browsers, and other SVG consumers.
7+
8+
set -euo pipefail
9+
10+
cd "$(dirname "$0")/.."
11+
12+
FORCE_COLOR=1 python -c "
13+
from codeatrium.cli import _print_banner
14+
_print_banner()
15+
" | freeze \
16+
--output assets/banner.svg \
17+
--padding 24,28,24,28 \
18+
--margin 0 \
19+
--background '#00000000' \
20+
--border.radius 8 \
21+
--font.family 'JetBrains Mono' \
22+
--font.size 14 \
23+
--line-height 1.2
24+
25+
echo "wrote: assets/banner.svg"

src/codeatrium/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""codeatrium — Memory palace for AI coding agents"""
22

3-
__version__ = "0.1.0"
3+
__version__ = "0.2.0"

0 commit comments

Comments
 (0)