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.
Files changed (135) 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 -24
  6. data/.irbrc +7 -7
  7. data/.tbls.yml +2 -2
  8. data/CHANGELOG.md +138 -0
  9. data/README.md +97 -1592
  10. data/Rakefile +8 -3
  11. data/SETUP.md +12 -12
  12. data/bin/htm_mcp +27 -0
  13. data/db/seed_data/README.md +2 -2
  14. data/db/seeds.rb +2 -2
  15. data/docs/api/database.md +37 -37
  16. data/docs/api/htm.md +1 -1
  17. data/docs/api/yard/HTM/ActiveRecordConfig.md +2 -2
  18. data/docs/api/yard/HTM/Configuration.md +26 -15
  19. data/docs/api/yard/HTM/Database.md +7 -8
  20. data/docs/api/yard/HTM/JobAdapter.md +1 -1
  21. data/docs/api/yard/HTM/Railtie.md +2 -2
  22. data/docs/architecture/adrs/001-postgresql-timescaledb.md +1 -1
  23. data/docs/architecture/adrs/011-pgai-integration.md +4 -4
  24. data/docs/database_rake_tasks.md +5 -5
  25. data/docs/development/rake-tasks.md +11 -11
  26. data/docs/development/setup.md +21 -21
  27. data/docs/development/testing.md +1 -1
  28. data/docs/getting-started/installation.md +51 -31
  29. data/docs/getting-started/quick-start.md +12 -12
  30. data/docs/guides/getting-started.md +2 -2
  31. data/docs/guides/long-term-memory.md +1 -1
  32. data/docs/guides/mcp-server.md +464 -29
  33. data/docs/guides/robot-groups.md +8 -8
  34. data/docs/index.md +4 -4
  35. data/docs/multi_framework_support.md +10 -10
  36. data/docs/setup_local_database.md +19 -19
  37. data/docs/using_rake_tasks_in_your_app.md +14 -14
  38. data/examples/README.md +50 -6
  39. data/examples/basic_usage.rb +31 -21
  40. data/examples/cli_app/README.md +8 -8
  41. data/examples/cli_app/htm_cli.rb +5 -5
  42. data/examples/config_file_example/README.md +256 -0
  43. data/examples/config_file_example/config/htm.local.yml +34 -0
  44. data/examples/config_file_example/custom_config.yml +22 -0
  45. data/examples/config_file_example/show_config.rb +125 -0
  46. data/examples/custom_llm_configuration.rb +7 -7
  47. data/examples/example_app/Rakefile +2 -2
  48. data/examples/example_app/app.rb +8 -8
  49. data/examples/file_loader_usage.rb +9 -9
  50. data/examples/mcp_client.rb +7 -7
  51. data/examples/rails_app/.gitignore +2 -0
  52. data/examples/rails_app/Gemfile +22 -0
  53. data/examples/rails_app/Gemfile.lock +430 -0
  54. data/examples/rails_app/Procfile.dev +1 -0
  55. data/examples/rails_app/README.md +98 -0
  56. data/examples/rails_app/Rakefile +5 -0
  57. data/examples/rails_app/app/assets/stylesheets/application.css +83 -0
  58. data/examples/rails_app/app/assets/stylesheets/inter-font.css +6 -0
  59. data/examples/rails_app/app/controllers/application_controller.rb +19 -0
  60. data/examples/rails_app/app/controllers/dashboard_controller.rb +27 -0
  61. data/examples/rails_app/app/controllers/files_controller.rb +205 -0
  62. data/examples/rails_app/app/controllers/memories_controller.rb +102 -0
  63. data/examples/rails_app/app/controllers/robots_controller.rb +44 -0
  64. data/examples/rails_app/app/controllers/search_controller.rb +46 -0
  65. data/examples/rails_app/app/controllers/tags_controller.rb +30 -0
  66. data/examples/rails_app/app/javascript/application.js +4 -0
  67. data/examples/rails_app/app/javascript/controllers/application.js +9 -0
  68. data/examples/rails_app/app/javascript/controllers/index.js +6 -0
  69. data/examples/rails_app/app/views/dashboard/index.html.erb +123 -0
  70. data/examples/rails_app/app/views/files/index.html.erb +108 -0
  71. data/examples/rails_app/app/views/files/new.html.erb +321 -0
  72. data/examples/rails_app/app/views/files/show.html.erb +130 -0
  73. data/examples/rails_app/app/views/layouts/application.html.erb +124 -0
  74. data/examples/rails_app/app/views/memories/_memory_card.html.erb +51 -0
  75. data/examples/rails_app/app/views/memories/deleted.html.erb +62 -0
  76. data/examples/rails_app/app/views/memories/edit.html.erb +35 -0
  77. data/examples/rails_app/app/views/memories/index.html.erb +81 -0
  78. data/examples/rails_app/app/views/memories/new.html.erb +71 -0
  79. data/examples/rails_app/app/views/memories/show.html.erb +126 -0
  80. data/examples/rails_app/app/views/robots/index.html.erb +106 -0
  81. data/examples/rails_app/app/views/robots/new.html.erb +36 -0
  82. data/examples/rails_app/app/views/robots/show.html.erb +79 -0
  83. data/examples/rails_app/app/views/search/index.html.erb +184 -0
  84. data/examples/rails_app/app/views/shared/_navbar.html.erb +52 -0
  85. data/examples/rails_app/app/views/shared/_stat_card.html.erb +52 -0
  86. data/examples/rails_app/app/views/tags/index.html.erb +131 -0
  87. data/examples/rails_app/app/views/tags/show.html.erb +67 -0
  88. data/examples/rails_app/bin/dev +8 -0
  89. data/examples/rails_app/bin/rails +4 -0
  90. data/examples/rails_app/bin/rake +4 -0
  91. data/examples/rails_app/config/application.rb +33 -0
  92. data/examples/rails_app/config/boot.rb +5 -0
  93. data/examples/rails_app/config/database.yml +15 -0
  94. data/examples/rails_app/config/environment.rb +5 -0
  95. data/examples/rails_app/config/importmap.rb +7 -0
  96. data/examples/rails_app/config/routes.rb +38 -0
  97. data/examples/rails_app/config/tailwind.config.js +35 -0
  98. data/examples/rails_app/config.ru +5 -0
  99. data/examples/rails_app/log/.keep +0 -0
  100. data/examples/rails_app/tmp/local_secret.txt +1 -0
  101. data/examples/robot_groups/multi_process.rb +5 -5
  102. data/examples/robot_groups/robot_worker.rb +5 -5
  103. data/examples/robot_groups/same_process.rb +9 -9
  104. data/examples/sinatra_app/app.rb +1 -1
  105. data/examples/timeframe_demo.rb +1 -1
  106. data/lib/htm/active_record_config.rb +12 -28
  107. data/lib/htm/circuit_breaker.rb +0 -2
  108. data/lib/htm/config/defaults.yml +246 -0
  109. data/lib/htm/config.rb +888 -0
  110. data/lib/htm/database.rb +26 -33
  111. data/lib/htm/embedding_service.rb +0 -4
  112. data/lib/htm/integrations/sinatra.rb +3 -7
  113. data/lib/htm/job_adapter.rb +1 -15
  114. data/lib/htm/jobs/generate_embedding_job.rb +1 -7
  115. data/lib/htm/jobs/generate_propositions_job.rb +2 -12
  116. data/lib/htm/jobs/generate_tags_job.rb +1 -8
  117. data/lib/htm/loaders/defaults_loader.rb +143 -0
  118. data/lib/htm/loaders/xdg_config_loader.rb +116 -0
  119. data/lib/htm/mcp/cli.rb +475 -0
  120. data/lib/htm/mcp/group_tools.rb +476 -0
  121. data/lib/htm/mcp/resources.rb +89 -0
  122. data/lib/htm/mcp/server.rb +98 -0
  123. data/lib/htm/mcp/tools.rb +488 -0
  124. data/lib/htm/models/file_source.rb +5 -3
  125. data/lib/htm/proposition_service.rb +2 -12
  126. data/lib/htm/railtie.rb +3 -8
  127. data/lib/htm/tag_service.rb +1 -8
  128. data/lib/htm/tasks.rb +7 -4
  129. data/lib/htm/version.rb +1 -1
  130. data/lib/htm.rb +124 -5
  131. data/lib/tasks/htm.rake +6 -9
  132. metadata +81 -6
  133. data/bin/htm_mcp.rb +0 -621
  134. data/config/database.yml +0 -74
  135. 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 RAILS_ENV=test
13
+ # Ensure test task runs with HTM_ENV=test (takes priority over RAILS_ENV/RACK_ENV)
14
14
  task :test do
15
- ENV['RAILS_ENV'] = 'test'
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['RAILS_ENV'] = 'test'
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 HTM_DBURL="postgresql://postgres@localhost:5432/htm_development"
63
+ export HTM_DATABASE__URL="postgresql://postgres@localhost:5432/htm_development"
64
64
 
65
65
  # Or for a specific user with password
66
- export HTM_DBURL="postgresql://username:password@localhost:5432/htm_development"
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
- | `HTM_DBURL` | Full PostgreSQL connection URL (preferred) | `postgresql://postgres@localhost:5432/htm_development` |
140
- | `HTM_DBNAME` | Database name (fallback) | `htm_development` |
141
- | `HTM_DBUSER` | Database user (fallback) | `postgres` |
142
- | `HTM_DBPASS` | Database password (fallback) | `` |
143
- | `HTM_DBHOST` | Database host (fallback) | `localhost` |
144
- | `HTM_DBPORT` | Database port (fallback) | `5432` |
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 HTM_DBURL="postgresql://postgres@localhost:5432/htm_development"
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
- │ └── database.yml # Database configuration
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 $HTM_DBURL
251
+ echo $HTM_DATABASE__URL
252
252
 
253
253
  # Test connection manually
254
- psql $HTM_DBURL -c "SELECT 1"
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
@@ -23,8 +23,8 @@ The seeding process uses environment variables for configuration. All settings h
23
23
 
24
24
  ### Database Settings
25
25
 
26
- - `HTM_DBURL` - Full PostgreSQL connection URL (required)
27
- - Or individual settings: `HTM_DBHOST`, `HTM_DBPORT`, `HTM_DBNAME`, `HTM_DBUSER`, `HTM_DBPASS`
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
- # HTM_DBURL - Database connection URL
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['HTM_DBURL'])
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['HTM_DBURL']` | Database connection URL |
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['HTM_DBNAME']` not set
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
- | `HTM_DBHOST` | Database hostname | `'cw7rxj91bm.srbbwwxn56.tsdb.cloud.timescale.com'` |
180
- | `HTM_DBPORT` | Database port | `37807` |
181
- | `HTM_DBNAME` | Database name | *required* |
182
- | `HTM_DBUSER` | Database user | *required* |
183
- | `HTM_DBPASS` | Database password | *required* |
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['HTM_DBNAME'] = 'tsdb'
190
- ENV['HTM_DBUSER'] = 'tsdbadmin'
191
- ENV['HTM_DBPASS'] = 'secret'
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['HTM_DBHOST'] = 'localhost'
205
- ENV['HTM_DBPORT'] = '5432'
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 HTM_DBNAME
211
- ENV.delete('HTM_DBNAME')
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['HTM_DBURL']` - Parse connection URL
234
- 2. `ENV['HTM_DBNAME']` - Parse individual params
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 HTM_DBURL
241
- ENV['HTM_DBURL'] = 'postgresql://user:pass@host/db'
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 HTM_DBNAME
246
- ENV.delete('HTM_DBURL')
247
- ENV['HTM_DBNAME'] = 'mydb'
248
- ENV['HTM_DBUSER'] = 'user'
249
- ENV['HTM_DBPASS'] = 'pass'
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('HTM_DBURL')
255
- ENV.delete('HTM_DBNAME')
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 HTM_DBURL='postgresql://tsdbadmin:PASSWORD@SERVICE.tsdb.cloud.timescale.com:37807/tsdb?sslmode=require'
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 HTM_DBHOST='xxx.tsdb.cloud.timescale.com'
352
- export HTM_DBPORT=37807
353
- export HTM_DBNAME='tsdb'
354
- export HTM_DBUSER='tsdbadmin'
355
- export HTM_DBPASS='your_password'
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 HTM_DBURL='postgresql://localhost/htm_dev'
361
+ export HTM_DATABASE__URL='postgresql://localhost/htm_dev'
362
362
 
363
363
  # Or with auth
364
- export HTM_DBURL='postgresql://user:pass@localhost:5432/htm_dev'
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 HTM_DBURL='postgresql://postgres:postgres@localhost:5432/htm'
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 HTM_DBURL or HTM_DBNAME environment variables"
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 $HTM_DBURL
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 HTM_DBURL environment variable. " \
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['HTM_DBURL']` | Database configuration |
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 config/database.yml
18
+ Establish database connection from HTM::Config
19
19
  ## load_database_config() {: #method-c-load_database_config }
20
- Load and parse database configuration from YAML with ERB
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.embedding_provider = :openai
23
- config.embedding_model = 'text-embedding-3-small'
24
- config.tag_provider = :openai
25
- config.tag_model = 'gpt-4o-mini'
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.embedding_provider = :ollama
33
- config.embedding_model = 'nomic-embed-text'
34
- config.tag_provider = :ollama
35
- config.tag_model = 'llama3'
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.embedding_provider = :openai
43
- config.embedding_model = 'text-embedding-3-small'
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.tag_provider = :anthropic
46
- config.tag_model = 'claude-3-haiku-20240307'
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 RAILS_ENV)
11
+ Get default database configuration (respects HTM_ENV)
12
12
 
13
- Uses ActiveRecordConfig which reads from config/database.yml and respects
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['HTM_DBURL'] if not provided)
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['HTM_DBURL'] if not provided)
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['HTM_DBURL'] if not provided)
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['HTM_DBURL'] if not provided)
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['HTM_DBURL'] if not provided)
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
 
@@ -18,7 +18,7 @@ Supported backends:
18
18
  **`@example`**
19
19
  ```ruby
20
20
  HTM.configure do |config|
21
- config.job_backend = :active_job
21
+ config.job.backend = :active_job
22
22
  end
23
23
  ```
24
24
  **`@example`**
@@ -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.embedding_model = 'custom-model'
24
- config.tag_model = 'custom-tag-model'
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['HTM_DBURL'] = "postgresql://user:pass@host:port/dbname?sslmode=require"
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 $HTM_DBURL < sql/schema.sql
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 $HTM_DBURL > htm_backup.sql
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 $HTM_DBURL < sql/schema.sql
292
+ psql $HTM_DATABASE__URL < sql/schema.sql
293
293
 
294
294
  # 4. (Optional) Regenerate embeddings with new model
295
- psql $HTM_DBURL -c "UPDATE nodes SET value = value;"
295
+ psql $HTM_DATABASE__URL -c "UPDATE nodes SET value = value;"
296
296
  # This triggers embedding regeneration for all nodes
297
297
  ```
298
298
 
@@ -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 `HTM_DBURL` or `.envrc`
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 HTM_DBURL="postgresql://user:password@host:port/dbname?sslmode=require"
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 `HTM_DBURL`
297
- - Verify: `echo $HTM_DBURL`
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 `HTM_DBURL`
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 `HTM_DBURL`
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 HTM_DBURL="postgresql://user@localhost:5432/htm_development"
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
- | `HTM_DBURL` | Full PostgreSQL connection URL (preferred) |
1016
- | `HTM_DBHOST` | Database host |
1017
- | `HTM_DBPORT` | Database port |
1018
- | `HTM_DBNAME` | Database name |
1019
- | `HTM_DBUSER` | Database username |
1020
- | `HTM_DBPASS` | Database password |
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 HTM_DBURL="postgresql://user:password@localhost:5432/htm_development"
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 `HTM_DBURL` environment variable:
1034
+ Set the `HTM_DATABASE__URL` environment variable:
1035
1035
 
1036
1036
  ```bash
1037
- export HTM_DBURL="postgresql://user@localhost:5432/htm_development"
1037
+ export HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development"
1038
1038
  ```
1039
1039
 
1040
1040
  ### "Extension not found"