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
4 changes: 3 additions & 1 deletion .github/workflows/auto-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ jobs:
run: |
echo "Vulnerabilities were found but npm audit fix made no changes."
echo "Some vulnerabilities may require a manual semver-major update."
npm audit
# Use || true so non-fixable vulns emit a visible warning without
# failing the job (they require a manual semver-major update).
npm audit || true

# ── Commit, push, PR to dev, then PR to main ──────────────────────────
- name: Commit fix and open PR to dev
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
types: [opened, edited, synchronize, reopened]
pull_request_target:
branches: [main, dev]
types: [opened]
types: [opened, edited, synchronize, reopened]

permissions:
pull-requests: write
Expand Down Expand Up @@ -61,6 +61,9 @@ jobs:
auto-label:
name: Auto Label
runs-on: ubuntu-latest
# Only run under pull_request_target which has a write-access GITHUB_TOKEN.
# pull_request from forks gets a read-only token → 403 on label API.
if: github.event_name == 'pull_request_target'
steps:
- name: Apply label based on PR title prefix
uses: actions/github-script@v9
Expand Down
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A modern, feature-rich LeetCode CLI built with TypeScript.
- 📋 **List problems** - Filter by difficulty, status, tags, and search
- 📖 **Beautiful problem display** - Formatted output with examples and constraints
- 📝 **Generate solution files** - Auto-organized by difficulty and category
- ♻️ **Reset solution files** - Restore an existing local solution to the original stub
- 🧪 **Test solutions** - Run against sample test cases
- 📤 **Submit solutions** - Submit directly to LeetCode
- 📊 **View statistics** - Track your progress
Expand Down Expand Up @@ -63,6 +64,9 @@ leetcode daily
# Pick a problem and generate solution file
leetcode pick 1

# Reset an existing solution back to the original stub
leetcode reset 1

# Test your solution (any format works!)
leetcode test 1 # Problem ID
leetcode test 1.two-sum.java # Filename
Expand Down Expand Up @@ -108,6 +112,7 @@ The CLI keeps command semantics the same and applies site-specific GraphQL queri
| `hint <id>` | Show hints for a problem |
| `pick <id>` | Generate solution file |
| `pick-batch <ids>` | Pick multiple problems |
| `reset <id>` | Reset solution file to original stub |
| `bookmark <action>` | Manage problem bookmarks |
| `note <id>` | Manage problem notes |
| `daily` | Show today's challenge |
Expand All @@ -120,6 +125,7 @@ The CLI keeps command semantics the same and applies site-specific GraphQL queri
| `snapshot <cmd>` | Save and restore solution versions |
| `diff <id>` | Compare solution with past submissions |
| `collab <cmd>` | Collaborative coding with a partner |
| `contest [slug]` | Browse and pick from contest problems |
| `workspace <cmd>` | Manage workspaces for different contexts |
| `config` | View or set configuration |
| `sync` | Sync solutions to Git repository |
Expand Down Expand Up @@ -178,6 +184,15 @@ leetcode pick 175 --lang sql
leetcode pick 1 --no-open
```

### Reset Problem

Reset an existing local solution file back to the original LeetCode stub. This overwrites the file immediately.

```bash
leetcode reset 1
leetcode reset two-sum
```

### Test & Submit

All formats work for both `test` and `submit`:
Expand Down Expand Up @@ -313,6 +328,32 @@ leetcode collab status
leetcode collab leave
```

### Contest Problems

```bash
# Browse contests and select a problem interactively
leetcode contest

# Jump directly to a contest by slug
leetcode contest weekly-contest-401

# Override language for solution generation
leetcode contest weekly-contest-401 -l python3

# Skip opening in editor
leetcode contest --no-open
```

### Reset Solution

```bash
# Reset a solution file back to the original LeetCode stub (by problem ID)
leetcode reset 1

# Reset by problem slug
leetcode reset two-sum
```

### Solution Snapshots

```bash
Expand Down
63 changes: 63 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,47 @@ leetcode random -d medium -t dp --pick --no-open

---

### `leetcode contest [slug]` (alias: `c`)

Browse contests and select a problem to solve.

**Arguments**:

- `[slug]` - Optional contest slug for direct selection (e.g., `weekly-contest-401`)

**Options**:

- `-l, --lang <language>` - Programming language for the solution
- `--no-open` - Do not open file in editor

**How it works**:

- Without a slug: interactively select a contest, then select a problem by order
- With a slug: jumps directly to problem selection within that contest
- Selected problem delegates to the normal solution generation flow
- Opens the file in your configured editor (supports Zed, VS Code, Vim, etc.)

**Examples**:

```bash
# Browse contests and select a problem interactively
leetcode contest
leetcode c

# Jump directly to a contest by slug
leetcode contest weekly-contest-401
leetcode contest c weekly-contest-401

# Override language for solution generation
leetcode contest weekly-contest-401 -l python3
leetcode contest -l java

# Skip opening in editor
leetcode contest --no-open
```

---

## Solving Problems

### `leetcode pick <id>` (alias: `p`)
Expand Down Expand Up @@ -263,6 +304,28 @@ leetcode pick 1 -l cpp --no-open

---

### `leetcode reset <id>`

Reset an existing local solution file back to the original LeetCode stub.

This command overwrites the existing file immediately. It preserves the existing file path and language by detecting the file extension.

**Arguments**:

- `<id>` - Problem ID or slug

**Examples**:

```bash
# By problem ID
leetcode reset 1

# By slug
leetcode reset two-sum
```

---

### `leetcode test <file>` (alias: `t`)

Test solution against sample test cases.
Expand Down
19 changes: 18 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ leetcode config -s leetcode.cn
# Set default work directory
leetcode config -w ~/Development/my-leetcode

# Use Zed to open generated solution files
leetcode config --editor zed

# Set Git repository
leetcode config -r https://github.com/myuser/leetcode-solutions.git
```
Expand All @@ -88,7 +91,7 @@ Config is stored per-workspace in `~/.leetcode/workspaces/<name>/config.json`.
| Key | Description |
| ---------- | ---------------------------------------------------- |
| `lang` | Default language extension (java, python3, sql, etc) |
| `editor` | Command to open files (code, vim, nano) |
| `editor` | Command to open files (code, zed, vim, nano) |
| `workDir` | Directory where solution files are saved |
| `syncRepo` | Remote Git repository URL |
| `site` | LeetCode site (`leetcode.com` or `leetcode.cn`) |
Expand Down Expand Up @@ -117,3 +120,17 @@ You can also manage workspace settings from TUI:
3. Open **Config** (`c`) to edit active workspace defaults.

Both screens use buffered editing (`Enter` to save, `Esc` to cancel).

### Zed

Set the editor command to `zed` to open generated contest and problem files in
Zed:

```bash
leetcode config --editor zed
```

`zed`, `zeditor`, and `zed.exe` are supported across platforms. Zed is launched
in the background with only the generated file path; VS Code-specific flags are
not passed to it. The configured editor takes precedence over the `EDITOR`
environment variable.
50 changes: 50 additions & 0 deletions docs/releases.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,55 @@
# Release Notes

## v3.4.0

> **Release Date**: 2026-07-29
> **Focus**: Contest Navigation + Solution Reset + Zed Editor Support + Security & CI Overhaul

### 🚀 Features

#### Contest Navigation (`leetcode contest [slug]`)

Browse available LeetCode contests and pick contest problems interactively or directly by contest slug.

- Browse global (`leetcode.com`) and China (`leetcode.cn`) contests
- Select contest problems in 1-indexed contest order
- Fully integrated with language selection (`-l/--lang`) and editor launching
- Added shell completions for Fish and Zsh

```bash
leetcode contest # Browse contests interactively
leetcode contest weekly-contest-401 # Open contest by slug directly
```

#### Solution Reset (`leetcode reset <id>`)

Restores an existing solution file back to the original LeetCode code stub.

- Automatically detects solution language from file extension
- Safety snapshot backup (`backup-before-reset-<timestamp>`) created before overwriting
- Validates workspace boundaries to prevent unintended file modifications

```bash
leetcode reset 1 # Reset problem 1 solution
leetcode reset two-sum # Reset by problem slug
```

#### Zed Editor Support

Full support for Zed editor (`zed`, `zeditor`, `zed.exe`) across macOS, Linux, and Windows.

```bash
leetcode config --editor zed
```

### 🔒 Security & Maintenance

- Upgraded `eslint` to `v10.8.0` and `@typescript-eslint` packages to `8.65.0`.
- Fixed all 10 high-severity security vulnerabilities reported by `npm audit` (0 vulnerabilities remaining).
- Fixed `auto-label` permission issue on fork PRs (`pull_request_target` event).

---

## v3.3.0

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