โ† Back to home@huangjua

dsh-session-index

๐Ÿ” Full-text session search & bookmarking engine for DSH with native CJK substring search

Stars
0
Language
TypeScript
Created
Sep 1, 2026
Updated
Sep 1, 2026

Introduction

๐Ÿ” dsh-session-index

Full-text session search & bookmarking engine for DSH
Native CJK Substring Search โ€ข Non-Blocking Worker Pool โ€ข Multi-Signal Ranking โ€ข Jump-Back Bookmarks

DSH Suite CJK Search License

Features โ€ข Quick Start โ€ข DSH Power Suite โ€ข Tools โ€ข Architecture โ€ข ็ฎ€ไฝ“ไธญๆ–‡


๐Ÿ’ก Why dsh-session-index?

DSH archives past conversations as compressed .jsonl.zstd event logs. Built-in search only supports exact whole-word Latin tokens, making Chinese searches return zero results, while full-pass decompression freezes the UI.

dsh-session-index transforms dead logs into an instantly queryable second brain:

  • ๐Ÿ‡จ๐Ÿ‡ณ Native CJK & Latin Substring FTS: Engineered with FTS5 trigrams. The only implementation allowing Chinese substring & code fragment matching across historical turns.
  • ๐Ÿš€ Non-Blocking Worker Pool: Streaming decompression with multi-core workers. Keeps main-thread event loop lag strictly under p95 < 23ms.
  • ๐ŸŽฏ Multi-Signal Relevance Ranking: Combines fzy fuzzy scoring, 21-day half-life recency decay, and workspace affinity (adapted from Atuin and McFly).
  • ๐Ÿ”– Deterministic Bookmarking & Jump-Back: Drop anchors at (sessionId, messageId) to quickly revisit past breakthroughs without modifying original archive files.

๐Ÿš€ Quick Start

Installation

# In your DSH plugin environment
dev_inject_plugin @dsh-external/dsh-session-index

Typical Usage Flow

  1. Search with Chinese / Substring: Run session_index_search query="้‡ๆž„ ่ฎค่ฏไธญ้—ดไปถ" mode="full".
  2. Review Relevance-Ranked Hits: Inspect Codex-style snippet previews with exact message IDs.
  3. Drop a Bookmark: Save critical moments via session_index_bookmark action="add" label="JWT Auth Fix".

๐Ÿงฉ DSH Power Suite

This plugin is part of the DSH Agent Power Suite โ€” 4 modular, zero-hard-dependency plugins forming a complete closed-loop developer workflow:

flowchart LR
    M["๐Ÿง  dsh-local-memory<br>(1. Remember rules & prefs)"] --> E["โšก dsh-context-economy<br>(2. Save 80%+ tokens reading code)"]
    E --> A["๐Ÿ›ก๏ธ dsh-evidence<br>(3. Tamper-proof audit receipts)"]
    A --> S["๐Ÿ” dsh-session-index<br>(4. CJK search & bookmarks)"]
    S --> M

    style M fill:#e8f4fd,stroke:#2b7de9,stroke-width:2px
    style E fill:#eef9f2,stroke:#1e8e3e,stroke-width:2px
    style A fill:#fef7e0,stroke:#f29900,stroke-width:2px
    style S fill:#f3e8fd,stroke:#8430ce,stroke-width:2px
PluginRole in SuiteSynergy with Session Index
๐Ÿ” dsh-session-indexSession Search (Current)Provides high-speed CJK search and bookmarking across compressed session archives.
๐Ÿง  dsh-local-memoryMemory LayerCurates high-level memories. Memory curation belongs to local-memory; log search belongs here.
๐Ÿ›ก๏ธ dsh-evidenceAudit & ReceiptsAllows searching past sessions to find past evidence bundles, audit logs, and claim anchors.
โšก dsh-context-economyContext EconomyCompact pointer output generates 80%+ smaller session logs, reducing search index load.

๐Ÿ“– Deep Dive & Reference

๐Ÿ› ๏ธ Available Tools (5 Tools)
ToolDescription
session_index_statusInspect / refresh indexing state (active, progress, worker health, retention).
session_index_listList sessions by workspace with stable cursor pagination or relevance sorting.
session_index_searchSearch sessions in mode=meta or mode=full (FTS/Worker) with role and time filters.
session_summaryGenerate deterministic summaries (timestamps, event breakdown, tool calls, optional LLM 1-liner).
session_index_bookmarkAdd/list/remove bookmarks anchored at (sessionId, messageId) for instant jump-back.
๐Ÿ—๏ธ Architecture & Non-Blocking Pipeline
session_index_status / session_index_list / session_index_search / session_summary
        โ”‚
        โ–ผ
SessionIndexBuilder (Singleton per root + indexFile)
 โ”œโ”€ Single-flight Promise deduplication
 โ”œโ”€ Durable run-marker: ~/.dsh/session-index/.tmp/build.lock
 โ”œโ”€ Phase A (Head Pass): Stream-decompress first 10 records โžก๏ธ quick index
 โ”œโ”€ Phase B (Full Pass): Full event counts & assistant text โžก๏ธ WorkerPool
 โ””โ”€ Atomic Commit: Unique tmpfile โžก๏ธ fsync โžก๏ธ validate โžก๏ธ rename
โš–๏ธ Technical Trade-offs & Boundaries
AdvantageTrade-off / Boundary
Unique CJK trigram search implementationCouplings to DSH's compressed session storage format
Non-blocking worker pool (lag < 23ms)Requires node:sqlite for FTS index
214 test cases covering crash consistency & streamingDual index co-exists with official session query service
๐Ÿงช Building & Testing
pnpm run check:dsh-contract  # Contract validation
pnpm run build               # Build TypeScript to lib/
npm test                     # Run 214 test cases
๐Ÿ™ Credits & Prior Art
  • OpenAI Codex (commit 9ded177): Non-blocking v2 architecture, snippet previews, HEAD_RECORD_LIMIT.
  • jhawthorn/fzy: fzyScore TypeScript translation (consecutive matching & bonus matrix).
  • Atuin & McFly: Hit tiers ร— exponential time-decay scoring.
  • fzf: Tie-break determinism algorithm.

Part of the DSH Agent Power Suite. Licensed under BSD-3-Clause.