@witness-ai/opencode 0.6.1-beta.0 → 0.6.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 (2) hide show
  1. package/package.json +3 -3
  2. package/witness.js +10 -30
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witness-ai/opencode",
3
3
  "mcpName": "io.github.IngTian/witness",
4
- "version": "0.6.1-beta.0",
4
+ "version": "0.6.1",
5
5
  "description": "MCP memory / second brain for Claude Code & OpenCode — captures your coding sessions and distills how your knowledge and habits evolve over time, queryable by your agent.",
6
6
  "type": "module",
7
7
  "main": "./witness.js",
@@ -21,8 +21,8 @@
21
21
  "README.md"
22
22
  ],
23
23
  "optionalDependencies": {
24
- "@witness-ai/opencode-darwin-arm64": "0.6.1-beta.0",
25
- "@witness-ai/opencode-linux-x64": "0.6.1-beta.0"
24
+ "@witness-ai/opencode-darwin-arm64": "0.6.1",
25
+ "@witness-ai/opencode-linux-x64": "0.6.1"
26
26
  },
27
27
  "keywords": [
28
28
  "mcp",
package/witness.js CHANGED
@@ -8,7 +8,6 @@ const DOWNLOAD_RETRY_MAX = 6
8
8
  const DOWNLOAD_RETRY_BASE_MS = 1000
9
9
  const DOWNLOAD_RETRY_CAP_MS = 30000
10
10
  const IMPORT_GRACE_MS = 5000
11
- const QUIET_PERIOD_MS = 5 * 60 * 1000
12
11
 
13
12
  const platformBin = platformWitnessBin()
14
13
  const WITNESS_BIN = globalThis.WITNESS_SHIM || process.env.WITNESS_BIN || (existsSync(platformBin) ? platformBin : "")
@@ -79,14 +78,13 @@ const plugin = async () => {
79
78
  let disposing = false
80
79
  let disposePromise = null
81
80
  let retryTimer = null
82
- let quietTimer = null
83
81
  let download = null
84
82
  let activeImport = null
85
83
  let activeWaiters = null
86
84
  let globalImportPending = false
87
85
  const pendingSessions = new Set()
88
86
  const sessionWaiters = new Map()
89
- const idleCycles = new Map()
87
+ const modernIdleWaiters = new Map()
90
88
  const idleWaiters = []
91
89
 
92
90
  function clearRetry() {
@@ -94,21 +92,6 @@ const plugin = async () => {
94
92
  retryTimer = null
95
93
  }
96
94
 
97
- function clearQuietTimer() {
98
- if (quietTimer) clearTimeout(quietTimer)
99
- quietTimer = null
100
- }
101
-
102
- function scheduleQuietWorker() {
103
- clearQuietTimer()
104
- quietTimer = setTimeout(() => {
105
- quietTimer = null
106
- if (disposed || disposing) return
107
- spawnWitness(["worker-run", "--auto"])
108
- }, QUIET_PERIOD_MS)
109
- quietTimer.unref?.()
110
- }
111
-
112
95
  function scheduleRetry(attempt) {
113
96
  if (disposed || disposing || process.env.WITNESS_SKIP_MODEL_DOWNLOAD === "1" || modelReady(PACKAGE_ROOT) || attempt > DOWNLOAD_RETRY_MAX) return
114
97
  clearRetry()
@@ -140,7 +123,7 @@ const plugin = async () => {
140
123
  }
141
124
 
142
125
  function syncOpenCode(sessions = []) {
143
- const args = ["import", "--agent", "opencode", "--quiet"]
126
+ const args = ["import", "--agent", "opencode", "--quiet", "--auto"]
144
127
  for (const sessionID of sessions) args.push("--session", sessionID)
145
128
  const proc = spawnWitness(args)
146
129
  if (!proc) return
@@ -242,8 +225,7 @@ const plugin = async () => {
242
225
  if (disposePromise) return disposePromise
243
226
  disposing = true
244
227
  clearRetry()
245
- clearQuietTimer()
246
- idleCycles.clear()
228
+ modernIdleWaiters.clear()
247
229
  disposePromise = (async () => {
248
230
  let timer
249
231
  const drained = await Promise.race([
@@ -280,21 +262,19 @@ const plugin = async () => {
280
262
  const type = eventType(event)
281
263
  const sessionID = event?.properties?.sessionID
282
264
  const modernIdle = type === "session.status" && event?.properties?.status?.type === "idle"
265
+ if (type === "session.idle" && sessionID && modernIdleWaiters.has(sessionID)) {
266
+ const done = modernIdleWaiters.get(sessionID)
267
+ modernIdleWaiters.delete(sessionID)
268
+ return done
269
+ }
283
270
  if ((type === "session.idle" || modernIdle) && sessionID) {
284
- const existing = idleCycles.get(sessionID)
285
- if (existing) return existing
286
271
  clearRetry()
287
272
  ensureDownload()
288
273
  const done = syncSessions(sessionID)
289
- idleCycles.set(sessionID, done)
290
- scheduleQuietWorker()
274
+ if (modernIdle) modernIdleWaiters.set(sessionID, done)
291
275
  return done
292
276
  }
293
- const sessionActivity = sessionID && (type.startsWith("message.") || type.startsWith("session."))
294
- if (sessionActivity) {
295
- if (sessionID) idleCycles.delete(sessionID)
296
- clearQuietTimer()
297
- }
277
+ if (type === "session.status" && sessionID) modernIdleWaiters.delete(sessionID)
298
278
  },
299
279
  }
300
280
  }