opencode-omni-memory-plugin 2.0.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 caoool
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,285 @@
1
+ # OpenCode Omni Memory Plugin
2
+
3
+ Native, local, Git-friendly long-term memory and project continuity for [OpenCode](https://opencode.ai/).
4
+
5
+ The package installs a global `omni-memory` skill, a companion plugin, seven slash commands, global memory files, and OpenCode instruction wiring. It keeps durable memory separate from mutable project state such as specifications, roadmaps, progress, findings, decisions, and session handoffs.
6
+
7
+ Formerly published as `opencode-markdown-memory`; installing this version over an old install migrates it in place.
8
+
9
+ ## Features
10
+
11
+ - Global cross-project memory
12
+ - Host-specific memory
13
+ - Project-scoped durable memory
14
+ - Branch-aware continuation handoffs
15
+ - Protected project charter and agent-maintained working specification
16
+ - Roadmap, progress, findings, and decision tracking
17
+ - Temporary journals for concurrent sessions
18
+ - Conservative automatic capture at meaningful transitions
19
+ - Self-evolution: user corrections and repeated friction are captured once, then promoted from memory into governing configuration
20
+ - Session bootstrap injected by the companion plugin so memory behavior is in context from turn one
21
+ - Compaction defense: the plugin instructs continuation summaries to carry forward memory pointers and un-persisted decisions
22
+ - Bounded startup injection with detailed retrieval on demand
23
+ - Plain Markdown storage with no external memory service
24
+ - Idempotent installer with update, status, backup, and uninstall support
25
+
26
+ ## How it works
27
+
28
+ Three layers cooperate:
29
+
30
+ 1. **Instructions** (`opencode.json` `instructions` array) auto-load global memory, project memory, and the project handoff into every request.
31
+ 2. **Plugin** (`plugins/omni-memory.js`) injects a compact orientation bootstrap into the first user message of each session (idempotent, marker-guarded) and pushes continuation requirements into the compaction prompt via `experimental.session.compacting`. The plugin cannot write files; it makes behavior consistent, while the skill defines it.
32
+ 3. **Skill** (`skills/omni-memory`) holds the full rulebook — orientation, precedence, retention, transitions, concurrency, handoff, archival — and is loaded on demand for substantive work.
33
+
34
+ ## Storage model
35
+
36
+ Global state:
37
+
38
+ ```text
39
+ ~/.config/opencode/memory/
40
+ ├── GLOBAL.md # Always loaded
41
+ ├── HANDOFF.md # Cross-project continuation, loaded on demand
42
+ ├── hosts/<hostname>.md # Host-specific facts
43
+ └── archive/
44
+ ```
45
+
46
+ Project state is created lazily under the active project:
47
+
48
+ ```text
49
+ .opencode/project/
50
+ ├── INDEX.md
51
+ ├── MEMORY.md # Always loaded
52
+ ├── HANDOFF.md # Always loaded
53
+ ├── CHARTER.md
54
+ ├── SPEC.md
55
+ ├── ROADMAP.md
56
+ ├── PROGRESS.md
57
+ ├── FINDINGS.md
58
+ ├── DECISIONS.md
59
+ ├── sessions/ # Temporary and Git-ignored
60
+ └── archive/<milestone>/
61
+ ```
62
+
63
+ Only global memory, project memory, and project handoff are inserted automatically. Detailed project state is retrieved when relevant, keeping normal startup context small.
64
+
65
+ ## Requirements
66
+
67
+ - OpenCode
68
+ - Bash
69
+ - Git
70
+ - Node.js
71
+
72
+ The installer edits strict JSON. If your only global configuration is an `opencode.jsonc` containing comments or trailing commas, follow the manual configuration section before running the installer.
73
+
74
+ ## Install
75
+
76
+ ### Recommended: npm package
77
+
78
+ The package bundles the installer and all managed files, so no separate clone is required:
79
+
80
+ ```bash
81
+ npx opencode-omni-memory-plugin install
82
+ ```
83
+
84
+ Or install it globally to keep the `update`, `status`, and `uninstall` subcommands handy:
85
+
86
+ ```bash
87
+ npm install -g opencode-omni-memory-plugin
88
+ opencode-omni-memory-plugin install
89
+ ```
90
+
91
+ Then quit and restart OpenCode. The same subcommands documented below (`update`, `status`, `uninstall`) work through the `opencode-omni-memory-plugin` binary.
92
+
93
+ ### Alternative: inspect and clone
94
+
95
+ ```bash
96
+ INSTALL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/opencode-omni-memory-plugin/repo"
97
+ git clone https://github.com/caoool/opencode-omni-memory-plugin.git "$INSTALL_DIR"
98
+ "$INSTALL_DIR/install.sh" install
99
+ ```
100
+
101
+ Then quit and restart OpenCode.
102
+
103
+ ### One-line bootstrap
104
+
105
+ This downloads the installer, which clones the repository into the managed data directory before installing:
106
+
107
+ ```bash
108
+ curl -fsSL https://raw.githubusercontent.com/caoool/opencode-omni-memory-plugin/main/install.sh | bash -s -- install
109
+ ```
110
+
111
+ Review remote scripts before piping them to a shell if you do not control the source.
112
+
113
+ ### Migrating from opencode-markdown-memory
114
+
115
+ Run `install` (or `update`) from this repository. The installer:
116
+
117
+ - Replaces the legacy `skills/markdown-memory` with `skills/omni-memory` (the legacy copy is backed up)
118
+ - Migrates the managed `AGENTS.md` block from the old `opencode-markdown-memory` markers to the new ones in place
119
+ - Leaves all memory data untouched
120
+
121
+ If your old managed checkout lives at `~/.local/share/opencode-markdown-memory/repo`, point its remote at the renamed repository or re-clone into the new path shown above.
122
+
123
+ ## Update
124
+
125
+ For the recommended managed checkout:
126
+
127
+ ```bash
128
+ "${XDG_DATA_HOME:-$HOME/.local/share}/opencode-omni-memory-plugin/repo/install.sh" update
129
+ ```
130
+
131
+ If you cloned the repository elsewhere:
132
+
133
+ ```bash
134
+ /path/to/opencode-omni-memory-plugin/install.sh update
135
+ ```
136
+
137
+ The updater performs a fast-forward-only Git update and reinstalls managed files. Existing managed files that differ are backed up under:
138
+
139
+ ```text
140
+ ${XDG_DATA_HOME:-$HOME/.local/share}/opencode-omni-memory-plugin/backups/<timestamp>/
141
+ ```
142
+
143
+ User memory files are created only when missing and are never overwritten during updates.
144
+
145
+ Restart OpenCode after every install or update because configuration, commands, plugins, and skills are loaded at startup.
146
+
147
+ ## Status
148
+
149
+ ```bash
150
+ "${XDG_DATA_HOME:-$HOME/.local/share}/opencode-omni-memory-plugin/repo/install.sh" status
151
+ ```
152
+
153
+ ## Uninstall
154
+
155
+ ```bash
156
+ "${XDG_DATA_HOME:-$HOME/.local/share}/opencode-omni-memory-plugin/repo/install.sh" uninstall
157
+ ```
158
+
159
+ Uninstall removes the managed skill, plugin, commands, the managed `AGENTS.md` block, and the three configuration instruction entries. It deliberately preserves:
160
+
161
+ - `~/.config/opencode/memory/`
162
+ - Every project's `.opencode/project/`
163
+ - The downloaded repository checkout
164
+
165
+ Delete those manually only if you no longer need the stored memory or updater source.
166
+
167
+ ## Commands
168
+
169
+ After restarting OpenCode:
170
+
171
+ ```text
172
+ /project-init [full]
173
+ /remember [global|host|project] <fact>
174
+ /recall <query>
175
+ /forget <query>
176
+ /handoff
177
+ /project-status
178
+ /memory-audit [global|project|all]
179
+ ```
180
+
181
+ Natural language works too:
182
+
183
+ ```text
184
+ Remember globally that I prefer pnpm.
185
+ Remember for this project that migrations must be backward compatible.
186
+ Recall what we decided about authentication.
187
+ Prepare a handoff for the next session.
188
+ ```
189
+
190
+ ## Automatic behavior
191
+
192
+ For substantive tasks, the injected bootstrap and installed global instructions tell OpenCode to:
193
+
194
+ 1. Orient silently from memory before acting; verified repository state overrides remembered state.
195
+ 2. Load the `omni-memory` skill for the full procedure when work is substantive.
196
+ 3. Retrieve charter, spec, roadmap, progress, findings, and decisions only when relevant.
197
+ 4. Update project state after material decisions, milestone changes, blockers, or verification results.
198
+ 5. Capture user corrections and repeated friction once, in the narrowest correct scope, and promote standing behavior rules out of memory into governing configuration.
199
+ 6. Enforce a single writer: only the primary agent writes memory or project state; subagents report candidate lessons instead.
200
+ 7. Perform a conservative durable-memory check at task completion.
201
+
202
+ The skill does not record raw transcripts, logs, secrets, temporary status, or unverified assumptions. The plugin's compaction hook asks the summarizer to carry forward memory pointers and un-persisted state, but it cannot write files; if OpenCode terminates abruptly, meaningful-transition checkpoints and `/handoff` provide best-effort continuity.
203
+
204
+ ## Project initialization
205
+
206
+ Project state is normally created on the first durable project fact. To initialize explicitly:
207
+
208
+ ```text
209
+ /project-init
210
+ ```
211
+
212
+ This creates `INDEX.md`, `MEMORY.md`, and `HANDOFF.md`.
213
+
214
+ For the complete project-control structure:
215
+
216
+ ```text
217
+ /project-init full
218
+ ```
219
+
220
+ The initializer preserves existing files. Existing project documentation remains independent; `.opencode/project/INDEX.md` records its relationship to the agent working specification.
221
+
222
+ ## Manual configuration
223
+
224
+ The installer adds these entries to the global `instructions` array:
225
+
226
+ ```json
227
+ {
228
+ "instructions": [
229
+ "~/.config/opencode/memory/GLOBAL.md",
230
+ ".opencode/project/MEMORY.md",
231
+ ".opencode/project/HANDOFF.md"
232
+ ]
233
+ }
234
+ ```
235
+
236
+ If your configuration uses commented JSONC, add those entries manually, temporarily provide a strict `opencode.json`, then rerun the installer. The installer refuses to rewrite commented JSONC because doing so could destroy comments or formatting.
237
+
238
+ The installer also maintains an idempotent block in `~/.config/opencode/AGENTS.md` between:
239
+
240
+ ```text
241
+ <!-- opencode-omni-memory-plugin:start -->
242
+ <!-- opencode-omni-memory-plugin:end -->
243
+ ```
244
+
245
+ Legacy `opencode-markdown-memory` markers are migrated automatically.
246
+
247
+ ## Custom locations and versions
248
+
249
+ ```bash
250
+ OPENCODE_CONFIG_DIR=/custom/opencode \
251
+ OPENCODE_OMNI_MEMORY_HOME=/custom/data/opencode-omni-memory-plugin \
252
+ OPENCODE_OMNI_MEMORY_REF=main \
253
+ ./install.sh install
254
+ ```
255
+
256
+ Environment variables:
257
+
258
+ | Variable | Purpose |
259
+ | --- | --- |
260
+ | `OPENCODE_CONFIG_DIR` | Override the OpenCode config directory |
261
+ | `OPENCODE_OMNI_MEMORY_HOME` | Override checkout, backups, and install metadata |
262
+ | `OPENCODE_OMNI_MEMORY_REF` | Select the Git branch/ref used by update |
263
+ | `OPENCODE_OMNI_MEMORY_SOURCE` | Install from a local checkout for development/testing |
264
+ | `OPENCODE_MEMORY_HOSTNAME` | Override the host-memory filename |
265
+
266
+ ## Development test
267
+
268
+ Install into an isolated temporary home without touching your actual OpenCode configuration:
269
+
270
+ ```bash
271
+ TEST_HOME="$(mktemp -d)"
272
+ HOME="$TEST_HOME" \
273
+ XDG_CONFIG_HOME="$TEST_HOME/.config" \
274
+ XDG_DATA_HOME="$TEST_HOME/.local/share" \
275
+ OPENCODE_OMNI_MEMORY_SOURCE="$PWD" \
276
+ ./install.sh install
277
+ ```
278
+
279
+ Then run `status`, `update`, and `uninstall` with the same environment.
280
+
281
+ The repository also includes an isolated smoke test:
282
+
283
+ ```bash
284
+ ./tests/install-smoke.sh
285
+ ```
package/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.0.0
package/bin/cli.js ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ /**
5
+ * npm entry point for opencode-omni-memory-plugin.
6
+ *
7
+ * Delegates to the bundled install.sh, which already resolves its own script
8
+ * directory as the install source (the SCRIPT_DIR branch in prepare_source),
9
+ * so running from the packaged files installs directly with no git clone.
10
+ *
11
+ * Usage: opencode-omni-memory-plugin [install|update|status|uninstall|help]
12
+ */
13
+
14
+ const { spawnSync } = require("node:child_process");
15
+ const path = require("node:path");
16
+
17
+ const installer = path.join(__dirname, "..", "install.sh");
18
+ const args = process.argv.slice(2);
19
+
20
+ const result = spawnSync("bash", [installer, ...args], {
21
+ stdio: "inherit",
22
+ env: process.env,
23
+ });
24
+
25
+ if (result.error) {
26
+ if (result.error.code === "ENOENT") {
27
+ console.error(
28
+ "[opencode-omni-memory-plugin] ERROR: 'bash' was not found on PATH. " +
29
+ "This installer requires Bash, Git, and Node.js.",
30
+ );
31
+ } else {
32
+ console.error("[opencode-omni-memory-plugin] ERROR:", result.error.message);
33
+ }
34
+ process.exit(1);
35
+ }
36
+
37
+ process.exit(result.status === null ? 1 : result.status);
@@ -0,0 +1,7 @@
1
+ ---
2
+ description: Remove or correct matching global, host, or project Markdown memory safely.
3
+ ---
4
+
5
+ Load the `omni-memory` skill and forget or correct the information described by `$ARGUMENTS`.
6
+
7
+ Search the appropriate active memory and directly relevant archives. Remove only matching information, preserve unrelated entries, reconcile references when necessary, and report the scope and concise result. If the request could erase materially different memories, ask for clarification before editing.
@@ -0,0 +1,9 @@
1
+ ---
2
+ description: Reconcile project state and write a truthful continuation handoff for the next session.
3
+ ---
4
+
5
+ Load the `omni-memory` skill and perform its full handoff procedure.
6
+
7
+ Inspect current branch, commit, working-tree changes, active task state, and session journals. Reconcile memory, decisions, working specification, roadmap, progress, and findings before rewriting `HANDOFF.md`. Include completed work, partial changes, checks run, blockers, risks, and exact next actions. Remove only fully reconciled temporary journals. Do not create a Git commit.
8
+
9
+ Additional context: `$ARGUMENTS`
@@ -0,0 +1,7 @@
1
+ ---
2
+ description: Audit native Markdown memory for scope, duplication, staleness, conflicts, and unsafe content.
3
+ ---
4
+
5
+ Load the `omni-memory` skill and audit the scope requested by `$ARGUMENTS` (`global`, `project`, or `all`; default to the current relevant scopes).
6
+
7
+ Check scope placement, duplication, provenance, last verification, contradictions, sensitive content, active injection size, stale handoff details, unreconciled session journals, and verified findings that should be promoted. Correct unambiguous issues conservatively and list anything requiring user judgment. Do not commit changes.
@@ -0,0 +1,9 @@
1
+ ---
2
+ description: Initialize native Markdown memory and project-state files for the current project.
3
+ ---
4
+
5
+ Load the `omni-memory` skill and initialize the current project according to its lazy-bootstrap rules.
6
+
7
+ Use the Git worktree root, or the OpenCode launch directory outside Git. Preserve existing files and documentation. Create the minimal `INDEX.md`, `MEMORY.md`, and `HANDOFF.md` unless `$ARGUMENTS` requests `full`, in which case also create the charter, working specification, roadmap, progress, findings, and decisions from the skill templates. Add the temporary sessions directory to `.gitignore` without disturbing existing rules.
8
+
9
+ Arguments: `$ARGUMENTS`
@@ -0,0 +1,9 @@
1
+ ---
2
+ description: Report current project objective, milestone, progress, blockers, findings, and next actions.
3
+ ---
4
+
5
+ Load the `omni-memory` skill and produce a concise current project-status report.
6
+
7
+ Orient against current repository state, then read the charter, working specification, roadmap, progress, findings, decisions, handoff, and active session journals that exist. Highlight stale or conflicting state and distinguish verified repository facts from remembered context. Do not modify files unless reconciliation is necessary to correct a proven stale claim.
8
+
9
+ Focus: `$ARGUMENTS`
@@ -0,0 +1,7 @@
1
+ ---
2
+ description: Retrieve relevant global, host, project, handoff, or archived Markdown memory.
3
+ ---
4
+
5
+ Load the `omni-memory` skill and recall information relevant to `$ARGUMENTS`.
6
+
7
+ Search active memory first, then task-relevant project state, host memory, global handoff, session journals, and archives as appropriate. Retrieve only relevant material, identify stale or conflicting claims, and verify source-sensitive facts before consequential use.
@@ -0,0 +1,7 @@
1
+ ---
2
+ description: Save a durable fact to global, host, or project Markdown memory.
3
+ ---
4
+
5
+ Load the `omni-memory` skill and retain the durable fact in `$ARGUMENTS`.
6
+
7
+ Honor an explicit first argument of `global`, `host`, or `project`. Otherwise infer the narrowest safe scope from context and ask only if scope materially changes meaning or privacy. Apply all retention, provenance, consolidation, sensitivity, and active-size rules. Do not store temporary status or unverified assumptions.
@@ -0,0 +1,15 @@
1
+ # Global Memory
2
+
3
+ Durable preferences and facts that apply across projects. Keep this file concise and current.
4
+
5
+ ## Working Preferences
6
+
7
+ ## Tooling and Environment
8
+
9
+ ## Conventions
10
+
11
+ - Use native Markdown for long-term agent memory, with automatic retrieval and conservative scope-aware capture.
12
+ - Keep durable project memory separate from mutable charter, specification, roadmap, progress, findings, decisions, and handoff state under `.opencode/project/`.
13
+ - Protect project charters from autonomous goal changes; allow agent working specifications to evolve within the charter and record material decisions.
14
+
15
+ ## Recurring Lessons
@@ -0,0 +1,18 @@
1
+ # Global Handoff
2
+
3
+ Cross-project and OpenCode-configuration continuation state. Retrieve only when relevant.
4
+
5
+ - Updated:
6
+ - Current focus: none
7
+
8
+ ## Completed
9
+
10
+ ## Current Changes
11
+
12
+ ## Decisions and Findings
13
+
14
+ ## Verification
15
+
16
+ ## Blockers and Risks
17
+
18
+ ## Exact Next Actions
@@ -0,0 +1,11 @@
1
+ # Host Memory: __HOSTNAME__
2
+
3
+ Machine-specific facts for this host. Verify consequential details before use.
4
+
5
+ ## Platform
6
+
7
+ ## Tooling
8
+
9
+ ## Paths and Constraints
10
+
11
+ ## Verified Lessons
@@ -0,0 +1,3 @@
1
+ # Global Memory Archive
2
+
3
+ Store inactive cross-project detail here. Active global memory should remain concise and current; retrieve archived material only when relevant.