@ryuenn3123/agentic-senior-core 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generatedAt": "2026-04-11T06:14:10.052Z",
|
|
3
|
+
"reportName": "token-optimization-benchmark",
|
|
4
|
+
"methodology": {
|
|
5
|
+
"tokenEstimate": "estimated_tokens = ceil(output_chars / 4)",
|
|
6
|
+
"scope": "command-output estimate only; model-specific tokenization differs by provider",
|
|
7
|
+
"repositoryRoot": "E:\\Project\\Agentic-Senior-Core"
|
|
8
|
+
},
|
|
9
|
+
"environment": {
|
|
10
|
+
"nodeVersion": "v22.22.0",
|
|
11
|
+
"platform": "win32",
|
|
12
|
+
"rtk": {
|
|
13
|
+
"isAvailable": true,
|
|
14
|
+
"version": "0.35.0",
|
|
15
|
+
"source": "local-tools",
|
|
16
|
+
"executablePath": "E:\\Project\\Agentic-Senior-Core\\.benchmarks\\tools\\rtk\\rtk.exe",
|
|
17
|
+
"reason": null
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"scenarios": [
|
|
21
|
+
{
|
|
22
|
+
"scenarioId": "git-show",
|
|
23
|
+
"scenarioName": "Latest commit detail review",
|
|
24
|
+
"baseline": {
|
|
25
|
+
"command": "git show HEAD --stat --patch --no-color",
|
|
26
|
+
"exitCode": 0,
|
|
27
|
+
"outputChars": 15191,
|
|
28
|
+
"outputLines": 368,
|
|
29
|
+
"estimatedTokens": 3798
|
|
30
|
+
},
|
|
31
|
+
"nativeOptimized": {
|
|
32
|
+
"command": "git show HEAD --stat --no-color",
|
|
33
|
+
"exitCode": 0,
|
|
34
|
+
"outputChars": 706,
|
|
35
|
+
"outputLines": 14,
|
|
36
|
+
"estimatedTokens": 177
|
|
37
|
+
},
|
|
38
|
+
"nativeSavings": {
|
|
39
|
+
"tokenDelta": 3621,
|
|
40
|
+
"savingsPercent": 95.34
|
|
41
|
+
},
|
|
42
|
+
"rtk": {
|
|
43
|
+
"command": "E:\\Project\\Agentic-Senior-Core\\.benchmarks\\tools\\rtk\\rtk.exe git show HEAD --stat --patch --no-color",
|
|
44
|
+
"exitCode": 0,
|
|
45
|
+
"outputChars": 15191,
|
|
46
|
+
"outputLines": 368,
|
|
47
|
+
"estimatedTokens": 3798
|
|
48
|
+
},
|
|
49
|
+
"rtkSavings": {
|
|
50
|
+
"tokenDelta": 0,
|
|
51
|
+
"savingsPercent": 0
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"scenarioId": "git-log",
|
|
56
|
+
"scenarioName": "Commit history review",
|
|
57
|
+
"baseline": {
|
|
58
|
+
"command": "git log -n 50",
|
|
59
|
+
"exitCode": 0,
|
|
60
|
+
"outputChars": 14918,
|
|
61
|
+
"outputLines": 385,
|
|
62
|
+
"estimatedTokens": 3730
|
|
63
|
+
},
|
|
64
|
+
"nativeOptimized": {
|
|
65
|
+
"command": "git log --oneline -n 50",
|
|
66
|
+
"exitCode": 0,
|
|
67
|
+
"outputChars": 3555,
|
|
68
|
+
"outputLines": 50,
|
|
69
|
+
"estimatedTokens": 889
|
|
70
|
+
},
|
|
71
|
+
"nativeSavings": {
|
|
72
|
+
"tokenDelta": 2841,
|
|
73
|
+
"savingsPercent": 76.17
|
|
74
|
+
},
|
|
75
|
+
"rtk": {
|
|
76
|
+
"command": "E:\\Project\\Agentic-Senior-Core\\.benchmarks\\tools\\rtk\\rtk.exe git log -n 50",
|
|
77
|
+
"exitCode": 0,
|
|
78
|
+
"outputChars": 6437,
|
|
79
|
+
"outputLines": 74,
|
|
80
|
+
"estimatedTokens": 1610
|
|
81
|
+
},
|
|
82
|
+
"rtkSavings": {
|
|
83
|
+
"tokenDelta": 2120,
|
|
84
|
+
"savingsPercent": 56.84
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"scenarioId": "search-token",
|
|
89
|
+
"scenarioName": "Search result scan",
|
|
90
|
+
"baseline": {
|
|
91
|
+
"command": "git grep -n token",
|
|
92
|
+
"exitCode": 0,
|
|
93
|
+
"outputChars": 21353,
|
|
94
|
+
"outputLines": 190,
|
|
95
|
+
"estimatedTokens": 5339
|
|
96
|
+
},
|
|
97
|
+
"nativeOptimized": {
|
|
98
|
+
"command": "git grep -n token README.md docs",
|
|
99
|
+
"exitCode": 0,
|
|
100
|
+
"outputChars": 4395,
|
|
101
|
+
"outputLines": 38,
|
|
102
|
+
"estimatedTokens": 1099
|
|
103
|
+
},
|
|
104
|
+
"nativeSavings": {
|
|
105
|
+
"tokenDelta": 4240,
|
|
106
|
+
"savingsPercent": 79.42
|
|
107
|
+
},
|
|
108
|
+
"rtk": {
|
|
109
|
+
"command": "E:\\Project\\Agentic-Senior-Core\\.benchmarks\\tools\\rtk\\rtk.exe git grep -n token",
|
|
110
|
+
"exitCode": 0,
|
|
111
|
+
"outputChars": 21353,
|
|
112
|
+
"outputLines": 190,
|
|
113
|
+
"estimatedTokens": 5339
|
|
114
|
+
},
|
|
115
|
+
"rtkSavings": {
|
|
116
|
+
"tokenDelta": 0,
|
|
117
|
+
"savingsPercent": 0
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"summary": {
|
|
122
|
+
"scenarioCount": 3,
|
|
123
|
+
"averageNativeSavingsPercent": 83.64,
|
|
124
|
+
"averageRtkSavingsPercent": 18.95
|
|
125
|
+
},
|
|
126
|
+
"artifact": {
|
|
127
|
+
"path": "E:\\Project\\Agentic-Senior-Core\\.agent-context\\state\\token-optimization-benchmark.json",
|
|
128
|
+
"writeMode": "stdout-and-file"
|
|
129
|
+
}
|
|
130
|
+
}
|
package/.cursorrules
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AGENTIC-SENIOR-CORE DYNAMIC GOVERNANCE RULESET
|
|
2
2
|
|
|
3
|
-
Generated by Agentic-Senior-Core CLI v2.0.
|
|
3
|
+
Generated by Agentic-Senior-Core CLI v2.0.4
|
|
4
4
|
Timestamp: 2026-04-08T14:58:53.570Z
|
|
5
5
|
Selected profile: beginner
|
|
6
6
|
Selected policy file: .agent-context/policies/llm-judge-threshold.json
|
package/.windsurfrules
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AGENTIC-SENIOR-CORE DYNAMIC GOVERNANCE RULESET
|
|
2
2
|
|
|
3
|
-
Generated by Agentic-Senior-Core CLI v2.0.
|
|
3
|
+
Generated by Agentic-Senior-Core CLI v2.0.4
|
|
4
4
|
Timestamp: 2026-04-08T14:58:53.570Z
|
|
5
5
|
Selected profile: beginner
|
|
6
6
|
Selected policy file: .agent-context/policies/llm-judge-threshold.json
|
package/README.md
CHANGED
|
@@ -153,6 +153,28 @@ npx @ryuenn3123/agentic-senior-core init --no-token-optimize
|
|
|
153
153
|
When enabled, the CLI writes `.agent-context/state/token-optimization.json`, regenerates compiled rules, and adds compact command guidance to `.cursorrules` and `.windsurfrules`.
|
|
154
154
|
If an external token proxy is available, the CLI prints setup hints. If not, native fallback guidance stays active, so outside users are not forced to install extra tooling.
|
|
155
155
|
|
|
156
|
+
### Token Efficiency Benchmark Snapshot
|
|
157
|
+
|
|
158
|
+
Latest local benchmark (2026-04-11) from `.agent-context/state/token-optimization-benchmark.json`:
|
|
159
|
+
|
|
160
|
+
| Scenario | Baseline Token Estimate | Agentic Native Token Estimate | Native Savings | RTK Token Estimate | RTK Status |
|
|
161
|
+
|----------|-------------------------|-------------------------------|----------------|--------------------|------------|
|
|
162
|
+
| Latest commit detail review | 3798 | 177 | 95.34% | 3798 | Detected (`rtk` v0.35.0) |
|
|
163
|
+
| Commit history review | 3730 | 889 | 76.17% | 1610 | Detected (`rtk` v0.35.0) |
|
|
164
|
+
| Search result scan | 5339 | 1099 | 79.42% | 5339 | Detected (`rtk` v0.35.0) |
|
|
165
|
+
| Average | - | - | 83.64% | 18.95% savings | Detected (`rtk` v0.35.0) |
|
|
166
|
+
|
|
167
|
+
Method note:
|
|
168
|
+
- Estimate formula is `ceil(output_chars / 4)`.
|
|
169
|
+
- This is a command-output estimate, not provider-specific tokenizer output.
|
|
170
|
+
- RTK results depend on host utilities. On Windows hosts without GNU `grep` or `ls`, RTK may fall back to `rtk git ...` paths for some scenarios.
|
|
171
|
+
|
|
172
|
+
Reproduce and refresh this table:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
npm run benchmark:token
|
|
176
|
+
```
|
|
177
|
+
|
|
156
178
|
### Install and Setup Choices
|
|
157
179
|
|
|
158
180
|
The CLI now supports a smaller decision surface for first-time setup:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryuenn3123/agentic-senior-core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Force your AI Agent to code like a Staff Engineer, not a Junior.",
|
|
6
6
|
"bin": {
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"prepublishOnly": "npm run gate:release",
|
|
48
48
|
"sbom:generate": "node ./scripts/generate-sbom.mjs",
|
|
49
49
|
"benchmark:detection": "node ./scripts/detection-benchmark.mjs",
|
|
50
|
+
"benchmark:token": "node ./scripts/token-optimization-benchmark.mjs",
|
|
50
51
|
"benchmark:gate": "node ./scripts/benchmark-gate.mjs",
|
|
51
52
|
"benchmark:intelligence": "node ./scripts/benchmark-intelligence.mjs",
|
|
52
53
|
"validate": "node ./scripts/validate.mjs",
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* token-optimization-benchmark.mjs
|
|
5
|
+
*
|
|
6
|
+
* Measures token-estimate reduction between baseline commands and
|
|
7
|
+
* native optimized command variants. If RTK is installed, it also
|
|
8
|
+
* compares RTK command output in the same scenarios.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { existsSync } from 'node:fs';
|
|
12
|
+
import fs from 'node:fs/promises';
|
|
13
|
+
import { spawnSync } from 'node:child_process';
|
|
14
|
+
import { dirname, join, resolve } from 'node:path';
|
|
15
|
+
import { fileURLToPath } from 'node:url';
|
|
16
|
+
|
|
17
|
+
const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
|
|
18
|
+
const SCRIPT_DIR = dirname(SCRIPT_FILE_PATH);
|
|
19
|
+
const REPOSITORY_ROOT = resolve(SCRIPT_DIR, '..');
|
|
20
|
+
const REPORT_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'token-optimization-benchmark.json');
|
|
21
|
+
const LOCAL_RTK_BINARY_PATH = join(REPOSITORY_ROOT, '.benchmarks', 'tools', 'rtk', 'rtk.exe');
|
|
22
|
+
const TOKEN_ESTIMATE_DIVISOR = 4;
|
|
23
|
+
const ARGUMENT_FLAGS = new Set(process.argv.slice(2));
|
|
24
|
+
const isStdoutOnlyMode = ARGUMENT_FLAGS.has('--stdout-only');
|
|
25
|
+
|
|
26
|
+
const BENCHMARK_SCENARIOS = [
|
|
27
|
+
{
|
|
28
|
+
scenarioId: 'git-show',
|
|
29
|
+
scenarioName: 'Latest commit detail review',
|
|
30
|
+
baselineCommand: { command: 'git', args: ['show', 'HEAD', '--stat', '--patch', '--no-color'] },
|
|
31
|
+
nativeOptimizedCommand: { command: 'git', args: ['show', 'HEAD', '--stat', '--no-color'] },
|
|
32
|
+
rtkCommand: { command: 'rtk', args: ['git', 'show', 'HEAD', '--stat', '--patch', '--no-color'] },
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
scenarioId: 'git-log',
|
|
36
|
+
scenarioName: 'Commit history review',
|
|
37
|
+
baselineCommand: { command: 'git', args: ['log', '-n', '50'] },
|
|
38
|
+
nativeOptimizedCommand: { command: 'git', args: ['log', '--oneline', '-n', '50'] },
|
|
39
|
+
rtkCommand: { command: 'rtk', args: ['git', 'log', '-n', '50'] },
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
scenarioId: 'search-token',
|
|
43
|
+
scenarioName: 'Search result scan',
|
|
44
|
+
baselineCommand: { command: 'git', args: ['grep', '-n', 'token'] },
|
|
45
|
+
nativeOptimizedCommand: { command: 'git', args: ['grep', '-n', 'token', 'README.md', 'docs'] },
|
|
46
|
+
rtkCommand: { command: 'rtk', args: ['git', 'grep', '-n', 'token'] },
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
function estimateTokenCount(outputText) {
|
|
51
|
+
if (!outputText || outputText.length === 0) {
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return Math.ceil(outputText.length / TOKEN_ESTIMATE_DIVISOR);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function formatCommandLine(commandDefinition) {
|
|
59
|
+
return [commandDefinition.command, ...commandDefinition.args].join(' ');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function executeCommand(commandDefinition) {
|
|
63
|
+
const commandResult = spawnSync(commandDefinition.command, commandDefinition.args, {
|
|
64
|
+
cwd: REPOSITORY_ROOT,
|
|
65
|
+
encoding: 'utf8',
|
|
66
|
+
maxBuffer: 1024 * 1024 * 20,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const standardOutput = commandResult.stdout || '';
|
|
70
|
+
const standardError = commandResult.stderr || '';
|
|
71
|
+
const combinedOutput = `${standardOutput}${standardError}`;
|
|
72
|
+
const normalizedOutput = combinedOutput.trimEnd();
|
|
73
|
+
|
|
74
|
+
const outputLineCount = normalizedOutput.length === 0
|
|
75
|
+
? 0
|
|
76
|
+
: normalizedOutput.split(/\r?\n/u).length;
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
command: formatCommandLine(commandDefinition),
|
|
80
|
+
exitCode: typeof commandResult.status === 'number' ? commandResult.status : 1,
|
|
81
|
+
outputChars: normalizedOutput.length,
|
|
82
|
+
outputLines: outputLineCount,
|
|
83
|
+
estimatedTokens: estimateTokenCount(normalizedOutput),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function resolveRtkBinaryPath() {
|
|
88
|
+
const configuredRtkBinaryPath = process.env.RTK_BINARY_PATH;
|
|
89
|
+
|
|
90
|
+
if (configuredRtkBinaryPath && existsSync(configuredRtkBinaryPath)) {
|
|
91
|
+
return {
|
|
92
|
+
executablePath: configuredRtkBinaryPath,
|
|
93
|
+
source: 'env',
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (existsSync(LOCAL_RTK_BINARY_PATH)) {
|
|
98
|
+
return {
|
|
99
|
+
executablePath: LOCAL_RTK_BINARY_PATH,
|
|
100
|
+
source: 'local-tools',
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
executablePath: 'rtk',
|
|
106
|
+
source: 'system-path',
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function detectRtkAvailability() {
|
|
111
|
+
const rtkBinary = resolveRtkBinaryPath();
|
|
112
|
+
|
|
113
|
+
const versionResult = spawnSync(rtkBinary.executablePath, ['--version'], {
|
|
114
|
+
cwd: REPOSITORY_ROOT,
|
|
115
|
+
encoding: 'utf8',
|
|
116
|
+
maxBuffer: 1024 * 1024,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
if (versionResult.error || versionResult.status !== 0) {
|
|
120
|
+
return {
|
|
121
|
+
isAvailable: false,
|
|
122
|
+
version: null,
|
|
123
|
+
source: rtkBinary.source,
|
|
124
|
+
executablePath: rtkBinary.executablePath,
|
|
125
|
+
reason: versionResult.error
|
|
126
|
+
? versionResult.error.message
|
|
127
|
+
: (versionResult.stderr || versionResult.stdout || 'RTK command unavailable').trim(),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const versionMatch = (versionResult.stdout || '').match(/\d+\.\d+\.\d+/u);
|
|
132
|
+
return {
|
|
133
|
+
isAvailable: true,
|
|
134
|
+
version: versionMatch ? versionMatch[0] : null,
|
|
135
|
+
source: rtkBinary.source,
|
|
136
|
+
executablePath: rtkBinary.executablePath,
|
|
137
|
+
reason: null,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function buildRtkCommand(commandDefinition, rtkAvailability) {
|
|
142
|
+
return {
|
|
143
|
+
command: rtkAvailability.executablePath || commandDefinition.command,
|
|
144
|
+
args: commandDefinition.args,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function computeSavingsSummary(baselineTokens, optimizedTokens) {
|
|
149
|
+
if (baselineTokens <= 0) {
|
|
150
|
+
return {
|
|
151
|
+
tokenDelta: 0,
|
|
152
|
+
savingsPercent: 0,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const tokenDelta = baselineTokens - optimizedTokens;
|
|
157
|
+
const savingsPercent = Number(((tokenDelta / baselineTokens) * 100).toFixed(2));
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
tokenDelta,
|
|
161
|
+
savingsPercent,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function calculateAverageSavings(benchmarkRows, savingsKeyName) {
|
|
166
|
+
const availableSavings = benchmarkRows
|
|
167
|
+
.map((benchmarkRow) => benchmarkRow[savingsKeyName]?.savingsPercent)
|
|
168
|
+
.filter((savingsPercent) => typeof savingsPercent === 'number');
|
|
169
|
+
|
|
170
|
+
if (availableSavings.length === 0) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const totalSavings = availableSavings.reduce((runningTotal, savingsPercent) => runningTotal + savingsPercent, 0);
|
|
175
|
+
return Number((totalSavings / availableSavings.length).toFixed(2));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async function runTokenOptimizationBenchmark() {
|
|
179
|
+
const rtkAvailability = detectRtkAvailability();
|
|
180
|
+
const scenarioResults = [];
|
|
181
|
+
|
|
182
|
+
for (const benchmarkScenario of BENCHMARK_SCENARIOS) {
|
|
183
|
+
const baselineRun = executeCommand(benchmarkScenario.baselineCommand);
|
|
184
|
+
const nativeOptimizedRun = executeCommand(benchmarkScenario.nativeOptimizedCommand);
|
|
185
|
+
const nativeSavings = computeSavingsSummary(
|
|
186
|
+
baselineRun.estimatedTokens,
|
|
187
|
+
nativeOptimizedRun.estimatedTokens
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
let rtkRun = null;
|
|
191
|
+
let rtkSavings = null;
|
|
192
|
+
|
|
193
|
+
if (rtkAvailability.isAvailable) {
|
|
194
|
+
rtkRun = executeCommand(buildRtkCommand(benchmarkScenario.rtkCommand, rtkAvailability));
|
|
195
|
+
if (rtkRun.exitCode === 0) {
|
|
196
|
+
rtkSavings = computeSavingsSummary(baselineRun.estimatedTokens, rtkRun.estimatedTokens);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
scenarioResults.push({
|
|
201
|
+
scenarioId: benchmarkScenario.scenarioId,
|
|
202
|
+
scenarioName: benchmarkScenario.scenarioName,
|
|
203
|
+
baseline: baselineRun,
|
|
204
|
+
nativeOptimized: nativeOptimizedRun,
|
|
205
|
+
nativeSavings,
|
|
206
|
+
rtk: rtkRun,
|
|
207
|
+
rtkSavings,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const benchmarkReport = {
|
|
212
|
+
generatedAt: new Date().toISOString(),
|
|
213
|
+
reportName: 'token-optimization-benchmark',
|
|
214
|
+
methodology: {
|
|
215
|
+
tokenEstimate: `estimated_tokens = ceil(output_chars / ${TOKEN_ESTIMATE_DIVISOR})`,
|
|
216
|
+
scope: 'command-output estimate only; model-specific tokenization differs by provider',
|
|
217
|
+
repositoryRoot: REPOSITORY_ROOT,
|
|
218
|
+
},
|
|
219
|
+
environment: {
|
|
220
|
+
nodeVersion: process.version,
|
|
221
|
+
platform: process.platform,
|
|
222
|
+
rtk: rtkAvailability,
|
|
223
|
+
},
|
|
224
|
+
scenarios: scenarioResults,
|
|
225
|
+
summary: {
|
|
226
|
+
scenarioCount: scenarioResults.length,
|
|
227
|
+
averageNativeSavingsPercent: calculateAverageSavings(scenarioResults, 'nativeSavings'),
|
|
228
|
+
averageRtkSavingsPercent: calculateAverageSavings(scenarioResults, 'rtkSavings'),
|
|
229
|
+
},
|
|
230
|
+
artifact: {
|
|
231
|
+
path: REPORT_PATH,
|
|
232
|
+
writeMode: isStdoutOnlyMode ? 'stdout-only' : 'stdout-and-file',
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
if (!isStdoutOnlyMode) {
|
|
237
|
+
await fs.mkdir(dirname(REPORT_PATH), { recursive: true });
|
|
238
|
+
await fs.writeFile(REPORT_PATH, JSON.stringify(benchmarkReport, null, 2) + '\n', 'utf8');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return benchmarkReport;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
runTokenOptimizationBenchmark()
|
|
245
|
+
.then((benchmarkReport) => {
|
|
246
|
+
console.log(JSON.stringify(benchmarkReport, null, 2));
|
|
247
|
+
})
|
|
248
|
+
.catch((benchmarkError) => {
|
|
249
|
+
const errorMessage = benchmarkError instanceof Error ? benchmarkError.message : String(benchmarkError);
|
|
250
|
+
console.error(`Token benchmark failed: ${errorMessage}`);
|
|
251
|
+
process.exit(1);
|
|
252
|
+
});
|