Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 56 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ Create `config.json`:

```json
{
"documents_dir": "./documents",
"document_patterns": [
"./documents",
"./notes/**/*.md",
"./projects/backend/**/*.md"
],
"db_path": "./vectors.db",
"chunk_size": 500,
"search_top_k": 5,
Expand All @@ -109,7 +113,11 @@ Create `config.json`:

### Configuration Options

- `documents_dir`: Directory containing markdown files
- `document_patterns`: Array of document paths and glob patterns
- Supports directory paths: `"./documents"`
- Supports glob patterns: `"./docs/**/*.md"` (recursive)
- Multiple patterns: Index files from different locations
- **Note**: Old `documents_dir` field is still supported (automatically migrated)
- `db_path`: Vector database file path
- `chunk_size`: Document chunk size in characters
- `search_top_k`: Number of search results to return
Expand All @@ -118,6 +126,19 @@ Create `config.json`:
- `model.name`: Embedding model name
- `model.dimensions`: Vector dimensions

### Pattern Examples

```json
{
"document_patterns": [
"./documents", // All .md files in documents/
"./notes/**/*.md", // Recursive search in notes/
"./projects/*/docs/*.md", // docs/ in each project
"/path/to/external/docs" // Absolute path
]
}
```

## MCP Tools

DevRag provides the following tools via Model Context Protocol:
Expand Down Expand Up @@ -168,7 +189,11 @@ Configure for your project's docs directory:

```json
{
"documents_dir": "./docs",
"document_patterns": [
"./docs",
"./api-docs/**/*.md",
"./wiki/**/*.md"
],
"db_path": "./.devrag/vectors.db"
}
```
Expand Down Expand Up @@ -415,7 +440,11 @@ Claude Codeで:

```json
{
"documents_dir": "./documents",
"document_patterns": [
"./documents",
"./notes/**/*.md",
"./projects/backend/**/*.md"
],
"db_path": "./vectors.db",
"chunk_size": 500,
"search_top_k": 5,
Expand All @@ -432,7 +461,11 @@ Claude Codeで:

### 設定項目

- `documents_dir`: マークダウンファイルを配置するディレクトリ
- `document_patterns`: ドキュメントのパスとglobパターンの配列
- ディレクトリパス対応: `"./documents"`
- globパターン対応: `"./docs/**/*.md"` (再帰的)
- 複数パターン: 異なる場所からファイルをインデックス化
- **注意**: 旧形式の`documents_dir`もサポート(自動的に移行)
- `db_path`: ベクトルデータベースのパス
- `chunk_size`: ドキュメントのチャンクサイズ(文字数)
- `search_top_k`: 検索結果の返却件数
Expand All @@ -441,6 +474,19 @@ Claude Codeで:
- `model.name`: 埋め込みモデル名
- `model.dimensions`: ベクトル次元数

### パターン例

```json
{
"document_patterns": [
"./documents", // documents/内の全.mdファイル
"./notes/**/*.md", // notes/内を再帰的に検索
"./projects/*/docs/*.md", // 各プロジェクトのdocs/
"/path/to/external/docs" // 絶対パス
]
}
```

## MCPツール

Model Context Protocolを通じて以下のツールを提供:
Expand Down Expand Up @@ -491,7 +537,11 @@ Model Context Protocolを通じて以下のツールを提供:

```json
{
"documents_dir": "./docs",
"document_patterns": [
"./docs",
"./api-docs/**/*.md",
"./wiki/**/*.md"
],
"db_path": "./.devrag/vectors.db"
}
```
Expand Down
12 changes: 7 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func main() {
}

fmt.Fprintf(os.Stderr, "[INFO] Configuration loaded successfully\n")
fmt.Fprintf(os.Stderr, "[INFO] Documents directory: %s\n", cfg.DocumentsDir)
fmt.Fprintf(os.Stderr, "[INFO] Document patterns: %v\n", cfg.DocumentPatterns)
fmt.Fprintf(os.Stderr, "[INFO] Database path: %s\n", cfg.DBPath)
fmt.Fprintf(os.Stderr, "[INFO] Model: %s (dimensions: %d)\n", cfg.Model.Name, cfg.Model.Dimensions)
fmt.Fprintf(os.Stderr, "[INFO] Device: %s\n", cfg.Compute.Device)
Expand All @@ -46,10 +46,12 @@ func main() {

// 4. Initialize components

// Ensure documents directory exists
if err := os.MkdirAll(cfg.DocumentsDir, 0755); err != nil {
fmt.Fprintf(os.Stderr, "[FATAL] Failed to create documents directory: %v\n", err)
os.Exit(1)
// Ensure base directories exist
baseDirs := cfg.GetBaseDirectories()
for _, dir := range baseDirs {
if err := os.MkdirAll(dir, 0755); err != nil {
fmt.Fprintf(os.Stderr, "[WARN] Failed to create directory %s: %v\n", dir, err)
}
}

// Initialize database
Expand Down
Loading