ai-wiki 0.1.0__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 (38) hide show
  1. ai_wiki-0.1.0/LICENSE +21 -0
  2. ai_wiki-0.1.0/PKG-INFO +16 -0
  3. ai_wiki-0.1.0/README.md +494 -0
  4. ai_wiki-0.1.0/pyproject.toml +36 -0
  5. ai_wiki-0.1.0/setup.cfg +4 -0
  6. ai_wiki-0.1.0/src/ai_wiki/__init__.py +1 -0
  7. ai_wiki-0.1.0/src/ai_wiki/catalog.py +110 -0
  8. ai_wiki-0.1.0/src/ai_wiki/cli.py +2226 -0
  9. ai_wiki-0.1.0/src/ai_wiki/index.py +842 -0
  10. ai_wiki-0.1.0/src/ai_wiki/models.py +178 -0
  11. ai_wiki-0.1.0/src/ai_wiki/quality.py +321 -0
  12. ai_wiki-0.1.0/src/ai_wiki/schemas.py +204 -0
  13. ai_wiki-0.1.0/src/ai_wiki/skill_templates/SKILL.md +196 -0
  14. ai_wiki-0.1.0/src/ai_wiki/skill_templates/ref-enrichment.md +111 -0
  15. ai_wiki-0.1.0/src/ai_wiki/skill_templates/ref-operations.md +182 -0
  16. ai_wiki-0.1.0/src/ai_wiki/skill_templates/ref-protocol.md +163 -0
  17. ai_wiki-0.1.0/src/ai_wiki/skill_templates/ref-templates.md +253 -0
  18. ai_wiki-0.1.0/src/ai_wiki/storage.py +314 -0
  19. ai_wiki-0.1.0/src/ai_wiki/utils.py +43 -0
  20. ai_wiki-0.1.0/src/ai_wiki/vector.py +139 -0
  21. ai_wiki-0.1.0/src/ai_wiki/web.py +534 -0
  22. ai_wiki-0.1.0/src/ai_wiki/wikilog.py +93 -0
  23. ai_wiki-0.1.0/src/ai_wiki.egg-info/PKG-INFO +16 -0
  24. ai_wiki-0.1.0/src/ai_wiki.egg-info/SOURCES.txt +36 -0
  25. ai_wiki-0.1.0/src/ai_wiki.egg-info/dependency_links.txt +1 -0
  26. ai_wiki-0.1.0/src/ai_wiki.egg-info/entry_points.txt +3 -0
  27. ai_wiki-0.1.0/src/ai_wiki.egg-info/requires.txt +8 -0
  28. ai_wiki-0.1.0/src/ai_wiki.egg-info/top_level.txt +1 -0
  29. ai_wiki-0.1.0/tests/test_cli.py +159 -0
  30. ai_wiki-0.1.0/tests/test_conventions.py +93 -0
  31. ai_wiki-0.1.0/tests/test_destroy.py +259 -0
  32. ai_wiki-0.1.0/tests/test_index.py +99 -0
  33. ai_wiki-0.1.0/tests/test_models.py +64 -0
  34. ai_wiki-0.1.0/tests/test_new_features.py +293 -0
  35. ai_wiki-0.1.0/tests/test_phase1_features.py +307 -0
  36. ai_wiki-0.1.0/tests/test_phase2_features.py +375 -0
  37. ai_wiki-0.1.0/tests/test_quality.py +130 -0
  38. ai_wiki-0.1.0/tests/test_storage.py +72 -0
ai_wiki-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 jungchangyong
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
ai_wiki-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: ai-wiki
3
+ Version: 0.1.0
4
+ Summary: Structured knowledge wiki CLI for AI agents
5
+ Project-URL: Homepage, https://github.com/j-dev-team/ai-wiki
6
+ Project-URL: Repository, https://github.com/j-dev-team/ai-wiki
7
+ Requires-Python: >=3.11
8
+ License-File: LICENSE
9
+ Requires-Dist: click>=8.0
10
+ Requires-Dist: pyyaml>=6.0
11
+ Requires-Dist: flask>=3.0
12
+ Requires-Dist: sqlite-vec>=0.1.6
13
+ Requires-Dist: sentence-transformers>=3.0
14
+ Provides-Extra: test
15
+ Requires-Dist: pytest>=7.0; extra == "test"
16
+ Dynamic: license-file
@@ -0,0 +1,494 @@
1
+ # AI Wiki — Structured Knowledge Encyclopedia
2
+
3
+ A CLI-based knowledge wiki system that stores, searches, and manages knowledge learned by AI assistants as **structured YAML** data.
4
+
5
+ [한국어 README](README.ko.md)
6
+
7
+ ---
8
+
9
+ ## Features
10
+
11
+ - **Structured YAML Storage** — Accumulate knowledge as key-value structured data, not markdown prose
12
+ - **FTS5 Full-Text Search** — SQLite FTS5-based keyword search for Korean and English
13
+ - **Vector Semantic Search** — `sentence-transformers` + `sqlite-vec` embedding search
14
+ - **Hybrid Search (RRF Fusion)** — Combines FTS5 + vector search via RRF (Reciprocal Rank Fusion): `score = Σ 1/(k+rank_i)`
15
+ - **Quality Gates** — 5-level automatic evaluation of confidence, sources, and verification
16
+ - **Auto Cross-Reference** — Automatic detection and bidirectional linking of related documents
17
+ - **Git Auto-Commit** — Automatic Git history recording on every document change
18
+ - **AI Agent Skill Integration** — Auto-generates skill files for Claude Code (`~/.claude/skills/`), Gemini CLI (`~/.gemini/skills/`), and GPT Codex (`~/.codex/skills/`)
19
+ - **Wiki Name Customization** — Name entered during init is displayed in the web UI header
20
+ - **Token Optimization** — Efficient operation with large document sets via DB metadata queries
21
+
22
+ ---
23
+
24
+ ## Installation
25
+
26
+ ### User Installation (pip)
27
+
28
+ ```bash
29
+ pip install ai-wiki
30
+ ai-wiki init ~/my-wiki
31
+ ```
32
+
33
+ ### Developer Installation (source)
34
+
35
+ ```bash
36
+ git clone https://github.com/j-dev-team/ai-wiki.git
37
+ cd ai-wiki
38
+ python -m venv .venv
39
+ source .venv/bin/activate # Linux/macOS
40
+ # .venv\Scripts\activate # Windows
41
+ pip install -e ".[test]"
42
+ ```
43
+
44
+ > **Windows Note**: Use `python` instead of `python3`.
45
+
46
+ ### Interactive Init Flow
47
+
48
+ `ai-wiki init` runs interactively:
49
+
50
+ 1. **Language Selection** — `English` / `한국어`
51
+ 2. **Wiki Name** — Displayed in the web UI header (saved in `.ai-wiki.yaml`)
52
+ 3. **Agent Selection** — Choose which AI agents you use (default: Claude Code)
53
+ 4. **Preset Selection** — Category structure matching your wiki's purpose
54
+
55
+ **Agent Selection UI:**
56
+
57
+ ```
58
+ Which AI agents do you use? (comma-separated numbers)
59
+ 1. Claude Code
60
+ 2. Gemini CLI
61
+ 3. GPT Codex
62
+ Select [1,2,3] (default: 1):
63
+ ```
64
+
65
+ - Default: `1` (Claude Code only)
66
+ - Multiple: `1,2` → Claude Code + Gemini CLI
67
+ - All: `1,2,3`
68
+ - Skills are installed only to the selected agent paths (saved in `.ai-wiki.yaml`)
69
+
70
+ | Preset | Description |
71
+ |--------|-------------|
72
+ | `general` | General knowledge (default) |
73
+ | `tech` | Technology & development focused |
74
+ | `business` | Business & management focused |
75
+ | `research` | Research & academic focused |
76
+
77
+ ---
78
+
79
+ ## Quick Start
80
+
81
+ ```bash
82
+ # Search documents (hybrid: FTS5 + vector auto-combined)
83
+ ai-wiki search "python"
84
+
85
+ # List documents (recent first, default 50)
86
+ ai-wiki list
87
+
88
+ # Filter by category + sort by title
89
+ ai-wiki list --category technology/python --sort title
90
+
91
+ # Pagination
92
+ ai-wiki list --limit 20 --offset 40
93
+
94
+ # Get a document
95
+ ai-wiki get <document-id>
96
+
97
+ # Create a document
98
+ ai-wiki create \
99
+ --title "Python Basics" \
100
+ --category "technology/programming" \
101
+ --tags "python,programming" \
102
+ --confidence 0.9 \
103
+ --source "https://docs.python.org" \
104
+ --content-stdin << EOF
105
+ type: knowledge
106
+ what: Python is a general-purpose interpreted programming language
107
+ creator: Guido van Rossum
108
+ release_year: 1991
109
+ paradigm:
110
+ - object-oriented
111
+ - functional
112
+ - procedural
113
+ use_cases:
114
+ - web development
115
+ - data science
116
+ - automation
117
+ - AI/ML
118
+ EOF
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Web UI
124
+
125
+ ```bash
126
+ # Start web UI
127
+ ai-wiki-web
128
+
129
+ # Default port: 5000 → http://localhost:5000
130
+ # Wiki name is read from the `name` field in .ai-wiki.yaml
131
+ ```
132
+
133
+ > **Warning**: The web UI has no authentication or authorization. Use it only on localhost and do not expose it to external networks.
134
+
135
+ ---
136
+
137
+ ## CLI Command Reference
138
+
139
+ ### Basic CRUD
140
+
141
+ | Command | Description |
142
+ |---------|-------------|
143
+ | `ai-wiki init [path]` | Initialize a new wiki (directory structure + config) |
144
+ | `ai-wiki create` | Create a new document |
145
+ | `ai-wiki get <ID>` | Get a document by ID |
146
+ | `ai-wiki update <ID>` | Update an existing document |
147
+ | `ai-wiki delete <ID> --confirm` | Delete a document |
148
+ | `ai-wiki list` | List all documents (`--sort`, `--category`, `--limit`, `--offset`) |
149
+ | `ai-wiki destroy [path]` | Destroy a wiki (remove skill files, env vars, directory) |
150
+ | `ai-wiki upgrade-skill` | Upgrade skill files to the latest version |
151
+
152
+ ### Search
153
+
154
+ | Command | Description |
155
+ |---------|-------------|
156
+ | `ai-wiki search "query"` | Hybrid search (FTS5 + vector, auto-combined via RRF) |
157
+ | `ai-wiki vsearch "query"` | Semantic vector search |
158
+ | `ai-wiki similar <ID>` | Find documents similar to a given document |
159
+ | `ai-wiki tag <tag>` | List documents with a specific tag |
160
+ | `ai-wiki tags` | List all tags and document counts |
161
+
162
+ ### Quality Management
163
+
164
+ | Command | Description |
165
+ |---------|-------------|
166
+ | `ai-wiki quality <ID>` | Single document quality report |
167
+ | `ai-wiki quality-all` | Batch quality check for all documents |
168
+ | `ai-wiki verify <ID>` | Update document verification date |
169
+ | `ai-wiki verify <ID> --human` | Mark as human-verified |
170
+ | `ai-wiki verify-queue` | List documents needing verification |
171
+ | `ai-wiki review <ID>` | Generate verification checklist |
172
+
173
+ ### Wiki Maintenance
174
+
175
+ | Command | Description |
176
+ |---------|-------------|
177
+ | `ai-wiki reindex` | Rebuild search index |
178
+ | `ai-wiki vindex` | Rebuild vector index |
179
+ | `ai-wiki lint` | Wiki health check |
180
+ | `ai-wiki lint --fix` | Health check + auto-fix |
181
+ | `ai-wiki maintain` | Run lint + quality + todo together |
182
+ | `ai-wiki backlinks <ID>` | List documents referencing this document |
183
+ | `ai-wiki sync-backlinks` | Bulk sync all bidirectional backlinks |
184
+
185
+ ### Analysis & Exploration
186
+
187
+ | Command | Description |
188
+ |---------|-------------|
189
+ | `ai-wiki stats` | Access statistics (Top N views/searches) |
190
+ | `ai-wiki gaps` | Gap analysis by category |
191
+ | `ai-wiki todo` | Auto-collected task list for the wiki |
192
+ | `ai-wiki stale` | List outdated documents (default: 90 days) |
193
+ | `ai-wiki discover` | Find isolated, low-quality, or stale documents |
194
+ | `ai-wiki path <ID1> <ID2>` | Shortest path between two documents (BFS) |
195
+ | `ai-wiki cluster` | Document topic clustering |
196
+ | `ai-wiki history <ID>` | Git change history for a document |
197
+
198
+ ### Export / Import
199
+
200
+ | Command | Description |
201
+ |---------|-------------|
202
+ | `ai-wiki export <ID>` | Export as Markdown or YAML |
203
+ | `ai-wiki export-all` | Batch export all documents |
204
+ | `ai-wiki ingest <file>` | Ingest a source file (auto-creates stub document) |
205
+
206
+ ---
207
+
208
+ ## Hybrid Search
209
+
210
+ `ai-wiki search` **automatically combines** FTS5 keyword search and vector semantic search.
211
+
212
+ - **RRF (Reciprocal Rank Fusion)** algorithm merges both result sets
213
+ - Returns a unified `hybrid_score` field
214
+ - Falls back to FTS5-only mode if vector search is not installed
215
+
216
+ ```bash
217
+ # Hybrid search (default)
218
+ ai-wiki search "machine learning python"
219
+
220
+ # Pure vector search only
221
+ ai-wiki vsearch "machine learning python"
222
+ ```
223
+
224
+ ---
225
+
226
+ ## Document Structure (YAML Schema)
227
+
228
+ ```yaml
229
+ id: tech-python-abc123
230
+ title: Python Basics
231
+ category: technology/programming
232
+ tags:
233
+ - python
234
+ - programming
235
+ confidence: 0.9
236
+ version: 1
237
+ created_at: 2026-01-01T00:00:00Z
238
+ last_modified: 2026-01-01T00:00:00Z
239
+ last_verified: 2026-01-01T00:00:00Z
240
+ sources:
241
+ - https://docs.python.org
242
+ related:
243
+ - tech-django-xyz789
244
+ author: claude
245
+ content:
246
+ type: knowledge
247
+ what: Python is a general-purpose interpreted programming language
248
+ creator: Guido van Rossum
249
+ release_year:
250
+ value: 1991
251
+ _v:
252
+ level: verified # unverified | sourced | verified | corroborated | human_verified | disputed
253
+ source: https://docs.python.org
254
+ use_cases:
255
+ - web development
256
+ - data science
257
+ _meta:
258
+ maturity: mature # stub | draft | review | mature
259
+ completeness: 0.85
260
+ _changelog:
261
+ - date: 2026-01-01T00:00:00Z
262
+ action: created
263
+ fields: [what, creator]
264
+ note: Document created
265
+ ```
266
+
267
+ ### File Storage Path
268
+
269
+ ```
270
+ articles/<category>/<subcategory>/<slug>.yaml
271
+ ```
272
+
273
+ Example: `articles/technology/programming/python-abc123.yaml`
274
+
275
+ ---
276
+
277
+ ## Quality System
278
+
279
+ ### Verification Levels (`_v`)
280
+
281
+ Track reliability by attaching `_v` metadata to factual data such as numbers, dates, and quotes.
282
+
283
+ | Level | Weight | Description |
284
+ |-------|--------|-------------|
285
+ | `unverified` | 0.0 | Not verified |
286
+ | `sourced` | 0.3 | Has a source |
287
+ | `verified` | 0.8 | Verified |
288
+ | `corroborated` | 0.8 | Cross-verified |
289
+ | `disputed` | 0.2 | Disputed |
290
+ | `human_verified` | 1.0 | Verified by a human |
291
+
292
+ ### Maturity Stages
293
+
294
+ | Stage | Description |
295
+ |-------|-------------|
296
+ | `stub` | Minimal info, needs enrichment |
297
+ | `draft` | Basic info present |
298
+ | `review` | Under review |
299
+ | `mature` | Complete document |
300
+
301
+ ### Quality Score Calculation
302
+
303
+ ```
304
+ score = structure keys (15%) + word count (20%) + sources (10%) +
305
+ tags (5%) + related docs (10%) + confidence (10%) + verification rate (30%)
306
+ ```
307
+
308
+ ---
309
+
310
+ ## Directory Structure
311
+
312
+ ```
313
+ ai_wiki/
314
+ +-- articles/ # Document YAML files (subdirectories by category)
315
+ +-- data/
316
+ | +-- wiki.db # SQLite main index (FTS5)
317
+ | +-- vectors.db # Vector embedding index
318
+ +-- sources/ # Ingested source files
319
+ +-- logs/ # Operation logs
320
+ +-- tmp/ # Temporary files
321
+ +-- src/ai_wiki/ # Package source
322
+ | +-- cli.py # CLI entry point
323
+ | +-- models.py # Article data model
324
+ | +-- storage.py # File/DB storage layer
325
+ | +-- index.py # SQLite search index
326
+ | +-- vector.py # Vector search engine
327
+ | +-- quality.py # Quality validation engine
328
+ | +-- schemas.py # Type-specific schemas
329
+ | +-- catalog.py # Catalog builder
330
+ | +-- wikilog.py # Operation logger
331
+ | +-- web.py # Web UI (Flask)
332
+ +-- tests/ # Tests
333
+ +-- .ai-wiki.yaml # Wiki configuration
334
+ +-- pyproject.toml
335
+ ```
336
+
337
+ ---
338
+
339
+ ## Wiki Operations
340
+
341
+ ### Single Wiki (Default)
342
+
343
+ Install one wiki and all AI agent projects on the system can automatically access it.
344
+
345
+ ```bash
346
+ ai-wiki init ~/my-wiki
347
+ ```
348
+
349
+ Skill files are auto-generated on init. Any agent in any project will automatically search, query, and create documents in the wiki when it receives knowledge-related questions.
350
+
351
+ ```
352
+ ~/.claude/skills/my-wiki/ <- Claude Code
353
+ ~/.gemini/skills/my-wiki/ <- Gemini CLI
354
+ ~/.codex/skills/my-wiki/ <- GPT Codex
355
+
356
+ Project A --+
357
+ Project B --+-- Share a single wiki
358
+ Project C --+
359
+ ```
360
+
361
+ ### Multi Wiki
362
+
363
+ Run multiple independent wikis on a single system.
364
+
365
+ #### Creating Wiki Instances
366
+
367
+ ```bash
368
+ # Work wiki
369
+ ai-wiki init ~/work-wiki
370
+ # -> Wiki name: "Work Wiki"
371
+ # -> Preset: business
372
+
373
+ # Personal knowledge wiki
374
+ ai-wiki init ~/knowledge-wiki
375
+ # -> Wiki name: "My Knowledge"
376
+ # -> Preset: general
377
+ ```
378
+
379
+ #### Switching Wikis
380
+
381
+ Switch the target wiki using the `AI_WIKI_ROOT` environment variable.
382
+
383
+ ```bash
384
+ # Search work wiki
385
+ AI_WIKI_ROOT=~/work-wiki ai-wiki search "client"
386
+
387
+ # Search personal wiki
388
+ AI_WIKI_ROOT=~/knowledge-wiki ai-wiki search "python"
389
+ ```
390
+
391
+ #### Agent Skill Integration
392
+
393
+ `ai-wiki init` auto-generates skill files for each selected agent. All agent projects can access all wiki skills, enabling multiple projects to share multiple wikis.
394
+
395
+ ```
396
+ ~/.claude/skills/
397
+ +-- work-wiki/SKILL.md (AI_WIKI_ROOT=~/work-wiki)
398
+ +-- knowledge-wiki/SKILL.md (AI_WIKI_ROOT=~/knowledge-wiki)
399
+
400
+ ~/.gemini/skills/
401
+ +-- work-wiki/SKILL.md (AI_WIKI_ROOT=~/work-wiki)
402
+ +-- knowledge-wiki/SKILL.md (AI_WIKI_ROOT=~/knowledge-wiki)
403
+
404
+ ~/.codex/skills/
405
+ +-- work-wiki/SKILL.md (AI_WIKI_ROOT=~/work-wiki)
406
+ +-- knowledge-wiki/SKILL.md (AI_WIKI_ROOT=~/knowledge-wiki)
407
+
408
+ Project A --+
409
+ Project B --+-- Access both wiki skills
410
+ Project C --+
411
+ ```
412
+
413
+ - **Data**: Fully isolated per wiki (separate articles/, data/)
414
+ - **Program**: Single shared ai-wiki CLI
415
+ - **Skills**: Independent skill files per wiki, accessible from all projects
416
+
417
+ ---
418
+
419
+ ## Environment Variables
420
+
421
+ | Variable | Description |
422
+ |----------|-------------|
423
+ | `AI_WIKI_ROOT` | Wiki root directory path (required) |
424
+
425
+ Automatically registered during `ai-wiki init`.
426
+
427
+ ```bash
428
+ # Manual setup (Windows)
429
+ setx AI_WIKI_ROOT "D:/dev/ai_wiki"
430
+
431
+ # Manual setup (Linux/macOS)
432
+ export AI_WIKI_ROOT="/home/user/ai_wiki"
433
+ ```
434
+
435
+ ---
436
+
437
+ ## Development / Testing
438
+
439
+ ```bash
440
+ # Activate virtual environment
441
+ source .venv/bin/activate # Linux/macOS
442
+ .venv\Scripts\activate # Windows
443
+
444
+ # Run tests
445
+ pytest
446
+
447
+ # Reinstall package (after source changes)
448
+ pip install -e .
449
+ ```
450
+
451
+ ---
452
+
453
+ ## Dependencies
454
+
455
+ | Package | Purpose |
456
+ |---------|---------|
457
+ | `click` | CLI framework |
458
+ | `pyyaml` | YAML parsing/serialization |
459
+ | `flask` | Web UI server |
460
+ | `sqlite-vec` | Vector embedding search |
461
+ | `sentence-transformers` | Multilingual embedding model |
462
+ | `pecab` *(optional)* | Korean morphological analysis |
463
+
464
+ Vector search (`vsearch`, `similar`, `vindex`) is only available when `sqlite-vec` and `sentence-transformers` are installed. FTS5 search works without them.
465
+
466
+ ---
467
+
468
+ ## AI Agent Skill Integration
469
+
470
+ Skill files are **auto-generated** during `ai-wiki init`. When an agent receives a knowledge-related question, the skill auto-triggers and uses the `ai-wiki` CLI to search, query, and create documents.
471
+
472
+ | Agent | Skill Path |
473
+ |-------|------------|
474
+ | Claude Code | `~/.claude/skills/<wiki-name>/` |
475
+ | Gemini CLI | `~/.gemini/skills/<wiki-name>/` |
476
+ | GPT Codex | `~/.codex/skills/<wiki-name>/` |
477
+
478
+ **Skills are installed only to the agents you select during init.**
479
+
480
+ - **`ai-wiki init`** — Creates skill files in the selected agent paths
481
+ - **`ai-wiki upgrade-skill`** — Updates skill files to the latest version (reads `agents` from `.ai-wiki.yaml`)
482
+ - **`ai-wiki destroy`** — Removes skill files from selected agent paths
483
+ - If `agents` field is missing, defaults to `["claude"]` (backward compatible)
484
+
485
+ ```bash
486
+ # Upgrade skill files to latest version
487
+ ai-wiki upgrade-skill
488
+ ```
489
+
490
+ ---
491
+
492
+ ## License
493
+
494
+ MIT License. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ai-wiki"
7
+ version = "0.1.0"
8
+ description = "Structured knowledge wiki CLI for AI agents"
9
+ requires-python = ">=3.11"
10
+ dependencies = [
11
+ "click>=8.0",
12
+ "pyyaml>=6.0",
13
+ "flask>=3.0",
14
+ "sqlite-vec>=0.1.6",
15
+ "sentence-transformers>=3.0",
16
+ ]
17
+
18
+ [project.urls]
19
+ Homepage = "https://github.com/j-dev-team/ai-wiki"
20
+ Repository = "https://github.com/j-dev-team/ai-wiki"
21
+
22
+ [project.scripts]
23
+ ai-wiki = "ai_wiki.cli:cli"
24
+ ai-wiki-web = "ai_wiki.web:main"
25
+
26
+ [project.optional-dependencies]
27
+ test = ["pytest>=7.0"]
28
+
29
+ [tool.pytest.ini_options]
30
+ testpaths = ["tests"]
31
+
32
+ [tool.setuptools.packages.find]
33
+ where = ["src"]
34
+
35
+ [tool.setuptools.package-data]
36
+ ai_wiki = ["skill_templates/*.md"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,110 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import sqlite3
5
+ from pathlib import Path
6
+
7
+ import yaml
8
+
9
+ from ai_wiki.storage import get_wiki_root, get_data_dir
10
+
11
+
12
+ def get_catalog_path() -> Path:
13
+ return get_wiki_root() / "index.yaml"
14
+
15
+
16
+ def _extract_summary(content: dict) -> str:
17
+ """content에서 한 줄 요약 추출. #20: what > definition > error_message > purpose 순."""
18
+ if not isinstance(content, dict):
19
+ return ""
20
+ for key in ("what", "definition", "error_message", "purpose"):
21
+ val = content.get(key)
22
+ if val and isinstance(val, str):
23
+ return val[:120]
24
+ return ""
25
+
26
+
27
+ def rebuild_catalog() -> int:
28
+ """#5: SQLite 기반 카탈로그 생성 (전체 파일 스캔 대신 DB 쿼리)."""
29
+ db_path = get_data_dir() / "wiki.db"
30
+
31
+ if not db_path.exists():
32
+ # DB 없으면 폴백
33
+ from ai_wiki.storage import list_all_articles
34
+ return _rebuild_from_articles(list_all_articles())
35
+
36
+ try:
37
+ conn = sqlite3.connect(str(db_path))
38
+ conn.row_factory = sqlite3.Row
39
+ cur = conn.cursor()
40
+ cur.execute("""
41
+ SELECT id, title, category, tags, confidence, last_modified, content_type,
42
+ maturity, quality_score
43
+ FROM articles_meta
44
+ ORDER BY category, lower(title)
45
+ """)
46
+
47
+ by_category: dict[str, list] = {}
48
+ total = 0
49
+ for row in cur.fetchall():
50
+ r = dict(row)
51
+ top_cat = r["category"].split("/")[0]
52
+ if top_cat not in by_category:
53
+ by_category[top_cat] = []
54
+
55
+ # summary: content에서 추출 필요 → 파일 읽기 (캐시된 경로로 O(1))
56
+ summary = ""
57
+ from ai_wiki.storage import load_article
58
+ article = load_article(r["id"])
59
+ if article:
60
+ summary = _extract_summary(article.content)
61
+
62
+ by_category[top_cat].append({
63
+ "id": r["id"],
64
+ "title": r["title"],
65
+ "category": r["category"],
66
+ "type": r["content_type"] or "",
67
+ "summary": summary,
68
+ "maturity": r.get("maturity", "unknown"),
69
+ "quality_score": r.get("quality_score", 0.0),
70
+ "confidence": r["confidence"],
71
+ "tags": json.loads(r["tags"] or "[]"),
72
+ "last_modified": r["last_modified"],
73
+ })
74
+ total += 1
75
+
76
+ conn.close()
77
+ except sqlite3.Error:
78
+ from ai_wiki.storage import list_all_articles
79
+ return _rebuild_from_articles(list_all_articles())
80
+
81
+ _write_catalog(total, by_category)
82
+ return total
83
+
84
+
85
+ def _rebuild_from_articles(articles) -> int:
86
+ """폴백: Article 리스트에서 카탈로그 생성."""
87
+ articles.sort(key=lambda a: a.category + "/" + a.title.lower())
88
+ by_category: dict[str, list] = {}
89
+ for a in articles:
90
+ top_cat = a.category.split("/")[0]
91
+ if top_cat not in by_category:
92
+ by_category[top_cat] = []
93
+ by_category[top_cat].append({
94
+ "id": a.id,
95
+ "title": a.title,
96
+ "category": a.category,
97
+ "type": a.content.get("type", "") if isinstance(a.content, dict) else "",
98
+ "summary": _extract_summary(a.content),
99
+ "confidence": a.confidence,
100
+ "tags": a.tags,
101
+ "last_modified": a._fmt(a.last_modified),
102
+ })
103
+ _write_catalog(len(articles), by_category)
104
+ return len(articles)
105
+
106
+
107
+ def _write_catalog(total: int, by_category: dict) -> None:
108
+ catalog = {"total": total, "categories": by_category}
109
+ with open(get_catalog_path(), "w", encoding="utf-8") as f:
110
+ yaml.dump(catalog, f, allow_unicode=True, default_flow_style=False, sort_keys=False)