lorewiki 0.2.2__tar.gz → 0.2.3__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.3}/PKG-INFO +100 -24
  2. {lorewiki-0.2.2 → lorewiki-0.2.3}/README.md +99 -23
  3. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/__init__.py +1 -1
  4. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/cli/apps.py +5 -3
  5. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/cli/commands.py +21 -5
  6. {lorewiki-0.2.2 → lorewiki-0.2.3}/pyproject.toml +1 -1
  7. {lorewiki-0.2.2 → lorewiki-0.2.3}/.gitignore +0 -0
  8. {lorewiki-0.2.2 → lorewiki-0.2.3}/LICENSE +0 -0
  9. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/__main__.py +0 -0
  10. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/cli/__init__.py +0 -0
  11. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/cli/add.py +0 -0
  12. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/cli/config_cmds.py +0 -0
  13. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/cli/helpers.py +0 -0
  14. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/cli/topic_cmds.py +0 -0
  15. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/config.py +0 -0
  16. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/db/__init__.py +0 -0
  17. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/db/connection.py +0 -0
  18. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/db/models.py +0 -0
  19. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/db/schema.sql +0 -0
  20. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/indexer/__init__.py +0 -0
  21. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/indexer/chunker.py +0 -0
  22. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/indexer/cleaning.py +0 -0
  23. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/indexer/indexer.py +0 -0
  24. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/indexer/parser.py +0 -0
  25. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/llm/__init__.py +0 -0
  26. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/llm/client.py +0 -0
  27. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/llm/generator.py +0 -0
  28. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/py.typed +0 -0
  29. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/retriever/__init__.py +0 -0
  30. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/retriever/base.py +0 -0
  31. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/retriever/bm25.py +0 -0
  32. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/retriever/fusion.py +0 -0
  33. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/retriever/hierarchy.py +0 -0
  34. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/retriever/search.py +0 -0
  35. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/retriever/vector.py +0 -0
  36. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/topic.py +0 -0
  37. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/utils/__init__.py +0 -0
  38. {lorewiki-0.2.2 → lorewiki-0.2.3}/lorewiki/utils/logger.py +0 -0
  39. {lorewiki-0.2.2 → lorewiki-0.2.3}/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.3
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,126 @@ it directly.
105
105
 
106
106
  ## Installation
107
107
 
108
+ LoreWiki ships as a Python wheel on **PyPI** (canonical) with an
109
+ **npm shim** that proxies to the same wheel. Pick one:
110
+
111
+ ### Python (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
+
108
130
  ```bash
109
- # Editable install (recommended for active development)
110
- uv tool install --editable .
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):
111
138
 
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)
139
+ ```bash
140
+ pip install lorewiki # core CLI
141
+ pip install 'lorewiki[vector]' # opt-in: vector retrieval
116
142
  ```
117
143
 
118
- Python **3.10+** required. After install, `lorewiki --version`
119
- should print `LoreWiki 0.1.0`.
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]`.
120
147
 
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.
148
+ ### Node (npm shim, identical CLI)
149
+
150
+ ```bash
151
+ npm install -g lorewiki # postinstall calls `uv tool install lorewiki`
152
+ npm install -g lorewiki@latest # upgrade
153
+ npm uninstall -g lorewiki # also runs `uv tool uninstall lorewiki`
154
+ ```
155
+
156
+ The npm package is a thin shim — it spawns the Python `lorewiki` that
157
+ the postinstall hook installed. See [`README.npm.md`](README.npm.md)
158
+ for the full story.
159
+
160
+ ### From source (for contributors)
161
+
162
+ ```bash
163
+ git clone https://github.com/JochenYang/Lore-wiki
164
+ cd Lore-wiki
165
+ uv tool install --editable . # dev install
166
+ uv tool install --editable '.[dev]' # + pytest / ruff / coverage
167
+ ```
168
+
169
+ Python **3.10+** is required. After install, `lorewiki --version`
170
+ should print a banner ending with `v0.2.x`.
171
+
172
+ > **Windows PowerShell + CJK note**: starting with 0.2.0, LoreWiki
173
+ > forces UTF-8 on stdout/stderr unconditionally — CJK characters
174
+ > round-trip cleanly through the shell without `chcp 65001`. If you
175
+ > hit garbled output on an older release, upgrade with
176
+ > `uv tool upgrade lorewiki` or prefix the command with
177
+ > `chcp 65001 |`.
178
+
179
+ For deeper install info (PATH troubleshooting, where data lives,
180
+ backups, common errors, how publishing works), see
181
+ [`docs/install.md`](docs/install.md).
125
182
 
126
183
  ## Quickstart
127
184
 
128
185
  ```bash
129
- # 1. Create a wiki + config
186
+ # 1. Create a wiki + sample Markdown
130
187
  lorewiki init --path ./my-wiki
131
188
 
132
- # 2. Author Markdown under ./my-wiki/, then index it
189
+ # 2. Index the Markdown into SQLite + FTS5 (one-time, then incremental)
133
190
  lorewiki index --path ./my-wiki
134
191
 
135
- # 3. Search
192
+ # 3. Search (default output is structured JSON for agents; --human for Rich Table)
136
193
  lorewiki search "用户登录接口" --path ./my-wiki --mode mix --top-k 5
194
+ lorewiki search "用户登录接口" --path ./my-wiki --mode mix --top-k 5 --human
137
195
 
138
196
  # 4. Ask (LLM-assisted answer, gracefully falls back to top chunks)
139
197
  lorewiki ask "如何实现幂等重试" --path ./my-wiki
140
198
 
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
199
+ # 5. Author a note from the CLI (writes + re-indexes in one go)
200
+ # Three equivalent ways to provide the body:
201
+ lorewiki add --title "Python Design" --module "patterns" --tag python,design \
202
+ --body "Some deep details about Python design patterns." \
203
+ --path ./my-wiki
204
+
205
+ # --file: read the body from a file
206
+ lorewiki add --title "From File" --module "patterns" \
207
+ --file ./drafts/python-design.md --path ./my-wiki
144
208
 
145
- # 6. Browse the index status
209
+ # stdin pipe (any of these is fine on Windows + PowerShell, even
210
+ # with CJK content; 0.2.2+ scrubs UTF-16 surrogates automatically)
211
+ echo "Some deep details about Python design patterns." \
212
+ | lorewiki add --title "From Pipe" --module "patterns" --path ./my-wiki
213
+
214
+ # 6. Browse the index / hierarchy / status
146
215
  lorewiki status --path ./my-wiki
216
+ lorewiki tree --path ./my-wiki # Rich-Tree view of the hierarchy
217
+ lorewiki show index.md --path ./my-wiki # print a doc body (cleaned)
147
218
  ```
148
219
 
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.
220
+ **Config resolution** (later wins):
221
+
222
+ 1. `<wiki>/.lorewiki/config.toml` — per-wiki defaults
223
+ 2. `~/.lorewiki/config.toml` — user-wide overrides
224
+ 3. `LOREWIKI_*` env vars — shell-level overrides
225
+
226
+ Edit any of these with `lorewiki config list / get / set` (TOML-aware,
227
+ no hand-editing required).
152
228
 
153
229
  ## Topics — your second brain
154
230
 
@@ -336,7 +412,7 @@ See `docs/lorewiki dev document.md` for the full design plan and
336
412
  ```bash
337
413
  pip install -e ".[dev]"
338
414
  ruff check lorewiki skills tests # lint
339
- pytest -q # 240 unit + integration tests
415
+ pytest -q # 241 unit + integration tests
340
416
  pytest --cov=lorewiki # coverage report
341
417
  ```
342
418
 
@@ -61,50 +61,126 @@ it directly.
61
61
 
62
62
  ## Installation
63
63
 
64
+ LoreWiki ships as a Python wheel on **PyPI** (canonical) with an
65
+ **npm shim** that proxies to the same wheel. Pick one:
66
+
67
+ ### Python (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
+
64
86
  ```bash
65
- # Editable install (recommended for active development)
66
- uv tool install --editable .
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):
67
94
 
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)
95
+ ```bash
96
+ pip install lorewiki # core CLI
97
+ pip install 'lorewiki[vector]' # opt-in: vector retrieval
72
98
  ```
73
99
 
74
- Python **3.10+** required. After install, `lorewiki --version`
75
- should print `LoreWiki 0.1.0`.
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]`.
76
103
 
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.
104
+ ### Node (npm shim, identical CLI)
105
+
106
+ ```bash
107
+ npm install -g lorewiki # postinstall calls `uv tool install lorewiki`
108
+ npm install -g lorewiki@latest # upgrade
109
+ npm uninstall -g lorewiki # also runs `uv tool uninstall lorewiki`
110
+ ```
111
+
112
+ The npm package is a thin shim — it spawns the Python `lorewiki` that
113
+ the postinstall hook installed. See [`README.npm.md`](README.npm.md)
114
+ for the full story.
115
+
116
+ ### From source (for contributors)
117
+
118
+ ```bash
119
+ git clone https://github.com/JochenYang/Lore-wiki
120
+ cd Lore-wiki
121
+ uv tool install --editable . # dev install
122
+ uv tool install --editable '.[dev]' # + pytest / ruff / coverage
123
+ ```
124
+
125
+ Python **3.10+** is required. After install, `lorewiki --version`
126
+ should print a banner ending with `v0.2.x`.
127
+
128
+ > **Windows PowerShell + CJK note**: starting with 0.2.0, LoreWiki
129
+ > forces UTF-8 on stdout/stderr unconditionally — CJK characters
130
+ > round-trip cleanly through the shell without `chcp 65001`. If you
131
+ > hit garbled output on an older release, upgrade with
132
+ > `uv tool upgrade lorewiki` or prefix the command with
133
+ > `chcp 65001 |`.
134
+
135
+ For deeper install info (PATH troubleshooting, where data lives,
136
+ backups, common errors, how publishing works), see
137
+ [`docs/install.md`](docs/install.md).
81
138
 
82
139
  ## Quickstart
83
140
 
84
141
  ```bash
85
- # 1. Create a wiki + config
142
+ # 1. Create a wiki + sample Markdown
86
143
  lorewiki init --path ./my-wiki
87
144
 
88
- # 2. Author Markdown under ./my-wiki/, then index it
145
+ # 2. Index the Markdown into SQLite + FTS5 (one-time, then incremental)
89
146
  lorewiki index --path ./my-wiki
90
147
 
91
- # 3. Search
148
+ # 3. Search (default output is structured JSON for agents; --human for Rich Table)
92
149
  lorewiki search "用户登录接口" --path ./my-wiki --mode mix --top-k 5
150
+ lorewiki search "用户登录接口" --path ./my-wiki --mode mix --top-k 5 --human
93
151
 
94
152
  # 4. Ask (LLM-assisted answer, gracefully falls back to top chunks)
95
153
  lorewiki ask "如何实现幂等重试" --path ./my-wiki
96
154
 
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
155
+ # 5. Author a note from the CLI (writes + re-indexes in one go)
156
+ # Three equivalent ways to provide the body:
157
+ lorewiki add --title "Python Design" --module "patterns" --tag python,design \
158
+ --body "Some deep details about Python design patterns." \
159
+ --path ./my-wiki
160
+
161
+ # --file: read the body from a file
162
+ lorewiki add --title "From File" --module "patterns" \
163
+ --file ./drafts/python-design.md --path ./my-wiki
100
164
 
101
- # 6. Browse the index status
165
+ # stdin pipe (any of these is fine on Windows + PowerShell, even
166
+ # with CJK content; 0.2.2+ scrubs UTF-16 surrogates automatically)
167
+ echo "Some deep details about Python design patterns." \
168
+ | lorewiki add --title "From Pipe" --module "patterns" --path ./my-wiki
169
+
170
+ # 6. Browse the index / hierarchy / status
102
171
  lorewiki status --path ./my-wiki
172
+ lorewiki tree --path ./my-wiki # Rich-Tree view of the hierarchy
173
+ lorewiki show index.md --path ./my-wiki # print a doc body (cleaned)
103
174
  ```
104
175
 
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.
176
+ **Config resolution** (later wins):
177
+
178
+ 1. `<wiki>/.lorewiki/config.toml` — per-wiki defaults
179
+ 2. `~/.lorewiki/config.toml` — user-wide overrides
180
+ 3. `LOREWIKI_*` env vars — shell-level overrides
181
+
182
+ Edit any of these with `lorewiki config list / get / set` (TOML-aware,
183
+ no hand-editing required).
108
184
 
109
185
  ## Topics — your second brain
110
186
 
@@ -292,7 +368,7 @@ See `docs/lorewiki dev document.md` for the full design plan and
292
368
  ```bash
293
369
  pip install -e ".[dev]"
294
370
  ruff check lorewiki skills tests # lint
295
- pytest -q # 240 unit + integration tests
371
+ pytest -q # 241 unit + integration tests
296
372
  pytest --cov=lorewiki # coverage report
297
373
  ```
298
374
 
@@ -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.3"
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.3"
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