Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,35 +118,3 @@ jobs:
await github.rest.issues.addLabels({
owner, repo, issue_number: pr, labels: [label],
});

# ── 4. Post a helpful checklist comment on first-time PR open ─────────────
welcome-comment:
name: Post Contribution Checklist
runs-on: ubuntu-latest
if: github.event.action == 'opened'
steps:
- name: Post checklist comment
uses: actions/github-script@v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const author = context.payload.pull_request.user.login;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: `Thanks for the PR, @${author}! 🎉

Before this gets reviewed, please make sure the following are checked:

- [ ] Tests pass locally (\`npm test\`)
- [ ] Type check passes (\`npm run typecheck\`)
- [ ] Lint passes (\`npm run lint\`)
- [ ] New features include tests
- [ ] Documentation updated if needed
- [ ] PR targets the \`dev\` branch (not \`main\`)

> See [CONTRIBUTING.md](https://github.com/night-slayer18/leetcode-cli/blob/dev/CONTRIBUTING.md) for full guidelines.

The CI pipeline will also run build, test, lint, and typecheck automatically.`
});
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ The CLI keeps command semantics the same and applies site-specific GraphQL queri
| `pick-batch <ids>` | Pick multiple problems |
| `reset <id>` | Reset solution file to original stub |
| `bookmark <action>` | Manage problem bookmarks |
| `note <id>` | Manage problem notes |
| `note <id\|name>` | Manage problem notes |
| `daily` | Show today's challenge |
| `random` | Get a random problem |
| `test <id\|file>` | Test solution against sample cases |
Expand Down Expand Up @@ -191,6 +191,9 @@ Reset an existing local solution file back to the original LeetCode stub. This o
```bash
leetcode reset 1
leetcode reset two-sum

# Reset for a specific language when multiple solutions exist
leetcode reset 1 --lang python3
```

### Test & Submit
Expand All @@ -202,6 +205,10 @@ All formats work for both `test` and `submit`:
leetcode test 20
leetcode submit 20

# Filter by language when multiple solutions exist
leetcode test 20 --lang python3
leetcode submit 20 --lang python3

# Using filename
leetcode test 20.valid-parentheses.java
leetcode submit 20.valid-parentheses.java
Expand Down Expand Up @@ -262,8 +269,9 @@ leetcode pick-batch 1 2 3 -l python3
leetcode bookmark add 1
leetcode bookmark list

# Keep personal notes
# Keep personal notes (by problem ID or name)
leetcode note 1 edit
leetcode note two-sum edit
```

### User Statistics
Expand Down Expand Up @@ -360,6 +368,9 @@ leetcode reset two-sum
# Save current approach
leetcode snapshot save 1 "brute-force"

# Save for a specific language
leetcode snapshot save 1 "optimized" --lang python3

# Try a new approach, then save
leetcode snapshot save 1 "hash-map"

Expand All @@ -379,6 +390,9 @@ leetcode snapshot restore 1 brute-force
# Compare with last accepted submission
leetcode diff 1

# Compare for a specific language
leetcode diff 1 --lang python3

# Show unified diff (line-by-line changes)
leetcode diff 1 --unified

Expand Down
31 changes: 31 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ This command overwrites the existing file immediately. It preserves the existing

- `<id>` - Problem ID or slug

**Options**:

- `-l, --lang <language>` - Only match solution files in this language (default: configured language)

**Examples**:

```bash
Expand All @@ -322,6 +326,9 @@ leetcode reset 1

# By slug
leetcode reset two-sum

# Reset the Python solution when multiple languages exist
leetcode reset 1 -l python3
```

---
Expand All @@ -338,6 +345,7 @@ Test solution against sample test cases.

- `-c, --testcase <testcase>` - Custom test case input
- `-V, --visualize` - Visual output for data structures
- `-l, --lang <language>` - Only match solution files in this language when testing by problem ID (default: configured language)

**Three Ways to Test**:

Expand Down Expand Up @@ -391,6 +399,10 @@ Submit solution to LeetCode.

- `<file>` - Problem ID, filename, or file path

**Options**:

- `-l, --lang <language>` - Only match solution files in this language when submitting by problem ID (default: configured language)

**Three Ways to Submit**:

```bash
Expand Down Expand Up @@ -664,6 +676,10 @@ Upload your current solution to the collaboration room.

**Usage**: `leetcode collab sync`

**Options**:

- `-l, --lang <language>` - Only match solution files in this language (default: configured language)

Reads your local solution file and syncs it to the cloud so your partner can see it.

---
Expand All @@ -674,6 +690,10 @@ Compare your solution with your partner's solution.

**Usage**: `leetcode collab compare`

**Options**:

- `-l, --lang <language>` - Only match solution files in this language (default: configured language)

Displays both solutions sequentially with line numbers for easy comparison.

---
Expand Down Expand Up @@ -709,12 +729,17 @@ Save current solution as a snapshot.
- `<id>` - Problem ID
- `[name]` - Optional snapshot name (defaults to `snapshot-N`)

**Options**:

- `-l, --lang <language>` - Only match solution files in this language (default: configured language)

**Examples**:

```bash
leetcode snapshot save 1 "brute-force"
leetcode snapshot save 1 "hash-map-approach"
leetcode snapshot save 1 # auto-named "snapshot-1"
leetcode snapshot save 1 -l python3
```

---
Expand Down Expand Up @@ -746,11 +771,16 @@ Restore a previously saved snapshot. Auto-creates backup of current code.
- `<id>` - Problem ID
- `<snapshot>` - Snapshot ID or name

**Options**:

- `-l, --lang <language>` - Only match solution files in this language (default: configured language)

**Examples**:

```bash
leetcode snapshot restore 1 1 # By ID
leetcode snapshot restore 1 brute-force # By name
leetcode snapshot restore 1 1 -l java
```

---
Expand Down Expand Up @@ -806,6 +836,7 @@ Compare your current solution with past submissions or other files.
- `-s, --submission <id>` - Compare with specific submission ID
- `-f, --file <path>` - Compare with a local file
- `-u, --unified` - Show unified diff (line-by-line changes)
- `-l, --lang <language>` - Only match solution files in this language (default: configured language)

**Default**: Shows both solutions one below the other with line numbers and summary.

Expand Down
59 changes: 59 additions & 0 deletions docs/releases.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,64 @@
# Release Notes

## v3.6.0

> **Release Date**: 2026-10-14
> **Focus**: Target Language Option (`--lang`) for Solution Locators, Unified Problem Identifier Resolution, and Dependency Security Fixes

### 🚀 Features

#### Target Language Option for ID-Based Commands ([#56](https://github.com/night-slayer18/leetcode-cli/issues/56))

Added the `-l, --lang <language>` option across all commands that locate solution files by problem ID (`test`, `submit`, `diff`, `snapshot`, `collab`, and `reset`):

- **Multi-language support**: If your workspace contains solutions in multiple languages (e.g. `1.two-sum.ts` and `1.two-sum.py`), `--lang` allows targeting a specific language solution without typing the full relative path.
- **Language validation**: Verifies user input against supported languages upfront, reporting friendly errors (e.g., `Unsupported language: foo`) before executing file lookups or network requests.
- **Aliases supported**: Supports standard aliases (e.g. `py` for `python3`, `ts` for `typescript`, `js` for `javascript`, `cpp` for `c++`, `cs` for `csharp`).

```bash
# Test or submit a specific language implementation
leetcode test 1 --lang python3
leetcode submit 1 --lang cpp

# Compare, snapshot, or reset a specific language solution
leetcode diff 1 --lang java
leetcode snapshot save 1 "optimized" --lang python3
leetcode reset 1 --lang typescript
```

#### Unified Problem Identifier Resolution ([#50](https://github.com/night-slayer18/leetcode-cli/pull/50))

Consolidated problem ID and title slug resolution into shared resolver utilities:

- **Shared resolver**: Extracted `resolveProblem`, `resolveProblemIdentifier`, and `isProblemNotFoundError` in `src/utils/problem-resolver.ts`.
- **Eliminated raw Zod schema validation errors**: When querying an unknown or mistyped slug, commands previously threw `expected object, received null`. They now report a clean, user-friendly message (`Problem "<slug>" not found`).
- **Consistent behavior across commands**: Unified across `show`, `hint`, `submissions`, `timer`, `pick`, `notes`, and `reset`.

#### Title Slug Support for Notes Command ([#50](https://github.com/night-slayer18/leetcode-cli/pull/50))

`leetcode notes <idOrName>` now accepts a problem name (slug) in addition to numeric IDs:

- Resolves the problem slug through the LeetCode API to associate the note with the problem's frontend ID.
- Avoids redundant API calls by passing the fetched problem details directly to note templates.

```bash
leetcode notes two-sum
leetcode notes two-sum edit
```

### 🔒 Security

- **Automated dependency audit fix**: Resolved two high-severity vulnerabilities (`http-cache-semantics` [GHSA-ch52-4w7c-c8xp](https://github.com/advisories/GHSA-ch52-4w7c-c8xp) and `source-map-js` [GHSA-68fv-2mgg-jv7q](https://github.com/advisories/GHSA-68fv-2mgg-jv7q)).

### 🧪 Testing

- Added unit tests for shared problem resolver in `src/__tests__/utils/problem-resolver.test.ts` (17 tests).
- Added unit tests for solution file lookup with language filter in `src/__tests__/utils/file-utils.test.ts`.
- Added regression tests for `--lang` support in `src/__tests__/commands/diff.test.ts`, `src/__tests__/commands/snapshot.test.ts`, and `src/__tests__/commands/reset.test.ts`.
- All 385 tests passing across 40 test suites.

---

## v3.5.2

> **Release Date**: 2026-09-07
Expand Down
Loading
Loading