dsh-ide-window 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ - insert:
2
+ - id: dsh-ide-window
3
+ name: 'dsh-ide-window'
4
+ config: {}
@@ -0,0 +1,209 @@
1
+ # Turn code navigation (LSP) on for dsh-ide-window — Windows.
2
+ #
3
+ # .\enable-navigation.ps1 # packages + server download + patch lines
4
+ # .\enable-navigation.ps1 -NoDownload # skip the server download (already have it)
5
+ # .\enable-navigation.ps1 -Profile web # another profile
6
+ #
7
+ # Safe to re-run. Only writes under %USERPROFILE%\.dsh (profile, lsp-bin,
8
+ # lsp-data); the DSH application itself is never modified.
9
+ #
10
+ # If PowerShell refuses to run this file ("execution policy"), start it with:
11
+ # powershell -ExecutionPolicy Bypass -File .\enable-navigation.ps1
12
+ param(
13
+ [string]$Profile = 'desktop',
14
+ [switch]$NoDownload
15
+ )
16
+ $ErrorActionPreference = 'Stop'
17
+
18
+ # A window that flashes and closes hides the reason. Every terminating error is
19
+ # printed with its source, and the console waits for a key before exiting.
20
+ trap {
21
+ Write-Host ''
22
+ Write-Host "安装失败:$($_.Exception.Message)" -ForegroundColor Red
23
+ if ($_.InvocationInfo -and $_.InvocationInfo.PositionMessage) {
24
+ Write-Host $_.InvocationInfo.PositionMessage -ForegroundColor DarkYellow
25
+ }
26
+ if ([Environment]::UserInteractive -and $Host.Name -ne 'ServerRemoteHost') {
27
+ Write-Host '按回车键退出…' -ForegroundColor Yellow
28
+ [void](Read-Host)
29
+ }
30
+ exit 1
31
+ }
32
+
33
+ $lspVersion = '0.2.2-rc.3'
34
+ $packages = @("@deepseek-ai/dsh-lsp@$lspVersion", "@deepseek-ai/dsh-lsp-stdio@$lspVersion")
35
+
36
+ # JetBrains publishes the server per platform under the same build. The CDN host
37
+ # only serves signed URLs, so the download always goes through
38
+ # download.jetbrains.com.
39
+ $build = '271.2085.0'
40
+ $arm = $env:PROCESSOR_ARCHITECTURE -eq 'ARM64'
41
+ $archiveName = if ($arm) { "intellij-server-$build-aarch64.win.zip" } else { "intellij-server-$build.win.zip" }
42
+ $archiveUrl = "https://download.jetbrains.com/language-server/intellij-server/$build/$archiveName"
43
+
44
+ $dshHome = if ($env:DSH_HOME) { $env:DSH_HOME } else { Join-Path $env:USERPROFILE '.dsh' }
45
+ $profileDir = Join-Path $dshHome "profiles\$Profile"
46
+ $lspBin = Join-Path $dshHome 'lsp-bin'
47
+ $lspData = Join-Path $dshHome 'lsp-data\intellij-server'
48
+
49
+ function Step([string]$Text) { Write-Host "`n==> $Text" }
50
+ # `exit` would close the console when the script runs through `irm | iex`, which
51
+ # looks like a window that flashes and disappears. Throwing keeps the window and
52
+ # prints the reason.
53
+ function Fail([string]$Text) {
54
+ Write-Host "错误:$Text" -ForegroundColor Red
55
+ throw "dsh-ide-window: $Text"
56
+ }
57
+
58
+ if (-not (Test-Path (Join-Path $profileDir 'package.json'))) {
59
+ Fail "profile ${Profile}还没有初始化:先启动一次 DSH 再重跑。"
60
+ }
61
+ # The copy DSH ships comes first: the profile was installed by that exact pnpm,
62
+ # and a different major version uses a different store directory — pnpm then
63
+ # refuses with ERR_PNPM_UNEXPECTED_STORE.
64
+ $pnpmCommand = $null
65
+ $pnpmArgs = @()
66
+ $runtime = Join-Path $dshHome 'dsh-runtimes\dsh-primary-runtime\dependencies'
67
+ $nodeExe = Join-Path $runtime 'node\node.exe'
68
+ $pnpmCjs = Join-Path $runtime 'pnpm\bin\pnpm.cjs'
69
+ if ((Test-Path $nodeExe) -and (Test-Path $pnpmCjs)) {
70
+ $pnpmCommand = $nodeExe
71
+ $pnpmArgs = @($pnpmCjs)
72
+ } else {
73
+ $onPath = Get-Command pnpm -ErrorAction SilentlyContinue
74
+ if ($onPath) { $pnpmCommand = $onPath.Source }
75
+ }
76
+ if (-not $pnpmCommand) { Fail '需要 pnpm:npm i -g pnpm(也可以先启动一次 DSH,它会自带一份 pnpm)。' }
77
+ $pnpmVersion = (& $pnpmCommand @pnpmArgs --version 2>$null | Out-String).Trim()
78
+ Write-Host " pnpm:$pnpmCommand $pnpmVersion"
79
+
80
+ # ---- 1. pipeline packages ---------------------------------------------------
81
+
82
+ Step "安装 LSP 管道包($lspVersion)"
83
+
84
+ # Run pnpm with its output captured: the npm error code (a store mismatch, a
85
+ # blocked registry, a missing version) is the only useful clue, and it was being
86
+ # swallowed before.
87
+ function Install-Packages([string[]]$Arguments) {
88
+ Push-Location $profileDir
89
+ try {
90
+ $all = @($pnpmArgs) + $Arguments
91
+ $output = & $pnpmCommand @all 2>&1
92
+ $code = $LASTEXITCODE
93
+ return [pscustomobject]@{ Code = $code; Output = ($output | Out-String).Trim() }
94
+ } finally {
95
+ Pop-Location
96
+ }
97
+ }
98
+
99
+ $attempt = Install-Packages (@('add') + @($packages))
100
+ if ($attempt.Code -ne 0) {
101
+ Write-Host ' 第一次安装失败,pnpm 输出如下:' -ForegroundColor Yellow
102
+ Write-Host $attempt.Output
103
+ Write-Host ' 改用 npmmirror 镜像重试…' -ForegroundColor Yellow
104
+ $attempt = Install-Packages (@('add', '--registry', 'https://registry.npmmirror.com') + @($packages))
105
+ }
106
+ if ($attempt.Code -ne 0) {
107
+ Write-Host ' 镜像也失败,pnpm 输出如下:' -ForegroundColor Red
108
+ Write-Host $attempt.Output
109
+ Fail "pnpm add 失败(exit $($attempt.Code)):看上面的 npm 错误码。ERR_PNPM_UNEXPECTED_STORE 表示 pnpm 的 store 版本和 profile 里的不一致;EAI_AGAIN/ETIMEDOUT/ECONNREFUSED 是网络或代理。"
110
+ }
111
+ Write-Host ' 已安装:@deepseek-ai/dsh-lsp、dsh-lsp-stdio'
112
+
113
+ # ---- 2. language server -----------------------------------------------------
114
+
115
+ Step '准备语言服务器'
116
+ New-Item -ItemType Directory -Path $lspBin, $lspData -Force | Out-Null
117
+ $serverBin = $null
118
+ if (Test-Path $lspBin) {
119
+ $found = Get-ChildItem -Path $lspBin -Recurse -Filter 'intellij-server.exe' -ErrorAction SilentlyContinue |
120
+ Where-Object { $_.FullName -match '\\bin\\' } |
121
+ Select-Object -First 1
122
+ if ($found) { $serverBin = $found.FullName }
123
+ }
124
+
125
+ if (-not $serverBin -and -not $NoDownload) {
126
+ Write-Host " 未找到服务器,开始下载 $archiveName(约 390 MB)"
127
+ $zip = Join-Path ([System.IO.Path]::GetTempPath()) "intellij-server-$build.zip"
128
+ try {
129
+ Invoke-WebRequest -Uri $archiveUrl -OutFile $zip -UseBasicParsing
130
+ } catch {
131
+ Fail "下载失败,可手动下载:$archiveUrl"
132
+ }
133
+ # The Windows archive has no top-level folder (`bin/`, `jbr/`, `plugins/` sit at
134
+ # the root), so it must be unpacked into a versioned directory: the host looks
135
+ # for `lsp-bin\intellij-server-*\bin\<launcher>`.
136
+ $serverDir = Join-Path $lspBin 'intellij-server-2027.1'
137
+ New-Item -ItemType Directory -Path $serverDir -Force | Out-Null
138
+ Write-Host " 解压到 $serverDir"
139
+ Expand-Archive -Path $zip -DestinationPath $serverDir -Force
140
+ Remove-Item $zip -Force -ErrorAction SilentlyContinue
141
+ $found = Get-ChildItem -Path $lspBin -Recurse -Filter 'intellij-server.exe' |
142
+ Where-Object { $_.FullName -match '\\bin\\' } |
143
+ Select-Object -First 1
144
+ if ($found) { $serverBin = $found.FullName }
145
+ }
146
+
147
+ if (-not $serverBin) {
148
+ Fail "缺少服务器。手动下载 $archiveUrl ,解压到 $lspBin,再重跑本脚本。"
149
+ }
150
+ Write-Host " 服务器:$serverBin"
151
+
152
+ # ---- 3. patch lines ---------------------------------------------------------
153
+
154
+ Step '写入 cordis.patch.yml 的 lsp / lsp-stdio 两行'
155
+ $patchPath = Join-Path $profileDir 'cordis.patch.yml'
156
+ # Forward slashes: the loader YAML needs no escaping, and Node spawns .exe directly.
157
+ $serverPosix = $serverBin -replace '\\', '/'
158
+ $dataPosix = $lspData -replace '\\', '/'
159
+ $block = @"
160
+ # 代码导航:IntelliJ Language Server
161
+ - insert:
162
+ - id: lsp
163
+ name: "@deepseek-ai/dsh-lsp"
164
+ - id: lsp-stdio
165
+ name: "@deepseek-ai/dsh-lsp-stdio"
166
+ config:
167
+ servers:
168
+ java:
169
+ command: $serverPosix
170
+ extensionToLanguage:
171
+ ".java": java
172
+ args:
173
+ - --stdio
174
+ - --eula=cd82e6cdaf2790f1
175
+ - --system-path=$dataPosix
176
+ - --data-sharing=none
177
+ - --log-level=WARNING
178
+ maxDocumentBytes: 4000000
179
+ "@
180
+
181
+ # A `$` in a Windows user name would be read as a regex replacement token, so
182
+ # escape it before handing the path to the replacement string.
183
+ function Escape-Replacement([string]$Value) { return ($Value -replace '\$', '$$$$') }
184
+
185
+ $text = if (Test-Path $patchPath) { Get-Content -Path $patchPath -Raw } else { '' }
186
+ if ($text -match '(?m)^\s*- id: lsp$') {
187
+ # Rewrite paths in place: they may come from another machine or build.
188
+ $text = [regex]::Replace($text, 'command:\s*\S*/bin/intellij-server(\.exe)?', ('command: ' + (Escape-Replacement $serverPosix)))
189
+ $text = [regex]::Replace($text, '--system-path=\S+', ('--system-path=' + (Escape-Replacement $dataPosix)))
190
+ Write-Host ' 已有 lsp 两行,已按本机路径校正'
191
+ } else {
192
+ $text = $block + $text
193
+ Write-Host ' 已写入 lsp 两行'
194
+ }
195
+ # UTF-8 without BOM: the profile loader reads YAML, and a BOM would end up in
196
+ # the first key.
197
+ $utf8 = New-Object System.Text.UTF8Encoding($false)
198
+ [System.IO.File]::WriteAllText($patchPath, $text, $utf8)
199
+
200
+ # ---- 4. license -------------------------------------------------------------
201
+
202
+ Step '检查 JetBrains 服务器授权'
203
+ & $serverBin license status
204
+ if ($LASTEXITCODE -ne 0) {
205
+ Write-Host ' 未授权或已失效。执行下面这条,按浏览器提示登录后再重启 DSH:' -ForegroundColor Yellow
206
+ Write-Host " `"$serverBin`" license login"
207
+ }
208
+
209
+ Write-Host "`n下一步:完全退出 DSH(托盘里退出,不是关窗口)再打开;进入代码工作区不再弹「代码导航未就绪」即成功。" -ForegroundColor Green
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Turn code navigation (LSP) on for dsh-ide-window — macOS.
4
+ #
5
+ # ./enable-navigation.sh # packages + server download + patch lines
6
+ # ./enable-navigation.sh --no-download # skip the server download (already have it)
7
+ # ./enable-navigation.sh --profile web # another profile
8
+ #
9
+ # Safe to re-run. Only writes under ~/.dsh (profile, lsp-bin, lsp-data); the DSH
10
+ # application itself is never modified.
11
+ set -euo pipefail
12
+
13
+ LSP_VERSION="0.2.2-rc.3"
14
+ PACKAGES=("@deepseek-ai/dsh-lsp@${LSP_VERSION}" "@deepseek-ai/dsh-lsp-stdio@${LSP_VERSION}")
15
+ SERVER_URL="https://download.jetbrains.com/language-server/intellij-server/271.2085.0/intellij-server-271.2085.0-aarch64.sit"
16
+
17
+ PROFILE="${DSH_PROFILE:-desktop}"
18
+ DSH_HOME_DIR="${DSH_HOME:-$HOME/.dsh}"
19
+ PROFILE_DIR="$DSH_HOME_DIR/profiles/$PROFILE"
20
+ LSP_BIN="$DSH_HOME_DIR/lsp-bin"
21
+ LSP_DATA="$DSH_HOME_DIR/lsp-data/intellij-server"
22
+ DOWNLOAD=1
23
+
24
+ while [ $# -gt 0 ]; do
25
+ case "$1" in
26
+ --profile) PROFILE="${2:-}"; PROFILE_DIR="$DSH_HOME_DIR/profiles/$PROFILE"; shift 2 ;;
27
+ --no-download) DOWNLOAD=0; shift ;;
28
+ -h|--help) sed -n '2,10p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
29
+ *) echo "未知参数:$1" >&2; exit 1 ;;
30
+ esac
31
+ done
32
+
33
+ step() { printf '\n==> %s\n' "$1"; }
34
+ fail() { printf '错误:%s\n' "$1" >&2; exit 1; }
35
+
36
+ [ -f "$PROFILE_DIR/package.json" ] || fail "profile ${PROFILE}还没有初始化:先启动一次 DSH 再重跑。"
37
+ command -v pnpm >/dev/null 2>&1 || fail "需要 pnpm:npm i -g pnpm"
38
+ command -v python3 >/dev/null 2>&1 || fail "需要 python3(macOS 自带)。"
39
+
40
+ # ---- 1. pipeline packages ---------------------------------------------------
41
+
42
+ step "安装 LSP 管道包(${LSP_VERSION})"
43
+ ( cd "$PROFILE_DIR" && pnpm add "${PACKAGES[@]}" >/dev/null && echo " 已安装:@deepseek-ai/dsh-lsp、dsh-lsp-stdio" )
44
+
45
+ # ---- 2. language server -----------------------------------------------------
46
+
47
+ step "准备语言服务器"
48
+ SERVER_BIN=""
49
+ find_server() {
50
+ local candidate
51
+ candidate="$(find "$LSP_BIN" -maxdepth 4 -type f -name intellij-server 2>/dev/null | head -1 || true)"
52
+ printf '%s' "$candidate"
53
+ }
54
+ mkdir -p "$LSP_BIN" "$LSP_DATA"
55
+ SERVER_BIN="$(find_server)"
56
+
57
+ if [ -z "$SERVER_BIN" ] && [ "$DOWNLOAD" = 1 ]; then
58
+ echo " 未找到服务器,开始下载(约 1.2 GB,来自 download.jetbrains.com)"
59
+ TMP_ZIP="$(mktemp -t intellij-server).zip"
60
+ curl -fL --progress-bar -o "$TMP_ZIP" "$SERVER_URL" || fail "下载失败,可手动下载:$SERVER_URL"
61
+ echo " 解压到 ${LSP_BIN}"
62
+ unzip -q -o "$TMP_ZIP" -d "$LSP_BIN" || fail "解压失败(归档是 zip 格式,用 unzip -d 手动解开)"
63
+ rm -f "$TMP_ZIP"
64
+ SERVER_BIN="$(find_server)"
65
+ fi
66
+
67
+ if [ -z "$SERVER_BIN" ]; then
68
+ fail "缺少服务器。手动下载 $SERVER_URL ,unzip 到 ${LSP_BIN},再重跑本脚本。"
69
+ fi
70
+ chmod +x "$SERVER_BIN" 2>/dev/null || true
71
+ echo " 服务器:$SERVER_BIN"
72
+
73
+ # ---- 3. patch lines ---------------------------------------------------------
74
+
75
+ step "写入 cordis.patch.yml 的 lsp / lsp-stdio 两行"
76
+ printf '%s' "$SERVER_BIN" > /tmp/.nav-server-path
77
+ printf '%s' "$PROFILE_DIR/cordis.patch.yml" > /tmp/.nav-patch-path
78
+ printf '%s' "$LSP_DATA" > /tmp/.nav-data-path
79
+ python3 - <<'PY'
80
+ import re, pathlib
81
+ server = pathlib.Path('/tmp/.nav-server-path').read_text().strip()
82
+ patch_path = pathlib.Path(pathlib.Path('/tmp/.nav-patch-path').read_text().strip())
83
+ data_dir = pathlib.Path('/tmp/.nav-data-path').read_text().strip()
84
+
85
+ block = f'''# 代码导航:IntelliJ Language Server
86
+ - insert:
87
+ - id: lsp
88
+ name: "@deepseek-ai/dsh-lsp"
89
+ - id: lsp-stdio
90
+ name: "@deepseek-ai/dsh-lsp-stdio"
91
+ config:
92
+ servers:
93
+ java:
94
+ command: {server}
95
+ extensionToLanguage:
96
+ ".java": java
97
+ args:
98
+ - --stdio
99
+ - --eula=cd82e6cdaf2790f1
100
+ - --system-path={data_dir}
101
+ - --data-sharing=none
102
+ - --log-level=WARNING
103
+ maxDocumentBytes: 4000000
104
+ '''
105
+
106
+ text = patch_path.read_text()
107
+ if 'id: lsp' in text:
108
+ # Rewrite the existing block in place: paths may come from another machine.
109
+ text = re.sub(r'command: .*/bin/intellij-server', f'command: {server}', text)
110
+ text = re.sub(r'--system-path=\S+', f'--system-path={data_dir}', text)
111
+ patch_path.write_text(text)
112
+ print(' 已有 lsp 两行,已按本机路径校正')
113
+ else:
114
+ patch_path.write_text(block + text)
115
+ print(' 已写入 lsp 两行')
116
+ PY
117
+ rm -f /tmp/.nav-server-path /tmp/.nav-patch-path /tmp/.nav-data-path
118
+
119
+ # ---- 4. license -------------------------------------------------------------
120
+
121
+ step "检查 JetBrains 服务器授权"
122
+ if "$SERVER_BIN" license status >/tmp/.nav-license 2>&1; then
123
+ head -3 /tmp/.nav-license | sed 's/^/ /'
124
+ else
125
+ head -5 /tmp/.nav-license | sed 's/^/ /' || true
126
+ printf ' 未授权或已失效。执行下面这条,按浏览器提示登录后再重启 DSH:\n'
127
+ printf ' %s license login\n' "$SERVER_BIN"
128
+ fi
129
+ rm -f /tmp/.nav-license
130
+
131
+ printf '\n下一步:完全退出 DSH(⌘Q)再打开;进入代码工作区不再弹「代码导航未就绪」即成功。\n'
package/icon.svg ADDED
@@ -0,0 +1,25 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="Code workspace">
2
+ <defs>
3
+ <linearGradient id="iw-bg" x1="0" y1="0" x2="1" y2="1">
4
+ <stop offset="0" stop-color="#2f6f5e"/>
5
+ <stop offset="1" stop-color="#14312a"/>
6
+ </linearGradient>
7
+ </defs>
8
+ <rect x="2" y="2" width="60" height="60" rx="14" fill="url(#iw-bg)"/>
9
+ <!-- window chrome: the editor frame -->
10
+ <rect x="12" y="15" width="40" height="34" rx="4" fill="none" stroke="#ffffff" stroke-width="2.6" opacity="0.9"/>
11
+ <path d="M12 23h40" fill="none" stroke="#ffffff" stroke-width="2" opacity="0.5"/>
12
+ <!-- file tree column -->
13
+ <path d="M21 27v17" fill="none" stroke="#8ff0c8" stroke-width="2" opacity="0.85"/>
14
+ <g fill="#8ff0c8" opacity="0.9">
15
+ <rect x="16.5" y="27" width="9" height="2.4" rx="1.2"/>
16
+ <rect x="19.5" y="33" width="9" height="2.4" rx="1.2"/>
17
+ <rect x="19.5" y="39" width="6" height="2.4" rx="1.2"/>
18
+ </g>
19
+ <!-- code lines on the right -->
20
+ <g fill="#ffffff" opacity="0.85">
21
+ <rect x="30" y="28" width="17" height="2.4" rx="1.2"/>
22
+ <rect x="30" y="33.5" width="12" height="2.4" rx="1.2"/>
23
+ <rect x="30" y="39" width="15" height="2.4" rx="1.2"/>
24
+ </g>
25
+ </svg>