@waterwx/dsh-novel-forge 1.3.0 → 1.3.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.
- package/package.json +2 -1
- package/scripts/assistant-frames.txt +8 -0
- package/scripts/diagnose-adapter.mts +81 -0
- package/scripts/diagnose-assistant.mjs +58 -0
- package/scripts/diagnose-bible.mjs +72 -0
- package/scripts/diagnose-harness.mts +75 -0
- package/scripts/novel-forge-restart.log +10 -0
- package/scripts/novel-forge-web.stderr.log +2 -0
- package/scripts/novel-forge-web.stdout.log +1 -0
- package/scripts/outline-sample.txt +449 -0
- package/scripts/patch-schemastery.mjs +47 -0
- package/scripts/probe.mjs +6 -0
- package/scripts/restart-web.ps1 +88 -0
- package/scripts/smoke.mts +72 -0
- package/scripts/upload-github.ps1 +51 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Upload the dsh-novel-forge project to GitHub via the Contents API.
|
|
2
|
+
# Uses the current token (passed as $env:GH_TOKEN) — one PUT per file,
|
|
3
|
+
# directories are created implicitly. Retries transient failures once.
|
|
4
|
+
param(
|
|
5
|
+
[string]$Owner = "watersxya",
|
|
6
|
+
[string]$Repo = "dsh-novel-forge",
|
|
7
|
+
[string]$SourceDir = "C:\Users\Ryan\Desktop\ai xiaoshuo",
|
|
8
|
+
[string]$Branch = "main"
|
|
9
|
+
)
|
|
10
|
+
$ErrorActionPreference = 'Stop'
|
|
11
|
+
$token = $env:GH_TOKEN
|
|
12
|
+
if ([string]::IsNullOrEmpty($token)) { Write-Host "GH_TOKEN env var required"; exit 1 }
|
|
13
|
+
$headers = @{
|
|
14
|
+
Authorization = "Bearer $token"
|
|
15
|
+
'User-Agent' = 'dsh-novel-forge-uploader'
|
|
16
|
+
'X-GitHub-Api-Version' = '2022-11-28'
|
|
17
|
+
}
|
|
18
|
+
$base = "https://api.github.com/repos/$Owner/$Repo/contents"
|
|
19
|
+
$files = Get-ChildItem $SourceDir -Recurse -File
|
|
20
|
+
$log = Join-Path $SourceDir 'upload-log.txt'
|
|
21
|
+
"=== upload started $(Get-Date) ===" | Set-Content $log -Encoding UTF8
|
|
22
|
+
$ok = 0; $failed = 0
|
|
23
|
+
foreach ($file in $files) {
|
|
24
|
+
$rel = $file.FullName.Substring($SourceDir.Length + 1).Replace('\', '/')
|
|
25
|
+
$bytes = [System.IO.File]::ReadAllBytes($file.FullName)
|
|
26
|
+
$contentB64 = [System.Convert]::ToBase64String($bytes)
|
|
27
|
+
$body = @{ message = "Add $rel"; content = $contentB64; branch = $Branch } | ConvertTo-Json
|
|
28
|
+
$done = $false
|
|
29
|
+
for ($attempt = 1; $attempt -le 2 -and -not $done; $attempt++) {
|
|
30
|
+
try {
|
|
31
|
+
$null = Invoke-RestMethod -Uri "$base/$rel" -Headers $headers -Method PUT -Body $body -ContentType "application/json" -TimeoutSec 60
|
|
32
|
+
$done = $true
|
|
33
|
+
$ok++
|
|
34
|
+
"[OK] $rel" | Add-Content $log -Encoding UTF8
|
|
35
|
+
} catch {
|
|
36
|
+
$resp = $_.Exception.Response
|
|
37
|
+
$status = if ($resp) { [int]$resp.StatusCode } else { 0 }
|
|
38
|
+
if ($attempt -eq 2 -or $status -ne 502 -and $status -ne 503) {
|
|
39
|
+
$msg = if ($resp) { (New-Object System.IO.StreamReader($resp.GetResponseStream())).ReadToEnd() } else { $_.Exception.Message }
|
|
40
|
+
$failed++
|
|
41
|
+
"[FAIL] $rel -> HTTP $status $msg" | Add-Content $log -Encoding UTF8
|
|
42
|
+
Write-Host "[FAIL] $rel -> HTTP $status"
|
|
43
|
+
break
|
|
44
|
+
}
|
|
45
|
+
Start-Sleep -Seconds 3
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if ($done) { Write-Host "[OK] $rel" }
|
|
49
|
+
}
|
|
50
|
+
"=== done: ok=$ok failed=$failed ===" | Add-Content $log -Encoding UTF8
|
|
51
|
+
Write-Host "=== done: ok=$ok failed=$failed ==="
|