@leo000001/opencode-quota-sidebar 2.0.5 → 2.0.7
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/dist/title.js +25 -3
- package/dist/title_apply.js +10 -3
- package/package.json +1 -1
package/dist/title.js
CHANGED
|
@@ -11,6 +11,9 @@ function isCoreDecoratedDetail(line) {
|
|
|
11
11
|
}
|
|
12
12
|
if (/^Cache\s+(Read|Write)\s+\$?\d[\d.,]*[kKmM]?$/.test(line))
|
|
13
13
|
return true;
|
|
14
|
+
if (/^Cache(?:\s+Read)?\s+Coverage\s+\d[\d.,]*(?:%|~)?$/.test(line)) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
14
17
|
if (/^\$\S+\s+as API cost$/.test(line))
|
|
15
18
|
return true;
|
|
16
19
|
// Single-line compact mode compatibility.
|
|
@@ -20,6 +23,23 @@ function isCoreDecoratedDetail(line) {
|
|
|
20
23
|
return true;
|
|
21
24
|
if (/^C(?:ache\s*)?W(?:rite)?\s+\$?\d[\d.,]*[kKmM]?$/.test(line))
|
|
22
25
|
return true;
|
|
26
|
+
if (/^C(?:ache(?:\s*R(?:ead)?)?)?\s*Coverage\s+\d[\d.,]*(?:%|~)?$/.test(line)) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
function isQuotaDecoratedDetail(line) {
|
|
32
|
+
if (!line)
|
|
33
|
+
return false;
|
|
34
|
+
if (/^(OpenAI|Copilot|Anthropic|Kimi|XYAI|Buzz|RC(?:-[^\s]+)?)\s*$/.test(line)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (/^(?:(?:Daily\s+\$[\d.,]+\/\$[\d.,]+|\$[\d.,]+\/\$[\d.,]+)(?:\s+(?:Rst|Exp\+?)\s+[-:\d]+)?|(?:\d+[hdw]|Weekly|Monthly)\s+\d{1,3}%(?:\s+Rst\s+[-:\d]+)?|Balance\s+\$[\d.,]+|Remaining\s+\?|(?:error|unsupported|unavailable))$/.test(line)) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (/^(OpenAI|Copilot|Anthropic|Kimi|XYAI|Buzz|RC(?:-[^\s]+)?)(?:\s+(?:(?:Daily\s+\$[\d.,]+\/\$[\d.,]+|\$[\d.,]+\/\$[\d.,]+)(?:\s+(?:Rst|Exp\+?)\s+[-:\d]+)?|(?:\d+[hdw]|Weekly|Monthly)\s+\d{1,3}%(?:\s+Rst\s+[-:\d]+)?|(?:error|unsupported|unavailable)))$/.test(line)) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
23
43
|
return false;
|
|
24
44
|
}
|
|
25
45
|
function isSingleLineDecoratedPrefix(line) {
|
|
@@ -41,7 +61,9 @@ function isSingleLineDecoratedPrefix(line) {
|
|
|
41
61
|
return false;
|
|
42
62
|
}
|
|
43
63
|
function isSingleLineDetailPrefix(line) {
|
|
44
|
-
return isCoreDecoratedDetail(line) ||
|
|
64
|
+
return (isCoreDecoratedDetail(line) ||
|
|
65
|
+
isSingleLineDecoratedPrefix(line) ||
|
|
66
|
+
isQuotaDecoratedDetail(line));
|
|
45
67
|
}
|
|
46
68
|
function decoratedSingleLineBase(line) {
|
|
47
69
|
const parts = sanitizeTitleFragment(line)
|
|
@@ -66,7 +88,7 @@ export function normalizeBaseTitle(title) {
|
|
|
66
88
|
const lines = stripAnsi(safeTitle).split(/\r?\n/);
|
|
67
89
|
if (lines.length > 1) {
|
|
68
90
|
const detail = lines.slice(1).map((line) => sanitizeTitleFragment(line).trim());
|
|
69
|
-
if (detail.some((line) => isCoreDecoratedDetail(line))) {
|
|
91
|
+
if (detail.some((line) => isCoreDecoratedDetail(line) || isQuotaDecoratedDetail(line))) {
|
|
70
92
|
return sanitizeTitleFragment(firstLine) || 'Session';
|
|
71
93
|
}
|
|
72
94
|
}
|
|
@@ -116,5 +138,5 @@ export function looksDecorated(title) {
|
|
|
116
138
|
const detail = lines
|
|
117
139
|
.slice(1)
|
|
118
140
|
.map((line) => sanitizeTitleFragment(line).trim());
|
|
119
|
-
return detail.some((line) => isCoreDecoratedDetail(line));
|
|
141
|
+
return detail.some((line) => isCoreDecoratedDetail(line) || isQuotaDecoratedDetail(line));
|
|
120
142
|
}
|
package/dist/title_apply.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { canonicalizeTitle, canonicalizeTitleForCompare, looksDecorated, } from './title.js';
|
|
1
|
+
import { canonicalizeTitle, canonicalizeTitleForCompare, looksDecorated, normalizeBaseTitle, } from './title.js';
|
|
2
2
|
import { swallow, debug, mapConcurrent } from './helpers.js';
|
|
3
3
|
export function createTitleApplicator(deps) {
|
|
4
4
|
const pendingAppliedTitle = new Map();
|
|
@@ -33,6 +33,13 @@ export function createTitleApplicator(deps) {
|
|
|
33
33
|
if (canonicalizeTitle(currentTitle) !==
|
|
34
34
|
canonicalizeTitle(sessionState.lastAppliedTitle || '')) {
|
|
35
35
|
if (looksDecorated(currentTitle)) {
|
|
36
|
+
if (/\r?\n/.test(currentTitle)) {
|
|
37
|
+
const normalizedBase = normalizeBaseTitle(currentTitle);
|
|
38
|
+
if (sessionState.baseTitle !== normalizedBase) {
|
|
39
|
+
sessionState.baseTitle = normalizedBase;
|
|
40
|
+
stateMutated = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
36
43
|
// Ignore decorated echoes as base-title source.
|
|
37
44
|
// If we previously applied a decorated title, treat this as an
|
|
38
45
|
// equivalent echo (OpenCode may normalize whitespace) and keep
|
|
@@ -53,7 +60,7 @@ export function createTitleApplicator(deps) {
|
|
|
53
60
|
}
|
|
54
61
|
}
|
|
55
62
|
else {
|
|
56
|
-
const nextBase =
|
|
63
|
+
const nextBase = normalizeBaseTitle(currentTitle);
|
|
57
64
|
if (sessionState.baseTitle !== nextBase) {
|
|
58
65
|
sessionState.baseTitle = nextBase;
|
|
59
66
|
stateMutated = true;
|
|
@@ -165,7 +172,7 @@ export function createTitleApplicator(deps) {
|
|
|
165
172
|
return;
|
|
166
173
|
}
|
|
167
174
|
}
|
|
168
|
-
args.sessionState.baseTitle =
|
|
175
|
+
args.sessionState.baseTitle = normalizeBaseTitle(args.incomingTitle);
|
|
169
176
|
args.sessionState.lastAppliedTitle = undefined;
|
|
170
177
|
deps.markDirty(deps.state.sessionDateMap[args.sessionID]);
|
|
171
178
|
deps.scheduleSave();
|