dsh-desktop-kit 2.30.0 → 2.31.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.
package/doctor.ps1 CHANGED
@@ -1,142 +1,161 @@
1
- #requires -Version 5.1
2
- <#
3
- .SYNOPSIS
4
- Report whether dsh-desktop-kit is installed and enabled.
5
- #>
6
- param(
7
- [string]$Profile = "desktop",
8
- [string]$DshHome = ""
9
- )
10
-
11
- $ErrorActionPreference = "Continue"
12
-
13
- if ([string]::IsNullOrWhiteSpace($DshHome)) {
14
- if ($env:DSH_HOME) { $DshHome = $env:DSH_HOME } else { $DshHome = Join-Path $env:USERPROFILE ".dsh" }
15
- }
16
-
17
- $profileDir = Join-Path $DshHome "profiles\$Profile"
18
- $profileJson = Join-Path $profileDir "package.json"
19
-
20
- Write-Host "DSH home: $DshHome"
21
- Write-Host "Profile: $profileDir"
22
-
23
- $dsh = $null
24
- $command = Get-Command dsh -ErrorAction SilentlyContinue
25
- if ($command) { $dsh = $command.Source }
26
- if (-not $dsh) {
27
- $fallback = Join-Path ${env:LOCALAPPDATA} "Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd"
28
- if (Test-Path $fallback) { $dsh = $fallback }
29
- }
30
- if ($dsh) {
31
- $version = & $dsh --version 2>$null
32
- Write-Host "DSH CLI: $version"
33
- } else {
34
- Write-Host "DSH CLI: not found" -ForegroundColor Yellow
35
- }
36
-
37
- if (-not (Test-Path $profileJson)) {
38
- Write-Host "Profile manifest not found." -ForegroundColor Red
39
- exit 1
40
- }
41
-
42
- $json = Get-Content -Path $profileJson -Raw | ConvertFrom-Json
43
- $issues = 0
44
-
45
- $dependency = $null
46
- if ($json.dependencies) { $dependency = $json.dependencies.'dsh-desktop-kit' }
47
- if ($dependency) {
48
- Write-Host "Dependency: $dependency" -ForegroundColor Green
49
- } else {
50
- Write-Host "Dependency: not installed" -ForegroundColor Red
51
- $issues += 1
52
- }
53
-
54
- $bundles = @()
55
- if ($json.dsh -and $json.dsh.profile -and $json.dsh.profile.bundles) { $bundles = @($json.dsh.profile.bundles) }
56
- if ($bundles -contains "dsh-desktop-kit") {
57
- Write-Host "Bundle: enabled" -ForegroundColor Green
58
- } else {
59
- Write-Host "Bundle: not enabled" -ForegroundColor Red
60
- $issues += 1
61
- }
62
-
63
- $link = Join-Path $profileDir "node_modules\dsh-desktop-kit"
64
- if (Test-Path $link) {
65
- $item = Get-Item -Path $link -Force
66
- if ($item.LinkType -eq "Junction" -or $item.LinkType -eq "SymbolicLink") {
67
- Write-Host "Package: linked -> $($item.Target)" -ForegroundColor Yellow
68
- Write-Host " development link; production installs use a real directory"
69
- } else {
70
- Write-Host "Package: real directory" -ForegroundColor Green
71
- }
72
- $kitPackage = Join-Path $link "package.json"
73
- if (Test-Path $kitPackage) {
74
- try {
75
- $kit = Get-Content -Path $kitPackage -Raw | ConvertFrom-Json
76
- Write-Host "Kit: $($kit.version)" -ForegroundColor Green
77
- } catch {
78
- Write-Host "Kit: package.json is unreadable" -ForegroundColor Red
79
- $issues += 1
80
- }
81
- } else {
82
- Write-Host "Kit: package.json missing" -ForegroundColor Red
83
- $issues += 1
84
- }
85
- $tmp = @(Get-ChildItem -Path (Join-Path $profileDir "node_modules") -Directory -Filter "dsh-desktop-kit_tmp_*" -ErrorAction SilentlyContinue)
86
- if ($tmp.Count -gt 0) {
87
- Write-Host "Stale: $($tmp.Count) dsh-desktop-kit_tmp_* folder(s); pnpm may fail with EPERM" -ForegroundColor Yellow
88
- Write-Host " remove them, then re-run the install"
89
- $issues += 1
90
- }
91
- } else {
92
- Write-Host "Package: missing (run install.ps1 again)" -ForegroundColor Red
93
- $issues += 1
94
- }
95
-
96
- $statePath = Join-Path $DshHome "skills\.dsh-kit-skills.json"
97
- if (Test-Path $statePath) {
98
- try {
99
- $state = Get-Content -Path $statePath -Raw | ConvertFrom-Json
100
- $skillNames = @()
101
- if ($state.skills) { $skillNames = @($state.skills.PSObject.Properties | ForEach-Object { $_.Name } | Where-Object { $_ }) }
102
- $conflictNames = @()
103
- if ($state.conflicts) { $conflictNames = @($state.conflicts.PSObject.Properties | ForEach-Object { $_.Name } | Where-Object { $_ }) }
104
- Write-Host "Skill sync: $($skillNames.Count) packaged, $($conflictNames.Count) conflicts, updated $($state.updatedAt)" -ForegroundColor Green
105
- if ($conflictNames.Count -gt 0) {
106
- Write-Host "Skill conflicts (your edits were kept): $($conflictNames -join ', ')" -ForegroundColor Yellow
107
- Write-Host " /kit conflicts - list; /kit sync - update without overwriting"
108
- }
109
- } catch {
110
- Write-Host "Skill sync: state file is unreadable ($($_.Exception.Message))" -ForegroundColor Yellow
111
- }
112
- } else {
113
- Write-Host "Skill sync: not written yet (start DSH once or run /kit sync)" -ForegroundColor Yellow
114
- }
115
-
116
- $pinned = @()
117
- foreach ($name in @($json.dependencies.PSObject.Properties.Name)) {
118
- if ($name -like "@deepseek-ai/*") { $pinned += $name }
119
- }
120
- if ($pinned.Count -gt 0) {
121
- Write-Host "Pinned @deepseek-ai packages (possible 'incompatible plugins' after a DSH update):" -ForegroundColor Yellow
122
- $pinned | ForEach-Object { Write-Host " $_" }
123
- } else {
124
- Write-Host "Pinned packages: none" -ForegroundColor Green
125
- }
126
-
127
- $skillsDir = Join-Path $DshHome "skills"
128
- if (Test-Path $skillsDir) {
129
- $count = (Get-ChildItem $skillsDir -Directory | Measure-Object).Count
130
- Write-Host "Skills: $count" -ForegroundColor Green
131
- } else {
132
- Write-Host "Skills: folder missing (the kit creates it on first start)" -ForegroundColor Yellow
133
- }
134
-
135
- if ($issues -eq 0) {
136
- Write-Host ""
137
- Write-Host "Everything is in place." -ForegroundColor Green
138
- exit 0
139
- }
140
- Write-Host ""
141
- Write-Host "$issues problem(s) found." -ForegroundColor Red
142
- exit 1
1
+ #requires -Version 5.1
2
+ <#
3
+ .SYNOPSIS
4
+ Report whether dsh-desktop-kit is installed and enabled.
5
+
6
+ .PARAMETER Json
7
+ Print the full environment probe and the install plan as JSON (exit 0 when
8
+ no blocking problem, 1 otherwise). Used by tools/onboarding-tests.mjs.
9
+
10
+ .PARAMETER SkipExternal
11
+ Do not probe dsh/gh/processes (tests).
12
+ #>
13
+ param(
14
+ [string]$Profile = "desktop",
15
+ [string]$DshHome = "",
16
+ [switch]$Json,
17
+ [switch]$SkipExternal
18
+ )
19
+
20
+ $ErrorActionPreference = "Continue"
21
+
22
+ if ([string]::IsNullOrWhiteSpace($DshHome)) {
23
+ if ($env:DSH_HOME) { $DshHome = $env:DSH_HOME } else { $DshHome = Join-Path $env:USERPROFILE ".dsh" }
24
+ }
25
+
26
+ if ($Json) {
27
+ $kitEnvScript = Join-Path $PSScriptRoot "tools\kit-env.ps1"
28
+ if (-not (Test-Path $kitEnvScript)) { throw "tools\kit-env.ps1 not found" }
29
+ . $kitEnvScript
30
+ $environment = Get-KitEnvironment -DshHome $DshHome -ProfileName $Profile -RepoPath $PSScriptRoot -SkipExternal:$SkipExternal
31
+ $plan = Get-KitPlan -Environment $environment
32
+ [pscustomobject]@{ environment = $environment; plan = $plan } | ConvertTo-Json -Depth 12
33
+ if ($environment.ok) { exit 0 } else { exit 1 }
34
+ }
35
+
36
+ $profileDir = Join-Path $DshHome "profiles\$Profile"
37
+ $profileJson = Join-Path $profileDir "package.json"
38
+
39
+ Write-Host "DSH home: $DshHome"
40
+ Write-Host "Profile: $profileDir"
41
+
42
+ $dsh = $null
43
+ $command = Get-Command dsh -ErrorAction SilentlyContinue
44
+ if ($command) { $dsh = $command.Source }
45
+ if (-not $dsh) {
46
+ $fallback = Join-Path ${env:LOCALAPPDATA} "Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd"
47
+ if (Test-Path $fallback) { $dsh = $fallback }
48
+ }
49
+ if ($dsh) {
50
+ $version = & $dsh --version 2>$null
51
+ Write-Host "DSH CLI: $version"
52
+ } else {
53
+ Write-Host "DSH CLI: not found" -ForegroundColor Yellow
54
+ }
55
+
56
+ if (-not (Test-Path $profileJson)) {
57
+ Write-Host "Profile manifest not found." -ForegroundColor Red
58
+ exit 1
59
+ }
60
+
61
+ $profileData = Get-Content -Path $profileJson -Raw | ConvertFrom-Json
62
+ $issues = 0
63
+
64
+ $dependency = $null
65
+ if ($profileData.dependencies) { $dependency = $profileData.dependencies.'dsh-desktop-kit' }
66
+ if ($dependency) {
67
+ Write-Host "Dependency: $dependency" -ForegroundColor Green
68
+ } else {
69
+ Write-Host "Dependency: not installed" -ForegroundColor Red
70
+ $issues += 1
71
+ }
72
+
73
+ $bundles = @()
74
+ if ($profileData.dsh -and $profileData.dsh.profile -and $profileData.dsh.profile.bundles) { $bundles = @($profileData.dsh.profile.bundles) }
75
+ if ($bundles -contains "dsh-desktop-kit") {
76
+ Write-Host "Bundle: enabled" -ForegroundColor Green
77
+ } else {
78
+ Write-Host "Bundle: not enabled" -ForegroundColor Red
79
+ $issues += 1
80
+ }
81
+
82
+ $link = Join-Path $profileDir "node_modules\dsh-desktop-kit"
83
+ if (Test-Path $link) {
84
+ $item = Get-Item -Path $link -Force
85
+ if ($item.LinkType -eq "Junction" -or $item.LinkType -eq "SymbolicLink") {
86
+ Write-Host "Package: linked -> $($item.Target)" -ForegroundColor Yellow
87
+ Write-Host " development link; production installs use a real directory"
88
+ } else {
89
+ Write-Host "Package: real directory" -ForegroundColor Green
90
+ }
91
+ $kitPackage = Join-Path $link "package.json"
92
+ if (Test-Path $kitPackage) {
93
+ try {
94
+ $kit = Get-Content -Path $kitPackage -Raw | ConvertFrom-Json
95
+ Write-Host "Kit: $($kit.version)" -ForegroundColor Green
96
+ } catch {
97
+ Write-Host "Kit: package.json is unreadable" -ForegroundColor Red
98
+ $issues += 1
99
+ }
100
+ } else {
101
+ Write-Host "Kit: package.json missing" -ForegroundColor Red
102
+ $issues += 1
103
+ }
104
+ $tmp = @(Get-ChildItem -Path (Join-Path $profileDir "node_modules") -Directory -Filter "dsh-desktop-kit_tmp_*" -ErrorAction SilentlyContinue)
105
+ if ($tmp.Count -gt 0) {
106
+ Write-Host "Stale: $($tmp.Count) dsh-desktop-kit_tmp_* folder(s); pnpm may fail with EPERM" -ForegroundColor Yellow
107
+ Write-Host " remove them, then re-run the install"
108
+ $issues += 1
109
+ }
110
+ } else {
111
+ Write-Host "Package: missing (run install.ps1 again)" -ForegroundColor Red
112
+ $issues += 1
113
+ }
114
+
115
+ $statePath = Join-Path $DshHome "skills\.dsh-kit-skills.json"
116
+ if (Test-Path $statePath) {
117
+ try {
118
+ $state = Get-Content -Path $statePath -Raw | ConvertFrom-Json
119
+ $skillNames = @()
120
+ if ($state.skills) { $skillNames = @($state.skills.PSObject.Properties | ForEach-Object { $_.Name } | Where-Object { $_ }) }
121
+ $conflictNames = @()
122
+ if ($state.conflicts) { $conflictNames = @($state.conflicts.PSObject.Properties | ForEach-Object { $_.Name } | Where-Object { $_ }) }
123
+ Write-Host "Skill sync: $($skillNames.Count) packaged, $($conflictNames.Count) conflicts, updated $($state.updatedAt)" -ForegroundColor Green
124
+ if ($conflictNames.Count -gt 0) {
125
+ Write-Host "Skill conflicts (your edits were kept): $($conflictNames -join ', ')" -ForegroundColor Yellow
126
+ Write-Host " /kit conflicts - list; /kit sync - update without overwriting"
127
+ }
128
+ } catch {
129
+ Write-Host "Skill sync: state file is unreadable ($($_.Exception.Message))" -ForegroundColor Yellow
130
+ }
131
+ } else {
132
+ Write-Host "Skill sync: not written yet (start DSH once or run /kit sync)" -ForegroundColor Yellow
133
+ }
134
+
135
+ $pinned = @()
136
+ foreach ($name in @($profileData.dependencies.PSObject.Properties.Name)) {
137
+ if ($name -like "@deepseek-ai/*") { $pinned += $name }
138
+ }
139
+ if ($pinned.Count -gt 0) {
140
+ Write-Host "Pinned @deepseek-ai packages (possible 'incompatible plugins' after a DSH update):" -ForegroundColor Yellow
141
+ $pinned | ForEach-Object { Write-Host " $_" }
142
+ } else {
143
+ Write-Host "Pinned packages: none" -ForegroundColor Green
144
+ }
145
+
146
+ $skillsDir = Join-Path $DshHome "skills"
147
+ if (Test-Path $skillsDir) {
148
+ $count = (Get-ChildItem $skillsDir -Directory | Measure-Object).Count
149
+ Write-Host "Skills: $count" -ForegroundColor Green
150
+ } else {
151
+ Write-Host "Skills: folder missing (the kit creates it on first start)" -ForegroundColor Yellow
152
+ }
153
+
154
+ if ($issues -eq 0) {
155
+ Write-Host ""
156
+ Write-Host "Everything is in place." -ForegroundColor Green
157
+ exit 0
158
+ }
159
+ Write-Host ""
160
+ Write-Host "$issues problem(s) found." -ForegroundColor Red
161
+ exit 1
package/index.js CHANGED
@@ -22,6 +22,16 @@ import {
22
22
  loadSkillState,
23
23
  STATE_FILE,
24
24
  } from "./lib/skills-sync.js";
25
+ import {
26
+ applyTune,
27
+ collectTuneMetrics,
28
+ detectEnvironment,
29
+ formatDoctor,
30
+ formatPlan,
31
+ formatTune,
32
+ planActions,
33
+ writeTuneReport,
34
+ } from "./lib/kit-diagnostics.js";
25
35
 
26
36
  import * as gkbRuUi from "./plugins/dsh-gkb-ru-ui/lib/index.js";
27
37
  import * as peakGuard from "./plugins/dsh-peak-guard/index.js";
@@ -139,10 +149,30 @@ function kitStatusText() {
139
149
  for (const error of runtimeState.mountErrors.slice(0, 5)) lines.push(`Ошибка ${error.name}: ${error.message}`);
140
150
  }
141
151
  lines.push(`Состояние: ${path.join(home, "skills", STATE_FILE)}`);
142
- lines.push("Команды: /kit status | sync | conflicts | force (перезаписать правки)");
152
+ lines.push("Команды: /kit status | doctor | plan | tune | sync | conflicts | force");
143
153
  return lines.join("\n");
144
154
  }
145
155
 
156
+ /** Split `/kit <command> [--flag value] [--json]` without a dependency. */
157
+ function parseKitArgs(rest) {
158
+ const flags = new Set();
159
+ const options = {};
160
+ for (let index = 0; index < rest.length; index += 1) {
161
+ const item = rest[index];
162
+ if (!item.startsWith("--")) continue;
163
+ const [key, inline] = item.slice(2).split("=", 2);
164
+ if (inline !== undefined) {
165
+ options[key] = inline;
166
+ } else if (rest[index + 1] && !rest[index + 1].startsWith("--")) {
167
+ options[key] = rest[index + 1];
168
+ index += 1;
169
+ } else {
170
+ flags.add(key);
171
+ }
172
+ }
173
+ return { flags, options };
174
+ }
175
+
146
176
  export function apply(ctx) {
147
177
  try {
148
178
  installSkills(ctx.logger);
@@ -173,12 +203,53 @@ export function apply(ctx) {
173
203
  try {
174
204
  const dispose = commandCtx.commands.register({
175
205
  name: "kit",
176
- description: "DSH Desktop Kit: состояние, синхронизация навыков, конфликты",
177
- input: { hint: "status | sync | conflicts | force" },
206
+ description: "DSH Desktop Kit: диагностика, план установки, замеры, синхронизация навыков",
207
+ input: { hint: "status | doctor | plan | tune | sync | conflicts | force (--json, --profile <имя>, --apply)" },
178
208
  recordInput: false,
179
- handler: ({ rawInput }) => {
180
- const command = String(rawInput ?? "").trim().toLowerCase();
209
+ handler: async ({ rawInput }) => {
210
+ const args = String(rawInput ?? "").trim().split(/\s+/u).filter(Boolean);
211
+ const command = (args[0] ?? "status").toLowerCase();
212
+ const { flags, options } = parseKitArgs(args.slice(1));
213
+ const profile = options.profile || process.env.DSH_PROFILE || "desktop";
214
+ const home = skillsHome();
181
215
  try {
216
+ if (command === "doctor") {
217
+ const env = detectEnvironment({ home, profile, repoPath: here });
218
+ return { kind: env.ok ? "success" : "error", text: formatDoctor(env) };
219
+ }
220
+ if (command === "plan") {
221
+ const env = detectEnvironment({ home, profile, repoPath: here });
222
+ const plan = planActions(env);
223
+ if (flags.has("json")) {
224
+ return {
225
+ kind: "success",
226
+ text: JSON.stringify(
227
+ {
228
+ plan,
229
+ environment: {
230
+ profile: env.profile,
231
+ kit: env.kit,
232
+ dsh: env.dsh,
233
+ node: env.node,
234
+ problems: env.problems,
235
+ },
236
+ },
237
+ null,
238
+ 2,
239
+ ),
240
+ };
241
+ }
242
+ return { kind: plan.blocked ? "error" : "success", text: formatPlan(plan, env) };
243
+ }
244
+ if (command === "tune") {
245
+ const report = collectTuneMetrics({ home, repoPath: here, profile });
246
+ const reportFile = writeTuneReport(home, report);
247
+ const applied = flags.has("apply") ? applyTune(home, report) : null;
248
+ if (flags.has("json")) {
249
+ return { kind: "success", text: JSON.stringify({ report, reportFile, applied }, null, 2) };
250
+ }
251
+ return { kind: "success", text: `${formatTune(report, applied)}\nОтчёт: ${reportFile}` };
252
+ }
182
253
  if (command === "sync" || command === "force") {
183
254
  const force = command === "force";
184
255
  const result = installSkills(ctx.logger, { force });