htm 0.0.17 → 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 -25
- data/.irbrc +7 -7
- data/.tbls.yml +2 -2
- data/CHANGELOG.md +71 -0
- data/README.md +1 -1
- data/Rakefile +8 -3
- data/SETUP.md +12 -12
- data/bin/htm_mcp +0 -4
- 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 +20 -20
- 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 +17 -17
- data/docs/guides/robot-groups.md +8 -8
- data/docs/index.md +4 -4
- data/docs/multi_framework_support.md +8 -8
- 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 +5 -5
- data/examples/rails_app/Gemfile.lock +48 -56
- data/examples/rails_app/README.md +1 -1
- 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 -25
- 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 +23 -27
- 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 +200 -58
- data/lib/htm/mcp/server.rb +3 -3
- data/lib/htm/proposition_service.rb +2 -12
- data/lib/htm/railtie.rb +3 -4
- data/lib/htm/tag_service.rb +1 -8
- data/lib/htm/version.rb +1 -1
- data/lib/htm.rb +124 -5
- metadata +24 -4
- data/config/database.yml +0 -77
- data/lib/htm/configuration.rb +0 -799
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7379c23800bf3f00cc328be9725b14bcea06a9d2158eaf3b3bca80b11a6efb74
|
|
4
|
+
data.tar.gz: ec96095a72ab89fed1dd7df0ceaeb3888938f5ddbdea6fd3f3c06aa15b80bf67
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 428b9c8f1db0f3a7a4be6e0b8bc4cc27f0bf058e7847c409cfca423c1bf9722a8efad92dbdd276d69844ab771670ea7cdc62e292018bec4705ed3f9f66255c16
|
|
7
|
+
data.tar.gz: af62a40339de40eac22f90b919a626b0f2d61a14440cdd5ca9e0aaf87ca088cc086cd35bc1eb4394d87a0646512c0a30d2fb47fdee7ec9ea2c4f11e469f2a44b
|
|
@@ -115,7 +115,7 @@ We will use **PostgreSQL with TimescaleDB** as the primary storage backend for H
|
|
|
115
115
|
### Connection Configuration
|
|
116
116
|
```ruby
|
|
117
117
|
# Via environment variable (preferred)
|
|
118
|
-
ENV['
|
|
118
|
+
ENV['HTM_DATABASE__URL'] = "postgresql://user:pass@host:port/dbname?sslmode=require"
|
|
119
119
|
|
|
120
120
|
# Parsed into connection hash
|
|
121
121
|
{
|
|
@@ -284,7 +284,7 @@ LIMIT $3;
|
|
|
284
284
|
ruby enable_extensions.rb
|
|
285
285
|
|
|
286
286
|
# 2. Run database schema with triggers
|
|
287
|
-
psql $
|
|
287
|
+
psql $HTM_DATABASE__URL < sql/schema.sql
|
|
288
288
|
|
|
289
289
|
# 3. Use HTM normally - embeddings automatic!
|
|
290
290
|
ruby -r ./lib/htm -e "HTM.new(robot_name: 'Bot').add_node('test', 'value')"
|
|
@@ -294,16 +294,16 @@ ruby -r ./lib/htm -e "HTM.new(robot_name: 'Bot').add_node('test', 'value')"
|
|
|
294
294
|
|
|
295
295
|
```bash
|
|
296
296
|
# 1. Backup database
|
|
297
|
-
pg_dump $
|
|
297
|
+
pg_dump $HTM_DATABASE__URL > htm_backup.sql
|
|
298
298
|
|
|
299
299
|
# 2. Enable pgai extension
|
|
300
300
|
ruby enable_extensions.rb
|
|
301
301
|
|
|
302
302
|
# 3. Apply new schema (adds triggers)
|
|
303
|
-
psql $
|
|
303
|
+
psql $HTM_DATABASE__URL < sql/schema.sql
|
|
304
304
|
|
|
305
305
|
# 4. (Optional) Regenerate embeddings with new model
|
|
306
|
-
psql $
|
|
306
|
+
psql $HTM_DATABASE__URL -c "UPDATE nodes SET value = value;"
|
|
307
307
|
# This triggers embedding regeneration for all nodes
|
|
308
308
|
```
|
|
309
309
|
|
|
@@ -333,7 +333,7 @@ htm.add_node('memory_001', 'PostgreSQL with TimescaleDB handles time-series data
|
|
|
333
333
|
HTM::Database.migrate
|
|
334
334
|
|
|
335
335
|
# 2. (Optional) Re-extract topics for existing nodes
|
|
336
|
-
psql $
|
|
336
|
+
psql $HTM_DATABASE__URL -c "UPDATE nodes SET value = value;"
|
|
337
337
|
# Triggers topic extraction for all existing nodes
|
|
338
338
|
```
|
|
339
339
|
|
data/.envrc
CHANGED
|
@@ -2,35 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
export RR=`pwd`
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export HTM_ENV=development
|
|
6
6
|
export HTM_EXTRACT_PROPOSITIONS=true
|
|
7
7
|
|
|
8
8
|
# Database connection - Localhost PostgreSQL
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
# export HTM_DBURL="postgresql://dewayne@localhost:5432/htm_development"
|
|
16
|
-
|
|
17
|
-
# Uncomment if using TimescaleDB Cloud instead:
|
|
18
|
-
# export HTM_SERVICE_NAME=$TIGER_SERVICE_NAME
|
|
19
|
-
# export HTM_DBURL=$TIGER_DBURL
|
|
20
|
-
# export HTM_DBNAME=$TIGER_DBNAME
|
|
21
|
-
# export HTM_DBUSER=$TIGER_DBUSER
|
|
22
|
-
# export HTM_DBPASS=$TIGER_DBPASS
|
|
23
|
-
# export HTM_DBHOST=$TIGER_DBHOST
|
|
24
|
-
# export HTM_DBPORT=$TIGER_DBPORT
|
|
9
|
+
export HTM_DATABASE__HOST=localhost
|
|
10
|
+
export HTM_DATABASE__PORT=5432
|
|
11
|
+
export HTM_DATABASE__NAME=htm_development
|
|
12
|
+
export HTM_DATABASE__USER=${USER}
|
|
13
|
+
export HTM_DATABASE__PASSWORD=
|
|
14
|
+
export HTM_DATABASE__URL="postgresql://${HTM_DATABASE__USER}@${HTM_DATABASE__HOST}:${HTM_DATABASE__PORT}/${HTM_DATABASE__NAME}?sslmode=disable"
|
|
25
15
|
|
|
26
16
|
# Client-side embedding generation
|
|
27
|
-
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export HTM_EMBEDDINGS_BASE_URL=http://localhost:11434
|
|
31
|
-
export HTM_EMBEDDINGS_DIMENSION=768
|
|
17
|
+
export HTM_EMBEDDING__PROVIDER=ollama
|
|
18
|
+
export HTM_EMBEDDING__MODEL=embeddinggemma
|
|
19
|
+
export HTM_EMBEDDING__DIMENSIONS=768
|
|
32
20
|
|
|
33
21
|
# Topic extraction (client-side)
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export HTM_TOPIC_BASE_URL=http://localhost:11434
|
|
22
|
+
export HTM_TAG__PROVIDER=ollama
|
|
23
|
+
export HTM_TAG__MODEL=phi4
|
data/.irbrc
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# HTM Interactive Development Console
|
|
4
|
-
# Usage:
|
|
4
|
+
# Usage: HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development" irb
|
|
5
5
|
|
|
6
6
|
require_relative 'lib/htm'
|
|
7
7
|
require 'debug_me'
|
|
@@ -21,12 +21,12 @@ end
|
|
|
21
21
|
|
|
22
22
|
# Configure HTM with sensible defaults for interactive use
|
|
23
23
|
HTM.configure do |config|
|
|
24
|
-
config.
|
|
25
|
-
config.
|
|
26
|
-
config.
|
|
27
|
-
config.
|
|
28
|
-
config.
|
|
29
|
-
config.
|
|
24
|
+
config.job.backend = :inline
|
|
25
|
+
config.embedding.provider = :ollama
|
|
26
|
+
config.embedding.model = 'nomic-embed-text:latest'
|
|
27
|
+
config.embedding.dimensions = 768
|
|
28
|
+
config.tag.provider = :ollama
|
|
29
|
+
config.tag.model = 'gemma3:latest'
|
|
30
30
|
config.reset_to_defaults
|
|
31
31
|
end
|
|
32
32
|
puts "✓ HTM configured (inline jobs, Ollama provider)"
|
data/.tbls.yml
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# tbls configuration for HTM database documentation
|
|
2
2
|
# https://github.com/k1LoW/tbls
|
|
3
3
|
|
|
4
|
-
# Database connection - uses
|
|
4
|
+
# Database connection - uses HTM_DATABASE__URL environment variable
|
|
5
5
|
# tbls expands environment variables with $VAR or ${VAR} syntax
|
|
6
|
-
dsn: $
|
|
6
|
+
dsn: $HTM_DATABASE__URL
|
|
7
7
|
|
|
8
8
|
# Output documentation to docs/database directory
|
|
9
9
|
docPath: docs/database
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,77 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
|
+
## [0.0.18] - 2025-12-20
|
|
10
|
+
### Added
|
|
11
|
+
- **Anyway::Config-based configuration system** - Replaced custom Configuration class with robust multi-source config management
|
|
12
|
+
- **Multi-layer configuration loading** with priority (lowest to highest):
|
|
13
|
+
1. Bundled defaults (`lib/htm/config/defaults.yml`)
|
|
14
|
+
2. XDG user config (`~/.config/htm/htm.yml`)
|
|
15
|
+
3. Project config (`./config/htm.yml`)
|
|
16
|
+
4. Local overrides (`./config/htm.local.yml`) - gitignored for secrets
|
|
17
|
+
5. Environment variables (`HTM_*`)
|
|
18
|
+
6. Programmatic (`HTM.configure` block)
|
|
19
|
+
- **Nested configuration access**: `HTM.config.database.host`, `HTM.config.embedding.model`, etc.
|
|
20
|
+
- **Environment-specific overrides**: Different defaults for development, test, and production environments
|
|
21
|
+
- **Configuration source tracing**: Debug where each configuration value originated
|
|
22
|
+
- **YAML-based prompt templates** - Tag and proposition extraction prompts now configurable via YAML
|
|
23
|
+
- Prompts use `%{placeholder}` syntax for runtime interpolation
|
|
24
|
+
- System and user prompts for tag extraction: `tag.system_prompt`, `tag.user_prompt_template`
|
|
25
|
+
- System and user prompts for proposition extraction: `proposition.system_prompt`, `proposition.user_prompt_template`
|
|
26
|
+
- Taxonomy context templates: `tag.taxonomy_context_existing`, `tag.taxonomy_context_empty`
|
|
27
|
+
- **New loaders for configuration sources**:
|
|
28
|
+
- `HTM::Loaders::DefaultsLoader` - Loads bundled gem defaults from YAML
|
|
29
|
+
- `HTM::Loaders::XDGConfigLoader` - Loads XDG-compliant user configuration
|
|
30
|
+
- **Configuration management example** - New `examples/config_file_example/` directory
|
|
31
|
+
- `show_config.rb` - Demonstrates configuration source tracing
|
|
32
|
+
- Sample configuration files showing override mechanisms
|
|
33
|
+
- Comprehensive README with configuration patterns
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- **BREAKING: Database environment variables renamed** - Migrate from `HTM_DBURL`/`HTM_DB*` to namespaced format
|
|
37
|
+
- `HTM_DBURL` → `HTM_DATABASE__URL`
|
|
38
|
+
- `HTM_DATABASE` → `HTM_DATABASE__NAME`
|
|
39
|
+
- `HTM_DB_USER` → `HTM_DATABASE__USER`
|
|
40
|
+
- `HTM_DB_PASSWORD` → `HTM_DATABASE__PASSWORD`
|
|
41
|
+
- `HTM_DB_HOST` → `HTM_DATABASE__HOST`
|
|
42
|
+
- `HTM_DB_PORT` → `HTM_DATABASE__PORT`
|
|
43
|
+
- Uses double underscore (`__`) for nested config (Anyway::Config convention)
|
|
44
|
+
- **Configuration access patterns updated** - Direct attributes → nested configuration
|
|
45
|
+
- `config.embedding_provider` → `config.embedding.provider`
|
|
46
|
+
- `config.embedding_model` → `config.embedding.model`
|
|
47
|
+
- `config.tag_provider` → `config.tag.provider`
|
|
48
|
+
- `config.tag_model` → `config.tag.model`
|
|
49
|
+
- `config.chunk_size` → `config.chunking.size`
|
|
50
|
+
- `config.chunk_overlap` → `config.chunking.overlap`
|
|
51
|
+
- **Removed `config/database.yml`** - Replaced by flexible YAML configuration files
|
|
52
|
+
- **Prompt generation refactored** - Hardcoded prompt strings moved to `defaults.yml` templates
|
|
53
|
+
- **MCP CLI enhanced** - Improved command handling and configuration output display
|
|
54
|
+
|
|
55
|
+
### Removed
|
|
56
|
+
- **`HTM::Configuration` class** - Replaced by `HTM::Config` using Anyway::Config
|
|
57
|
+
- **Legacy database environment variable support** - Must use new `HTM_DATABASE__*` format
|
|
58
|
+
|
|
59
|
+
### Dependencies
|
|
60
|
+
- Added `anyway_config` gem for configuration management
|
|
61
|
+
|
|
62
|
+
### Migration Guide
|
|
63
|
+
Update your environment variables:
|
|
64
|
+
```bash
|
|
65
|
+
# Old format
|
|
66
|
+
export HTM_DBURL="postgresql://user@localhost:5432/htm_development"
|
|
67
|
+
|
|
68
|
+
# New format
|
|
69
|
+
export HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Update configuration access:
|
|
73
|
+
```ruby
|
|
74
|
+
# Old pattern
|
|
75
|
+
HTM.configuration.embedding_model
|
|
76
|
+
|
|
77
|
+
# New pattern
|
|
78
|
+
HTM.config.embedding.model
|
|
79
|
+
```
|
|
9
80
|
|
|
10
81
|
## [0.0.17] - 2025-12-18
|
|
11
82
|
|
data/README.md
CHANGED
|
@@ -39,7 +39,7 @@ HTM includes a Model Context Protocol server with 23 tools for memory management
|
|
|
39
39
|
"mcpServers": {
|
|
40
40
|
"htm": {
|
|
41
41
|
"command": "htm_mcp",
|
|
42
|
-
"env": { "
|
|
42
|
+
"env": { "HTM_DATABASE__URL": "postgresql://localhost/htm" }
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
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
CHANGED
|
@@ -13,10 +13,6 @@
|
|
|
13
13
|
# htm_mcp version # Show HTM version
|
|
14
14
|
# htm_mcp help # Show help and environment variables
|
|
15
15
|
|
|
16
|
-
# Setup bundler to load gems from Gemfile
|
|
17
|
-
# This allows running the script directly without `bundle exec`
|
|
18
|
-
require 'bundler/setup'
|
|
19
|
-
|
|
20
16
|
require_relative '../lib/htm'
|
|
21
17
|
require_relative '../lib/htm/mcp/cli'
|
|
22
18
|
|
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|
|