opencode-session-search 0.1.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/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/README.md +133 -0
- package/dist/index.js +12668 -0
- package/index.ts +425 -0
- package/package.json +47 -0
- package/scripts/install-local.sh +15 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-02-21
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Initial release of `session-search` and `session-transcript` tools.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Arthur Tyukayev
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# OpenCode Session Search
|
|
2
|
+
|
|
3
|
+
A plugin for OpenCode that provides tools to search and retrieve your local chat history.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
### `session-search`
|
|
8
|
+
|
|
9
|
+
Search your local OpenCode chat history for sessions containing specific text.
|
|
10
|
+
|
|
11
|
+
**Args**
|
|
12
|
+
- `query` (string, required): Text to search for (1-200 chars, non-whitespace)
|
|
13
|
+
- `limitSessions` (number, optional): Max sessions to return (1-12, default: 6)
|
|
14
|
+
|
|
15
|
+
**Returns**
|
|
16
|
+
- Matching sessions with metadata (title, directory, match count)
|
|
17
|
+
- Snippets from each session (2 per session, 220 chars each)
|
|
18
|
+
- Suggested `session-transcript` calls and a `question`-tool prompt to let users pick which session to open
|
|
19
|
+
|
|
20
|
+
### `session-transcript`
|
|
21
|
+
|
|
22
|
+
Reconstruct the full transcript of a specific chat session.
|
|
23
|
+
|
|
24
|
+
**Args**
|
|
25
|
+
- `sessionId` (string, required): Session ID (e.g., `ses_xxx`)
|
|
26
|
+
- `limit` (number, optional): Max entries to return (1-120, default: 80)
|
|
27
|
+
- `order` (string, optional): `asc` or `desc` (default: `asc`)
|
|
28
|
+
|
|
29
|
+
**Returns**
|
|
30
|
+
- Session metadata (title, slug, directory, project info)
|
|
31
|
+
- Full conversation entries with timestamps and roles
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
### npm (Recommended)
|
|
36
|
+
|
|
37
|
+
Add the package to your OpenCode config:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"plugin": ["opencode-session-history"]
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Supported config locations:
|
|
46
|
+
- Global config: `~/.config/opencode/opencode.json`
|
|
47
|
+
- Project config: `.opencode/opencode.json`
|
|
48
|
+
|
|
49
|
+
Restart OpenCode so the plugin is loaded.
|
|
50
|
+
|
|
51
|
+
## Example Usage
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
Find my recent work on authentication:
|
|
55
|
+
⚙ session-search [query=auth login, limitSessions=5]
|
|
56
|
+
|
|
57
|
+
Get the full conversation:
|
|
58
|
+
⚙ session-transcript [sessionId=ses_abc123, limit=100]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Run the same search from your terminal:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
bun run search -- "auth login" --limitSessions 5
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
This command uses the same query path as the `session-search` tool and prints JSON.
|
|
68
|
+
|
|
69
|
+
## Development
|
|
70
|
+
|
|
71
|
+
### Local install
|
|
72
|
+
|
|
73
|
+
Install directly from this repo:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
bun run install:local
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
This copies `index.ts` to:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
~/.config/opencode/plugins/history.ts
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Manual copy option:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
mkdir -p ~/.config/opencode/plugins
|
|
89
|
+
cp index.ts ~/.config/opencode/plugins/history.ts
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Restart OpenCode and the tools will be available automatically.
|
|
93
|
+
|
|
94
|
+
## Versioning
|
|
95
|
+
|
|
96
|
+
This package follows Semantic Versioning (`MAJOR.MINOR.PATCH`).
|
|
97
|
+
|
|
98
|
+
- `PATCH`: backward-compatible fixes
|
|
99
|
+
- `MINOR`: backward-compatible features
|
|
100
|
+
- `MAJOR`: breaking changes
|
|
101
|
+
|
|
102
|
+
Recommended release commands:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
bun pm version patch
|
|
106
|
+
bun pm version minor
|
|
107
|
+
bun pm version major
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Then publish:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
bun publish
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Configuration
|
|
117
|
+
|
|
118
|
+
The plugin resolves the DB path in this order:
|
|
119
|
+
1. `OPENCODE_DB_PATH` env var (if set)
|
|
120
|
+
2. `opencode db path` (platform-aware)
|
|
121
|
+
3. Fallback: `~/.local/share/opencode/opencode.db`
|
|
122
|
+
|
|
123
|
+
## Publish Checklist
|
|
124
|
+
|
|
125
|
+
- Run type checks: `bun run test` (or `bun run typecheck`)
|
|
126
|
+
- Build distributable file: `bun run build`
|
|
127
|
+
- Preview package contents: `bun pm pack --dry-run`
|
|
128
|
+
- Confirm version bump uses SemVer (`bun pm version patch|minor|major`)
|
|
129
|
+
- Publish: `bun publish`
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
MIT
|