htm 0.0.15 → 0.0.18
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/.architecture/decisions/adrs/001-use-postgresql-timescaledb-storage.md +1 -1
- data/.architecture/decisions/adrs/011-database-side-embedding-generation-with-pgai.md +4 -4
- data/.architecture/decisions/adrs/012-llm-driven-ontology-topic-extraction.md +1 -1
- data/.envrc +12 -24
- data/.irbrc +7 -7
- data/.tbls.yml +2 -2
- data/CHANGELOG.md +138 -0
- data/README.md +97 -1592
- data/Rakefile +8 -3
- data/SETUP.md +12 -12
- data/bin/htm_mcp +27 -0
- data/db/seed_data/README.md +2 -2
- data/db/seeds.rb +2 -2
- data/docs/api/database.md +37 -37
- data/docs/api/htm.md +1 -1
- data/docs/api/yard/HTM/ActiveRecordConfig.md +2 -2
- data/docs/api/yard/HTM/Configuration.md +26 -15
- data/docs/api/yard/HTM/Database.md +7 -8
- data/docs/api/yard/HTM/JobAdapter.md +1 -1
- data/docs/api/yard/HTM/Railtie.md +2 -2
- data/docs/architecture/adrs/001-postgresql-timescaledb.md +1 -1
- data/docs/architecture/adrs/011-pgai-integration.md +4 -4
- data/docs/database_rake_tasks.md +5 -5
- data/docs/development/rake-tasks.md +11 -11
- data/docs/development/setup.md +21 -21
- data/docs/development/testing.md +1 -1
- data/docs/getting-started/installation.md +51 -31
- data/docs/getting-started/quick-start.md +12 -12
- data/docs/guides/getting-started.md +2 -2
- data/docs/guides/long-term-memory.md +1 -1
- data/docs/guides/mcp-server.md +464 -29
- data/docs/guides/robot-groups.md +8 -8
- data/docs/index.md +4 -4
- data/docs/multi_framework_support.md +10 -10
- data/docs/setup_local_database.md +19 -19
- data/docs/using_rake_tasks_in_your_app.md +14 -14
- data/examples/README.md +50 -6
- data/examples/basic_usage.rb +31 -21
- data/examples/cli_app/README.md +8 -8
- data/examples/cli_app/htm_cli.rb +5 -5
- data/examples/config_file_example/README.md +256 -0
- data/examples/config_file_example/config/htm.local.yml +34 -0
- data/examples/config_file_example/custom_config.yml +22 -0
- data/examples/config_file_example/show_config.rb +125 -0
- data/examples/custom_llm_configuration.rb +7 -7
- data/examples/example_app/Rakefile +2 -2
- data/examples/example_app/app.rb +8 -8
- data/examples/file_loader_usage.rb +9 -9
- data/examples/mcp_client.rb +7 -7
- data/examples/rails_app/.gitignore +2 -0
- data/examples/rails_app/Gemfile +22 -0
- data/examples/rails_app/Gemfile.lock +430 -0
- data/examples/rails_app/Procfile.dev +1 -0
- data/examples/rails_app/README.md +98 -0
- data/examples/rails_app/Rakefile +5 -0
- data/examples/rails_app/app/assets/stylesheets/application.css +83 -0
- data/examples/rails_app/app/assets/stylesheets/inter-font.css +6 -0
- data/examples/rails_app/app/controllers/application_controller.rb +19 -0
- data/examples/rails_app/app/controllers/dashboard_controller.rb +27 -0
- data/examples/rails_app/app/controllers/files_controller.rb +205 -0
- data/examples/rails_app/app/controllers/memories_controller.rb +102 -0
- data/examples/rails_app/app/controllers/robots_controller.rb +44 -0
- data/examples/rails_app/app/controllers/search_controller.rb +46 -0
- data/examples/rails_app/app/controllers/tags_controller.rb +30 -0
- data/examples/rails_app/app/javascript/application.js +4 -0
- data/examples/rails_app/app/javascript/controllers/application.js +9 -0
- data/examples/rails_app/app/javascript/controllers/index.js +6 -0
- data/examples/rails_app/app/views/dashboard/index.html.erb +123 -0
- data/examples/rails_app/app/views/files/index.html.erb +108 -0
- data/examples/rails_app/app/views/files/new.html.erb +321 -0
- data/examples/rails_app/app/views/files/show.html.erb +130 -0
- data/examples/rails_app/app/views/layouts/application.html.erb +124 -0
- data/examples/rails_app/app/views/memories/_memory_card.html.erb +51 -0
- data/examples/rails_app/app/views/memories/deleted.html.erb +62 -0
- data/examples/rails_app/app/views/memories/edit.html.erb +35 -0
- data/examples/rails_app/app/views/memories/index.html.erb +81 -0
- data/examples/rails_app/app/views/memories/new.html.erb +71 -0
- data/examples/rails_app/app/views/memories/show.html.erb +126 -0
- data/examples/rails_app/app/views/robots/index.html.erb +106 -0
- data/examples/rails_app/app/views/robots/new.html.erb +36 -0
- data/examples/rails_app/app/views/robots/show.html.erb +79 -0
- data/examples/rails_app/app/views/search/index.html.erb +184 -0
- data/examples/rails_app/app/views/shared/_navbar.html.erb +52 -0
- data/examples/rails_app/app/views/shared/_stat_card.html.erb +52 -0
- data/examples/rails_app/app/views/tags/index.html.erb +131 -0
- data/examples/rails_app/app/views/tags/show.html.erb +67 -0
- data/examples/rails_app/bin/dev +8 -0
- data/examples/rails_app/bin/rails +4 -0
- data/examples/rails_app/bin/rake +4 -0
- data/examples/rails_app/config/application.rb +33 -0
- data/examples/rails_app/config/boot.rb +5 -0
- data/examples/rails_app/config/database.yml +15 -0
- data/examples/rails_app/config/environment.rb +5 -0
- data/examples/rails_app/config/importmap.rb +7 -0
- data/examples/rails_app/config/routes.rb +38 -0
- data/examples/rails_app/config/tailwind.config.js +35 -0
- data/examples/rails_app/config.ru +5 -0
- data/examples/rails_app/log/.keep +0 -0
- data/examples/rails_app/tmp/local_secret.txt +1 -0
- data/examples/robot_groups/multi_process.rb +5 -5
- data/examples/robot_groups/robot_worker.rb +5 -5
- data/examples/robot_groups/same_process.rb +9 -9
- data/examples/sinatra_app/app.rb +1 -1
- data/examples/timeframe_demo.rb +1 -1
- data/lib/htm/active_record_config.rb +12 -28
- data/lib/htm/circuit_breaker.rb +0 -2
- data/lib/htm/config/defaults.yml +246 -0
- data/lib/htm/config.rb +888 -0
- data/lib/htm/database.rb +26 -33
- data/lib/htm/embedding_service.rb +0 -4
- data/lib/htm/integrations/sinatra.rb +3 -7
- data/lib/htm/job_adapter.rb +1 -15
- data/lib/htm/jobs/generate_embedding_job.rb +1 -7
- data/lib/htm/jobs/generate_propositions_job.rb +2 -12
- data/lib/htm/jobs/generate_tags_job.rb +1 -8
- data/lib/htm/loaders/defaults_loader.rb +143 -0
- data/lib/htm/loaders/xdg_config_loader.rb +116 -0
- data/lib/htm/mcp/cli.rb +475 -0
- data/lib/htm/mcp/group_tools.rb +476 -0
- data/lib/htm/mcp/resources.rb +89 -0
- data/lib/htm/mcp/server.rb +98 -0
- data/lib/htm/mcp/tools.rb +488 -0
- data/lib/htm/models/file_source.rb +5 -3
- data/lib/htm/proposition_service.rb +2 -12
- data/lib/htm/railtie.rb +3 -8
- data/lib/htm/tag_service.rb +1 -8
- data/lib/htm/tasks.rb +7 -4
- data/lib/htm/version.rb +1 -1
- data/lib/htm.rb +124 -5
- data/lib/tasks/htm.rake +6 -9
- metadata +81 -6
- data/bin/htm_mcp.rb +0 -621
- data/config/database.yml +0 -74
- data/lib/htm/configuration.rb +0 -766
data/Rakefile
CHANGED
|
@@ -10,16 +10,21 @@ Rake::TestTask.new(:test) do |t|
|
|
|
10
10
|
t.verbose = true
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
# Ensure test task runs with
|
|
13
|
+
# Ensure test task runs with HTM_ENV=test (takes priority over RAILS_ENV/RACK_ENV)
|
|
14
14
|
task :test do
|
|
15
|
-
ENV['
|
|
15
|
+
ENV['HTM_ENV'] = 'test'
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# Prepend environment setup before test runs
|
|
19
19
|
Rake::Task[:test].enhance [:set_test_env]
|
|
20
20
|
|
|
21
21
|
task :set_test_env do
|
|
22
|
-
ENV['
|
|
22
|
+
ENV['HTM_ENV'] = 'test'
|
|
23
|
+
# Set database URL if not already configured
|
|
24
|
+
# Uses current system user for local PostgreSQL connection
|
|
25
|
+
unless ENV['HTM_DATABASE__URL']
|
|
26
|
+
ENV['HTM_DATABASE__URL'] = "postgresql://#{ENV['USER']}@localhost:5432/htm_test"
|
|
27
|
+
end
|
|
23
28
|
end
|
|
24
29
|
|
|
25
30
|
task default: :test
|
data/SETUP.md
CHANGED
|
@@ -60,10 +60,10 @@ psql htm_development -c "SELECT extname, extversion FROM pg_extension;"
|
|
|
60
60
|
|
|
61
61
|
```bash
|
|
62
62
|
# Add to your ~/.bashrc or ~/.zshrc
|
|
63
|
-
export
|
|
63
|
+
export HTM_DATABASE__URL="postgresql://postgres@localhost:5432/htm_development"
|
|
64
64
|
|
|
65
65
|
# Or for a specific user with password
|
|
66
|
-
export
|
|
66
|
+
export HTM_DATABASE__URL="postgresql://username:password@localhost:5432/htm_development"
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
### 5. Verify Connection
|
|
@@ -136,12 +136,12 @@ export OLLAMA_URL="http://custom-host:11434"
|
|
|
136
136
|
|
|
137
137
|
| Variable | Description | Example Value |
|
|
138
138
|
|----------|-------------|---------------|
|
|
139
|
-
| `
|
|
140
|
-
| `
|
|
141
|
-
| `
|
|
142
|
-
| `
|
|
143
|
-
| `
|
|
144
|
-
| `
|
|
139
|
+
| `HTM_DATABASE__URL` | Full PostgreSQL connection URL (preferred) | `postgresql://postgres@localhost:5432/htm_development` |
|
|
140
|
+
| `HTM_DATABASE__NAME` | Database name (fallback) | `htm_development` |
|
|
141
|
+
| `HTM_DATABASE__USER` | Database user (fallback) | `postgres` |
|
|
142
|
+
| `HTM_DATABASE__PASSWORD` | Database password (fallback) | `` |
|
|
143
|
+
| `HTM_DATABASE__HOST` | Database host (fallback) | `localhost` |
|
|
144
|
+
| `HTM_DATABASE__PORT` | Database port (fallback) | `5432` |
|
|
145
145
|
| `OLLAMA_URL` | Ollama server URL | `http://localhost:11434` |
|
|
146
146
|
|
|
147
147
|
## Development Workflow
|
|
@@ -150,7 +150,7 @@ export OLLAMA_URL="http://custom-host:11434"
|
|
|
150
150
|
|
|
151
151
|
```bash
|
|
152
152
|
# 1. Set database URL (if not in shell config)
|
|
153
|
-
export
|
|
153
|
+
export HTM_DATABASE__URL="postgresql://postgres@localhost:5432/htm_development"
|
|
154
154
|
|
|
155
155
|
# 2. Install dependencies
|
|
156
156
|
bundle install
|
|
@@ -196,7 +196,7 @@ HTM/
|
|
|
196
196
|
│ │ ├── configuration.rb # Multi-provider LLM config
|
|
197
197
|
│ │ └── version.rb # Version constant
|
|
198
198
|
├── config/
|
|
199
|
-
│ └──
|
|
199
|
+
│ └── defaults.yml # Default configuration values
|
|
200
200
|
├── db/
|
|
201
201
|
│ └── schema.sql # Database schema
|
|
202
202
|
├── test/
|
|
@@ -248,10 +248,10 @@ If you get connection errors:
|
|
|
248
248
|
|
|
249
249
|
```bash
|
|
250
250
|
# Verify environment variable is set
|
|
251
|
-
echo $
|
|
251
|
+
echo $HTM_DATABASE__URL
|
|
252
252
|
|
|
253
253
|
# Test connection manually
|
|
254
|
-
psql $
|
|
254
|
+
psql $HTM_DATABASE__URL -c "SELECT 1"
|
|
255
255
|
|
|
256
256
|
# Check PostgreSQL is running
|
|
257
257
|
brew services list | grep postgresql # macOS
|
data/bin/htm_mcp
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# HTM MCP Server with CLI management commands
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# htm_mcp # Start MCP server (default)
|
|
8
|
+
# htm_mcp server # Start MCP server (explicit)
|
|
9
|
+
# htm_mcp setup # Initialize database
|
|
10
|
+
# htm_mcp init # Initialize database (alias for setup)
|
|
11
|
+
# htm_mcp verify # Verify database connection
|
|
12
|
+
# htm_mcp stats # Show memory statistics
|
|
13
|
+
# htm_mcp version # Show HTM version
|
|
14
|
+
# htm_mcp help # Show help and environment variables
|
|
15
|
+
|
|
16
|
+
require_relative '../lib/htm'
|
|
17
|
+
require_relative '../lib/htm/mcp/cli'
|
|
18
|
+
|
|
19
|
+
# Handle CLI commands (exits if command handled)
|
|
20
|
+
# Returns false if server should start
|
|
21
|
+
unless HTM::MCP::CLI.run(ARGV) == false
|
|
22
|
+
exit 0
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Start MCP server
|
|
26
|
+
require_relative '../lib/htm/mcp/server'
|
|
27
|
+
HTM::MCP::Server.start
|
data/db/seed_data/README.md
CHANGED
|
@@ -23,8 +23,8 @@ The seeding process uses environment variables for configuration. All settings h
|
|
|
23
23
|
|
|
24
24
|
### Database Settings
|
|
25
25
|
|
|
26
|
-
- `
|
|
27
|
-
- Or individual settings: `
|
|
26
|
+
- `HTM_DATABASE__URL` - Full PostgreSQL connection URL (required)
|
|
27
|
+
- Or individual settings: `HTM_DATABASE__HOST`, `HTM_DATABASE__PORT`, `HTM_DATABASE__NAME`, `HTM_DATABASE__USER`, `HTM_DATABASE__PASSWORD`
|
|
28
28
|
|
|
29
29
|
### Other Settings
|
|
30
30
|
|
data/db/seeds.rb
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
# HTM_EMBEDDING_TIMEOUT - Embedding generation timeout in seconds (default: 120)
|
|
16
16
|
# HTM_TAG_TIMEOUT - Tag generation timeout in seconds (default: 180)
|
|
17
17
|
# HTM_CONNECTION_TIMEOUT - LLM connection timeout in seconds (default: 30)
|
|
18
|
-
#
|
|
18
|
+
# HTM_DATABASE__URL - Database connection URL
|
|
19
19
|
#
|
|
20
20
|
# Usage:
|
|
21
21
|
# rake htm:db:seed
|
|
@@ -64,7 +64,7 @@ end
|
|
|
64
64
|
puts "✓ HTM configured"
|
|
65
65
|
puts
|
|
66
66
|
|
|
67
|
-
# Create HTM instance (uses default database config from ENV['
|
|
67
|
+
# Create HTM instance (uses default database config from ENV['HTM_DATABASE__URL'])
|
|
68
68
|
htm = HTM.new(robot_name: ENV['HTM_ROBOT_NAME'] || "Seed Robot")
|
|
69
69
|
|
|
70
70
|
# Add sample conversation messages
|
data/docs/api/database.md
CHANGED
|
@@ -38,7 +38,7 @@ HTM::Database.setup(db_url = nil)
|
|
|
38
38
|
|
|
39
39
|
| Parameter | Type | Default | Description |
|
|
40
40
|
|-----------|------|---------|-------------|
|
|
41
|
-
| `db_url` | String, nil | `ENV['
|
|
41
|
+
| `db_url` | String, nil | `ENV['HTM_DATABASE__URL']` | Database connection URL |
|
|
42
42
|
|
|
43
43
|
#### Returns
|
|
44
44
|
|
|
@@ -170,25 +170,25 @@ HTM::Database.parse_connection_params()
|
|
|
170
170
|
#### Returns
|
|
171
171
|
|
|
172
172
|
- `Hash` - Connection configuration
|
|
173
|
-
- `nil` - If `ENV['
|
|
173
|
+
- `nil` - If `ENV['HTM_DATABASE__NAME']` not set
|
|
174
174
|
|
|
175
175
|
#### Environment Variables
|
|
176
176
|
|
|
177
177
|
| Variable | Description | Default |
|
|
178
178
|
|----------|-------------|---------|
|
|
179
|
-
| `
|
|
180
|
-
| `
|
|
181
|
-
| `
|
|
182
|
-
| `
|
|
183
|
-
| `
|
|
179
|
+
| `HTM_DATABASE__HOST` | Database hostname | `'cw7rxj91bm.srbbwwxn56.tsdb.cloud.timescale.com'` |
|
|
180
|
+
| `HTM_DATABASE__PORT` | Database port | `37807` |
|
|
181
|
+
| `HTM_DATABASE__NAME` | Database name | *required* |
|
|
182
|
+
| `HTM_DATABASE__USER` | Database user | *required* |
|
|
183
|
+
| `HTM_DATABASE__PASSWORD` | Database password | *required* |
|
|
184
184
|
|
|
185
185
|
#### Examples
|
|
186
186
|
|
|
187
187
|
```ruby
|
|
188
188
|
# Set environment variables
|
|
189
|
-
ENV['
|
|
190
|
-
ENV['
|
|
191
|
-
ENV['
|
|
189
|
+
ENV['HTM_DATABASE__NAME'] = 'tsdb'
|
|
190
|
+
ENV['HTM_DATABASE__USER'] = 'tsdbadmin'
|
|
191
|
+
ENV['HTM_DATABASE__PASSWORD'] = 'secret'
|
|
192
192
|
|
|
193
193
|
config = HTM::Database.parse_connection_params()
|
|
194
194
|
# => {
|
|
@@ -201,14 +201,14 @@ config = HTM::Database.parse_connection_params()
|
|
|
201
201
|
# }
|
|
202
202
|
|
|
203
203
|
# Custom host and port
|
|
204
|
-
ENV['
|
|
205
|
-
ENV['
|
|
204
|
+
ENV['HTM_DATABASE__HOST'] = 'localhost'
|
|
205
|
+
ENV['HTM_DATABASE__PORT'] = '5432'
|
|
206
206
|
|
|
207
207
|
config = HTM::Database.parse_connection_params()
|
|
208
208
|
# => { host: "localhost", port: 5432, ... }
|
|
209
209
|
|
|
210
|
-
# Without
|
|
211
|
-
ENV.delete('
|
|
210
|
+
# Without HTM_DATABASE__NAME
|
|
211
|
+
ENV.delete('HTM_DATABASE__NAME')
|
|
212
212
|
config = HTM::Database.parse_connection_params()
|
|
213
213
|
# => nil
|
|
214
214
|
```
|
|
@@ -230,29 +230,29 @@ HTM::Database.default_config()
|
|
|
230
230
|
|
|
231
231
|
#### Priority Order
|
|
232
232
|
|
|
233
|
-
1. `ENV['
|
|
234
|
-
2. `ENV['
|
|
233
|
+
1. `ENV['HTM_DATABASE__URL']` - Parse connection URL
|
|
234
|
+
2. `ENV['HTM_DATABASE__NAME']` - Parse individual params
|
|
235
235
|
3. `nil` - No configuration available
|
|
236
236
|
|
|
237
237
|
#### Examples
|
|
238
238
|
|
|
239
239
|
```ruby
|
|
240
|
-
# Using
|
|
241
|
-
ENV['
|
|
240
|
+
# Using HTM_DATABASE__URL
|
|
241
|
+
ENV['HTM_DATABASE__URL'] = 'postgresql://user:pass@host/db'
|
|
242
242
|
config = HTM::Database.default_config
|
|
243
243
|
# => Parsed from URL
|
|
244
244
|
|
|
245
|
-
# Using
|
|
246
|
-
ENV.delete('
|
|
247
|
-
ENV['
|
|
248
|
-
ENV['
|
|
249
|
-
ENV['
|
|
245
|
+
# Using HTM_DATABASE__NAME
|
|
246
|
+
ENV.delete('HTM_DATABASE__URL')
|
|
247
|
+
ENV['HTM_DATABASE__NAME'] = 'mydb'
|
|
248
|
+
ENV['HTM_DATABASE__USER'] = 'user'
|
|
249
|
+
ENV['HTM_DATABASE__PASSWORD'] = 'pass'
|
|
250
250
|
config = HTM::Database.default_config
|
|
251
251
|
# => Parsed from params
|
|
252
252
|
|
|
253
253
|
# No configuration
|
|
254
|
-
ENV.delete('
|
|
255
|
-
ENV.delete('
|
|
254
|
+
ENV.delete('HTM_DATABASE__URL')
|
|
255
|
+
ENV.delete('HTM_DATABASE__NAME')
|
|
256
256
|
config = HTM::Database.default_config
|
|
257
257
|
# => nil
|
|
258
258
|
|
|
@@ -341,33 +341,33 @@ Using URL (recommended):
|
|
|
341
341
|
|
|
342
342
|
```bash
|
|
343
343
|
# In ~/.bashrc__tiger
|
|
344
|
-
export
|
|
344
|
+
export HTM_DATABASE__URL='postgresql://tsdbadmin:PASSWORD@SERVICE.tsdb.cloud.timescale.com:37807/tsdb?sslmode=require'
|
|
345
345
|
```
|
|
346
346
|
|
|
347
347
|
Using individual variables:
|
|
348
348
|
|
|
349
349
|
```bash
|
|
350
350
|
# In ~/.bashrc__tiger
|
|
351
|
-
export
|
|
352
|
-
export
|
|
353
|
-
export
|
|
354
|
-
export
|
|
355
|
-
export
|
|
351
|
+
export HTM_DATABASE__HOST='xxx.tsdb.cloud.timescale.com'
|
|
352
|
+
export HTM_DATABASE__PORT=37807
|
|
353
|
+
export HTM_DATABASE__NAME='tsdb'
|
|
354
|
+
export HTM_DATABASE__USER='tsdbadmin'
|
|
355
|
+
export HTM_DATABASE__PASSWORD='your_password'
|
|
356
356
|
```
|
|
357
357
|
|
|
358
358
|
### Local PostgreSQL
|
|
359
359
|
|
|
360
360
|
```bash
|
|
361
|
-
export
|
|
361
|
+
export HTM_DATABASE__URL='postgresql://localhost/htm_dev'
|
|
362
362
|
|
|
363
363
|
# Or with auth
|
|
364
|
-
export
|
|
364
|
+
export HTM_DATABASE__URL='postgresql://user:pass@localhost:5432/htm_dev'
|
|
365
365
|
```
|
|
366
366
|
|
|
367
367
|
### Docker PostgreSQL
|
|
368
368
|
|
|
369
369
|
```bash
|
|
370
|
-
export
|
|
370
|
+
export HTM_DATABASE__URL='postgresql://postgres:postgres@localhost:5432/htm'
|
|
371
371
|
```
|
|
372
372
|
|
|
373
373
|
---
|
|
@@ -402,7 +402,7 @@ if config
|
|
|
402
402
|
puts "Port: #{config[:port]}"
|
|
403
403
|
else
|
|
404
404
|
puts "No database configuration found"
|
|
405
|
-
puts "Please set
|
|
405
|
+
puts "Please set HTM_DATABASE__URL or HTM_DATABASE__NAME environment variables"
|
|
406
406
|
end
|
|
407
407
|
|
|
408
408
|
# Test connection
|
|
@@ -493,7 +493,7 @@ pg_isready -h localhost -p 5432
|
|
|
493
493
|
psql -h localhost -U user -d dbname
|
|
494
494
|
|
|
495
495
|
# Verify environment
|
|
496
|
-
echo $
|
|
496
|
+
echo $HTM_DATABASE__URL
|
|
497
497
|
```
|
|
498
498
|
|
|
499
499
|
### Permission Denied
|
|
@@ -576,7 +576,7 @@ end
|
|
|
576
576
|
config = HTM::Database.default_config
|
|
577
577
|
|
|
578
578
|
unless config
|
|
579
|
-
raise "Database not configured. Please set
|
|
579
|
+
raise "Database not configured. Please set HTM_DATABASE__URL environment variable. " \
|
|
580
580
|
"See README.md for configuration instructions."
|
|
581
581
|
end
|
|
582
582
|
```
|
data/docs/api/htm.md
CHANGED
|
@@ -49,7 +49,7 @@ HTM.new(
|
|
|
49
49
|
|-----------|------|---------|-------------|
|
|
50
50
|
| `working_memory_size` | Integer | `128_000` | Maximum tokens for working memory |
|
|
51
51
|
| `robot_name` | String, nil | `"robot_#{uuid[0..7]}"` | Human-readable name |
|
|
52
|
-
| `db_config` | Hash, nil | From `ENV['
|
|
52
|
+
| `db_config` | Hash, nil | From `ENV['HTM_DATABASE__URL']` | Database configuration |
|
|
53
53
|
| `db_pool_size` | Integer | `5` | Database connection pool size |
|
|
54
54
|
| `db_query_timeout` | Integer | `30_000` | Query timeout in milliseconds |
|
|
55
55
|
| `db_cache_size` | Integer | `1000` | Query cache size (0 to disable) |
|
|
@@ -15,9 +15,9 @@ Get connection pool statistics
|
|
|
15
15
|
## disconnect!() {: #method-c-disconnect! }
|
|
16
16
|
Close all database connections
|
|
17
17
|
## establish_connection!() {: #method-c-establish_connection! }
|
|
18
|
-
Establish database connection from
|
|
18
|
+
Establish database connection from HTM::Config
|
|
19
19
|
## load_database_config() {: #method-c-load_database_config }
|
|
20
|
-
Load
|
|
20
|
+
Load database configuration from HTM::Config
|
|
21
21
|
## verify_extensions!() {: #method-c-verify_extensions! }
|
|
22
22
|
Verify required extensions are available
|
|
23
23
|
|
|
@@ -16,37 +16,48 @@ HTM uses RubyLLM for multi-provider LLM support. Supported providers:
|
|
|
16
16
|
* :deepseek (DeepSeek)
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
**`@example`**
|
|
19
|
+
**`@example`** Using nested configuration sections
|
|
20
20
|
```ruby
|
|
21
21
|
HTM.configure do |config|
|
|
22
|
-
config.
|
|
23
|
-
config.
|
|
24
|
-
config.
|
|
25
|
-
config.
|
|
22
|
+
config.embedding.provider = :openai
|
|
23
|
+
config.embedding.model = 'text-embedding-3-small'
|
|
24
|
+
config.tag.provider = :openai
|
|
25
|
+
config.tag.model = 'gpt-4o-mini'
|
|
26
26
|
config.openai_api_key = ENV['OPENAI_API_KEY']
|
|
27
27
|
end
|
|
28
28
|
```
|
|
29
|
-
**`@example`**
|
|
29
|
+
**`@example`** Using Ollama (local default)
|
|
30
30
|
```ruby
|
|
31
31
|
HTM.configure do |config|
|
|
32
|
-
config.
|
|
33
|
-
config.
|
|
34
|
-
config.
|
|
35
|
-
config.
|
|
32
|
+
config.embedding.provider = :ollama
|
|
33
|
+
config.embedding.model = 'nomic-embed-text'
|
|
34
|
+
config.tag.provider = :ollama
|
|
35
|
+
config.tag.model = 'llama3'
|
|
36
36
|
config.ollama_url = 'http://localhost:11434'
|
|
37
37
|
end
|
|
38
38
|
```
|
|
39
|
-
**`@example`**
|
|
39
|
+
**`@example`** Mixed providers
|
|
40
40
|
```ruby
|
|
41
41
|
HTM.configure do |config|
|
|
42
|
-
config.
|
|
43
|
-
config.
|
|
42
|
+
config.embedding.provider = :openai
|
|
43
|
+
config.embedding.model = 'text-embedding-3-small'
|
|
44
44
|
config.openai_api_key = ENV['OPENAI_API_KEY']
|
|
45
|
-
config.
|
|
46
|
-
config.
|
|
45
|
+
config.tag.provider = :anthropic
|
|
46
|
+
config.tag.model = 'claude-3-haiku-20240307'
|
|
47
47
|
config.anthropic_api_key = ENV['ANTHROPIC_API_KEY']
|
|
48
48
|
end
|
|
49
49
|
```
|
|
50
|
+
**`@example`** Job and chunking configuration
|
|
51
|
+
```ruby
|
|
52
|
+
HTM.configure do |config|
|
|
53
|
+
config.job.backend = :inline # or :sidekiq, :active_job, :thread
|
|
54
|
+
config.chunking.size = 1024
|
|
55
|
+
config.chunking.overlap = 64
|
|
56
|
+
config.proposition.enabled = true
|
|
57
|
+
config.proposition.provider = :ollama
|
|
58
|
+
config.proposition.model = 'gemma3:latest'
|
|
59
|
+
end
|
|
60
|
+
```
|
|
50
61
|
**`@example`**
|
|
51
62
|
```ruby
|
|
52
63
|
HTM.configure do |config|
|
|
@@ -8,10 +8,9 @@ initialization
|
|
|
8
8
|
|
|
9
9
|
# Class Methods
|
|
10
10
|
## default_config() {: #method-c-default_config }
|
|
11
|
-
Get default database configuration (respects
|
|
11
|
+
Get default database configuration (respects HTM_ENV)
|
|
12
12
|
|
|
13
|
-
Uses
|
|
14
|
-
RAILS_ENV for environment-specific database selection.
|
|
13
|
+
Uses HTM::Config for database settings.
|
|
15
14
|
**`@return`** [Hash, nil] Connection configuration hash with PG-style keys
|
|
16
15
|
|
|
17
16
|
## drop(db_url nil) {: #method-c-drop }
|
|
@@ -37,7 +36,7 @@ comprehensive database documentation including:
|
|
|
37
36
|
* Table schemas with comments
|
|
38
37
|
* Index information
|
|
39
38
|
* Relationship diagrams
|
|
40
|
-
**`@param`** [String] Database connection URL (uses ENV['
|
|
39
|
+
**`@param`** [String] Database connection URL (uses ENV['HTM_DATABASE__URL'] if not provided)
|
|
41
40
|
|
|
42
41
|
**`@return`** [void]
|
|
43
42
|
|
|
@@ -57,13 +56,13 @@ Uses psql to load the schema file
|
|
|
57
56
|
|
|
58
57
|
## migrate(db_url nil) {: #method-c-migrate }
|
|
59
58
|
Run pending database migrations
|
|
60
|
-
**`@param`** [String] Database connection URL (uses ENV['
|
|
59
|
+
**`@param`** [String] Database connection URL (uses ENV['HTM_DATABASE__URL'] if not provided)
|
|
61
60
|
|
|
62
61
|
**`@return`** [void]
|
|
63
62
|
|
|
64
63
|
## migration_status(db_url nil) {: #method-c-migration_status }
|
|
65
64
|
Show migration status
|
|
66
|
-
**`@param`** [String] Database connection URL (uses ENV['
|
|
65
|
+
**`@param`** [String] Database connection URL (uses ENV['HTM_DATABASE__URL'] if not provided)
|
|
67
66
|
|
|
68
67
|
**`@return`** [void]
|
|
69
68
|
|
|
@@ -85,13 +84,13 @@ Seed database with sample data
|
|
|
85
84
|
Loads and executes db/seeds.rb file following Rails conventions. All seeding
|
|
86
85
|
logic is contained in db/seeds.rb and reads data from markdown files in
|
|
87
86
|
db/seed_data/ directory.
|
|
88
|
-
**`@param`** [String] Database connection URL (uses ENV['
|
|
87
|
+
**`@param`** [String] Database connection URL (uses ENV['HTM_DATABASE__URL'] if not provided)
|
|
89
88
|
|
|
90
89
|
**`@return`** [void]
|
|
91
90
|
|
|
92
91
|
## setup(db_url nil, run_migrations: true, dump_schema: false) {: #method-c-setup }
|
|
93
92
|
Set up the HTM database schema
|
|
94
|
-
**`@param`** [String] Database connection URL (uses ENV['
|
|
93
|
+
**`@param`** [String] Database connection URL (uses ENV['HTM_DATABASE__URL'] if not provided)
|
|
95
94
|
|
|
96
95
|
**`@param`** [Boolean] Whether to run migrations (default: true)
|
|
97
96
|
|
|
@@ -20,8 +20,8 @@ This railtie automatically configures HTM when Rails boots:
|
|
|
20
20
|
```ruby
|
|
21
21
|
# config/initializers/htm.rb
|
|
22
22
|
HTM.configure do |config|
|
|
23
|
-
config.
|
|
24
|
-
config.
|
|
23
|
+
config.embedding.model = 'custom-model'
|
|
24
|
+
config.tag.model = 'custom-tag-model'
|
|
25
25
|
end
|
|
26
26
|
```
|
|
27
27
|
|
|
@@ -145,7 +145,7 @@ CREATE INDEX nodes_type_idx ON nodes (type);
|
|
|
145
145
|
|
|
146
146
|
```ruby
|
|
147
147
|
# Via environment variable (preferred)
|
|
148
|
-
ENV['
|
|
148
|
+
ENV['HTM_DATABASE__URL'] = "postgresql://user:pass@host:port/dbname?sslmode=require"
|
|
149
149
|
|
|
150
150
|
# Parsed into connection hash
|
|
151
151
|
{
|
|
@@ -273,7 +273,7 @@ LIMIT $3;
|
|
|
273
273
|
ruby enable_extensions.rb
|
|
274
274
|
|
|
275
275
|
# 2. Run database schema with triggers
|
|
276
|
-
psql $
|
|
276
|
+
psql $HTM_DATABASE__URL < sql/schema.sql
|
|
277
277
|
|
|
278
278
|
# 3. Use HTM normally - embeddings automatic!
|
|
279
279
|
ruby -r ./lib/htm -e "HTM.new(robot_name: 'Bot').add_node('test', 'value')"
|
|
@@ -283,16 +283,16 @@ ruby -r ./lib/htm -e "HTM.new(robot_name: 'Bot').add_node('test', 'value')"
|
|
|
283
283
|
|
|
284
284
|
```bash
|
|
285
285
|
# 1. Backup database
|
|
286
|
-
pg_dump $
|
|
286
|
+
pg_dump $HTM_DATABASE__URL > htm_backup.sql
|
|
287
287
|
|
|
288
288
|
# 2. Enable pgai extension
|
|
289
289
|
ruby enable_extensions.rb
|
|
290
290
|
|
|
291
291
|
# 3. Apply new schema (adds triggers)
|
|
292
|
-
psql $
|
|
292
|
+
psql $HTM_DATABASE__URL < sql/schema.sql
|
|
293
293
|
|
|
294
294
|
# 4. (Optional) Regenerate embeddings with new model
|
|
295
|
-
psql $
|
|
295
|
+
psql $HTM_DATABASE__URL -c "UPDATE nodes SET value = value;"
|
|
296
296
|
# This triggers embedding regeneration for all nodes
|
|
297
297
|
```
|
|
298
298
|
|
data/docs/database_rake_tasks.md
CHANGED
|
@@ -143,7 +143,7 @@ Opens an interactive PostgreSQL console (psql).
|
|
|
143
143
|
|
|
144
144
|
**What it does:**
|
|
145
145
|
- Launches `psql` connected to your HTM database
|
|
146
|
-
- Uses connection parameters from `
|
|
146
|
+
- Uses connection parameters from `HTM_DATABASE__URL` or `.envrc`
|
|
147
147
|
- Allows you to run SQL queries directly
|
|
148
148
|
|
|
149
149
|
**Example:**
|
|
@@ -237,7 +237,7 @@ rake htm:db:info
|
|
|
237
237
|
|
|
238
238
|
### Method 2: Manual Export
|
|
239
239
|
```bash
|
|
240
|
-
export
|
|
240
|
+
export HTM_DATABASE__URL="postgresql://user:password@host:port/dbname?sslmode=require"
|
|
241
241
|
rake htm:db:info
|
|
242
242
|
```
|
|
243
243
|
|
|
@@ -293,12 +293,12 @@ rake htm:db:migrate # Run new migrations only
|
|
|
293
293
|
|
|
294
294
|
### "Database configuration not found"
|
|
295
295
|
- Run `direnv allow` in the project directory
|
|
296
|
-
- Or manually export `
|
|
297
|
-
- Verify: `echo $
|
|
296
|
+
- Or manually export `HTM_DATABASE__URL`
|
|
297
|
+
- Verify: `echo $HTM_DATABASE__URL`
|
|
298
298
|
|
|
299
299
|
### "Connection refused"
|
|
300
300
|
- Check database is running
|
|
301
|
-
- Verify host/port in `
|
|
301
|
+
- Verify host/port in `HTM_DATABASE__URL`
|
|
302
302
|
- Test: `rake htm:db:test`
|
|
303
303
|
|
|
304
304
|
### "Extension not found"
|
|
@@ -56,7 +56,7 @@ Running migrations...
|
|
|
56
56
|
|
|
57
57
|
**What it does:**
|
|
58
58
|
|
|
59
|
-
- Connects to PostgreSQL using `
|
|
59
|
+
- Connects to PostgreSQL using `HTM_DATABASE__URL`
|
|
60
60
|
- Verifies required extensions (pgvector, pg_trgm)
|
|
61
61
|
- Creates all HTM tables (robots, nodes, tags, file_sources, etc.)
|
|
62
62
|
- Runs all pending ActiveRecord migrations
|
|
@@ -906,7 +906,7 @@ Rebuilding tags for 1,542 nodes...
|
|
|
906
906
|
bundle install
|
|
907
907
|
|
|
908
908
|
# Set database URL
|
|
909
|
-
export
|
|
909
|
+
export HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development"
|
|
910
910
|
|
|
911
911
|
# Create and setup database
|
|
912
912
|
rake htm:db:create
|
|
@@ -1012,17 +1012,17 @@ All tasks require database configuration. Set one of these:
|
|
|
1012
1012
|
|
|
1013
1013
|
| Variable | Description |
|
|
1014
1014
|
|----------|-------------|
|
|
1015
|
-
| `
|
|
1016
|
-
| `
|
|
1017
|
-
| `
|
|
1018
|
-
| `
|
|
1019
|
-
| `
|
|
1020
|
-
| `
|
|
1015
|
+
| `HTM_DATABASE__URL` | Full PostgreSQL connection URL (preferred) |
|
|
1016
|
+
| `HTM_DATABASE__HOST` | Database host |
|
|
1017
|
+
| `HTM_DATABASE__PORT` | Database port |
|
|
1018
|
+
| `HTM_DATABASE__NAME` | Database name |
|
|
1019
|
+
| `HTM_DATABASE__USER` | Database username |
|
|
1020
|
+
| `HTM_DATABASE__PASSWORD` | Database password |
|
|
1021
1021
|
|
|
1022
1022
|
**Example:**
|
|
1023
1023
|
|
|
1024
1024
|
```bash
|
|
1025
|
-
export
|
|
1025
|
+
export HTM_DATABASE__URL="postgresql://user:password@localhost:5432/htm_development"
|
|
1026
1026
|
```
|
|
1027
1027
|
|
|
1028
1028
|
---
|
|
@@ -1031,10 +1031,10 @@ export HTM_DBURL="postgresql://user:password@localhost:5432/htm_development"
|
|
|
1031
1031
|
|
|
1032
1032
|
### "Database configuration not found"
|
|
1033
1033
|
|
|
1034
|
-
Set the `
|
|
1034
|
+
Set the `HTM_DATABASE__URL` environment variable:
|
|
1035
1035
|
|
|
1036
1036
|
```bash
|
|
1037
|
-
export
|
|
1037
|
+
export HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development"
|
|
1038
1038
|
```
|
|
1039
1039
|
|
|
1040
1040
|
### "Extension not found"
|