Skip to content

feat: add Japanese keyword patterns and session-end auto-save#2

Merged
kandotrun merged 2 commits intomainfrom
feat/japanese-keywords-and-session-save
Mar 19, 2026
Merged

feat: add Japanese keyword patterns and session-end auto-save#2
kandotrun merged 2 commits intomainfrom
feat/japanese-keywords-and-session-save

Conversation

@kandotrun
Copy link
Owner

@kandotrun kandotrun commented Mar 19, 2026

Changes

1. Japanese memory keyword patterns

Added 11 Japanese trigger patterns so the plugin recognizes memory requests in Japanese:

  • 覚えて, 記憶して, メモして, 保存して, 忘れないで, 忘れるな, 記録して, 覚えておいて, メモっておいて, メモっといて, ノートして

2. Session-end auto-save

Automatically saves conversation summaries to supermemory when a session ends:

  • Tracks user and assistant messages during the session
  • On session.deleted event, ingests the conversation into both project and user scopes
  • Minimum 3 messages required to trigger save (skip trivial sessions)
  • Capped at 50 tracked messages / 50k chars to prevent unbounded memory growth

Dependencies

Summary by CodeRabbit

リリースノート

  • 新機能
    • 日本語のメモ・記録関連キーワード検出機能を追加しました
    • セッション終了時に会話内容が自動的にサマリー化され保存されるようになりました
    • セッション中のユーザーメッセージをリアルタイムで追跡・記録する機能を実装しました

OpenCode v1.2.25+ validates that all part IDs must start with 'prt'.
The chat.message hook was creating parts with IDs like
'supermemory-nudge-xxx' and 'supermemory-context-xxx', causing
ZodError crashes on every session start.

Changes:
- Extract generatePartId/generateMessageId into shared ids.ts
- Use generatePartId() in index.ts for nudge and context parts
- Remove duplicated functions from compaction.ts

Fixes supermemoryai#28
Fixes supermemoryai#29
Fixes supermemoryai#32
1. Japanese memory keywords:
   Added patterns like 覚えて, メモして, 保存して, 忘れないで etc.
   so the plugin recognizes Japanese memory trigger phrases.

2. Session-end auto-save:
   - Track user and assistant messages during the session
   - On session.deleted event, ingest the conversation into
     both project and user scopes via supermemory
   - Minimum 3 messages required to trigger save
   - Capped at 50 tracked messages / 50k chars to avoid
     unbounded memory growth
@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

Caution

Review failed

Pull request was closed or merged during review

ウォークスルー

日本語キーワードパターンを設定に追加し、セッションメッセージの収集と会話要約機能を実装しました。ID生成ロジックを共有モジュールに統合し、セッション終了時にSupermemoryへの会話データ保存機能が追加されました。

変更内容

コホート / ファイル(s) 概要
設定の拡張
src/config.ts
DEFAULT_KEYWORD_PATTERNSに日本語キーワードパターンを追加(覚えて、記憶して、メモして等)。英語パターンに// Englishコメント、日本語パターンに// Japaneseコメントを追加。
セッション管理と会話追跡
src/index.ts
セッションメッセージの収集機能を追加。collectMessage()でユーザー・アシスタントメッセージを追跡し、最大50件を保持。saveSessionSummary()でセッション終了時にSupermemoryへ会話要約を保存。イベントハンドラーを拡張し、session.deletedmessage.updatedイベントに対応。
ID生成の統合
src/services/compaction.ts, src/services/ids.ts
新規モジュールids.tsgeneratePartId()generateMessageId()を実装。compaction.tsから重複するID生成ロジックを削除し、共有モジュールをインポート。タイムスタンプとランダム値を使用したID生成を一元化。

シーケンス図

sequenceDiagram
    participant User as ユーザー
    participant Session as セッション管理
    participant Memory as インメモリ追跡<br/>(sessionMessages)
    participant Supermemory as Supermemory<br/>サービス
    
    User->>Session: メッセージ送信
    Session->>Memory: collectMessage()でメッセージ保存
    Memory->>Memory: 最大50件まで保持
    Note over Session: セッション処理中
    User->>Session: セッション終了
    Session->>Session: session.deleted イベント
    Session->>Memory: セッションのメッセージを取得
    Memory-->>Session: 50,000文字以内に圧縮した<br/>会話トランスクリプト
    Session->>Supermemory: ingestConversation()で<br/>会話要約を保存
    Supermemory-->>Session: 保存完了
    Note over Session: メタデータ: type="conversation"<br/>source="session-end"
Loading

推定コードレビュー工数

🎯 3 (中程度) | ⏱️ ~25 分

ウサギのポエム

🐰 セッションの記憶を集めて、
データベースへ優しく保存。
タイムスタンプ、ランダムな番号、
IDは整理され、統一された。
会話の思い出、永遠に残る。 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed タイトルはプルリクエストの2つの主な変更点(日本語キーワードパターンの追加とセッション終了時の自動保存)を正確に反映しており、簡潔で具体的です。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/japanese-keywords-and-session-save
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kandotrun kandotrun merged commit db96f73 into main Mar 19, 2026
1 check was pending
@kandotrun kandotrun self-assigned this Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant