{"id":43510,"library":"opencode-postgres","title":"OpenCode Postgres","description":"OpenCode plugin (v0.1.3) that adds a postgres_query tool for running SQL queries against a configured Postgres database. Ships TypeScript types. Requires @opencode-ai/plugin >=1.15.12. Key differentiator: tight integration with OpenCode's permission system, allowing per-query authorization. Supports read-only mode and connection string configuration. Release cadence: early development.","status":"active","version":"0.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/vimtor/opencode-plugins","tags":["javascript","opencode","opencode-plugin","plugin","postgres","postgresql","database","sql","ai","typescript"],"install":[{"cmd":"npm install opencode-postgres","lang":"bash","label":"npm"},{"cmd":"yarn add opencode-postgres","lang":"bash","label":"yarn"},{"cmd":"pnpm add opencode-postgres","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; required to register the plugin with OpenCode.","package":"@opencode-ai/plugin","optional":false}],"imports":[{"note":"ESM-only; CommonJS require not supported.","wrong":"const opencodePostgres = require('opencode-postgres')","symbol":"default","correct":"import opencodePostgres from 'opencode-postgres'"},{"note":"Type symbol exported; both value and type imports work, but using 'import type' is unnecessary.","wrong":"import type { PostgresPluginOptions } from 'opencode-postgres'","symbol":"PostgresPluginOptions","correct":"import { PostgresPluginOptions } from 'opencode-postgres'"},{"note":"Also exported as default; use 'import opencodePostgres from ...' for default.","wrong":"import { plugin } from 'opencode-postgres';\n// Not a common mistake, but note: default export is also available.","symbol":"plugin","correct":"import { plugin } from 'opencode-postgres'"}],"quickstart":{"code":"// Install: add to OpenCode config\n// .opencode.json or opencode.config.json\n{\n  \"$schema\": \"https://opencode.ai/config.json\",\n  \"plugin\": [\n    [\n      \"opencode-postgres\",\n      {\n        \"connectionString\": process.env.DATABASE_URL ?? 'postgres://user:password@localhost:5432/mydb',\n        \"readOnly\": true\n      }\n    ]\n  ],\n  \"permission\": {\n    \"postgres_query\": \"ask\"\n  }\n}","lang":"typescript","description":"Configures the Postgres plugin with a connection string, read-only mode, and permission prompt."},"warnings":[{"fix":"Set readOnly: true or restrict the database role to read-only access.","message":"If readOnly is false, the plugin still uses a read-write transaction; database-level permissions should be the source of truth.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Update @opencode-ai/plugin to >=1.15.12.","message":"Requires @opencode-ai/plugin version >=1.15.12. Older OpenCode versions will fail to load the plugin.","severity":"breaking","affected_versions":"<0.1.0"},{"fix":"Use exactly 'postgres_query' in the permission config.","message":"The permission key is 'postgres_query', not 'postgres' or 'query'.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set permission.postgres_query to 'deny' if you want to block queries.","message":"If permission.postgres_query is not configured, OpenCode's native fallback allows most permissions. Explicitly deny to restrict.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"N/A","message":"No deprecated features known for v0.1.3; this warning is a placeholder.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'/plugin':28 '1.15.12':29 'add':7 'ai':27,67 'allow':39 'author':43 'cadenc':54 'configur':18,52 'connect':50 'databas':20,65 'develop':56 'differenti':31 'earli':55 'integr':33 'javascript':57 'key':30 'mode':48 'opencod':1,3,26,35,58,60 'opencode-ai':25 'opencode-plugin':59 'per':41 'per-queri':40 'permiss':37 'plugin':4,61,62 'postgr':2,9,19,63 'postgresql':64 'queri':10,15,42 'read':46 'read-on':45 'releas':53 'requir':24 'run':13 'ship':21 'sql':14,66 'string':51 'support':44 'system':38 'tight':32 'tool':11 'type':23 'typescript':22,68 'v0.1.3':5","created_at":"2026-06-05T17:00:08.607747+00:00","updated_at":"2026-06-05T17:00:08.607747+00:00","problems":[{"fix":"Run `npm install @opencode-ai/plugin@>=1.15.12` in your project.","cause":"Missing peer dependency @opencode-ai/plugin.","error":"Error: Failed to load plugin 'opencode-postgres': Cannot find module '@opencode-ai/plugin'"},{"fix":"Add `\"connectionString\": \"postgres://...\"` to the plugin options.","cause":"Missing 'connectionString' in plugin config.","error":"Error: Connection string is required"},{"fix":"Set `\"postgres_query\": \"allow\"` in the permission config or choose 'always' in the prompt.","cause":"The plugin's permission is set to 'deny' or user did not grant permission.","error":"Error: Permission denied: postgres_query"},{"fix":"Ensure the plugin is correctly configured in opencode config and OpenCode is restarted.","cause":"The plugin is not properly initialized or the tool is not available.","error":"TypeError: Cannot read properties of undefined (reading 'query')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/vimtor/opencode-plugins/tree/main/packages/opencode-postgres#readme","github":"https://github.com/vimtor/opencode-plugins","docs":null,"changelog":null,"pypi":null,"npm":"opencode-postgres","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}