opencode-statboard 2.10.16 → 2.10.18
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.
- package/package.json +1 -1
- package/pricing.js +23 -1
- package/tui-dashboard.js +27 -20
- package/fix-i18n.js +0 -161
- package/fix-port-final.js +0 -86
- package/fix-port-final10.js +0 -79
- package/fix-port-final11.js +0 -79
- package/fix-port-final12.js +0 -79
- package/fix-port-final13.js +0 -79
- package/fix-port-final14.js +0 -79
- package/fix-port-final15.js +0 -79
- package/fix-port-final16.js +0 -79
- package/fix-port-final17.js +0 -79
- package/fix-port-final18.js +0 -79
- package/fix-port-final19.js +0 -79
- package/fix-port-final2.js +0 -79
- package/fix-port-final20.js +0 -79
- package/fix-port-final21.js +0 -79
- package/fix-port-final22.js +0 -79
- package/fix-port-final23.js +0 -79
- package/fix-port-final3.js +0 -79
- package/fix-port-final5.js +0 -79
- package/fix-port-final7.js +0 -79
- package/fix-port-final8.js +0 -79
- package/fix-port-final9.js +0 -79
- package/fix-port-v2.js +0 -58
- package/fix-port-v3.js +0 -79
- package/fix-port.js +0 -32
- package/test-open.js +0 -4
package/package.json
CHANGED
package/pricing.js
CHANGED
|
@@ -93,7 +93,29 @@ function priceFor(provider, model) {
|
|
|
93
93
|
}
|
|
94
94
|
// Any provider, cheapest nonzero listing for the same base name. Cheapest
|
|
95
95
|
// keeps the estimate conservative (it understates savings, never inflates).
|
|
96
|
-
|
|
96
|
+
// Also try the full model name (with provider prefix) as a base, since cache keys may include provider prefix.
|
|
97
|
+
const allBases = [...bases];
|
|
98
|
+
if (model !== bases[0] && !allBases.includes(model)) allBases.push(model); // full model name (may include provider prefix)
|
|
99
|
+
// Also try provider/model as a base (for cases where model name doesn't include provider prefix but cache key does)
|
|
100
|
+
const providerModel = `${provider}/${model}`;
|
|
101
|
+
if (!allBases.includes(providerModel)) allBases.push(providerModel);
|
|
102
|
+
// Also try openrouter/ + model (common case where sub-providers like reflection are under openrouter)
|
|
103
|
+
const openrouterModel = `openrouter/${model}`;
|
|
104
|
+
if (!allBases.includes(openrouterModel)) allBases.push(openrouterModel);
|
|
105
|
+
// Also try openrouter/provider/model (for cases where cache has openrouter/subprovider/model)
|
|
106
|
+
const openrouterProviderModel = `openrouter/${provider}/${model}`;
|
|
107
|
+
if (!allBases.includes(openrouterProviderModel)) allBases.push(openrouterProviderModel);
|
|
108
|
+
// Also try openrouter + common sub-providers (reflection, nvidia, etc.) for openrouter models without sub-provider prefix
|
|
109
|
+
if (provider === 'openrouter' && !model.includes('/')) {
|
|
110
|
+
const subProviders = ['reflection', 'nvidia', 'google', 'anthropic', 'meta', 'mistral', 'cohere', 'mistralai'];
|
|
111
|
+
for (const sub of subProviders) {
|
|
112
|
+
const subModel = `${sub}/${model}`;
|
|
113
|
+
if (!allBases.includes(subModel)) allBases.push(subModel);
|
|
114
|
+
const openrouterSubModel = `openrouter/${sub}/${model}`;
|
|
115
|
+
if (!allBases.includes(openrouterSubModel)) allBases.push(openrouterSubModel);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
for (const b of allBases) {
|
|
97
119
|
let best = null;
|
|
98
120
|
for (const pid of Object.keys(data).sort()) {
|
|
99
121
|
const e = entry(data, pid, b);
|
package/tui-dashboard.js
CHANGED
|
@@ -604,15 +604,34 @@ class TUIServer {
|
|
|
604
604
|
|
|
605
605
|
const height = this.getContentHeight() - 4;
|
|
606
606
|
const width = this.getContentWidth();
|
|
607
|
-
const chartHeight = Math.max(1, Math.floor(height /
|
|
607
|
+
const chartHeight = Math.max(1, Math.floor(height / 4) - 2);
|
|
608
|
+
|
|
609
|
+
let out = '{center}{bold}\u2501\u2501\u2501 ' + t('trend') + ' \u2501\u2501\u2501{/bold}{/center}\n\n';
|
|
610
|
+
|
|
611
|
+
const maxInOut = Math.max(...labels.map((_, i) => Math.max(input[i] || 0, output[i] || 0)), 1);
|
|
612
|
+
let inOutChart = [];
|
|
613
|
+
inOutChart.push('{bold}' + t('input') + ' (' + this.formatNumber(input[input.length - 1] || 0) + ') + ' + t('output') + ' (' + this.formatNumber(output[output.length - 1] || 0) + ') today, max: ' + this.formatNumber(maxInOut) + '{/bold}');
|
|
614
|
+
for (let row = chartHeight - 1; row >= 0; row--) {
|
|
615
|
+
let line = '';
|
|
616
|
+
const threshold = (row / chartHeight) * maxInOut;
|
|
617
|
+
for (let i = 0; i < width; i++) {
|
|
618
|
+
const idx = Math.floor(i * labels.length / width);
|
|
619
|
+
const inVal = input[idx] || 0;
|
|
620
|
+
const outVal = output[idx] || 0;
|
|
621
|
+
if (inVal >= threshold && outVal >= threshold) line += '{magenta-fg}\u2588{/}';
|
|
622
|
+
else if (inVal >= threshold) line += '{cyan-fg}\u2588{/}';
|
|
623
|
+
else if (outVal >= threshold) line += '{green-fg}\u2588{/}';
|
|
624
|
+
else line += ' ';
|
|
625
|
+
}
|
|
626
|
+
inOutChart.push(line);
|
|
627
|
+
}
|
|
628
|
+
out += inOutChart.join('\n') + '\n';
|
|
608
629
|
|
|
609
|
-
// Helper: render one chart with its own max
|
|
610
630
|
const renderChart = (data, label, color, maxVal) => {
|
|
611
631
|
if (maxVal <= 0) return '{gray}(no data){/gray}\n';
|
|
612
632
|
let lines = [];
|
|
613
|
-
// Show current (today = last index) value next to label
|
|
614
633
|
const todayVal = data[data.length - 1] || 0;
|
|
615
|
-
lines.push('{bold}' + label + ': ' + this.formatNumber(todayVal) + ' (today){/bold}');
|
|
634
|
+
lines.push('{bold}' + label + ': ' + this.formatNumber(todayVal) + ' (today, max: ' + this.formatNumber(maxVal) + '){/bold}');
|
|
616
635
|
for (let row = chartHeight - 1; row >= 0; row--) {
|
|
617
636
|
let line = '';
|
|
618
637
|
const threshold = (row / chartHeight) * maxVal;
|
|
@@ -627,21 +646,13 @@ class TUIServer {
|
|
|
627
646
|
return lines.join('\n');
|
|
628
647
|
};
|
|
629
648
|
|
|
630
|
-
const
|
|
631
|
-
const maxOut = Math.max(...output, 1);
|
|
649
|
+
const maxReasoning = Math.max(...reasoning, 1);
|
|
632
650
|
const maxCache = Math.max(...cache, 1);
|
|
633
|
-
const maxTotal = Math.max(...labels.map((_, i) => (input[i] || 0) + (output[i] || 0) + (reasoning[i] || 0) + (cache[i] || 0)), 1);
|
|
634
651
|
const maxCost = Math.max(...cost, 1);
|
|
635
|
-
|
|
636
|
-
let out = '{center}{bold}\u2501\u2501\u2501 ' + t('trend') + ' \u2501\u2501\u2501{/bold}{/center}\n\n';
|
|
637
|
-
|
|
638
|
-
out += renderChart(input, t('input') + ' (cyan)', 'cyan', maxIn) + '\n';
|
|
639
|
-
out += renderChart(output, t('output') + ' (green)', 'green', maxOut) + '\n';
|
|
652
|
+
out += renderChart(reasoning, t('reasoning') + ' (tool)', 'tool', maxReasoning) + '\n';
|
|
640
653
|
out += renderChart(cache, t('cacheRead') + ' (yellow)', 'yellow', maxCache) + '\n';
|
|
641
|
-
out += renderChart(labels.map((_, i) => (input[i] || 0) + (output[i] || 0) + (reasoning[i] || 0) + (cache[i] || 0)), t('total') + ' (magenta)', 'magenta', maxTotal) + '\n';
|
|
642
654
|
out += renderChart(cost, t('cost') + ' (red)', 'red', maxCost) + '\n';
|
|
643
655
|
|
|
644
|
-
// X-axis: show first date, middle date, last date
|
|
645
656
|
let xAxis = '';
|
|
646
657
|
const labelStep = Math.max(1, Math.ceil(width / 20));
|
|
647
658
|
for (let i = 0; i < width; i++) {
|
|
@@ -654,18 +665,14 @@ class TUIServer {
|
|
|
654
665
|
}
|
|
655
666
|
out += '{gray}' + xAxis + '{/gray}\n';
|
|
656
667
|
|
|
657
|
-
// Add date range info
|
|
658
668
|
const firstDate = trend.dates ? trend.dates[0] : labels[0];
|
|
659
669
|
const lastDate = trend.dates ? trend.dates[trend.dates.length - 1] : labels[labels.length - 1];
|
|
670
|
+
const totalToday = (input[input.length-1]||0) + (output[output.length-1]||0) + (reasoning[reasoning.length-1]||0) + (cache[cache.length-1]||0);
|
|
660
671
|
out += '\n{gray}Range: ' + firstDate + ' \u2192 ' + lastDate + ' (' + labels.length + ' days){/gray}\n';
|
|
661
|
-
|
|
662
|
-
const lastIdx = labels.length - 1;
|
|
663
|
-
const totalTokens = (input[lastIdx] || 0) + (output[lastIdx] || 0) + (reasoning[lastIdx] || 0) + (cache[lastIdx] || 0);
|
|
664
|
-
out += '\n{bold}' + t('today') + ':{/bold} Input: ' + this.formatNumber(input[lastIdx] || 0) + ' | Output: ' + this.formatNumber(output[lastIdx] || 0) + ' | Cache: ' + this.formatNumber(cache[lastIdx] || 0) + ' | Total: ' + this.formatNumber(totalTokens) + ' | Cost: ' + this.formatCost(cost[lastIdx] || 0);
|
|
672
|
+
out += '{bold}' + t('today') + ':{/bold} Input: ' + this.formatNumber(input[input.length - 1] || 0) + ' | Output: ' + this.formatNumber(output[output.length - 1] || 0) + ' | Reasoning: ' + this.formatNumber(reasoning[reasoning.length - 1] || 0) + ' | Cache: ' + this.formatNumber(cache[cache.length - 1] || 0) + ' | Total: ' + this.formatNumber(totalToday) + ' | Cost: ' + this.formatCost(cost[cost.length - 1] || 0);
|
|
665
673
|
|
|
666
674
|
return out;
|
|
667
675
|
}
|
|
668
|
-
|
|
669
676
|
renderHeatmap() {
|
|
670
677
|
const trend = this.data.trend;
|
|
671
678
|
const t = this.t.bind(this);
|
package/fix-i18n.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const c = fs.readFileSync('tui-dashboard.js', 'utf8');
|
|
3
|
-
|
|
4
|
-
const zhOld = ` zh: {
|
|
5
|
-
title: 'opencode-statboard v{version} TUI',
|
|
6
|
-
keys: '[1]總覽 [2]專案 [3]模型 [4]趨勢 [5]熱力 [W]網頁 [R]重整 [Q]離開 [L]語言',
|
|
7
|
-
footer: '上次更新: {time} | 視圖: {view} | W:網頁 R:重整 Q:離開',
|
|
8
|
-
loading: '載入資料中...',
|
|
9
|
-
error: '錯誤: {error}',
|
|
10
|
-
overview: '總覽',
|
|
11
|
-
projects: '專案',
|
|
12
|
-
models: '模型',
|
|
13
|
-
trend: '趨勢 (90 天)',
|
|
14
|
-
heatmap: '熱力圖',
|
|
15
|
-
noData: '無資料',
|
|
16
|
-
sessions: '會話',
|
|
17
|
-
main: '主',
|
|
18
|
-
total: '總計',
|
|
19
|
-
projectsLabel: '專案數',
|
|
20
|
-
days: '天數',
|
|
21
|
-
messages: '訊息',
|
|
22
|
-
tokens: 'Token',
|
|
23
|
-
input: '輸入',
|
|
24
|
-
output: '輸出',
|
|
25
|
-
reasoning: '推理',
|
|
26
|
-
cacheRead: '快取讀取',
|
|
27
|
-
cacheWrite: '快取寫入',
|
|
28
|
-
total: '總計',
|
|
29
|
-
cost: '成本',
|
|
30
|
-
marketValue: '市場價值',
|
|
31
|
-
saved: '節省',
|
|
32
|
-
avgCostDay: '日均成本',
|
|
33
|
-
avgTokensDay: '日均Token',
|
|
34
|
-
projectHeader: '{專案:<45} {會話:>10} {Token:>18} {成本:>14}',
|
|
35
|
-
modelHeader: '{模型:<40} {供應商:<14} {Token:>18} {成本:>12} {速度:>10}',
|
|
36
|
-
unknown: '未知',
|
|
37
|
-
today: '今天',
|
|
38
|
-
version: '版本',
|
|
39
|
-
sun: '日', mon: '一', tue: '二', wed: '三', thu: '四', fri: '五', sat: '六'
|
|
40
|
-
}`;
|
|
41
|
-
|
|
42
|
-
const zhNew = ` zh: {
|
|
43
|
-
title: 'opencode-statboard v{version} TUI',
|
|
44
|
-
keys: '[1]總覽 [2]專案 [3]模型 [4]趨勢 [5]熱力 [W]網頁 [R]重整 [Q]離開 [L]語言',
|
|
45
|
-
footer: '上次更新: {time} | 視圖: {view} | W:網頁 R:重整 Q:離開',
|
|
46
|
-
loading: '載入資料中...',
|
|
47
|
-
error: '錯誤: {error}',
|
|
48
|
-
overview: '總覽',
|
|
49
|
-
projects: '專案',
|
|
50
|
-
models: '模型',
|
|
51
|
-
trend: '趨勢 (90 天)',
|
|
52
|
-
heatmap: '熱力圖',
|
|
53
|
-
noData: '無資料',
|
|
54
|
-
sessions: '會話',
|
|
55
|
-
main: '主',
|
|
56
|
-
total: '總計',
|
|
57
|
-
projectsLabel: '專案數',
|
|
58
|
-
days: '天數',
|
|
59
|
-
messages: '訊息',
|
|
60
|
-
tokens: 'Token',
|
|
61
|
-
input: '輸入',
|
|
62
|
-
output: '輸出',
|
|
63
|
-
reasoning: '推理',
|
|
64
|
-
cacheRead: '快取讀取',
|
|
65
|
-
cacheWrite: '快取寫入',
|
|
66
|
-
total: '總計',
|
|
67
|
-
cost: '成本',
|
|
68
|
-
marketValue: '市場價值',
|
|
69
|
-
saved: '節省',
|
|
70
|
-
avgCostDay: '日均成本',
|
|
71
|
-
avgTokensDay: '日均Token',
|
|
72
|
-
projectHeader: '{專案:<45} {會話:>10} {Token:>18} {成本:>14}',
|
|
73
|
-
modelHeader: '{模型:<40} {供應商:<14} {Token:>18} {成本:>12} {速度:>10}',
|
|
74
|
-
unknown: '未知',
|
|
75
|
-
today: '今天',
|
|
76
|
-
version: '版本',
|
|
77
|
-
sun: '日', mon: '一', tue: '二', wed: '三', thu: '四', fri: '五', sat: '六',
|
|
78
|
-
day: '日', week: '周', month: '月', quarter: '季', all: '全',
|
|
79
|
-
range: '範圍'
|
|
80
|
-
}`;
|
|
81
|
-
|
|
82
|
-
const enOld = ` en: {
|
|
83
|
-
title: 'opencode-statboard v{version} TUI',
|
|
84
|
-
keys: '[1]Overview [2]Projects [3]Models [4]Trend [5]Heatmap [W]Web [R]Refresh [Q]Quit',
|
|
85
|
-
footer: 'Last update: {time} | View: {view} | W:Web R:Refresh Q:Quit',
|
|
86
|
-
loading: 'Loading data...',
|
|
87
|
-
error: 'Error: {error}',
|
|
88
|
-
overview: 'OVERVIEW',
|
|
89
|
-
projects: 'PROJECTS',
|
|
90
|
-
models: 'MODELS',
|
|
91
|
-
trend: 'TREND (90 days)',
|
|
92
|
-
heatmap: 'HEATMAP',
|
|
93
|
-
noData: 'No data',
|
|
94
|
-
sessions: 'Sessions',
|
|
95
|
-
main: 'main',
|
|
96
|
-
total: 'total',
|
|
97
|
-
projectsLabel: 'Projects',
|
|
98
|
-
days: 'Days',
|
|
99
|
-
messages: 'Messages',
|
|
100
|
-
tokens: 'Tokens',
|
|
101
|
-
input: 'Input',
|
|
102
|
-
output: 'Output',
|
|
103
|
-
reasoning: 'Reasoning',
|
|
104
|
-
cacheRead: 'Cache Read',
|
|
105
|
-
cacheWrite: 'Cache Write',
|
|
106
|
-
total: 'Total',
|
|
107
|
-
cost: 'Cost',
|
|
108
|
-
marketValue: 'Market Value',
|
|
109
|
-
saved: 'Saved',
|
|
110
|
-
avgCostDay: 'Avg Cost/Day',
|
|
111
|
-
avgTokensDay: 'Avg Tokens/Day',
|
|
112
|
-
projectHeader: '{Project:<45} {Sessions:>10} {Tokens:>18} {Cost:>14}',
|
|
113
|
-
modelHeader: '{Model:<40} {Provider:<14} {Tokens:>18} {Cost:>12} {Speed:>10}',
|
|
114
|
-
unknown: 'unknown',
|
|
115
|
-
today: 'Today',
|
|
116
|
-
version: 'Version'
|
|
117
|
-
}`;
|
|
118
|
-
|
|
119
|
-
const enNew = ` en: {
|
|
120
|
-
title: 'opencode-statboard v{version} TUI',
|
|
121
|
-
keys: '[1]Overview [2]Projects [3]Models [4]Trend [5]Heatmap [W]Web [R]Refresh [Q]Quit [L]Lang',
|
|
122
|
-
footer: 'Last update: {time} | View: {view} | W:Web R:Refresh Q:Quit',
|
|
123
|
-
loading: 'Loading data...',
|
|
124
|
-
error: 'Error: {error}',
|
|
125
|
-
overview: 'OVERVIEW',
|
|
126
|
-
projects: 'PROJECTS',
|
|
127
|
-
models: 'MODELS',
|
|
128
|
-
trend: 'TREND (90 days)',
|
|
129
|
-
heatmap: 'HEATMAP',
|
|
130
|
-
noData: 'No data',
|
|
131
|
-
sessions: 'Sessions',
|
|
132
|
-
main: 'main',
|
|
133
|
-
total: 'total',
|
|
134
|
-
projectsLabel: 'Projects',
|
|
135
|
-
days: 'Days',
|
|
136
|
-
messages: 'Messages',
|
|
137
|
-
tokens: 'Tokens',
|
|
138
|
-
input: 'Input',
|
|
139
|
-
output: 'Output',
|
|
140
|
-
reasoning: 'Reasoning',
|
|
141
|
-
cacheRead: 'Cache Read',
|
|
142
|
-
cacheWrite: 'Cache Write',
|
|
143
|
-
total: 'Total',
|
|
144
|
-
cost: 'Cost',
|
|
145
|
-
marketValue: 'Market Value',
|
|
146
|
-
saved: 'Saved',
|
|
147
|
-
avgCostDay: 'Avg Cost/Day',
|
|
148
|
-
avgTokensDay: 'Avg Tokens/Day',
|
|
149
|
-
projectHeader: '{Project:<45} {Sessions:>10} {Tokens:>18} {Cost:>14}',
|
|
150
|
-
modelHeader: '{Model:<40} {Provider:<14} {Tokens:>18} {Cost:>12} {Speed:>10}',
|
|
151
|
-
unknown: 'unknown',
|
|
152
|
-
today: 'Today',
|
|
153
|
-
version: 'Version',
|
|
154
|
-
day: 'Day', week: 'Week', month: 'Month', quarter: 'Quarter', all: 'All',
|
|
155
|
-
range: 'Range'
|
|
156
|
-
}`;
|
|
157
|
-
|
|
158
|
-
let newContent = c.replace(zhOld, zhNew).replace(enOld, enNew);
|
|
159
|
-
|
|
160
|
-
fs.writeFileSync('tui-dashboard.js', newContent);
|
|
161
|
-
console.log('Done');
|
package/fix-port-final.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const c = fs.readFileSync('server.js', 'utf8');
|
|
3
|
-
|
|
4
|
-
// Find the tryListen function start
|
|
5
|
-
const tryListenStart = c.indexOf('function tryListen(port, maxPort) {');
|
|
6
|
-
if (tryListenStart === -1) {
|
|
7
|
-
console.log('Could not find tryListen function');
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Find the end of tryListen function
|
|
12
|
-
let braceCount = 0;
|
|
13
|
-
let tryListenEnd = -1;
|
|
14
|
-
for (let i = tryListenStart; i < c.length; i++) {
|
|
15
|
-
if (c[i] === '{') braceCount++;
|
|
16
|
-
else if (c[i] === '}') {
|
|
17
|
-
braceCount--;
|
|
18
|
-
if (braceCount === 0) {
|
|
19
|
-
tryListenEnd = i + 1; // Include the closing brace
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (tryListenEnd === -1) {
|
|
25
|
-
console.log('Could not find end of tryListen function');
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Find the IIFE start
|
|
30
|
-
const iifeStart = c.indexOf('(async () => {');
|
|
31
|
-
if (iifeStart === -1) {
|
|
32
|
-
console.log('Could not find IIFE start');
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Find the end of the IIFE (the closing })();)
|
|
37
|
-
let braceCount = 0;
|
|
38
|
-
let iifeEnd = -1;
|
|
39
|
-
for (let i = c.indexOf('(async () => {'); i < c.length; i++) {
|
|
40
|
-
if (c[i] === '{') braceCount++;
|
|
41
|
-
else if (c[i] === '}') {
|
|
42
|
-
braceCount--;
|
|
43
|
-
if (braceCount === 0) {
|
|
44
|
-
// Check if next chars are })();
|
|
45
|
-
const nextChars = c.substring(i, i + 10);
|
|
46
|
-
if (nextChars.startsWith('})();')) {
|
|
47
|
-
tryListenEnd = i + 5; // Include })();
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (tryListenEnd === -1) {
|
|
54
|
-
console.log('Could not find end of IIFE');
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Find the IIFE start (the async () => { part)
|
|
59
|
-
const iifeStart = c.indexOf('(async () => {');
|
|
60
|
-
if (iifeStart === -1) {
|
|
61
|
-
console.log('Could not find IIFE start');
|
|
62
|
-
process.exit(1);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Build new content
|
|
66
|
-
const beforeTryListen = c.substring(0, tryListenStart);
|
|
67
|
-
const afterIifeStart = c.substring(iifeStart);
|
|
68
|
-
|
|
69
|
-
const newContent = beforeTryListen + `
|
|
70
|
-
async function startServer() {
|
|
71
|
-
return new Promise((resolve, reject) => {
|
|
72
|
-
server.listen(PORT, '127.0.0.1', () => {
|
|
73
|
-
console.log('opencode stats dashboard: http://127.0.0.1:' + PORT);
|
|
74
|
-
resolve(PORT);
|
|
75
|
-
});
|
|
76
|
-
server.once('error', (e) => {
|
|
77
|
-
console.error('Server error:', e.message);
|
|
78
|
-
process.exit(1);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
` + c.substring(iifeStart);
|
|
84
|
-
|
|
85
|
-
fs.writeFileSync('server.js', newContent);
|
|
86
|
-
console.log('Fixed server.js - replaced tryListen with fixed port listener');
|
package/fix-port-final10.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const c = fs.readFileSync('server.js', 'utf8');
|
|
3
|
-
|
|
4
|
-
// Find the tryListen function start
|
|
5
|
-
const tryListenStart = c.indexOf('function tryListen(port, maxPort) {');
|
|
6
|
-
if (tryListenStart === -1) {
|
|
7
|
-
console.log('Could not find tryListen function');
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Find the end of tryListen function
|
|
12
|
-
let braceCount = 0;
|
|
13
|
-
let tryListenEnd = -1;
|
|
14
|
-
for (let i = tryListenStart; i < c.length; i++) {
|
|
15
|
-
if (c[i] === '{') braceCount++;
|
|
16
|
-
else if (c[i] === '}') {
|
|
17
|
-
braceCount--;
|
|
18
|
-
if (braceCount === 0) {
|
|
19
|
-
tryListenEnd = i + 1; // Include the closing brace
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (tryListenEnd === -1) {
|
|
25
|
-
console.log('Could not find end of tryListen function');
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Find the IIFE start
|
|
30
|
-
const iifeStart = c.indexOf('(async () => {');
|
|
31
|
-
if (iifeStart === -1) {
|
|
32
|
-
console.log('Could not find IIFE start');
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Find the end of the IIFE (the closing })();)
|
|
37
|
-
let braceCount = 0;
|
|
38
|
-
let iifeEnd = -1;
|
|
39
|
-
for (let i = c.indexOf('(async () => {'); i < c.length; i++) {
|
|
40
|
-
if (c[i] === '{') braceCount++;
|
|
41
|
-
else if (c[i] === '}') {
|
|
42
|
-
braceCount--;
|
|
43
|
-
if (braceCount === 0) {
|
|
44
|
-
// Check if next chars are })();
|
|
45
|
-
const nextChars = c.substring(i, i + 10);
|
|
46
|
-
if (nextChars.startsWith('})();')) {
|
|
47
|
-
iifeEnd = i + 5; // Include })();
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (iifeEnd === -1) {
|
|
54
|
-
console.log('Could not find end of IIFE');
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Build new content
|
|
59
|
-
const beforeTryListen = c.substring(0, tryListenStart);
|
|
60
|
-
const afterIifeEnd = c.substring(iifeEnd);
|
|
61
|
-
|
|
62
|
-
const newContent = c.substring(0, tryListenStart) + `
|
|
63
|
-
async function startServer() {
|
|
64
|
-
return new Promise((resolve, reject) => {
|
|
65
|
-
server.listen(PORT, '127.0.0.1', () => {
|
|
66
|
-
console.log('opencode stats dashboard: http://127.0.0.1:' + PORT);
|
|
67
|
-
resolve(PORT);
|
|
68
|
-
});
|
|
69
|
-
server.once('error', (e) => {
|
|
70
|
-
console.error('Server error:', e.message);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
` + c.substring(iifeStart);
|
|
77
|
-
|
|
78
|
-
fs.writeFileSync('server.js', newContent);
|
|
79
|
-
console.log('Fixed server.js - replaced tryListen with fixed port listener');
|
package/fix-port-final11.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const c = fs.readFileSync('server.js', 'utf8');
|
|
3
|
-
|
|
4
|
-
// Find the tryListen function start
|
|
5
|
-
const tryListenStart = c.indexOf('function tryListen(port, maxPort) {');
|
|
6
|
-
if (tryListenStart === -1) {
|
|
7
|
-
console.log('Could not find tryListen function');
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Find the end of tryListen function
|
|
12
|
-
let braceCount = 0;
|
|
13
|
-
let tryListenEnd = -1;
|
|
14
|
-
for (let i = tryListenStart; i < c.length; i++) {
|
|
15
|
-
if (c[i] === '{') braceCount++;
|
|
16
|
-
else if (c[i] === '}') {
|
|
17
|
-
braceCount--;
|
|
18
|
-
if (braceCount === 0) {
|
|
19
|
-
tryListenEnd = i + 1; // Include the closing brace
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (tryListenEnd === -1) {
|
|
25
|
-
console.log('Could not find end of tryListen function');
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Find the IIFE start
|
|
30
|
-
const iifeStart = c.indexOf('(async () => {');
|
|
31
|
-
if (iifeStart === -1) {
|
|
32
|
-
console.log('Could not find IIFE start');
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Find the end of the IIFE (the closing })();)
|
|
37
|
-
let braceCount = 0;
|
|
38
|
-
let iifeEnd = -1;
|
|
39
|
-
for (let i = c.indexOf('(async () => {'); i < c.length; i++) {
|
|
40
|
-
if (c[i] === '{') braceCount++;
|
|
41
|
-
else if (c[i] === '}') {
|
|
42
|
-
braceCount--;
|
|
43
|
-
if (braceCount === 0) {
|
|
44
|
-
// Check if next chars are })();
|
|
45
|
-
const nextChars = c.substring(i, i + 10);
|
|
46
|
-
if (nextChars.startsWith('})();')) {
|
|
47
|
-
iifeEnd = i + 5; // Include })();
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (iifeEnd === -1) {
|
|
54
|
-
console.log('Could not find end of IIFE');
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Build new content
|
|
59
|
-
const beforeTryListen = c.substring(0, tryListenStart);
|
|
60
|
-
const afterIifeEnd = c.substring(iifeEnd);
|
|
61
|
-
|
|
62
|
-
const newContent = c.substring(0, tryListenStart) + `
|
|
63
|
-
async function startServer() {
|
|
64
|
-
return new Promise((resolve, reject) => {
|
|
65
|
-
server.listen(PORT, '127.0.0.1', () => {
|
|
66
|
-
console.log('opencode stats dashboard: http://127.0.0.1:' + PORT);
|
|
67
|
-
resolve(PORT);
|
|
68
|
-
});
|
|
69
|
-
server.once('error', (e) => {
|
|
70
|
-
console.error('Server error:', e.message);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
` + c.substring(iifeStart);
|
|
77
|
-
|
|
78
|
-
fs.writeFileSync('server.js', newContent);
|
|
79
|
-
console.log('Fixed server.js - replaced tryListen with fixed port listener');
|
package/fix-port-final12.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const c = fs.readFileSync('server.js', 'utf8');
|
|
3
|
-
|
|
4
|
-
// Find the tryListen function start
|
|
5
|
-
const tryListenStart = c.indexOf('function tryListen(port, maxPort) {');
|
|
6
|
-
if (tryListenStart === -1) {
|
|
7
|
-
console.log('Could not find tryListen function');
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Find the end of tryListen function
|
|
12
|
-
let braceCount = 0;
|
|
13
|
-
let tryListenEnd = -1;
|
|
14
|
-
for (let i = tryListenStart; i < c.length; i++) {
|
|
15
|
-
if (c[i] === '{') braceCount++;
|
|
16
|
-
else if (c[i] === '}') {
|
|
17
|
-
braceCount--;
|
|
18
|
-
if (braceCount === 0) {
|
|
19
|
-
tryListenEnd = i + 1; // Include the closing brace
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (tryListenEnd === -1) {
|
|
25
|
-
console.log('Could not find end of tryListen function');
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Find the IIFE start
|
|
30
|
-
const iifeStart = c.indexOf('(async () => {');
|
|
31
|
-
if (iifeStart === -1) {
|
|
32
|
-
console.log('Could not find IIFE start');
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Find the end of the IIFE (the closing })();)
|
|
37
|
-
let braceCount = 0;
|
|
38
|
-
let iifeEnd = -1;
|
|
39
|
-
for (let i = c.indexOf('(async () => {'); i < c.length; i++) {
|
|
40
|
-
if (c[i] === '{') braceCount++;
|
|
41
|
-
else if (c[i] === '}') {
|
|
42
|
-
braceCount--;
|
|
43
|
-
if (braceCount === 0) {
|
|
44
|
-
// Check if next chars are })();
|
|
45
|
-
const nextChars = c.substring(i, i + 10);
|
|
46
|
-
if (nextChars.startsWith('})();')) {
|
|
47
|
-
iifeEnd = i + 5; // Include })();
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (iifeEnd === -1) {
|
|
54
|
-
console.log('Could not find end of IIFE');
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Build new content
|
|
59
|
-
const beforeTryListen = c.substring(0, tryListenStart);
|
|
60
|
-
const afterIifeEnd = c.substring(iifeEnd);
|
|
61
|
-
|
|
62
|
-
const newContent = c.substring(0, tryListenStart) + `
|
|
63
|
-
async function startServer() {
|
|
64
|
-
return new Promise((resolve, reject) => {
|
|
65
|
-
server.listen(PORT, '127.0.0.1', () => {
|
|
66
|
-
console.log('opencode stats dashboard: http://127.0.0.1:' + PORT);
|
|
67
|
-
resolve(PORT);
|
|
68
|
-
});
|
|
69
|
-
server.once('error', (e) => {
|
|
70
|
-
console.error('Server error:', e.message);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
` + c.substring(iifeStart);
|
|
77
|
-
|
|
78
|
-
fs.writeFileSync('server.js', newContent);
|
|
79
|
-
console.log('Fixed server.js - replaced tryListen with fixed port listener');
|
package/fix-port-final13.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const c = fs.readFileSync('server.js', 'utf8');
|
|
3
|
-
|
|
4
|
-
// Find the tryListen function start
|
|
5
|
-
const tryListenStart = c.indexOf('function tryListen(port, maxPort) {');
|
|
6
|
-
if (tryListenStart === -1) {
|
|
7
|
-
console.log('Could not find tryListen function');
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Find the end of tryListen function
|
|
12
|
-
let braceCount = 0;
|
|
13
|
-
let tryListenEnd = -1;
|
|
14
|
-
for (let i = tryListenStart; i < c.length; i++) {
|
|
15
|
-
if (c[i] === '{') braceCount++;
|
|
16
|
-
else if (c[i] === '}') {
|
|
17
|
-
braceCount--;
|
|
18
|
-
if (braceCount === 0) {
|
|
19
|
-
tryListenEnd = i + 1; // Include the closing brace
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (tryListenEnd === -1) {
|
|
25
|
-
console.log('Could not find end of tryListen function');
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Find the IIFE start
|
|
30
|
-
const iifeStart = c.indexOf('(async () => {');
|
|
31
|
-
if (iifeStart === -1) {
|
|
32
|
-
console.log('Could not find IIFE start');
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Find the end of the IIFE (the closing })();)
|
|
37
|
-
let braceCount = 0;
|
|
38
|
-
let iifeEnd = -1;
|
|
39
|
-
for (let i = c.indexOf('(async () => {'); i < c.length; i++) {
|
|
40
|
-
if (c[i] === '{') braceCount++;
|
|
41
|
-
else if (c[i] === '}') {
|
|
42
|
-
braceCount--;
|
|
43
|
-
if (braceCount === 0) {
|
|
44
|
-
// Check if next chars are })();
|
|
45
|
-
const nextChars = c.substring(i, i + 10);
|
|
46
|
-
if (nextChars.startsWith('})();')) {
|
|
47
|
-
iifeEnd = i + 5; // Include })();
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (iifeEnd === -1) {
|
|
54
|
-
console.log('Could not find end of IIFE');
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Build new content
|
|
59
|
-
const beforeTryListen = c.substring(0, tryListenStart);
|
|
60
|
-
const afterIifeEnd = c.substring(iifeEnd);
|
|
61
|
-
|
|
62
|
-
const newContent = c.substring(0, tryListenStart) + `
|
|
63
|
-
async function startServer() {
|
|
64
|
-
return new Promise((resolve, reject) => {
|
|
65
|
-
server.listen(PORT, '127.0.0.1', () => {
|
|
66
|
-
console.log('opencode stats dashboard: http://127.0.0.1:' + PORT);
|
|
67
|
-
resolve(PORT);
|
|
68
|
-
});
|
|
69
|
-
server.once('error', (e) => {
|
|
70
|
-
console.error('Server error:', e.message);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
` + c.substring(iifeStart);
|
|
77
|
-
|
|
78
|
-
fs.writeFileSync('server.js', newContent);
|
|
79
|
-
console.log('Fixed server.js - replaced tryListen with fixed port listener');
|