|
| 1 | +# opencode-session-manager |
| 2 | + |
| 3 | +OpenCode plugin that turns your past sessions into something you can actually reuse. |
| 4 | + |
| 5 | +It adds four tools: |
| 6 | + |
| 7 | +- `session_list` |
| 8 | +- `session_read` |
| 9 | +- `session_search` |
| 10 | +- `session_info` |
| 11 | + |
| 12 | +## Why this is useful |
| 13 | + |
| 14 | +This plugin is most helpful when your current session is full and you need to keep moving. |
| 15 | + |
| 16 | +Example workflow: |
| 17 | + |
| 18 | +1. Start a new session. |
| 19 | +2. Ask OpenCode: "Review our last session and continue from where we left off." |
| 20 | +3. It can find and read the previous session, then pick up the work. |
| 21 | + |
| 22 | +It is also useful when: |
| 23 | + |
| 24 | +- you remember discussing something but forgot the details |
| 25 | +- you want OpenCode to recall a decision from a past session |
| 26 | +- you need to find where a bug, fix, or plan was originally discussed |
| 27 | + |
| 28 | +In practice, it feels like a lightweight memory system built on your own local session history. |
| 29 | + |
| 30 | +## What the tools do |
| 31 | + |
| 32 | +- `session_list`: list recent sessions with title, timestamp, message count, and agents used |
| 33 | +- `session_read`: read messages from a specific session in order |
| 34 | +- `session_search`: search text across sessions (or within one session) |
| 35 | +- `session_info`: show summary metadata for a session |
| 36 | + |
| 37 | +Useful options: |
| 38 | + |
| 39 | +- `all_scopes: true` searches across all workspaces |
| 40 | +- `from_date` / `to_date` support date-only input (`YYYY-MM-DD`) and treat full days as inclusive |
| 41 | + |
| 42 | +## Install |
| 43 | + |
| 44 | +### From npm (recommended) |
| 45 | + |
| 46 | +Add this to `~/.config/opencode/opencode.jsonc` (or project `opencode.json`): |
| 47 | + |
| 48 | +```jsonc |
| 49 | +{ |
| 50 | + "plugin": ["opencode-session-manager"], |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +### From source (local development) |
| 55 | + |
| 56 | +```bash |
| 57 | +bun install |
| 58 | +bun run build |
| 59 | +``` |
| 60 | + |
| 61 | +Then point OpenCode at your local build: |
| 62 | + |
| 63 | +```jsonc |
| 64 | +{ |
| 65 | + "plugin": ["/absolute/path/to/opencode-session-manager/dist/index.js"], |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +## Example prompts |
| 70 | + |
| 71 | +- "What did we work on last session?" |
| 72 | +- "Review our last session and continue from where we left off." |
| 73 | +- "Search past sessions for where we discussed OAuth token refresh." |
| 74 | +- "What did we decide last week about the session manager date filter?" |
| 75 | +- "List sessions across all scopes from 2026-03-01 to 2026-03-03." |
| 76 | + |
| 77 | +### Example outputs |
| 78 | + |
| 79 | +Prompt: `What did we work on last session?` |
| 80 | + |
| 81 | +```text |
| 82 | +Last session summary: |
| 83 | +- Added date-range support (`from_date` / `to_date`) to `session_list` |
| 84 | +- Fixed inclusive end-of-day handling for date-only inputs |
| 85 | +- Added tests for cross-scope filtering |
| 86 | +``` |
| 87 | + |
| 88 | +Prompt: `Review our last session and continue from where we left off.` |
| 89 | + |
| 90 | +```text |
| 91 | +I reviewed session `ses_demo_01`. We completed the parser update and left off before wiring docs. |
| 92 | +
|
| 93 | +Next step I will take now: |
| 94 | +1. Update README examples for `all_scopes` and date filters |
| 95 | +2. Add one integration test for mixed date formats |
| 96 | +``` |
| 97 | + |
| 98 | +Prompt: `Search past sessions for where we discussed OAuth token refresh.` |
| 99 | + |
| 100 | +```text |
| 101 | +Found 3 relevant matches: |
| 102 | +- ses_demo_14 (2026-02-18): "rotate refresh token on each use" |
| 103 | +- ses_demo_19 (2026-02-22): "handle 401 with single-flight refresh" |
| 104 | +- ses_demo_27 (2026-02-28): "store token expiry as epoch ms" |
| 105 | +``` |
| 106 | + |
| 107 | +Prompt: `What did we decide last week about the session manager date filter?` |
| 108 | + |
| 109 | +```text |
| 110 | +Decision recap (last week): |
| 111 | +- Date-only values (`YYYY-MM-DD`) are interpreted in local time |
| 112 | +- `to_date` is inclusive through 23:59:59.999 |
| 113 | +- Invalid dates return a clear validation error |
| 114 | +``` |
| 115 | + |
| 116 | +Prompt: `List sessions across all scopes from 2026-03-01 to 2026-03-03.` |
| 117 | + |
| 118 | +```text |
| 119 | +Sessions found across all scopes (2026-03-01 to 2026-03-03): |
| 120 | +
|
| 121 | +| Session ID | Title | Messages | Last | |
| 122 | +|---------------|-------------------------------|----------|---------------------| |
| 123 | +| ses_demo_31 | Session search perf pass | 24 | 2026-03-03 18:42:10 | |
| 124 | +| ses_demo_30 | README examples cleanup | 11 | 2026-03-03 09:14:02 | |
| 125 | +| ses_demo_28 | Date filter bug investigation | 37 | 2026-03-02 21:03:44 | |
| 126 | +| ses_demo_25 | Initial plugin scaffolding | 19 | 2026-03-01 16:27:51 | |
| 127 | +``` |
| 128 | + |
| 129 | +### Example |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | +## Development |
| 134 | + |
| 135 | +```bash |
| 136 | +bun run typecheck |
| 137 | +bun run build |
| 138 | +bun test |
| 139 | +``` |
| 140 | + |
| 141 | +## Compatibility |
| 142 | + |
| 143 | +- OpenCode plugin API: `@opencode-ai/plugin >= 1.0.0` |
| 144 | +- Verified with `@opencode-ai/plugin 1.2.x` |
| 145 | + |
| 146 | +## License |
| 147 | + |
| 148 | +MIT |
0 commit comments