Skip to content

Commit fd9fb65

Browse files
committed
feat: bootstrap session manager plugin
0 parents  commit fd9fb65

File tree

11 files changed

+1181
-0
lines changed

11 files changed

+1181
-0
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: oven-sh/setup-bun@v2
14+
with:
15+
bun-version: latest
16+
- name: Install dependencies
17+
run: bun install
18+
- name: Typecheck
19+
run: bun run typecheck
20+
- name: Build
21+
run: bun run build
22+
- name: Test
23+
run: bun test

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
dist/
3+
.DS_Store
4+
package-lock.json
5+
yarn.lock
6+
pnpm-lock.yaml

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Jacob
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.

README.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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+
![Session list output example](example.png)
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

bun.lock

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example.png

300 KB
Loading

package.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"name": "opencode-session-manager",
3+
"version": "0.1.0",
4+
"description": "OpenCode plugin with session listing, reading, search, and metadata tools",
5+
"type": "module",
6+
"main": "dist/index.js",
7+
"types": "dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"types": "./dist/index.d.ts",
11+
"import": "./dist/index.js"
12+
}
13+
},
14+
"files": [
15+
"dist",
16+
"README.md",
17+
"LICENSE"
18+
],
19+
"scripts": {
20+
"build": "tsc -p tsconfig.json",
21+
"typecheck": "tsc --noEmit -p tsconfig.json",
22+
"test": "bun test",
23+
"prepublishOnly": "npm run build && npm run test"
24+
},
25+
"keywords": [
26+
"opencode",
27+
"plugin",
28+
"session",
29+
"agent"
30+
],
31+
"author": "Jacob",
32+
"license": "MIT",
33+
"repository": {
34+
"type": "git",
35+
"url": "https://github.com/jacobjmc/opencode-session-manager.git"
36+
},
37+
"bugs": {
38+
"url": "https://github.com/jacobjmc/opencode-session-manager/issues"
39+
},
40+
"homepage": "https://github.com/jacobjmc/opencode-session-manager#readme",
41+
"publishConfig": {
42+
"access": "public",
43+
"provenance": true
44+
},
45+
"opencode": {
46+
"type": "plugin",
47+
"tools": [
48+
"session_list",
49+
"session_read",
50+
"session_search",
51+
"session_info"
52+
]
53+
},
54+
"dependencies": {
55+
"@opencode-ai/plugin": "^1.2.15"
56+
},
57+
"peerDependencies": {
58+
"@opencode-ai/plugin": ">=1.0.0"
59+
},
60+
"devDependencies": {
61+
"@opencode-ai/sdk": "^1.2.15",
62+
"@types/bun": "^1.3.5",
63+
"@types/node": "^22.13.9",
64+
"typescript": "^5.8.2"
65+
}
66+
}

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { SessionManager } from "./session-manager.js";
2+
3+
export { SessionManager };
4+
export default SessionManager;

0 commit comments

Comments
 (0)