shmem-opencode 0.3.30 → 0.3.32
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/index.ts +21 -6
- package/package.json +2 -2
package/index.ts
CHANGED
|
@@ -10,16 +10,31 @@ const ID = "shmem-opencode"
|
|
|
10
10
|
const RESUBSCRIBE_MS = 1_000
|
|
11
11
|
|
|
12
12
|
// shmemRoot is the data root `shmem install` wrote into shmem's MCP entry
|
|
13
|
-
// when it was a custom one
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
13
|
+
// when it was a custom one: `--root DIR` in its command, or, from older
|
|
14
|
+
// installs, SHMEM_ROOT in its environment. OpenCode runs this plugin with
|
|
15
|
+
// its own environment, which lacks a SHMEM_ROOT set only for install, so
|
|
16
|
+
// the hooks take the root from the config instead. It is passed as an
|
|
17
|
+
// environment variable rather than `--root`, which older shmem binaries
|
|
18
|
+
// reject.
|
|
17
19
|
let shmemRoot: string | undefined
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
type MCPEntry = { type?: string; command?: string[]; environment?: Record<string, string> }
|
|
22
|
+
|
|
23
|
+
function rootFrom(entry: MCPEntry | undefined) {
|
|
20
24
|
if (entry?.type === "local") {
|
|
21
|
-
shmemRoot = entry.environment?.SHMEM_ROOT || undefined
|
|
25
|
+
shmemRoot = rootArg(entry.command ?? []) || entry.environment?.SHMEM_ROOT || undefined
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// rootArg is the value of --root (or --root=) in an MCP command line.
|
|
30
|
+
function rootArg(command: string[]): string | undefined {
|
|
31
|
+
for (let i = 1; i < command.length; i++) {
|
|
32
|
+
const a = command[i]
|
|
33
|
+
if (a === "--") return undefined
|
|
34
|
+
if (a.startsWith("--root=")) return a.slice("--root=".length)
|
|
35
|
+
if (a === "--root" && i + 1 < command.length) return command[i + 1]
|
|
22
36
|
}
|
|
37
|
+
return undefined
|
|
23
38
|
}
|
|
24
39
|
|
|
25
40
|
function shmemHook(subcommand: string, payload: Record<string, string>): void {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shmem-opencode",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.32",
|
|
4
4
|
"description": "shmem memory hooks for OpenCode",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@opencode-ai/plugin": "^1.17.13",
|
|
14
14
|
"@opencode/plugin": "^2.2.7",
|
|
15
15
|
"@types/node": "^26.1.0",
|
|
16
|
-
"typescript": "^
|
|
16
|
+
"typescript": "^7.0.2"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
19
|
"shmem",
|