Skip to content

feat(pgpm): pgpm env keeps already-set PG* vars; pgpm skill accepts a developer's own Postgres - #1804

Closed
pyramation wants to merge 1 commit into
mainfrom
feat/pgpm-env-keep-existing-pg-vars
Closed

pyramation wants to merge 1 commit into
mainfrom
feat/pgpm-env-keep-existing-pg-vars

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

Onboarding follow-up (constructive-io/constructive-planning#1970): a developer who already runs PostgreSQL on 5432 was told by the pgpm skill to lsof -i :5432 and stop it, and eval "$(pgpm env)" silently replaced their credentials with the Docker defaults. Both are fixed here; the boilerplate side is constructive-io/pgpm-boilerplates#45.

pgpm env — PG* variables already present in the shell win; only the missing ones come from the profile, and the output says so:

$ PGUSER=dan PGPASSWORD=x pgpm env
# keeping PGUSER, PGPASSWORD from your environment (pass --reset to overwrite)
export PGHOST=localhost
export PGPORT=5432
export PGDATABASE=postgres

New --reset restores the old overwrite-everything behaviour; --supabase implies it (an explicit profile switch should switch). Same rule applies in exec mode (pgpm env pnpm test). The logic is pulled into an exported resolveEnvVars(profile, existing, { objectStore, reset }) with unit tests; object-store vars (CDN_ENDPOINT, AWS_*) are always emitted as before.

pgpm skill (.agents/skills/pgpm, installed into every new workspace by pgpm init): Quick Start and the docker/env/troubleshooting references now say — check pg_isready -h localhost -p 5432 first; if it answers, use that server with the developer's superuser credentials and pgpm admin-users bootstrap --yes, never stop it; want the container as well → pgpm docker start --port 5433 + export PGPORT=5433. The "port in use → stop conflicting process" rows are gone. Added an ERR_PNPM_IGNORED_BUILDS → edit pnpm-policy.yaml, don't pnpm approve-builds row.

Verified: pgpm/cli jest (__tests__/env.test.ts), eslint, tsc --noEmit, and the built CLI output above.

Link to Devin session: https://app.devin.ai/sessions/1ef0d1c209f041afa29e0e4cc4b2cb29
Open in Devin Desktop: https://app.devin.ai/desktop/session/1ef0d1c209f041afa29e0e4cc4b2cb29?variant=devin
Requested by: @pyramation

…loper's own Postgres

- pgpm env no longer overwrites PGHOST/PGPORT/PGUSER/PGPASSWORD/PGDATABASE
  that the shell already has; it fills in the missing ones and prints a
  '# keeping ...' comment. --reset (and --supabase) overwrite as before.
- pgpm skill: check pg_isready before starting Docker, reuse an existing
  server with the developer's credentials, never stop it to free 5432;
  --port 5433 + PGPORT=5433 only when both are wanted. Add the
  ERR_PNPM_IGNORED_BUILDS -> pnpm-policy.yaml row.
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@tenki-reviewer

tenki-reviewer Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR refactors pgpm env so that PG* variables already present in the caller's shell are kept as-is by default and only missing ones are filled from the selected profile, with a new --reset flag (and implicit reset for --supabase) to overwrite them.

Files Change
pgpm/cli/src/commands/env.ts Extracts resolveEnvVars/EnvResolution, adds keep/overwrite semantics with a --reset flag, and threads the resolution through printExports and executeCommand.
pgpm/cli/__tests__/env.test.ts Adds unit tests covering keep, reset, and object-store behavior.
.agents/skills/pgpm/* docs Documents the new keep/--reset behavior in help text and skill references.

The change is well-scoped and tested; the keep/overwrite logic and object-store handling are covered by the new test cases.

Reviewed commit: c0a08e9

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Superseded by a docs-only PR (the pgpm env change was dropped — if you brought your own PG* vars, just don't run pgpm env).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant