Positron python upstream merge

From posit-dev/positron · View interactive version

Positron python upstream merge is an AI agent skill from the GitHub repository posit-dev/positron. Use when merging a new microsoft/vscode-python release into extensions/positron-python, working through the monthly "INTERNAL: Python maintenance" checklist issue, or refreshing positron-python's pinned Python requirements, ipykernel bundle, or PET version.

How to use this skill

Skill file

positron-python upstream merge

extensions/positron-python is a fork of microsoft/vscode-python. Each maintenance round applies the upstream diff between two release tags as one commit, then updates dependencies and CI. The risky part is not the conflicts. It is upstream behavior changes that land cleanly in code Positron depends on. So triage comes before applying, and behavior decisions go to the user.

Scripts are in .claude/skills/positron-python-upstream-merge/scripts/ (below: $S). Run them from the repo root on the user's feature branch. From step 2 on, the tree must be clean.

Inputs

Workflow

1. Preview and triage (no changes to the tree)

bash $S/preview.sh START END [path-to-local-vscode-python-clone]

The script fetches the tags into refs/vscode-python/* (kept for apply.sh) and prints per-status counts and a report dir:

commits.txt only covers files with Positron blocks. Also review these, which it can't flag:

For each change, find the Positron callers of what it changes, especially in src/client/positron/. Then put it in one of these groups:

| Group | Typical areas |

|---|---|

| High: changes behavior that Positron code depends on | interpreterService / getActiveInterpreter (positron/manager.ts starts a session from its result after onDidChangeInterpreter), new callers of _onConfigChanged() with no scope (Positron then defaults to startSession: true), activationManager, nativePythonFinder (PET), installers, python_files/posit kernel deps |

| Medium: build, toolchain, or CI | TypeScript, @vscode/test-electron, webpack plugins, build/test-requirements.txt, upstream .github/ changes |

| Low: inert in Positron | Environments extension (useEnvExtension() is forced to false), PYTHONSTARTUP/pythonrc.py/PyREPL (forced off in terminals/pythonStartup.ts), native REPL, Pylance-only paths, chat tools hidden with "when": "false", telemetry |

A "Low" area can stop being inert. Check that the Positron override still exists before you rely on it.

STOP and report to the user with the groups, a recommendation for each High item (take upstream, keep Positron behavior, or adapt), and a list of manual validation areas. Wait for their decisions before you apply.

2. Apply

bash $S/apply.sh START END

This runs git diff | git apply --3way into the subdirectory, keeps Positron's package-lock.json, and deletes new upstream files that Positron's .gitignore excludes (build artifacts). Conflicted files keep their markers.

3. Resolve conflicts

| Situation | Resolution |

|---|---|

| package.json version / description | Keep Positron's |

| Positron has an older version of the same bump (npm dep, action version, pinned requirement) | Take upstream |

| extensions/positron-python/.github/** | Take upstream. These files don't run in Positron CI; they are the reference for step 6 |

| Upstream edits lines inside a Positron block | Keep the Positron block. If the block holds commented-out upstream code, update that copy to the new upstream code so the next merge diffs cleanly |

| Upstream adds lines next to a Positron block | Keep both |

| Upstream removes code that a Positron block only existed to override | Take upstream and delete the Positron block that no longer has a purpose |

| A High item the user decided to keep in Positron | Implement it inside // --- Start Positron --- / // --- End Positron --- with a comment that explains why |

AUTOMERGE files with positron_blocks>0 merged silently. Read their diff too (git diff HEAD -- <file>): a clean textual merge can still change behavior around a Positron block.

Then run bash $S/check-markers.sh and fix everything it reports.

4. Commit the merge as positron-bot

GIT_AUTHOR_NAME="positron-bot[bot]" GIT_AUTHOR_EMAIL="173392469+positron-bot[bot]@users.noreply.github.com" \
GIT_COMMITTER_NAME="positron-bot[bot]" GIT_COMMITTER_EMAIL="173392469+positron-bot[bot]@users.noreply.github.com" \
git commit -m "vscode-python changes from START to END"

Put everything after this in separate commits under the user's name.

5. Rebuild and verify (commit: "update deps")

In extensions/positron-python:

  1. npm install to regenerate the lockfile. Check whether each npm overrides entry in package.json is still needed (npm ls <pkg>).
  2. npx tsc -p ./ --noEmit. Then, from the repo root, run the TS7 native compiler that Positron CI uses (build/lib/tsgo.ts). It is stricter than the extension's TypeScript 5.x. For example, it rejects an interface key that upstream declares twice. Command: node "$(dirname "$(node -p "require.resolve('@typescript/native/package.json')")")/bin/tsc" --project extensions/positron-python/tsconfig.json --pretty false --noEmit. If it reports errors in upstream code, fence the fix in a Positron block. Then npm run lint and npm run format-check. Fix with npm run format-fix. Never use the repo-root scripts/format.mts, which uses tabs; this extension uses 4 spaces.
  3. npx tsc -p ./ (the unit tests run from out/), then npm run test:unittests. Narrow it with -- --grep while you iterate, and run everything at the end. Only *.unit.test.ts files run here; other *.test.ts files run in CI's extension-host job.
  4. Python: ./scripts/check-python-quality.sh; pytest in python_files/posit; python python_files/tests/run_all.py (CI runs uv run --active python_files/tests/run_all.py) if upstream changed the python_files/ adapters. For the last one, mirror the positron-python-ci.yml job: requirements.txt installed with pip -t python_files/lib/python, then build/test-requirements.txt. Move the old python_files/lib/python to the Trash first: pip -t without --upgrade skips existing package directories and leaves old code next to new metadata.

6. Mirror upstream CI into Positron (commit: "fix ci")

Compare git diff refs/vscode-python/START refs/vscode-python/END -- .github/ with .github/workflows/positron-python-ci.yml (repo root). Port the changes that affect what gets tested: Python or pytest versions, install order, test dependencies, timeouts. Keep the existing action pinning style of the Positron workflow.

7. Dependencies (the remaining checklist items)

8. PR

Draft the PR body as a markdown file in the working directory. Do not post it without asking. Include: the upstream range and issue link, the user's decisions on High items, the MAJOR dependency jumps, the manual validation areas from step 1, and e2e tags (use the positron-pr-helper skill).

9. Full suite run

PR CI runs only the tagged e2e tests. An upstream merge needs a full run as well. The tests run in the private repo posit-dev/positron-builds, through its Full Suite lane (test-full-suite.yml). After the branch is pushed and the PR is open, ask the user, then start it:

gh workflow run test-full-suite.yml --repo posit-dev/positron-builds --ref main \
  -f positron_ref="$(git rev-parse HEAD)" \
  -f run_unit=true

The defaults run every e2e test of each lane and the extension-host suites, and run_unit=true adds the unit suites, so this covers unit, extension host, and e2e on Ubuntu (Electron and Chromium) and Windows, with the test credentials. A failed run posts to Slack (notify_on is failures_only by default). The commit must be pushed, and you give it by its full SHA. The Jupyter and Pyrefly lanes are off by default (run_e2e_jupyter=true, run_e2e_pyrefly=true). The Full Suite lane has no Windows extension-host lane at this time. If step 1 found risk in those areas, say so in the PR. Get the run ID and URL with gh run list --repo posit-dev/positron-builds --workflow test-full-suite.yml --branch main --limit 5 --json databaseId,url,createdAt, and put the URL in the PR description or a PR comment.

The run is not a required PR check, so nothing blocks the merge if it fails. Watch it in the background (gh run watch <id> --exit-status; it takes tens of minutes) and report the result to the user. Do not call the PR ready to merge until the run passes, or until the user has triaged each failure (use the e2e-failure-analyzer skill) as unrelated or fixed.

Common mistakes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.