htm 0.0.18 → 0.0.20
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +59 -1
- data/README.md +12 -0
- data/db/seeds.rb +1 -1
- data/docs/api/embedding-service.md +140 -110
- data/docs/api/yard/HTM/ActiveRecordConfig.md +6 -0
- data/docs/api/yard/HTM/Config.md +173 -0
- data/docs/api/yard/HTM/ConfigSection.md +28 -0
- data/docs/api/yard/HTM/Database.md +1 -1
- data/docs/api/yard/HTM/Railtie.md +2 -2
- data/docs/api/yard/HTM.md +0 -57
- data/docs/api/yard/index.csv +76 -61
- data/docs/api/yard-reference.md +2 -1
- data/docs/architecture/adrs/003-ollama-embeddings.md +45 -36
- data/docs/architecture/adrs/004-hive-mind.md +1 -1
- data/docs/architecture/adrs/008-robot-identification.md +1 -1
- data/docs/architecture/index.md +11 -9
- data/docs/architecture/overview.md +11 -7
- data/docs/assets/images/balanced-strategy-decay.svg +41 -0
- data/docs/assets/images/class-hierarchy.svg +1 -1
- data/docs/assets/images/eviction-priority.svg +43 -0
- data/docs/assets/images/exception-hierarchy.svg +2 -2
- data/docs/assets/images/hive-mind-shared-memory.svg +52 -0
- data/docs/assets/images/htm-architecture-overview.svg +3 -3
- data/docs/assets/images/htm-core-components.svg +4 -4
- data/docs/assets/images/htm-layered-architecture.svg +1 -1
- data/docs/assets/images/htm-memory-addition-flow.svg +2 -2
- data/docs/assets/images/htm-memory-recall-flow.svg +2 -2
- data/docs/assets/images/memory-topology.svg +53 -0
- data/docs/assets/images/two-tier-memory-architecture.svg +55 -0
- data/docs/development/setup.md +76 -44
- data/docs/examples/basic-usage.md +133 -0
- data/docs/examples/config-files.md +170 -0
- data/docs/examples/file-loading.md +208 -0
- data/docs/examples/index.md +116 -0
- data/docs/examples/llm-configuration.md +168 -0
- data/docs/examples/mcp-client.md +172 -0
- data/docs/examples/rails-integration.md +173 -0
- data/docs/examples/robot-groups.md +210 -0
- data/docs/examples/sinatra-integration.md +218 -0
- data/docs/examples/standalone-app.md +216 -0
- data/docs/examples/telemetry.md +224 -0
- data/docs/examples/timeframes.md +143 -0
- data/docs/getting-started/installation.md +97 -40
- data/docs/getting-started/quick-start.md +28 -11
- data/docs/guides/configuration.md +515 -0
- data/docs/guides/file-loading.md +322 -0
- data/docs/guides/getting-started.md +40 -9
- data/docs/guides/index.md +3 -3
- data/docs/guides/mcp-server.md +30 -12
- data/docs/guides/propositions.md +264 -0
- data/docs/guides/recalling-memories.md +4 -4
- data/docs/guides/search-strategies.md +3 -3
- data/docs/guides/tags.md +318 -0
- data/docs/guides/telemetry.md +229 -0
- data/docs/index.md +8 -16
- data/docs/{architecture → robots}/hive-mind.md +8 -111
- data/docs/robots/index.md +73 -0
- data/docs/{guides → robots}/multi-robot.md +3 -3
- data/docs/{guides → robots}/robot-groups.md +8 -7
- data/docs/{architecture → robots}/two-tier-memory.md +13 -149
- data/docs/robots/why-robots.md +85 -0
- data/lib/htm/config/defaults.yml +4 -4
- data/lib/htm/config.rb +2 -2
- data/lib/htm/job_adapter.rb +75 -1
- data/lib/htm/version.rb +1 -1
- data/lib/htm/workflows/remember_workflow.rb +212 -0
- data/lib/htm.rb +1 -0
- data/mkdocs.yml +33 -8
- metadata +60 -7
- data/docs/api/yard/HTM/Configuration.md +0 -240
- data/docs/telemetry.md +0 -391
data/docs/development/setup.md
CHANGED
|
@@ -10,7 +10,7 @@ Setting up HTM for development involves:
|
|
|
10
10
|
2. Installing Ruby and system dependencies
|
|
11
11
|
3. Installing Ruby gem dependencies
|
|
12
12
|
4. Setting up TimescaleDB database
|
|
13
|
-
5. Configuring Ollama
|
|
13
|
+
5. Configuring an LLM provider (Ollama, OpenAI, etc.)
|
|
14
14
|
6. Verifying your setup
|
|
15
15
|
7. Running tests and examples
|
|
16
16
|
|
|
@@ -274,77 +274,94 @@ ruby enable_extensions.rb
|
|
|
274
274
|
|
|
275
275
|
This ensures that TimescaleDB, pgvector, and pg_trgm extensions are enabled.
|
|
276
276
|
|
|
277
|
-
## Step 5:
|
|
277
|
+
## Step 5: Configure LLM Provider
|
|
278
278
|
|
|
279
|
-
HTM uses
|
|
279
|
+
HTM uses RubyLLM to generate vector embeddings and extract tags. RubyLLM supports multiple providers, so you can choose what works best for your development environment.
|
|
280
280
|
|
|
281
|
-
###
|
|
281
|
+
### Supported Providers
|
|
282
282
|
|
|
283
|
-
|
|
283
|
+
| Provider | Best For | Setup Required |
|
|
284
|
+
|----------|----------|----------------|
|
|
285
|
+
| **Ollama** (default) | Local development, privacy | Install Ollama + models |
|
|
286
|
+
| **OpenAI** | Production, high-quality | API key only |
|
|
287
|
+
| **Anthropic** | Claude models for tags | API key only |
|
|
288
|
+
| **Gemini** | Google Cloud users | API key only |
|
|
284
289
|
|
|
290
|
+
### Option A: Ollama (Recommended for Development)
|
|
291
|
+
|
|
292
|
+
Ollama runs locally with no API costs.
|
|
293
|
+
|
|
294
|
+
#### Install Ollama
|
|
295
|
+
|
|
296
|
+
**macOS:**
|
|
285
297
|
```bash
|
|
286
|
-
#
|
|
298
|
+
# Direct download
|
|
287
299
|
curl https://ollama.ai/install.sh | sh
|
|
288
300
|
|
|
289
301
|
# Or using Homebrew
|
|
290
302
|
brew install ollama
|
|
291
303
|
```
|
|
292
304
|
|
|
293
|
-
|
|
294
|
-
|
|
305
|
+
**Linux:**
|
|
295
306
|
```bash
|
|
296
307
|
curl https://ollama.ai/install.sh | sh
|
|
297
308
|
```
|
|
298
309
|
|
|
299
|
-
|
|
310
|
+
#### Start Ollama Service
|
|
300
311
|
|
|
301
|
-
Ollama typically starts automatically
|
|
312
|
+
Ollama typically starts automatically. Verify it's running:
|
|
302
313
|
|
|
303
314
|
```bash
|
|
304
|
-
# Check if Ollama is running
|
|
305
315
|
curl http://localhost:11434/api/version
|
|
306
|
-
|
|
307
|
-
# Expected output:
|
|
308
|
-
# {"version":"0.1.x"}
|
|
309
316
|
```
|
|
310
317
|
|
|
311
|
-
If not running
|
|
318
|
+
If not running:
|
|
312
319
|
|
|
313
320
|
```bash
|
|
314
|
-
# macOS -
|
|
315
|
-
# Check Activity Monitor or start from Applications
|
|
316
|
-
|
|
321
|
+
# macOS - Check Activity Monitor or start from Applications
|
|
317
322
|
# Linux
|
|
318
323
|
ollama serve &
|
|
319
324
|
```
|
|
320
325
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
HTM uses the `gpt-oss` model by default:
|
|
326
|
+
#### Pull Required Models
|
|
324
327
|
|
|
325
328
|
```bash
|
|
326
|
-
# Pull
|
|
327
|
-
ollama pull
|
|
329
|
+
# Pull embedding model
|
|
330
|
+
ollama pull nomic-embed-text
|
|
331
|
+
|
|
332
|
+
# Pull tag extraction model
|
|
333
|
+
ollama pull gemma3:latest
|
|
328
334
|
|
|
329
|
-
# Verify
|
|
335
|
+
# Verify models
|
|
330
336
|
ollama list
|
|
331
|
-
# Should show gpt-oss in the list
|
|
332
337
|
```
|
|
333
338
|
|
|
334
|
-
|
|
339
|
+
#### Configure Custom URL (Optional)
|
|
335
340
|
|
|
336
341
|
```bash
|
|
337
|
-
|
|
338
|
-
ollama run gpt-oss "Hello, HTM!"
|
|
342
|
+
export OLLAMA_URL="http://custom-host:11434"
|
|
339
343
|
```
|
|
340
344
|
|
|
341
|
-
###
|
|
345
|
+
### Option B: OpenAI (Recommended for Production)
|
|
342
346
|
|
|
343
|
-
|
|
347
|
+
```bash
|
|
348
|
+
export OPENAI_API_KEY="sk-..."
|
|
349
|
+
```
|
|
344
350
|
|
|
351
|
+
Configure in your code:
|
|
352
|
+
```ruby
|
|
353
|
+
HTM.configure do |config|
|
|
354
|
+
config.embedding.provider = :openai
|
|
355
|
+
config.embedding.model = 'text-embedding-3-small'
|
|
356
|
+
end
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Option C: Other Providers
|
|
360
|
+
|
|
361
|
+
Set the appropriate API key:
|
|
345
362
|
```bash
|
|
346
|
-
|
|
347
|
-
export
|
|
363
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
364
|
+
export GEMINI_API_KEY="..."
|
|
348
365
|
```
|
|
349
366
|
|
|
350
367
|
## Step 6: Initialize Database Schema
|
|
@@ -420,11 +437,11 @@ HTM Basic Usage Example
|
|
|
420
437
|
============================================================
|
|
421
438
|
|
|
422
439
|
1. Initializing HTM for 'Code Helper' robot...
|
|
423
|
-
Using RubyLLM with
|
|
440
|
+
Using RubyLLM with configured provider for embeddings
|
|
424
441
|
✓ HTM initialized
|
|
425
442
|
Robot ID: robot-abc123
|
|
426
443
|
Robot Name: Code Helper
|
|
427
|
-
Embedding Service:
|
|
444
|
+
Embedding Service: Configured provider via RubyLLM
|
|
428
445
|
|
|
429
446
|
2. Adding memory nodes...
|
|
430
447
|
✓ Added decision about database choice
|
|
@@ -485,11 +502,14 @@ HTM uses environment variables for configuration. Here's a complete reference:
|
|
|
485
502
|
| `HTM_DATABASE__PORT` | Database port | `37807` |
|
|
486
503
|
| `HTM_SERVICE_NAME` | Service identifier (informational) | `db-67977` |
|
|
487
504
|
|
|
488
|
-
###
|
|
505
|
+
### LLM Provider Variables
|
|
489
506
|
|
|
490
507
|
| Variable | Description | Example |
|
|
491
508
|
|----------|-------------|---------|
|
|
492
|
-
| `OLLAMA_URL` | Ollama API URL (
|
|
509
|
+
| `OLLAMA_URL` | Ollama API URL (if using Ollama) | `http://localhost:11434` |
|
|
510
|
+
| `OPENAI_API_KEY` | OpenAI API key (if using OpenAI) | `sk-...` |
|
|
511
|
+
| `ANTHROPIC_API_KEY` | Anthropic API key (if using Anthropic) | `sk-ant-...` |
|
|
512
|
+
| `GEMINI_API_KEY` | Gemini API key (if using Gemini) | `...` |
|
|
493
513
|
|
|
494
514
|
### Managing Environment Files
|
|
495
515
|
|
|
@@ -497,7 +517,7 @@ You can organize your environment variables using multiple files:
|
|
|
497
517
|
|
|
498
518
|
```bash
|
|
499
519
|
# ~/.bashrc__tiger - Database configuration
|
|
500
|
-
#
|
|
520
|
+
# LLM provider environment variables (set based on your chosen provider)
|
|
501
521
|
|
|
502
522
|
# Load all configuration files in ~/.bashrc
|
|
503
523
|
source ~/.bashrc__tiger
|
|
@@ -527,11 +547,11 @@ psql $HTM_DATABASE__URL
|
|
|
527
547
|
docker ps | grep timescale
|
|
528
548
|
```
|
|
529
549
|
|
|
530
|
-
#### "
|
|
550
|
+
#### "LLM provider connection failed"
|
|
531
551
|
|
|
532
552
|
**Symptoms**: Embedding generation fails
|
|
533
553
|
|
|
534
|
-
**Solutions**:
|
|
554
|
+
**Solutions for Ollama**:
|
|
535
555
|
|
|
536
556
|
```bash
|
|
537
557
|
# Verify Ollama is running
|
|
@@ -541,11 +561,23 @@ curl http://localhost:11434/api/version
|
|
|
541
561
|
# macOS: Start from Applications or Activity Monitor
|
|
542
562
|
# Linux: ollama serve &
|
|
543
563
|
|
|
544
|
-
# Check if
|
|
545
|
-
ollama list | grep
|
|
564
|
+
# Check if models are downloaded
|
|
565
|
+
ollama list | grep nomic-embed-text
|
|
566
|
+
|
|
567
|
+
# Pull models if missing
|
|
568
|
+
ollama pull nomic-embed-text
|
|
569
|
+
ollama pull gemma3:latest
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
**Solutions for Cloud Providers**:
|
|
573
|
+
|
|
574
|
+
```bash
|
|
575
|
+
# Verify API key is set
|
|
576
|
+
echo $OPENAI_API_KEY
|
|
577
|
+
echo $ANTHROPIC_API_KEY
|
|
546
578
|
|
|
547
|
-
#
|
|
548
|
-
|
|
579
|
+
# Test API connectivity
|
|
580
|
+
curl https://api.openai.com/v1/models -H "Authorization: Bearer $OPENAI_API_KEY"
|
|
549
581
|
```
|
|
550
582
|
|
|
551
583
|
#### "Extension not available"
|
|
@@ -602,7 +634,7 @@ rake db_setup
|
|
|
602
634
|
source ~/.bashrc__tiger
|
|
603
635
|
env | grep TIGER
|
|
604
636
|
|
|
605
|
-
# Check
|
|
637
|
+
# Check LLM provider (if using Ollama)
|
|
606
638
|
curl http://localhost:11434/api/version
|
|
607
639
|
|
|
608
640
|
# Run tests with verbose output
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Basic Usage Example
|
|
2
|
+
|
|
3
|
+
This example demonstrates the core HTM operations: configuring the system, remembering information, and recalling memories.
|
|
4
|
+
|
|
5
|
+
**Source:** [`examples/basic_usage.rb`](https://github.com/madbomber/htm/blob/main/examples/basic_usage.rb)
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
The basic usage example shows:
|
|
10
|
+
|
|
11
|
+
- Configuring HTM with a provider (Ollama by default)
|
|
12
|
+
- Initializing an HTM instance for a robot
|
|
13
|
+
- Storing memories with `remember()`
|
|
14
|
+
- Retrieving memories with `recall()`
|
|
15
|
+
- Using different search strategies
|
|
16
|
+
|
|
17
|
+
## Running the Example
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
export HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development"
|
|
21
|
+
ruby examples/basic_usage.rb
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Code Walkthrough
|
|
25
|
+
|
|
26
|
+
### Configuration
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
HTM.configure do |config|
|
|
30
|
+
# Provider configuration (Ollama is default)
|
|
31
|
+
config.embedding.provider = :ollama
|
|
32
|
+
config.embedding.model = 'nomic-embed-text:latest'
|
|
33
|
+
config.embedding.dimensions = 768
|
|
34
|
+
|
|
35
|
+
config.tag.provider = :ollama
|
|
36
|
+
config.tag.model = 'gemma3:latest'
|
|
37
|
+
|
|
38
|
+
# Use inline job backend for synchronous execution
|
|
39
|
+
# In production, use :thread or :sidekiq for async
|
|
40
|
+
config.job.backend = :inline
|
|
41
|
+
end
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Initialize HTM
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
htm = HTM.new(
|
|
48
|
+
robot_name: "Code Helper",
|
|
49
|
+
working_memory_size: 128_000 # Token limit
|
|
50
|
+
)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Storing Memories
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
# Remember automatically generates embeddings and tags
|
|
57
|
+
node_id = htm.remember(
|
|
58
|
+
"PostgreSQL supports native vector search with pgvector."
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# Tags are extracted via LLM
|
|
62
|
+
# Embeddings enable semantic search
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Recalling Memories
|
|
66
|
+
|
|
67
|
+
```ruby
|
|
68
|
+
# Full-text search (keyword matching)
|
|
69
|
+
memories = htm.recall(
|
|
70
|
+
"PostgreSQL",
|
|
71
|
+
timeframe: (Time.now - 3600)..Time.now,
|
|
72
|
+
limit: 5,
|
|
73
|
+
strategy: :fulltext
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
# Vector search (semantic similarity)
|
|
77
|
+
memories = htm.recall("database features", strategy: :vector)
|
|
78
|
+
|
|
79
|
+
# Hybrid search (combines both)
|
|
80
|
+
memories = htm.recall("database features", strategy: :hybrid)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Expected Output
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
HTM Basic Usage Example
|
|
87
|
+
============================================================
|
|
88
|
+
|
|
89
|
+
1. Configuring HTM with Ollama provider...
|
|
90
|
+
✓ HTM configured with Ollama provider (inline job backend)
|
|
91
|
+
|
|
92
|
+
2. Initializing HTM for 'Code Helper' robot...
|
|
93
|
+
✓ HTM initialized
|
|
94
|
+
Robot ID: 1
|
|
95
|
+
Robot Name: Code Helper
|
|
96
|
+
Embedding Service: ollama (nomic-embed-text:latest)
|
|
97
|
+
|
|
98
|
+
3. Remembering information...
|
|
99
|
+
✓ Remembered decision about database choice (node 1)
|
|
100
|
+
✓ Remembered decision about RAG approach (node 2)
|
|
101
|
+
✓ Remembered fact about user preferences (node 3)
|
|
102
|
+
|
|
103
|
+
4. Recalling memories about 'PostgreSQL'...
|
|
104
|
+
✓ Found 1 memories
|
|
105
|
+
- Node 1: We decided to use PostgreSQL for HTM storage because...
|
|
106
|
+
|
|
107
|
+
============================================================
|
|
108
|
+
✓ Example completed successfully!
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Key Concepts
|
|
112
|
+
|
|
113
|
+
### Search Strategies
|
|
114
|
+
|
|
115
|
+
| Strategy | Description | Best For |
|
|
116
|
+
|----------|-------------|----------|
|
|
117
|
+
| `:fulltext` | Keyword matching with PostgreSQL tsvector | Exact term matches |
|
|
118
|
+
| `:vector` | Semantic similarity with pgvector | Conceptual queries |
|
|
119
|
+
| `:hybrid` | Combines both with RRF scoring | General queries |
|
|
120
|
+
|
|
121
|
+
### Job Backends
|
|
122
|
+
|
|
123
|
+
| Backend | Behavior | Use Case |
|
|
124
|
+
|---------|----------|----------|
|
|
125
|
+
| `:inline` | Synchronous execution | Examples, testing |
|
|
126
|
+
| `:thread` | Background threads | Development |
|
|
127
|
+
| `:sidekiq` | Sidekiq workers | Production |
|
|
128
|
+
|
|
129
|
+
## See Also
|
|
130
|
+
|
|
131
|
+
- [LLM Configuration Example](llm-configuration.md)
|
|
132
|
+
- [Adding Memories Guide](../guides/adding-memories.md)
|
|
133
|
+
- [Search Strategies Guide](../guides/search-strategies.md)
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Configuration Files Example
|
|
2
|
+
|
|
3
|
+
This example demonstrates HTM's flexible, layered configuration management using the `anyway_config` gem.
|
|
4
|
+
|
|
5
|
+
**Source:** [`examples/config_file_example/`](https://github.com/madbomber/htm/tree/main/examples/config_file_example)
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
The configuration example shows:
|
|
10
|
+
|
|
11
|
+
- Configuration source hierarchy and priority
|
|
12
|
+
- Using `htm_mcp config` to generate config files
|
|
13
|
+
- Environment-specific configuration sections
|
|
14
|
+
- Environment variable overrides with `HTM_*`
|
|
15
|
+
- Custom config file paths with `HTM_CONF`
|
|
16
|
+
- Programmatic configuration with `HTM.configure`
|
|
17
|
+
|
|
18
|
+
## Configuration Priority
|
|
19
|
+
|
|
20
|
+
HTM loads configuration from multiple sources, merged in priority order:
|
|
21
|
+
|
|
22
|
+
| Priority | Source | Location |
|
|
23
|
+
|----------|--------|----------|
|
|
24
|
+
| 1 (lowest) | Bundled Defaults | `lib/htm/config/defaults.yml` |
|
|
25
|
+
| 2 | XDG User Config | `~/.config/htm/htm.yml` |
|
|
26
|
+
| 3 | Project Config | `./config/htm.yml` |
|
|
27
|
+
| 4 | Local Overrides | `./config/htm.local.yml` |
|
|
28
|
+
| 5 | HTM_CONF File | Path in `HTM_CONF` env var |
|
|
29
|
+
| 6 | Environment Variables | `HTM_*` |
|
|
30
|
+
| 7 (highest) | Code Block | `HTM.configure { }` |
|
|
31
|
+
|
|
32
|
+
## Running the Example
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
cd examples/config_file_example
|
|
36
|
+
|
|
37
|
+
# Basic usage - loads ./config/htm.local.yml automatically
|
|
38
|
+
ruby show_config.rb
|
|
39
|
+
|
|
40
|
+
# Different environment
|
|
41
|
+
HTM_ENV=production ruby show_config.rb
|
|
42
|
+
|
|
43
|
+
# Override with environment variable
|
|
44
|
+
HTM_EMBEDDING__MODEL=mxbai-embed-large ruby show_config.rb
|
|
45
|
+
|
|
46
|
+
# Use custom config file
|
|
47
|
+
HTM_CONF=./custom_config.yml ruby show_config.rb
|
|
48
|
+
|
|
49
|
+
# Combine multiple overrides
|
|
50
|
+
HTM_CONF=./custom_config.yml HTM_ENV=test HTM_LOG_LEVEL=warn ruby show_config.rb
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Generating Config Files
|
|
54
|
+
|
|
55
|
+
Use the `htm_mcp config` command to output the complete default configuration:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Create a project config file
|
|
59
|
+
htm_mcp config > ./config/htm.yml
|
|
60
|
+
|
|
61
|
+
# Create a local overrides file (add to .gitignore)
|
|
62
|
+
htm_mcp config > ./config/htm.local.yml
|
|
63
|
+
|
|
64
|
+
# Create a user-wide XDG config
|
|
65
|
+
mkdir -p ~/.config/htm
|
|
66
|
+
htm_mcp config > ~/.config/htm/htm.yml
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Example Config Files
|
|
70
|
+
|
|
71
|
+
### Project Config with Environment Sections
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
# ./config/htm.yml
|
|
75
|
+
defaults:
|
|
76
|
+
database:
|
|
77
|
+
host: localhost
|
|
78
|
+
port: 5432
|
|
79
|
+
|
|
80
|
+
development:
|
|
81
|
+
database:
|
|
82
|
+
name: myapp_development
|
|
83
|
+
log_level: debug
|
|
84
|
+
|
|
85
|
+
production:
|
|
86
|
+
database:
|
|
87
|
+
name: myapp_production
|
|
88
|
+
pool_size: 25
|
|
89
|
+
telemetry_enabled: true
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Local Overrides (Gitignored)
|
|
93
|
+
|
|
94
|
+
```yaml
|
|
95
|
+
# ./config/htm.local.yml
|
|
96
|
+
database:
|
|
97
|
+
name: my_local_db
|
|
98
|
+
|
|
99
|
+
providers:
|
|
100
|
+
openai:
|
|
101
|
+
api_key: sk-your-actual-key
|
|
102
|
+
|
|
103
|
+
log_level: debug
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Environment Variables
|
|
107
|
+
|
|
108
|
+
Use double underscores (`__`) for nested values:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Database configuration
|
|
112
|
+
export HTM_DATABASE__URL="postgresql://user:pass@host:5432/dbname"
|
|
113
|
+
export HTM_DATABASE__POOL_SIZE=25
|
|
114
|
+
|
|
115
|
+
# Embedding configuration
|
|
116
|
+
export HTM_EMBEDDING__PROVIDER=openai
|
|
117
|
+
export HTM_EMBEDDING__MODEL=text-embedding-3-small
|
|
118
|
+
|
|
119
|
+
# Provider credentials
|
|
120
|
+
export HTM_PROVIDERS__OPENAI__API_KEY=sk-your-key
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Example Output
|
|
124
|
+
|
|
125
|
+
The `show_config.rb` script displays loaded configuration with source tracing:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
HTM Configuration Example
|
|
129
|
+
============================================================
|
|
130
|
+
|
|
131
|
+
Environment: development
|
|
132
|
+
|
|
133
|
+
Config sources checked:
|
|
134
|
+
- Bundled defaults: lib/htm/config/defaults.yml
|
|
135
|
+
- XDG config: ~/.config/htm/htm.yml
|
|
136
|
+
- Project config: ./config/htm.yml
|
|
137
|
+
- Local overrides: ./config/htm.local.yml
|
|
138
|
+
- HTM_CONF override: (not set)
|
|
139
|
+
- Environment variables: HTM_*
|
|
140
|
+
|
|
141
|
+
------------------------------------------------------------
|
|
142
|
+
Configuration with Sources:
|
|
143
|
+
------------------------------------------------------------
|
|
144
|
+
|
|
145
|
+
database:
|
|
146
|
+
host: "localhost" # from: htm.local.yml
|
|
147
|
+
port: 5432 # from: htm.local.yml
|
|
148
|
+
name: "htm_example" # from: htm.local.yml
|
|
149
|
+
pool_size: 10 # from: bundled_defaults
|
|
150
|
+
embedding:
|
|
151
|
+
provider: "ollama" # from: htm.local.yml
|
|
152
|
+
model: "nomic-embed-text:latest" # from: htm.local.yml
|
|
153
|
+
...
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Files in This Example
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
config_file_example/
|
|
160
|
+
├── README.md # Detailed documentation
|
|
161
|
+
├── show_config.rb # Demo script with source tracing
|
|
162
|
+
├── custom_config.yml # Example for HTM_CONF usage
|
|
163
|
+
└── config/
|
|
164
|
+
└── htm.local.yml # Auto-loaded local overrides
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## See Also
|
|
168
|
+
|
|
169
|
+
- [Configuration Guide](../guides/configuration.md)
|
|
170
|
+
- [anyway_config Documentation](https://github.com/palkan/anyway_config)
|