cost-compact-context
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCost Compact Context
成本压缩上下文
Wraps from for cost-analysis queries. The bridge dynamically imports with graceful fallback: when the package isn't installed, is and the skill exits cleanly. No MCP tool wraps today (ADR-0002 §"Riskiest assumption"); we shell a Node one-liner instead.
getTokenOptimizer().getCompactContext()@claude-flow/integrationagentic-flowtokensSaved0getTokenOptimizer封装来自的,用于成本分析查询。桥接器会动态导入并提供优雅降级方案:当该包未安装时,设为,技能会平稳退出。目前没有MCP工具封装(ADR-0002 §"风险最高的假设");因此我们改用Node单行命令实现。
@claude-flow/integrationgetTokenOptimizer().getCompactContext()agentic-flowtokensSaved0getTokenOptimizerSteps
步骤
-
Take the query — the single argument.
-
Invoke — run from anywhere underso
v3/resolves:@claude-flow/integrationbash( cd v3 && node ../plugins/ruflo-cost-tracker/scripts/compact.mjs "<QUERY>" )The script imports(canonical export — not@claude-flow/integration/token-optimizer, which would double thedist/token-optimizer.jsextension via Node's.jsexports rule), calls./*, and prints a markdown summary plus a JSON line viagetCompactContext(query).COMPACT_QUIET=1 -
Report — markdown table with: memories retrieved, tokens saved (bridge-reported), agentic-flow availability, cache hit rate. The script also emits a "bridge-reported, not measured against a no-RAG baseline" disclaimer. On bridge-unavailable: prints "agentic-flow not installed — bridge returns inert results." and exits cleanly.
-
接收查询 —— 唯一的参数。
-
调用执行 —— 在目录下任意位置运行,确保
v3/能正常解析:@claude-flow/integrationbash( cd v3 && node ../plugins/ruflo-cost-tracker/scripts/compact.mjs "<QUERY>" )该脚本导入(标准导出 —— 不要使用@claude-flow/integration/token-optimizer,否则会因Node的dist/token-optimizer.js导出规则导致./*扩展名重复),调用.js,并通过getCompactContext(query)输出markdown摘要和一行JSON数据。COMPACT_QUIET=1 -
结果上报 —— 生成包含以下内容的markdown表格:检索到的记忆数量、桥接器返回的token节省量、agentic-flow可用性、缓存命中率。脚本还会附带一条“数据来自桥接器,未与无RAG基线对比”的声明。当桥接器不可用时:打印“agentic-flow未安装 —— 桥接器返回无效结果。”并平稳退出。
Caveats — claimed upstream, not yet verified
注意事项 —— 上游声称,尚未验证
CLAUDE.md root claims tokens. The bridge's is (token-optimizer.ts:141–143) — a heuristic, not a baseline-measured saving. token-optimizer.ts:9–10 itself says: "No fabricated metrics are reported — all stats reflect real measurements". This skill carries that disclaimer forward.
ReasoningBank retrieval: -32%tokensSavedquery_tokens − compact_prompt_tokensBooster-specific availability is not exposed as a getter — observable only through returning . The canonical Tier 1 signal is (see ).
optimizedEdit()method: 'agent-booster'[AGENT_BOOSTER_AVAILABLE]cost-booster-routeCLAUDE.md根文档声称。桥接器的计算方式为(token-optimizer.ts:141–143)—— 这是一种启发式算法,并非基于基线测量的真实节省量。token-optimizer.ts:9–10本身说明:“不报告虚构指标 —— 所有统计数据均反映真实测量结果”。本技能会沿用该声明。
ReasoningBank检索:token减少32%tokensSavedquery_tokens − compact_prompt_tokensBooster的具体可用性未通过getter暴露 —— 仅能通过返回观察到。标准的Tier 1信号是(参见)。
optimizedEdit()method: 'agent-booster'[AGENT_BOOSTER_AVAILABLE]cost-booster-routeFallback
降级方案
agentic-flowgetCompactContext{tokensSaved: 0, memories: []}optimizedEdit{method: 'traditional'}getOptimalConfig若未安装 → 返回(第116–124行),返回,回退到防漂移默认值。技能会打印“不可用”提示并平稳退出。
agentic-flowgetCompactContext{tokensSaved: 0, memories: []}optimizedEdit{method: 'traditional'}getOptimalConfigCross-references
交叉引用
ADR-0002 Decision #2 + §"Riskiest assumption" · (singleton export) · (verification findings).
token-optimizer.ts:308docs/benchmarks/0002-baseline.mdADR-0002 决策#2 + §"风险最高的假设" · (单例导出) · (验证结果)。
token-optimizer.ts:308docs/benchmarks/0002-baseline.md