Skip to content

Commit 0029be4

Browse files
committed
docs: add module location and cross-references to AI structuring modules
- mneme/core/prompts/json_parser.py: Location, related modules, tests - mneme/core/ai_provider.py: Architecture hierarchy, related modules - mneme/core/worker.py: StructuringWorker architecture, related modules - mneme/core/heuristic_structuring.py: Method overview, related modules - Bump version to 2.0.24
1 parent db7a788 commit 0029be4

7 files changed

Lines changed: 87 additions & 7 deletions

File tree

mneme/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""kimi-mneme — Persistent memory for Kimi Code CLI."""
22

3-
__version__ = "2.0.23"
3+
__version__ = "2.0.24"

mneme/core/ai_provider.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
"""AI provider for observation structuring using configurable LLM backends."""
1+
"""AI provider for observation structuring using configurable LLM backends.
2+
3+
Location: mneme/core/ai_provider.py
4+
5+
This module provides the AI/Hybrid providers that orchestrate observation structuring.
6+
It sends tool call data to an LLM and parses the JSON response into structured observations.
7+
8+
Architecture:
9+
AIProvider (abstract)
10+
├── ConfigurableAIProvider -- Uses any LLM client (Kimi, Ollama, OpenAI-compatible)
11+
└── HybridProvider -- Tries AI first, falls back to heuristic structuring
12+
13+
Related modules:
14+
- mneme/core/prompts/json_parser.py -- Parses LLM JSON responses
15+
- mneme/core/prompts/observation_prompt.py -- Prompt templates
16+
- mneme/core/heuristic_structuring.py -- Fallback when AI is unavailable
17+
- mneme/core/llm_client.py -- LLM client abstraction
18+
- mneme/core/worker.py -- Background worker using HybridProvider
19+
- mneme/db/structured_store.py -- Stores ParsedObservation results
20+
21+
Tests: tests/test_ai_provider.py
22+
"""
223

324
from __future__ import annotations
425

mneme/core/heuristic_structuring.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
"""Heuristic structuring as fallback when AI is unavailable.
22
3+
Location: mneme/core/heuristic_structuring.py
4+
35
This module extracts structured observations from raw tool calls using
46
rule-based analysis. It's designed to be fast, deterministic, and produce
57
high-quality results comparable to AI structuring for common patterns.
8+
9+
Architecture:
10+
HeuristicStructuring
11+
├── structure() -- Main entry point
12+
├── _detect_type() -- Detects observation type from tool/error/prompt
13+
├── _generate_title() -- Generates human-readable title
14+
├── _generate_subtitle() -- Generates subtitle/summary
15+
├── _extract_facts() -- Extracts key facts (up to 5)
16+
├── _generate_narrative() -- Generates narrative description
17+
├── _detect_concepts() -- Detects concept tags from patterns
18+
├── _extract_files_*() -- Extracts file paths
19+
└── _extract_file_paths() -- Regex-based file path extraction
20+
21+
Related modules:
22+
- mneme/core/ai_provider.py -- HybridProvider falls back to this module
23+
- mneme/core/prompts/json_parser.py -- ParsedObservation dataclass (same fields)
24+
- mneme/db/structured_store.py -- Stores HeuristicObservation results
25+
26+
Tests: tests/test_ai_provider.py (TestHeuristicStructuring)
627
"""
728

829
from __future__ import annotations

mneme/core/prompts/json_parser.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
"""Parse JSON responses from AI structuring."""
1+
"""Parse JSON responses from AI structuring.
2+
3+
Location: mneme/core/prompts/json_parser.py
4+
5+
This module is part of the AI structuring pipeline. It parses raw JSON responses
6+
from LLMs into structured ParsedObservation objects.
7+
8+
Related modules:
9+
- mneme/core/ai_provider.py -- Uses parse_observation_json() via HybridProvider / ConfigurableAIProvider
10+
- mneme/core/prompts/observation_prompt.py -- Prompt templates sent to LLM
11+
- mneme/core/heuristic_structuring.py -- Fallback when AI is disabled
12+
- mneme/core/worker.py -- Background worker that orchestrates structuring
13+
- mneme/db/structured_store.py -- Stores the resulting ParsedObservation
14+
15+
Tests: tests/test_json_parser.py
16+
"""
217

318
from __future__ import annotations
419

mneme/core/worker.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1-
"""Background worker for AI structuring queue."""
1+
"""Background worker for AI structuring queue.
2+
3+
Location: mneme/core/worker.py
4+
5+
This module runs a background loop that fetches pending observations from the queue,
6+
processes them through AI/heuristic structuring, and stores structured results.
7+
8+
Architecture:
9+
StructuringWorker
10+
├── _build_ai_provider_from_config() -- Creates ConfigurableAIProvider from config
11+
├── start() -- Main loop (async)
12+
├── _process_batch() -- Claims messages, structures, stores results
13+
└── _extract_project() -- Extracts project name from cwd
14+
15+
Related modules:
16+
- mneme/core/ai_provider.py -- HybridProvider / ConfigurableAIProvider
17+
- mneme/core/prompts/json_parser.py -- Parses LLM JSON responses
18+
- mneme/core/heuristic_structuring.py -- Fallback when AI is unavailable
19+
- mneme/db/store.py -- Raw observation queue (claim_pending_messages)
20+
- mneme/db/structured_store.py -- Stores structured observations
21+
- mneme/db/vector.py -- Vector search index
22+
23+
Tests: tests/test_worker.py
24+
"""
225

326
from __future__ import annotations
427

plugin/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kimi-mneme",
3-
"version": "2.0.23",
3+
"version": "2.0.24",
44
"description": "Persistent memory plugin for Kimi Code CLI \u2014 search and retrieve past session context. Part of the kimi-plugins ecosystem.",
55
"config_file": "config.json",
66
"inject": {
@@ -111,4 +111,4 @@
111111
}
112112
}
113113
]
114-
}
114+
}

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 = "kimi-mneme"
7-
version = "2.0.23"
7+
version = "2.0.24"
88
description = "Persistent memory plugin for Kimi Code CLI"
99
readme = "README.md"
1010
license = { text = "AGPL-3.0" }

0 commit comments

Comments
 (0)