|
|
@@ -1,4 +1,4 @@
|
|
|
-#!/usr/bin/env pwsh
|
|
|
+#!/usr/bin/env pwsh
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
# evolve.ps1 — novel-write 自优化编排器 (PowerShell)
|
|
|
# 进化结果写入 evolution/ 文件夹,不修改 SKILL.md
|
|
|
@@ -13,6 +13,15 @@
|
|
|
# .\evolve.ps1 -Compile # 编译:从事件日志重建进化状态
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
|
|
+param(
|
|
|
+ [string]$Project = "",
|
|
|
+ [switch]$Quick,
|
|
|
+ [switch]$Full,
|
|
|
+ [switch]$Sync,
|
|
|
+ [switch]$Report,
|
|
|
+ [switch]$Compile
|
|
|
+)
|
|
|
+
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
|
$SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
|
@@ -134,11 +143,13 @@ function Find-Project {
|
|
|
function Get-GenreId {
|
|
|
param([string]$ProjectPath)
|
|
|
try {
|
|
|
+ $scriptDirUnix = $SCRIPT_DIR -replace '\\', '/'
|
|
|
+ $projectPathUnix = $ProjectPath -replace '\\', '/'
|
|
|
$result = & $PYTHON -c @"
|
|
|
-import sys; sys.path.insert(0, '$($SCRIPT_DIR -replace '\\','/')')
|
|
|
+import sys; sys.path.insert(0, '$scriptDirUnix')
|
|
|
from utils import find_project_genre, map_genre_to_inkos_id
|
|
|
from pathlib import Path
|
|
|
-print(map_genre_to_inkos_id(find_project_genre(Path('$($ProjectPath -replace '\\','/')'))))
|
|
|
+print(map_genre_to_inkos_id(find_project_genre(Path('$projectPathUnix'))))
|
|
|
"@ 2>$null
|
|
|
if ($result) { return $result.Trim() }
|
|
|
} catch { }
|
|
|
@@ -169,12 +180,13 @@ function Invoke-PhaseCollect {
|
|
|
Write-Log " 题材: $genreId"
|
|
|
|
|
|
# 首次使用:初始化题材进化目录
|
|
|
- $genreDir = Join-Path $EVOLUTION_DIR "genres" $genreId
|
|
|
+ $genreDir = Join-Path (Join-Path $EVOLUTION_DIR "genres") $genreId
|
|
|
if (-not (Test-Path $genreDir)) {
|
|
|
Write-Log " 初始化题材进化目录: evolution/genres/$genreId/"
|
|
|
try {
|
|
|
+ $scriptDirUnix = $SCRIPT_DIR -replace '\\', '/'
|
|
|
& $PYTHON -c @"
|
|
|
-import sys; sys.path.insert(0, '$($SCRIPT_DIR -replace '\\','/')')
|
|
|
+import sys; sys.path.insert(0, '$scriptDirUnix')
|
|
|
from seed_extractor import SeedExtractor
|
|
|
SeedExtractor().initialize_genre('$genreId')
|
|
|
"@ 2>$null
|
|
|
@@ -233,7 +245,7 @@ function Invoke-PhaseReport {
|
|
|
if ($Project) {
|
|
|
$genreId = Get-GenreId -ProjectPath $Project
|
|
|
if ($genreId) {
|
|
|
- $genreDir = Join-Path $EVOLUTION_DIR "genres" $genreId
|
|
|
+ $genreDir = Join-Path (Join-Path $EVOLUTION_DIR "genres") $genreId
|
|
|
if (Test-Path $genreDir) {
|
|
|
Write-Host ""
|
|
|
Write-Host "## 题材级进化 (evolution/genres/$genreId/)" -ForegroundColor Cyan
|
|
|
@@ -272,9 +284,10 @@ function Invoke-PhaseReport {
|
|
|
$sessionFile = Join-Path $EVOLUTION_DIR "session_state.json"
|
|
|
if (Test-Path $sessionFile) {
|
|
|
try {
|
|
|
+ $sessionFileUnix = $sessionFile -replace '\\', '/'
|
|
|
& $PYTHON -c @"
|
|
|
import json
|
|
|
-state = json.loads(open('$($sessionFile -replace '\\','/')').read())
|
|
|
+state = json.loads(open('$sessionFileUnix').read())
|
|
|
print(f' 反馈数: {state.get(\"total_feedback_count\", 0)}')
|
|
|
recent = state.get('recent_chapters', [])
|
|
|
if recent:
|
|
|
@@ -404,7 +417,7 @@ function Main {
|
|
|
if ($Project) {
|
|
|
$genreId = Get-GenreId -ProjectPath $Project
|
|
|
if ($genreId) {
|
|
|
- $genreDir = Join-Path $EVOLUTION_DIR "genres" $genreId
|
|
|
+ $genreDir = Join-Path (Join-Path $EVOLUTION_DIR "genres") $genreId
|
|
|
if (Test-Path $genreDir) {
|
|
|
Write-Host ""
|
|
|
Write-Host " evolution/ 目录内容 (题材级: $genreId):"
|
|
|
@@ -422,13 +435,4 @@ function Main {
|
|
|
|
|
|
# ── 入口 ───────────────────────────────────────────────
|
|
|
|
|
|
-param(
|
|
|
- [string]$Project = "",
|
|
|
- [switch]$Quick,
|
|
|
- [switch]$Full,
|
|
|
- [switch]$Sync,
|
|
|
- [switch]$Report,
|
|
|
- [switch]$Compile
|
|
|
-)
|
|
|
-
|
|
|
Main -Project $Project -Quick:$Quick -Full:$Full -Sync:$Sync -Report:$Report -Compile:$Compile
|