The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
fix(lib): remove unused cost-estimate.js duplicate rate table
Amir Fathi08c1c4073cf6
diff --git a/scripts/lib/cost-estimate.js b/scripts/lib/cost-estimate.jsdeleted file mode 100644index a1651a8c9..000000000--- a/scripts/lib/cost-estimate.js+++ /dev/null@@ -1,32 +0,0 @@-'use strict';--/**- * Shared cost estimation for ECC hooks.- *- * Approximate per-1M-token blended rates (conservative defaults).- */--const RATE_TABLE = {- haiku: { in: 0.8, out: 4.0 },- sonnet: { in: 3.0, out: 15.0 },- opus: { in: 15.0, out: 75.0 }-};--/**- * Estimate USD cost from token counts.- * @param {string} model - Model name (may contain "haiku", "sonnet", or "opus")- * @param {number} inputTokens- * @param {number} outputTokens- * @returns {number} Estimated cost in USD (rounded to 6 decimal places)- */-function estimateCost(model, inputTokens, outputTokens) {- const normalized = String(model || '').toLowerCase();- let rates = RATE_TABLE.sonnet;- if (normalized.includes('haiku')) rates = RATE_TABLE.haiku;- if (normalized.includes('opus')) rates = RATE_TABLE.opus;-- const cost = (inputTokens / 1_000_000) * rates.in + (outputTokens / 1_000_000) * rates.out;- return Math.round(cost * 1e6) / 1e6;-}--module.exports = { estimateCost, RATE_TABLE };diff --git a/tests/lib/cost-estimate.test.js b/tests/lib/cost-estimate.test.jsdeleted file mode 100644index bcb5906bc..000000000--- a/tests/lib/cost-estimate.test.js+++ /dev/null@@ -1,114 +0,0 @@-/**- * Tests for scripts/lib/cost-estimate.js- *- * Run with: node tests/lib/cost-estimate.test.js- */--const assert = require('assert');--const { estimateCost, RATE_TABLE } = require('../../scripts/lib/cost-estimate');--// Test helper-function test(name, fn) {- try {- fn();- console.log(` \u2713 ${name}`);- return true;- } catch (err) {- console.log(` \u2717 ${name}`);- console.log(` Error: ${err.message}`);- return false;- }-}--function runTests() {- console.log('\n=== Testing cost-estimate.js ===\n');-- let passed = 0;- let failed = 0;-- // RATE_TABLE structure- console.log('RATE_TABLE:');-- if (- test('RATE_TABLE has haiku, sonnet, opus keys', () => {- assert.ok(RATE_TABLE.haiku, 'Missing haiku');- assert.ok(RATE_TABLE.sonnet, 'Missing sonnet');- assert.ok(RATE_TABLE.opus, 'Missing opus');- assert.strictEqual(typeof RATE_TABLE.haiku.in, 'number');- assert.strictEqual(typeof RATE_TABLE.haiku.out, 'number');- assert.strictEqual(typeof RATE_TABLE.sonnet.in, 'number');- assert.strictEqual(typeof RATE_TABLE.sonnet.out, 'number');- assert.strictEqual(typeof RATE_TABLE.opus.in, 'number');- assert.strictEqual(typeof RATE_TABLE.opus.out, 'number');- })- )- passed++;- else failed++;-- // estimateCost tests- console.log('\nestimateCost:');-- if (- test('opus 1M/1M tokens returns 90', () => {- const cost = estimateCost('opus', 1_000_000, 1_000_000);- assert.strictEqual(cost, 90);- })- )- passed++;- else failed++;-- if (- test('sonnet 1M/1M tokens returns 18', () => {- const cost = estimateCost('sonnet', 1_000_000, 1_000_000);- assert.strictEqual(cost, 18);- })- )- passed++;- else failed++;-- if (- test('haiku 1M/1M tokens returns 4.8', () => {- const cost = estimateCost('haiku', 1_000_000, 1_000_000);- assert.strictEqual(cost, 4.8);- })- )- passed++;- else failed++;-- if (- test('null model with 0 tokens returns 0', () => {- const cost = estimateCost(null, 0, 0);- assert.strictEqual(cost, 0);- })- )- passed++;- else failed++;-- if (- test('full model name claude-opus-4-6 uses opus rates', () => {- const cost = estimateCost('claude-opus-4-6', 500, 200);- // (500 / 1_000_000) * 15 + (200 / 1_000_000) * 75 = 0.0075 + 0.015 = 0.0225- const expected = Math.round(0.0225 * 1e6) / 1e6;- assert.strictEqual(cost, expected);- })- )- passed++;- else failed++;-- if (- test('unknown model falls back to sonnet rates', () => {- const cost = estimateCost('unknown-model', 1_000_000, 1_000_000);- assert.strictEqual(cost, 18);- })- )- passed++;- else failed++;-- // Summary- console.log(`\nResults: ${passed} passed, ${failed} failed\n`);- return { passed, failed };-}--const { failed } = runTests();-process.exit(failed > 0 ? 1 : 0);