opencode-context-persistence 0.1.8 → 0.1.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-context-persistence",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "OpenCode plugin that re-injects AGENTS.md context after compaction to prevent context loss.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/index.ts CHANGED
@@ -4,8 +4,10 @@ import { join } from "node:path"
4
4
 
5
5
  const plugin: Plugin = {
6
6
  id: "context-persistence",
7
- setup: async (ctx: { directory: string; worktree?: string }) => {
8
- const agentsPath = join(ctx.worktree || ctx.directory, "AGENTS.md")
7
+ setup: async (ctx: any) => {
8
+ const directory = ctx?.location?.directory || ctx?.directory || process.cwd()
9
+ const worktree = ctx?.location?.worktree || ctx?.worktree || directory
10
+ const agentsPath = join(worktree, "AGENTS.md")
9
11
 
10
12
  const readAgents = (): string => {
11
13
  try {
@@ -7,4 +7,11 @@ describe("ContextPersistence plugin v2", () => {
7
7
  expect(mod.default.id).toBe("context-persistence")
8
8
  expect(typeof mod.default.setup).toBe("function")
9
9
  })
10
- })
10
+
11
+ test("setup returns compaction hook", async () => {
12
+ const mod = await import("../src/index.ts")
13
+ const result = await mod.default.setup({ location: { directory: "/tmp", worktree: "/tmp" } })
14
+ expect(result).toHaveProperty("experimental.session.compacting")
15
+ expect(typeof result["experimental.session.compacting"]).toBe("function")
16
+ })
17
+ })