htm 0.0.17 → 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.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.architecture/decisions/adrs/001-use-postgresql-timescaledb-storage.md +1 -1
  3. data/.architecture/decisions/adrs/011-database-side-embedding-generation-with-pgai.md +4 -4
  4. data/.architecture/decisions/adrs/012-llm-driven-ontology-topic-extraction.md +1 -1
  5. data/.envrc +12 -25
  6. data/.irbrc +7 -7
  7. data/.tbls.yml +2 -2
  8. data/CHANGELOG.md +130 -1
  9. data/README.md +13 -1
  10. data/Rakefile +8 -3
  11. data/SETUP.md +12 -12
  12. data/bin/htm_mcp +0 -4
  13. data/db/seed_data/README.md +2 -2
  14. data/db/seeds.rb +3 -3
  15. data/docs/api/database.md +37 -37
  16. data/docs/api/embedding-service.md +140 -110
  17. data/docs/api/htm.md +1 -1
  18. data/docs/api/yard/HTM/ActiveRecordConfig.md +8 -2
  19. data/docs/api/yard/HTM/Config.md +173 -0
  20. data/docs/api/yard/HTM/ConfigSection.md +28 -0
  21. data/docs/api/yard/HTM/Database.md +7 -8
  22. data/docs/api/yard/HTM/JobAdapter.md +1 -1
  23. data/docs/api/yard/HTM.md +0 -57
  24. data/docs/api/yard/index.csv +76 -61
  25. data/docs/api/yard-reference.md +2 -1
  26. data/docs/architecture/adrs/001-postgresql-timescaledb.md +1 -1
  27. data/docs/architecture/adrs/003-ollama-embeddings.md +45 -36
  28. data/docs/architecture/adrs/004-hive-mind.md +1 -1
  29. data/docs/architecture/adrs/008-robot-identification.md +1 -1
  30. data/docs/architecture/adrs/011-pgai-integration.md +4 -4
  31. data/docs/architecture/index.md +11 -9
  32. data/docs/architecture/overview.md +11 -7
  33. data/docs/assets/images/balanced-strategy-decay.svg +41 -0
  34. data/docs/assets/images/class-hierarchy.svg +1 -1
  35. data/docs/assets/images/eviction-priority.svg +43 -0
  36. data/docs/assets/images/exception-hierarchy.svg +2 -2
  37. data/docs/assets/images/hive-mind-shared-memory.svg +52 -0
  38. data/docs/assets/images/htm-architecture-overview.svg +3 -3
  39. data/docs/assets/images/htm-core-components.svg +4 -4
  40. data/docs/assets/images/htm-layered-architecture.svg +1 -1
  41. data/docs/assets/images/htm-memory-addition-flow.svg +2 -2
  42. data/docs/assets/images/htm-memory-recall-flow.svg +2 -2
  43. data/docs/assets/images/memory-topology.svg +53 -0
  44. data/docs/assets/images/two-tier-memory-architecture.svg +55 -0
  45. data/docs/database_rake_tasks.md +5 -5
  46. data/docs/development/rake-tasks.md +11 -11
  47. data/docs/development/setup.md +97 -65
  48. data/docs/development/testing.md +1 -1
  49. data/docs/examples/basic-usage.md +133 -0
  50. data/docs/examples/config-files.md +170 -0
  51. data/docs/examples/file-loading.md +208 -0
  52. data/docs/examples/index.md +116 -0
  53. data/docs/examples/llm-configuration.md +168 -0
  54. data/docs/examples/mcp-client.md +172 -0
  55. data/docs/examples/rails-integration.md +173 -0
  56. data/docs/examples/robot-groups.md +210 -0
  57. data/docs/examples/sinatra-integration.md +218 -0
  58. data/docs/examples/standalone-app.md +216 -0
  59. data/docs/examples/telemetry.md +224 -0
  60. data/docs/examples/timeframes.md +143 -0
  61. data/docs/getting-started/installation.md +117 -60
  62. data/docs/getting-started/quick-start.md +35 -18
  63. data/docs/guides/configuration.md +515 -0
  64. data/docs/guides/file-loading.md +322 -0
  65. data/docs/guides/getting-started.md +42 -11
  66. data/docs/guides/index.md +3 -3
  67. data/docs/guides/long-term-memory.md +1 -1
  68. data/docs/guides/mcp-server.md +47 -29
  69. data/docs/guides/propositions.md +264 -0
  70. data/docs/guides/recalling-memories.md +4 -4
  71. data/docs/guides/search-strategies.md +3 -3
  72. data/docs/guides/tags.md +318 -0
  73. data/docs/guides/telemetry.md +229 -0
  74. data/docs/index.md +10 -18
  75. data/docs/multi_framework_support.md +8 -8
  76. data/docs/{architecture → robots}/hive-mind.md +8 -111
  77. data/docs/robots/index.md +73 -0
  78. data/docs/{guides → robots}/multi-robot.md +3 -3
  79. data/docs/{guides → robots}/robot-groups.md +14 -13
  80. data/docs/{architecture → robots}/two-tier-memory.md +13 -149
  81. data/docs/robots/why-robots.md +85 -0
  82. data/docs/setup_local_database.md +19 -19
  83. data/docs/using_rake_tasks_in_your_app.md +14 -14
  84. data/examples/README.md +50 -6
  85. data/examples/basic_usage.rb +31 -21
  86. data/examples/cli_app/README.md +8 -8
  87. data/examples/cli_app/htm_cli.rb +5 -5
  88. data/examples/config_file_example/README.md +256 -0
  89. data/examples/config_file_example/config/htm.local.yml +34 -0
  90. data/examples/config_file_example/custom_config.yml +22 -0
  91. data/examples/config_file_example/show_config.rb +125 -0
  92. data/examples/custom_llm_configuration.rb +7 -7
  93. data/examples/example_app/Rakefile +2 -2
  94. data/examples/example_app/app.rb +8 -8
  95. data/examples/file_loader_usage.rb +9 -9
  96. data/examples/mcp_client.rb +5 -5
  97. data/examples/rails_app/Gemfile.lock +48 -56
  98. data/examples/rails_app/README.md +1 -1
  99. data/examples/robot_groups/multi_process.rb +5 -5
  100. data/examples/robot_groups/robot_worker.rb +5 -5
  101. data/examples/robot_groups/same_process.rb +9 -9
  102. data/examples/sinatra_app/app.rb +1 -1
  103. data/examples/timeframe_demo.rb +1 -1
  104. data/lib/htm/active_record_config.rb +12 -25
  105. data/lib/htm/circuit_breaker.rb +0 -2
  106. data/lib/htm/config/defaults.yml +246 -0
  107. data/lib/htm/config.rb +888 -0
  108. data/lib/htm/database.rb +23 -27
  109. data/lib/htm/embedding_service.rb +0 -4
  110. data/lib/htm/integrations/sinatra.rb +3 -7
  111. data/lib/htm/job_adapter.rb +76 -16
  112. data/lib/htm/jobs/generate_embedding_job.rb +1 -7
  113. data/lib/htm/jobs/generate_propositions_job.rb +2 -12
  114. data/lib/htm/jobs/generate_tags_job.rb +1 -8
  115. data/lib/htm/loaders/defaults_loader.rb +143 -0
  116. data/lib/htm/loaders/xdg_config_loader.rb +116 -0
  117. data/lib/htm/mcp/cli.rb +200 -58
  118. data/lib/htm/mcp/server.rb +3 -3
  119. data/lib/htm/proposition_service.rb +2 -12
  120. data/lib/htm/railtie.rb +3 -4
  121. data/lib/htm/tag_service.rb +1 -8
  122. data/lib/htm/version.rb +1 -1
  123. data/lib/htm/workflows/remember_workflow.rb +212 -0
  124. data/lib/htm.rb +125 -5
  125. data/mkdocs.yml +33 -8
  126. metadata +83 -10
  127. data/config/database.yml +0 -77
  128. data/docs/api/yard/HTM/Configuration.md +0 -229
  129. data/docs/telemetry.md +0 -391
  130. data/lib/htm/configuration.rb +0 -799
@@ -0,0 +1,322 @@
1
+ # File Loading
2
+
3
+ HTM can load text-based files (currently markdown) into long-term memory with automatic chunking, source tracking, and re-sync support. This is ideal for building knowledge bases from documentation, notes, or any text content.
4
+
5
+ ## Overview
6
+
7
+ The file loading system provides:
8
+
9
+ - **Automatic chunking**: Large files are split into semantically-aware chunks
10
+ - **YAML frontmatter extraction**: Metadata from file headers is preserved
11
+ - **Source tracking**: Files are tracked for re-sync when content changes
12
+ - **Duplicate detection**: Content hashing prevents duplicate chunks
13
+ - **Soft delete**: Unloading files uses soft delete for recovery
14
+
15
+ ## Quick Start
16
+
17
+ ```ruby
18
+ require 'htm'
19
+
20
+ htm = HTM.new(robot_name: "Document Loader")
21
+
22
+ # Load a single markdown file
23
+ result = htm.load_file("docs/guide.md")
24
+ # => { file_source_id: 1, chunks_created: 5, chunks_updated: 0, skipped: false }
25
+
26
+ # Load all markdown files from a directory
27
+ results = htm.load_directory("docs/", pattern: "**/*.md")
28
+ # => [{ file_path: "docs/guide.md", ... }, { file_path: "docs/api.md", ... }]
29
+
30
+ # Query nodes from a specific file
31
+ nodes = htm.nodes_from_file("docs/guide.md")
32
+
33
+ # Unload a file (soft deletes chunks)
34
+ htm.unload_file("docs/guide.md")
35
+ ```
36
+
37
+ ## API Reference
38
+
39
+ ### load_file(path, force: false)
40
+
41
+ Loads a single file into long-term memory.
42
+
43
+ | Parameter | Type | Default | Description |
44
+ |-----------|------|---------|-------------|
45
+ | `path` | String | required | Path to the file |
46
+ | `force` | Boolean | `false` | Force reload even if file unchanged |
47
+
48
+ **Returns:** Hash with keys:
49
+ - `file_source_id`: ID of the FileSource record
50
+ - `chunks_created`: Number of new chunks created
51
+ - `chunks_updated`: Number of existing chunks updated
52
+ - `chunks_deleted`: Number of chunks removed
53
+ - `skipped`: Whether file was skipped (unchanged)
54
+
55
+ ```ruby
56
+ # Normal load - skips unchanged files
57
+ result = htm.load_file("docs/guide.md")
58
+
59
+ # Force reload even if file hasn't changed
60
+ result = htm.load_file("docs/guide.md", force: true)
61
+ ```
62
+
63
+ ### load_directory(path, pattern: "**/*.md", force: false)
64
+
65
+ Loads all matching files from a directory.
66
+
67
+ | Parameter | Type | Default | Description |
68
+ |-----------|------|---------|-------------|
69
+ | `path` | String | required | Directory path |
70
+ | `pattern` | String | `"**/*.md"` | Glob pattern for files |
71
+ | `force` | Boolean | `false` | Force reload all files |
72
+
73
+ **Returns:** Array of result hashes (one per file)
74
+
75
+ ```ruby
76
+ # Load all markdown files
77
+ results = htm.load_directory("docs/")
78
+
79
+ # Load only top-level markdown files
80
+ results = htm.load_directory("docs/", pattern: "*.md")
81
+
82
+ # Load specific subdirectory
83
+ results = htm.load_directory("docs/guides/", pattern: "**/*.md")
84
+ ```
85
+
86
+ ### nodes_from_file(path)
87
+
88
+ Returns all nodes loaded from a specific file.
89
+
90
+ ```ruby
91
+ nodes = htm.nodes_from_file("docs/guide.md")
92
+ nodes.each do |node|
93
+ puts "#{node.id}: #{node.content[0..50]}..."
94
+ end
95
+ ```
96
+
97
+ ### unload_file(path)
98
+
99
+ Soft deletes all nodes from a file and removes the file source.
100
+
101
+ ```ruby
102
+ count = htm.unload_file("docs/guide.md")
103
+ puts "Removed #{count} chunks"
104
+ ```
105
+
106
+ ## YAML Frontmatter
107
+
108
+ Files with YAML frontmatter have their metadata extracted and stored:
109
+
110
+ ```markdown
111
+ ---
112
+ title: PostgreSQL Guide
113
+ author: HTM Team
114
+ tags:
115
+ - database
116
+ - postgresql
117
+ version: 1.2
118
+ ---
119
+
120
+ # PostgreSQL Guide
121
+
122
+ Content starts here...
123
+ ```
124
+
125
+ Access frontmatter via the FileSource model:
126
+
127
+ ```ruby
128
+ source = HTM::Models::FileSource.find_by(file_path: "docs/guide.md")
129
+ source.title # => "PostgreSQL Guide"
130
+ source.author # => "HTM Team"
131
+ source.frontmatter_tags # => ["database", "postgresql"]
132
+ source.frontmatter # => { "title" => "...", "author" => "...", ... }
133
+ ```
134
+
135
+ ## Chunking Strategy
136
+
137
+ HTM uses the [Baran gem](https://github.com/baran) with `MarkdownSplitter` for intelligent chunking that respects markdown structure:
138
+
139
+ - **Headers**: Chunks break at header boundaries
140
+ - **Code blocks**: Code blocks are kept intact
141
+ - **Horizontal rules**: Natural section breaks
142
+ - **Configurable size**: Control chunk size and overlap
143
+
144
+ ### Configuration
145
+
146
+ ```ruby
147
+ # Global configuration
148
+ HTM.configure do |config|
149
+ config.chunk_size = 1024 # Characters per chunk (default: 1024)
150
+ config.chunk_overlap = 64 # Overlap between chunks (default: 64)
151
+ end
152
+
153
+ # Or via environment variables
154
+ # HTM_CHUNK_SIZE=512
155
+ # HTM_CHUNK_OVERLAP=50
156
+ ```
157
+
158
+ ### Per-Loader Configuration
159
+
160
+ ```ruby
161
+ loader = HTM::Loaders::MarkdownLoader.new(
162
+ htm,
163
+ chunk_size: 512,
164
+ chunk_overlap: 50
165
+ )
166
+ loader.load("docs/guide.md")
167
+ ```
168
+
169
+ ## Re-Sync Behavior
170
+
171
+ The file loading system tracks file modification times for efficient re-syncing:
172
+
173
+ 1. **First load**: Creates FileSource record and chunks
174
+ 2. **Subsequent loads**: Compares mtime, skips unchanged files
175
+ 3. **Changed files**: Re-chunks and updates nodes
176
+ 4. **Force reload**: Bypasses mtime check
177
+
178
+ ```ruby
179
+ # First load - creates chunks
180
+ htm.load_file("docs/guide.md")
181
+ # => { skipped: false, chunks_created: 5 }
182
+
183
+ # Second load - skipped (unchanged)
184
+ htm.load_file("docs/guide.md")
185
+ # => { skipped: true }
186
+
187
+ # After editing file - re-syncs
188
+ htm.load_file("docs/guide.md")
189
+ # => { skipped: false, chunks_updated: 2, chunks_created: 1 }
190
+
191
+ # Force reload
192
+ htm.load_file("docs/guide.md", force: true)
193
+ # => { skipped: false, chunks_updated: 5 }
194
+ ```
195
+
196
+ ## FileSource Model
197
+
198
+ The `HTM::Models::FileSource` tracks loaded files:
199
+
200
+ ```ruby
201
+ source = HTM::Models::FileSource.find_by(file_path: "docs/guide.md")
202
+
203
+ source.file_path # Full path to file
204
+ source.mtime # Last modification time
205
+ source.needs_sync? # Check if file changed since load
206
+ source.chunks # Associated nodes (ordered by position)
207
+ source.frontmatter # Parsed YAML frontmatter
208
+ source.title # Frontmatter title (convenience)
209
+ source.author # Frontmatter author (convenience)
210
+ source.frontmatter_tags # Tags from frontmatter
211
+ ```
212
+
213
+ ## Rake Tasks
214
+
215
+ HTM provides rake tasks for file management:
216
+
217
+ ```bash
218
+ # Load a single file
219
+ rake 'htm:files:load[docs/guide.md]'
220
+
221
+ # Load directory
222
+ rake 'htm:files:load_dir[docs/]'
223
+ rake 'htm:files:load_dir[docs/,**/*.md]'
224
+
225
+ # List loaded files
226
+ rake htm:files:list
227
+
228
+ # Show file details
229
+ rake 'htm:files:info[docs/guide.md]'
230
+
231
+ # Unload a file
232
+ rake 'htm:files:unload[docs/guide.md]'
233
+
234
+ # Sync all files (reload changed)
235
+ rake htm:files:sync
236
+
237
+ # Show statistics
238
+ rake htm:files:stats
239
+
240
+ # Force reload with FORCE=true
241
+ FORCE=true rake 'htm:files:load[docs/guide.md]'
242
+ ```
243
+
244
+ ## Best Practices
245
+
246
+ ### Organize Files Logically
247
+
248
+ ```ruby
249
+ # Load by category
250
+ htm.load_directory("docs/guides/", pattern: "**/*.md")
251
+ htm.load_directory("docs/api/", pattern: "**/*.md")
252
+ htm.load_directory("docs/tutorials/", pattern: "**/*.md")
253
+ ```
254
+
255
+ ### Use Frontmatter for Metadata
256
+
257
+ ```markdown
258
+ ---
259
+ title: API Authentication
260
+ category: api
261
+ tags:
262
+ - security
263
+ - authentication
264
+ priority: high
265
+ ---
266
+ ```
267
+
268
+ ### Tune Chunk Size for Your Content
269
+
270
+ ```ruby
271
+ # Smaller chunks for dense technical content
272
+ HTM.configure { |c| c.chunk_size = 512 }
273
+
274
+ # Larger chunks for narrative content
275
+ HTM.configure { |c| c.chunk_size = 2048 }
276
+ ```
277
+
278
+ ### Regular Sync for Updated Content
279
+
280
+ ```ruby
281
+ # Sync all loaded files periodically
282
+ htm.sync_files # Re-checks all FileSource records
283
+ ```
284
+
285
+ ## Example: Building a Knowledge Base
286
+
287
+ ```ruby
288
+ require 'htm'
289
+
290
+ # Initialize
291
+ htm = HTM.new(robot_name: "Knowledge Base")
292
+
293
+ # Configure chunking for technical docs
294
+ HTM.configure do |config|
295
+ config.chunk_size = 768
296
+ config.chunk_overlap = 100
297
+ end
298
+
299
+ # Load documentation
300
+ htm.load_directory("docs/", pattern: "**/*.md")
301
+ htm.load_directory("README.md")
302
+ htm.load_directory("CHANGELOG.md")
303
+
304
+ # Query the knowledge base
305
+ results = htm.recall(
306
+ "How do I configure authentication?",
307
+ strategy: :hybrid,
308
+ limit: 5
309
+ )
310
+
311
+ results.each do |result|
312
+ puts result['content']
313
+ puts "---"
314
+ end
315
+ ```
316
+
317
+ ## Related Documentation
318
+
319
+ - [Adding Memories](adding-memories.md) - Core memory operations
320
+ - [Search Strategies](search-strategies.md) - Querying loaded content
321
+ - [API Reference: HTM](../api/htm.md) - Complete API documentation
322
+ - [Example: File Loading](../examples/file-loading.md) - Working example
@@ -8,26 +8,47 @@ Before starting, ensure you have:
8
8
 
9
9
  1. **Ruby 3.0+** installed
10
10
  2. **PostgreSQL with TimescaleDB** (or access to a TimescaleDB cloud instance)
11
- 3. **Ollama** installed and running (for embeddings)
11
+ 3. **LLM Provider** configured - Ollama (default for local development), OpenAI, Anthropic, Gemini, or others via RubyLLM
12
12
  4. Basic understanding of Ruby and LLMs
13
13
 
14
- ### Installing Ollama
14
+ ### Configuring an LLM Provider
15
15
 
16
- HTM uses Ollama for generating vector embeddings by default:
16
+ HTM uses RubyLLM which supports multiple providers for generating embeddings and extracting tags.
17
+
18
+ **Option A: Ollama (Recommended for Local Development)**
17
19
 
18
20
  ```bash
19
21
  # Install Ollama
20
22
  curl https://ollama.ai/install.sh | sh
21
23
 
22
- # Pull the gpt-oss model (default for HTM)
23
- ollama pull gpt-oss
24
+ # Pull required models
25
+ ollama pull nomic-embed-text
26
+ ollama pull gemma3:latest
24
27
 
25
28
  # Verify Ollama is running
26
29
  curl http://localhost:11434/api/version
27
30
  ```
28
31
 
32
+ **Option B: OpenAI (Recommended for Production)**
33
+
34
+ ```bash
35
+ export OPENAI_API_KEY="sk-..."
36
+ ```
37
+
38
+ Configure HTM:
39
+ ```ruby
40
+ HTM.configure do |config|
41
+ config.embedding.provider = :openai
42
+ config.embedding.model = 'text-embedding-3-small'
43
+ end
44
+ ```
45
+
46
+ **Option C: Other Providers** (Anthropic, Gemini, Azure, Bedrock, DeepSeek)
47
+
48
+ Set the appropriate API key and configure HTM with your preferred provider.
49
+
29
50
  !!! tip
30
- The gpt-oss model provides high-quality embeddings optimized for semantic search. HTM uses these embeddings to understand the meaning of your memories, not just keyword matches.
51
+ HTM uses vector embeddings to understand the semantic meaning of your memories, not just keyword matches. Any provider will work—choose based on your privacy, cost, and quality requirements.
31
52
 
32
53
  ## Installation
33
54
 
@@ -55,10 +76,10 @@ HTM requires a TimescaleDB database. Set your database connection:
55
76
 
56
77
  ```bash
57
78
  # Add to your .bashrc or .zshrc
58
- export HTM_DBURL="postgresql://user:password@host:port/database"
79
+ export HTM_DATABASE__URL="postgresql://user:password@host:port/database"
59
80
 
60
81
  # Or create a config file
61
- echo "export HTM_DBURL='your-connection-string'" > ~/.bashrc__tiger
82
+ echo "export HTM_DATABASE__URL='your-connection-string'" > ~/.bashrc__tiger
62
83
  source ~/.bashrc__tiger
63
84
  ```
64
85
 
@@ -463,9 +484,9 @@ htm.forget(node_id, soft: false, confirm: :confirmed)
463
484
 
464
485
  ## Troubleshooting
465
486
 
466
- ### Ollama Connection Issues
487
+ ### LLM Provider Connection Issues
467
488
 
468
- If you see embedding errors:
489
+ **If using Ollama:**
469
490
 
470
491
  ```bash
471
492
  # Check Ollama is running
@@ -474,10 +495,20 @@ curl http://localhost:11434/api/version
474
495
  # If not running, start it
475
496
  ollama serve
476
497
 
477
- # Verify the model is available
498
+ # Verify the models are available
478
499
  ollama list
479
500
  ```
480
501
 
502
+ **If using cloud providers:**
503
+
504
+ ```bash
505
+ # Verify API key is set
506
+ echo $OPENAI_API_KEY # or ANTHROPIC_API_KEY, GEMINI_API_KEY, etc.
507
+
508
+ # Test connectivity
509
+ curl https://api.openai.com/v1/models -H "Authorization: Bearer $OPENAI_API_KEY"
510
+ ```
511
+
481
512
  ### Database Connection Issues
482
513
 
483
514
  ```ruby
data/docs/guides/index.md CHANGED
@@ -32,7 +32,7 @@ Learn how to work with HTM's memory system effectively.
32
32
 
33
33
  Dive deeper into HTM's powerful capabilities.
34
34
 
35
- - [**Multi-Robot Usage**](multi-robot.md) - Building hive mind systems with multiple robots
35
+ - [**Multi-Robot Usage**](../robots/multi-robot.md) - Building hive mind systems with multiple robots
36
36
  - [**Search Strategies**](search-strategies.md) - Vector, full-text, and hybrid search
37
37
  - [**Context Assembly**](context-assembly.md) - Creating optimized context for LLMs
38
38
 
@@ -62,7 +62,7 @@ We recommend the following progression:
62
62
  - [Search Strategies](search-strategies.md) - Optimize retrieval
63
63
 
64
64
  4. **Advanced Topics**: Multi-Robot Systems
65
- - [Multi-Robot Usage](multi-robot.md) - Build collaborative systems
65
+ - [Multi-Robot Usage](../robots/multi-robot.md) - Build collaborative systems
66
66
 
67
67
  ## Quick Reference
68
68
 
@@ -73,7 +73,7 @@ We recommend the following progression:
73
73
  - **Search for memories**: See [Recalling Memories](recalling-memories.md#basic-recall)
74
74
  - **Create LLM context**: See [Context Assembly](context-assembly.md#basic-usage)
75
75
  - **Monitor memory usage**: See [Working Memory](working-memory.md#monitoring-utilization)
76
- - **Multi-robot setup**: See [Multi-Robot Usage](multi-robot.md#setting-up-multiple-robots)
76
+ - **Multi-robot setup**: See [Multi-Robot Usage](../robots/multi-robot.md#setting-up-multiple-robots)
77
77
  - **Use with Claude/AIA**: See [MCP Server](mcp-server.md#client-configuration)
78
78
 
79
79
  ### Memory Types
@@ -803,7 +803,7 @@ begin
803
803
  conn.close
804
804
  rescue PG::Error => e
805
805
  puts "Connection failed: #{e.message}"
806
- puts "Check HTM_DBURL environment variable"
806
+ puts "Check HTM_DATABASE__URL environment variable"
807
807
  end
808
808
  ```
809
809
 
@@ -26,15 +26,23 @@ Before using the MCP server, ensure you have:
26
26
 
27
27
  2. **PostgreSQL database set up**
28
28
  ```bash
29
- export HTM_DBURL="postgresql://user@localhost:5432/htm_development"
29
+ export HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development"
30
30
  htm_mcp setup
31
31
  ```
32
32
 
33
- 3. **Ollama running** (for embeddings and tag extraction)
33
+ 3. **LLM provider configured** (for embeddings and tag extraction)
34
+
35
+ **Option A: Ollama (default for local development)**
34
36
  ```bash
35
37
  ollama serve
36
38
  ollama pull nomic-embed-text
37
- ollama pull llama3
39
+ ollama pull gemma3:latest
40
+ ```
41
+
42
+ **Option B: Cloud providers** (OpenAI, Anthropic, etc.)
43
+ ```bash
44
+ export OPENAI_API_KEY="sk-..."
45
+ # Configure via HTM.configure or environment variables
38
46
  ```
39
47
 
40
48
  ## Starting the Server
@@ -66,7 +74,7 @@ The `htm_mcp` executable includes management commands for database setup and dia
66
74
 
67
75
  ```bash
68
76
  # Set your database URL
69
- export HTM_DBURL="postgresql://user@localhost:5432/htm_development"
77
+ export HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development"
70
78
 
71
79
  # Initialize the database
72
80
  htm_mcp setup
@@ -681,8 +689,8 @@ Memory statistics as JSON.
681
689
  "current_robot": "my-assistant",
682
690
  "robot_id": 5,
683
691
  "robot_initialized": true,
684
- "embedding_provider": "ollama",
685
- "embedding_model": "nomic-embed-text"
692
+ "embedding_provider": "ollama", // or "openai", "gemini", etc.
693
+ "embedding_model": "nomic-embed-text" // provider-specific model
686
694
  }
687
695
  ```
688
696
 
@@ -745,7 +753,7 @@ Add to `~/.config/claude/claude_desktop_config.json` (Linux/macOS) or `%APPDATA%
745
753
  "htm-memory": {
746
754
  "command": "htm_mcp",
747
755
  "env": {
748
- "HTM_DBURL": "postgresql://user@localhost:5432/htm_development"
756
+ "HTM_DATABASE__URL": "postgresql://user@localhost:5432/htm_development"
749
757
  }
750
758
  }
751
759
  }
@@ -760,7 +768,7 @@ If `htm_mcp` is not in your PATH, use the absolute path:
760
768
  "htm-memory": {
761
769
  "command": "/path/to/htm_mcp",
762
770
  "env": {
763
- "HTM_DBURL": "postgresql://user@localhost:5432/htm_development"
771
+ "HTM_DATABASE__URL": "postgresql://user@localhost:5432/htm_development"
764
772
  }
765
773
  }
766
774
  }
@@ -782,7 +790,7 @@ Add to `~/.claude/claude_code_config.json`:
782
790
  "htm-memory": {
783
791
  "command": "htm_mcp",
784
792
  "env": {
785
- "HTM_DBURL": "postgresql://user@localhost:5432/htm_development"
793
+ "HTM_DATABASE__URL": "postgresql://user@localhost:5432/htm_development"
786
794
  }
787
795
  }
788
796
  }
@@ -812,7 +820,7 @@ mcp_servers:
812
820
  htm-memory:
813
821
  command: htm_mcp
814
822
  env:
815
- HTM_DBURL: postgresql://user@localhost:5432/htm_development
823
+ HTM_DATABASE__URL: postgresql://user@localhost:5432/htm_development
816
824
  ```
817
825
 
818
826
  For project-specific configuration, add to `.aia/config.yml` in your project root:
@@ -822,7 +830,7 @@ mcp_servers:
822
830
  htm-memory:
823
831
  command: htm_mcp
824
832
  env:
825
- HTM_DBURL: postgresql://user@localhost:5432/my_project_htm
833
+ HTM_DATABASE__URL: postgresql://user@localhost:5432/my_project_htm
826
834
  ```
827
835
 
828
836
  ## Usage Examples
@@ -952,9 +960,9 @@ This will find `database:postgresql` even with the typo.
952
960
  gem install fast-mcp
953
961
  ```
954
962
 
955
- **Error: `HTM_DBURL not set`**
963
+ **Error: `HTM_DATABASE__URL not set`**
956
964
  ```bash
957
- export HTM_DBURL="postgresql://user@localhost:5432/htm_development"
965
+ export HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development"
958
966
  ```
959
967
 
960
968
  ### Database Connection Issues
@@ -982,16 +990,22 @@ psql htm_development -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
982
990
  **Claude Code doesn't recognize tools:**
983
991
  1. Run `/mcp` to refresh MCP connections
984
992
  2. Verify config is valid JSON
985
- 3. Check that HTM_DBURL is set in the env section
993
+ 3. Check that HTM_DATABASE__URL is set in the env section
986
994
 
987
995
  ### Embedding/Tag Errors
988
996
 
989
- **Error: `Connection refused` (Ollama)**
997
+ **Error: `Connection refused` (when using Ollama)**
990
998
  1. Start Ollama: `ollama serve`
991
999
  2. Pull required models:
992
1000
  ```bash
993
1001
  ollama pull nomic-embed-text
994
- ollama pull llama3
1002
+ ollama pull gemma3:latest
1003
+ ```
1004
+
1005
+ **Error: `API key invalid` (when using cloud providers)**
1006
+ 1. Verify the API key is set:
1007
+ ```bash
1008
+ echo $OPENAI_API_KEY # or ANTHROPIC_API_KEY, GEMINI_API_KEY
995
1009
  ```
996
1010
 
997
1011
  ### Debugging
@@ -1011,34 +1025,38 @@ Run `htm_mcp help` for a complete list. Key variables:
1011
1025
 
1012
1026
  | Variable | Description |
1013
1027
  |----------|-------------|
1014
- | `HTM_DBURL` | PostgreSQL connection URL (e.g., `postgresql://user:pass@localhost:5432/htm_development`) |
1028
+ | `HTM_DATABASE__URL` | PostgreSQL connection URL (e.g., `postgresql://user:pass@localhost:5432/htm_development`) |
1015
1029
 
1016
- ### Database (alternative to HTM_DBURL)
1030
+ ### Database (alternative to HTM_DATABASE__URL)
1017
1031
 
1018
1032
  | Variable | Description | Default |
1019
1033
  |----------|-------------|---------|
1020
- | `HTM_DBNAME` | Database name | - |
1021
- | `HTM_DBHOST` | Database host | `localhost` |
1022
- | `HTM_DBPORT` | Database port | `5432` |
1023
- | `HTM_DBUSER` | Database username | - |
1024
- | `HTM_DBPASS` | Database password | - |
1034
+ | `HTM_DATABASE__NAME` | Database name | - |
1035
+ | `HTM_DATABASE__HOST` | Database host | `localhost` |
1036
+ | `HTM_DATABASE__PORT` | Database port | `5432` |
1037
+ | `HTM_DATABASE__USER` | Database username | - |
1038
+ | `HTM_DATABASE__PASSWORD` | Database password | - |
1025
1039
  | `HTM_DBSSLMODE` | SSL mode | `prefer` |
1026
1040
 
1027
1041
  ### LLM Providers
1028
1042
 
1043
+ HTM uses RubyLLM which supports multiple providers. Defaults to Ollama for local development.
1044
+
1029
1045
  | Variable | Description | Default |
1030
1046
  |----------|-------------|---------|
1031
- | `HTM_EMBEDDING_PROVIDER` | Embedding provider | `ollama` |
1032
- | `HTM_EMBEDDING_MODEL` | Embedding model | `nomic-embed-text:latest` |
1047
+ | `HTM_EMBEDDING_PROVIDER` | Embedding provider (`ollama`, `openai`, `gemini`, etc.) | `ollama` |
1048
+ | `HTM_EMBEDDING_MODEL` | Embedding model (provider-specific) | `nomic-embed-text` |
1033
1049
  | `HTM_TAG_PROVIDER` | Tag extraction provider | `ollama` |
1034
1050
  | `HTM_TAG_MODEL` | Tag model | `gemma3:latest` |
1035
- | `HTM_OLLAMA_URL` | Ollama server URL | `http://localhost:11434` |
1051
+ | `HTM_OLLAMA_URL` | Ollama server URL (if using Ollama) | `http://localhost:11434` |
1036
1052
 
1037
- ### Other Providers (set API keys as needed)
1053
+ ### Cloud Provider API Keys
1038
1054
 
1039
1055
  | Variable | Description |
1040
1056
  |----------|-------------|
1041
- | `HTM_OPENAI_API_KEY` | OpenAI API key |
1057
+ | `OPENAI_API_KEY` | OpenAI API key |
1058
+ | `ANTHROPIC_API_KEY` | Anthropic API key |
1059
+ | `GEMINI_API_KEY` | Google Gemini API key |
1042
1060
  | `HTM_ANTHROPIC_API_KEY` | Anthropic API key |
1043
1061
  | `HTM_GEMINI_API_KEY` | Google Gemini API key |
1044
1062
  | `HTM_AZURE_API_KEY` | Azure OpenAI API key |
@@ -1049,4 +1067,4 @@ Run `htm_mcp help` for a complete list. Key variables:
1049
1067
  - [Getting Started](getting-started.md) - HTM basics
1050
1068
  - [Adding Memories](adding-memories.md) - Learn about tags and metadata
1051
1069
  - [Recalling Memories](recalling-memories.md) - Search strategies
1052
- - [Multi-Robot Systems](multi-robot.md) - Working with multiple robots
1070
+ - [Multi-Robot Systems](../robots/multi-robot.md) - Working with multiple robots