Repository navigation
Expand file tree
/
Copy pathsetup.ps1
More file actions
199 lines (177 loc) · 7.12 KB
/
Copy pathsetup.ps1
File metadata and controls
199 lines (177 loc) · 7.12 KB
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<#
.SYNOPSIS
Yukinary Turnkey Setup & Installer for Windows
.DESCRIPTION
Installs Yukinary Compiler, Standard Library, LSP Server, and VS Code
Extension into %USERPROFILE%\.yukinary, automatically configuring User PATH
and system shims for instant 'ykn' CLI access.
#>
$ErrorActionPreference = "Stop"
Write-Host ""
Write-Host "========================================================" -ForegroundColor Cyan
Write-Host " Yukinary v1.0.0 Turnkey Setup (Windows) " -ForegroundColor Yellow
Write-Host "========================================================" -ForegroundColor Cyan
Write-Host ""
$baseDir = $PSScriptRoot
if (-not $baseDir) {
$baseDir = (Get-Location).Path
}
$userDir = $env:USERPROFILE
$yknHome = Join-Path $userDir ".yukinary"
$yknBin = Join-Path $yknHome "bin"
$yknStd = Join-Path $yknHome "std"
# 1. Create target directories
if (-not (Test-Path $yknBin)) {
New-Item -ItemType Directory -Force -Path $yknBin | Out-Null
}
if (-not (Test-Path $yknStd)) {
New-Item -ItemType Directory -Force -Path $yknStd | Out-Null
}
# Stop running ykn background processes before updating binaries
Get-Process "ykn*", "ykn_lsp*" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Start-Sleep -Milliseconds 300
# 2. Locate ykn.exe binary
$candidateExes = @(
(Join-Path $baseDir "ykn.exe"),
(Join-Path $baseDir "bin\ykn.exe"),
(Join-Path $baseDir "app_full.exe")
)
$srcExe = $null
foreach ($c in $candidateExes) {
if (Test-Path $c) {
$srcExe = $c
break
}
}
if (-not $srcExe) {
Write-Host "[ERROR] ykn.exe binary not found in $baseDir" -ForegroundColor Red
exit 1
}
function Install-FileSafe($src, $dst) {
if (-not (Test-Path $src)) { return }
try {
Copy-Item $src $dst -Force -ErrorAction Stop
} catch {
$oldFile = "$dst.old"
if (Test-Path $oldFile) {
Remove-Item $oldFile -Force -ErrorAction SilentlyContinue
}
Move-Item $dst $oldFile -Force -ErrorAction SilentlyContinue
Copy-Item $src $dst -Force -ErrorAction SilentlyContinue
Remove-Item $oldFile -Force -ErrorAction SilentlyContinue
}
}
Install-FileSafe $srcExe (Join-Path $yknBin "ykn.exe")
Install-FileSafe $srcExe (Join-Path $yknBin "ykn_lsp.exe")
Write-Host "[+] Installed ykn.exe and ykn_lsp.exe to $yknBin" -ForegroundColor Green
# 2b. Locate and install ykn_llm_simd.dll (AVX2 SIMD acceleration runtime for Windows)
$candidateDlls = @(
(Join-Path $baseDir "ykn_llm_simd.dll"),
(Join-Path $baseDir "bin\ykn_llm_simd.dll"),
(Join-Path $baseDir "build\ykn_llm_simd.dll")
)
$srcDll = $null
foreach ($d in $candidateDlls) {
if (Test-Path $d) {
$srcDll = $d
break
}
}
if ($srcDll) {
Install-FileSafe $srcDll (Join-Path $yknBin "ykn_llm_simd.dll")
Write-Host "[+] Installed ykn_llm_simd.dll to $yknBin" -ForegroundColor Green
} else {
Write-Host "[!] Note: ykn_llm_simd.dll not found in $baseDir" -ForegroundColor Yellow
}
# 3. Create ykn.cmd shim for instant cmd.exe execution
$cmdShim = "@echo off`r`n`"%~dp0ykn.exe`" %*"
Set-Content -Path (Join-Path $yknBin "ykn.cmd") -Value $cmdShim -Encoding ASCII
Write-Host "[+] Created ykn.cmd shim" -ForegroundColor Green
# 4. Copy Standard Library (std/)
$candidateStd = @(
(Join-Path $baseDir "std"),
(Join-Path $baseDir "..\std")
)
$srcStd = $null
foreach ($s in $candidateStd) {
if (Test-Path $s) {
$srcStd = $s
break
}
}
if ($srcStd) {
Copy-Item -Path "$srcStd\*" -Destination $yknStd -Recurse -Force
Write-Host "[+] Installed Yukinary Standard Library to $yknStd" -ForegroundColor Green
} else {
Write-Host "[!] Warning: std/ directory not found nearby. Standard library skipped." -ForegroundColor Yellow
}
# 5. Locate and install VS Code Extension (.vsix)
$candidateVsix = @(
(Join-Path $baseDir "yukinary-lang-1.0.0.vsix"),
(Join-Path $baseDir "vscode\yukinary-lang-1.0.0.vsix"),
(Join-Path $baseDir "vscode-eklentisi\yukinary-lang-1.0.0.vsix")
)
$srcVsix = $null
foreach ($v in $candidateVsix) {
if (Test-Path $v) {
$srcVsix = $v
break
}
}
$codeCli = Get-Command "code" -ErrorAction SilentlyContinue
if ($codeCli -and $srcVsix) {
Write-Host "[*] Visual Studio Code detected. Installing Yukinary extension..." -ForegroundColor Cyan
try {
& code --install-extension $srcVsix --force | Out-Null
Write-Host "[+] VS Code Extension (yukinary-lang-1.0.0) successfully installed!" -ForegroundColor Green
} catch {
Write-Host "[!] Note: Could not auto-install VS Code extension: $_" -ForegroundColor Yellow
}
} elseif ($srcVsix) {
Write-Host "[*] VS Code extension package ready at: $srcVsix" -ForegroundColor Gray
Write-Host " (Run 'code --install-extension $srcVsix' to install anytime)" -ForegroundColor Gray
}
# 6. Configure User PATH environment variable
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
$cleanParts = $currentPath -split ";" | Where-Object { $_ -ne "" -and $_ -notlike "*\.yukinary\bin*" }
$newPath = "$yknBin;" + ($cleanParts -join ";")
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
$env:Path = "$yknBin;$env:Path"
# 7. Sync to WindowsApps (Guaranteed fallback for Windows 10/11)
$winApps = Join-Path $env:LOCALAPPDATA "Microsoft\WindowsApps"
if (Test-Path $winApps) {
Install-FileSafe (Join-Path $yknBin "ykn.exe") (Join-Path $winApps "ykn.exe")
Install-FileSafe (Join-Path $yknBin "ykn.cmd") (Join-Path $winApps "ykn.cmd")
if (Test-Path (Join-Path $yknBin "ykn_llm_simd.dll")) {
Install-FileSafe (Join-Path $yknBin "ykn_llm_simd.dll") (Join-Path $winApps "ykn_llm_simd.dll")
}
}
# 8. Broadcast WM_SETTINGCHANGE to notify running shells
try {
Add-Type -Namespace Win32 -Name NativeMethods -MemberDefinition @"
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
public static extern System.IntPtr SendMessageTimeout(
System.IntPtr hWnd,
uint Msg,
System.UIntPtr wParam,
string lParam,
uint fuFlags,
uint uTimeout,
out System.UIntPtr lpdwResult);
"@ -ErrorAction SilentlyContinue | Out-Null
$result = [System.UIntPtr]::Zero
[Win32.NativeMethods]::SendMessageTimeout([System.IntPtr]0xffff, 0x001A, [System.UIntPtr]::Zero, "Environment", 2, 5000, [ref]$result) | Out-Null
} catch {
# Non-critical fallback
}
Write-Host ""
Write-Host "========================================================" -ForegroundColor Green
Write-Host " YUKINARY HAS BEEN SUCCESSFULLY INSTALLED & CONFIGURED!" -ForegroundColor Green
Write-Host "========================================================" -ForegroundColor Green
Write-Host ""
Write-Host "You can now run 'ykn' directly from ANY terminal (PowerShell, CMD, Git Bash):" -ForegroundColor Cyan
Write-Host " ykn --yardim (Goster yardim mesaji)" -ForegroundColor White
Write-Host " ykn --version (Surum kontrolu)" -ForegroundColor White
Write-Host " ykn dosya.ykn (Derle ve calistir)" -ForegroundColor White
Write-Host " ykn convert kod.py (Python -> Yukinary AI donusumu)" -ForegroundColor White
Write-Host ""