Skip to content

xinetzone/SpecWeave / .agents/skills/loop-engineering-cmd

loop-engineering-cmd

Verified

当用户提到'Loop Engineering'、'循环工程'、'自动迭代'、'验证器设计'、'自动优化循环'、'AI循环'、'Loop设计'、'三要素验证'、'适用性判定'、'循环设计检查'、'Loop风险评估'时,必须使用此技能。提供Loop Engineering设计验证与知识查询能力:适用性判定→三要素验证→五步法设计检查→风险评估→知识库查询。不要凭经验设计Loop——本Skill封装了三要素铁律、四项适用标准、五步设计法、双重风险防控(理解债+认知让渡),确保Loop设计不踩红线、ROI可控。

scripts/query-knowledge.ps1

View on GitHub
$ErrorActionPreference = "Stop"
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8

$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
. (Join-Path $ScriptDir "common.ps1")

$parsed = Parse-Arguments -Arguments $args -Defaults @{
    format = "markdown"
    category = "all"
    keyword = ""
}

$Format = Get-Format $parsed
$Category = "all"
if ($parsed.ContainsKey("category")) { $Category = [string]$parsed["category"] }

$Keyword = ""
if ($parsed.ContainsKey("keyword")) { $Keyword = [string]$parsed["keyword"] }

if ([string]::IsNullOrEmpty($Keyword)) {
    Write-Host "错误: 必须提供 --keyword 参数指定检索关键词" -ForegroundColor Red
    Write-Host "用法: loop-engineering-cmd query-knowledge --keyword <关键词> [--category <分类>]" -ForegroundColor Yellow
    exit 1
}

$KnowledgePath = Join-Path (Split-Path -Parent $ScriptDir) "data\knowledge.json"

if (-not (Test-Path $KnowledgePath)) {
    Write-Host "错误: 知识库文件不存在: $KnowledgePath" -ForegroundColor Red
    exit 1
}

try {
    $knowledge = Get-Content $KnowledgePath -Raw -Encoding UTF8 | ConvertFrom-Json
} catch {
    Write-Host "错误: 无法读取知识库: $_" -ForegroundColor Red
    exit 1
}

$keywordLower = $Keyword.ToLower()
$matched = @()

function Search-Category {
    param($Items, $CategoryName)
    foreach ($item in $Items) {
        $kw = @($item.keywords) -join " "
        $text = ($item.title + " " + $kw + " " + $item.content + " " + $item.id).ToLower()
        if ($text -like "*$keywordLower*") {
            $script:matched += @{
                id = $item.id
                category = $CategoryName
                title = $item.title
                keywords = $item.keywords
                content = $item.content
            }
        }
    }
}

switch ($Category.ToLower()) {
    "concept" { Search-Category $knowledge.concepts "概念" }
    "data" { Search-Category $knowledge.data "数据" }
    "case" { Search-Category $knowledge.cases "案例" }
    "risk" { Search-Category $knowledge.risks "风险" }
    "all" {
        Search-Category $knowledge.concepts "概念"
        Search-Category $knowledge.data "数据"
        Search-Category $knowledge.cases "案例"
        Search-Category $knowledge.risks "风险"
    }
    default {
        Write-Host "错误: 未知分类 '$Category',可选值: concept/data/case/risk/all" -ForegroundColor Red
        exit 1
    }
}

if ($Format -eq "json") {
    $output = @{
        command = "query-knowledge"
        keyword = $Keyword
        category = $Category
        total = $matched.Count
        results = $matched
    }
    $output | ConvertTo-Json -Depth 10
    exit 0
}

Write-Host "========================================" -ForegroundColor Cyan
Write-Host "  Loop Engineering - 知识库查询" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "关键词: $Keyword" -ForegroundColor White
Write-Host "分类: $Category" -ForegroundColor White
Write-Host "找到 $($matched.Count) 条结果" -ForegroundColor $(if ($matched.Count -gt 0) { "Green" } else { "Yellow" })
Write-Host ""

if ($matched.Count -eq 0) {
    Write-Host "[!] 未找到匹配的知识点。" -ForegroundColor Yellow
    Write-Host "  建议:尝试使用更通用的关键词,或使用 --category all 搜索全部分类。" -ForegroundColor Gray
    Write-Host ""
    Write-Host "热门关键词参考:" -ForegroundColor Yellow
    Write-Host "  三要素、验证器、状态文件、停止条件" -ForegroundColor Gray
    Write-Host "  适用标准、频率、预算、环境" -ForegroundColor Gray
    Write-Host "  五步法、探索、评分、变更" -ForegroundColor Gray
    Write-Host "  理解债、认知让渡、风险、ROI" -ForegroundColor Gray
    Write-Host "  正面案例、反面案例、作弊" -ForegroundColor Gray
    Write-Host ""
    exit 0
}

$grouped = $matched | Group-Object category
foreach ($group in $grouped) {
    Write-Host "[$($group.Name)]" -ForegroundColor Yellow
    foreach ($item in $group.Group) {
        Write-Host "  [*] $($item.title)" -ForegroundColor Green
        Write-Host "     ID: $($item.id)" -ForegroundColor DarkGray
        Write-Host "     关键词: $($item.keywords -join ', ')" -ForegroundColor Gray
        Write-Host ""
        Write-Host "     $($item.content)" -ForegroundColor White
        Write-Host ""
    }
}

Write-Host "提示: 使用 --category 参数可筛选特定分类(concept/data/case/risk)" -ForegroundColor Gray
Write-Host ""

exit 0
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 465kUpdated Claude CodeCodexUnverifiedInstall
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 465kUpdated Claude CodeCodexUnverifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 318kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 318kUpdated Claude CodeCodexVerifiedInstall