Skip to content

feat: replace the LeetCode CLI with direct GraphQL/REST APIs - #1028

Open
yanxijian wants to merge 2 commits into
LeetCode-OpenSource:masterfrom
yanxijian:pr/direct-graphql-apis
Open

yanxijian wants to merge 2 commits into
LeetCode-OpenSource:masterfrom
yanxijian:pr/direct-graphql-apis

Conversation

@yanxijian

Copy link
Copy Markdown

Summary

Replace the bundled vsc-leetcode-cli with direct GraphQL/REST calls and modernize the extension for current VS Code. The CLI is effectively unmaintained and forces a Node.js dependency; this change removes it and talks to LeetCode directly, while keeping the upstream package identity and default endpoint (leetcode) for compatibility.

What changed

  • Authentication: cookie-based login stored in VS Code SecretStorage, plus Web Authorization. Local multi-account sessions.
  • Data layer: problem list (paged GraphQL, including LCP/interview IDs), statements, official/top solutions, tags, companies, favorites.
  • Judge: sample/custom tests and submissions via the REST judge endpoints, with polling and formatted runtime/memory.
  • CLI removal: delete leetCodeExecutor, cliSession, cpUtils, wslUtils; remove vsc-leetcode-cli, the Node.js requirement, leetcode.nodePath, and leetcode.useWsl.
  • VS Code modernization: require VS Code 1.90, asWebviewUri + nonce CSP, remove legacy vscode-resource/enableCommandUris/retainContextWhenHidden, add viewsWelcome and a sign-in context key.
  • Localization: English/Simplified Chinese manifest and runtime l10n resources.
  • Engineering: esbuild bundle (dist/extension.js), ESLint, unit tests, Node 20 CI matrix, and smaller VSIX packaging.
  • Docs: README and Chinese README updated for cookie login and the removed Node.js settings; CHANGELOG.md has an Unreleased entry.

Testing

  • npm ci
  • npm run typecheck
  • npm run lint
  • npm test — 6 unit tests (cookie parsing and problem-file generation)
  • npm run package — VSIX builds and installs into an isolated extensions directory
  • Development checks against a live leetcode.cn account covered the problem list, statements, solutions, test/submit, and favorites.

Compatibility notes

  • The package name, publisher, version, and default endpoint remain unchanged; leetcode.cn is selected with Switch Endpoint.
  • This is intentionally a large change. I am happy to split it into smaller PRs (for example, API layer first, then UI/localization) if that is easier to review.

Replace the bundled vsc-leetcode-cli with GraphQL/REST calls for cookie authentication, problems, statements, solutions, tests, submissions, and favorites. Cookies live in SecretStorage, with local multi-account sessions.

Require VS Code 1.90, remove the Node.js, leetcode.nodePath, and leetcode.useWsl requirements, adopt asWebviewUri with a nonce CSP, add esbuild bundling, ESLint, unit tests, a Node 20 CI matrix, and English/Simplified Chinese localization.

Keep the upstream package identity, version, and default endpoint so the change stays reviewable.
Document cookie/Web Authorization login, VS Code 1.90, and the removal of Node.js, leetcode.nodePath, and leetcode.useWsl. Add an Unreleased changelog entry and keep the endpoint default unchanged.
@yanxijian
yanxijian force-pushed the pr/direct-graphql-apis branch from 45a6ea9 to 39c4802 Compare October 21, 2026 12:29

This branch has not been deployed

No deployments
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