opencode-sesh 2.0.4 → 2.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.
package/install.sh CHANGED
@@ -28,7 +28,7 @@ PLUGIN_VERSION_FALLBACK="2.0.25"
28
28
  # Peer line the panel was developed and typechecked against. A checkout's
29
29
  # package.json overrides these, so dependency bumps cannot drift the installed
30
30
  # config out of sync (solid-js moves with OpenTUI via @opentui/keymap's peer).
31
- OPENTUI_RANGE="^0.5.11"
31
+ OPENTUI_RANGE="^0.6.5"
32
32
  SOLID_VERSION="1.9.15"
33
33
  if [ -f "$SOURCE_DIR/package.json" ] && command -v jq >/dev/null 2>&1; then
34
34
  opentui_range=$(jq -r '.devDependencies["@opentui/solid"] // empty' "$SOURCE_DIR/package.json" 2>/dev/null || true)
@@ -111,22 +111,28 @@ remove_opencode_entry() {
111
111
  }
112
112
 
113
113
  # The launcher is a symlink we create. Treat it as ours only when it resolves to
114
- # a sesh launcher, so a foreign symlink is never replaced on install nor deleted
115
- # on uninstall. Recognized by the exact source path, a `.../bin/sesh` target, or
116
- # the marker in the target file (covers npm upgrades and a moved checkout).
114
+ # our source or an opencode-sesh package, including relative npm symlinks.
117
115
  launcher_is_ours() {
118
- local link=$1 target
116
+ local link=$1 target hops=0 package directory
119
117
  [ -L "$link" ] || return 1
120
- target=$(readlink "$link" 2>/dev/null) || return 1
121
- [ -n "$target" ] || return 1
122
- case "$target" in
123
- /*) ;;
124
- *) target="$(cd "$(dirname "$link")" && pwd -P)/$target" ;;
125
- esac
126
- case "$target" in
127
- "$SOURCE_DIR/bin/sesh"|*/bin/sesh) return 0 ;;
128
- esac
129
- [ -f "$target" ] && grep -qF 'Pick an opencode session' "$target" 2>/dev/null
118
+ while [ -L "$link" ]; do
119
+ hops=$((hops + 1))
120
+ [ "$hops" -le 40 ] || return 1
121
+ target=$(readlink "$link" 2>/dev/null) || return 1
122
+ [ -n "$target" ] || return 1
123
+ case "$target" in
124
+ /*) link=$target ;;
125
+ *) link="$(dirname "$link")/$target" ;;
126
+ esac
127
+ done
128
+ directory=$(cd "$(dirname "$link")" 2>/dev/null && pwd -P) || return 1
129
+ target="$directory/$(basename "$link")"
130
+ [ "$target" = "$SOURCE_DIR/bin/sesh" ] && return 0
131
+ [ -f "$target" ] || return 1
132
+ case "$target" in */bin/sesh) ;; *) return 1 ;; esac
133
+ package="${target%/bin/sesh}/package.json"
134
+ command -v jq >/dev/null 2>&1 && [ -f "$package" ] &&
135
+ jq -e '.name == "opencode-sesh" and .bin.sesh == "bin/sesh"' "$package" >/dev/null 2>&1
130
136
  }
131
137
 
132
138
  install_file() {
@@ -152,10 +158,9 @@ install_tui_panel() {
152
158
  fi
153
159
  plugin_version="${opencode_version:-$PLUGIN_VERSION_FALLBACK}"
154
160
 
155
- local opencode_created=0 opencode_tmp=''
161
+ local opencode_tmp=''
156
162
  if [ ! -f "$OPENCODE_JSON" ]; then
157
163
  printf '{\n "$schema": "https://opencode.ai/config.json",\n "plugins": []\n}\n' > "$OPENCODE_JSON"
158
- opencode_created=1
159
164
  note "created $OPENCODE_JSON"
160
165
  fi
161
166
  opencode_tmp=$(mktemp "${TMPDIR:-/tmp}/sesh-opencode.XXXXXX")
@@ -181,10 +186,9 @@ install_tui_panel() {
181
186
  # Local plugins resolve their imports from the config directory, and opencode
182
187
  # runs `bun install` there at startup. Keep the required packages declared
183
188
  # without clobbering versions the user already pinned.
184
- local pkg_created=0 pkg_tmp=''
189
+ local pkg_tmp=''
185
190
  if [ ! -f "$PACKAGE_JSON" ]; then
186
191
  printf '{\n "dependencies": {}\n}\n' > "$PACKAGE_JSON"
187
- pkg_created=1
188
192
  note "created $PACKAGE_JSON"
189
193
  fi
190
194
  pkg_tmp=$(mktemp "${TMPDIR:-/tmp}/sesh-pkg.XXXXXX")
@@ -267,6 +271,7 @@ if [ "$SYNC_PANEL" = 1 ]; then
267
271
  # touching the launcher or requiring fzf/sqlite. No-op when the panel is
268
272
  # absent, so `npm install` never adds a TUI panel on its own.
269
273
  [ -f "$PANEL_DST" ] || { note "sesh sidebar panel is not installed; nothing to sync."; exit 0; }
274
+ command -v jq >/dev/null 2>&1 || fail "required tool 'jq' is unavailable; install jq and rerun bash install.sh --sync-panel."
270
275
  umask 077
271
276
  install_tui_panel
272
277
  note_restart
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-sesh",
3
- "version": "2.0.4",
3
+ "version": "2.1.1",
4
4
  "description": "OpenCode session browser: search, preview, and resume every session across every project from the terminal or TUI.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -56,13 +56,13 @@
56
56
  "prepare": "husky",
57
57
  "build": "node scripts/build-tui.mjs",
58
58
  "prepack": "node scripts/build-tui.mjs",
59
- "test": "node scripts/build-tui.mjs && bash tests/sesh.sh && bash tests/changelog.sh",
60
- "test:unit": "node scripts/build-tui.mjs && bash tests/sesh.sh",
59
+ "test": "bun run test:unit && bash tests/changelog.sh",
60
+ "test:unit": "node scripts/build-tui.mjs && bash tests/sesh.sh && bash tests/install.sh",
61
61
  "test:changelog": "bash tests/changelog.sh",
62
62
  "test:picker": "python3 tests/picker.py",
63
63
  "typecheck": "tsc --noEmit",
64
64
  "lint:sh": "for script in bin/*.sh bin/sesh install.sh tests/*.sh scripts/*.sh; do bash -n \"$script\" || exit; done",
65
- "postinstall": "bash install.sh --sync-panel || true",
65
+ "postinstall": "bash install.sh --sync-panel || printf '%s\\n' 'sesh postinstall: panel sync failed; run bash install.sh --sync-panel after resolving the error above.' >&2",
66
66
  "prepublishOnly": "bun run test && bun run typecheck"
67
67
  },
68
68
  "peerDependencies": {
@@ -6,7 +6,7 @@ import { join } from "node:path"
6
6
 
7
7
  function dbPath(): string {
8
8
  if (process.env.SESH_DB) return process.env.SESH_DB
9
- const xdgPath = join(process.env.XDG_DATA_HOME ?? join(homedir(), ".local", "share"), "opencode", "opencode.db")
9
+ const xdgPath = join(process.env.XDG_DATA_HOME || join(homedir(), ".local", "share"), "opencode", "opencode.db")
10
10
  if (existsSync(xdgPath)) return xdgPath
11
11
  try {
12
12
  const result = spawnSync(process.env.SESH_OPENCODE ?? "opencode", ["debug", "paths"], { encoding: "utf8" })
@@ -59,7 +59,7 @@ export default Plugin.define({
59
59
  const scoped = typeof args.directory === "string" && args.directory.length > 0
60
60
  const query = `SELECT id, title, directory, time_updated AS updated, time_created AS created
61
61
  FROM session_v2
62
- WHERE parent_id IS NULL AND COALESCE(time_archived, 0) = 0${scoped ? " AND directory = ?" : ""}
62
+ WHERE COALESCE(parent_id, '') = '' AND COALESCE(time_archived, 0) = 0${scoped ? " AND directory = ?" : ""}
63
63
  ORDER BY time_updated DESC, id DESC
64
64
  LIMIT ${limit}`
65
65
  const rows = scoped ? db.query(query).all(args.directory) : db.query(query).all()