@jimmyyen/opencode-context-cache 1.0.0 → 1.0.1
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/README.md +4 -11
- package/index.mjs +4 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,25 +18,18 @@ npm install @jimmyyen/opencode-context-cache
|
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
-
Add to your `opencode.jsonc` plugin array
|
|
21
|
+
Add to your `opencode.jsonc` plugin array:
|
|
22
22
|
|
|
23
23
|
```jsonc
|
|
24
24
|
{
|
|
25
25
|
"$schema": "https://opencode.ai/config.json",
|
|
26
26
|
"plugin": [
|
|
27
27
|
"@jimmyyen/opencode-context-cache"
|
|
28
|
-
]
|
|
29
|
-
"provider": {
|
|
30
|
-
"openai": {
|
|
31
|
-
"options": {
|
|
32
|
-
"setCacheKey": true
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
28
|
+
]
|
|
36
29
|
}
|
|
37
30
|
```
|
|
38
31
|
|
|
39
|
-
The plugin auto-registers on the `chat.params` hook at import time.
|
|
32
|
+
That's it — listed = enabled, removed = disabled. No provider options needed. The plugin auto-registers on the `chat.params` hook at import time.
|
|
40
33
|
|
|
41
34
|
## Cache key precedence
|
|
42
35
|
|
|
@@ -54,7 +47,7 @@ The key is SHA256-hashed before being sent to the server. Already-hashed values
|
|
|
54
47
|
export OPENCODE_CONTEXT_CACHE_DEBUG=1
|
|
55
48
|
```
|
|
56
49
|
|
|
57
|
-
Logs are written to
|
|
50
|
+
Logs are written to `~/.cache/opencode-context-cache.log` with timestamps, PID, and key resolution details.
|
|
58
51
|
|
|
59
52
|
## Exports
|
|
60
53
|
|
package/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Features:
|
|
5
5
|
* - Per-project cache isolation using absolute path with user@host prefix
|
|
6
6
|
* - Support for ALL providers (not just specific ones)
|
|
7
|
-
* - Debug logging to file (
|
|
7
|
+
* - Debug logging to file (~/.cache/opencode-context-cache.log)
|
|
8
8
|
* - Smart cache key generation with multiple fallbacks
|
|
9
9
|
* - Unified session header and cache key management
|
|
10
10
|
* - SHA256 hashed cache key for privacy (server sees only hash)
|
|
@@ -21,21 +21,17 @@
|
|
|
21
21
|
* 5. opencode sessionID (fallback)
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import { hostname, userInfo } from "os";
|
|
24
|
+
import { hostname, homedir, userInfo } from "os";
|
|
25
25
|
import { dirname, join } from "path";
|
|
26
26
|
import { appendFileSync, existsSync, mkdirSync } from "fs";
|
|
27
|
-
import { fileURLToPath } from "url";
|
|
28
|
-
import { createHash } from "crypto";
|
|
29
27
|
|
|
30
28
|
const SESSION_ID_HEADER_NAMES = ["x-session-id", "conversation_id", "session_id"];
|
|
31
29
|
const PROMPT_CACHE_KEY_ENV_VAR = "OPENCODE_PROMPT_CACHE_KEY";
|
|
32
30
|
const STICKY_SESSION_ID_ENV_VAR = "OPENCODE_STICKY_SESSION_ID";
|
|
33
31
|
const CACHE_DEBUG_ENV_VAR = "OPENCODE_CONTEXT_CACHE_DEBUG";
|
|
34
32
|
|
|
35
|
-
//
|
|
36
|
-
const
|
|
37
|
-
const __dirname = dirname(__filename);
|
|
38
|
-
const LOG_FILE_PATH = join(__dirname, "context-cache.log");
|
|
33
|
+
// Debug log lives in ~/.cache so it's easy to find regardless of install location.
|
|
34
|
+
const LOG_FILE_PATH = join(homedir(), ".cache", "opencode-context-cache.log");
|
|
39
35
|
|
|
40
36
|
class DebugLogger {
|
|
41
37
|
constructor(logFilePath) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jimmyyen/opencode-context-cache",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "OpenCode plugin for stable, privacy-preserving prompt cache key and sticky session management. Fork of JackDrogon/opencode-context-cache.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|