@jungtz/wiki-router 1.3.0 → 1.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jungtz/wiki-router",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "LLM Wiki 知識庫路由引擎 - 將結構化知識轉為 Markdown 維基,智慧路由查詢",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -34,6 +34,7 @@
34
34
  "dev": "rollup -c -w",
35
35
  "test": "node --test",
36
36
  "preview": "node scripts/preview.js",
37
+ "preview:multi": "node scripts/preview-multi.js",
37
38
  "lint": "eslint src/",
38
39
  "lint:fix": "eslint src/ --fix",
39
40
  "format": "prettier --write src/",
package/src/types.d.ts CHANGED
@@ -17,11 +17,13 @@
17
17
 
18
18
  /**
19
19
  * @typedef {Object} Store
20
- * @property {() => Promise<string[]>} list - 列出已生成的 wiki 檔名(含副檔名)
20
+ * @property {() => Promise<string[]>} list - 列出已生成的 wiki 檔名(含副檔名);應排除非路由用的衍生檔(例如以底線開頭者)
21
21
  * @property {(filename: string) => Promise<string|null>} read - 讀取 wiki 檔;不存在回 null
22
22
  * @property {(filename: string, content: string) => Promise<void>} write - 寫入 wiki 檔
23
23
  * @property {() => Promise<Record<string, string>|null>} [readManifest] - 選用;讀取上次 build 的來源指紋;不存在回 null
24
24
  * @property {(manifest: Record<string, string>) => Promise<void>} [writeManifest] - 選用;寫入本次 build 的來源指紋
25
+ * @property {() => Promise<string|null>} [readPersona] - 選用;讀取自動產生的角色設定;不存在回 null
26
+ * @property {(persona: string) => Promise<void>} [writePersona] - 選用;寫入自動產生的角色設定
25
27
  */
26
28
 
27
29
  /**
@@ -37,17 +39,22 @@
37
39
  * @property {string} [splitPrompt] - 自訂 Split prompt 字串,未提供時使用內建預設
38
40
  * @property {string} [mergePrompt] - 自訂 Merge prompt 字串,未提供時使用內建預設
39
41
  * @property {string} [routerPrompt] - 自訂 Router prompt 字串,未提供時使用內建預設
42
+ * @property {string} [personaPrompt] - 自訂 Persona prompt 字串,未提供時使用內建預設
43
+ * @property {number} [personaSampleSize=4000] - 產 persona 時,從非 Index 檔抽取的內容總長度上限(字元)
40
44
  */
41
45
 
42
46
  /**
43
47
  * @typedef {Object} BuildOptions
44
48
  * @property {boolean} [force=false] - 為 true 時跳過 fingerprint 比對,無條件重建
49
+ * @property {boolean} [skipPersona=false] - 為 true 時 build 完不順帶產 persona
45
50
  */
46
51
 
47
52
  /**
48
53
  * @typedef {Object} WikiRouterInstance
49
54
  * @property {(options?: BuildOptions) => Promise<boolean>} build - 建構或更新 Wiki 知識庫
50
55
  * @property {(prompt: string) => Promise<string>} getContext - 根據問題取得相關 Wiki 上下文
56
+ * @property {(options?: { force?: boolean }) => Promise<boolean>} buildPersona - 依 Index.md + 內容樣本產出角色設定,寫入 store.writePersona()
57
+ * @property {() => Promise<string|null>} getPersona - 取得目前儲存的角色設定;store 不支援或尚未生成則回 null
51
58
  */
52
59
 
53
60
  /**
@@ -62,6 +69,7 @@
62
69
  * @property {string} tenantId - 多租戶識別字串
63
70
  * @property {string} [filesTable='wiki_files'] - 自訂 files 表名
64
71
  * @property {string} [manifestsTable='wiki_manifests'] - 自訂 manifests 表名
72
+ * @property {string} [personasTable='wiki_personas'] - 自訂 personas 表名
65
73
  */
66
74
 
67
75
  /**
@@ -79,6 +87,8 @@
79
87
  * @property {string} [splitPrompt] - 同 WikiRouterConfig.splitPrompt
80
88
  * @property {string} [mergePrompt] - 同 WikiRouterConfig.mergePrompt
81
89
  * @property {string} [routerPrompt] - 同 WikiRouterConfig.routerPrompt
90
+ * @property {string} [personaPrompt] - 同 WikiRouterConfig.personaPrompt
91
+ * @property {number} [personaSampleSize] - 同 WikiRouterConfig.personaSampleSize
82
92
  */
83
93
 
84
94
  /**
@@ -86,6 +96,8 @@
86
96
  * @property {(tenantId: string, options?: BuildOptions) => Promise<boolean>} build - 為單一租戶建構 wiki
87
97
  * @property {() => Promise<PromiseSettledResult<boolean>[]>} buildAll - 並行建構所有租戶(需設定 listTenants)
88
98
  * @property {(prompt: string, tenantId: string) => Promise<string>} getContext - 取得指定租戶的 wiki 上下文
99
+ * @property {(tenantId: string) => Promise<string|null>} getPersona - 取得指定租戶的 persona
100
+ * @property {(tenantId: string, options?: { force?: boolean }) => Promise<boolean>} buildPersona - 為指定租戶單獨重建 persona
89
101
  * @property {(tenantId: string) => boolean} isBuilt - 該租戶是否已成功 build 過
90
102
  * @property {() => string[]} listBuilt - 已成功 build 過的租戶清單
91
103
  */