cost-booster-edit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Cost Booster Edit

Cost Booster Edit

Direct wrapper around
agent-booster.apply()
(npm
agent-booster
v0.2.x, exposed via
agentic-flow/agent-booster
). Use when a transform is already classified as Tier 1 eligible —
cost-booster-route
recommends whether; this skill executes.
直接封装
agent-booster.apply()
(npm包
agent-booster
v0.2.x,通过
agentic-flow/agent-booster
暴露)。当转换已被归类为符合Tier 1条件时使用——
cost-booster-route
负责判断是否适用,本技能负责执行转换。

When to use

使用场景

  • Bulk transforms across many files (
    var → const
    ,
    add-types
    ,
    remove-console
    ,
    add-error-handling
    ,
    async-await
    ,
    add-logging
    ).
  • Any simple, structural edit where an LLM would otherwise be called and billed.
  • Inside CI pipelines where determinism + zero-cost matter more than naturalness.
Do NOT use when the transform requires reasoning about intent, naming, or cross-file context — those are Tier 2/3 jobs.
  • 多文件批量转换(
    var → const
    add-types
    remove-console
    add-error-handling
    async-await
    add-logging
    )。
  • 任何原本需要调用LLM并产生费用的简单结构化编辑场景。
  • 在CI流水线中,确定性与零成本比自然语义更重要的场景。
请勿使用场景:转换需要推理意图、命名或跨文件上下文——这些属于Tier 2/3任务。

Steps

步骤

  1. Take inputs
    intent
    (one of the 6 booster intents) and
    file
    path.
  2. Read the source to a variable, derive the intended
    edit
    text from the intent (caller supplies).
  3. Invoke — run from anywhere under
    v3/
    so
    agent-booster
    resolves:
    bash
    node --input-type=module -e '
      import("agent-booster")
        .then(async ({ AgentBooster }) => {
          const booster = new AgentBooster();
          const r = await booster.apply({
            code: process.argv[1],
            edit: process.argv[2],
            language: process.argv[3] || "javascript",
          });
          console.log(JSON.stringify({
            success: r.success, output: r.output, latency: r.latency,
            confidence: r.confidence, strategy: r.strategy,
            tokens: r.tokens,
          }));
        })
        .catch(e => console.log(JSON.stringify({ success: false, error: String(e.message) })));
    ' -- "$CODE" "$EDIT" "$LANG"
  4. Check confidence — default threshold is
    0.5
    . Below that, fail closed: do NOT write the file; report and escalate to Tier 2/3.
  5. Write back the
    output
    field if
    success && confidence >= 0.5
    .
  6. Persist outcome
    memory_store --namespace cost-tracking --key "booster-edit-..." --value '{"intent":..., "latency":..., "confidence":..., "strategy":..., "applied":true}'
    . Feed the routing learner via
    hooks_model-outcome
    (use the
    cost-optimize
    skill's step 8).
  1. 接收输入——
    intent
    (6种booster意图之一)和
    file
    路径。
  2. 读取源码到变量,根据intent推导目标
    edit
    文本(由调用方提供)。
  3. 调用执行——在
    v3/
    目录下任意位置运行,确保
    agent-booster
    可以被解析:
    bash
    node --input-type=module -e '
      import("agent-booster")
        .then(async ({ AgentBooster }) => {
          const booster = new AgentBooster();
          const r = await booster.apply({
            code: process.argv[1],
            edit: process.argv[2],
            language: process.argv[3] || "javascript",
          });
          console.log(JSON.stringify({
            success: r.success, output: r.output, latency: r.latency,
            confidence: r.confidence, strategy: r.strategy,
            tokens: r.tokens,
          }));
        })
        .catch(e => console.log(JSON.stringify({ success: false, error: String(e.message) })));
    ' -- "$CODE" "$EDIT" "$LANG"
  4. 检查置信度——默认阈值为
    0.5
    。低于该阈值时,终止操作:请勿写入文件,上报并升级至Tier 2/3任务。
  5. 写入结果——若
    success && confidence >= 0.5
    ,将
    output
    字段内容写回文件。
  6. 保存结果——
    memory_store --namespace cost-tracking --key "booster-edit-..." --value '{"intent":..., "latency":..., "confidence":..., "strategy":..., "applied":true}'
    。通过
    hooks_model-outcome
    将结果反馈给路由学习器(参考
    cost-optimize
    技能的步骤8)。

Measured benchmark (2026-05-04, this checkout)

实测基准(2026-05-04,当前版本)

5 representative intents run through
AgentBooster.apply()
:
intentlatency (ms)wall (ms)confidencestrategysuccess
var-to-const550.65fuzzy_replacetrue
add-types110.64fuzzy_replacetrue
remove-console000.70fuzzy_replacetrue
add-error-handling000.85exact_replacetrue
async-await000.85exact_replacetrue
Avg measured latency ≈ 1.2 ms. All 5 above the default 0.5 confidence threshold. See
docs/benchmarks/0002-baseline.md
for the LLM-baseline comparison.
5种代表性意图通过
AgentBooster.apply()
运行的结果:
intent延迟 (ms)实际耗时 (ms)置信度策略成功
var-to-const550.65fuzzy_replacetrue
add-types110.64fuzzy_replacetrue
remove-console000.70fuzzy_replacetrue
add-error-handling000.85exact_replacetrue
async-await000.85exact_replacetrue
平均实测延迟≈1.2毫秒。上述5种意图的置信度均高于默认阈值0.5。LLM基准对比请参考
docs/benchmarks/0002-baseline.md

What's verified locally

本地验证项

ClaimStatus here
100% win rateVerified — 12/12 on
bench/booster-corpus.json
(see
runs/latest.json
). Booster AND Gemini 2.0 Flash both score 12/12 — this is a structural-correctness corpus, not a hard adversarial one.
Sub-millisecond latencyVerified — avg 0.67 ms, p50 0 ms, p99 6 ms, max 6 ms.
$0 per editVerified structurally — no API call, no token billing.
Deterministic AST-based mergeVerified — same inputs reproduce the same
output
and
strategy
.
Confidence ≥ 0.5 ⇒ correctVerified on this corpus — 12/12 above 0.5 (min 0.551), all correct.
350×
speedup vs. LLM
Verified — exceeded against every tier: 1000.9× vs Gemini 2.0 Flash, 1838.7× vs Claude Sonnet 4.6, 2634.1× vs Claude Opus 4.7. Run
BENCH_LLM_BASELINE=1 BENCH_ANTHROPIC=1 node scripts/bench.mjs
to refresh.
Cost saved per editMeasured: $0.000020 vs Gemini, $0.000722 vs Sonnet 4.6, $0.004720 vs Opus 4.7 (the booster side is $0 in all cases).
Win parity with frontier LLMsVerified — Booster, Gemini 2.0 Flash, Sonnet 4.6, Opus 4.7 all scored 12/12 on this corpus. Booster matches LLM accuracy structurally for deterministic transforms.
To extend: add cases to
bench/booster-corpus.json
, run
( cd v3 && node ../plugins/ruflo-cost-tracker/scripts/bench.mjs )
(or with
BENCH_LLM_BASELINE=1
), commit
runs/latest.json
. Smoke step 23 fails the build if win rate drops below 0.80.
Override the LLM model:
BENCH_LLM_MODEL='claude-sonnet-4'
(when wired against
api.anthropic.com
) or
BENCH_LLM_MODEL='models/gemini-2.5-flash'
for a reasoning-model comparison. Pricing flags:
BENCH_LLM_PRICE_IN
,
BENCH_LLM_PRICE_OUT
.
fuzzy_replace
is best-effort; for production transforms prefer cases that route to
exact_replace
(≥0.85 confidence in our sample).
声明当前验证状态
100%成功率已验证 — 在
bench/booster-corpus.json
上12/12通过(见
runs/latest.json
)。Booster与Gemini 2.0 Flash均获得12/12的成绩——这是一个结构正确性测试集,而非高难度对抗测试集。
亚毫秒级延迟已验证 — 平均0.67毫秒,p50为0毫秒,p99为6毫秒,最大值6毫秒。
每次编辑零成本结构验证通过 — 无API调用,无token计费。
基于AST的确定性合并已验证 — 相同输入会生成相同的
output
strategy
置信度≥0.5即正确在当前测试集上已验证 — 12项测试的置信度均高于0.5(最低0.551),全部正确。
比LLM快350倍已验证——远超所有LLM层级:比Gemini 2.0 Flash快1000.9倍,比Claude Sonnet 4.6快1838.7倍比Claude Opus 4.7快2634.1倍。运行
BENCH_LLM_BASELINE=1 BENCH_ANTHROPIC=1 node scripts/bench.mjs
可刷新基准数据。
每次编辑节省的成本已测算:对比Gemini节省$0.000020,对比Sonnet 4.6节省$0.000722对比Opus 4.7节省$0.004720(Booster侧均为$0)。
与前沿LLM准确率持平已验证 — Booster、Gemini 2.0 Flash、Sonnet 4.6、Opus 4.7在该测试集上均获得12/12的成绩。对于确定性转换,Booster在结构准确性上与LLM持平。
扩展方法:在
bench/booster-corpus.json
中添加测试用例,运行
( cd v3 && node ../plugins/ruflo-cost-tracker/scripts/bench.mjs )
(或添加
BENCH_LLM_BASELINE=1
参数),提交
runs/latest.json
。若成功率低于0.80,冒烟测试步骤23会导致构建失败。
覆盖LLM模型
BENCH_LLM_MODEL='claude-sonnet-4'
(对接
api.anthropic.com
时)或
BENCH_LLM_MODEL='models/gemini-2.5-flash'
,用于推理模型对比。定价参数:
BENCH_LLM_PRICE_IN
BENCH_LLM_PRICE_OUT
fuzzy_replace
为尽力而为策略;生产环境转换优先选择路由到
exact_replace
的场景(在我们的样本中置信度≥0.85)。

Cross-references

交叉引用

ADR-0002 §"Decision 1" (route classifier) and §"Riskiest assumption" (Bash-shelled invocation) ·
cost-booster-route
(classifier-side companion) ·
agent-booster
npm README (3-mode install, MCP / npm / HTTP).
ADR-0002 §"Decision 1"(路由分类器)和§"Riskiest assumption"(Bash shell调用) ·
cost-booster-route
(分类器侧配套工具) ·
agent-booster
npm README(三种安装模式:MCP / npm / HTTP)。