Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Run the dream consolidation cycle, which performs automated memory maintenance i

- **Light phase:** Sort and deduplicate near-duplicate memories (cosine similarity ≥ `dream.similarity_threshold`).
- **Deep phase:** Score, promote, decay, and merge memories. Also promotes inbox items to long-term memory (items with attention_score ≥ `dream.min_score` become permanent; lower-scored items are evicted). Decays confidence on idle memories. Boosts frequently accessed memories. Performs LLM-assisted merging of similar pairs. Auto-links memories with high cosine similarity (≥ `dream.auto_link_threshold`, default 0.85).
- **REM phase:** Extract themes from memory clusters and write a dream diary (read-only reflection). When Ollama is available, generates actionable behavioral insights via LLM; falls back to count-based summaries when Ollama is unavailable.
- **REM phase:** Extract themes from memory clusters and write a dream diary (read-only reflection). When Ollama is available, generates actionable behavioral insights via LLM with "Do" directives, "Verify" steps, and `[SKILL PATCH]` sections (Detection Rule, Checklist, Pitfall, Verification); falls back to count-based summaries when Ollama is unavailable. When run with `--apply`, also appends behavioral insight and skill patch sections to `proposed-changes.md` at `~/.config/llmem/proposed-changes.md` (or `LMEM_HOME/proposed-changes.md`). Each dream run's entries are separated by a timestamp header. The file is append-only — existing content is preserved.

Without `--apply`, the dream cycle runs as a **dry run** — output is prefixed with `[DRY RUN]` and no changes are written to the database.

Expand Down
3 changes: 2 additions & 1 deletion docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dream:
boost_amount: 0.05
diary_path: null # Auto-resolved from GetDreamDiaryPath()
report_path: null # Auto-resolved from GetDreamReportPath()
proposed_changes_path: null # Auto-resolved from GetProposedChangesPath()
behavioral_threshold: 3
behavioral_lookback_days: 30
ollama_url: http://localhost:11434 # Ollama API URL for LLM-generated behavioral insights
Expand All @@ -62,7 +63,7 @@ session:
debounce_seconds: 30 # Idle debounce interval in seconds
```

> **Note:** The following fields exist in the Python config but are **not wired** in the Go implementation: `min_score`, `min_recall_count`, `min_unique_queries`, `boost_on_promote`, `merge_model`, `calibration_enabled`, `calibration_lookback_days`, `inbox_capacity`, `correction_detection` (top-level), `copilot` (top-level), and `proposed_changes_path`. Setting these in `config.yaml` has no effect when using the Go CLI.
> **Note:** The following fields exist in the Python config but are **not wired** in the Go implementation: `min_score`, `min_recall_count`, `min_unique_queries`, `boost_on_promote`, `merge_model`, `calibration_enabled`, `calibration_lookback_days`, `inbox_capacity`, `correction_detection` (top-level), and `copilot` (top-level). Setting these in `config.yaml` has no effect when using the Go CLI.

> **Note:** The Go config resolves `db_path` for OpenCode as `~/.local/share/opencode/opencode.db` using `filepath.Join` with proper path handling. The database is opened in read-only mode (`mode=ro`) using a `file:` URI prefix to ensure the `modernc.org/sqlite` driver enforces the read-only constraint. Without the `file:` prefix, query parameters like `mode=ro` are silently ignored and the driver opens in read-write mode.

Expand Down
8 changes: 7 additions & 1 deletion docs/DREAM.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The dream cycle performs automated memory maintenance during idle periods. It ca

- **Light phase:** Sort and deduplicate near-duplicate memories (cosine similarity ≥ threshold).
- **Deep phase:** Score, promote, decay, and merge memories. Decays confidence on idle memories. Boosts frequently accessed memories. Auto-links memories with high cosine similarity (≥ `dream.auto_link_threshold`, default 0.85) by creating `related_to` relations between them. Procedure memories older than `dream.stale_procedure_days` (default 30 days) with no recent access decay at double the normal rate — proposed-but-never-adopted procedures fade faster than confirmed ones.
- **REM phase:** Extract themes from memory clusters and write a dream diary (read-only reflection). Also extracts behavioral insights (patterns exceeding `dream.behavioral_threshold` occurrences within `dream.behavioral_lookback_days` days). When Ollama is available, uses an LLM call to generate specific, actionable procedural rules with "Do" directives and "Verify" steps. Falls back to count-based summaries when Ollama is unavailable.
- **REM phase:** Extract themes from memory clusters and write a dream diary (read-only reflection). Also extracts behavioral insights (patterns exceeding `dream.behavioral_threshold` occurrences within `dream.behavioral_lookback_days` days). When Ollama is available, uses an LLM call to generate specific, actionable procedural rules with "Do" directives and "Verify" steps; also generates `[SKILL PATCH]` sections (Detection Rule, Checklist, Pitfall, Verification). Falls back to count-based summaries when Ollama is unavailable. When run with `--apply`, appends behavioral insight and skill patch sections to `proposed-changes.md`, with a timestamp header separating dream runs. Proposed procedure memories are linked to their `proposed-changes.md` entry via `proposed_changes_link` metadata.

Configuration is under the `dream:` key in `config.yaml`. See [Configuration](CONFIGURATION.md) for all dream settings.

Expand Down Expand Up @@ -48,6 +48,7 @@ dreamer, err := dream.NewDreamer(dream.DreamerConfig{
OllamaClient: nil, // nil → created from BaseURL; takes precedence if provided
DiaryPath: "", // defaults from paths.GetDreamDiaryPath()
ReportPath: "", // defaults from paths.GetDreamReportPath()
ProposedChangesPath: "", // defaults from paths.GetProposedChangesPath()
})
if err != nil {
log.Fatal(err)
Expand All @@ -62,6 +63,9 @@ result, err := dreamer.Run(ctx, true, "deep")
// Write dream diary (markdown with sync.Mutex for in-process concurrency)
err = dreamer.WriteDiary(result)

// Write proposed-changes.md (behavioral insights + skill patches, append-only)
err = dreamer.WriteProposedChanges(ctx, result)

// Generate HTML dream report
err = dreamer.GenerateDreamReport(result, "/path/to/report.html")
```
Expand All @@ -88,6 +92,7 @@ err = dreamer.GenerateDreamReport(result, "/path/to/report.html")
| Model | string | `"glm-5.1:cloud"` | Ollama model name for behavioral insight generation |
| DiaryPath | string | paths.GetDreamDiaryPath() | Path for dream diary markdown |
| ReportPath | string | paths.GetDreamReportPath() | Path for HTML dream report |
| ProposedChangesPath | string | paths.GetProposedChangesPath() | Path for proposed-changes.md (behavioral insights and skill patches) |

#### DreamResult

Expand Down Expand Up @@ -117,6 +122,7 @@ type BehavioralInsight struct {
Count int
InsightID string
ContentSnippet string
Samples []string
}

type RemPhaseResult struct {
Expand Down
4 changes: 3 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ type DreamConfig struct {
Model string `yaml:"model"`
// ModelTimeout is the timeout for each LLM call during REM behavioral insight generation.
// Parsed as a Go duration string (e.g. "5m", "120s"). Defaults to "5m".
ModelTimeout string `yaml:"model_timeout"`
ModelTimeout string `yaml:"model_timeout"`
ProposedChangesPath string `yaml:"proposed_changes_path"`
}

// SessionConfig holds session lifecycle settings.
Expand Down Expand Up @@ -239,6 +240,7 @@ func (c *Config) DreamerConfig() dream.DreamerConfig {
StaleProcedureDays: c.Dream.StaleProcedureDays,
DiaryPath: c.Dream.DiaryPath,
ReportPath: c.Dream.ReportPath,
ProposedChangesPath: c.Dream.ProposedChangesPath,
BaseURL: ollamaURL,
Model: model,
ModelTimeout: modelTimeout,
Expand Down
Loading
Loading