sprag-cli 3.94.0 → 3.95.0
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/bin/cli.js +1 -1
- package/package.json +1 -1
- package/src/commands/saved.js +20 -5
- package/src/monthly-reset-offer.js +7 -7
- package/src/saved-reset.cjs +6 -4
package/bin/cli.js
CHANGED
|
@@ -428,7 +428,7 @@ async function main() {
|
|
|
428
428
|
}
|
|
429
429
|
|
|
430
430
|
// Subcommand: saved — stopwatch reset for the lifetime "saved" counters.
|
|
431
|
-
// sprag saved | saved reset [routing|doc2md|all] | saved undo | saved keep
|
|
431
|
+
// sprag saved | saved reset [routing|doc2md|all] [--month-start] | saved undo | saved keep
|
|
432
432
|
if (args[0] === 'saved') {
|
|
433
433
|
return (await import('../src/commands/saved.js')).run({ args, hasFlag });
|
|
434
434
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sprag-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.95.0",
|
|
4
4
|
"description": "Model-delegation router for Claude Code and Codex: lookups, checks and test runs go to cheaper models, documents go in as compact Markdown, and a live statusline shows spend and savings.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/commands/saved.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* sprag saved # totals since the last reset
|
|
5
5
|
* sprag saved reset [routing|doc2md|all] # start counting from now
|
|
6
|
+
* --month-start # or from the 1st of this month, 00:00 local
|
|
6
7
|
* sprag saved undo # put the previous counters back
|
|
7
8
|
* sprag saved keep # decline this month's reset offer
|
|
8
9
|
* (add --agent codex for the Codex counters: codex-routing, codex-docs)
|
|
@@ -166,7 +167,7 @@ export async function run({ args, hasFlag, agent = 'claude', dir: dirArg, rescan
|
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
if (sub === 'reset') {
|
|
169
|
-
const arg = args
|
|
170
|
+
const arg = args.slice(2).find((a) => !a.startsWith('-')) || 'all';
|
|
170
171
|
const base = agent === 'codex' ? { routing: 'codex-routing', doc2md: 'codex-docs' } : { routing: 'routing', doc2md: 'doc2md' };
|
|
171
172
|
let targets;
|
|
172
173
|
if (arg === 'all') targets = scopes;
|
|
@@ -178,13 +179,27 @@ export async function run({ args, hasFlag, agent = 'claude', dir: dirArg, rescan
|
|
|
178
179
|
: `Unknown scope: ${arg}. Valid scopes are ${scopes.join(', ')}, all.`);
|
|
179
180
|
process.exit(1);
|
|
180
181
|
}
|
|
182
|
+
// --month-start dates the mark to the 1st, 00:00 local, rather than now: the
|
|
183
|
+
// monthly offer is usually answered a day or more into the month (the 1st
|
|
184
|
+
// fell on a Sunday in 2026-11), and a mark at "now" would drop those days.
|
|
185
|
+
const now = Date.now();
|
|
186
|
+
const today = new Date(now);
|
|
187
|
+
const fromMonthStart = hasFlag('--month-start');
|
|
188
|
+
const mark = fromMonthStart ? new Date(today.getFullYear(), today.getMonth(), 1).getTime() : now;
|
|
181
189
|
const before = {};
|
|
182
190
|
for (const s of targets) before[s] = await currentTotals(s, dir);
|
|
183
|
-
resetSaved(targets, { dir });
|
|
191
|
+
resetSaved(targets, { dir, now, mark });
|
|
184
192
|
for (const s of targets) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
193
|
+
if (fromMonthStart) {
|
|
194
|
+
const after = await currentTotals(s, dir);
|
|
195
|
+
console.log(ko
|
|
196
|
+
? `${label(s)} 카운터를 ${today.getMonth() + 1}월 1일 0시부터 다시 셉니다. 이번 달 합계는 ${fmtTotal(after)}이고 이전 합계는 ${fmtTotal(before[s])}입니다.`
|
|
197
|
+
: `The ${label(s)} counter now counts from ${today.getMonth() + 1}/1 00:00. This month so far: ${fmtTotal(after)}. The previous total was ${fmtTotal(before[s])}.`);
|
|
198
|
+
} else {
|
|
199
|
+
console.log(ko
|
|
200
|
+
? `${label(s)} 카운터를 0으로 초기화했습니다. 이전 합계는 ${fmtTotal(before[s])}입니다.`
|
|
201
|
+
: `Reset the ${label(s)} counter to zero. The previous total was ${fmtTotal(before[s])}.`);
|
|
202
|
+
}
|
|
188
203
|
}
|
|
189
204
|
console.log(ko
|
|
190
205
|
? `원장 기록은 지우지 않았습니다. \`sprag saved undo${suffix}\`로 되돌릴 수 있습니다.`
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*
|
|
8
8
|
* The asking happens at session start for the same reason as the upgrade and
|
|
9
9
|
* seed offers: a statusline cannot open a dialog. The offer repeats at every
|
|
10
|
-
* fresh session until the user answers: yes runs
|
|
11
|
-
*
|
|
12
|
-
* declined. Printing alone records nothing, because a session where nobody
|
|
10
|
+
* fresh session until the user answers: yes runs
|
|
11
|
+
* `sprag saved reset all --month-start`, whose mark (the 1st, 00:00) silences
|
|
12
|
+
* it; no runs `sprag saved keep`, which records the month as declined. Printing alone records nothing, because a session where nobody
|
|
13
13
|
* read the offer must not count as an answer (2026-11-01: a batch job got
|
|
14
14
|
* November's only ask under the old once-per-month rule).
|
|
15
15
|
*/
|
|
@@ -98,16 +98,16 @@ export function monthlyResetOffer({ dir = userDataDir(), now = Date.now(), lang
|
|
|
98
98
|
const block = ko
|
|
99
99
|
? [
|
|
100
100
|
`✇ [sprag monthly-reset] ${today.getMonth() + 1}월 1일 이후 절감 집계를 초기화한 적이 없습니다. 지금 보이는 값은 ${sinceText} 누적입니다: 라우팅 절감 ${formatMoney(routingOk)}, Doc2md 절감 ${formatMoney(docOk)}.`,
|
|
101
|
-
'이번 달 기준으로 새로 보려면 초기화를 권장합니다. 초기화하면 라우팅 절감과 Doc2md 절감, Model used
|
|
101
|
+
'이번 달 기준으로 새로 보려면 초기화를 권장합니다. 초기화하면 라우팅 절감과 Doc2md 절감, Model used 비율을 이번 달 1일 0시부터 다시 집계합니다. 기록은 지워지지 않고 `sprag saved undo` 로 되돌릴 수 있습니다.',
|
|
102
102
|
'사용자에게 위 내용을 알리고 초기화할지 물어보십시오. 승낙하면 첫째 명령을, 거절하면 둘째 명령을 실행하십시오. 둘 중 하나를 실행하기 전에는 새 세션을 열 때마다 이 안내가 다시 나옵니다. 거절하면 이번 달에는 더 묻지 않습니다.',
|
|
103
|
-
' sprag saved reset all',
|
|
103
|
+
' sprag saved reset all --month-start',
|
|
104
104
|
' sprag saved keep',
|
|
105
105
|
]
|
|
106
106
|
: [
|
|
107
107
|
`✇ [sprag monthly-reset] The saved counters have not been reset since ${MONTH_NAMES[today.getMonth()]} 1. The figures shown are cumulative ${sinceText}: routing saved ${formatMoney(routingOk)}, Doc2md saved ${formatMoney(docOk)}.`,
|
|
108
|
-
'A reset is recommended to see this month on its own. It
|
|
108
|
+
'A reset is recommended to see this month on its own. It recounts routing savings, Doc2md savings and the Model used share from the 1st of this month, 00:00. Nothing is deleted, and `sprag saved undo` puts it back.',
|
|
109
109
|
'Tell the user this and ask whether to reset. If they agree, run the first command; if they decline, run the second. Until one of them runs, this offer comes back at every new session. A decline keeps it quiet for the rest of the month.',
|
|
110
|
-
' sprag saved reset all',
|
|
110
|
+
' sprag saved reset all --month-start',
|
|
111
111
|
' sprag saved keep',
|
|
112
112
|
];
|
|
113
113
|
|
package/src/saved-reset.cjs
CHANGED
|
@@ -72,17 +72,19 @@ function readResetMarks(dir) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
* Reset the given scopes to `now
|
|
76
|
-
* ignored; the caller validates user input.
|
|
75
|
+
* Reset the given scopes to `mark` (default `now`). Returns the new marks.
|
|
76
|
+
* Unknown scopes are ignored; the caller validates user input. `mark` may lie
|
|
77
|
+
* before `now`: `sprag saved reset --month-start` dates it to the 1st so a
|
|
78
|
+
* reset made on the 2nd still counts the whole month.
|
|
77
79
|
*/
|
|
78
|
-
function resetSaved(scopes, { dir, now = Date.now() } = {}) {
|
|
80
|
+
function resetSaved(scopes, { dir, now = Date.now(), mark = now } = {}) {
|
|
79
81
|
const state = readState(dir);
|
|
80
82
|
const valid = [...new Set(scopes)].filter((s) => SCOPES.includes(s));
|
|
81
83
|
if (valid.length === 0) return state.marks;
|
|
82
84
|
const prev = {};
|
|
83
85
|
for (const s of valid) {
|
|
84
86
|
prev[s] = state.marks[s];
|
|
85
|
-
state.marks[s] =
|
|
87
|
+
state.marks[s] = mark;
|
|
86
88
|
}
|
|
87
89
|
state.history.push({ at: now, scopes: valid, prev });
|
|
88
90
|
if (state.history.length > MAX_HISTORY) state.history.splice(0, state.history.length - MAX_HISTORY);
|