opencode-deja 0.1.0 → 0.1.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.
Files changed (3) hide show
  1. package/index.js +11 -2
  2. package/lib.js +12 -0
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -11,9 +11,9 @@ import { execFile } from "node:child_process"
11
11
  import { promisify } from "node:util"
12
12
  import { homedir } from "node:os"
13
13
  import { join } from "node:path"
14
- import { accessSync, constants } from "node:fs"
14
+ import { accessSync, constants, existsSync } from "node:fs"
15
15
 
16
- import { clampLimit, contextText, lastUserText } from "./lib.js"
16
+ import { clampLimit, cliPluginPath, contextText, lastUserText } from "./lib.js"
17
17
 
18
18
  const require = createRequire(import.meta.url)
19
19
  const run_ = promisify(execFile)
@@ -189,6 +189,15 @@ export const DejaPlugin = async ({ client, directory }, options = {}) => {
189
189
 
190
190
  if (config.autoRecall === false) return hooks
191
191
 
192
+ // `deja install opencode-auto` writes a plugin of its own, and opencode loads
193
+ // it alongside this package: two entries in the resolved plugin list, both
194
+ // pushing the same recall onto the system prompt and both raising the same
195
+ // toast. The file on disk wins because the installer keeps it current; this
196
+ // package keeps its tools and drops only the duplicated recall.
197
+ try {
198
+ if (existsSync(cliPluginPath(process.env, homedir()))) return hooks
199
+ } catch {}
200
+
192
201
  // opencode has no session-start hook. The system prompt is assembled on
193
202
  // every request, so the session digest is fetched once and pushed there —
194
203
  // the same place Claude Code's SessionStart output lands.
package/lib.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { join } from "node:path"
2
+
1
3
  // The pure half of the plugin: everything that reads deja's output or
2
4
  // opencode's message shape, with no process and no host. Kept apart from
3
5
  // index.js because opencode loads every function a plugin module exports —
@@ -34,6 +36,16 @@ export function lastUserText(messages) {
34
36
  return { parts: [], prompt: "" }
35
37
  }
36
38
 
39
+ // cliPluginPath is where `deja install opencode-auto` writes its own plugin.
40
+ // opencode loads that file and this package side by side — both are entries in
41
+ // the resolved `plugin` list — and both push recall onto the system prompt, so
42
+ // whoever finds the other has to stand down. Mirrors opencodeConfigHome() in
43
+ // the installer: XDG_CONFIG_HOME wins, else ~/.config.
44
+ export function cliPluginPath(env, home) {
45
+ const base = (env && env.XDG_CONFIG_HOME) || join(home || "", ".config")
46
+ return join(base, "opencode", "plugins", "deja.js")
47
+ }
48
+
37
49
  // clampLimit keeps a model that asks for a hundred sessions from spending the
38
50
  // window on a tail nobody reads.
39
51
  export function clampLimit(value, fallback = 5) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-deja",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Brings the session history of nineteen other coding agents into opencode: recall, session digest and per-file history tools over a local index, plus automatic recall on every request.",
5
5
  "type": "module",
6
6
  "main": "index.js",