Browse the knowledge base from a single side panel menu

Add a read-only view of backend/knowledge_base/**.md so the files that get
injected into the system prompt can be inspected from the GUI:

- GET /api/kb/files lists the Markdown files (title, preview, size, mtime and
  whether the file is already embedded), GET /api/kb/file returns one in full.
  Paths are resolved against the knowledge base directory and rejected unless
  they stay inside it and end in .md.
- KnowledgeBasePanel.vue groups the files by folder (collapsible, so web_search
  can be folded away), filters by title/path/preview and renders the selected
  file with MarkdownContent.

The header had grown to four side panel toggles, so collapse them into one
menu: panels.ts now holds the list of panels along with the component each one
renders, App.vue picks it with <component :is>, and SidePanelMenu.vue shows the
active panel on its button. Re-picking the open panel (or "パネルを閉じる")
closes it; a click outside or Esc closes just the menu.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-23 21:38:54 +09:00
co-authored by Claude Opus 5
parent 5d63a59b86
commit f085db421c
13 changed files with 654 additions and 34 deletions
+54
View File
@@ -252,6 +252,60 @@ attachment; filename="______.md"; filename*=UTF-8''%E8%B2%B7%E3%81%84%E7%89%A9%E
---
## ローカルナレッジベース(閲覧)
`backend/knowledge_base/**.md` を GUI から読むための読み取り専用 API。編集・削除はできない。
### GET /api/kb/files
ナレッジベース配下の Markdown を、パス順の一覧で返す(本文は含めない)。
```json
[
{
"path": "web_search/02b627ac75bb2fd4.md",
"name": "02b627ac75bb2fd4.md",
"directory": "web_search",
"title": "SOUL.md use-soul-with-hermes",
"preview": "SOUL.mdは、Hermes Agent インスタンスの主要な…",
"size": 6150,
"updated_at": "2026-06-21T05:03:52.684324Z",
"indexed": true
}
]
```
`directory` はナレッジベース直下なら空文字。`indexed` は `local_knowledge_docs` に埋め込み済み
(=話題に応じた自動注入の対象になっている)かどうか。未埋め込みのファイルは次回のチャット時に
`sync_local_kb()` が取り込む。
---
### GET /api/kb/file
1 ファイルの全文を返す。
**クエリパラメーター**
| 名前 | 必須 | 説明 |
|---|---|---|
| `path` | ✓ | ナレッジベースディレクトリからの相対パス(`web_search/xxxx.md` など) |
ナレッジベースの外を指すパス(`../` や絶対パス)、`.md` 以外、存在しないファイルはすべて `404`。
```json
{
"path": "fgo.md",
"name": "fgo.md",
"title": "Fate / Grand Order",
"content": "# Fate / Grand Order
…",
"size": 13942,
"updated_at": "2026-06-20T09:39:45.542875Z"
}
```
---
## ログ
### GET /logs