pantheon-opencode 2.1.3 → 2.1.4

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/CHANGELOG.md CHANGED
@@ -13,6 +13,32 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
13
13
  `node scripts/versioning.mjs apply --notes` pre-fills the generated sections from conventional commits.
14
14
  Running apply will move this section to a versioned entry and reset the template below. -->
15
15
 
16
+ ## [v2.1.4] - 2026-11-14
17
+
18
+ ### 🆕 What's New
19
+
20
+ - **Global Install Shadowing (#424)**: Doctor check (H2b) detects multiple global binaries, dangling symlinks, and prefix skew.
21
+ - **Strict Test Slice Ordering (#442)**: Fixed `--test-name-pattern` flag ordering in `test:slice` so regex filters work during fix loops.
22
+ - **Security Boundaries (#441)**: Hardened `auto-permissions` and `zeusReadGuard` to exclude `.git/` and `node_modules/` from reads.
23
+ - **Universal Session Todos (#439)**: Granted `todowrite` and `todoread` across all 14 specialist agent manifests.
24
+ - **Session Auto-Discovery (#440)**: Automated active session discovery from environment and SQLite `opencode.db` for vision.
25
+
26
+ ### Fixed
27
+
28
+ - **install (#424)** — added doctor check (H2b) for PATH shadowing, version skew check in `resolveStablePantheonRoot`, and sanitized npm env in `sync-tui.mjs`.
29
+ - **tests (#442)** — reordered `--test-name-pattern` before test path in `scripts/test-slice.mjs` so Node's test runner enforces filters during fix loops.
30
+ - **security (#441)** — enforced deterministic path checks in `auto-permissions.ts` and `zeusReadGuard` denying `.git/**`, `node_modules/**`, and traversal.
31
+ - **tools (#439)** — granted `todowrite` and `todoread` across all 14 specialist agent manifests in `src/agents/roster.json` and registered tool capabilities.
32
+ - **vision (#440)** — automated session ID resolution from `OPENCODE_SESSION_ID` and SQLite `opencode.db` (`session_v2`) for `vision_describe`.
33
+
34
+ ### ✅ Closed Issues
35
+
36
+ - #424 - detect and prevent global install shadowing and prefix version skew
37
+ - #439 - expose todowrite and todoread across specialist agents
38
+ - #440 - auto-discover OpenCode session ID for vision_describe
39
+ - #441 - enforce .git and node_modules exclusion in auto-permissions and guards
40
+ - #442 - reorder test-name-pattern filter before file path in test:slice
41
+
16
42
  ## [v2.1.3] - 2026-11-14
17
43
 
18
44
  ### 🆕 What's New
@@ -254,6 +280,30 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
254
280
 
255
281
  ## [Unreleased]
256
282
 
283
+ ### 🆕 What's New
284
+
285
+ - **Global Install Shadowing (#424)**: Doctor check (H2b) detects multiple global binaries, dangling symlinks, and prefix skew.
286
+ - **Strict Test Slice Ordering (#442)**: Fixed `--test-name-pattern` flag ordering in `test:slice` so regex filters work during fix loops.
287
+ - **Security Boundaries (#441)**: Hardened `auto-permissions` and `zeusReadGuard` to exclude `.git/` and `node_modules/` from reads.
288
+ - **Universal Session Todos (#439)**: Granted `todowrite` and `todoread` across all 14 specialist agent manifests.
289
+ - **Session Auto-Discovery (#440)**: Automated active session discovery from environment and SQLite `opencode.db` for vision.
290
+
291
+ ### Fixed
292
+
293
+ - **install (#424)** — added doctor check (H2b) for PATH shadowing, version skew check in `resolveStablePantheonRoot`, and sanitized npm env in `sync-tui.mjs`.
294
+ - **tests (#442)** — reordered `--test-name-pattern` before test path in `scripts/test-slice.mjs` so Node's test runner enforces filters during fix loops.
295
+ - **security (#441)** — enforced deterministic path checks in `auto-permissions.ts` and `zeusReadGuard` denying `.git/**`, `node_modules/**`, and traversal.
296
+ - **tools (#439)** — granted `todowrite` and `todoread` across all 14 specialist agent manifests in `src/agents/roster.json` and registered tool capabilities.
297
+ - **vision (#440)** — automated session ID resolution from `OPENCODE_SESSION_ID` and SQLite `opencode.db` (`session_v2`) for `vision_describe`.
298
+
299
+ ### ✅ Closed Issues
300
+
301
+ - #424 - detect and prevent global install shadowing and prefix version skew
302
+ - #439 - expose todowrite and todoread across specialist agents
303
+ - #440 - auto-discover OpenCode session ID for vision_describe
304
+ - #441 - enforce .git and node_modules exclusion in auto-permissions and guards
305
+ - #442 - reorder test-name-pattern filter before file path in test:slice
306
+
257
307
  <!-- Add new changes here.
258
308
  Canonical sections (docs/RELEASING.md): ### 🆕 What's New (curated highlights, ≤6 bullets ≤140 chars) →
259
309
  ### Added / Changed / Deprecated / Removed / Fixed / Security → ### ⚠️ Known Issues / ### ✅ Closed Issues.
package/README.md CHANGED
@@ -225,6 +225,16 @@ Working runnable reference projects demonstrating Pantheon orchestration in prac
225
225
 
226
226
  ---
227
227
 
228
+ ## What's New in v2.1.4
229
+
230
+ - **Global Install Shadowing & PATH Hygiene (#424):** Doctor check (H2b) detects multiple global binaries, dangling symlinks, and prefix skew. Version skew validation prevents `_npx` from binding to older global packages.
231
+ - **Strict Test Slice Ordering (#442):** Reordered `--test-name-pattern` flag ahead of the test file path in `scripts/test-slice.mjs` so Node's native test runner filters tests during failure/fix loops.
232
+ - **Security Boundaries on Internal Folders (#441):** Hardened `auto-permissions` and `zeusReadGuard` to exclude `.git/` and `node_modules/` from autonomous reads.
233
+ - **Universal Session Todo Tool Availability (#439):** Granted `todowrite` and `todoread` across all 14 specialist agent manifests.
234
+ - **Session Auto-Discovery for Zen Vision (#440):** Automated active session discovery from environment (`OPENCODE_SESSION_ID`) and SQLite `opencode.db` (`session_v2`) for `vision_describe`.
235
+
236
+ ---
237
+
228
238
  ## What's New in v2.0.1
229
239
 
230
240
  - **Bilingual TUI Settings (PT-BR / EN):** Visual localization for Decision Router, Autonomy & Budgets, and J1 Safety Gate tabs, with intelligent system locale auto-detection (`LANG` / `LC_ALL`) and manual preference cycling (`auto`, `pt-BR`, `en`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-opencode",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "Multi-agent orchestration for OpenCode \u2014 14 specialized agents, TDD, Themis review gates.",
5
5
  "type": "module",
6
6
  "workspaces": [
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pantheon",
3
3
  "publisher": "ils15",
4
- "version": "2.1.3",
4
+ "version": "2.1.4",
5
5
  "displayName": "Pantheon",
6
6
  "description": "Conductor-Delegate orchestration platform with 14 specialized agents, 25 skills, and OpenCode support.",
7
7
  "agents": "./src/agents",
package/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "setuptools.backends._legacy:_Backend"
4
4
 
5
5
  [project]
6
6
  name = "pantheon"
7
- version = "2.1.3"
7
+ version = "2.1.4"
8
8
  description = "Multi-agent orchestration framework"
9
9
  requires-python = ">=3.11"
10
10
  # Python sources under src/mcp/ import fastmcp/pydantic at runtime, but those
@@ -22,9 +22,17 @@
22
22
  * Exit codes: 0 = no blocking errors (warnings are allowed), 2 = errors.
23
23
  */
24
24
 
25
- import { spawn as spawnAsync, spawnSync } from 'node:child_process'
25
+ import { execSync, spawn as spawnAsync, spawnSync } from 'node:child_process'
26
26
  import { createHash } from 'node:crypto'
27
- import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, statSync } from 'node:fs'
27
+ import {
28
+ existsSync,
29
+ lstatSync,
30
+ mkdirSync,
31
+ readdirSync,
32
+ readFileSync,
33
+ realpathSync,
34
+ statSync,
35
+ } from 'node:fs'
28
36
  import { homedir } from 'node:os'
29
37
  import { basename, dirname, isAbsolute, join, resolve } from 'node:path'
30
38
  import { fileURLToPath } from 'node:url'
@@ -1514,6 +1522,106 @@ export function checkInstallVersionDrift(args) {
1514
1522
  return 'sync'
1515
1523
  }
1516
1524
 
1525
+ // ---------------------------------------------------------------------------
1526
+ // Check H2b: PATH shadowing across global npm prefixes (Issue #424)
1527
+ // ---------------------------------------------------------------------------
1528
+
1529
+ /**
1530
+ * Check H2b: PATH shadowing across global npm prefixes.
1531
+ *
1532
+ * When multiple copies of pantheon-opencode are installed globally (e.g. across nvm,
1533
+ * ~/.npm-global, /usr/local), PATH may resolve an older or different version than the
1534
+ * package running doctor or OpenCode.
1535
+ */
1536
+ export function checkPathShadowing(args = {}) {
1537
+ section('H2b. PATH Shadowing & Binary Resolution')
1538
+ const env = args.env ?? process.env
1539
+ const isWindows = process.platform === 'win32'
1540
+ const whichCmd = isWindows ? 'where pantheon-opencode' : 'which -a pantheon-opencode'
1541
+
1542
+ let raw = ''
1543
+ try {
1544
+ raw = execSync(whichCmd, {
1545
+ env,
1546
+ encoding: 'utf8',
1547
+ stdio: ['ignore', 'pipe', 'ignore'],
1548
+ }).trim()
1549
+ } catch {
1550
+ info('No global pantheon-opencode binary found in PATH')
1551
+ return 'no-binary'
1552
+ }
1553
+
1554
+ const binaries = raw
1555
+ .split(/\r?\n/)
1556
+ .map((line) => line.trim())
1557
+ .filter(Boolean)
1558
+
1559
+ if (binaries.length === 0) {
1560
+ info('No pantheon-opencode binary found in PATH')
1561
+ return 'no-binary'
1562
+ }
1563
+
1564
+ let danglingFound = false
1565
+ const resolvedBinaries = []
1566
+
1567
+ for (const binPath of binaries) {
1568
+ let real = null
1569
+ try {
1570
+ real = realpathSync(binPath)
1571
+ } catch {
1572
+ danglingFound = true
1573
+ error(`Dangling binary symlink in PATH: ${binPath} points to a non-existent path`)
1574
+ continue
1575
+ }
1576
+
1577
+ let binVersion = null
1578
+ let curDir = dirname(real)
1579
+ for (let i = 0; i < 4; i++) {
1580
+ const candidatePkg = join(curDir, 'package.json')
1581
+ if (existsSync(candidatePkg)) {
1582
+ try {
1583
+ const p = readJson(candidatePkg)
1584
+ if (p?.name === 'pantheon-opencode') {
1585
+ binVersion = p.version
1586
+ break
1587
+ }
1588
+ } catch {}
1589
+ }
1590
+ curDir = dirname(curDir)
1591
+ }
1592
+
1593
+ resolvedBinaries.push({ path: binPath, real, version: binVersion })
1594
+ }
1595
+
1596
+ if (danglingFound) return 'dangling'
1597
+
1598
+ if (resolvedBinaries.length > 1) {
1599
+ const primary = resolvedBinaries[0]
1600
+ const others = resolvedBinaries.slice(1)
1601
+ const divergent = others.filter(
1602
+ (b) => b.version && primary.version && b.version !== primary.version,
1603
+ )
1604
+
1605
+ if (divergent.length > 0) {
1606
+ warn(
1607
+ `Multiple global pantheon-opencode installs detected across PATH prefixes:\n` +
1608
+ resolvedBinaries
1609
+ .map(
1610
+ (b, idx) =>
1611
+ ` ${idx === 0 ? '▶ (active)' : ' (shadowed)'} ${b.path} (v${b.version ?? 'unknown'})`,
1612
+ )
1613
+ .join('\n') +
1614
+ `\nStale global copies cause version skew. Clean up stale prefixes with: npm uninstall -g pantheon-opencode`,
1615
+ { code: 'path_shadowing_detected', classification: 'advisory' },
1616
+ )
1617
+ return 'shadowing'
1618
+ }
1619
+ }
1620
+
1621
+ pass(`Primary binary in PATH resolves cleanly (${binaries[0]})`)
1622
+ return 'ok'
1623
+ }
1624
+
1517
1625
  // ---------------------------------------------------------------------------
1518
1626
  // Check H3: Plugin version drift (issue #158)
1519
1627
  // ---------------------------------------------------------------------------
@@ -3053,6 +3161,7 @@ async function main() {
3053
3161
  checkCodeModeDir(args)
3054
3162
  checkCodeModeManifest(args)
3055
3163
  checkInstallVersionDrift(args)
3164
+ checkPathShadowing(args)
3056
3165
  checkPluginVersionDrift(args)
3057
3166
  await checkTuiPlugin(args)
3058
3167
  await checkInstallerFileInventory(args)
@@ -642,6 +642,22 @@ export function resolveStablePantheonRoot(root = ROOT) {
642
642
  'pantheon-opencode',
643
643
  )
644
644
  if (existsSync(join(globalCandidate, 'src', 'plugin', 'index.ts'))) {
645
+ try {
646
+ const rootPkg = readJsonConfig(join(root, 'package.json'))
647
+ const globalPkg = readJsonConfig(join(globalCandidate, 'package.json'))
648
+ if (rootPkg?.version && globalPkg?.version) {
649
+ if (rootPkg.version === globalPkg.version) {
650
+ return { root: globalCandidate, volatile: false }
651
+ }
652
+ return {
653
+ root,
654
+ volatile: true,
655
+ skew: { running: rootPkg.version, global: globalPkg.version },
656
+ }
657
+ }
658
+ } catch {
659
+ // Fallback if package.json read fails
660
+ }
645
661
  return { root: globalCandidate, volatile: false }
646
662
  }
647
663
  return { root, volatile: true }
@@ -150,6 +150,8 @@ const GLOBAL_NPM_ENV_KEYS = new Set([
150
150
  'npm_config_globalconfig',
151
151
  'npm_config_prefix',
152
152
  'npm_config_location',
153
+ 'npm_config_allow_scripts',
154
+ 'npm_config_approve_scripts',
153
155
  ])
154
156
 
155
157
  /**
@@ -229,7 +229,7 @@ export function resolveTestSlice(files = [], options = {}) {
229
229
  if (slice.type.startsWith('python')) {
230
230
  finalCommand = `pytest ${slice.testFile} -k "${failedOnly}" -q --tb=short`
231
231
  } else if (slice.type.startsWith('node')) {
232
- finalCommand = `node --test ${slice.testFile} --test-name-pattern="${failedOnly}"`
232
+ finalCommand = `node --test --test-name-pattern="${failedOnly}" ${slice.testFile}`
233
233
  }
234
234
  }
235
235
  return {
@@ -16,6 +16,8 @@ permission:
16
16
  question: allow
17
17
  task:
18
18
  "*": deny
19
+ todowrite: allow
20
+ todoread: allow
19
21
  mcp_tools:
20
22
  pantheon-resources: all
21
23
  pantheon-memory: [memory_search]
@@ -15,6 +15,8 @@ permission:
15
15
  bash: deny
16
16
  task:
17
17
  "*": deny
18
+ todowrite: allow
19
+ todoread: allow
18
20
  mcp_tools:
19
21
  pantheon-resources: all
20
22
  pantheon-memory:
@@ -18,6 +18,7 @@ permission:
18
18
  task:
19
19
  "*": deny
20
20
  apollo: allow
21
+ todoread: allow
21
22
  mcp_tools:
22
23
  pantheon-resources: all
23
24
  pantheon-memory:
@@ -14,6 +14,8 @@ permission:
14
14
  webfetch: allow
15
15
  task:
16
16
  "*": deny
17
+ todowrite: allow
18
+ todoread: allow
17
19
  mcp_tools:
18
20
  pantheon-resources: all
19
21
  pantheon-memory: [memory_search]
@@ -14,6 +14,8 @@ permission:
14
14
  bash: deny
15
15
  task:
16
16
  "*": deny
17
+ todowrite: allow
18
+ todoread: allow
17
19
  mcp_tools:
18
20
  pantheon-resources: all
19
21
  pantheon-memory: [memory_recall]
@@ -13,6 +13,8 @@ permission:
13
13
  webfetch: allow
14
14
  task:
15
15
  "*": deny
16
+ todowrite: allow
17
+ todoread: allow
16
18
  mcp_tools:
17
19
  pantheon-resources: all
18
20
  pantheon-memory: [memory_search]
@@ -15,6 +15,8 @@ permission:
15
15
  task:
16
16
  "*": deny
17
17
  apollo: allow
18
+ todowrite: allow
19
+ todoread: allow
18
20
  mcp_tools:
19
21
  pantheon-resources: all
20
22
  pantheon-memory: [memory_search]
@@ -18,6 +18,8 @@ permission:
18
18
  hashline_edit: deny
19
19
  task:
20
20
  "*": deny
21
+ todowrite: allow
22
+ todoread: allow
21
23
  mcp_tools:
22
24
  pantheon-resources: all
23
25
  pantheon-memory: [memory_recall]
@@ -18,6 +18,8 @@ permission:
18
18
  ".pantheon/deepwork/**": allow
19
19
  task:
20
20
  "*": deny
21
+ todowrite: allow
22
+ todoread: allow
21
23
  mcp_tools:
22
24
  pantheon-resources: all
23
25
  pantheon-memory:
package/src/agents/nyx.md CHANGED
@@ -14,6 +14,8 @@ permission:
14
14
  hashline_edit: deny
15
15
  task:
16
16
  "*": deny
17
+ todowrite: allow
18
+ todoread: allow
17
19
  mcp_tools:
18
20
  pantheon-resources: all
19
21
  pantheon-memory: [memory_search]
@@ -14,6 +14,8 @@ permission:
14
14
  webfetch: allow
15
15
  task:
16
16
  "*": deny
17
+ todowrite: allow
18
+ todoread: allow
17
19
  mcp_tools:
18
20
  pantheon-resources: all
19
21
  pantheon-memory: [memory_search]
@@ -13,6 +13,8 @@ permission:
13
13
  grep: allow
14
14
  task:
15
15
  "*": deny
16
+ todowrite: allow
17
+ todoread: allow
16
18
  mcp_tools:
17
19
  pantheon-resources: all
18
20
  pantheon-memory: [memory_recall]
@@ -14,6 +14,8 @@ permission:
14
14
  pantheon_deepwork: allow
15
15
  task:
16
16
  "*": deny
17
+ todowrite: allow
18
+ todoread: allow
17
19
  mcp_tools:
18
20
  pantheon-resources: all
19
21
  pantheon-memory: [memory_search]
@@ -295,9 +295,33 @@ def _validated_session_id(value: object) -> str | None:
295
295
  return value if isinstance(value, str) and value.startswith("ses") else None
296
296
 
297
297
 
298
+ def _discover_active_session_id() -> str | None:
299
+ """Discover active session id from environment or opencode.db."""
300
+ for env_var in ("OPENCODE_SESSION_ID", "SESSION_ID"):
301
+ val = os.getenv(env_var, "").strip()
302
+ if _validated_session_id(val):
303
+ return val
304
+ opencode_db_env = os.getenv("OPENCODE_DB", "").strip()
305
+ if opencode_db_env:
306
+ try:
307
+ db_path = Path(opencode_db_env)
308
+ if db_path.exists():
309
+ with sqlite3.connect(f"file:{db_path}?mode=ro", uri=True) as conn:
310
+ cur = conn.cursor()
311
+ cur.execute("SELECT id FROM session_v2 ORDER BY time_created DESC LIMIT 1")
312
+ row = cur.fetchone()
313
+ if row and _validated_session_id(row[0]):
314
+ return str(row[0])
315
+ except Exception:
316
+ pass
317
+ return None
318
+
319
+
298
320
  def _require_session_id(value: object) -> str:
299
321
  """Return a valid session id or fail before any Zen-bound work."""
300
322
  session_id = _validated_session_id(value)
323
+ if session_id is None and value is None:
324
+ session_id = _discover_active_session_id()
301
325
  if session_id is None:
302
326
  raise VisionError(
303
327
  "A valid OpenCode session id is required for Zen Vision; "
@@ -90,6 +90,26 @@ const SAFE_DEV_BINARIES: ReadonlySet<string> = new Set([
90
90
  'bash',
91
91
  ])
92
92
 
93
+ /** Check if a resource target points to an excluded or sensitive path (.git, node_modules, traversal). */
94
+ export function isExcludedReadPath(rawPath: string): boolean {
95
+ const trimmed = rawPath.trim()
96
+ if (!trimmed) return false
97
+ const normalized = trimmed.replace(/\\/g, '/')
98
+ // Traversal outside workspace
99
+ if (normalized.startsWith('../') || normalized === '..' || normalized.includes('/../')) {
100
+ return true
101
+ }
102
+ // Sensitive system paths
103
+ if (/^\/(etc|boot|sys|proc|root)(\/|$)/.test(normalized)) {
104
+ return true
105
+ }
106
+ // Excluded repository internal directories (.git and node_modules)
107
+ if (/(^|\/)(\.git|node_modules)(\/|$)/.test(normalized)) {
108
+ return true
109
+ }
110
+ return false
111
+ }
112
+
93
113
  /** Check if auto-permissions engine is enabled in environment. */
94
114
  export function autoPermissionsEnabled(
95
115
  env: Record<string, string | undefined> = process.env,
@@ -245,7 +265,7 @@ export function evaluateAutoPermission(
245
265
  }
246
266
  }
247
267
 
248
- // 3. Read-only inspection tools are safe within workspace (excluding network/external URLs)
268
+ // 3. Read-only inspection tools are safe within workspace (excluding network/external URLs and excluded directories)
249
269
  if (['read', 'glob', 'grep', 'webfetch', 'question'].includes(action)) {
250
270
  const firstResource =
251
271
  Array.isArray(event.resources) && typeof event.resources[0] === 'string'
@@ -254,6 +274,11 @@ export function evaluateAutoPermission(
254
274
  if (firstResource.startsWith('http://') || firstResource.startsWith('https://')) {
255
275
  return { decision: 'passthrough' }
256
276
  }
277
+ if (firstResource && isExcludedReadPath(firstResource)) {
278
+ event.effect = 'deny'
279
+ event.message = `Pantheon auto-permissions denied: reading '${firstResource}' is prohibited (.git and node_modules are excluded)`
280
+ return { decision: 'deny', reason: 'excluded-path' }
281
+ }
257
282
  event.effect = 'allow'
258
283
  return { decision: 'allow', reason: 'safe-read-action' }
259
284
  }
@@ -200,9 +200,15 @@ export const DEFAULT_BLOCKED_TOOLS: ReadonlySet<string> = new Set([
200
200
  /**
201
201
  * Path patterns that Zeus must NOT read directly. Zeus must delegate
202
202
  * codebase reads to @apollo to avoid context bloat and enforce separation
203
- * of concerns.
203
+ * of concerns. .git and node_modules are excluded repository noise.
204
204
  */
205
- export const ZEUS_READ_DENY_PATTERNS: ReadonlyArray<RegExp> = [/^src\//, /^tests?\//, /^scripts?\//]
205
+ export const ZEUS_READ_DENY_PATTERNS: ReadonlyArray<RegExp> = [
206
+ /^src\//,
207
+ /^tests?\//,
208
+ /^scripts?\//,
209
+ /(^|\/)\.git(\/|$)/,
210
+ /(^|\/)node_modules(\/|$)/,
211
+ ]
206
212
 
207
213
  /**
208
214
  * Normalize a tool-supplied path before it meets the deny patterns.
@@ -300,6 +306,9 @@ export function isDeniedGlobPattern(pattern: string): boolean {
300
306
  if (normalized.startsWith('../') || normalized === '..' || normalized.includes('/../')) {
301
307
  return true
302
308
  }
309
+ if (/(^|\/)(\.git|node_modules)(\/|$)/.test(normalized)) {
310
+ return true
311
+ }
303
312
  if (isDeniedReadPath(normalized, true)) {
304
313
  return true
305
314
  }
@@ -2,6 +2,7 @@
2
2
 
3
3
  import type { LookupAddress } from 'node:dns'
4
4
  import { lookup as dnsLookup } from 'node:dns/promises'
5
+ import { existsSync } from 'node:fs'
5
6
  import { readFile } from 'node:fs/promises'
6
7
  import { request as httpRequest } from 'node:http'
7
8
  import { request as httpsRequest } from 'node:https'
@@ -524,6 +525,53 @@ async function imageAttachment(
524
525
  return toImageAttachment(bytes, localPath.split(/[\\/]/).at(-1) || 'image')
525
526
  }
526
527
 
528
+ /**
529
+ * Discover the active OpenCode session ID from environment or opencode.db.
530
+ */
531
+ export function discoverActiveSessionId(directory?: string): string | undefined {
532
+ for (const envVar of ['OPENCODE_SESSION_ID', 'SESSION_ID']) {
533
+ const val = (process.env[envVar] ?? '').trim()
534
+ if (isValidSessionId(val)) return val
535
+ }
536
+ try {
537
+ const dataHome = process.env.XDG_DATA_HOME || join(homedir(), '.local', 'share')
538
+ const dbPath = process.env.OPENCODE_DB || join(dataHome, 'opencode', 'opencode.db')
539
+ if (!existsSync(dbPath)) return undefined
540
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
541
+ const sqlite = require('node:sqlite') as {
542
+ DatabaseSync: new (
543
+ path: string,
544
+ options: { readOnly: boolean },
545
+ ) => {
546
+ prepare: (query: string) => {
547
+ get: (...params: unknown[]) => Record<string, unknown> | undefined
548
+ }
549
+ close: () => void
550
+ }
551
+ }
552
+ const db = new sqlite.DatabaseSync(dbPath, { readOnly: true })
553
+ try {
554
+ if (directory) {
555
+ const row = db
556
+ .prepare(
557
+ 'SELECT id FROM session_v2 WHERE directory = ? ORDER BY time_created DESC LIMIT 1',
558
+ )
559
+ .get(directory)
560
+ if (row && isValidSessionId(row.id)) return String(row.id)
561
+ }
562
+ const fallbackRow = db
563
+ .prepare('SELECT id FROM session_v2 ORDER BY time_created DESC LIMIT 1')
564
+ .get()
565
+ if (fallbackRow && isValidSessionId(fallbackRow.id)) return String(fallbackRow.id)
566
+ } finally {
567
+ db.close()
568
+ }
569
+ } catch {
570
+ // Graceful fallback when node:sqlite is unavailable or db schema differs
571
+ }
572
+ return undefined
573
+ }
574
+
527
575
  export function createV2VisionTool(runtime: V2VisionRuntime): V2VisionToolDefinition {
528
576
  return {
529
577
  name: 'vision_describe',
@@ -551,7 +599,11 @@ export function createV2VisionTool(runtime: V2VisionRuntime): V2VisionToolDefini
551
599
  let stage = 'validate OpenCode session'
552
600
  try {
553
601
  const call = (asRecord(rawContext) ?? {}) as V2VisionToolContext
554
- if (!isValidSessionId(call.sessionID)) {
602
+ let sessionID = isValidSessionId(call.sessionID) ? call.sessionID : undefined
603
+ if (!sessionID) {
604
+ sessionID = discoverActiveSessionId(call.directory || process.cwd())
605
+ }
606
+ if (!sessionID) {
555
607
  throw new Error(
556
608
  'a valid OpenCode session id is required; retry this tool from an active OpenCode session',
557
609
  )
@@ -594,7 +646,7 @@ export function createV2VisionTool(runtime: V2VisionRuntime): V2VisionToolDefini
594
646
  // header ONLY for Zen targets, never to a non-Zen provider.
595
647
  const requestTarget: NativeVisionTarget = {
596
648
  ...target,
597
- sessionID: call.sessionID,
649
+ sessionID,
598
650
  }
599
651
  let failure: NativeVisionFailure | undefined
600
652
  const output = await describeImagesNative(
@@ -53,6 +53,21 @@ var SAFE_DEV_BINARIES = /* @__PURE__ */ new Set([
53
53
  "sh",
54
54
  "bash"
55
55
  ]);
56
+ function isExcludedReadPath(rawPath) {
57
+ const trimmed = rawPath.trim();
58
+ if (!trimmed) return false;
59
+ const normalized = trimmed.replace(/\\/g, "/");
60
+ if (normalized.startsWith("../") || normalized === ".." || normalized.includes("/../")) {
61
+ return true;
62
+ }
63
+ if (/^\/(etc|boot|sys|proc|root)(\/|$)/.test(normalized)) {
64
+ return true;
65
+ }
66
+ if (/(^|\/)(\.git|node_modules)(\/|$)/.test(normalized)) {
67
+ return true;
68
+ }
69
+ return false;
70
+ }
56
71
  function autoPermissionsEnabled(env = process.env) {
57
72
  const val = (env.PANTHEON_AUTO_PERMISSIONS ?? "").trim().toLowerCase();
58
73
  return val !== "off" && val !== "0" && val !== "false";
@@ -140,6 +155,11 @@ function evaluateAutoPermission(event, options = {}) {
140
155
  if (firstResource.startsWith("http://") || firstResource.startsWith("https://")) {
141
156
  return { decision: "passthrough" };
142
157
  }
158
+ if (firstResource && isExcludedReadPath(firstResource)) {
159
+ event.effect = "deny";
160
+ event.message = `Pantheon auto-permissions denied: reading '${firstResource}' is prohibited (.git and node_modules are excluded)`;
161
+ return { decision: "deny", reason: "excluded-path" };
162
+ }
143
163
  event.effect = "allow";
144
164
  return { decision: "allow", reason: "safe-read-action" };
145
165
  }
@@ -3866,7 +3886,13 @@ var DEFAULT_BLOCKED_TOOLS = /* @__PURE__ */ new Set([
3866
3886
  // opencode.db.
3867
3887
  "pantheon_model"
3868
3888
  ]);
3869
- var ZEUS_READ_DENY_PATTERNS = [/^src\//, /^tests?\//, /^scripts?\//];
3889
+ var ZEUS_READ_DENY_PATTERNS = [
3890
+ /^src\//,
3891
+ /^tests?\//,
3892
+ /^scripts?\//,
3893
+ /(^|\/)\.git(\/|$)/,
3894
+ /(^|\/)node_modules(\/|$)/
3895
+ ];
3870
3896
  function normalizeGuardPath(value) {
3871
3897
  let normalized = value.replace(/\\/g, "/");
3872
3898
  while (normalized.startsWith("./")) normalized = normalized.slice(2);
@@ -3903,6 +3929,9 @@ function isDeniedGlobPattern(pattern) {
3903
3929
  if (normalized.startsWith("../") || normalized === ".." || normalized.includes("/../")) {
3904
3930
  return true;
3905
3931
  }
3932
+ if (/(^|\/)(\.git|node_modules)(\/|$)/.test(normalized)) {
3933
+ return true;
3934
+ }
3906
3935
  if (isDeniedReadPath(normalized, true)) {
3907
3936
  return true;
3908
3937
  }
@@ -8237,6 +8266,7 @@ function createJ3EscalationObserver(options) {
8237
8266
 
8238
8267
  // src/pantheon/native-vision.ts
8239
8268
  import { lookup as dnsLookup } from "node:dns/promises";
8269
+ import { existsSync as existsSync4 } from "node:fs";
8240
8270
  import { readFile as readFile4 } from "node:fs/promises";
8241
8271
  import { request as httpRequest } from "node:http";
8242
8272
  import { request as httpsRequest } from "node:https";
@@ -9207,6 +9237,33 @@ async function imageAttachment(value, directory, signal) {
9207
9237
  }
9208
9238
  return toImageAttachment(bytes, localPath.split(/[\\/]/).at(-1) || "image");
9209
9239
  }
9240
+ function discoverActiveSessionId(directory) {
9241
+ for (const envVar of ["OPENCODE_SESSION_ID", "SESSION_ID"]) {
9242
+ const val = (process.env[envVar] ?? "").trim();
9243
+ if (isValidSessionId(val)) return val;
9244
+ }
9245
+ try {
9246
+ const dataHome = process.env.XDG_DATA_HOME || join10(homedir4(), ".local", "share");
9247
+ const dbPath = process.env.OPENCODE_DB || join10(dataHome, "opencode", "opencode.db");
9248
+ if (!existsSync4(dbPath)) return void 0;
9249
+ const sqlite = __require("node:sqlite");
9250
+ const db = new sqlite.DatabaseSync(dbPath, { readOnly: true });
9251
+ try {
9252
+ if (directory) {
9253
+ const row = db.prepare(
9254
+ "SELECT id FROM session_v2 WHERE directory = ? ORDER BY time_created DESC LIMIT 1"
9255
+ ).get(directory);
9256
+ if (row && isValidSessionId(row.id)) return String(row.id);
9257
+ }
9258
+ const fallbackRow = db.prepare("SELECT id FROM session_v2 ORDER BY time_created DESC LIMIT 1").get();
9259
+ if (fallbackRow && isValidSessionId(fallbackRow.id)) return String(fallbackRow.id);
9260
+ } finally {
9261
+ db.close();
9262
+ }
9263
+ } catch {
9264
+ }
9265
+ return void 0;
9266
+ }
9210
9267
  function createV2VisionTool(runtime) {
9211
9268
  return {
9212
9269
  name: "vision_describe",
@@ -9229,7 +9286,11 @@ function createV2VisionTool(runtime) {
9229
9286
  let stage = "validate OpenCode session";
9230
9287
  try {
9231
9288
  const call = asRecord2(rawContext) ?? {};
9232
- if (!isValidSessionId(call.sessionID)) {
9289
+ let sessionID = isValidSessionId(call.sessionID) ? call.sessionID : void 0;
9290
+ if (!sessionID) {
9291
+ sessionID = discoverActiveSessionId(call.directory || process.cwd());
9292
+ }
9293
+ if (!sessionID) {
9233
9294
  throw new Error(
9234
9295
  "a valid OpenCode session id is required; retry this tool from an active OpenCode session"
9235
9296
  );
@@ -9268,7 +9329,7 @@ function createV2VisionTool(runtime) {
9268
9329
  stage = "send image to the selected multimodal model";
9269
9330
  const requestTarget = {
9270
9331
  ...target,
9271
- sessionID: call.sessionID
9332
+ sessionID
9272
9333
  };
9273
9334
  let failure;
9274
9335
  const output = await describeImagesNative(
@@ -10738,7 +10799,7 @@ import { promisify } from "node:util";
10738
10799
 
10739
10800
  // src/pantheon/cost-command.ts
10740
10801
  import { execFile } from "node:child_process";
10741
- import { accessSync, constants as constants3, existsSync as existsSync5, statSync as statSync3 } from "node:fs";
10802
+ import { accessSync, constants as constants3, existsSync as existsSync6, statSync as statSync3 } from "node:fs";
10742
10803
  import { delimiter, dirname as dirname8, join as join14 } from "node:path";
10743
10804
  import { fileURLToPath as fileURLToPath4 } from "node:url";
10744
10805
  import { z } from "zod";
@@ -10748,7 +10809,7 @@ import { homedir as homedir6 } from "node:os";
10748
10809
  import { join as join13 } from "node:path";
10749
10810
 
10750
10811
  // src/plugins/tui/src/model-pricing.ts
10751
- import { existsSync as existsSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync6, renameSync as renameSync3, writeFileSync as writeFileSync4 } from "node:fs";
10812
+ import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync6, renameSync as renameSync3, writeFileSync as writeFileSync4 } from "node:fs";
10752
10813
  import { homedir as homedir5 } from "node:os";
10753
10814
  import { dirname as dirname7, join as join12 } from "node:path";
10754
10815
  var MODELS_DEV_URL = "https://models.dev/api.json";
@@ -10894,7 +10955,7 @@ function parseCachedCatalog(raw) {
10894
10955
  }
10895
10956
  function readPricingCache(cachePath) {
10896
10957
  try {
10897
- if (!existsSync4(cachePath)) return void 0;
10958
+ if (!existsSync5(cachePath)) return void 0;
10898
10959
  return parseCachedCatalog(JSON.parse(readFileSync6(cachePath, "utf8")));
10899
10960
  } catch {
10900
10961
  return void 0;
@@ -11125,7 +11186,7 @@ var costArgs = {
11125
11186
  };
11126
11187
  function findExistingDb(override) {
11127
11188
  const candidate = override === void 0 ? resolveCostDbPath() : resolveCostDbPath({ dbPath: override });
11128
- return existsSync5(candidate) ? candidate : void 0;
11189
+ return existsSync6(candidate) ? candidate : void 0;
11129
11190
  }
11130
11191
  var COST_AGGREGATE_SQL = {
11131
11192
  message: (sessionId) => `
@@ -11834,7 +11895,7 @@ async function queryWithCliFallback(dbPath, days, deps) {
11834
11895
  const execFileAsync = deps?.execFile ?? defaultExecFile;
11835
11896
  const isExecutable = deps?.isExecutable ?? defaultIsExecutable;
11836
11897
  const costScript = join14(__dirname, "..", "..", "scripts", "cost.mjs");
11837
- if (!existsSync5(costScript)) {
11898
+ if (!existsSync6(costScript)) {
11838
11899
  throw new Error(`CLI fallback script not found: ${costScript}`);
11839
11900
  }
11840
11901
  const node = resolveNodeExecutable(env, isExecutable);
@@ -12160,7 +12221,7 @@ function buildApprovalQuestion(plan) {
12160
12221
  }
12161
12222
 
12162
12223
  // src/pantheon/deepwork/plan-tracker.ts
12163
- import { existsSync as existsSync6 } from "node:fs";
12224
+ import { existsSync as existsSync7 } from "node:fs";
12164
12225
  import { appendFile as appendFile3, mkdir as mkdir6, readdir, readFile as readFile6, rename as rename5, writeFile as writeFile3 } from "node:fs/promises";
12165
12226
  import { join as join16 } from "node:path";
12166
12227
 
@@ -12393,7 +12454,7 @@ async function resolvePlanDecision(cwd = process.cwd(), slug, decisionId, chosen
12393
12454
  }
12394
12455
  async function listPlans(cwd = process.cwd()) {
12395
12456
  const root = deepworkRootDir(cwd);
12396
- if (!existsSync6(root)) return [];
12457
+ if (!existsSync7(root)) return [];
12397
12458
  const entries = await readdir(root, { withFileTypes: true });
12398
12459
  const result = [];
12399
12460
  for (const entry of entries) {
@@ -2062,7 +2062,7 @@ async function readChangelogForBundle(bundleUrl) {
2062
2062
  }
2063
2063
  /** The ambient build-time version, or null outside a tsdown build. */
2064
2064
  function embeddedVersion() {
2065
- return "2.1.3";
2065
+ return "2.1.4";
2066
2066
  }
2067
2067
  /**
2068
2068
  * Resolve the running Pantheon version for the what's-new window: the plugin
@@ -2287,7 +2287,7 @@ function persistUpdateCheckState(previous, latest) {
2287
2287
  } catch {}
2288
2288
  }
2289
2289
  function resolveRunningVersion() {
2290
- return "2.1.3";
2290
+ return "2.1.4";
2291
2291
  }
2292
2292
  const VALUE_WIDTH = 24;
2293
2293
  function SettingsWindow(props) {
@@ -6513,7 +6513,7 @@ async function checkForPantheonUpdate(context) {
6513
6513
  const latest = String((await response.json())?.version ?? "");
6514
6514
  if (!latest) return;
6515
6515
  const notice = pickUpdateNotice({
6516
- currentVersion: "2.1.3",
6516
+ currentVersion: "2.1.4",
6517
6517
  latestVersion: latest,
6518
6518
  state: readState(),
6519
6519
  nowMs: Date.now()
@@ -7325,7 +7325,7 @@ function Sidebar(props) {
7325
7325
  get children() {
7326
7326
  var _el$13 = createElement("text");
7327
7327
  setProp(_el$13, "attributes", 1);
7328
- insert(_el$13, `Pantheon v2.1.3`);
7328
+ insert(_el$13, `Pantheon v2.1.4`);
7329
7329
  effect((_$p) => setProp(_el$13, "fg", text(), _$p));
7330
7330
  return _el$13;
7331
7331
  }
@@ -8097,7 +8097,7 @@ function HomeStatus(props) {
8097
8097
  },
8098
8098
  get children() {
8099
8099
  var _el$73 = createElement("text");
8100
- insert(_el$73, () => `Pantheon v2.1.3${preset().name ? ` ▸ ${preset().name}` : ""}`);
8100
+ insert(_el$73, () => `Pantheon v2.1.4${preset().name ? ` ▸ ${preset().name}` : ""}`);
8101
8101
  effect((_$p) => setProp(_el$73, "fg", muted(), _$p));
8102
8102
  return _el$73;
8103
8103
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pantheon-tui",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pantheon-tui",
9
- "version": "2.1.3",
9
+ "version": "2.1.4",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@opencode/plugin": "2.0.26",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pantheon-tui",
3
3
  "type": "module",
4
- "version": "2.1.3",
4
+ "version": "2.1.4",
5
5
  "description": "Pantheon TUI plugin \u2014 V1 rich sidebar and usage gauges; native V2 status, session and delegation sidebar",
6
6
  "license": "MIT",
7
7
  "engines": {