Preface¶
DeepSeek Harness (DSH) adopts the “everything is a plugin” philosophy, extending its core capabilities through plugins. When practicing LeetCode problems and organizing notes, developers often face challenges such as scattered problem sets, inconvenient code execution, inconsistent note formatting, and time-consuming review and organization. The LeetCode Notebook plugin integrates practice, code execution, and Markdown notes into a single page, making LeetCode practice and review more centralized, traceable, and manageable.
Plugin Overview¶
- Name: dsh-leetcode-notebook (GitHub title: LeetCode Notebook)
- Maintainer: wxing2008666
- Category: Web Tool
- Stars: 0
- Description: dsh-leetcode-notebook, dsh plugin for leetcode
- Highlight: Category: Web Tool
This plugin provides DSH with an online LeetCode practice environment and a Markdown review notebook: it fetches problem lists or Hot 100 in real time from leetcode.cn, allows code execution within the page, and generates editable Markdown notes from successful solutions. It supports viewing, filtering, searching, and AI Q&A within a local directory.
Core Features¶
- Problem Set Fetching: Fetches the full problem list or Hot 100 from leetcode.cn in real time. Supports searching by problem number or title, as well as filtering by category and difficulty. Since Hot 100 contains only 100 problems, combined filters may yield empty results; you can switch using the “Search in Full Problem Set” button.
- Code Execution:
- Local execution: No login required. Supports JavaScript / Python3. Executes code and displays the return value only; does not judge correctness.
- Official judge: Requires a LeetCode login session. Calls the
interpret_solutionAPI to return official judging results. - Add to Review: After a successful run, click “Add to Review,” enter your approach and complexity. The plugin saves the problem description, code, and category as a Markdown file in the user-specified directory. If a note already exists for the same problem number, the new solution is appended as an additional method.
- Review Library: The page reads
.mdfiles from the local directory, supporting viewing, editing the raw content, saving, and deleting. Supports filtering by Hot 100 / category / difficulty and keyword search. Files remain in their original directory; category and difficulty are only used for page grouping and do not move or rename files. - Markdown Compatibility: Simply copy well-formatted
.mdfiles into the directory to display them. The parser is compatible with common conventions both with and without YAML front matter. - AI Q&A: Based on the current note, calls DSH’s current default model to answer questions. The AI panel supports two modes: “Q&A” and “Edit Note.” The latter only writes to the file after user confirmation.
- Configurable: The review directory and LeetCode login Cookie can both be modified in the page settings.
Installation & Enablement¶
- Prerequisites: DSH
0.2.x, Node.js 22+. - Install from a local directory:
1. Open DSH’s Plugins page.
2. Select Add plugin and choose the directory containingpackage.json.
3. Enable LeetCode Notebook.
4. Click the notebook icon in the left sidebar to open the page. - Command-line install (local directory):
plugin_manager install_bundle target=<this-directory>
- Command-line install (npm package, after publishing):
plugin_manager install_bundle target=dsh-leetcode-notebook
- Install from GitHub:
git clone https://github.com/wxing2008666/dsh-leetcode-notebook.git
Then select the cloned directory in DSH’s Plugins → Add plugin.
- Plugin Marketplace: Once the plugin is added to the awesome-dsh-plugin directory, it can be searched and installed from the plugin marketplace.
Typical Usage¶
Practice¶
- Switch between Practice / Review at the top of the page.
- Toggle between Full Problem Set and Hot 100 on the left side.
- Search by problem number or title; filter via the category dropdown; difficulty can be layered on top.
- After selecting a problem, the right side displays the problem description and code editor.
- Select a language, choose a sample or enter a custom test case, and click Run.
Execution mode descriptions:
| Mode | Login Required | Description |
|---|---|---|
| Local Execution | No | Executes code and displays the return value only; does not judge correctness. Supports JavaScript / Python3 |
| Official Judge | Yes | Calls LeetCode’s interpret_solution API and returns official judging results |
Local execution spawns a short-lived subprocess in a temporary directory with a timeout set; it does not execute user code directly in the DSH main process.
Adding to Review¶
After a successful run, click “Add to Review” and fill in your approach and complexity. The plugin saves the current problem’s description, code, and category as a Markdown file, for example:
0001-two-sum.md
If a note already exists for the same problem number, the new code is appended as an additional method and will not overwrite existing content.
Review¶
- View all
.mdfiles in the directory on the Review page. - The page groups by “Primary Category → Difficulty,” which is collapsible; the primary category is the first category of the problem.
- Supports filtering by Hot 100, category, and difficulty, as well as keyword search.
- Click “Edit” to directly edit the raw Markdown; saving writes back to disk.
- Click “AI Q&A” to open a conversation panel on the right. You can ask for code explanations, bug finding, better solutions, etc.
- The page refreshes the directory every 15 seconds and when the window regains focus; changes saved by an external editor appear automatically (edits in progress will not overwrite the draft).
Review Directory¶
Default directory: ~/LeetCode-Notes (on Windows, typically C:\Users\<you>\LeetCode-Notes).
Modify in “Settings → General.” The directory is created automatically if it does not exist. All read/write operations are restricted to this directory; .. and absolute paths are rejected. Category and difficulty are only used for page grouping and do not move or rename files, to avoid disrupting file paths, Obsidian backlinks, and Git history.
LeetCode Login (Optional)¶
Only required for the official judge. Enter LEETCODE_SESSION and csrftoken in the settings (obtained from LeetCode’s Cookies via browser developer tools). The Cookie is stored locally at ~/.dsh/dsh-leetcode-notebook/config.json. The page only reads “whether it is configured” and does not access the Cookie value. Clearing login removes the locally stored value.
AI Q&A¶
AI uses DSH’s current default model; no API Key needs to be entered in the plugin. If the default model has no credentials or is unavailable, the settings page will display the specific reason. Note content is sent to the model provider along with the question; the plugin does not write notes to any other location.
The AI panel has two modes:
- Q&A: Answers only; does not modify files.
- Edit Note: Tell the AI what to change (e.g., “Complete the approach and complexity for each method”). The AI returns partial modification operations, listing the changes in a preview. The file is written only after you confirm “Apply to Note.”
Partial modifications only replace the specified sections. Fields in the front matter such as id/title/slug/categories/tags/source, the problem description, other methods, and code are all preserved. A full replacement is only permitted when explicitly requesting “overwrite the entire note / rewrite the whole thing.” The write action is confirmed by the user; notes are never silently modified in the background.
Markdown Note Format¶
Recommended format (this is the shape of files generated by the plugin):
---
id: "1"
title: "两数之和"
slug: "two-sum"
difficulty: "简单"
categories:
- 数组
- 哈希表
tags: 数据结构与算法-leetcode
hot100: true
updatedAt: "2026-11-21T10:00:00.000Z"
source: "https://leetcode.cn/problems/two-sum/"
---
# 1. 两数之和
> 难度:简单 | 分类:数组、哈希表 | Hot 100:是
## 题目描述
给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出和为目标值的两个整数,并返回它们的数组下标。
## 解题方法
### 方法一
**思路**:用哈希表记录已经遍历过的值和下标。
```javascript
var twoSum = function(nums, target) {
const map = new Map();
for (let i = 0; i < nums.length; i += 1) {
if (map.has(target - nums[i])) return [map.get(target - nums[i]), i];
map.set(nums[i], i);
}
};
复杂度分析:时间复杂度 O(n),空间复杂度 O(n)。
It is also compatible with notes that have no front matter: the title is read from the first `#` heading, and `分类:` (Category), `难度:` (Difficulty), `Hot100:` should be written within the first 80 lines of the body. Multiple methods are separated by `### 方法一:…`, `### 方法二:…`, etc. UTF-8 and Windows CRLF line endings are supported; files saved from tools like VS Code or Obsidian do not need to be converted to LF.
# Settings & Data Locations
| Content | Location |
| --- | --- |
| Plugin settings, Cookie | `~/.dsh/dsh-leetcode-notebook/config.json` |
| Review notes | User-selected directory, default `~/LeetCode-Notes` |
| Page UI preferences / AI conversation cache | Browser localStorage (current browser only) |
# Privacy & Boundaries
- Problem lists and problem content are fetched from LeetCode in real time; access to the corresponding site is required.
- The official judge sends your code and test cases to LeetCode, consistent with submitting on the web.
- AI Q&A sends the current note and question to the model provider configured in DSH.
- Local execution is not a secure sandbox: it executes code written by the user themselves. The plugin uses a subprocess + timeout to mitigate risk, but untrusted code should not be executed.
- Notes are plain files; the delete operation removes the disk file directly with no recycle bin.
# Known Limitations
- leetcode.cn's APIs may change; if the problem list or judging fails, first confirm the site is accessible.
- Local execution only supports JavaScript / Python3 and does not verify answer correctness.
- Interactive problems, design problems, and other problems without a standard entry function will be rejected by local execution; the official judge is recommended.
- The `interpret_solution` API for the official judge depends on a login session and has not been tested with real accounts in the repository's CI.
- Browser end-to-end testing of the page UI requires an authenticated DSH page; the repository's CI only performs syntax checks, Host unit tests, and packaging checks.
# Development & Testing
- `npm run check`: Runs `node --check` for syntax validation.
- `npm test`: Runs smoke tests for Host, routing, AI, and judging parsing (does not access LeetCode).
- `npm pack --dry-run`: Packaging check.
Directory structure:
```text
index.js Host entry point
host/ LeetCode / Notes / Local execution / AI / Routing
client.js Page bundle (loaded by DSH Client loader)
locale/ Plugin manager display strings
docs/ Documentation and preview images
scripts/smoke.mjs Host tests
Publishing & Indexing¶
- GitHub repository: https://github.com/wxing2008666/dsh-leetcode-notebook
- npm package name:
dsh-leetcode-notebook - npm publish command:
npm login
npm run check
npm test
npm publish --access public
prepublishOnly runs syntax checks, unit tests, and repository metadata checks again.
- Plugin Marketplace: The marketplace directory comes from awesome-dsh-plugin. You need to add a plugin entry to that repository and submit a PR; after merging, awesome-dsh-plugin.com and the DSH plugin marketplace will automatically index it. Do not submit plugin entries to the dsh-market/dsh-market repository.
Use Cases & Cautions¶
- Suitable for developers who need to practice LeetCode online and integrate practice and review notes within DSH.
- The plugin runs with the current DSH process privileges; it is recommended to read the source code and license before installing.
- Local execution does not provide a secure sandbox; do not execute untrusted code.
- Note deletion is a direct disk file removal with no recycle bin.
Summary¶
The LeetCode Notebook plugin unifies LeetCode practice, code execution, and Markdown note management in a single page, providing a complete workflow from problem set fetching, code execution, note generation, to review and AI Q&A. It is compatible with existing Markdown notes, supports custom directories, and integrates well with tools like Obsidian and Git.
- Plugin directory page: https://www.skillhub.cn/plugins/wxing2008666/dsh-leetcode-notebook
- GitHub repository: https://github.com/wxing2008666/dsh-leetcode-notebook