opencode-claude-memory 1.3.1 → 1.5.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/README.md +10 -0
- package/bin/opencode-memory +46 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,6 +65,12 @@ opencode-memory uninstall # removes shell hook from .zshrc/.bashrc
|
|
|
65
65
|
npm uninstall -g opencode-claude-memory
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
To print the wrapper package version:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
opencode-memory self -v
|
|
72
|
+
```
|
|
73
|
+
|
|
68
74
|
This removes the shell hook, the CLI, and the plugin. Your saved memories in `~/.claude/projects/` are **not** deleted.
|
|
69
75
|
|
|
70
76
|
## 💡 Why this exists
|
|
@@ -110,6 +116,7 @@ The shell hook defines an `opencode()` function that delegates to `opencode-memo
|
|
|
110
116
|
6. It evaluates the auto-dream gate (default: at least 24h since last consolidation and 5 touched sessions)
|
|
111
117
|
7. If the gate passes, it runs a background consolidation pass to merge/prune memories
|
|
112
118
|
8. Maintenance runs **in the background** unless `OPENCODE_MEMORY_FOREGROUND=1`
|
|
119
|
+
9. Terminal maintenance logs are shown in foreground mode by default, or can be forced on/off with `OPENCODE_MEMORY_TERMINAL_LOG=1|0`
|
|
113
120
|
|
|
114
121
|
### Compatibility details
|
|
115
122
|
|
|
@@ -156,6 +163,7 @@ Yes. Set `OPENCODE_MEMORY_AUTODREAM=0`. You can also tune gates with:
|
|
|
156
163
|
|
|
157
164
|
- `OPENCODE_MEMORY_EXTRACT` (default `1`): set `0` to disable automatic memory extraction
|
|
158
165
|
- `OPENCODE_MEMORY_FOREGROUND` (default `0`): set `1` to run maintenance in foreground
|
|
166
|
+
- `OPENCODE_MEMORY_TERMINAL_LOG` (default `foreground-only`): set `1` to force terminal logs on, `0` to force them off
|
|
159
167
|
- `OPENCODE_MEMORY_MODEL`: override model used for extraction
|
|
160
168
|
- `OPENCODE_MEMORY_AGENT`: override agent used for extraction
|
|
161
169
|
- `OPENCODE_MEMORY_AUTODREAM` (default `1`): set `0` to disable auto-dream consolidation
|
|
@@ -170,6 +178,8 @@ Logs are written to `$TMPDIR/opencode-memory-logs/`:
|
|
|
170
178
|
- `extract-*.log`: automatic memory extraction
|
|
171
179
|
- `dream-*.log`: auto-dream consolidation
|
|
172
180
|
|
|
181
|
+
By default, terminal log lines are only printed when maintenance runs in foreground (`OPENCODE_MEMORY_FOREGROUND=1`). Background runs stay quiet unless you explicitly set `OPENCODE_MEMORY_TERMINAL_LOG=1`.
|
|
182
|
+
|
|
173
183
|
### Concurrency safety
|
|
174
184
|
|
|
175
185
|
Lock files prevent concurrent extraction/consolidation runs per project root. Stale locks are cleaned up automatically.
|
package/bin/opencode-memory
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
# Subcommands:
|
|
9
9
|
# opencode-memory install — Install shell hook to ~/.zshrc or ~/.bashrc
|
|
10
10
|
# opencode-memory uninstall — Remove shell hook
|
|
11
|
+
# opencode-memory self -v — Print the wrapper package version
|
|
11
12
|
# opencode-memory [args...] — Run opencode with post-session memory maintenance
|
|
12
13
|
#
|
|
13
14
|
# How it works:
|
|
@@ -26,6 +27,7 @@
|
|
|
26
27
|
# Environment variables:
|
|
27
28
|
# OPENCODE_MEMORY_EXTRACT=0 — Disable post-session extraction
|
|
28
29
|
# OPENCODE_MEMORY_FOREGROUND=1 — Run maintenance in foreground (debug)
|
|
30
|
+
# OPENCODE_MEMORY_TERMINAL_LOG=1|0 — Force-enable/disable terminal logs (default: foreground only)
|
|
29
31
|
# OPENCODE_MEMORY_MODEL=... — Extraction model override
|
|
30
32
|
# OPENCODE_MEMORY_AGENT=... — Extraction agent override
|
|
31
33
|
# OPENCODE_MEMORY_AUTODREAM=0 — Disable auto-dream consolidation
|
|
@@ -38,6 +40,22 @@
|
|
|
38
40
|
|
|
39
41
|
set -euo pipefail
|
|
40
42
|
|
|
43
|
+
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
44
|
+
PACKAGE_JSON="$SCRIPT_DIR/../package.json"
|
|
45
|
+
|
|
46
|
+
print_wrapper_version() {
|
|
47
|
+
local version
|
|
48
|
+
|
|
49
|
+
version=$(awk -F'"' '/^[[:space:]]*"version"[[:space:]]*:/ { print $4; exit }' "$PACKAGE_JSON")
|
|
50
|
+
|
|
51
|
+
if [ -z "$version" ]; then
|
|
52
|
+
echo "[opencode-memory] ERROR: Cannot read package version from $PACKAGE_JSON" >&2
|
|
53
|
+
exit 1
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
printf '%s\n' "$version"
|
|
57
|
+
}
|
|
58
|
+
|
|
41
59
|
# ============================================================================
|
|
42
60
|
# Shell Hook Management
|
|
43
61
|
# ============================================================================
|
|
@@ -137,6 +155,14 @@ case "${1:-}" in
|
|
|
137
155
|
uninstall_hook
|
|
138
156
|
exit 0
|
|
139
157
|
;;
|
|
158
|
+
self)
|
|
159
|
+
case "${2:-}" in
|
|
160
|
+
-v|--version|version)
|
|
161
|
+
print_wrapper_version
|
|
162
|
+
exit 0
|
|
163
|
+
;;
|
|
164
|
+
esac
|
|
165
|
+
;;
|
|
140
166
|
esac
|
|
141
167
|
|
|
142
168
|
# ============================================================================
|
|
@@ -164,6 +190,7 @@ REAL_OPENCODE="$(find_real_opencode)"
|
|
|
164
190
|
|
|
165
191
|
EXTRACT_ENABLED="${OPENCODE_MEMORY_EXTRACT:-1}"
|
|
166
192
|
FOREGROUND="${OPENCODE_MEMORY_FOREGROUND:-0}"
|
|
193
|
+
LOG_ENABLED="${OPENCODE_MEMORY_TERMINAL_LOG:-}"
|
|
167
194
|
EXTRACT_MODEL="${OPENCODE_MEMORY_MODEL:-}"
|
|
168
195
|
EXTRACT_AGENT="${OPENCODE_MEMORY_AGENT:-}"
|
|
169
196
|
|
|
@@ -295,7 +322,17 @@ EOF
|
|
|
295
322
|
# Helper Functions
|
|
296
323
|
# ============================================================================
|
|
297
324
|
|
|
325
|
+
should_log() {
|
|
326
|
+
if [ -n "$LOG_ENABLED" ]; then
|
|
327
|
+
[ "$LOG_ENABLED" = "1" ]
|
|
328
|
+
return $?
|
|
329
|
+
fi
|
|
330
|
+
|
|
331
|
+
[ "$FOREGROUND" = "1" ]
|
|
332
|
+
}
|
|
333
|
+
|
|
298
334
|
log() {
|
|
335
|
+
should_log || return 0
|
|
299
336
|
echo "[opencode-memory] $*" >&2
|
|
300
337
|
}
|
|
301
338
|
|
|
@@ -303,6 +340,15 @@ is_positive_int() {
|
|
|
303
340
|
[[ "$1" =~ ^[0-9]+$ ]] && [ "$1" -gt 0 ]
|
|
304
341
|
}
|
|
305
342
|
|
|
343
|
+
is_bool_flag() {
|
|
344
|
+
[ "$1" = "0" ] || [ "$1" = "1" ]
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if [ -n "$LOG_ENABLED" ] && ! is_bool_flag "$LOG_ENABLED"; then
|
|
348
|
+
echo "[opencode-memory] Invalid OPENCODE_MEMORY_TERMINAL_LOG=$LOG_ENABLED, expected 0 or 1; defaulting to foreground-only logging" >&2
|
|
349
|
+
LOG_ENABLED=""
|
|
350
|
+
fi
|
|
351
|
+
|
|
306
352
|
if ! is_positive_int "$AUTODREAM_MIN_HOURS"; then
|
|
307
353
|
log "Invalid OPENCODE_MEMORY_AUTODREAM_MIN_HOURS=$AUTODREAM_MIN_HOURS, using default 24"
|
|
308
354
|
AUTODREAM_MIN_HOURS=24
|
package/package.json
CHANGED