caveman Windows 安装深度指南:irm | iex 失败后的手动兜底与完整回退路径
【免费下载链接】caveman🪨 why use many token when few token do trick — Claude Code skill that cuts 65% of tokens by talking like caveman项目地址: https://gitcode.com/GitHub_Trending/caveman1/caveman
caveman 的官方一条式安装命令irm ... install.ps1 | iex在部分 Windows 环境下会因引号、执行策略或 JSON 合并丢失而失败。本文以仓库中 docs/install-windows.md 为主线,讲清 Windows 安装失败后的完整手动回退方案:如何用 PowerShell 脚本手动完成 Claude Code 的 plugin-skill 激活、如何验证安装结果、Codex 在 Windows 上的符号链接限制,以及npx skills的--copy兜底写法,并结合 install.ps1 与 bin/install.js 的源码解释每条回退路径背后的设计原因。读完本文,你可以独立完成 Windows 上 caveman 的安装、验证与常驻配置。
一条式安装的架构:install.ps1 只是薄壳
理解 Windows 兜底方案前,先要弄清一条式命令到底在做什么。install.ps1 顶部注释写明,它是围绕 bin/install.js(统一 Node 安装器)的"thin wrapper",所有传给它的 flag 都会原样转发。整个脚本只有一层函数包装和两条执行路径:
# 仓库内 clone 路径:若本地存在 bin/install.js,直接运行 if ($PSCommandPath) { $here = Split-Path -Parent $PSCommandPath $local = Join-Path $here "bin/install.js" if (Test-Path $local) { & node $local @InstallerArgs exit $LASTEXITCODE } } # curl-pipe 路径:委托给 npx(默认钉在 v2.4.0,可用 CAVEMAN_REF 覆盖) & npx -y "github:$Repo#$PinnedRef" @InstallerArgs这段代码透露了 Windows 安装历史上出过什么问题:
- 为什么必须是 Node 安装器?源码注释明确写道(install.ps1):
install.sh和install.ps1曾经是两份并行维护的"真相来源",不断漂移;issue #249 就是一个node -e "..."引号 bug,导致每次 Windows 安装都静默丢掉了 JSON 合并步骤。换成一份到处都能跑的 Node 脚本后,引号 bug 被根除。这正是 docs/install-windows.md 开头说"irm失败(issues #249, #199, #72)"的历史背景。 - 为什么包在函数里而不是顶层
param()?irm | iex会把脚本当字符串执行,此时$PSCommandPath为$null,顶层param块也收不到管道传参(issue #565)。旧代码对$PSCommandPath无保护地做Split-Path时,直接崩溃报 "Cannot bind argument to parameter 'Path' because it is null"。包成Install-Caveman函数后,一条脚本同时兼容"无参无路径的管道路径"和"本地 clone 路径"(install.ps1)。 - 前置依赖:要求 Node ≥ 18(脚本会检查主版本,不满足直接报错退出);npx 随 Node ≥ 18 自带,缺失时提示重装 Node.js。
- 版本钉住:默认
$PinnedRef = "v2.4.0",仅当刻意测试其他 ref 时才设CAVEMAN_REF环境变量。
由于是薄壳,统一安装器的全部能力在 Windows 上同样可用:从 clone 里执行node bin/install.js --dry-run预览全部命令、--list查看约 30 行的 agent 检测矩阵、--only claude只装一个 agent、--force强制重跑。完整 flag 语义见 INSTALL.md 的 flag 表。
手动兜底:PowerShell 脚本完成 plugin-skill 激活
当一条式安装失败时,docs/install-windows.md 给出的核心方案是手工建立 plugin-skill 激活。需要明确这条路径的边界:它不安装独立 hooks,也不安装statusline——这两者之后要用统一 Node 安装器补上(命令见下文"补全 hooks 与 statusline"小节)。
脚本完整内容(从仓库 clone 中执行):
$ClaudeDir = if ($env:CLAUDE_CONFIG_DIR) { $env:CLAUDE_CONFIG_DIR } else { Join-Path $HOME ".claude" } $PluginSkillDir = Join-Path $ClaudeDir ".agents\plugins\caveman\skills\caveman" $MarketplaceDir = Join-Path $ClaudeDir ".agents\plugins" $MarketplaceFile = Join-Path $MarketplaceDir "marketplace.json" # Copy SKILL.md into the plugin path (run from a clone of the repo) New-Item -ItemType Directory -Path $PluginSkillDir -Force | Out-Null Copy-Item ".\skills\caveman\SKILL.md" "$PluginSkillDir\SKILL.md" -Force # Create or update marketplace.json with the caveman entry New-Item -ItemType Directory -Path $MarketplaceDir -Force | Out-Null if (Test-Path $MarketplaceFile) { $marketplace = Get-Content $MarketplaceFile -Raw | ConvertFrom-Json } else { $marketplace = [pscustomobject]@{} } if (-not ($marketplace.PSObject.Properties.Name -contains "plugins")) { $marketplace | Add-Member -NotePropertyName plugins -NotePropertyValue ([pscustomobject]@{}) } $plugins = [ordered]@{} foreach ($p in $marketplace.plugins.PSObject.Properties) { $plugins[$p.Name] = $p.Value } $plugins["caveman"] = [ordered]@{ name = "caveman"; source = "JuliusBrussee/caveman"; version = "main" } $marketplace.plugins = [pscustomobject]$plugins $marketplace | ConvertTo-Json -Depth 10 | Set-Content -Path $MarketplaceFile -Encoding UTF8逐段拆解这个脚本在做什么:
1. 配置目录解析
$ClaudeDir优先读CLAUDE_CONFIG_DIR环境变量,缺省回落到~/.claude。这与 INSTALL.md 中--config-dirflag 的语义一致("Default:$CLAUDE_CONFIG_DIRor~/.claude"),即 Claude Code 的全部状态都以该目录为根。
2. 复制技能文件到插件路径
skills\caveman\SKILL.md是 caveman 技能的唯一内容源——一个带 frontmatter 的 Markdown 文件,声明了技能名、触发词(/caveman、"caveman mode"、"talk like caveman" 等)以及 lite/full/ultra/wenyan 等强度级别的完整压缩规则。脚本把它复制进$ClaudeDir\.agents\plugins\caveman\skills\caveman\SKILL.md。注意源路径.\skills\caveman\SKILL.md是相对路径,因此必须在仓库 clone 根目录下运行该脚本(仓库内的实际文件即 skills/caveman/SKILL.md)。
3. 合并写入 marketplace.json
后半段是典型的"读—改—写"JSON 合并,几个细节值得注意:
- 保留已有条目:先解析现有
marketplace.json(不存在则建空对象),用[ordered]@{}按原顺序收集全部plugins条目,再把caveman追加到末尾。这保证不会覆盖你机器上其他 marketplace 插件。 - caveman 条目本身:
name = "caveman"; source = "JuliusBrussee/caveman"; version = "main",其中source指向上游仓库、version钉在main分支。 ConvertTo-Json -Depth 10:嵌套深度足够,避免plugins下的对象结构被 PowerShell 默认深度截断成空。- 这正是 #249 那类 bug 的正面教材:安装器侧曾因引号 bug 静默丢掉这个 JSON 合并步骤,所以手动脚本把它写得足够显式、无子进程引号嵌套。
验证
Test-Path "$PluginSkillDir\SKILL.md" # 应输出 True然后重启 Claude Code,输入/caveman确认技能加载。若响应变成简短的碎片句(如 "Got it. Caveman mode on."),说明技能文件已被读取生效。
补全 hooks 与 statusline:统一 Node 安装器
手动脚本只完成了 skill 激活。文档明确说 standalone hooks 和 statusline 不在其中,需要随后运行:
npx -y github:JuliusBrussee/caveman -- --only claude或在 clone 内:
node bin/install.js --only claude补上之后,Claude Code 侧才具备完整的 hook 链路。这些 hook 文件在仓库里都有对应源码,位于 src/hooks/:
- caveman-activate.js:SessionStart 时写入
.caveman-active标志文件; - caveman-mode-tracker.js:按会话记录模式开关状态到
.caveman-sessions/; - caveman-statusline.ps1 与 caveman-statusline.sh:PowerShell 与 Shell 双版本状态栏,在 Claude Code 底部显示
[CAVEMAN]徽标。
INSTALL.md 的故障排查一节专门针对 Windows 强调了这一点:Git Bash 下跑install.sh也能装,但 hook 侧配的是 PowerShell 版本(caveman-statusline.ps1),所以推荐直接用install.ps1;最低要求 PowerShell 5.1,用$PSVersionTable.PSVersion检查;若irm | iex被执行策略拦截,先Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass再重试。
补装完成后的验证方式(来自 INSTALL.md 的 Verify 节):
# 1. 查看 agent 检测矩阵,确认 claude 被识别 node bin/install.js --list # 2. 检查标志文件(内容应为 full) Get-Content "${env:CLAUDE_CONFIG_DIR:$HOME/.claude}\.caveman-active" # 3. 多窗口状态下逐一查看 ls "${env:CLAUDE_CONFIG_DIR:$HOME/.claude}\.caveman-sessions\"Codex on Windows:符号链接前置与手动激活
文档的 "Codex on Windows" 一节给出三步流程,核心障碍是符号链接权限:
- 先启用符号链接:
git config --global core.symlinks true——前提是系统已开启 Developer Mode 或你以管理员运行; - 装插件:clone 仓库 → 打开 VS Code → Codex Settings → Plugins → 在 local marketplace 中找到 "Caveman" → Install → Reload Window;
- 手动激活:Codex hooks 目前在 Windows 上处于禁用状态,因此每个会话都要用
$caveman手动开启模式。
第 1 步与 Windows 平台的硬限制直接相关:非管理员账户创建符号链接需要开发者模式授权,这也是后面npx skills --copy兜底存在的同一个根因。
npx skills的 symlink 兜底:加--copy
npx skills add默认用符号链接落地技能文件。当 Windows 上符号链接创建失败(未开开发者模式、非管理员)时,加--copy让 CLI 改为实体复制:
npx skills add JuliusBrussee/caveman --copy这条命令适用于 Codex、Cursor、Windsurf 等走npx skills通道的 agent(完整 agent 列表与 profile slug 见 INSTALL.md 的 Per-agent install 表)。另一个容易踩的坑:npx skills add默认写入当前运行目录的./.agents/skills,不带-g时按用户全局目录读取技能的 agent(如 Cursor 读~/.cursor/skills)根本看不到——全局安装要加-g。
想要任何 agent 常驻开启:静态规则文本
对于没有 hook 系统的 agent(Cursor、Windsurf、Cline、Copilot 等),文档最后一节给出"always on"方案:把下面这段规则直接贴进 agent 的 system prompt 或 rules 文件:
Terse like caveman. Technical substance exact. Only fluff die. Drop: articles, filler (just/really/basically), pleasantries, hedging. Fragments OK. Short synonyms. Code unchanged. Pattern: [thing] [action] [reason]. [next step]. ACTIVE EVERY RESPONSE. No revert after many turns. No filler drift. Code/commits/PRs: normal. Off: "stop caveman" / "normal mode".这段短文本是 skills/caveman/SKILL.md 完整规则的极简压缩版:保留技术实质、删掉冠词/填充词/客套/模糊措辞,[thing] [action] [reason]. [next step].是其输出句式模板;代码块、commit、PR 正文保持正常书写,stop caveman或normal mode可随时退出。仓库中统一安装器的对应自动化路径是--with-init,它会把规则写入.cursor/rules/、.windsurf/rules/、.clinerules/、.github/copilot-instructions.md、AGENTS.md等各 agent 位置(规则正文单一来源为 src/rules/caveman-activate.md);在不允许 hook 的受管环境中,这是"零全局状态、只落当前仓库"的合规做法:
node bin/install.js --with-init --only cursor --only windsurf故障排查速查表
把文档与 INSTALL.md 中 Windows 相关的排查要点汇总成一张表:
| 症状 | 原因 | 处置 |
|---|---|---|
irm \| iex执行后被拦截 | PowerShell 执行策略 | Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass后重跑 |
| 报错 "Cannot bind argument to parameter 'Path' because it is null" | 旧版脚本对管道下为$null的$PSCommandPath无保护操作(issue #565) | 更新到当前 install.ps1,函数包装已修复 |
安装"成功"但settings.json里没有 caveman 条目 | 旧版引号 bug 静默丢失 JSON 合并(issue #249) | 用当前 Node 统一安装器重装:node bin/install.js --only claude --force |
| Claude Code 仍用正常口吻 | claude不在 PATH / hook 未注册 | node bin/install.js --list确认检测;查settings.json中caveman-activate.js;重启 Claude Code(SessionStart hook 只在会话开始时触发) |
npx skills add符号链接失败 | 非管理员且未开开发者模式 | 加--copy参数实体复制 |
| Codex 装了但 hooks 无效 | Codex hooks 在 Windows 上当前禁用 | 每会话用$caveman手动开启 |
| PowerShell 版本过低 | 最低要求 5.1 | $PSVersionTable.PSVersion检查后升级 |
小结
Windows 上 caveman 的安装失败绝大多数集中在两个根因:PowerShell 字符串插值里的引号嵌套(历史 JSON 合并丢失)与符号链接权限限制。仓库的应对策略是把安装逻辑收敛到单一 Node 脚本(bin/install.js),install.ps1 退化为纯转发薄壳;再为确实走不通的环境提供 docs/install-windows.md 这条手动兜底:PowerShell 脚本手工完成SKILL.md复制与marketplace.json合并,统一安装器补 hooks 与 statusline,--copy与--with-init分别化解符号链接与常驻规则两个问题。按"一条式 → 手动 plugin-skill → 统一安装器补全 →--copy/规则文件"的顺序逐级回退,可以覆盖绝大多数 Windows 环境。
【免费下载链接】caveman🪨 why use many token when few token do trick — Claude Code skill that cuts 65% of tokens by talking like caveman项目地址: https://gitcode.com/GitHub_Trending/caveman1/caveman
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考