@zhengxiantai/dsh-mindmap 0.0.0-stage → 0.7.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,18 @@
1
+ # dsh-mindmap bundle patch.
2
+ #
3
+ # Installed through the official CLI:
4
+ #
5
+ # dsh plugin --profile <name> add @zhengxiantai/dsh-mindmap
6
+ #
7
+ # the CLI appends this bundle to `dsh.profile.bundles`, and the profile boot
8
+ # merges THIS patch: one `insert` of the plugin row. For a local checkout,
9
+ # the same row can be mounted manually in the profile's cordis.patch.yml.
10
+ - insert:
11
+ - id: mindmap
12
+ name: '@zhengxiantai/dsh-mindmap'
13
+ config:
14
+ autoSummarize: true
15
+ summaryMaxInputChars: 12000
16
+ summaryMaxOutputTokens: 700
17
+ summaryTimeoutMs: 60000
18
+ maxTopicsPerRequest: 64
Binary file
Binary file
package/install.ps1 ADDED
@@ -0,0 +1,83 @@
1
+ # Install / uninstall dsh-mindmap into a DSH profile.
2
+ #
3
+ # pwsh -File install.ps1 # mount into the desktop profile
4
+ # pwsh -File install.ps1 -Profile web # mount into another profile
5
+ # pwsh -File install.ps1 -Uninstall # remove the package and its mount row
6
+ #
7
+ # The package is copied to <profile>/node_modules/@zhengxiantai/dsh-mindmap and a single
8
+ # loader row is appended to <profile>/cordis.patch.yml. A profile with HMR
9
+ # enabled re-composes the tree automatically; otherwise restart DSH.
10
+ param(
11
+ [string]$Profile = 'desktop',
12
+ [switch]$Uninstall
13
+ )
14
+
15
+ $ErrorActionPreference = 'Stop'
16
+
17
+ $source = $PSScriptRoot
18
+ $packageName = '@zhengxiantai/dsh-mindmap'
19
+ $dshHome = if ($env:DSH_HOME) { $env:DSH_HOME } else { Join-Path $HOME '.dsh' }
20
+ $profileDir = Join-Path $dshHome "profiles\$Profile"
21
+ if (-not (Test-Path -LiteralPath $profileDir)) {
22
+ throw "Profile not found: $profileDir"
23
+ }
24
+ $patchFile = Join-Path $profileDir 'cordis.patch.yml'
25
+ $target = Join-Path $profileDir 'node_modules\@zhengxiantai\dsh-mindmap'
26
+ $mountBlock = @"
27
+ - insert:
28
+ - id: mindmap
29
+ name: '$packageName'
30
+ "@
31
+
32
+ if ($Uninstall) {
33
+ if (Test-Path -LiteralPath $target) {
34
+ Remove-Item -LiteralPath $target -Recurse -Force
35
+ Write-Host "Removed $target"
36
+ }
37
+ if (Test-Path -LiteralPath $patchFile) {
38
+ $content = Get-Content -LiteralPath $patchFile -Raw
39
+ $escaped = [regex]::Escape($packageName)
40
+ $pattern = '(?ms)^[ \t]*-[ \t]*insert:[ \t]*\r?\n[ \t]*-[ \t]*id:[ \t]*mindmap[ \t]*\r?\n[ \t]*name:[ \t]*[''"]' + $escaped + '[''"][ \t]*\r?\n'
41
+ $next = [regex]::Replace($content, $pattern, '')
42
+ $meaningful = @($next -split "`n" | Where-Object { $_.Trim() -ne '' -and -not $_.TrimStart().StartsWith('#') })
43
+ if ($meaningful.Count -eq 0) { $next = "[]" }
44
+ $utf8 = New-Object System.Text.UTF8Encoding($false)
45
+ [System.IO.File]::WriteAllText($patchFile, ($next.TrimEnd() + "`n"), $utf8)
46
+ Write-Host "Unmounted $packageName from $patchFile"
47
+ }
48
+ exit 0
49
+ }
50
+
51
+ New-Item -ItemType Directory -Path (Split-Path $target) -Force | Out-Null
52
+ New-Item -ItemType Directory -Path $target -Force | Out-Null
53
+ foreach ($item in @('lib', 'package.json', 'cordis.patch.yml', 'README.md')) {
54
+ $from = Join-Path $source $item
55
+ if (Test-Path -LiteralPath $from) {
56
+ Copy-Item -LiteralPath $from -Destination $target -Recurse -Force
57
+ }
58
+ }
59
+ Write-Host "Installed package to $target"
60
+
61
+ $lines = if (Test-Path -LiteralPath $patchFile) { @(Get-Content -LiteralPath $patchFile) } else { @() }
62
+ $already = $lines | Where-Object { $_ -match [regex]::Escape($packageName) }
63
+ if ($already) {
64
+ Write-Host 'Mount row already present; nothing to change.'
65
+ exit 0
66
+ }
67
+
68
+ # A bare `[]` is a valid empty layer but cannot be followed by list items.
69
+ # Replace it with the mount block; otherwise append a new list item.
70
+ $meaningful = @($lines | Where-Object { $_.Trim() -ne '' -and -not $_.TrimStart().StartsWith('#') })
71
+ if ($meaningful.Count -gt 0 -and ($meaningful -join "`n").Trim() -eq '[]') {
72
+ $commentLines = @($lines | Where-Object { $_.Trim() -eq '' -or $_.TrimStart().StartsWith('#') })
73
+ $body = (@($commentLines) + @('', $mountBlock)) -join "`n"
74
+ } else {
75
+ $body = (@($lines) + @('', $mountBlock)) -join "`n"
76
+ }
77
+ $utf8 = New-Object System.Text.UTF8Encoding($false)
78
+ [System.IO.File]::WriteAllText($patchFile, ($body.TrimEnd() + "`n"), $utf8)
79
+ Write-Host "Mounted dsh-mindmap in $patchFile"
80
+
81
+ Write-Host ''
82
+ Write-Host 'Done. Open the sidebar entry "话题地图" (Topic map).'
83
+ Write-Host 'Profiles with HMR reload automatically; otherwise restart DSH.'