用例
四个命令都支持使用Get-Help获取帮助,使用示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| dshweb Start-DshWeb
dshinstall plugin-name -git Install-DshPlugin plugin-name -Git
dshlist dshlist tui Get-DshPlugin
dshremove plugin-name Uninstall-DshPlugin plugin-name -Profile tui
dshremove plugin-name -Confirm:$false
|
(别问为什么前两个没有支持其他Profile,问就是后面那俩是大肥鱼顺手给补上的,前面我自己写的时候没想到)
配置
要求PowerShell版本在5.1及以上,使用 code $PROFILE 使用VSCode打开PowerShell配置文件(类似 ~/.bashrc 的文件)
在文件末尾粘贴以下内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
function Start-DshWeb { [CmdletBinding()] [OutputType([void])] param()
if (-not (Get-Command -Name npx -ErrorAction SilentlyContinue)) { throw "未在 PATH 中找到 npx,请先安装 Node.js (https://nodejs.org/)。" }
Write-Verbose "> npx -y @deepseek-ai/dsh@latest web" npx -y '@deepseek-ai/dsh@latest' web }
function Install-DshPlugin { [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] [OutputType([void])] param( [Parameter(Mandatory, Position = 0)] [ValidateNotNullOrEmpty()] [string]$Name,
[Alias('g', 'github')] [switch]$Git,
[Parameter(ValueFromRemainingArguments)] [string[]]$RemainingArgs )
foreach ($arg in $RemainingArgs) { switch -Regex ($arg) { '^--?git(hub)?$' { $Git = $true; continue } default { Write-Warning "忽略未知参数: $arg" } } }
$pluginSpec = if ($Git) { "github:$Name" } else { $Name }
if ($PSCmdlet.ShouldProcess('DeepSeek Harness', "安装插件: $pluginSpec")) { Write-Verbose "Install from GitHub: $($Git.IsPresent)" if($Git) { Write-Verbose "Installing from GitHub..." } else { Write-Verbose "Installing from NPM..." } Write-Host "> npx -y @deepseek-ai/dsh@latest plugin --profile web add $pluginSpec" -ForegroundColor Cyan
npx -y '@deepseek-ai/dsh@latest' plugin --profile web add $pluginSpec } }
function Get-DshPlugin { [CmdletBinding()] [OutputType([void])] param( [Parameter(Position = 0)] [ValidateNotNullOrEmpty()] [string]$Profile = 'web' )
if (-not (Get-Command -Name npx -ErrorAction SilentlyContinue)) { throw "未在 PATH 中找到 npx,请先安装 Node.js (https://nodejs.org)。" }
Write-Verbose "> npx -y @deepseek-ai/dsh@latest plugin --profile $Profile list"
npx -y '@deepseek-ai/dsh@latest' plugin --profile $Profile list }
function Uninstall-DshPlugin { [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] [OutputType([void])] param( [Parameter(Mandatory, Position = 0)] [ValidateNotNullOrEmpty()] [string]$Name,
[Parameter(Position = 1)] [ValidateNotNullOrEmpty()] [string]$Profile = 'web' )
if (-not (Get-Command -Name npx -ErrorAction SilentlyContinue)) { throw "未在 PATH 中找到 npx,请先安装 Node.js (https://nodejs.org)。" }
if ($PSCmdlet.ShouldProcess('DeepSeek Harness', "在配置文件 $Profile 中移除插件: $Name")) { Write-Host "> npx -y @deepseek-ai/dsh@latest plugin --profile $Profile remove $Name" -ForegroundColor Cyan
npx -y '@deepseek-ai/dsh@latest' plugin --profile $Profile remove $Name } }
Set-Alias -Name dshweb -Value Start-DshWeb -Scope Global -Force -ErrorAction SilentlyContinue Set-Alias -Name dshinstall -Value Install-DshPlugin -Scope Global -Force -ErrorAction SilentlyContinue Set-Alias -Name dshlist -Value Get-DshPlugin -Scope Global -Force -ErrorAction SilentlyContinue Set-Alias -Name dshremove -Value Uninstall-DshPlugin -Scope Global -Force -ErrorAction SilentlyContinue
|