Skip to content

Commit 84eb544

Browse files
authored
feat: add self version command (#8)
1 parent d97f6f4 commit 84eb544

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ opencode-memory uninstall # removes shell hook from .zshrc/.bashrc
6565
npm uninstall -g opencode-claude-memory
6666
```
6767

68+
To print the wrapper package version:
69+
70+
```bash
71+
opencode-memory self -v
72+
```
73+
6874
This removes the shell hook, the CLI, and the plugin. Your saved memories in `~/.claude/projects/` are **not** deleted.
6975

7076
## 💡 Why this exists

bin/opencode-memory

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# Subcommands:
99
# opencode-memory install — Install shell hook to ~/.zshrc or ~/.bashrc
1010
# opencode-memory uninstall — Remove shell hook
11+
# opencode-memory self -v — Print the wrapper package version
1112
# opencode-memory [args...] — Run opencode with post-session memory maintenance
1213
#
1314
# How it works:
@@ -39,6 +40,22 @@
3940

4041
set -euo pipefail
4142

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+
4259
# ============================================================================
4360
# Shell Hook Management
4461
# ============================================================================
@@ -138,6 +155,14 @@ case "${1:-}" in
138155
uninstall_hook
139156
exit 0
140157
;;
158+
self)
159+
case "${2:-}" in
160+
-v|--version|version)
161+
print_wrapper_version
162+
exit 0
163+
;;
164+
esac
165+
;;
141166
esac
142167

143168
# ============================================================================

0 commit comments

Comments
 (0)