opencode-codex-memory 0.9.4 → 0.9.5
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 +2 -2
- package/dist/src/v2/agents.d.ts +8 -2
- package/dist/src/v2/agents.js +36 -8
- package/dist/src/v2/shim.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ to your existing global `~/.config/opencode/opencode.jsonc` or `opencode.json`
|
|
|
35
35
|
{
|
|
36
36
|
"$schema": "https://opencode.ai/config.json",
|
|
37
37
|
"plugins": [
|
|
38
|
-
{ "package": "opencode-codex-memory@0.9.
|
|
38
|
+
{ "package": "opencode-codex-memory@0.9.5" }
|
|
39
39
|
]
|
|
40
40
|
}
|
|
41
41
|
```
|
|
@@ -45,7 +45,7 @@ to your existing global `~/.config/opencode/opencode.jsonc` or `opencode.json`
|
|
|
45
45
|
```json
|
|
46
46
|
{
|
|
47
47
|
"$schema": "https://opencode.ai/config.json",
|
|
48
|
-
"plugin": ["opencode-codex-memory@0.9.
|
|
48
|
+
"plugin": ["opencode-codex-memory@0.9.5"]
|
|
49
49
|
}
|
|
50
50
|
```
|
|
51
51
|
|
package/dist/src/v2/agents.d.ts
CHANGED
|
@@ -17,8 +17,14 @@ export interface V2AgentDefinition {
|
|
|
17
17
|
}
|
|
18
18
|
/** V2-native memorize definition (V2 action names: edit covers write/patch). */
|
|
19
19
|
export declare function buildMemorizeAgent(): V2AgentDefinition;
|
|
20
|
-
/**
|
|
21
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Session rules run after agent rules: a concurrent helper gets one root only.
|
|
22
|
+
* `sessionDir` is the helper location. OpenCode 2 asserts a session-relative
|
|
23
|
+
* resource when the target is inside the session or project directory, so
|
|
24
|
+
* absolute grants alone miss and the leading wildcard deny blocks the global
|
|
25
|
+
* store. Pass the same directory the session is created in.
|
|
26
|
+
*/
|
|
27
|
+
export declare function consolidationPermissions(root: string, sessionDir?: string): V2AgentDefinition["permissions"];
|
|
22
28
|
/**
|
|
23
29
|
* Hidden extraction definition. Unused at runtime (extraction goes through
|
|
24
30
|
* generate.text), kept for parity with the V1 bundle and the health
|
package/dist/src/v2/agents.js
CHANGED
|
@@ -32,23 +32,31 @@ export function buildMemorizeAgent() {
|
|
|
32
32
|
system: MEMORIZE_SYSTEM,
|
|
33
33
|
permissions: [
|
|
34
34
|
{ action: "*", resource: "*", effect: "deny" },
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
35
|
+
// Absolute grants cover a memory root outside the session (same role as
|
|
36
|
+
// external_directory in the V1 definition). The helper session adds the
|
|
37
|
+
// session-relative form; see consolidationPermissions.
|
|
38
38
|
...writeMemoryVersions().flatMap((version) => workspacePermissions(memoryRoot(version))),
|
|
39
39
|
],
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
/**
|
|
43
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Session rules run after agent rules: a concurrent helper gets one root only.
|
|
44
|
+
* `sessionDir` is the helper location. OpenCode 2 asserts a session-relative
|
|
45
|
+
* resource when the target is inside the session or project directory, so
|
|
46
|
+
* absolute grants alone miss and the leading wildcard deny blocks the global
|
|
47
|
+
* store. Pass the same directory the session is created in.
|
|
48
|
+
*/
|
|
49
|
+
export function consolidationPermissions(root, sessionDir) {
|
|
44
50
|
return [
|
|
45
51
|
{ action: "*", resource: "*", effect: "deny" },
|
|
46
|
-
...workspacePermissions(root),
|
|
52
|
+
...workspacePermissions(root, sessionDir),
|
|
47
53
|
];
|
|
48
54
|
}
|
|
49
|
-
function workspacePermissions(root) {
|
|
55
|
+
function workspacePermissions(root, sessionDir) {
|
|
56
|
+
const absolute = [root, path.join(root, "*")];
|
|
50
57
|
return [
|
|
51
|
-
...
|
|
58
|
+
...sessionRelativePermissions(root, sessionDir),
|
|
59
|
+
...["read", "edit", "external_directory"].flatMap((action) => absolute.map((resource) => ({
|
|
52
60
|
action, resource, effect: "allow",
|
|
53
61
|
}))),
|
|
54
62
|
// These actions check the search pattern, not a path. search-sandbox.ts
|
|
@@ -56,6 +64,26 @@ function workspacePermissions(root) {
|
|
|
56
64
|
...["glob", "grep"].map((action) => ({ action, resource: "*", effect: "allow" })),
|
|
57
65
|
];
|
|
58
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* FileAccess resolves and normalizes paths before permission evaluation.
|
|
69
|
+
* When the session is within the memory root, allow relative paths but deny
|
|
70
|
+
* absolute paths and traversal above that root. Absolute workspace grants run
|
|
71
|
+
* afterwards. external_directory always uses absolute resources.
|
|
72
|
+
*/
|
|
73
|
+
function sessionRelativePermissions(root, sessionDir) {
|
|
74
|
+
if (!sessionDir)
|
|
75
|
+
return [];
|
|
76
|
+
const rel = path.relative(sessionDir, root);
|
|
77
|
+
if (path.isAbsolute(rel))
|
|
78
|
+
return []; // Different Windows drives.
|
|
79
|
+
const posix = rel.split(path.sep).join("/");
|
|
80
|
+
const inside = !posix || posix.split("/").every((seg) => seg === "..");
|
|
81
|
+
const escape = posix ? `${posix}/..` : "..";
|
|
82
|
+
return ["read", "edit"].flatMap((action) => inside ? [
|
|
83
|
+
{ action, resource: "*", effect: "allow" },
|
|
84
|
+
...["/*", "?:/*", escape, `${escape}/*`].map((resource) => ({ action, resource, effect: "deny" })),
|
|
85
|
+
] : [posix, `${posix}/*`].map((resource) => ({ action, resource, effect: "allow" })));
|
|
86
|
+
}
|
|
59
87
|
/**
|
|
60
88
|
* Hidden extraction definition. Unused at runtime (extraction goes through
|
|
61
89
|
* generate.text), kept for parity with the V1 bundle and the health
|
package/dist/src/v2/shim.js
CHANGED
|
@@ -528,13 +528,14 @@ export function buildV1ClientShim() {
|
|
|
528
528
|
releasedSubSessions.delete(EXTRACT_STUB_SESSION_ID);
|
|
529
529
|
return { data: { id: EXTRACT_STUB_SESSION_ID } };
|
|
530
530
|
}
|
|
531
|
+
const directory = opts?.query?.directory ?? memoryRoot();
|
|
531
532
|
const res = await ctx().session.create({
|
|
532
533
|
...(opts?.body?.title ? { title: opts.body.title } : {}),
|
|
533
534
|
...(opts?.body?.metadata ? { metadata: opts.body.metadata } : {}),
|
|
534
535
|
...(opts?.body?.title === "codex-memory-consolidate"
|
|
535
|
-
? { permissions: consolidationPermissions(memoryRoot()) }
|
|
536
|
+
? { permissions: consolidationPermissions(memoryRoot(), directory) }
|
|
536
537
|
: {}),
|
|
537
|
-
location: { directory
|
|
538
|
+
location: { directory },
|
|
538
539
|
});
|
|
539
540
|
return { data: { id: und(res)?.id } };
|
|
540
541
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-codex-memory",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "Persistent memory plugin for opencode — ports codex's two-phase memory system (extraction → consolidation → injection → citation feedback)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/src/index.js",
|