Skip to content

Releases

v1.1.0 — audit-driven rewrite

Choose a tag to compare

@EnerJizeIT EnerJizeIT released this 27 Jul 14:20

Major rewrite after a full code audit. Breaking: none — all changes are backwards-compatible additions and bug fixes.

Critical bug fixes

  • backupDir setting now honoured everywhere — previously hardcoded to DEFAULT_BACKUP_DIR; users who configured a custom backup directory silently had backups written to the wrong location.
  • sm_restore force=true is now safe — a safety backup of the existing session is created automatically before deletion. If the subsequent import fails, the user still has a recovery file. Previously the original was deleted first and could be lost irreversibly.
  • sm_full_backup now finds the plugin on npm-installs — searches local-dev + three npm-cache layouts. Previously it only looked at ~/.config/opencode/plugins/session-manager.ts, which does not exist for end users who installed via the plugin[] array.
  • Removed truncateId() — the helper was hiding full session IDs from the agent (ses_060358f5...), making subsequent tool calls fail with "Session not found".

P0 — current session support

  • New hook tool.execute.before captures currentSessionId in-memory on every tool call.
  • sm_pin / sm_unpin / sm_backup: sessionId is now optional — defaults to the current session. "Pin this session" finally works in one call.
  • New tool sm_current_session for introspection.
  • sm_pin now updates the note on an already-pinned session instead of returning "Already pinned".

P1 — quality of life

  • findSessionByQuery — git-like prefix matching (≥4 chars). Distinguishes found / not_found / ambiguous / error (the previous findSessionById swallowed all errors as null).
  • sm_list — scope: pinned | recent | all (default pinned).
  • New tool sm_list_backups — enumerate backup files with metadata (filename, session, title, date, corrupt flag).
  • sm_cleanup / sm_cleanup_backups — dry_run=true by default. Destructive operations now require explicit dry_run=false.
  • sm_search — search_in: title | title+note, capped at 50 results to avoid OOM on large session DBs.

Refactor — modular structure

session-manager.ts shrank from 1293 to 646 lines (-50%). Logic moved into focused modules:

Module Responsibility
src/state.ts paths + loadStateDefault / saveStateDefault / getBackupDir / logHookEvent
src/types.ts shared interfaces
src/format.ts pure helpers (formatDate, findPluginSourcePath)
src/cli.ts opencode CLI wrappers + findSessionByQuery + searchSessions
src/backup.ts backup / cleanup / retention / restore / full-backup

Quality

  • tsconfig.json: strict: true + noUncheckedIndexedAccess: true.
  • package.json: new typecheck script; prepublishOnly now runs typecheck && test && build.
  • GitHub Actions CI: typecheck + test + build on every push/PR.
  • Tests: afterAll cleanup for .tmp-test-* artifacts (was leaving 5+ dirs in the working tree).
  • install.sh: rm -rf dist/ before cp -r — fixes a bug where repeated installs created a nested dist/dist/ and left opencode loading a stale plugin.js.
  • Diagnostic log: hook invocations are logged to ~/.local/share/opencode/session-manager-hooks.log to verify whether opencode actually fires session.idle / session.deleted.

Stats

13 files changed, +1201 / −566 lines. 22 tests pass, typecheck clean.

Full Changelog: v1.0.7...v1.1.0

v1.0.7 — OpenCode Session Manager

Choose a tag to compare

@EnerJizeIT EnerJizeIT released this 26 Jul 02:34

Pin, back up & restore your opencode AI sessions

Never lose a valuable AI conversation again. This plugin adds 12 tools + 2 hooks to opencode for session management — all through natural language.

Features

  • 📌 Pin/unpin — protect important sessions from cleanup
  • 💾 Backup — individual or all pinned sessions (JSON, survives reinstalls)
  • ♻️ Restore — bring a session back from backup
  • 🧹 Auto-cleanup — old sessions backed up then deleted (pinned always safe)
  • 🔍 Search — find sessions by title
  • ⚙️ Configurable — cleanup/retention settings, set and forget

Install

// ~/.config/opencode/opencode.json
{ "plugin": ["@enerjizeit/opencode-session-manager"] }

Links