1
0
mirror of https://github.com/hustcer/deepseek-review.git synced 2026-05-13 05:16:05 +08:00

15 Commits
v1.19 ... v1.20

Author SHA1 Message Date
hustcer
90c8878923 Bump to v1.20 2026-01-23 19:53:21 +08:00
Justin Ma
231c2d8432 chore: Update Nushell to 0.110.0 (#196) 2026-01-21 07:50:05 +08:00
hustcer
923ee0f999 deps: Upgrade hustcer/setup-nu to v3.22 2025-12-13 22:42:11 +08:00
Justin Ma
32cffba4d1 deps: Upgrade Nu to 0.109.1 (#195) 2025-12-03 22:34:55 +08:00
Justin Ma
0c001b0ee2 refactor: A better from env parser (#194)
* refactor: A better `from env` parser

* refactor: A better `from env` parser
2025-11-29 22:45:55 +08:00
hustcer
edcd90e48b deps: Upgrade actions/checkout@v6 2025-11-26 23:10:18 +08:00
Justin Ma
dfc4c59c1f fix: Fix from env for .env file parsing (#193)
* fix: Fix `from env` for .env file parsing

* fix: Fix `from env` for .env file parsing

* fix: Fix `from env` for .env file parsing
2025-11-26 23:07:41 +08:00
hustcer
92061e6c82 chore: Update README.md 2025-11-22 23:22:03 +08:00
Justin Ma
3c3f0a3c85 deps: Upgrade hustcer/setup-nu to v3.21 (#192) 2025-10-25 11:13:42 +08:00
Justin Ma
7a87f8adc0 chore: Update nutest to main ref (#191) 2025-10-24 23:06:24 +08:00
Justin Ma
d7b2e3a926 deps: Upgrade Nushell version to 0.108.0 (#190) 2025-10-24 22:51:09 +08:00
hustcer
91ae07bb82 deps: Upgrade hustcer/setup-nu to v3.20 2025-08-25 20:03:18 +08:00
hustcer
d830da6937 deps: Upgrade to actions/checkout@v5 2025-08-25 19:48:24 +08:00
hustcer
885b55dbb0 chore: Update minimum required Nushell version to 0.106.1 2025-08-18 21:16:27 +08:00
hustcer
317d3c92da fix: Make config-check use default value for --config flag 2025-08-13 22:14:52 +08:00
10 changed files with 141 additions and 71 deletions

View File

@@ -37,7 +37,7 @@ jobs:
As a senior Nushell engineer, perform comprehensive script review with focus on:
### 1. Core Requirements:
- Validate Nu 0.90+ compatibility
- Validate Nu 0.100+ compatibility
- Check structured data handling
- Verify pipeline efficiency
- Assess module organization
@@ -55,7 +55,7 @@ jobs:
- Parallel execution opportunities
**Rules:**
- Target Nu 0.90+ features
- Target Nu 0.100+ features
- Highlight data flow vulnerabilities
- Suggest structured data optimizations
- Keep feedback Nu-specific

View File

@@ -42,12 +42,12 @@ jobs:
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Checkout Nutest Repo
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
ref: v1.1.0
ref: main
path: nutest
repository: vyadh/nutest
sparse-checkout: nutest/

View File

@@ -1,6 +1,34 @@
# Changelog
All notable changes to this project will be documented in this file.
## [1.20.0] - 2026-01-23
### Bug Fixes
- Make config-check use default value for --config flag
- Fix `from env` for .env file parsing (#193)
### Miscellaneous Tasks
- Update minimum required Nushell version to 0.110.0
- Update nutest to main ref (#191)
- Update README.md
### Refactor
- A better `from env` parser (#194)
### Deps
- Upgrade to actions/checkout@v5
- Upgrade `hustcer/setup-nu` to v3.20
- Upgrade Nushell version to 0.108.0 (#190)
- Upgrade `hustcer/setup-nu` to v3.21 (#192)
- Upgrade actions/checkout@v6
- Upgrade Nu to 0.109.1 (#195)
- Update Nushell to 0.110.0 (#196)
- Upgrade `hustcer/setup-nu` to v3.22
## [1.19.0] - 2025-07-23
### Bug Fixes

View File

@@ -7,31 +7,31 @@
[中文说明](README.zh-CN.md)
`deepseek-review` also offers seamless integration with DeepSeek models on SiliconCloud. [Sign Up Now](https://cloud.siliconflow.cn/i/rqCdIxzS) to **Claim Your Free 20 Million Tokens** and start exploring its capabilities!
`deepseek-review` offers seamless integration with DeepSeek models on SiliconCloud. [Sign Up Now](https://cloud.siliconflow.cn/i/rqCdIxzS) to **claim your free 20 million tokens** and start exploring its capabilities!
## Features
### GitHub Action
- Automate PR Reviews with DeepSeek via GitHub Action
- Add `skip cr` or `skip review` to PR Title or Body to Disable Code Review in GitHub Actions
- Add `skip cr` or `skip review` to the PR title or body to disable code review in GitHub Actions
- Cross-platform Support: Compatible with GitHub Runners across `macOS`, `Ubuntu`, and `Windows`.
### Local Code Review
- Streaming Output Support for Local Code Review
- Review Remote GitHub PRs Directly from Your Local CLI
- Review Commit Changes with DeepSeek for Any Local Repository by CLI
- Support On-demand Changes Generation via `git show`/`git diff` Command for Further Code Review
- Output Code Review Result to Specified File in Markdown Format
- Cross-platform Compatibility: Designed to function seamlessly across all platforms capable of running [Nushell](https://github.com/nushell/nushell)
- Streaming output support for local code review
- Review remote GitHub PRs directly from your local CLI
- Review commit changes with DeepSeek for any local repository via CLI
- Support on-demand change generation via `git show`/`git diff` commands for further code review
- Output code review results to a specified file in Markdown format
- Cross-platform compatibility: Designed to function seamlessly across all platforms capable of running [Nushell](https://github.com/nushell/nushell)
### Both GH Action & Local
- Support Both DeepSeek's `V3` & `R1` Models
- Fully Customizable: Choose Models, Base URLs, and Prompts
- Supports Self-Hosted DeepSeek Models for Enhanced Flexibility
- Perform Code Reviews for Changes That either Include or Exclude Specific Files
- Support both DeepSeek's `V3` and `R1` models
- Fully customizable: Choose models, base URLs, and prompts
- Support self-hosted DeepSeek models for enhanced flexibility
- Perform code reviews for changes that either include or exclude specific files
## Planned Features
@@ -40,7 +40,7 @@
## Code Review with GitHub Action
### Initiate Code Review When PR was Created
### Initiate Code Review When a PR is Created
Add a GitHub workflow with the following contents:
@@ -82,13 +82,13 @@ jobs:
</details>
When a PR is created, DeepSeek code review will be automatically triggered, and the review results(depend on your prompt) will be posted as comments on the corresponding PR. For example:
When a PR is created, DeepSeek code review will be automatically triggered, and the review results (depending on your prompt) will be posted as comments on the corresponding PR. For example:
- [Example 1](https://github.com/hustcer/deepseek-review/pull/30) with [default prompts](https://github.com/hustcer/deepseek-review/blob/main/action.yaml#L35) & [Run Log](https://github.com/hustcer/deepseek-review/actions/runs/13043609677/job/36390331791#step:2:53).
- [Example 2](https://github.com/hustcer/deepseek-review/pull/68) with [this prompt](https://github.com/hustcer/deepseek-review/blob/eba892d969049caff00b51a31e5c093aeeb536e3/.github/workflows/cr.yml#L32)
### Trigger CR When a Specific Label was Added
### Trigger Code Review When a Specific Label is Added
If you don't want automatic review on PR creation, you can choose to trigger code review by adding a label. For example, create the following workflow:
If you don't want automatic code review on PR creation, you can choose to trigger code review by adding a label. For example, create the following workflow:
```yaml
name: Code Review
@@ -123,12 +123,12 @@ With this setup, DeepSeek code review will not run automatically upon PR creatio
| chat-token | String | Required, DeepSeek API Token |
| model | String | Optional, The model used for code review, defaults to `deepseek-chat` |
| base-url | String | Optional, DeepSeek API Base URL, defaults to `https://api.deepseek.com` |
| max-length | Int | Optional, Maximum length(Unicode width) of the content for review, if the content length exceeds this value, the review will be skipped. Default `0` means no limit. |
| max-length | Int | Optional, Maximum length (Unicode width) of the content for review. If the content length exceeds this value, the review will be skipped. Default `0` means no limit. |
| sys-prompt | String | Optional, System prompt corresponding to `$sys_prompt` in the payload, default value see note below |
| user-prompt | String | Optional, User prompt corresponding to `$user_prompt` in the payload, default value see note below |
| temperature | Number | Optional, The temperature for the model to generate the response, between `0` and `2`, default value `0.3` |
| include-patterns | String | Optional, The comma separated file patterns to include in the code review. No default |
| exclude-patterns | String | Optional, The comma separated file patterns to exclude in the code review. Default to `pnpm-lock.yaml,package-lock.json,*.lock` |
| temperature | Number | Optional, The temperature for the model to generate the response, between `0` and `2`. Default value is `0.3` |
| include-patterns | String | Optional, Comma-separated file patterns to include in the code review. No default |
| exclude-patterns | String | Optional, Comma-separated file patterns to exclude from the code review. Defaults to `pnpm-lock.yaml,package-lock.json,*.lock` |
| github-token | String | Optional, The `GITHUB_TOKEN` secret or personal access token to authenticate. Defaults to `${{ github.token }}`. |
**DeepSeek API Call Payload**:
@@ -154,18 +154,18 @@ With this setup, DeepSeek code review will not run automatically upon PR creatio
> [!NOTE]
>
> You can control the language of the code review results by the language of the
> Prompt. The default Prompt language is currently English. When you use a Chinese
> Prompt, the generated code review results will be in Chinese.
> You can control the language of the code review results through the language of the
> prompt. The default prompt language is currently English. When you use a Chinese
> prompt, the generated code review results will be in Chinese.
## Local Code Review
### Required Tools
To perform code reviews locally(should works for `macOS`, `Ubuntu`, and `Windows`), you need to install the following tools:
To perform code reviews locally (works on `macOS`, `Ubuntu`, and `Windows`), you need to install the following tools:
- [`Nushell`](https://www.nushell.sh/book/installation.html). It is recommended to install the latest versions(min version required: `0.103`).
- The latest version of [`awk`](https://github.com/onetrueawk/awk) or [`gawk`](https://www.gnu.org/software/gawk/) is required, with `gawk` being the preferred choice.
- [`Nushell`](https://www.nushell.sh/book/installation.html). It is recommended to install the latest version (minimum version required: `0.110.0`).
- The latest version of [`awk`](https://github.com/onetrueawk/awk) or [`gawk`](https://www.gnu.org/software/gawk/) is required, with `gawk` being preferred.
- Clone this repository to your local machine, navigate to the repository directory, and run `nu cr -h`. You should see an output similar to the following:
```console
@@ -202,27 +202,27 @@ Parameters:
### Environment Configuration
To perform code review locally, you need to modify the configuration file. The repository already provides a configuration example [`config.example.yml`](https://github.com/hustcer/deepseek-review/blob/main/config.example.yml). Copy it to `config.yml` and modify it according to your actual needs. **Read the comments in the configuration file carefully**, as they explain the purpose of each configuration item.
To perform code reviews locally, you need to modify the configuration file. The repository provides a configuration example [`config.example.yml`](https://github.com/hustcer/deepseek-review/blob/main/config.example.yml). Copy it to `config.yml` and modify it according to your needs. **Read the comments in the configuration file carefully**, as they explain the purpose of each configuration item.
> [!WARNING]
>
> The `config.yml` configuration file is **only used locally** and will not be utilized in GitHub Workflow. **Sensitive information** in this file should be properly secured and **never committed** to the code repository.
> The `config.yml` configuration file is **only used locally** and will not be utilized in GitHub Workflows. **Sensitive information** in this file should be properly secured and **never committed** to the code repository.
>
**Create Command Alias**
**Create a Command Alias**
For convenience in performing code review across any local repository, create a command alias. For example:
For convenience when performing code reviews across any local repository, create a command alias. For example:
```sh
# For Nushell: Modify config.nu and add:
alias cr = nu /absolute/path/to/deepseek-review/cr --config /absolute/path/to/deepseek-review/config.yml
# Modify ~/.zshrc for zsh or ~/.bashrc for bash or ~/.config/fish/config.fish for fish and add:
# Modify ~/.zshrc for zsh, ~/.bashrc for bash, or ~/.config/fish/config.fish for fish and add:
alias cr="nu /absolute/path/to/deepseek-review/cr --config /absolute/path/to/deepseek-review/config.yml"
# After sourcing the modified profile, use `cr` for code review
# After sourcing the modified profile, use `cr` for code reviews
# For Windows powershell users please set cr alias by editing $PROFILE and add:
# For Windows PowerShell users, set the cr alias by editing $PROFILE and add:
function cr {
nu D:\absolute\path\to\deepseek-review\cr --config D:\absolute\path\to\deepseek-review\config.yml @args
}
@@ -235,20 +235,20 @@ function cr {
To review a local repository:
- Navigate to the Git repository directory.
- Use the `cr` command to review current modifications, provided that `config.yml` is correctly configured.
- Use the `cr` command to review current modifications, provided that `config.yml` is correctly configured.
**Usage Examples**
```sh
# Perform code review on the `git diff` changes in current directory
# Perform code review on the `git diff` changes in the current directory
cr
# Perform code review on the `git diff f536acc` changes in current directory
# Perform code review on the `git diff f536acc` changes in the current directory
cr --diff-from f536acc
# Perform code review on the `git diff f536acc` changes and output result to review.md
# Perform code review on the `git diff f536acc` changes and output the result to review.md
cr --diff-from f536acc --output review.md
# Perform code review on the `git diff f536acc 0dd0eb5` changes in current directory
# Perform code review on the `git diff f536acc 0dd0eb5` changes in the current directory
cr --diff-from f536acc --diff-to 0dd0eb5
# Review the changes in current directory using the `--patch-cmd` flag
# Review the changes in the current directory using the `--patch-cmd` flag
cr --patch-cmd 'git diff head~3'
cr -c 'git show head~3'
cr -c 'git diff 2393375 71f5a31'
@@ -261,17 +261,17 @@ cr -c 'git diff 2393375 71f5a31 :!nu/*'
When reviewing a remote GitHub PR locally:
- Always specify the PR number via `--pr-number`
- Always specify the PR number via `--pr-number`.
- Use `--repo` to indicate the target repository (e.g., `hustcer/deepseek-review`). If `--repo` is omitted, the tool reads `settings.default-github-repo` from `config.yml`.
**Usage Examples**
```sh
# Perform code review on PR #31 in the remote DEFAULT_GITHUB_REPO repo
# Perform code review on PR #31 in the remote DEFAULT_GITHUB_REPO repository
cr --pr-number 31
# Perform code review on PR #31 in the remote hustcer/deepseek-review repo
# Perform code review on PR #31 in the remote hustcer/deepseek-review repository
cr --pr-number 31 --repo hustcer/deepseek-review
# Perform code review on PR #31 and exclude changes of pnpm-lock.yaml
# Perform code review on PR #31 and exclude changes in pnpm-lock.yaml
cr --pr-number 31 --exclude pnpm-lock.yaml
```

View File

@@ -161,7 +161,7 @@ DeepSeek 接口调用入参:
在本地进行代码审查,支持 `macOS`, `Ubuntu` & `Windows` 不过需要安装以下工具:
- [`Nushell`](https://www.nushell.sh/book/installation.html), 建议安装最新版本(最低版本 `0.103`)
- [`Nushell`](https://www.nushell.sh/book/installation.html), 建议安装最新版本(最低版本 `0.110.0`)
- [`awk`](https://github.com/onetrueawk/awk) 或者 [`gawk`](https://www.gnu.org/software/gawk/) 的最新版版本,优先推荐 `gawk`
- 接下来只需要把本仓库代码克隆到本地,然后进入仓库目录执行 `nu cr -h` 即可看到类似如下输出:

View File

@@ -58,9 +58,9 @@ runs:
using: 'composite'
steps:
- name: Setup Nu
uses: hustcer/setup-nu@v3.19
uses: hustcer/setup-nu@v3.22
with:
version: 0.106.0
version: 0.110.0
- name: DeepSeek Code Review
shell: nu {0}

View File

@@ -1,7 +1,7 @@
{
"name": "deepseek-review",
"version": "1.19.0",
"actionVer": "v1.19",
"version": "1.20.0",
"actionVer": "v1.20",
"author": "hustcer",
"license": "MIT",
"github": "https://github.com/hustcer/deepseek-review",

View File

@@ -81,22 +81,63 @@ export def check-nushell [--debug] {
}
# Converts a .env file into a record
# may be used like this: open .env | load-env
# works with quoted and unquoted .env files
export def 'from env' []: string -> record {
lines
| split column '#' # remove comments
| get column1
| parse '{key}={value}'
| update value {
str trim # Trim whitespace between value and inline comments
| str trim -c '"' # unquote double-quoted values
| str trim -c "'" # unquote single-quoted values
| str replace -a "\\n" "\n" # replace `\n` with newline char
| str replace -a "\\r" "\r" # replace `\r` with carriage return
| str replace -a "\\t" "\t" # replace `\t` with tab
}
| transpose -r -d
# May be used like this: open .env | load-env
# Works with quoted and unquoted .env files
export def "from env" []: string -> record {
let input = $in
# Process escape sequences in double-quoted values using str replace chain
# Use NUL char as placeholder to avoid replacement conflicts
let process_escapes = {|content: string|
$content
| str replace -a '\\' (char nul) # Placeholder for \\ to avoid conflicts
| str replace -a '\n' (char nl)
| str replace -a '\r' (char cr)
| str replace -a '\t' (char tab)
| str replace -a '\"' '"'
| str replace -a (char nul) '\' # Restore \\ to single \
}
# Parse double-quoted value with escape sequence support
let parse_double_quoted = {|val: string|
let matched = ($val | parse -r '^"(?P<content>(?:[^"\\]|\\.)*)"')
if ($matched | is-empty) { $val | str trim -c '"' } else { do $process_escapes $matched.0.content }
}
# Parse single-quoted value (no escape processing)
let parse_single_quoted = {|val: string|
let matched = ($val | parse -r "^'(?P<content>[^']*)'")
if ($matched | is-empty) { $val | str trim -c "'" } else { $matched.0.content }
}
# Parse unquoted value: handle escaped hash (\#) and strip inline comments
let parse_unquoted = {|val: string|
$val
| str replace -a '\#' (char nul) # Placeholder for \#
| split row '#' # Split by comment delimiter
| first # Take content before first #
| str replace -a (char nul) '#' # Restore \# to #
| str trim
}
# Parse value based on its format
let parse_value = {|val: string|
match $val {
$v if ($v | str starts-with '"') => { do $parse_double_quoted $v }
$v if ($v | str starts-with "'") => { do $parse_single_quoted $v }
_ => { do $parse_unquoted $val }
}
}
let parsed = $input | lines
| str trim
| compact -e
| where {|line| not ($line | str starts-with '#') }
| parse "{key}={value}"
| update key {|row| $row.key | str trim | str replace -r '^export\s+' '' }
| update value {|row| do $parse_value ($row.value | str trim) }
if ($parsed | is-empty) { {} } else { $parsed | transpose -r -d -l }
}
# Compact the record by removing empty columns

View File

@@ -91,7 +91,8 @@ def check-models [options: record] {
}
# Check if the config.yml file exists and if it's valid
export def config-check [--config: string = $SETTING_FILE] {
export def config-check [--config: string] {
let config = $config | default $SETTING_FILE
file-exists $config
let options = open $config
check-prompts $options

View File

@@ -132,7 +132,7 @@ def install-gawk-for-actions [] {
Invoke-Expression (New-Object System.Net.WebClient).DownloadString("https://get.scoop.sh")
$env:Path = "$env:USERPROFILE\scoop\shims;" + $env:Path; scoop update; scoop install gawk
'# | complete | get stdout | print
let awk_bin = $'($nu.home-path)/scoop/shims/gawk.exe'
let awk_bin = $'($nu.home-dir)/scoop/shims/gawk.exe'
let version = get-awk-ver $awk_bin
{ awk_bin: $awk_bin, version: $version }
}