htm 0.0.1
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 +7 -0
- data/.architecture/decisions/adrs/001-use-postgresql-timescaledb-storage.md +227 -0
- data/.architecture/decisions/adrs/002-two-tier-memory-architecture.md +322 -0
- data/.architecture/decisions/adrs/003-ollama-default-embedding-provider.md +339 -0
- data/.architecture/decisions/adrs/004-multi-robot-shared-memory-hive-mind.md +374 -0
- data/.architecture/decisions/adrs/005-rag-based-retrieval-with-hybrid-search.md +443 -0
- data/.architecture/decisions/adrs/006-context-assembly-strategies.md +444 -0
- data/.architecture/decisions/adrs/007-working-memory-eviction-strategy.md +461 -0
- data/.architecture/decisions/adrs/008-robot-identification-system.md +550 -0
- data/.architecture/decisions/adrs/009-never-forget-explicit-deletion-only.md +570 -0
- data/.architecture/decisions/adrs/010-redis-working-memory-rejected.md +323 -0
- data/.architecture/decisions/adrs/011-database-side-embedding-generation-with-pgai.md +585 -0
- data/.architecture/decisions/adrs/012-llm-driven-ontology-topic-extraction.md +583 -0
- data/.architecture/decisions/adrs/013-activerecord-orm-and-many-to-many-tagging.md +299 -0
- data/.architecture/decisions/adrs/014-client-side-embedding-generation-workflow.md +569 -0
- data/.architecture/decisions/adrs/015-hierarchical-tag-ontology-and-llm-extraction.md +701 -0
- data/.architecture/decisions/adrs/016-async-embedding-and-tag-generation.md +694 -0
- data/.architecture/members.yml +144 -0
- data/.architecture/reviews/2025-10-29-llm-configuration-and-async-processing-review.md +1137 -0
- data/.architecture/reviews/initial-system-analysis.md +330 -0
- data/.envrc +32 -0
- data/.irbrc +145 -0
- data/CHANGELOG.md +150 -0
- data/COMMITS.md +196 -0
- data/LICENSE +21 -0
- data/README.md +1347 -0
- data/Rakefile +51 -0
- data/SETUP.md +268 -0
- data/config/database.yml +67 -0
- data/db/migrate/20250101000001_enable_extensions.rb +14 -0
- data/db/migrate/20250101000002_create_robots.rb +14 -0
- data/db/migrate/20250101000003_create_nodes.rb +42 -0
- data/db/migrate/20250101000005_create_tags.rb +38 -0
- data/db/migrate/20250101000007_add_node_vector_indexes.rb +30 -0
- data/db/schema.sql +473 -0
- data/db/seed_data/README.md +100 -0
- data/db/seed_data/presidents.md +136 -0
- data/db/seed_data/states.md +151 -0
- data/db/seeds.rb +208 -0
- data/dbdoc/README.md +173 -0
- data/dbdoc/public.node_stats.md +48 -0
- data/dbdoc/public.node_stats.svg +41 -0
- data/dbdoc/public.node_tags.md +40 -0
- data/dbdoc/public.node_tags.svg +112 -0
- data/dbdoc/public.nodes.md +54 -0
- data/dbdoc/public.nodes.svg +118 -0
- data/dbdoc/public.nodes_tags.md +39 -0
- data/dbdoc/public.nodes_tags.svg +112 -0
- data/dbdoc/public.ontology_structure.md +48 -0
- data/dbdoc/public.ontology_structure.svg +38 -0
- data/dbdoc/public.operations_log.md +42 -0
- data/dbdoc/public.operations_log.svg +130 -0
- data/dbdoc/public.relationships.md +39 -0
- data/dbdoc/public.relationships.svg +41 -0
- data/dbdoc/public.robot_activity.md +46 -0
- data/dbdoc/public.robot_activity.svg +35 -0
- data/dbdoc/public.robots.md +35 -0
- data/dbdoc/public.robots.svg +90 -0
- data/dbdoc/public.schema_migrations.md +29 -0
- data/dbdoc/public.schema_migrations.svg +26 -0
- data/dbdoc/public.tags.md +35 -0
- data/dbdoc/public.tags.svg +60 -0
- data/dbdoc/public.topic_relationships.md +45 -0
- data/dbdoc/public.topic_relationships.svg +32 -0
- data/dbdoc/schema.json +1437 -0
- data/dbdoc/schema.svg +154 -0
- data/docs/api/database.md +806 -0
- data/docs/api/embedding-service.md +532 -0
- data/docs/api/htm.md +797 -0
- data/docs/api/index.md +259 -0
- data/docs/api/long-term-memory.md +1096 -0
- data/docs/api/working-memory.md +665 -0
- data/docs/architecture/adrs/001-postgresql-timescaledb.md +314 -0
- data/docs/architecture/adrs/002-two-tier-memory.md +411 -0
- data/docs/architecture/adrs/003-ollama-embeddings.md +421 -0
- data/docs/architecture/adrs/004-hive-mind.md +437 -0
- data/docs/architecture/adrs/005-rag-retrieval.md +531 -0
- data/docs/architecture/adrs/006-context-assembly.md +496 -0
- data/docs/architecture/adrs/007-eviction-strategy.md +645 -0
- data/docs/architecture/adrs/008-robot-identification.md +625 -0
- data/docs/architecture/adrs/009-never-forget.md +648 -0
- data/docs/architecture/adrs/010-redis-working-memory-rejected.md +323 -0
- data/docs/architecture/adrs/011-pgai-integration.md +494 -0
- data/docs/architecture/adrs/index.md +215 -0
- data/docs/architecture/hive-mind.md +736 -0
- data/docs/architecture/index.md +351 -0
- data/docs/architecture/overview.md +538 -0
- data/docs/architecture/two-tier-memory.md +873 -0
- data/docs/assets/css/custom.css +83 -0
- data/docs/assets/images/htm-core-components.svg +63 -0
- data/docs/assets/images/htm-database-schema.svg +93 -0
- data/docs/assets/images/htm-hive-mind-architecture.svg +125 -0
- data/docs/assets/images/htm-importance-scoring-framework.svg +83 -0
- data/docs/assets/images/htm-layered-architecture.svg +71 -0
- data/docs/assets/images/htm-long-term-memory-architecture.svg +115 -0
- data/docs/assets/images/htm-working-memory-architecture.svg +120 -0
- data/docs/assets/images/htm.jpg +0 -0
- data/docs/assets/images/htm_demo.gif +0 -0
- data/docs/assets/js/mathjax.js +18 -0
- data/docs/assets/videos/htm_video.mp4 +0 -0
- data/docs/database_rake_tasks.md +322 -0
- data/docs/development/contributing.md +787 -0
- data/docs/development/index.md +336 -0
- data/docs/development/schema.md +596 -0
- data/docs/development/setup.md +719 -0
- data/docs/development/testing.md +819 -0
- data/docs/guides/adding-memories.md +824 -0
- data/docs/guides/context-assembly.md +1009 -0
- data/docs/guides/getting-started.md +577 -0
- data/docs/guides/index.md +118 -0
- data/docs/guides/long-term-memory.md +941 -0
- data/docs/guides/multi-robot.md +866 -0
- data/docs/guides/recalling-memories.md +927 -0
- data/docs/guides/search-strategies.md +953 -0
- data/docs/guides/working-memory.md +717 -0
- data/docs/index.md +214 -0
- data/docs/installation.md +477 -0
- data/docs/multi_framework_support.md +519 -0
- data/docs/quick-start.md +655 -0
- data/docs/setup_local_database.md +302 -0
- data/docs/using_rake_tasks_in_your_app.md +383 -0
- data/examples/basic_usage.rb +93 -0
- data/examples/cli_app/README.md +317 -0
- data/examples/cli_app/htm_cli.rb +270 -0
- data/examples/custom_llm_configuration.rb +183 -0
- data/examples/example_app/Rakefile +71 -0
- data/examples/example_app/app.rb +206 -0
- data/examples/sinatra_app/Gemfile +21 -0
- data/examples/sinatra_app/app.rb +335 -0
- data/lib/htm/active_record_config.rb +113 -0
- data/lib/htm/configuration.rb +342 -0
- data/lib/htm/database.rb +594 -0
- data/lib/htm/embedding_service.rb +115 -0
- data/lib/htm/errors.rb +34 -0
- data/lib/htm/job_adapter.rb +154 -0
- data/lib/htm/jobs/generate_embedding_job.rb +65 -0
- data/lib/htm/jobs/generate_tags_job.rb +82 -0
- data/lib/htm/long_term_memory.rb +965 -0
- data/lib/htm/models/node.rb +109 -0
- data/lib/htm/models/node_tag.rb +33 -0
- data/lib/htm/models/robot.rb +52 -0
- data/lib/htm/models/tag.rb +76 -0
- data/lib/htm/railtie.rb +76 -0
- data/lib/htm/sinatra.rb +157 -0
- data/lib/htm/tag_service.rb +135 -0
- data/lib/htm/tasks.rb +38 -0
- data/lib/htm/version.rb +5 -0
- data/lib/htm/working_memory.rb +182 -0
- data/lib/htm.rb +400 -0
- data/lib/tasks/db.rake +19 -0
- data/lib/tasks/htm.rake +147 -0
- data/lib/tasks/jobs.rake +312 -0
- data/mkdocs.yml +190 -0
- data/scripts/install_local_database.sh +309 -0
- metadata +341 -0
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
# Development Setup Guide
|
|
2
|
+
|
|
3
|
+
This guide will walk you through setting up a complete HTM development environment from scratch.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Setting up HTM for development involves:
|
|
8
|
+
|
|
9
|
+
1. Cloning the repository
|
|
10
|
+
2. Installing Ruby and system dependencies
|
|
11
|
+
3. Installing Ruby gem dependencies
|
|
12
|
+
4. Setting up TimescaleDB database
|
|
13
|
+
5. Configuring Ollama for embeddings
|
|
14
|
+
6. Verifying your setup
|
|
15
|
+
7. Running tests and examples
|
|
16
|
+
|
|
17
|
+
Let's get started!
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
Before you begin, ensure you have:
|
|
22
|
+
|
|
23
|
+
- **macOS, Linux, or WSL2** (Windows Subsystem for Linux)
|
|
24
|
+
- **Git** installed (`git --version`)
|
|
25
|
+
- **Ruby 3.0 or higher** (we'll install this)
|
|
26
|
+
- **Internet connection** (for downloading dependencies)
|
|
27
|
+
|
|
28
|
+
## Step 1: Clone the Repository
|
|
29
|
+
|
|
30
|
+
### Fork the Repository (Recommended for Contributors)
|
|
31
|
+
|
|
32
|
+
If you plan to submit pull requests, fork the repository first:
|
|
33
|
+
|
|
34
|
+
1. Visit [https://github.com/madbomber/htm](https://github.com/madbomber/htm)
|
|
35
|
+
2. Click the "Fork" button in the upper right
|
|
36
|
+
3. Clone your fork:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
git clone https://github.com/YOUR_USERNAME/htm.git
|
|
40
|
+
cd htm
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Or Clone Directly (For Read-Only Access)
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
git clone https://github.com/madbomber/htm.git
|
|
47
|
+
cd htm
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Add Upstream Remote (For Forked Repos)
|
|
51
|
+
|
|
52
|
+
If you forked, add the original repository as upstream:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
git remote add upstream https://github.com/madbomber/htm.git
|
|
56
|
+
git fetch upstream
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Step 2: Install Ruby
|
|
60
|
+
|
|
61
|
+
HTM requires Ruby 3.0 or higher. We recommend using **rbenv** for managing Ruby versions.
|
|
62
|
+
|
|
63
|
+
### Check Current Ruby Version
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
ruby --version
|
|
67
|
+
# Example output: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
If you already have Ruby 3.0+, you can skip to Step 3.
|
|
71
|
+
|
|
72
|
+
### Install rbenv (macOS)
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Install rbenv and ruby-build
|
|
76
|
+
brew install rbenv ruby-build
|
|
77
|
+
|
|
78
|
+
# Initialize rbenv in your shell
|
|
79
|
+
echo 'eval "$(rbenv init - bash)"' >> ~/.bashrc
|
|
80
|
+
source ~/.bashrc
|
|
81
|
+
|
|
82
|
+
# Verify installation
|
|
83
|
+
rbenv --version
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Install rbenv (Linux)
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Clone rbenv
|
|
90
|
+
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
|
|
91
|
+
|
|
92
|
+
# Add to PATH
|
|
93
|
+
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
|
|
94
|
+
echo 'eval "$(rbenv init - bash)"' >> ~/.bashrc
|
|
95
|
+
source ~/.bashrc
|
|
96
|
+
|
|
97
|
+
# Install ruby-build
|
|
98
|
+
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Install Ruby 3.3 (Latest Stable)
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# List available Ruby versions
|
|
105
|
+
rbenv install --list
|
|
106
|
+
|
|
107
|
+
# Install Ruby 3.3.0 (or latest 3.x version)
|
|
108
|
+
rbenv install 3.3.0
|
|
109
|
+
|
|
110
|
+
# Set as global default
|
|
111
|
+
rbenv global 3.3.0
|
|
112
|
+
|
|
113
|
+
# Verify installation
|
|
114
|
+
ruby --version
|
|
115
|
+
# Should show: ruby 3.3.0
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Step 3: Install Ruby Dependencies
|
|
119
|
+
|
|
120
|
+
HTM uses Bundler to manage Ruby gem dependencies.
|
|
121
|
+
|
|
122
|
+
### Install Bundler
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
gem install bundler
|
|
126
|
+
|
|
127
|
+
# Verify installation
|
|
128
|
+
bundle --version
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Install Project Dependencies
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# From the htm directory
|
|
135
|
+
bundle install
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
This will install:
|
|
139
|
+
|
|
140
|
+
- **pg**: PostgreSQL adapter
|
|
141
|
+
- **pgvector**: Vector similarity search support
|
|
142
|
+
- **connection_pool**: Database connection pooling
|
|
143
|
+
- **tiktoken_ruby**: Token counting for working memory
|
|
144
|
+
- **ruby_llm**: LLM client for embeddings
|
|
145
|
+
- **rake**: Task automation
|
|
146
|
+
- **minitest**: Testing framework
|
|
147
|
+
- **minitest-reporters**: Test output formatting
|
|
148
|
+
- **debug_me**: Debugging utility
|
|
149
|
+
|
|
150
|
+
### Verify Installation
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
bundle exec ruby -e "require 'htm'; puts HTM::VERSION"
|
|
154
|
+
# Should output: 0.1.0 (or current version)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Step 4: Set Up TimescaleDB Database
|
|
158
|
+
|
|
159
|
+
HTM requires PostgreSQL with TimescaleDB and pgvector extensions. You have two options:
|
|
160
|
+
|
|
161
|
+
### Option A: TimescaleDB Cloud (Recommended for Quick Start)
|
|
162
|
+
|
|
163
|
+
This is the fastest way to get a working database:
|
|
164
|
+
|
|
165
|
+
#### 1. Create Account
|
|
166
|
+
|
|
167
|
+
Visit [https://www.timescale.com/](https://www.timescale.com/) and sign up for a free account.
|
|
168
|
+
|
|
169
|
+
#### 2. Create Service
|
|
170
|
+
|
|
171
|
+
- Click "Create Service"
|
|
172
|
+
- Select your region (choose closest to you)
|
|
173
|
+
- Choose the **Free Tier** (or your preferred plan)
|
|
174
|
+
- Click "Create Service"
|
|
175
|
+
- Wait 2-3 minutes for provisioning
|
|
176
|
+
|
|
177
|
+
#### 3. Get Connection Details
|
|
178
|
+
|
|
179
|
+
- Click on your new service
|
|
180
|
+
- Click "Connection Info"
|
|
181
|
+
- Copy the full connection string (looks like `postgres://username:password@host:port/database?sslmode=require`)
|
|
182
|
+
|
|
183
|
+
#### 4. Configure Environment Variables
|
|
184
|
+
|
|
185
|
+
Create or edit `~/.bashrc__tiger`:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# TimescaleDB Connection Configuration
|
|
189
|
+
export HTM_SERVICE_NAME="db-67977" # Your service name
|
|
190
|
+
export HTM_DBNAME="tsdb"
|
|
191
|
+
export HTM_DBUSER="tsdbadmin"
|
|
192
|
+
export HTM_DBPASS="your_password_here"
|
|
193
|
+
export HTM_DBPORT="37807" # Your port number
|
|
194
|
+
export HTM_DBURL="postgres://tsdbadmin:your_password@host:port/tsdb?sslmode=require"
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Replace the placeholders with your actual connection details.
|
|
198
|
+
|
|
199
|
+
#### 5. Load Environment Variables
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Load configuration
|
|
203
|
+
source ~/.bashrc__tiger
|
|
204
|
+
|
|
205
|
+
# Optionally, add to your ~/.bashrc for automatic loading
|
|
206
|
+
echo 'source ~/.bashrc__tiger' >> ~/.bashrc
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Option B: Local PostgreSQL with Docker (Advanced)
|
|
210
|
+
|
|
211
|
+
For local development with Docker:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
# Create docker-compose.yml
|
|
215
|
+
cat > docker-compose.yml <<'EOF'
|
|
216
|
+
version: '3.8'
|
|
217
|
+
services:
|
|
218
|
+
timescaledb:
|
|
219
|
+
image: timescale/timescaledb-ha:pg17
|
|
220
|
+
environment:
|
|
221
|
+
POSTGRES_USER: tsdbadmin
|
|
222
|
+
POSTGRES_PASSWORD: devpassword
|
|
223
|
+
POSTGRES_DB: tsdb
|
|
224
|
+
ports:
|
|
225
|
+
- "5432:5432"
|
|
226
|
+
volumes:
|
|
227
|
+
- timescale_data:/var/lib/postgresql/data
|
|
228
|
+
|
|
229
|
+
volumes:
|
|
230
|
+
timescale_data:
|
|
231
|
+
EOF
|
|
232
|
+
|
|
233
|
+
# Start TimescaleDB
|
|
234
|
+
docker-compose up -d
|
|
235
|
+
|
|
236
|
+
# Configure environment variables
|
|
237
|
+
cat > ~/.bashrc__tiger <<'EOF'
|
|
238
|
+
export HTM_SERVICE_NAME="local-dev"
|
|
239
|
+
export HTM_DBNAME="tsdb"
|
|
240
|
+
export HTM_DBUSER="tsdbadmin"
|
|
241
|
+
export HTM_DBPASS="devpassword"
|
|
242
|
+
export HTM_DBPORT="5432"
|
|
243
|
+
export HTM_DBURL="postgres://tsdbadmin:devpassword@localhost:5432/tsdb?sslmode=disable"
|
|
244
|
+
EOF
|
|
245
|
+
|
|
246
|
+
source ~/.bashrc__tiger
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Verify Database Connection
|
|
250
|
+
|
|
251
|
+
Test your database connection:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# From the htm directory
|
|
255
|
+
ruby test_connection.rb
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Expected output:
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
Connected successfully!
|
|
262
|
+
TimescaleDB Extension: Version 2.22.1
|
|
263
|
+
pgvector Extension: Version 0.8.1
|
|
264
|
+
pg_trgm Extension: Version 1.6
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Enable Required Extensions
|
|
268
|
+
|
|
269
|
+
Run the extension setup script:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
ruby enable_extensions.rb
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
This ensures that TimescaleDB, pgvector, and pg_trgm extensions are enabled.
|
|
276
|
+
|
|
277
|
+
## Step 5: Set Up Ollama for Embeddings
|
|
278
|
+
|
|
279
|
+
HTM uses Ollama (via RubyLLM) to generate vector embeddings for semantic search.
|
|
280
|
+
|
|
281
|
+
### Install Ollama
|
|
282
|
+
|
|
283
|
+
#### macOS
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
# Download and install from official site
|
|
287
|
+
curl https://ollama.ai/install.sh | sh
|
|
288
|
+
|
|
289
|
+
# Or using Homebrew
|
|
290
|
+
brew install ollama
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
#### Linux
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
curl https://ollama.ai/install.sh | sh
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Start Ollama Service
|
|
300
|
+
|
|
301
|
+
Ollama typically starts automatically after installation. Verify it's running:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
# Check if Ollama is running
|
|
305
|
+
curl http://localhost:11434/api/version
|
|
306
|
+
|
|
307
|
+
# Expected output:
|
|
308
|
+
# {"version":"0.1.x"}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
If not running, start it manually:
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
# macOS - Ollama runs as a background service
|
|
315
|
+
# Check Activity Monitor or start from Applications
|
|
316
|
+
|
|
317
|
+
# Linux
|
|
318
|
+
ollama serve &
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Pull the gpt-oss Model
|
|
322
|
+
|
|
323
|
+
HTM uses the `gpt-oss` model by default:
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
# Pull the model (downloads ~4GB)
|
|
327
|
+
ollama pull gpt-oss
|
|
328
|
+
|
|
329
|
+
# Verify the model is available
|
|
330
|
+
ollama list
|
|
331
|
+
# Should show gpt-oss in the list
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Test Embedding Generation
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
# Test that embeddings work
|
|
338
|
+
ollama run gpt-oss "Hello, HTM!"
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### Optional: Configure Custom Ollama URL
|
|
342
|
+
|
|
343
|
+
If Ollama is running on a different host or port:
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
# Add to ~/.bashrc__tiger
|
|
347
|
+
export OLLAMA_URL="http://custom-host:11434"
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Step 6: Initialize Database Schema
|
|
351
|
+
|
|
352
|
+
Now that everything is set up, initialize the HTM database schema:
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
# Run database setup
|
|
356
|
+
rake db_setup
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
This creates all required tables, indexes, views, and triggers. See the [Schema Documentation](schema.md) for details.
|
|
360
|
+
|
|
361
|
+
### Alternative: Manual Setup
|
|
362
|
+
|
|
363
|
+
You can also run the schema SQL directly:
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
# Using psql
|
|
367
|
+
psql $HTM_DBURL -f sql/schema.sql
|
|
368
|
+
|
|
369
|
+
# Or using Ruby
|
|
370
|
+
ruby -r ./lib/htm -e "HTM::Database.setup"
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
## Step 7: Verify Your Setup
|
|
374
|
+
|
|
375
|
+
Let's make sure everything is working correctly.
|
|
376
|
+
|
|
377
|
+
### Run the Test Suite
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
# Run all tests
|
|
381
|
+
rake test
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
Expected output:
|
|
385
|
+
|
|
386
|
+
```
|
|
387
|
+
HTMTest
|
|
388
|
+
test_version_exists PASS (0.00s)
|
|
389
|
+
test_version_format PASS (0.00s)
|
|
390
|
+
test_htm_class_exists PASS (0.00s)
|
|
391
|
+
...
|
|
392
|
+
|
|
393
|
+
Finished in 0.05s
|
|
394
|
+
12 tests, 0 failures, 0 errors, 0 skips
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### Run Integration Tests
|
|
398
|
+
|
|
399
|
+
Integration tests require a working database:
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
ruby test/integration_test.rb
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Run the Example
|
|
406
|
+
|
|
407
|
+
Test the full workflow with a real example:
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
rake example
|
|
411
|
+
|
|
412
|
+
# Or directly
|
|
413
|
+
ruby examples/basic_usage.rb
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
Expected output:
|
|
417
|
+
|
|
418
|
+
```
|
|
419
|
+
HTM Basic Usage Example
|
|
420
|
+
============================================================
|
|
421
|
+
|
|
422
|
+
1. Initializing HTM for 'Code Helper' robot...
|
|
423
|
+
Using RubyLLM with Ollama provider and gpt-oss model for embeddings
|
|
424
|
+
✓ HTM initialized
|
|
425
|
+
Robot ID: robot-abc123
|
|
426
|
+
Robot Name: Code Helper
|
|
427
|
+
Embedding Service: Ollama (gpt-oss via RubyLLM)
|
|
428
|
+
|
|
429
|
+
2. Adding memory nodes...
|
|
430
|
+
✓ Added decision about database choice
|
|
431
|
+
✓ Added decision about RAG approach
|
|
432
|
+
✓ Added fact about user preferences
|
|
433
|
+
...
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
## Development Tools
|
|
437
|
+
|
|
438
|
+
HTM includes several Rake tasks to streamline development:
|
|
439
|
+
|
|
440
|
+
### Available Rake Tasks
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
# Show all available tasks
|
|
444
|
+
rake --tasks
|
|
445
|
+
|
|
446
|
+
# Output:
|
|
447
|
+
# rake db_setup # Run database setup
|
|
448
|
+
# rake db_test # Test database connection
|
|
449
|
+
# rake example # Run example
|
|
450
|
+
# rake stats # Show gem statistics
|
|
451
|
+
# rake test # Run tests
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### Common Development Commands
|
|
455
|
+
|
|
456
|
+
```bash
|
|
457
|
+
# Run all tests
|
|
458
|
+
rake test
|
|
459
|
+
|
|
460
|
+
# Test database connection
|
|
461
|
+
rake db_test
|
|
462
|
+
|
|
463
|
+
# Run example
|
|
464
|
+
rake example
|
|
465
|
+
|
|
466
|
+
# Show code statistics
|
|
467
|
+
rake stats
|
|
468
|
+
|
|
469
|
+
# Setup database schema
|
|
470
|
+
rake db_setup
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
## Environment Configuration
|
|
474
|
+
|
|
475
|
+
HTM uses environment variables for configuration. Here's a complete reference:
|
|
476
|
+
|
|
477
|
+
### Database Variables
|
|
478
|
+
|
|
479
|
+
| Variable | Description | Example |
|
|
480
|
+
|----------|-------------|---------|
|
|
481
|
+
| `HTM_DBURL` | Full PostgreSQL connection URL (preferred) | `postgres://user:pass@host:port/db?sslmode=require` |
|
|
482
|
+
| `HTM_DBNAME` | Database name | `tsdb` |
|
|
483
|
+
| `HTM_DBUSER` | Database username | `tsdbadmin` |
|
|
484
|
+
| `HTM_DBPASS` | Database password | `your_password` |
|
|
485
|
+
| `HTM_DBPORT` | Database port | `37807` |
|
|
486
|
+
| `HTM_SERVICE_NAME` | Service identifier (informational) | `db-67977` |
|
|
487
|
+
|
|
488
|
+
### Ollama Variables
|
|
489
|
+
|
|
490
|
+
| Variable | Description | Example |
|
|
491
|
+
|----------|-------------|---------|
|
|
492
|
+
| `OLLAMA_URL` | Ollama API URL (optional) | `http://localhost:11434` |
|
|
493
|
+
|
|
494
|
+
### Managing Environment Files
|
|
495
|
+
|
|
496
|
+
You can organize your environment variables using multiple files:
|
|
497
|
+
|
|
498
|
+
```bash
|
|
499
|
+
# ~/.bashrc__tiger - Database configuration
|
|
500
|
+
# ~/.bashrc__ollama - Ollama configuration (if needed)
|
|
501
|
+
|
|
502
|
+
# Load all configuration files in ~/.bashrc
|
|
503
|
+
source ~/.bashrc__tiger
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
## Troubleshooting
|
|
507
|
+
|
|
508
|
+
### Common Setup Issues
|
|
509
|
+
|
|
510
|
+
#### "Cannot connect to database"
|
|
511
|
+
|
|
512
|
+
**Symptoms**: Connection refused or timeout errors
|
|
513
|
+
|
|
514
|
+
**Solutions**:
|
|
515
|
+
|
|
516
|
+
```bash
|
|
517
|
+
# Verify environment variables are set
|
|
518
|
+
echo $HTM_DBURL
|
|
519
|
+
|
|
520
|
+
# Test connection directly with psql
|
|
521
|
+
psql $HTM_DBURL
|
|
522
|
+
|
|
523
|
+
# Check if service is running (TimescaleDB Cloud)
|
|
524
|
+
# Visit your Timescale Cloud dashboard
|
|
525
|
+
|
|
526
|
+
# For Docker, check if container is running
|
|
527
|
+
docker ps | grep timescale
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
#### "Ollama connection refused"
|
|
531
|
+
|
|
532
|
+
**Symptoms**: Embedding generation fails
|
|
533
|
+
|
|
534
|
+
**Solutions**:
|
|
535
|
+
|
|
536
|
+
```bash
|
|
537
|
+
# Verify Ollama is running
|
|
538
|
+
curl http://localhost:11434/api/version
|
|
539
|
+
|
|
540
|
+
# Start Ollama service
|
|
541
|
+
# macOS: Start from Applications or Activity Monitor
|
|
542
|
+
# Linux: ollama serve &
|
|
543
|
+
|
|
544
|
+
# Check if model is downloaded
|
|
545
|
+
ollama list | grep gpt-oss
|
|
546
|
+
|
|
547
|
+
# Pull model if missing
|
|
548
|
+
ollama pull gpt-oss
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
#### "Extension not available"
|
|
552
|
+
|
|
553
|
+
**Symptoms**: Errors about missing TimescaleDB or pgvector
|
|
554
|
+
|
|
555
|
+
**Solutions**:
|
|
556
|
+
|
|
557
|
+
```bash
|
|
558
|
+
# Re-run extension setup
|
|
559
|
+
ruby enable_extensions.rb
|
|
560
|
+
|
|
561
|
+
# Check extension status
|
|
562
|
+
psql $HTM_DBURL -c "SELECT extname, extversion FROM pg_extension ORDER BY extname"
|
|
563
|
+
|
|
564
|
+
# For TimescaleDB Cloud, extensions should be pre-installed
|
|
565
|
+
# For local PostgreSQL, ensure you're using timescale/timescaledb-ha image
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
#### "Bundle install fails"
|
|
569
|
+
|
|
570
|
+
**Symptoms**: Gem installation errors
|
|
571
|
+
|
|
572
|
+
**Solutions**:
|
|
573
|
+
|
|
574
|
+
```bash
|
|
575
|
+
# Ensure you have development tools
|
|
576
|
+
# macOS:
|
|
577
|
+
xcode-select --install
|
|
578
|
+
|
|
579
|
+
# Linux (Ubuntu/Debian):
|
|
580
|
+
sudo apt-get install build-essential libpq-dev
|
|
581
|
+
|
|
582
|
+
# Update RubyGems and Bundler
|
|
583
|
+
gem update --system
|
|
584
|
+
gem install bundler
|
|
585
|
+
|
|
586
|
+
# Clear bundle cache and retry
|
|
587
|
+
bundle clean --force
|
|
588
|
+
bundle install
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
#### "Test failures"
|
|
592
|
+
|
|
593
|
+
**Symptoms**: Tests fail with database or connection errors
|
|
594
|
+
|
|
595
|
+
**Solutions**:
|
|
596
|
+
|
|
597
|
+
```bash
|
|
598
|
+
# Ensure database is set up
|
|
599
|
+
rake db_setup
|
|
600
|
+
|
|
601
|
+
# Verify environment variables
|
|
602
|
+
source ~/.bashrc__tiger
|
|
603
|
+
env | grep TIGER
|
|
604
|
+
|
|
605
|
+
# Check Ollama is running
|
|
606
|
+
curl http://localhost:11434/api/version
|
|
607
|
+
|
|
608
|
+
# Run tests with verbose output
|
|
609
|
+
rake test TESTOPTS="-v"
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
### SSL/TLS Issues
|
|
613
|
+
|
|
614
|
+
If you see SSL certificate errors:
|
|
615
|
+
|
|
616
|
+
```bash
|
|
617
|
+
# Ensure sslmode is set in connection URL
|
|
618
|
+
echo $HTM_DBURL | grep sslmode
|
|
619
|
+
# Should show: sslmode=require
|
|
620
|
+
|
|
621
|
+
# For local development without SSL
|
|
622
|
+
export HTM_DBURL="postgres://user:pass@localhost:5432/tsdb?sslmode=disable"
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
### Ruby Version Issues
|
|
626
|
+
|
|
627
|
+
If you see Ruby version errors:
|
|
628
|
+
|
|
629
|
+
```bash
|
|
630
|
+
# Check Ruby version
|
|
631
|
+
ruby --version
|
|
632
|
+
|
|
633
|
+
# Update to Ruby 3.3
|
|
634
|
+
rbenv install 3.3.0
|
|
635
|
+
rbenv global 3.3.0
|
|
636
|
+
|
|
637
|
+
# Reinstall gems
|
|
638
|
+
bundle install
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
## Development Best Practices
|
|
642
|
+
|
|
643
|
+
### Keep Your Fork Updated
|
|
644
|
+
|
|
645
|
+
If you forked the repository, regularly sync with upstream:
|
|
646
|
+
|
|
647
|
+
```bash
|
|
648
|
+
# Fetch upstream changes
|
|
649
|
+
git fetch upstream
|
|
650
|
+
|
|
651
|
+
# Merge into your main branch
|
|
652
|
+
git checkout main
|
|
653
|
+
git merge upstream/main
|
|
654
|
+
|
|
655
|
+
# Push to your fork
|
|
656
|
+
git push origin main
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
### Use Feature Branches
|
|
660
|
+
|
|
661
|
+
Always create a branch for your changes:
|
|
662
|
+
|
|
663
|
+
```bash
|
|
664
|
+
# Create and switch to feature branch
|
|
665
|
+
git checkout -b feature/my-new-feature
|
|
666
|
+
|
|
667
|
+
# Make changes, commit, push
|
|
668
|
+
git add .
|
|
669
|
+
git commit -m "Add my new feature"
|
|
670
|
+
git push origin feature/my-new-feature
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
### Run Tests Before Committing
|
|
674
|
+
|
|
675
|
+
Always run the test suite before committing:
|
|
676
|
+
|
|
677
|
+
```bash
|
|
678
|
+
# Run all tests
|
|
679
|
+
rake test
|
|
680
|
+
|
|
681
|
+
# If tests pass, commit
|
|
682
|
+
git commit -m "Your commit message"
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
### Use debug_me for Debugging
|
|
686
|
+
|
|
687
|
+
HTM uses the `debug_me` gem for debugging. Don't use `puts` statements:
|
|
688
|
+
|
|
689
|
+
```ruby
|
|
690
|
+
require 'debug_me'
|
|
691
|
+
|
|
692
|
+
def some_method(param)
|
|
693
|
+
debug_me { [ :param ] } # Outputs: param = "value"
|
|
694
|
+
|
|
695
|
+
# For simple strings
|
|
696
|
+
debug_me "Reached this point in execution"
|
|
697
|
+
|
|
698
|
+
# Your code here
|
|
699
|
+
end
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
## Next Steps
|
|
703
|
+
|
|
704
|
+
Now that your development environment is set up:
|
|
705
|
+
|
|
706
|
+
1. **[Learn about Testing](testing.md)**: Understand HTM's test suite and write your own tests
|
|
707
|
+
2. **[Read Contributing Guide](contributing.md)**: Learn our workflow and submit your first PR
|
|
708
|
+
3. **[Explore the Schema](schema.md)**: Understand the database architecture
|
|
709
|
+
4. **[Check the Roadmap](../architecture/index.md)**: See what features are planned
|
|
710
|
+
|
|
711
|
+
## Getting Help
|
|
712
|
+
|
|
713
|
+
If you encounter issues not covered here:
|
|
714
|
+
|
|
715
|
+
- **Check existing issues**: [GitHub Issues](https://github.com/madbomber/htm/issues)
|
|
716
|
+
- **Ask in discussions**: [GitHub Discussions](https://github.com/madbomber/htm/discussions)
|
|
717
|
+
- **Review planning docs**: See `htm_teamwork.md` for design decisions
|
|
718
|
+
|
|
719
|
+
Happy developing! We look forward to your contributions.
|