lorewiki 0.2.2__tar.gz → 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. {lorewiki-0.2.2 → lorewiki-0.2.4}/PKG-INFO +88 -24
  2. {lorewiki-0.2.2 → lorewiki-0.2.4}/README.md +87 -23
  3. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/__init__.py +1 -1
  4. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/cli/apps.py +5 -3
  5. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/cli/commands.py +21 -5
  6. {lorewiki-0.2.2 → lorewiki-0.2.4}/pyproject.toml +1 -1
  7. {lorewiki-0.2.2 → lorewiki-0.2.4}/.gitignore +0 -0
  8. {lorewiki-0.2.2 → lorewiki-0.2.4}/LICENSE +0 -0
  9. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/__main__.py +0 -0
  10. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/cli/__init__.py +0 -0
  11. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/cli/add.py +0 -0
  12. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/cli/config_cmds.py +0 -0
  13. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/cli/helpers.py +0 -0
  14. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/cli/topic_cmds.py +0 -0
  15. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/config.py +0 -0
  16. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/db/__init__.py +0 -0
  17. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/db/connection.py +0 -0
  18. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/db/models.py +0 -0
  19. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/db/schema.sql +0 -0
  20. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/indexer/__init__.py +0 -0
  21. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/indexer/chunker.py +0 -0
  22. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/indexer/cleaning.py +0 -0
  23. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/indexer/indexer.py +0 -0
  24. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/indexer/parser.py +0 -0
  25. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/llm/__init__.py +0 -0
  26. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/llm/client.py +0 -0
  27. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/llm/generator.py +0 -0
  28. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/py.typed +0 -0
  29. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/retriever/__init__.py +0 -0
  30. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/retriever/base.py +0 -0
  31. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/retriever/bm25.py +0 -0
  32. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/retriever/fusion.py +0 -0
  33. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/retriever/hierarchy.py +0 -0
  34. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/retriever/search.py +0 -0
  35. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/retriever/vector.py +0 -0
  36. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/topic.py +0 -0
  37. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/utils/__init__.py +0 -0
  38. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/utils/logger.py +0 -0
  39. {lorewiki-0.2.2 → lorewiki-0.2.4}/lorewiki/utils/topic_shared.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lorewiki
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Local-first knowledge base for LLM-assisted coding, with hybrid retrieval (BM25 + hierarchy + optional vector) over SQLite FTS5.
5
5
  Project-URL: Documentation, https://github.com/JochenYang/Lore-wiki
6
6
  Project-URL: Source, https://github.com/JochenYang/Lore-wiki
@@ -105,50 +105,114 @@ it directly.
105
105
 
106
106
  ## Installation
107
107
 
108
+ LoreWiki ships as a single Python wheel on **PyPI** (the only
109
+ distribution channel). Pick your preferred installer:
110
+
111
+ ### uv (recommended, full feature set)
112
+
113
+ ```bash
114
+ # Install — isolated per-tool venv, the lorewiki.exe (Windows)
115
+ # or lorewiki binary (macOS/Linux) is added to your PATH.
116
+ uv tool install lorewiki
117
+
118
+ # With the optional vector-retrieval extra (sqlite-vec + sentence-transformers):
119
+ uv tool install 'lorewiki[vector]'
120
+
121
+ # Upgrade:
122
+ uv tool upgrade lorewiki
123
+
124
+ # Uninstall (does NOT touch ~/.lorewiki/ — your data is yours):
125
+ uv tool uninstall lorewiki
126
+ ```
127
+
128
+ If you don't have `uv` yet:
129
+
130
+ ```bash
131
+ # macOS / Linux:
132
+ curl -LsSf https://astral.sh/uv/install.sh | sh
133
+ # Windows (PowerShell):
134
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
135
+ ```
136
+
137
+ Plain `pip` works too (the `lorewiki.exe` entry point is the same):
138
+
108
139
  ```bash
109
- # Editable install (recommended for active development)
110
- uv tool install --editable .
140
+ pip install lorewiki # core CLI
141
+ pip install 'lorewiki[vector]' # opt-in: vector retrieval
142
+ ```
111
143
 
112
- # Or plain pip
113
- pip install -e . # core CLI
114
- pip install -e ".[dev]" # add pytest / ruff / coverage
115
- pip install -e ".[vector]" # opt-in: vector retrieval (sqlite-vec)
144
+ > The `[rest]` and `[mcp]` extras from 0.1.x are gone as of 0.2.0.
145
+ > The CLI + opencode skill replaced the FastAPI / MCP server surface.
146
+ > The `[all]` extra is now an alias for `[vector]`.
147
+
148
+ ### From source (for contributors)
149
+
150
+ ```bash
151
+ git clone https://github.com/JochenYang/Lore-wiki
152
+ cd Lore-wiki
153
+ uv tool install --editable . # dev install
154
+ uv tool install --editable '.[dev]' # + pytest / ruff / coverage
116
155
  ```
117
156
 
118
- Python **3.10+** required. After install, `lorewiki --version`
119
- should print `LoreWiki 0.1.0`.
157
+ Python **3.10+** is required. After install, `lorewiki --version`
158
+ should print a banner ending with `v0.2.x`.
120
159
 
121
- > Windows PowerShell users: if CJK characters show as `?` in
122
- > `lorewiki search --raw` output, prefix the command with
123
- > `chcp 65001 |` to force the shell code page to UTF-8, or upgrade
124
- > to v0.1.1+ which forces UTF-8 stdout automatically.
160
+ > **Windows PowerShell + CJK note**: starting with 0.2.0, LoreWiki
161
+ > forces UTF-8 on stdout/stderr unconditionally CJK characters
162
+ > round-trip cleanly through the shell without `chcp 65001`. If you
163
+ > hit garbled output on an older release, upgrade with
164
+ > `uv tool upgrade lorewiki` or prefix the command with
165
+ > `chcp 65001 |`.
166
+
167
+ For deeper install info (PATH troubleshooting, where data lives,
168
+ backups, common errors, how publishing works), see
169
+ [`docs/install.md`](docs/install.md).
125
170
 
126
171
  ## Quickstart
127
172
 
128
173
  ```bash
129
- # 1. Create a wiki + config
174
+ # 1. Create a wiki + sample Markdown
130
175
  lorewiki init --path ./my-wiki
131
176
 
132
- # 2. Author Markdown under ./my-wiki/, then index it
177
+ # 2. Index the Markdown into SQLite + FTS5 (one-time, then incremental)
133
178
  lorewiki index --path ./my-wiki
134
179
 
135
- # 3. Search
180
+ # 3. Search (default output is structured JSON for agents; --human for Rich Table)
136
181
  lorewiki search "用户登录接口" --path ./my-wiki --mode mix --top-k 5
182
+ lorewiki search "用户登录接口" --path ./my-wiki --mode mix --top-k 5 --human
137
183
 
138
184
  # 4. Ask (LLM-assisted answer, gracefully falls back to top chunks)
139
185
  lorewiki ask "如何实现幂等重试" --path ./my-wiki
140
186
 
141
- # 5. Or author a note from the CLI (writes + re-indexes in one go)
142
- echo "Some deep details about Python design pattern." \
143
- | lorewiki add --title "Python Design" --module "patterns" --tag python,design
187
+ # 5. Author a note from the CLI (writes + re-indexes in one go)
188
+ # Three equivalent ways to provide the body:
189
+ lorewiki add --title "Python Design" --module "patterns" --tag python,design \
190
+ --body "Some deep details about Python design patterns." \
191
+ --path ./my-wiki
192
+
193
+ # --file: read the body from a file
194
+ lorewiki add --title "From File" --module "patterns" \
195
+ --file ./drafts/python-design.md --path ./my-wiki
196
+
197
+ # stdin pipe (any of these is fine on Windows + PowerShell, even
198
+ # with CJK content; 0.2.2+ scrubs UTF-16 surrogates automatically)
199
+ echo "Some deep details about Python design patterns." \
200
+ | lorewiki add --title "From Pipe" --module "patterns" --path ./my-wiki
144
201
 
145
- # 6. Browse the index status
202
+ # 6. Browse the index / hierarchy / status
146
203
  lorewiki status --path ./my-wiki
204
+ lorewiki tree --path ./my-wiki # Rich-Tree view of the hierarchy
205
+ lorewiki show index.md --path ./my-wiki # print a doc body (cleaned)
147
206
  ```
148
207
 
149
- The default config lives in `<wiki>/.lorewiki/config.toml`; user-wide
150
- overrides live in `~/.lorewiki/config.toml`; env vars `LOREWIKI_*` override
151
- both.
208
+ **Config resolution** (later wins):
209
+
210
+ 1. `<wiki>/.lorewiki/config.toml` — per-wiki defaults
211
+ 2. `~/.lorewiki/config.toml` — user-wide overrides
212
+ 3. `LOREWIKI_*` env vars — shell-level overrides
213
+
214
+ Edit any of these with `lorewiki config list / get / set` (TOML-aware,
215
+ no hand-editing required).
152
216
 
153
217
  ## Topics — your second brain
154
218
 
@@ -336,7 +400,7 @@ See `docs/lorewiki dev document.md` for the full design plan and
336
400
  ```bash
337
401
  pip install -e ".[dev]"
338
402
  ruff check lorewiki skills tests # lint
339
- pytest -q # 240 unit + integration tests
403
+ pytest -q # 241 unit + integration tests
340
404
  pytest --cov=lorewiki # coverage report
341
405
  ```
342
406
 
@@ -61,50 +61,114 @@ it directly.
61
61
 
62
62
  ## Installation
63
63
 
64
+ LoreWiki ships as a single Python wheel on **PyPI** (the only
65
+ distribution channel). Pick your preferred installer:
66
+
67
+ ### uv (recommended, full feature set)
68
+
69
+ ```bash
70
+ # Install — isolated per-tool venv, the lorewiki.exe (Windows)
71
+ # or lorewiki binary (macOS/Linux) is added to your PATH.
72
+ uv tool install lorewiki
73
+
74
+ # With the optional vector-retrieval extra (sqlite-vec + sentence-transformers):
75
+ uv tool install 'lorewiki[vector]'
76
+
77
+ # Upgrade:
78
+ uv tool upgrade lorewiki
79
+
80
+ # Uninstall (does NOT touch ~/.lorewiki/ — your data is yours):
81
+ uv tool uninstall lorewiki
82
+ ```
83
+
84
+ If you don't have `uv` yet:
85
+
86
+ ```bash
87
+ # macOS / Linux:
88
+ curl -LsSf https://astral.sh/uv/install.sh | sh
89
+ # Windows (PowerShell):
90
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
91
+ ```
92
+
93
+ Plain `pip` works too (the `lorewiki.exe` entry point is the same):
94
+
64
95
  ```bash
65
- # Editable install (recommended for active development)
66
- uv tool install --editable .
96
+ pip install lorewiki # core CLI
97
+ pip install 'lorewiki[vector]' # opt-in: vector retrieval
98
+ ```
67
99
 
68
- # Or plain pip
69
- pip install -e . # core CLI
70
- pip install -e ".[dev]" # add pytest / ruff / coverage
71
- pip install -e ".[vector]" # opt-in: vector retrieval (sqlite-vec)
100
+ > The `[rest]` and `[mcp]` extras from 0.1.x are gone as of 0.2.0.
101
+ > The CLI + opencode skill replaced the FastAPI / MCP server surface.
102
+ > The `[all]` extra is now an alias for `[vector]`.
103
+
104
+ ### From source (for contributors)
105
+
106
+ ```bash
107
+ git clone https://github.com/JochenYang/Lore-wiki
108
+ cd Lore-wiki
109
+ uv tool install --editable . # dev install
110
+ uv tool install --editable '.[dev]' # + pytest / ruff / coverage
72
111
  ```
73
112
 
74
- Python **3.10+** required. After install, `lorewiki --version`
75
- should print `LoreWiki 0.1.0`.
113
+ Python **3.10+** is required. After install, `lorewiki --version`
114
+ should print a banner ending with `v0.2.x`.
76
115
 
77
- > Windows PowerShell users: if CJK characters show as `?` in
78
- > `lorewiki search --raw` output, prefix the command with
79
- > `chcp 65001 |` to force the shell code page to UTF-8, or upgrade
80
- > to v0.1.1+ which forces UTF-8 stdout automatically.
116
+ > **Windows PowerShell + CJK note**: starting with 0.2.0, LoreWiki
117
+ > forces UTF-8 on stdout/stderr unconditionally CJK characters
118
+ > round-trip cleanly through the shell without `chcp 65001`. If you
119
+ > hit garbled output on an older release, upgrade with
120
+ > `uv tool upgrade lorewiki` or prefix the command with
121
+ > `chcp 65001 |`.
122
+
123
+ For deeper install info (PATH troubleshooting, where data lives,
124
+ backups, common errors, how publishing works), see
125
+ [`docs/install.md`](docs/install.md).
81
126
 
82
127
  ## Quickstart
83
128
 
84
129
  ```bash
85
- # 1. Create a wiki + config
130
+ # 1. Create a wiki + sample Markdown
86
131
  lorewiki init --path ./my-wiki
87
132
 
88
- # 2. Author Markdown under ./my-wiki/, then index it
133
+ # 2. Index the Markdown into SQLite + FTS5 (one-time, then incremental)
89
134
  lorewiki index --path ./my-wiki
90
135
 
91
- # 3. Search
136
+ # 3. Search (default output is structured JSON for agents; --human for Rich Table)
92
137
  lorewiki search "用户登录接口" --path ./my-wiki --mode mix --top-k 5
138
+ lorewiki search "用户登录接口" --path ./my-wiki --mode mix --top-k 5 --human
93
139
 
94
140
  # 4. Ask (LLM-assisted answer, gracefully falls back to top chunks)
95
141
  lorewiki ask "如何实现幂等重试" --path ./my-wiki
96
142
 
97
- # 5. Or author a note from the CLI (writes + re-indexes in one go)
98
- echo "Some deep details about Python design pattern." \
99
- | lorewiki add --title "Python Design" --module "patterns" --tag python,design
143
+ # 5. Author a note from the CLI (writes + re-indexes in one go)
144
+ # Three equivalent ways to provide the body:
145
+ lorewiki add --title "Python Design" --module "patterns" --tag python,design \
146
+ --body "Some deep details about Python design patterns." \
147
+ --path ./my-wiki
148
+
149
+ # --file: read the body from a file
150
+ lorewiki add --title "From File" --module "patterns" \
151
+ --file ./drafts/python-design.md --path ./my-wiki
152
+
153
+ # stdin pipe (any of these is fine on Windows + PowerShell, even
154
+ # with CJK content; 0.2.2+ scrubs UTF-16 surrogates automatically)
155
+ echo "Some deep details about Python design patterns." \
156
+ | lorewiki add --title "From Pipe" --module "patterns" --path ./my-wiki
100
157
 
101
- # 6. Browse the index status
158
+ # 6. Browse the index / hierarchy / status
102
159
  lorewiki status --path ./my-wiki
160
+ lorewiki tree --path ./my-wiki # Rich-Tree view of the hierarchy
161
+ lorewiki show index.md --path ./my-wiki # print a doc body (cleaned)
103
162
  ```
104
163
 
105
- The default config lives in `<wiki>/.lorewiki/config.toml`; user-wide
106
- overrides live in `~/.lorewiki/config.toml`; env vars `LOREWIKI_*` override
107
- both.
164
+ **Config resolution** (later wins):
165
+
166
+ 1. `<wiki>/.lorewiki/config.toml` — per-wiki defaults
167
+ 2. `~/.lorewiki/config.toml` — user-wide overrides
168
+ 3. `LOREWIKI_*` env vars — shell-level overrides
169
+
170
+ Edit any of these with `lorewiki config list / get / set` (TOML-aware,
171
+ no hand-editing required).
108
172
 
109
173
  ## Topics — your second brain
110
174
 
@@ -292,7 +356,7 @@ See `docs/lorewiki dev document.md` for the full design plan and
292
356
  ```bash
293
357
  pip install -e ".[dev]"
294
358
  ruff check lorewiki skills tests # lint
295
- pytest -q # 240 unit + integration tests
359
+ pytest -q # 241 unit + integration tests
296
360
  pytest --cov=lorewiki # coverage report
297
361
  ```
298
362
 
@@ -1,4 +1,4 @@
1
1
  """LoreWiki - Local-first knowledge base for LLM-assisted coding."""
2
2
 
3
- __version__ = "0.2.2"
3
+ __version__ = "0.2.4"
4
4
  __all__ = ["__version__"]
@@ -150,9 +150,11 @@ def main(
150
150
  "--topic",
151
151
  "-t",
152
152
  help=(
153
- "Active knowledge topic for this invocation. Overrides "
154
- "LOREWIKI_TOPIC env and ~/lorewiki/current. Use `lorewiki "
155
- "topic list` to see available topics."
153
+ "Active knowledge topic NAME for this invocation. Overrides "
154
+ "the LOREWIKI_TOPIC env var and ~/lorewiki/current. "
155
+ "Note: this is the OPTION form — to manage topics "
156
+ "(list / create / use / delete), use the `topic` subcommand. "
157
+ "Example: --topic react search 'useState closure'."
156
158
  ),
157
159
  ),
158
160
  ] = None,
@@ -126,7 +126,14 @@ def index(
126
126
  typer.Option("--rebuild", help="Drop and rebuild the index from scratch."),
127
127
  ] = False,
128
128
  ) -> None:
129
- """Index a directory of Markdown files into SQLite + FTS5."""
129
+ """Build or rebuild the SQLite + FTS5 index for a wiki directory.
130
+
131
+ Scans every ``.md`` file under the wiki, parses Markdown (with
132
+ frontmatter), and writes the index. By default this is incremental
133
+ — files whose content hash hasn't changed are skipped, so
134
+ re-running on a large wiki is fast. Pass ``--rebuild`` to wipe
135
+ the existing index and start from scratch.
136
+ """
130
137
  cfg = resolve_config(path)
131
138
  if not cfg.wiki_path.exists():
132
139
  console.print(
@@ -304,7 +311,13 @@ def update(
304
311
  typer.Option("--watch", help="Watch for file changes and re-index incrementally."),
305
312
  ] = False,
306
313
  ) -> None:
307
- """Incrementally update the index."""
314
+ """Re-index only files that changed since the last index run.
315
+
316
+ Today ``update`` is functionally equivalent to ``index`` — the
317
+ indexer is already incremental. The split is kept so a future
318
+ watcher (phase 6) can plug into the same surface without a
319
+ breaking change.
320
+ """
308
321
  phase_pending("update", "phase 6 (incremental enhancements)")
309
322
 
310
323
 
@@ -332,10 +345,13 @@ def ask(
332
345
  typer.Option("--raw", help="Print the answer + hits as JSON."),
333
346
  ] = False,
334
347
  ) -> None:
335
- """Retrieve relevant chunks and ask the LLM to compose an answer.
348
+ """Compose an answer from the top-k retrieved chunks.
336
349
 
337
- Gracefully degrades to "show the top chunks" if the LLM is disabled or
338
- unreachable, so the command always returns useful output.
350
+ Requires ``[llm]`` to be enabled and reachable in the wiki config
351
+ (``lorewiki config list`` to inspect). If the LLM is disabled or
352
+ the backend is unreachable, ``ask`` gracefully degrades to
353
+ printing the top chunks with a "degraded" notice — your workflow
354
+ never breaks because the model is down.
339
355
  """
340
356
  cfg = resolve_config(path)
341
357
  if cfg.db_path is None or not cfg.db_path.exists():
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "lorewiki"
7
- version = "0.2.2"
7
+ version = "0.2.4"
8
8
  description = "Local-first knowledge base for LLM-assisted coding, with hybrid retrieval (BM25 + hierarchy + optional vector) over SQLite FTS5."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes