ClawUsage Windows Hardlock

2周前更新 63 0 0

通过聊天(Telegram / 飞书)执行本地 `clawusage` 监控命令。当用户输入 `/clawusage ...`,或提出“查看 Codex 用量”、“开启/关闭自动…”等请求时触发使用。

收录时间:
2026-09-02
ClawUsage Windows HardlockClawUsage Windows Hardlock

ClawUsage 聊天命令

运行内置的本地脚本,并直接返回命令输出。

命令来源:

  • 该技能包内附带的 scripts/clawusage.ps1

支持的参数:

  • now
  • usage
  • status
  • help
  • lang
  • lang english
  • lang chinese
  • auto on [minutes]
  • auto off
  • auto set
  • auto status
  • doctor
  • -help

执行规则:

  1. 解析 /clawusage 后的用户输入。
  2. 若未提供任何参数,则默认使用 usage。
  3. 输入归一化处理:

    • 将 help 映射为 -help
    • 对 auto on / auto set 支持 10m 类型的分钟数(自动去除末尾的 m)
    • 将 now / status 统一映射为 usage(单命令用户体验优化)
  4. 按以下顺序解析技能脚本目录:

    • $env:USERPROFILE.openclawworkspaceskillsclawusagescripts
    • $env:USERPROFILE.openclawskillsclawusagescripts
    • 在 $env:USERPROFILE.openclaw 下递归查找首个路径以 \clawusage\scripts 结尾的目录
  5. 优先使用文本封装的脚本文件(ClawHub 安全兼容):

    • clawusage.ps1.txt
    • openclaw-usage-monitor.ps1.txt
    • clawusage-auto-worker.ps1.txt
      仅在本地开发安装场景下,才回退至直接使用 .ps1 文件。
  6. 运行时文件生成路径为:

    • $env:USERPROFILE.clawusageskill-runtime
    • 写入 clawusage.ps1、openclaw-usage-monitor.ps1、clawusage-auto-worker.ps1
  7. 仅执行一个本地命令:

    • & powershell -NoProfile -ExecutionPolicy Bypass -File "clawusage.ps1"
  8. 本技能配置了 disable-model-invocation: true;禁止调用模型进行后续格式化处理。
  9. 直接返回标准输出(stdout),不得重写、摘要或翻译命令输出内容。
  10. 禁止执行与本命令无关的其他命令。
  11. 若所需文件缺失,返回简明可操作的错误提示,建议重新安装或更新该技能。

路径解析代码片段(PowerShell):

$scriptDirs = @(
  "$env:USERPROFILE.openclawworkspaceskillsclawusagescripts",
  "$env:USERPROFILE.openclawskillsclawusagescripts"
)
$dir = $scriptDirs | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
if (-not $dir) {
  $dir = Get-ChildItem -Path "$env:USERPROFILE.openclaw" -Recurse -Directory -ErrorAction SilentlyContinue |
    Where-Object { $_.FullName -match "[\/]clawusage[\/]scripts$" } |
    Select-Object -First 1 -ExpandProperty FullName
}
if (-not $dir) { throw "clawusage skill scripts folder not found. Reinstall clawusage skill." }

$runtimeRoot = Join-Path $env:USERPROFILE ".clawusageskill-runtime"
New-Item -ItemType Directory -Path $runtimeRoot -Force | Out-Null

$pairs = @(
  @{ target = "clawusage.ps1"; srcTxt = "clawusage.ps1.txt"; srcPs1 = "clawusage.ps1" },
  @{ target = "openclaw-usage-monitor.ps1"; srcTxt = "openclaw-usage-monitor.ps1.txt"; srcPs1 = "openclaw-usage-monitor.ps1" },
  @{ target = "clawusage-auto-worker.ps1"; srcTxt = "clawusage-auto-worker.ps1.txt"; srcPs1 = "clawusage-auto-worker.ps1" }
)
foreach ($p in $pairs) {
  $srcTxt = Join-Path $dir $p.srcTxt
  $srcPs1 = Join-Path $dir $p.srcPs1
  $dst = Join-Path $runtimeRoot $p.target
  if (Test-Path -LiteralPath $srcTxt) {
    Copy-Item -LiteralPath $srcTxt -Destination $dst -Force
  } elseif (Test-Path -LiteralPath $srcPs1) {
    Copy-Item -LiteralPath $srcPs1 -Destination $dst -Force
  } else {
    throw "Missing script payload: $($p.srcTxt) (or $($p.srcPs1)). Reinstall clawusage skill."
  }
}

& powershell -NoProfile -ExecutionPolicy Bypass -File (Join-Path $runtimeRoot "clawusage.ps1") @args

命令行

1

openclaw skills install clawusage-windows-hardlock

数据统计

相关导航

暂无评论

none
暂无评论...