dsh-ide-window 0.0.0-stage → 0.1.0

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,189 @@
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
+ Push-Location $profileDir
84
+ try {
85
+ $all = @($pnpmArgs) + @('add') + @($packages)
86
+ & $pnpmCommand @all | Out-Null
87
+ if ($LASTEXITCODE -ne 0) { Fail 'pnpm add 失败,请检查网络或代理。' }
88
+ } finally {
89
+ Pop-Location
90
+ }
91
+ Write-Host ' 已安装:@deepseek-ai/dsh-lsp、dsh-lsp-stdio'
92
+
93
+ # ---- 2. language server -----------------------------------------------------
94
+
95
+ Step '准备语言服务器'
96
+ New-Item -ItemType Directory -Path $lspBin, $lspData -Force | Out-Null
97
+ $serverBin = $null
98
+ if (Test-Path $lspBin) {
99
+ $found = Get-ChildItem -Path $lspBin -Recurse -Filter 'intellij-server.exe' -ErrorAction SilentlyContinue |
100
+ Where-Object { $_.FullName -match '\\bin\\' } |
101
+ Select-Object -First 1
102
+ if ($found) { $serverBin = $found.FullName }
103
+ }
104
+
105
+ if (-not $serverBin -and -not $NoDownload) {
106
+ Write-Host " 未找到服务器,开始下载 $archiveName(约 390 MB)"
107
+ $zip = Join-Path ([System.IO.Path]::GetTempPath()) "intellij-server-$build.zip"
108
+ try {
109
+ Invoke-WebRequest -Uri $archiveUrl -OutFile $zip -UseBasicParsing
110
+ } catch {
111
+ Fail "下载失败,可手动下载:$archiveUrl"
112
+ }
113
+ # The Windows archive has no top-level folder (`bin/`, `jbr/`, `plugins/` sit at
114
+ # the root), so it must be unpacked into a versioned directory: the host looks
115
+ # for `lsp-bin\intellij-server-*\bin\<launcher>`.
116
+ $serverDir = Join-Path $lspBin 'intellij-server-2027.1'
117
+ New-Item -ItemType Directory -Path $serverDir -Force | Out-Null
118
+ Write-Host " 解压到 $serverDir"
119
+ Expand-Archive -Path $zip -DestinationPath $serverDir -Force
120
+ Remove-Item $zip -Force -ErrorAction SilentlyContinue
121
+ $found = Get-ChildItem -Path $lspBin -Recurse -Filter 'intellij-server.exe' |
122
+ Where-Object { $_.FullName -match '\\bin\\' } |
123
+ Select-Object -First 1
124
+ if ($found) { $serverBin = $found.FullName }
125
+ }
126
+
127
+ if (-not $serverBin) {
128
+ Fail "缺少服务器。手动下载 $archiveUrl ,解压到 $lspBin,再重跑本脚本。"
129
+ }
130
+ Write-Host " 服务器:$serverBin"
131
+
132
+ # ---- 3. patch lines ---------------------------------------------------------
133
+
134
+ Step '写入 cordis.patch.yml 的 lsp / lsp-stdio 两行'
135
+ $patchPath = Join-Path $profileDir 'cordis.patch.yml'
136
+ # Forward slashes: the loader YAML needs no escaping, and Node spawns .exe directly.
137
+ $serverPosix = $serverBin -replace '\\', '/'
138
+ $dataPosix = $lspData -replace '\\', '/'
139
+ $block = @"
140
+ # 代码导航:IntelliJ Language Server
141
+ - insert:
142
+ - id: lsp
143
+ name: "@deepseek-ai/dsh-lsp"
144
+ - id: lsp-stdio
145
+ name: "@deepseek-ai/dsh-lsp-stdio"
146
+ config:
147
+ servers:
148
+ java:
149
+ command: $serverPosix
150
+ extensionToLanguage:
151
+ ".java": java
152
+ args:
153
+ - --stdio
154
+ - --eula=cd82e6cdaf2790f1
155
+ - --system-path=$dataPosix
156
+ - --data-sharing=none
157
+ - --log-level=WARNING
158
+ maxDocumentBytes: 4000000
159
+ "@
160
+
161
+ # A `$` in a Windows user name would be read as a regex replacement token, so
162
+ # escape it before handing the path to the replacement string.
163
+ function Escape-Replacement([string]$Value) { return ($Value -replace '\$', '$$$$') }
164
+
165
+ $text = if (Test-Path $patchPath) { Get-Content -Path $patchPath -Raw } else { '' }
166
+ if ($text -match '(?m)^\s*- id: lsp$') {
167
+ # Rewrite paths in place: they may come from another machine or build.
168
+ $text = [regex]::Replace($text, 'command:\s*\S*/bin/intellij-server(\.exe)?', ('command: ' + (Escape-Replacement $serverPosix)))
169
+ $text = [regex]::Replace($text, '--system-path=\S+', ('--system-path=' + (Escape-Replacement $dataPosix)))
170
+ Write-Host ' 已有 lsp 两行,已按本机路径校正'
171
+ } else {
172
+ $text = $block + $text
173
+ Write-Host ' 已写入 lsp 两行'
174
+ }
175
+ # UTF-8 without BOM: the profile loader reads YAML, and a BOM would end up in
176
+ # the first key.
177
+ $utf8 = New-Object System.Text.UTF8Encoding($false)
178
+ [System.IO.File]::WriteAllText($patchPath, $text, $utf8)
179
+
180
+ # ---- 4. license -------------------------------------------------------------
181
+
182
+ Step '检查 JetBrains 服务器授权'
183
+ & $serverBin license status
184
+ if ($LASTEXITCODE -ne 0) {
185
+ Write-Host ' 未授权或已失效。执行下面这条,按浏览器提示登录后再重启 DSH:' -ForegroundColor Yellow
186
+ Write-Host " `"$serverBin`" license login"
187
+ }
188
+
189
+ 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>