feat: 着陆页加 Windows 安装命令 + PowerShell 安装脚本

- 新增 install.ps1(与 install.sh 功能对等)
- 着陆页 Step 1 加 macOS/Linux 和 Windows Tab 切换
- SVG 图标美化 Tab 按钮
This commit is contained in:
2026-04-07 08:30:27 +08:00
parent f370632809
commit aaa938ad45
2 changed files with 1150 additions and 0 deletions
+170
View File
@@ -0,0 +1,170 @@
# 黑手党提案 Agent — Windows 一键安装/更新脚本 (PowerShell)
# 用法: irm https://git.brainwork.club/lidf/chanpinhsd/archive/main.zip -OutFile $env:TEMP\mafia.zip; Expand-Archive $env:TEMP\mafia.zip $env:TEMP\mafia -Force; & $env:TEMP\mafia\chanpinhsd\agent\install.ps1
$ErrorActionPreference = "Stop"
function Write-Info($msg) { Write-Host "[mafia] $msg" -ForegroundColor Green }
function Write-Warn($msg) { Write-Host "[mafia] $msg" -ForegroundColor Yellow }
function Write-Err($msg) { Write-Host "[mafia] $msg" -ForegroundColor Red; exit 1 }
$COPAW_HOME = if ($env:COPAW_HOME) { $env:COPAW_HOME } else { Join-Path $env:USERPROFILE ".copaw" }
$AGENT_ID = "mafia-expert"
$WORKSPACE_DIR = Join-Path $COPAW_HOME "workspaces\$AGENT_ID"
$SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path
# ── 检查 CoPaw ────────────────────────────────────────────────────────
if (-not (Test-Path (Join-Path $COPAW_HOME "config.json"))) {
Write-Err "CoPaw 未安装。请先安装 CoPaw 桌面客户端:https://copaw.agentscope.io"
}
Write-Info "CoPaw 已就绪"
# ── 创建工作区 ─────────────────────────────────────────────────────────
Write-Info "配置 $AGENT_ID 工作区..."
$dirs = @("skills", "cases", "iteration_reports", "memory")
foreach ($d in $dirs) {
$p = Join-Path $WORKSPACE_DIR $d
if (-not (Test-Path $p)) { New-Item -ItemType Directory -Path $p -Force | Out-Null }
}
# ── 核心配置 ───────────────────────────────────────────────────────────
$coreFiles = @("AGENTS.md", "SOUL.md", "PROFILE.md", "HEARTBEAT.md", "agent.json")
foreach ($f in $coreFiles) {
$src = Join-Path $SCRIPT_DIR $f
if (Test-Path $src) { Copy-Item $src (Join-Path $WORKSPACE_DIR $f) -Force }
}
# MEMORY.md 只在首次创建
$memPath = Join-Path $WORKSPACE_DIR "MEMORY.md"
if (-not (Test-Path $memPath)) {
$memSrc = Join-Path $SCRIPT_DIR "MEMORY.md"
if (Test-Path $memSrc) { Copy-Item $memSrc $memPath }
else { Set-Content $memPath "# 黑手党提案专家长期记忆" -Encoding UTF8 }
}
# ── Skills(每次全量覆盖) ─────────────────────────────────────────────
$skillsSrc = Join-Path $SCRIPT_DIR "skills"
if (Test-Path $skillsSrc) {
Get-ChildItem $skillsSrc -Directory | ForEach-Object {
if ($_.Name -eq "mafia_agent_installer") { return }
$target = Join-Path $WORKSPACE_DIR "skills\$($_.Name)"
if (-not (Test-Path $target)) { New-Item -ItemType Directory -Path $target -Force | Out-Null }
Copy-Item "$($_.FullName)\*" $target -Force -Recurse 2>$null
}
}
Write-Info "文件复制完成"
# ── 合并 skill.json ────────────────────────────────────────────────────
Write-Info "注册自定义 Skills..."
$wsSkillJson = Join-Path $WORKSPACE_DIR "skill.json"
$repoSkillJson = Join-Path $SCRIPT_DIR "skill.json"
$pyScript = @"
import json, os, time
ws_skill = r'$wsSkillJson'
repo_skill = r'$repoSkillJson'
if os.path.exists(ws_skill):
with open(ws_skill, encoding='utf-8') as f:
manifest = json.load(f)
else:
manifest = {'schema_version': 'workspace-skill-manifest.v1', 'version': 0, 'skills': {}}
if os.path.exists(repo_skill):
with open(repo_skill, encoding='utf-8') as f:
repo = json.load(f)
for name, skill_cfg in repo.get('skills', {}).items():
manifest['skills'][name] = skill_cfg
print(f' + {name}')
skills_dir = os.path.join(r'$WORKSPACE_DIR', 'skills')
if os.path.isdir(skills_dir):
for d in os.listdir(skills_dir):
if d.startswith('.'):
continue
skill_md = os.path.join(skills_dir, d, 'SKILL.md')
if os.path.exists(skill_md) and d not in manifest['skills']:
manifest['skills'][d] = {
'enabled': True,
'channels': ['all'],
'source': 'customized',
'metadata': {
'name': d,
'description': '',
'version_text': '1.0.0',
'source': 'customized',
'protected': False,
'requirements': {'require_bins': [], 'require_envs': []},
},
'requirements': {'require_bins': [], 'require_envs': []},
}
print(f' + {d} (from dir)')
manifest['version'] = int(time.time() * 1000)
with open(ws_skill, 'w', encoding='utf-8') as f:
json.dump(manifest, f, indent=2, ensure_ascii=False)
print(' skills done')
"@
python3 -c $pyScript 2>$null
if ($LASTEXITCODE -ne 0) { python -c $pyScript }
# ── 注册到 config.json ─────────────────────────────────────────────────
Write-Info "注册 Agent..."
$regScript = @"
import json, os
config_path = os.path.join(r'$COPAW_HOME', 'config.json')
with open(config_path, 'r', encoding='utf-8') as f:
cfg = json.load(f)
agent_id = '$AGENT_ID'
ws_dir = r'$WORKSPACE_DIR'
changed = False
if agent_id not in cfg['agents']['profiles']:
cfg['agents']['profiles'][agent_id] = {
'id': agent_id,
'workspace_dir': ws_dir,
'enabled': True
}
changed = True
if agent_id not in cfg['agents']['agent_order']:
cfg['agents']['agent_order'].append(agent_id)
changed = True
if changed:
with open(config_path, 'w', encoding='utf-8') as f:
json.dump(cfg, f, indent=2, ensure_ascii=False)
print(' registered')
else:
print(' already registered')
"@
python3 -c $regScript 2>$null
if ($LASTEXITCODE -ne 0) { python -c $regScript }
# ── 记录来源 ───────────────────────────────────────────────────────────
$repoDir = Split-Path -Parent $SCRIPT_DIR
Set-Content (Join-Path $WORKSPACE_DIR ".repo_path") $repoDir -Encoding UTF8
# ── 清理临时文件 ───────────────────────────────────────────────────────
if ($SCRIPT_DIR -like "$env:TEMP*") {
Write-Info "清理临时文件..."
Remove-Item $repoDir -Recurse -Force -ErrorAction SilentlyContinue
}
# ── 完成 ───────────────────────────────────────────────────────────────
Write-Host ""
Write-Info "════════════════════════════════════════════════"
Write-Info " ✅ 黑手党提案专家 安装/更新完成!"
Write-Info "════════════════════════════════════════════════"
Write-Host ""
Write-Info "下一步:"
Write-Info " 1. 打开 CoPaw 客户端"
Write-Info " 2. 刷新页面(Ctrl+R / F5"
Write-Info " 3. 左上角切换到「黑手党提案专家」"
Write-Info " 4. 发送:我想为 XX 品牌做一个黑手党提案"
Write-Host ""