@biaoo/tiangong-wiki 0.2.0
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.
- package/LICENSE +21 -0
- package/README.md +167 -0
- package/README.zh-CN.md +167 -0
- package/SKILL.md +116 -0
- package/agents/openai.yaml +4 -0
- package/assets/config.example.env +18 -0
- package/assets/templates/achievement.md +32 -0
- package/assets/templates/bridge.md +33 -0
- package/assets/templates/concept.md +47 -0
- package/assets/templates/faq.md +31 -0
- package/assets/templates/lesson.md +31 -0
- package/assets/templates/method.md +31 -0
- package/assets/templates/misconception.md +35 -0
- package/assets/templates/person.md +31 -0
- package/assets/templates/research-note.md +34 -0
- package/assets/templates/resume.md +34 -0
- package/assets/templates/source-summary.md +35 -0
- package/assets/vllm/qwen3_5_openai_developer.jinja +182 -0
- package/assets/wiki.config.default.json +193 -0
- package/dist/commands/check-config.js +77 -0
- package/dist/commands/create.js +32 -0
- package/dist/commands/daemon.js +186 -0
- package/dist/commands/dashboard.js +112 -0
- package/dist/commands/doctor.js +22 -0
- package/dist/commands/export-graph.js +28 -0
- package/dist/commands/export-index.js +31 -0
- package/dist/commands/find.js +36 -0
- package/dist/commands/fts.js +32 -0
- package/dist/commands/graph.js +35 -0
- package/dist/commands/init.js +48 -0
- package/dist/commands/lint.js +35 -0
- package/dist/commands/list.js +28 -0
- package/dist/commands/page-info.js +24 -0
- package/dist/commands/search.js +32 -0
- package/dist/commands/setup.js +15 -0
- package/dist/commands/stat.js +20 -0
- package/dist/commands/sync.js +38 -0
- package/dist/commands/template.js +71 -0
- package/dist/commands/type.js +88 -0
- package/dist/commands/vault.js +64 -0
- package/dist/core/agent.js +201 -0
- package/dist/core/cli-env.js +129 -0
- package/dist/core/codex-workflow.js +233 -0
- package/dist/core/config.js +126 -0
- package/dist/core/db.js +292 -0
- package/dist/core/embedding.js +104 -0
- package/dist/core/frontmatter.js +287 -0
- package/dist/core/indexer.js +241 -0
- package/dist/core/onboarding.js +967 -0
- package/dist/core/page-files.js +91 -0
- package/dist/core/paths.js +161 -0
- package/dist/core/presenters.js +23 -0
- package/dist/core/query.js +58 -0
- package/dist/core/runtime.js +20 -0
- package/dist/core/sync.js +235 -0
- package/dist/core/synology.js +412 -0
- package/dist/core/template-evolution.js +38 -0
- package/dist/core/vault-processing.js +742 -0
- package/dist/core/vault.js +594 -0
- package/dist/core/workflow-context.js +188 -0
- package/dist/core/workflow-result.js +162 -0
- package/dist/core/workspace-bootstrap.js +30 -0
- package/dist/core/workspace-skills.js +220 -0
- package/dist/daemon/client.js +147 -0
- package/dist/daemon/server.js +807 -0
- package/dist/daemon/state.js +53 -0
- package/dist/dashboard/assets/index-1FgAUZ28.css +1 -0
- package/dist/dashboard/assets/index-6A0PWT4X.js +154 -0
- package/dist/dashboard/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-cyrillic-500-normal-DJqRU3vO.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-cyrillic-500-normal-DmUKJPL_.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-cyrillic-700-normal-BWTpRfYl.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-cyrillic-700-normal-CEoEElIJ.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-greek-500-normal-D7SFKleX.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-greek-500-normal-JpySY46c.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-greek-700-normal-C6CZE3T8.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-greek-700-normal-DEigVDxa.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-700-normal-BYuf6tUa.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-700-normal-D3wTyLJW.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-ext-500-normal-ckzbgY84.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-ext-700-normal-CZipNAKV.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-ext-700-normal-CxPITLHs.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-vietnamese-500-normal-DNRqzVM1.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-vietnamese-700-normal-BDLVIk2r.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-400-normal-BnQMeOim.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-400-normal-CJ-V5oYT.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-500-normal-CNSSEhBt.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-500-normal-lFbtlQH6.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-700-normal-CwsQ-cCU.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-700-normal-RjhwGPKo.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-ext-400-normal-CfP_5XZW.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-ext-400-normal-DRPE3kg4.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-ext-500-normal-3dgZTiw9.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-ext-500-normal-DUe3BAxM.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-ext-700-normal-BQnZhY3m.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-ext-700-normal-HVCqSBdx.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-vietnamese-400-normal-B7xT_GF5.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-vietnamese-400-normal-BIWiOVfw.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-vietnamese-500-normal-BTqKIpxg.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-vietnamese-500-normal-BmEvtly_.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-vietnamese-700-normal-DMty7AZE.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-vietnamese-700-normal-Duxec5Rn.woff +0 -0
- package/dist/dashboard/index.html +18 -0
- package/dist/index.js +86 -0
- package/dist/operations/dashboard.js +1231 -0
- package/dist/operations/export.js +110 -0
- package/dist/operations/query.js +649 -0
- package/dist/operations/type-template.js +210 -0
- package/dist/operations/write.js +143 -0
- package/dist/types/config.js +1 -0
- package/dist/types/page.js +1 -0
- package/dist/utils/case.js +22 -0
- package/dist/utils/errors.js +26 -0
- package/dist/utils/fs.js +77 -0
- package/dist/utils/output.js +33 -0
- package/dist/utils/process.js +60 -0
- package/dist/utils/segmenter.js +24 -0
- package/dist/utils/slug.js +10 -0
- package/dist/utils/time.js +24 -0
- package/package.json +64 -0
- package/references/cli-interface.md +312 -0
- package/references/env.md +122 -0
- package/references/template-design-guide.md +271 -0
- package/references/vault-to-wiki-instruction.md +110 -0
- package/references/wiki-maintenance-instruction.md +190 -0
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@biaoo/tiangong-wiki",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Local-first wiki index and query engine for Markdown knowledge pages (Tiangong Wiki).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/Biaoo/tiangong-wiki.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/Biaoo/tiangong-wiki#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/Biaoo/tiangong-wiki/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"bin": {
|
|
19
|
+
"tiangong-wiki": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"assets",
|
|
25
|
+
"references",
|
|
26
|
+
"agents",
|
|
27
|
+
"SKILL.md"
|
|
28
|
+
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "npm run build:cli && npm run build:dashboard",
|
|
34
|
+
"build:cli": "tsc -p tsconfig.json",
|
|
35
|
+
"build:dashboard": "vite build --config dashboard/vite.config.ts",
|
|
36
|
+
"clean": "rm -rf dist node_modules/.vitest node_modules/.vite",
|
|
37
|
+
"dev": "tsx src/index.ts",
|
|
38
|
+
"dev:dashboard": "vite --config dashboard/vite.config.ts",
|
|
39
|
+
"test": "npm run build && vitest run",
|
|
40
|
+
"test:watch": "vitest"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@antv/g6": "^5.1.0",
|
|
44
|
+
"@fontsource/jetbrains-mono": "^5.2.8",
|
|
45
|
+
"@fontsource/space-grotesk": "^5.2.10",
|
|
46
|
+
"@openai/codex-sdk": "^0.118.0",
|
|
47
|
+
"adm-zip": "^0.5.17",
|
|
48
|
+
"better-sqlite3": "^12.8.0",
|
|
49
|
+
"commander": "^14.0.3",
|
|
50
|
+
"gray-matter": "^4.0.3",
|
|
51
|
+
"preact": "^10.29.1",
|
|
52
|
+
"sqlite-vec": "^0.1.9"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@preact/preset-vite": "^2.10.5",
|
|
56
|
+
"@types/adm-zip": "^0.5.8",
|
|
57
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
58
|
+
"@types/node": "^24.5.2",
|
|
59
|
+
"tsx": "^4.21.0",
|
|
60
|
+
"typescript": "^6.0.2",
|
|
61
|
+
"vite": "^8.0.7",
|
|
62
|
+
"vitest": "^4.1.2"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# CLI Reference
|
|
2
|
+
|
|
3
|
+
All commands are invoked through a single entry point:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# Global install
|
|
7
|
+
tiangong-wiki <command> [options]
|
|
8
|
+
|
|
9
|
+
# npx
|
|
10
|
+
npx @biaoo/tiangong-wiki <command> [options]
|
|
11
|
+
|
|
12
|
+
# Development
|
|
13
|
+
npm run dev -- <command> [options]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Command Overview
|
|
19
|
+
|
|
20
|
+
| Command | Description |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| `setup` | Interactive configuration wizard — writes `.wiki.env` and scaffolds workspace |
|
|
23
|
+
| `doctor` | Diagnose configuration, paths, embedding, and daemon health |
|
|
24
|
+
| `init` | Initialize workspace assets and run the first sync |
|
|
25
|
+
| `sync` | Incrementally sync pages, embeddings, and vault metadata |
|
|
26
|
+
| `check-config` | Validate environment variables, config, and templates |
|
|
27
|
+
| `find` | Query pages by structured metadata filters |
|
|
28
|
+
| `search` | Semantic search over page summary embeddings |
|
|
29
|
+
| `fts` | Full-text search over title, tags, and summary text |
|
|
30
|
+
| `graph` | Traverse the knowledge graph from a root node |
|
|
31
|
+
| `page-info` | Show full metadata and edges for a single page |
|
|
32
|
+
| `list` | List wiki pages |
|
|
33
|
+
| `stat` | Show aggregate index statistics |
|
|
34
|
+
| `create` | Create a new page from a registered template |
|
|
35
|
+
| `template` | List, show, or create wiki templates |
|
|
36
|
+
| `type` | Inspect and recommend page types |
|
|
37
|
+
| `vault` | Inspect vault files and changelog entries |
|
|
38
|
+
| `lint` | Validate pages, references, and graph integrity |
|
|
39
|
+
| `export-graph` | Export graph nodes and edges as JSON |
|
|
40
|
+
| `export-index` | Export a human-readable Markdown index |
|
|
41
|
+
| `daemon` | Manage the background HTTP daemon |
|
|
42
|
+
| `dashboard` | Open the web dashboard in a browser |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Command Details
|
|
47
|
+
|
|
48
|
+
### setup
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
tiangong-wiki setup
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Interactive step-by-step wizard that:
|
|
55
|
+
|
|
56
|
+
- Records `WIKI_PATH`, `VAULT_PATH`, `WIKI_DB_PATH`, `WIKI_CONFIG_PATH`, `WIKI_TEMPLATES_PATH`
|
|
57
|
+
- Optionally configures `EMBEDDING_*` and Synology vault settings
|
|
58
|
+
- Writes `.wiki.env` in the current working directory
|
|
59
|
+
- Scaffolds `wiki/pages/`, `vault/`, `wiki.config.json`, and `templates/`
|
|
60
|
+
|
|
61
|
+
After setup, run `tiangong-wiki doctor` then `tiangong-wiki init` to complete initialization.
|
|
62
|
+
|
|
63
|
+
### doctor
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
tiangong-wiki doctor [--probe] [--format text|json]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
| Option | Description |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `--probe` | Additionally test remote services (embedding endpoint, Synology NAS) |
|
|
72
|
+
| `--format` | Output format: `text` (default) or `json` |
|
|
73
|
+
|
|
74
|
+
Checks: `.wiki.env` loading, path existence, database accessibility, config validity, template completeness, embedding configuration, and daemon status. Exit code `2` on errors.
|
|
75
|
+
|
|
76
|
+
### init
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
tiangong-wiki init [--force]
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
| Option | Description |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| `--force` | Force a full rebuild of the index |
|
|
85
|
+
|
|
86
|
+
Creates `index.db` (if needed), builds tables according to `wiki.config.json` (including dynamic columns), and runs the first full sync.
|
|
87
|
+
|
|
88
|
+
### sync
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
tiangong-wiki sync [options]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
| Option | Description |
|
|
95
|
+
| --- | --- |
|
|
96
|
+
| `--path <pagePath>` | Sync only a single page (page-only, no vault scan) |
|
|
97
|
+
| `--force` | Force a full rebuild (ignore content_hash) |
|
|
98
|
+
| `--skip-embedding` | Skip embedding generation |
|
|
99
|
+
| `--process` | Process vault queue items after sync |
|
|
100
|
+
| `--vault-file <fileId>` | Process only one vault queue item |
|
|
101
|
+
|
|
102
|
+
When `--path` is used, vault scanning is skipped. If a global config or embedding profile change is detected, `--path` automatically upgrades to a full sync.
|
|
103
|
+
|
|
104
|
+
### check-config
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
tiangong-wiki check-config [--probe] [--format text|json]
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Validates environment variables, `wiki.config.json`, and template files. With `--probe`, also tests embedding API connectivity.
|
|
111
|
+
|
|
112
|
+
### find
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
tiangong-wiki find [options]
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
| Option | Description |
|
|
119
|
+
| --- | --- |
|
|
120
|
+
| `--type <pageType>` | Filter by page type |
|
|
121
|
+
| `--status <status>` | Filter by status |
|
|
122
|
+
| `--visibility <vis>` | Filter by visibility |
|
|
123
|
+
| `--tag <tag>` | Filter by tag |
|
|
124
|
+
| `--node-id <nodeId>` | Filter by node ID |
|
|
125
|
+
| `--updated-after <date>` | Filter by updatedAt >= date |
|
|
126
|
+
| `--sort <column>` | Sort column |
|
|
127
|
+
| `--limit <n>` | Max rows (default: 50) |
|
|
128
|
+
|
|
129
|
+
Supports custom columns declared in `wiki.config.json` as additional `--<column> <value>` filters.
|
|
130
|
+
|
|
131
|
+
Output: JSON array to stdout.
|
|
132
|
+
|
|
133
|
+
### search
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
tiangong-wiki search <query> [--type <pageType>] [--limit <n>]
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Semantic similarity search. The query is embedded via the configured embedding API and matched against `vec_pages`. Requires `EMBEDDING_*` environment variables.
|
|
140
|
+
|
|
141
|
+
Output: JSON array with `similarity` scores.
|
|
142
|
+
|
|
143
|
+
### fts
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
tiangong-wiki fts <query> [--type <pageType>] [--limit <n>]
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Full-text search against the `pages_fts` table (title, tags, summary_text). Default limit: 20.
|
|
150
|
+
|
|
151
|
+
### graph
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
tiangong-wiki graph <root> [options]
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
| Option | Description |
|
|
158
|
+
| --- | --- |
|
|
159
|
+
| `--depth <n>` | Traversal depth (default: 1) |
|
|
160
|
+
| `--edge-type <type>` | Filter by edge type |
|
|
161
|
+
| `--direction <dir>` | `outgoing`, `incoming`, or `both` (default: both) |
|
|
162
|
+
|
|
163
|
+
Returns `{ root, nodes[], edges[] }` as JSON.
|
|
164
|
+
|
|
165
|
+
### page-info
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
tiangong-wiki page-info <pageId>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Returns full indexed metadata for one page: all frontmatter fields, incoming/outgoing edges, embedding status, and content hash.
|
|
172
|
+
|
|
173
|
+
### list
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
tiangong-wiki list [--type <pageType>] [--sort <column>] [--limit <n>]
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Compact listing with title, pageType, status, updatedAt, and filePath. Default sort: `updatedAt`, default limit: 50.
|
|
180
|
+
|
|
181
|
+
### stat
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
tiangong-wiki stat
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Aggregate statistics: total pages, breakdown by type/status, total edges, orphan count, embedding status, vault file count, last sync time, and registered template count.
|
|
188
|
+
|
|
189
|
+
### create
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
tiangong-wiki create --type <pageType> --title <title> [--node-id <nodeId>]
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Creates a page from the corresponding template in `wiki/templates/`, fills frontmatter fields (title, createdAt, updatedAt, etc.), writes to `wiki/pages/`, and immediately indexes it.
|
|
196
|
+
|
|
197
|
+
Output: `{ created, filePath }`.
|
|
198
|
+
|
|
199
|
+
### template
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
tiangong-wiki template list [--format text|json]
|
|
203
|
+
tiangong-wiki template show <pageType> [--format text|json]
|
|
204
|
+
tiangong-wiki template create --type <pageType> --title <title>
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
- `list` — Show registered templates
|
|
208
|
+
- `show` — Display template content for a specific type
|
|
209
|
+
- `create` — Generate a new template file in `wiki/templates/` and register it in `wiki.config.json`
|
|
210
|
+
|
|
211
|
+
### type
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
tiangong-wiki type list [--format text|json]
|
|
215
|
+
tiangong-wiki type show <pageType> [--format text|json]
|
|
216
|
+
tiangong-wiki type recommend [--text <text>] [--keywords <kw>] [--limit <n>] [--format text|json]
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
- `list` — List all registered page types with their columns, edges, and summary fields
|
|
220
|
+
- `show` — Show full schema for one type
|
|
221
|
+
- `recommend` — Suggest page types based on vector similarity against existing pages (requires embeddings)
|
|
222
|
+
|
|
223
|
+
### vault
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
tiangong-wiki vault list [--path <prefix>] [--ext <ext>]
|
|
227
|
+
tiangong-wiki vault diff [--since <date>] [--path <prefix>]
|
|
228
|
+
tiangong-wiki vault queue [--status pending|processing|done|skipped|error]
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
- `list` — List indexed vault files; `--path` does prefix matching on relative paths
|
|
232
|
+
- `diff` — Show changes since the last sync (or since a given date with `--since`)
|
|
233
|
+
- `queue` — Show processing queue status and item details
|
|
234
|
+
|
|
235
|
+
### lint
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
tiangong-wiki lint [--path <pagePath>] [--level error|warning|info] [--format text|json]
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Validates all pages (or a single page with `--path`) for integrity issues at three severity levels:
|
|
242
|
+
|
|
243
|
+
- **error** — Missing required fields, unregistered pageType, broken references
|
|
244
|
+
- **warning** — Orphan pages, empty sourceRefs, stale active pages, references to archived pages
|
|
245
|
+
- **info** — Unregistered frontmatter fields, draft count, pending embeddings
|
|
246
|
+
|
|
247
|
+
### export-graph
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
tiangong-wiki export-graph [--output <filePath>]
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Exports all graph nodes (pages with node IDs) and edges as JSON. Prints to stdout by default; `--output` writes to a file.
|
|
254
|
+
|
|
255
|
+
### export-index
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
tiangong-wiki export-index [--output <filePath>] [--group-by pageType|tags]
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Generates a human-readable Markdown index of all pages. Default grouping: `pageType`.
|
|
262
|
+
|
|
263
|
+
### daemon
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
tiangong-wiki daemon run # Foreground (for process managers)
|
|
267
|
+
tiangong-wiki daemon start # Background (detached process)
|
|
268
|
+
tiangong-wiki daemon stop
|
|
269
|
+
tiangong-wiki daemon status [--format text|json]
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
The daemon provides a local HTTP server (binds to `127.0.0.1` only) for the web dashboard and accelerated query routing. When running, query commands automatically use HTTP instead of direct database access.
|
|
273
|
+
|
|
274
|
+
### dashboard
|
|
275
|
+
|
|
276
|
+
```
|
|
277
|
+
tiangong-wiki dashboard [--no-open] [--format text|json]
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Opens the web dashboard in the default browser. Starts the daemon automatically if it is not already running. Use `--no-open` to print the URL without opening a browser.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## Output Conventions
|
|
285
|
+
|
|
286
|
+
### Exit Codes
|
|
287
|
+
|
|
288
|
+
| Code | Meaning |
|
|
289
|
+
| --- | --- |
|
|
290
|
+
| `0` | Success |
|
|
291
|
+
| `1` | Runtime error |
|
|
292
|
+
| `2` | Configuration error |
|
|
293
|
+
|
|
294
|
+
### Output Formats
|
|
295
|
+
|
|
296
|
+
| Type | Commands | Default Output | Machine-Readable Option |
|
|
297
|
+
| --- | --- | --- | --- |
|
|
298
|
+
| Query | find, search, fts, graph, page-info, list, stat, vault list/diff/queue | JSON to stdout | — (default is JSON) |
|
|
299
|
+
| Mutation | init, sync, create, template create | JSON to stdout | — (default is JSON) |
|
|
300
|
+
| Wizard | setup | Interactive text | — |
|
|
301
|
+
| Validation | lint | Human-readable text | `--format json` |
|
|
302
|
+
| Export | export-graph | JSON | — |
|
|
303
|
+
| Export | export-index | Markdown | — |
|
|
304
|
+
| Info | doctor, check-config, template list/show, type list/show/recommend, daemon status, dashboard | Human-readable text | `--format json` |
|
|
305
|
+
|
|
306
|
+
### Error Output
|
|
307
|
+
|
|
308
|
+
Runtime and configuration errors are written to stderr as JSON:
|
|
309
|
+
|
|
310
|
+
```json
|
|
311
|
+
{ "error": "...", "type": "config | runtime | not_found | not_configured" }
|
|
312
|
+
```
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Environment Variables
|
|
2
|
+
|
|
3
|
+
All configuration is managed through `.wiki.env` (created by `tiangong-wiki setup`). Variables can also be set in shell environment or a `.env` file.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Core
|
|
8
|
+
|
|
9
|
+
| Variable | Required | Description |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| `WIKI_PATH` | Yes | Path to the Markdown pages directory |
|
|
12
|
+
| `WIKI_DB_PATH` | Yes | Path to the SQLite index database |
|
|
13
|
+
| `WIKI_CONFIG_PATH` | Yes | Path to `wiki.config.json` |
|
|
14
|
+
| `WIKI_TEMPLATES_PATH` | Yes | Path to the templates directory |
|
|
15
|
+
| `WIKI_SYNC_INTERVAL` | No | Auto-sync interval in seconds (default: `86400`) |
|
|
16
|
+
|
|
17
|
+
## Vault
|
|
18
|
+
|
|
19
|
+
| Variable | Required | Description |
|
|
20
|
+
| --- | --- | --- |
|
|
21
|
+
| `VAULT_PATH` | Yes | Path to the local vault directory |
|
|
22
|
+
| `VAULT_SOURCE` | Yes | Vault source type (`local` or `synology`) |
|
|
23
|
+
| `VAULT_HASH_MODE` | No | Hash mode for change detection (`content` or `mtime`, default: `mtime`) |
|
|
24
|
+
| `VAULT_SYNOLOGY_REMOTE_PATH` | If `synology` | Remote path on Synology NAS |
|
|
25
|
+
|
|
26
|
+
## Synology (when `VAULT_SOURCE=synology`)
|
|
27
|
+
|
|
28
|
+
| Variable | Required | Description |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| `SYNOLOGY_BASE_URL` | Yes | Synology DSM base URL |
|
|
31
|
+
| `SYNOLOGY_USERNAME` | Yes | DSM username |
|
|
32
|
+
| `SYNOLOGY_PASSWORD` | Yes | DSM password |
|
|
33
|
+
| `SYNOLOGY_VERIFY_SSL` | No | Verify SSL certificates (default: `true`) |
|
|
34
|
+
| `SYNOLOGY_READONLY` | No | Read-only mode (default: `false`) |
|
|
35
|
+
|
|
36
|
+
## Embedding
|
|
37
|
+
|
|
38
|
+
| Variable | Required | Description |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| `EMBEDDING_BASE_URL` | Yes | Embedding API base URL |
|
|
41
|
+
| `EMBEDDING_API_KEY` | Yes | Embedding API key |
|
|
42
|
+
| `EMBEDDING_MODEL` | Yes | Embedding model name |
|
|
43
|
+
| `EMBEDDING_DIMENSIONS` | No | Vector dimensions (default: model-dependent) |
|
|
44
|
+
|
|
45
|
+
## Agent (Agentic Workflow)
|
|
46
|
+
|
|
47
|
+
The agent uses [Codex SDK](https://www.npmjs.com/package/@openai/codex-sdk) to process vault items. When `WIKI_AGENT_BASE_URL` is set, a custom `model_provider` is injected to override any global `~/.codex/config.toml` settings, ensuring requests go to the correct endpoint.
|
|
48
|
+
|
|
49
|
+
| Variable | Required | Description |
|
|
50
|
+
| --- | --- | --- |
|
|
51
|
+
| `WIKI_AGENT_ENABLED` | No | Enable agentic workflow (`true` / `false`, default: `false`) |
|
|
52
|
+
| `WIKI_AGENT_BASE_URL` | No | LLM API base URL (e.g. `https://api.openai.com/v1`). When set, overrides global Codex config |
|
|
53
|
+
| `WIKI_AGENT_API_KEY` | If enabled | API key for the LLM provider |
|
|
54
|
+
| `WIKI_AGENT_MODEL` | No | Model name (e.g. `gpt-5.4`, `Qwen/Qwen3.5-397B-A17B-GPTQ-Int4`) |
|
|
55
|
+
| `WIKI_AGENT_BATCH_SIZE` | No | Max concurrent vault items per batch (default: `5`) |
|
|
56
|
+
| `WIKI_PARSER_SKILLS` | No | Comma-separated parser skill list (e.g. `pdf,docx,pptx,xlsx`) |
|
|
57
|
+
|
|
58
|
+
### OpenAI (default)
|
|
59
|
+
|
|
60
|
+
No special setup required. Set `WIKI_AGENT_BASE_URL` to `https://api.openai.com/v1` (or leave empty) and provide your API key.
|
|
61
|
+
|
|
62
|
+
```env
|
|
63
|
+
WIKI_AGENT_ENABLED=true
|
|
64
|
+
WIKI_AGENT_API_KEY=sk-...
|
|
65
|
+
WIKI_AGENT_MODEL=gpt-5.4
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### vLLM
|
|
69
|
+
|
|
70
|
+
vLLM can serve as a self-hosted LLM provider via its OpenAI-compatible API. Wiki's agentic workflow communicates through the [Responses API](https://platform.openai.com/docs/api-reference/responses) (`/v1/responses`), which requires vLLM **v0.8.5+**.
|
|
71
|
+
|
|
72
|
+
```env
|
|
73
|
+
WIKI_AGENT_ENABLED=true
|
|
74
|
+
WIKI_AGENT_BASE_URL=http://<host>:<port>/v1
|
|
75
|
+
WIKI_AGENT_API_KEY=<your-token>
|
|
76
|
+
WIKI_AGENT_MODEL=Qwen/Qwen3.5-397B-A17B-GPTQ-Int4
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### Chat template: `developer` role support
|
|
80
|
+
|
|
81
|
+
The Codex CLI sends `developer`-role messages (the OpenAI equivalent of `system` that can appear mid-conversation). Most model chat templates only recognize `system`, `user`, `assistant`, and `tool` — they will reject `developer` with:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
400 Bad Request: "Unexpected message role."
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Fix:** Use a modified chat template that maps `developer` → `system`. A ready-to-use template for Qwen3.5 is included at:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
assets/vllm/qwen3_5_openai_developer.jinja
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Launch vLLM with the custom template:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
vllm serve <model> \
|
|
97
|
+
--chat-template /path/to/qwen3_5_openai_developer.jinja \
|
|
98
|
+
--port 7730
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The template is derived from the official Qwen3.5 template with a single semantic change: `developer` messages are treated as `system` messages. Key modifications:
|
|
102
|
+
|
|
103
|
+
1. **Instruction prefix detection** — counts both `system` and `developer` at the start of the conversation (line 56)
|
|
104
|
+
2. **Role normalization** — `developer` → `system` throughout the conversation loop (lines 111, 160, 166)
|
|
105
|
+
|
|
106
|
+
> For other model families (LLaMA, Mistral, etc.), apply the same pattern: find `message.role == "system"` checks in the template and extend them to also match `"developer"`.
|
|
107
|
+
|
|
108
|
+
#### Verifying vLLM compatibility
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Test the /v1/responses endpoint directly
|
|
112
|
+
curl -s http://<host>:<port>/v1/responses \
|
|
113
|
+
-H "Content-Type: application/json" \
|
|
114
|
+
-H "Authorization: Bearer <token>" \
|
|
115
|
+
-d '{
|
|
116
|
+
"model": "<model-name>",
|
|
117
|
+
"input": "Say hello.",
|
|
118
|
+
"reasoning": {"effort": "low"}
|
|
119
|
+
}' | head -c 500
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
A successful response returns a JSON object with `output` containing the model's reply.
|