opendream 0.1.0__tar.gz

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 (39) hide show
  1. opendream-0.1.0/LICENSE +7 -0
  2. opendream-0.1.0/PKG-INFO +381 -0
  3. opendream-0.1.0/README.md +348 -0
  4. opendream-0.1.0/opendream/__init__.py +5 -0
  5. opendream-0.1.0/opendream/bootstrap.py +56 -0
  6. opendream-0.1.0/opendream/cli.py +703 -0
  7. opendream-0.1.0/opendream/consolidator.py +456 -0
  8. opendream-0.1.0/opendream/dream.py +241 -0
  9. opendream-0.1.0/opendream/episodes.py +120 -0
  10. opendream-0.1.0/opendream/evaluation.py +150 -0
  11. opendream-0.1.0/opendream/extractor.py +123 -0
  12. opendream-0.1.0/opendream/fixtures/dream_fidelity_transcript.jsonl +5 -0
  13. opendream-0.1.0/opendream/fixtures/golden_events.jsonl +20 -0
  14. opendream-0.1.0/opendream/fixtures/memory_quality_eval.json +61 -0
  15. opendream-0.1.0/opendream/integration.py +457 -0
  16. opendream-0.1.0/opendream/models.py +192 -0
  17. opendream-0.1.0/opendream/observability.py +725 -0
  18. opendream-0.1.0/opendream/retriever.py +147 -0
  19. opendream-0.1.0/opendream/schema/consolidation-op.schema.json +40 -0
  20. opendream-0.1.0/opendream/schema/memory-candidate.schema.json +67 -0
  21. opendream-0.1.0/opendream/schema/memory-event.schema.json +77 -0
  22. opendream-0.1.0/opendream/schema/memory-index.schema.json +27 -0
  23. opendream-0.1.0/opendream/schema/memory-topic.schema.json +66 -0
  24. opendream-0.1.0/opendream/storage.py +808 -0
  25. opendream-0.1.0/opendream/util.py +180 -0
  26. opendream-0.1.0/opendream/validation.py +118 -0
  27. opendream-0.1.0/opendream/webapp.py +414 -0
  28. opendream-0.1.0/opendream.egg-info/PKG-INFO +381 -0
  29. opendream-0.1.0/opendream.egg-info/SOURCES.txt +37 -0
  30. opendream-0.1.0/opendream.egg-info/dependency_links.txt +1 -0
  31. opendream-0.1.0/opendream.egg-info/entry_points.txt +2 -0
  32. opendream-0.1.0/opendream.egg-info/requires.txt +5 -0
  33. opendream-0.1.0/opendream.egg-info/top_level.txt +1 -0
  34. opendream-0.1.0/pyproject.toml +79 -0
  35. opendream-0.1.0/setup.cfg +4 -0
  36. opendream-0.1.0/tests/test_memory_cli.py +702 -0
  37. opendream-0.1.0/tests/test_observability.py +177 -0
  38. opendream-0.1.0/tests/test_release_artifact.py +128 -0
  39. opendream-0.1.0/tests/test_validation_and_models.py +82 -0
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2026 OpenDream contributors.
2
+
3
+ All rights reserved.
4
+
5
+ No license is granted to copy, modify, distribute, sublicense, or use this software outside the terms explicitly approved by the repository owner.
6
+
7
+ This repository is release-hardened for internal or controlled distribution, but it is not offered under an open-source license unless and until this file is replaced by an explicit license grant.
@@ -0,0 +1,381 @@
1
+ Metadata-Version: 2.4
2
+ Name: opendream
3
+ Version: 0.1.0
4
+ Summary: Local-first memory subsystem for coding agents
5
+ Author: OpenDream Maintainers
6
+ License: Copyright (c) 2026 OpenDream contributors.
7
+
8
+ All rights reserved.
9
+
10
+ No license is granted to copy, modify, distribute, sublicense, or use this software outside the terms explicitly approved by the repository owner.
11
+
12
+ This repository is release-hardened for internal or controlled distribution, but it is not offered under an open-source license unless and until this file is replaced by an explicit license grant.
13
+
14
+ Keywords: agents,memory,coding-agents,local-first
15
+ Classifier: Development Status :: 3 - Alpha
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: License :: Other/Proprietary License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Topic :: Software Development :: Libraries
25
+ Requires-Python: >=3.11
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Provides-Extra: dev
29
+ Requires-Dist: build>=1.2.2; extra == "dev"
30
+ Requires-Dist: mypy>=1.11; extra == "dev"
31
+ Requires-Dist: ruff>=0.11; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ # OpenDream
35
+
36
+ OpenDream is a local-first memory subsystem for coding agents. It captures immutable evidence, derives typed memory candidates, consolidates durable memory with provenance, and exposes reproducible CLI workflows for bootstrap, dreaming, retrieval, evaluation, and release checks.
37
+
38
+ ## Integration model (canonical surface)
39
+
40
+ OpenDream’s **core product** is a **local CLI-first memory engine** plus the thin runtime integration layer from spec **403**. It does **not** ship a long-running daemon or an in-repo model-driven “decide what to remember” service.
41
+
42
+ The **practical integration contract** is:
43
+
44
+ - **`emit-event`** — append schema-valid evidence to the store.
45
+ - **`maintain`** — cron-/idle-/session-end-friendly wrapper that runs extract plus consolidate when work qualifies, with structured **`status`** and **`reason`** when it skips (not a silent no-op).
46
+ - **`prepare-context`** — prompt-ready retrieval surface for the next task.
47
+
48
+ The **runtime** (hooks, scripts, IDE rules, or your own automation) decides **when** to call these commands. OpenDream validates, extracts, consolidates, retrieves, and writes audit artifacts **once invoked**.
49
+
50
+ **Corrections vs loose descriptions elsewhere:**
51
+
52
+ - Prefer **`maintain`** as the documented maintenance entrypoint (spec **403**). The CLI may expose additional commands; treat **`maintain`** as the integration anchor.
53
+ - **First-party product surface** = this **generic CLI**. Runtime-specific hook or script glue is **operator-owned** unless you add it yourself.
54
+ - **No first-party MCP server** ships in this repo; [`docs/mcp/servers.md`](./docs/mcp/servers.md) is a template for inventorying MCP, not an OpenDream server spec.
55
+
56
+ ## What’s in this repo
57
+
58
+ - `opendream/` — runtime package for events, candidates, consolidation, retrieval, and storage
59
+ - `tests/` — fixture-driven integration and validation tests
60
+ - `specs/401-autodream-style-memory-subsystem/` — canonical implementation spec
61
+ - `openspec/changes/401-autodream-style-memory-subsystem/` — proposal bundle and design artifacts
62
+ - `docs/` — repo-wide architecture and governance docs
63
+
64
+ Governance reserves `.meta/spec-adapters/` as the **preferred location for optional, non-normative** framework examples (see [`AGENTS.md`](./AGENTS.md)). Those files are **not** part of the packaged product API; `scripts/check_adapters.py` only checks that example paths and documented CLI strings stay consistent.
65
+
66
+ ## Quick start (contributors)
67
+
68
+ ```bash
69
+ make sync
70
+ # or: make setup
71
+ make demo
72
+ make verify
73
+ make release-check
74
+ opendream --help
75
+ ```
76
+
77
+ `make sync` uses **uv** and matches CI (`uv sync --group dev`). `make setup` uses **pip** in a fresh `python3 -m venv`. Use `.venv/bin/opendream` if you skip activating the venv.
78
+
79
+ ## Operator path (install + smoke)
80
+
81
+ Prefer the **console entrypoint** after install (`pyproject.toml` defines `opendream`). The **PyPI distribution**, **Python package**, and **CLI** are all named **`opendream`** (`python3 -m opendream.cli` is the module fallback if the script is not on `PATH`).
82
+
83
+ ### 1. Install the console entrypoint
84
+
85
+ **PyPI (recommended once published):** install into an isolated tool environment so you avoid Homebrew’s system Python (**PEP 668**).
86
+
87
+ ```bash
88
+ uv tool install opendream
89
+ # or: pipx install opendream
90
+ # or: python3 -m venv .venv && .venv/bin/pip install opendream
91
+ opendream --help
92
+ ```
93
+
94
+ **Bleeding edge from Git** (same isolation; no PyPI required):
95
+
96
+ **[uv](https://docs.astral.sh/uv/guides/tools/):**
97
+
98
+ ```bash
99
+ uv tool install "opendream @ git+https://github.com/pylit-ai/opendream.git"
100
+ opendream --help
101
+ ```
102
+
103
+ **[pipx](https://pipx.pypa.io/):**
104
+
105
+ ```bash
106
+ pipx install git+https://github.com/pylit-ai/opendream.git
107
+ opendream --help
108
+ ```
109
+
110
+ To pin a branch or tag, use a PEP 508 URL suffix (e.g. `@main` or `@v0.1.0`) where your installer allows it.
111
+
112
+ **Local checkout (contributors or editable hack):** from the OpenDream root, use the repo venv (avoids `externally-managed-environment` on system `python3`):
113
+
114
+ ```bash
115
+ make setup
116
+ .venv/bin/opendream --help
117
+ ```
118
+
119
+ **Manual venv** (same as `make setup`, any checkout path):
120
+
121
+ ```bash
122
+ cd /path/to/opendream
123
+ python3 -m venv .venv
124
+ .venv/bin/python -m pip install -e .
125
+ .venv/bin/opendream --help
126
+ ```
127
+
128
+ After `source .venv/bin/activate`, you can run `opendream` without the prefix.
129
+
130
+ If `python3` is missing, install Python from [python.org](https://www.python.org/downloads/) or your OS package manager. On macOS, `python` is often absent while `python3` is present.
131
+
132
+ ### 2. Initialize a workspace
133
+
134
+ ```bash
135
+ opendream init --workspace .tmp/ws
136
+ ```
137
+
138
+ Expected: `memory/` under the workspace, including `memory/state/durable_records.json`, `memory/state/index.json`, and `memory/MEMORY.md`.
139
+
140
+ ### 3. Emit one event manually
141
+
142
+ ```bash
143
+ opendream emit-event \
144
+ --workspace .tmp/ws \
145
+ --kind project_decision \
146
+ --content "Use pnpm in this repo" \
147
+ --message-ref manual-1 \
148
+ --tag key:package-manager
149
+ ```
150
+
151
+ Expected: JSON with `"status": "appended"`, and new JSONL under `memory/state/events/`.
152
+
153
+ ### 4. Run maintenance
154
+
155
+ ```bash
156
+ opendream maintain --workspace .tmp/ws
157
+ ```
158
+
159
+ Expected: JSON output with `extract.processed_events > 0` when events were pending, `consolidate.status` of `completed` or an explicit skip reason, and `memory/state/maintenance_state.json` updated when work runs. After consolidation, topic files and the startup index appear when promotion rules allow.
160
+
161
+ ### 5. Prepare prompt context
162
+
163
+ ```bash
164
+ opendream prepare-context \
165
+ --workspace .tmp/ws \
166
+ --query "package manager and workflow"
167
+ ```
168
+
169
+ Expected: `selected_memory_ids`, `why`, and `prompt_context` (startup index section plus selected durable memory).
170
+
171
+ ### 6. Run the repo verifiers
172
+
173
+ ```bash
174
+ make verify
175
+ make release-check
176
+ ```
177
+
178
+ `make verify` runs `scripts/verify.py` (Ruff lint, mypy on `opendream` and `scripts`, unit tests, `eval dream-fidelity`, adapter example integrity, packaging smoke). `make release-check` adds the full release gate (wheel/sdist, clean venv install, `dream run`, `eval dream-fidelity`, and `tests.test_release_artifact`).
179
+
180
+ **Verification limits:** This gate is **real** for CLI behavior and packaging, but it is still a **bounded** suite. It does not prove absence of every defect class you might care about in production. Treat failures as authoritative; treat PASS as “meets this repo’s bar,” not universal safety.
181
+
182
+ ### Observability UI (run it yourself)
183
+
184
+ Nothing starts a browser or background server for you: **you** run the CLI on your machine. The UI reads **one** workspace’s `memory/` tree (the path you pass to `--workspace`), not every repo at once.
185
+
186
+ After install:
187
+
188
+ ```bash
189
+ opendream observe index --workspace "$PWD"
190
+ opendream observe serve --workspace "$PWD" --port 8000
191
+ ```
192
+
193
+ `observe serve` **blocks the terminal** until you stop it (Ctrl+C). On the same machine, open **http://127.0.0.1:8000/overview** (adjust `--port` / `--host` if needed).
194
+
195
+ More detail: [Observability web app](#observability-web-app).
196
+
197
+ ## CLI
198
+
199
+ **Primary invocation** (after `pip install -e .` or `make setup`):
200
+
201
+ ```bash
202
+ opendream init --workspace .tmp/workspace
203
+ opendream init --workspace ~/.opendream-global --store-kind global
204
+ opendream demo --workspace .tmp/demo
205
+ opendream bootstrap-index --workspace .tmp/workspace --events tests/fixtures/bootstrap_events.jsonl
206
+ opendream consolidate --workspace .tmp/workspace
207
+ opendream retrieve --workspace .tmp/workspace --query "package manager and workflow"
208
+ opendream emit-event --workspace .tmp/workspace --kind project_decision --content "Use pnpm in this repo" --message-ref manual-1 --tag key:package-manager
209
+ opendream maintain --workspace .tmp/workspace
210
+ opendream dream run --workspace .tmp/workspace --episodes tests/fixtures/transcript_only_dream.jsonl
211
+ opendream dream status --workspace .tmp/workspace
212
+ opendream dream tick --workspace .tmp/workspace --episodes tests/fixtures/transcript_only_dream.jsonl
213
+ opendream eval dream-fidelity --workspace .tmp/dream-eval --compat-mode autodream
214
+ opendream eval memory-quality --workspace .tmp/eval
215
+ opendream prepare-context --workspace .tmp/workspace --query "package manager and workflow"
216
+ opendream prepare-context --workspace .tmp/workspace --query "package manager and workflow" --include-global --global-workspace ~/.opendream-global
217
+ opendream status --workspace .tmp/workspace
218
+ opendream observe index --workspace .tmp/workspace
219
+ opendream observe serve --workspace .tmp/workspace --port 8000
220
+ ```
221
+
222
+ **Module fallback** (editable checkout without console script on `PATH`):
223
+
224
+ ```bash
225
+ python3 -m opendream.cli --help
226
+ python3 -m opendream.cli init --workspace .tmp/workspace
227
+ # …same subcommands as opendream …
228
+ ```
229
+
230
+ ## Verification
231
+
232
+ OpenDream is only "verified" when the scripted gate passes. The gate emits `.tmp/verification/verification_report.json` with per-stage PASS or FAIL evidence.
233
+
234
+ - `make lint` — Ruff (`scripts/lint.py`)
235
+ - `make typecheck` — mypy on `opendream` and `scripts` (`scripts/typecheck.py`)
236
+ - `make test` — unit tests
237
+ - `make verify` — `scripts/verify.py` (lint, typecheck, tests, `eval dream-fidelity`, `scripts/check_adapters.py`, packaging smoke)
238
+ - `make release-check` — authoritative release gate: artifacts, clean venv install, `dream run`, `eval dream-fidelity`, verification replay
239
+
240
+ `make release-check` emits:
241
+
242
+ - `.tmp/release-check/release_manifest.json`
243
+ - `.tmp/release-check/release_summary.md`
244
+
245
+ ## Releasing (maintainers)
246
+
247
+ Publishing matches the **agentic-devkit** pattern: **tag push** runs [`.github/workflows/publish-pypi.yml`](./.github/workflows/publish-pypi.yml) (`uv build` + `uv publish`) using **PyPI Trusted Publishing (OIDC)**—no API token stored in GitHub secrets.
248
+
249
+ ### Agentic-devkit vs OpenDream (same *name*, different *binding*)
250
+
251
+ - **GitHub Environment `pypi`:** There is one environment **per repository**. The `pypi` environment on **agent-dev-templates** does **not** apply to **pylit-ai/opendream**. This repo’s workflow uses `environment: pypi`, so **pylit-ai/opendream** must have its own environment named `pypi` (Settings → Environments). It can use the same *name* as other repos; it is still a separate object.
252
+ - **PyPI trusted publisher:** Each **PyPI project** has its own publisher rules. The **opendream** project on PyPI must list **repository `pylit-ai/opendream`** and workflow **`publish-pypi.yml`**. A row that only allows **agent-dev-templates** / **agentic-devkit** will **not** publish **opendream**.
253
+
254
+ ### Checklist
255
+
256
+ 1. **PyPI (project `opendream`):** In PyPI, open the **opendream** project → **Settings** → **Publishing** → add **trusted publisher**:
257
+ - Owner: `pylit-ai`
258
+ - Repository: `opendream` (not `agent-dev-templates`)
259
+ - Workflow: `publish-pypi.yml`
260
+ - Environment name: `pypi` (must match the workflow; this workflow sets `environment: pypi`)
261
+ 2. **GitHub (`pylit-ai/opendream`):** Environment **`pypi`** exists (Settings → Environments). Add branch protection / required reviewers there if you want release gates.
262
+ 3. **Cut a release:** `pyproject.toml` version must be new on PyPI. Then either:
263
+ - `git tag -a v0.1.0 -m "Release v0.1.0"` and `git push origin v0.1.0` (version in tag and in `pyproject.toml` should agree), or
264
+ - `make release-patch` / `release-minor` / `release-major` (bumps version, commits `pyproject.toml` + `uv.lock`, tags, pushes).
265
+
266
+ Local dry run: `uv build` (artifacts under `dist/`). **TestPyPI** is not wired by default; add a second job or workflow if you need it.
267
+
268
+ ## Docs
269
+
270
+ - [NORTHSTAR.md](./NORTHSTAR.md)
271
+ - [PRD.md](./PRD.md)
272
+ - [CONSTITUTION.md](./CONSTITUTION.md)
273
+ - [AGENTS.md](./AGENTS.md)
274
+
275
+ ## Generated data
276
+
277
+ Memory artifacts are written under a workspace-local `memory/` directory by default. Use `--memory-dir <relative-path>` when a repo needs a non-default location, and the same path is honored by direct writes, dreaming, retrieval context, and status commands.
278
+
279
+ ## Runtime integration
280
+
281
+ For real agent use, treat OpenDream as a **CLI sidecar**:
282
+
283
+ - emit memory-worthy events with **`emit-event`**
284
+ - run **`maintain`** on a schedule or after sessions so extract + consolidate can run (structured skip reasons when there is nothing to do)
285
+ - run **`dream run`** against transcript or log episodes when you want reflective consolidation
286
+ - use **`dream status`** or **`dream tick`** when you want scheduler-safe DreamRunner state and backlog polling
287
+ - use **`prepare-context`** to inject selected memory into the next planning prompt
288
+ - call **`status`** when you want lock and pending-work visibility before prompting
289
+
290
+ ## Layered stores
291
+
292
+ Initialize a repo-local project store and an optional user-global store:
293
+
294
+ ```bash
295
+ opendream init --workspace "$PWD"
296
+ opendream init --workspace ~/.opendream-global --store-kind global
297
+ ```
298
+
299
+ Route user preferences into the global store:
300
+
301
+ ```bash
302
+ opendream emit-event \
303
+ --workspace "$PWD" \
304
+ --route global \
305
+ --global-workspace ~/.opendream-global \
306
+ --scope global \
307
+ --kind preference_signal \
308
+ --content "Prefer concise summaries across repos." \
309
+ --message-ref manual-global-1 \
310
+ --tag key:summary-style
311
+ ```
312
+
313
+ Compose project and global context with project precedence:
314
+
315
+ ```bash
316
+ opendream prepare-context \
317
+ --workspace "$PWD" \
318
+ --query "package manager and summary style" \
319
+ --include-global \
320
+ --global-workspace ~/.opendream-global
321
+ ```
322
+
323
+ ## Scheduler surface
324
+
325
+ **`maintain`** is the documented wrapper for repeated extract + consolidate. **`status`** exposes pending work, last run, lock state, and dream state.
326
+
327
+ ```bash
328
+ opendream status --workspace "$PWD"
329
+ opendream maintain --workspace "$PWD"
330
+ ```
331
+
332
+ Dream runs are explicit and bounded:
333
+
334
+ ```bash
335
+ opendream dream run \
336
+ --workspace "$PWD" \
337
+ --episodes tests/fixtures/transcript_only_dream.jsonl \
338
+ --compat-mode autodream
339
+
340
+ opendream dream status --workspace "$PWD" --compat-mode autodream
341
+ opendream dream tick --workspace "$PWD" --compat-mode autodream
342
+ ```
343
+
344
+ Memory quality and dream fidelity can be benchmarked locally:
345
+
346
+ ```bash
347
+ opendream eval dream-fidelity --workspace .tmp/dream-eval --compat-mode autodream
348
+ opendream eval memory-quality --workspace .tmp/eval
349
+ ```
350
+
351
+ Cron example:
352
+
353
+ ```bash
354
+ */10 * * * * cd /path/to/repo && opendream maintain --workspace "$PWD" --include-global --global-workspace ~/.opendream-global
355
+ ```
356
+
357
+ ## Observability web app
358
+
359
+ OpenDream ships a local-first observability stack built from the same filesystem artifacts as the runtime. The read model is derived, provenance-preserving, and never becomes the source of truth.
360
+
361
+ **You start it locally** (see [Operator path → Observability UI](#observability-ui-run-it-yourself)). There is no hosted instance bundled with the repo.
362
+
363
+ ```bash
364
+ opendream observe index --workspace "$PWD"
365
+ opendream observe serve --workspace "$PWD" --port 8000
366
+ # Then open http://127.0.0.1:8000/overview (same machine as the server).
367
+ ```
368
+
369
+ The server exposes:
370
+
371
+ - a read model at `memory/state/observability_index.json`
372
+ - read APIs for overview, memories, runs, retrievals, sessions, context, graph, reviews, evals, and exports
373
+ - audited write APIs for annotations, review decisions, and exports
374
+ - SSE updates at `/api/stream/status`
375
+ - a no-build desktop-first UI at routes like `/overview`, `/memories`, `/runs`, `/retrievals`, `/sessions`, `/reviews`, `/graph`, `/evals`, and `/exports`
376
+
377
+ `prepare-context` persists context-assembly artifacts so the context viewer can reconstruct what the agent actually saw.
378
+
379
+ ## Optional non-normative examples
380
+
381
+ Framework-oriented **example** snippets and scripts may live under `.meta/spec-adapters/` per [`AGENTS.md`](./AGENTS.md). They translate the **same CLI** into hook or prompt patterns; they are **not** a separate supported API. `scripts/check_adapters.py` ensures those examples stay present and reference real `opendream` subcommands.