@legios/quartermaster 0.1.20 → 0.1.22
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/README.md +158 -8
- package/bin/qm +12 -8
- package/bin/qm-barra.swift +32 -4
- package/bin/qm-indicator +59 -7
- package/bin/qm-tray.ps1 +49 -4
- package/bin/qm.cmd +6 -2
- package/bin/qm.mjs +23 -2
- package/dist/adapters/antigravity.js +2 -1
- package/dist/adapters/antigravity.js.map +1 -1
- package/dist/adapters/barra.js +18 -13
- package/dist/adapters/barra.js.map +1 -1
- package/dist/adapters/cache-cuota.js +3 -2
- package/dist/adapters/cache-cuota.js.map +1 -1
- package/dist/adapters/codex.js +140 -7
- package/dist/adapters/codex.js.map +1 -1
- package/dist/adapters/credenciales.js +2 -1
- package/dist/adapters/credenciales.js.map +1 -1
- package/dist/adapters/cuota-guardada.js +23 -0
- package/dist/adapters/cuota-guardada.js.map +1 -0
- package/dist/adapters/cuota.js +6 -5
- package/dist/adapters/cuota.js.map +1 -1
- package/dist/adapters/entorno.js +21 -20
- package/dist/adapters/entorno.js.map +1 -1
- package/dist/adapters/lineas.js +111 -0
- package/dist/adapters/lineas.js.map +1 -0
- package/dist/adapters/statusline.js +252 -0
- package/dist/adapters/statusline.js.map +1 -0
- package/dist/adapters/transcripciones.js +140 -2
- package/dist/adapters/transcripciones.js.map +1 -1
- package/dist/adapters/utilizacion.js +19 -7
- package/dist/adapters/utilizacion.js.map +1 -1
- package/dist/adapters/zai.js +5 -4
- package/dist/adapters/zai.js.map +1 -1
- package/dist/cli/aviso.js +136 -0
- package/dist/cli/aviso.js.map +1 -0
- package/dist/cli/desglose.js +200 -0
- package/dist/cli/desglose.js.map +1 -0
- package/dist/cli/mejor.js +140 -0
- package/dist/cli/mejor.js.map +1 -0
- package/dist/cli/preflight.js +3 -2
- package/dist/cli/preflight.js.map +1 -1
- package/dist/cli/qm.js +369 -90
- package/dist/cli/qm.js.map +1 -1
- package/dist/core/aviso.js +66 -0
- package/dist/core/aviso.js.map +1 -0
- package/dist/core/config.js +6 -2
- package/dist/core/config.js.map +1 -1
- package/dist/core/desglose.js +343 -0
- package/dist/core/desglose.js.map +1 -0
- package/dist/core/eleccion.js +105 -0
- package/dist/core/eleccion.js.map +1 -0
- package/dist/core/idioma.js +51 -0
- package/dist/core/idioma.js.map +1 -0
- package/dist/core/perfiles.js +69 -3
- package/dist/core/perfiles.js.map +1 -1
- package/dist/core/presupuesto.js +26 -10
- package/dist/core/presupuesto.js.map +1 -1
- package/dist/core/proyeccion.js +12 -4
- package/dist/core/proyeccion.js.map +1 -1
- package/dist/core/relevancia.js +5 -4
- package/dist/core/relevancia.js.map +1 -1
- package/dist/core/tipos.js +41 -10
- package/dist/core/tipos.js.map +1 -1
- package/dist/render/barras.js +18 -11
- package/dist/render/barras.js.map +1 -1
- package/dist/render/desglose.js +237 -0
- package/dist/render/desglose.js.map +1 -0
- package/dist/render/tablero.html +16 -1
- package/extension/gnome43/quartermaster@legios/metadata.json +1 -1
- package/extension/quartermaster@legios/metadata.json +1 -1
- package/package.json +1 -1
- package/scripts/gate-avisos.py +96 -0
- package/scripts/gate-dibujo.sh +11 -0
- package/scripts/gate-duraciones.py +5 -1
- package/scripts/gate-edades.py +124 -0
- package/scripts/gate-presupuesto.py +4 -1
- package/src/render/tablero.html +16 -1
package/README.md
CHANGED
|
@@ -105,30 +105,181 @@ get one, rather than dying with a syntax error.
|
|
|
105
105
|
|
|
106
106
|
```sh
|
|
107
107
|
qm # quota and usage for every account
|
|
108
|
-
qm --
|
|
108
|
+
qm --statusline # one line, for Claude Code's statusLine — and it records
|
|
109
|
+
# the quota Claude Code hands it, no network, no credential
|
|
110
|
+
qm --breve # the quota part of that line, without reading stdin
|
|
111
|
+
qm --todas # dormant accounts in full, not one line each at the bottom
|
|
109
112
|
qm --json # the same, for scripts and panels
|
|
110
113
|
qm --refrescar # also ask the endpoint (needs a live token)
|
|
111
114
|
qm --watch 60 # redraw every N seconds
|
|
112
115
|
qm --umbral=80 # exit 3 if any bar is over N%
|
|
113
116
|
qm --esperar # block until quota drops: qm --esperar && codex ...
|
|
117
|
+
qm --mejor -- claude # start claude in the profile with the most room left
|
|
118
|
+
qm --aviso # a UserPromptSubmit hook: warns inside Claude Code
|
|
114
119
|
qm --diagnostico # everything a bug report needs, already redacted
|
|
120
|
+
qm --desglose # where the week's quota went — disk only, never the network
|
|
121
|
+
qm --idioma=es # this run in Spanish (or =en); QM_IDIOMA does it for good
|
|
115
122
|
```
|
|
116
123
|
|
|
117
124
|
In Claude Code's `settings.json`:
|
|
118
125
|
|
|
119
126
|
```json
|
|
120
|
-
{ "statusLine": { "type": "command", "command": "qm --
|
|
127
|
+
{ "statusLine": { "type": "command", "command": "qm --statusline" } }
|
|
121
128
|
```
|
|
122
129
|
|
|
130
|
+
**Put it here even if you never look at the line.** Claude Code no longer
|
|
131
|
+
leaves the quota in `.claude.json` on every use; what it does do is pass the
|
|
132
|
+
statusline command a `rate_limits` object on every redraw — the session and
|
|
133
|
+
weekly percentages from the last API response. `qm --statusline` saves that
|
|
134
|
+
per profile, so every other `qm` (the terminal, `--json`, the panels) has a
|
|
135
|
+
number that is seconds old and cost no request. It carries only those two
|
|
136
|
+
bars, so it is laid **over** the last endpoint reading rather than replacing
|
|
137
|
+
it: a model-scoped bar the statusline does not know about keeps its value and
|
|
138
|
+
shows its own age.
|
|
139
|
+
|
|
140
|
+
Already have a statusline script? Pipe the event through and print what comes
|
|
141
|
+
back: `echo "$input" | qm --statusline`.
|
|
142
|
+
|
|
123
143
|
```
|
|
124
|
-
personal 23/75%! · teams 9/42% · codex 49/59%
|
|
144
|
+
ctx 182k · cache 12m · personal 23/75%! · teams 9/42% · codex 49/59%
|
|
125
145
|
```
|
|
126
146
|
|
|
147
|
+
The first two segments are the session drawing the line, and they are what the
|
|
148
|
+
*next* prompt will cost: the context size (yellow from 400k — prompts that big
|
|
149
|
+
were 35 % of a measured week's weighted cost with 16 % of the requests) and
|
|
150
|
+
how long the prompt cache stays warm. Once it goes cold the line says
|
|
151
|
+
`cold cache (+181k)`: the next request rewrites that many tokens of cache, so
|
|
152
|
+
that is the moment to decide between `/clear` and carrying on. `--breve` prints
|
|
153
|
+
only the quota part.
|
|
154
|
+
|
|
127
155
|
**Two numbers per account, on purpose.** The first is the session; the second is
|
|
128
156
|
the bar that stops you first. They answer different questions — "can I keep
|
|
129
157
|
going right now?" and "do I make it to the end of the week?" — and either one
|
|
130
158
|
alone is half an answer.
|
|
131
159
|
|
|
160
|
+
When that second bar is not the one you would assume — a model-scoped bar, or
|
|
161
|
+
one the server sends without a name — the line says which: `main 44%
|
|
162
|
+
iguana_necktie` next to a weekly at 13 % is that bar, not a wrong weekly.
|
|
163
|
+
|
|
164
|
+
### Language
|
|
165
|
+
|
|
166
|
+
`qm` speaks English or Spanish, picked from the locale the way any terminal
|
|
167
|
+
program does: the first non-empty of `LC_ALL`, `LC_MESSAGES` and `LANG` — `es*`
|
|
168
|
+
is Spanish, anything else (including `C` and `C.UTF-8`) is English — and on
|
|
169
|
+
Windows, where those are usually unset, the system's regional setting.
|
|
170
|
+
`QM_IDIOMA=es` or `QM_IDIOMA=en` overrides it for good, `--idioma=` for one run.
|
|
171
|
+
A Spanish speaker on a machine with `LC_ALL=C.UTF-8` gets English until they set
|
|
172
|
+
`QM_IDIOMA=es`. The `--aviso` hook runs with Claude Code's environment, so its
|
|
173
|
+
warning follows the same rule.
|
|
174
|
+
|
|
175
|
+
`--json` is the exception. The four panels draw its sentences (`frase`,
|
|
176
|
+
`nombre`, `credencial`, `porque`) next to labels of their own that are still in
|
|
177
|
+
Spanish, and a panel with half its words in each language reads worse than one
|
|
178
|
+
in Spanish. So the JSON's text stays Spanish unless you ask for a language on
|
|
179
|
+
purpose with `QM_IDIOMA` or `--idioma`. Its keys never change.
|
|
180
|
+
|
|
181
|
+
## Before the wall
|
|
182
|
+
|
|
183
|
+
**`qm --mejor`** picks the Claude profile with the most room right now: the
|
|
184
|
+
lowest binding bar, then a projection that hits 100% before the reset counts
|
|
185
|
+
against it, then the emptier session. A window whose reset already passed is
|
|
186
|
+
*unknown*, not 0%. Profiles with no session or no stored number are left out.
|
|
187
|
+
|
|
188
|
+
```sh
|
|
189
|
+
qm --mejor -- claude # start claude there
|
|
190
|
+
qm --mejor # just print the directory, for scripts
|
|
191
|
+
qm --mejor --json # the whole ranking, and why
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Use the `--` form to launch. `CLAUDE_CONFIG_DIR=$(qm --mejor) claude` is wrong
|
|
195
|
+
for the default profile: with the variable set, even to `~/.claude`, Claude
|
|
196
|
+
Code reads `~/.claude/.claude.json` instead of `~/.claude.json`, and on macOS
|
|
197
|
+
it stops looking in the keychain — a different profile, with no session.
|
|
198
|
+
`qm --mejor -- …` removes the variable for the default profile.
|
|
199
|
+
|
|
200
|
+
**`qm --aviso`** is a hook that warns you *inside* Claude Code, where you are
|
|
201
|
+
looking, before the bar stops you. In the profile's `settings.json`:
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"hooks": {
|
|
206
|
+
"UserPromptSubmit": [
|
|
207
|
+
{ "hooks": [{ "type": "command", "command": "qm --aviso" }] }
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
qm · main: iguana_necktie at 92 % · resets in 3d7h. teams has 94 % free: CLAUDE_CONFIG_DIR=~/.claude-teams claude
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
It speaks when the binding bar crosses 90% (`--umbral=N`), again at 95 and
|
|
218
|
+
100, and when the projection says you hit 100% before the reset within 30
|
|
219
|
+
minutes — once per step and per window, so it does not repeat on every
|
|
220
|
+
prompt. The message goes in `systemMessage`, which Claude Code shows to you and
|
|
221
|
+
not to the model; it never blocks the prompt and always exits 0. Disk only, like
|
|
222
|
+
`--breve`: it reads what `qm --statusline` and the bar left, so it needs one of
|
|
223
|
+
them to have a number.
|
|
224
|
+
|
|
225
|
+
## Where did it go?
|
|
226
|
+
|
|
227
|
+
`qm` tells you how much is left. `qm --desglose` tells you what spent it: the
|
|
228
|
+
same transcripts, broken down over the last 7 days (`--dias=N` for another
|
|
229
|
+
window), one block per account.
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
.claude · ~/.claude
|
|
233
|
+
7,909 requests · 282.1M of weighted cost (equivalent input tokens)
|
|
234
|
+
|
|
235
|
+
what to do · shares of the weighted cost: they approximate the quota, they don't measure it
|
|
236
|
+
· 35.0% of the cost came from prompts of 400k or more (16.3% of the
|
|
237
|
+
requests). Every turn rereads the whole context: /compact or /clear
|
|
238
|
+
before you get there makes every request after it cheaper.
|
|
239
|
+
|
|
240
|
+
by token class
|
|
241
|
+
cache read ██████████░░░░░ 67.6% 1.9G tokens
|
|
242
|
+
write 1h ██░░░░░░░░░░░░░ 11.7% 16.5M tokens
|
|
243
|
+
write 5m ██░░░░░░░░░░░░░ 11.9% 26.8M tokens
|
|
244
|
+
output █░░░░░░░░░░░░░░ 8.8% 5.0M tokens
|
|
245
|
+
input ░░░░░░░░░░░░░░░ 0.0% 15.9k tokens
|
|
246
|
+
…
|
|
247
|
+
400k or more: 35.0% of the cost in 1,288 requests (16.3% of the requests)
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
It opens with **what to do** — at most three tips per account, each one
|
|
251
|
+
carrying the measured number it rests on, ranked by how much of the cost it
|
|
252
|
+
explains: prompts of 400k or more (`/compact` or `/clear` sooner), cache
|
|
253
|
+
rewritten after a pause, an agent type that costs per request as much as the
|
|
254
|
+
main thread (a `fork` drags the whole conversation along) when a cheaper one is
|
|
255
|
+
in common use, or a few sessions taking most of the week. A tip appears only
|
|
256
|
+
when its number crosses a threshold; an account with nothing to fix gets no
|
|
257
|
+
generic advice. Then the evidence, five answers per account:
|
|
258
|
+
|
|
259
|
+
- **Cost by token class.** Tokens are weighted by their relative API price —
|
|
260
|
+
cache read 0.1, cache write 1.25 (5-minute TTL) or 2 (1-hour TTL), input 1,
|
|
261
|
+
output 5 — as a **proxy** for quota drain. Anthropic does not publish how a
|
|
262
|
+
subscription weighs them, and the output says so every time.
|
|
263
|
+
- **Cost by prompt size**, in buckets from `<50k` to `>700k`, plus how much of
|
|
264
|
+
it came from prompts of 400k or more.
|
|
265
|
+
- **Cache rebuilds**: requests that wrote more than 20k of cache without being
|
|
266
|
+
the first of their transcript, split by how long the cache sat idle (over an
|
|
267
|
+
hour, 5–60 minutes, or no gap) and by main thread vs subagent.
|
|
268
|
+
- **Subagents**: the main thread against each agent type.
|
|
269
|
+
- **The most expensive sessions**: requests, largest and median context,
|
|
270
|
+
compactions and duration, with the project directory — never message
|
|
271
|
+
content.
|
|
272
|
+
|
|
273
|
+
Requests are deduplicated by message and request id, because a reply with
|
|
274
|
+
several content blocks is written once per block with the same usage. Codex is
|
|
275
|
+
included when it is installed (its rollouts report usage per request; they do
|
|
276
|
+
not report cache writes or subagents, and the output says that instead of
|
|
277
|
+
printing zeros). `--json` gives the same numbers for a script, and
|
|
278
|
+
`--redactado` also replaces every project directory with `project 1`,
|
|
279
|
+
`project 2`… (`proyecto 1` in Spanish and in `--json`) and drops session ids, so the report can be pasted somewhere
|
|
280
|
+
public. Reading a week of transcripts — about 2 GB across two profiles — takes
|
|
281
|
+
about two seconds; see [`numeros/desglose.md`](numeros/desglose.md).
|
|
282
|
+
|
|
132
283
|
## When something is wrong
|
|
133
284
|
|
|
134
285
|
```sh
|
|
@@ -145,10 +296,10 @@ the cache directory, and `ps` for when the graphical session started — and it
|
|
|
145
296
|
prompted it:
|
|
146
297
|
|
|
147
298
|
```
|
|
148
|
-
⚠ extension.js
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
→
|
|
299
|
+
⚠ extension.js is 12.9 h NEWER than the graphical session.
|
|
300
|
+
The shell loads the module once and keeps it in memory: what is
|
|
301
|
+
running is the old file …
|
|
302
|
+
→ log out and back in. It is the only step left.
|
|
152
303
|
```
|
|
153
304
|
|
|
154
305
|
Anything it cannot find out it says so — it never omits and never guesses. It
|
|
@@ -267,7 +418,6 @@ secret configured — and says in the log which ones it skipped and why.
|
|
|
267
418
|
| **`.deb`** | `sudo apt install ./quartermaster_*.deb` | the same package, standalone | attached to the release |
|
|
268
419
|
| **Windows installer** | `quartermaster-<v>-setup.exe` | per-user, no UAC: `qm` on `PATH`, tray in the Start menu | attached to the release |
|
|
269
420
|
| **scoop** | `scoop install quartermaster` | the portable zip, no installer | the tag, automatically |
|
|
270
|
-
| **winget** | `winget install Legios.Quartermaster` | the installer, declaring Node as a dependency | the tag opens the PR |
|
|
271
421
|
| **AUR** | `yay -S quartermaster` | `PKGBUILD`, with a real `nodejs>=22.6` | the tag, automatically |
|
|
272
422
|
| **Nix** | `nix run github:legiosai/quartermaster` | the flake, with its own Node in the closure | nothing to publish |
|
|
273
423
|
| **GNOME Extensions** | from the Extensions app | the Shell extension | **by hand** — no upload API |
|
package/bin/qm
CHANGED
|
@@ -116,14 +116,18 @@ if [ -f "$RAIZ/dist/cli/qm.js" ]; then
|
|
|
116
116
|
# bandera ya mergeada en main, porque el dist/ del disco era de diez horas
|
|
117
117
|
# antes.
|
|
118
118
|
#
|
|
119
|
-
#
|
|
120
|
-
#
|
|
121
|
-
#
|
|
122
|
-
#
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
119
|
+
# Avisar no alcanzó. El 2026-11-01 `npm test` dio dos rojos falsos por esto
|
|
120
|
+
# —los tests corren este lanzador y el dist/ era de cinco semanas antes— y
|
|
121
|
+
# el aviso salía por un stderr que nadie lee dentro de un test. Así que ahora
|
|
122
|
+
# se corre el src/: si algún .ts es más nuevo que el dist/, el dist/ es de una
|
|
123
|
+
# corrida anterior y no describe lo que está escrito.
|
|
124
|
+
#
|
|
125
|
+
# Sólo pasa en un clone. El tarball de npm no lleva src/cli, y brew y el .deb
|
|
126
|
+
# no llevan dist/: en ninguno de los tres hay dos versiones que comparar.
|
|
127
|
+
if [ -f "$RAIZ/src/cli/qm.ts" ] && \
|
|
128
|
+
[ -n "$(find "$RAIZ/src" -name '*.ts' -newer "$RAIZ/dist/cli/qm.js" 2>/dev/null | head -n 1)" ]; then
|
|
129
|
+
echo "qm: dist/ es más viejo que src/: corro src/. \`npm run construir\` lo pone al día." >&2
|
|
130
|
+
exec "$NODO" $SIN_EXPERIMENTAL "$RAIZ/src/cli/qm.ts" "$@"
|
|
127
131
|
fi
|
|
128
132
|
exec "$NODO" $SIN_EXPERIMENTAL "$RAIZ/dist/cli/qm.js" "$@"
|
|
129
133
|
fi
|
package/bin/qm-barra.swift
CHANGED
|
@@ -237,8 +237,19 @@ struct Ventana {
|
|
|
237
237
|
let grupo: String?
|
|
238
238
|
/// Lo decide qm, no acá.
|
|
239
239
|
let preocupa: Bool
|
|
240
|
+
/// Cuándo se leyó ESTA barra, sólo cuando es de una lectura más vieja que
|
|
241
|
+
/// la cuenta: desde `qm --statusline` la sesión y la semanal pueden ser de
|
|
242
|
+
/// recién y el resto de la última lectura del endpoint. nil = la de la
|
|
243
|
+
/// cuenta. Con valor por defecto para que el `Lider` no tenga que pasarlo.
|
|
244
|
+
var medidoEn: Date? = nil
|
|
240
245
|
|
|
241
246
|
var nombre: String { alcance == nil ? clave : "\(clave) (\(alcance!))" }
|
|
247
|
+
|
|
248
|
+
/// Los segundos desde que se leyó esta barra: la suya si la trae, la de la
|
|
249
|
+
/// cuenta si no.
|
|
250
|
+
func edad(_ deLaCuenta: Int?) -> Int? {
|
|
251
|
+
medidoEn.map { max(0, Int(-$0.timeIntervalSinceNow)) } ?? deLaCuenta
|
|
252
|
+
}
|
|
242
253
|
}
|
|
243
254
|
|
|
244
255
|
struct Proyeccion {
|
|
@@ -460,7 +471,8 @@ func leer() -> Lectura {
|
|
|
460
471
|
activa: v["activa"] as? Bool ?? false,
|
|
461
472
|
reinicia: fecha(v["reinicia"]),
|
|
462
473
|
grupo: v["grupo"] as? String,
|
|
463
|
-
preocupa: v["preocupa"] as? Bool ?? false
|
|
474
|
+
preocupa: v["preocupa"] as? Bool ?? false,
|
|
475
|
+
medidoEn: fecha(v["medidoEn"]))
|
|
464
476
|
}
|
|
465
477
|
let mostrar = (cuota["mostrar"] as? [[String: Any]] ?? []).map(aVentana)
|
|
466
478
|
let historia: [(t: Double, pct: Int)] = (cuota["historia"] as? [[String: Any]] ?? []).compactMap {
|
|
@@ -501,7 +513,8 @@ func leer() -> Lectura {
|
|
|
501
513
|
nombre: p["perfil"] as? String ?? "?",
|
|
502
514
|
directorio: p["directorio"] as? String ?? "",
|
|
503
515
|
cuenta: p["cuenta"] as? String,
|
|
504
|
-
|
|
516
|
+
// planNombre es el que se dibuja; `plan` queda para un qm anterior.
|
|
517
|
+
plan: (p["planNombre"] as? String) ?? (p["plan"] as? String),
|
|
505
518
|
credencial: p["credencial"] as? String ?? "?",
|
|
506
519
|
hayNumero: hayNumero,
|
|
507
520
|
frase: cuota["frase"] as? String,
|
|
@@ -536,6 +549,12 @@ func leer() -> Lectura {
|
|
|
536
549
|
// ── avisos ───────────────────────────────────────────────────────────────
|
|
537
550
|
/// Sin bundle no hay UNUserNotificationCenter, y osascript sí anda: es la vía
|
|
538
551
|
// que no obliga a empaquetar una .app para decir una frase.
|
|
552
|
+
//
|
|
553
|
+
// Se va sola, como en GNOME y Windows (AVISO_MS de bin/qm-indicator): macOS lo
|
|
554
|
+
// muestra como el banner temporal de Script Editor, unos 5 s, y lo deja en el
|
|
555
|
+
// centro de notificaciones. No hay urgencia que lo clave. Si se queda en
|
|
556
|
+
// pantalla es porque el estilo de Script Editor está en «Persistente» o
|
|
557
|
+
// «Alertas» en Ajustes › Notificaciones; sin bundle no hay API para cerrarlo.
|
|
539
558
|
func notificar(titulo: String, cuerpo: String) {
|
|
540
559
|
let limpio: (String) -> String = { $0.replacingOccurrences(of: "\"", with: "'") }
|
|
541
560
|
let p = Process()
|
|
@@ -673,7 +692,12 @@ final class VistaCuenta: NSView {
|
|
|
673
692
|
let chocas = p.proyeccion?.chocas ?? false
|
|
674
693
|
self.barras = p.hayNumero ? visibles.map { v in
|
|
675
694
|
var pie = v.reinicia.map { "reinicia en \(duracion(Int($0.timeIntervalSinceNow)))" } ?? ""
|
|
676
|
-
|
|
695
|
+
// Una barra de una lectura más vieja que la cuenta dice la suya,
|
|
696
|
+
// sea o no la que frena: es la de bin/qm-indicator, pie_de_barra().
|
|
697
|
+
if v.medidoEn != nil, let e = v.edad(nil) {
|
|
698
|
+
pie += pie.isEmpty ? "" : " · "
|
|
699
|
+
pie += "leída hace \(duracion(e))" + (e >= VIEJO_SEGUNDOS ? " · vieja" : "")
|
|
700
|
+
} else if let e = p.edadSegundos, v.clave == cual?.clave {
|
|
677
701
|
pie += pie.isEmpty ? "" : " · "
|
|
678
702
|
pie += "cache de hace \(duracion(e))" + (e >= VIEJO_SEGUNDOS ? " · viejo" : "")
|
|
679
703
|
}
|
|
@@ -1218,7 +1242,11 @@ final class Barra: NSObject, NSApplicationDelegate {
|
|
|
1218
1242
|
menu.addItem(.separator())
|
|
1219
1243
|
|
|
1220
1244
|
if p.hayNumero, let cual = p.frena {
|
|
1221
|
-
|
|
1245
|
+
// La edad de lo que se DIBUJA —la sesión y la semanal—, no la
|
|
1246
|
+
// de la cuenta: con la statusline encima, la cuenta puede ser
|
|
1247
|
+
// de recién y una de las dos venir de una lectura de ayer.
|
|
1248
|
+
let viejo = [p.sesion, p.semanal].compactMap { $0?.edad(p.edadSegundos) }
|
|
1249
|
+
.max().map { $0 >= VIEJO_SEGUNDOS } ?? ((p.edadSegundos ?? 0) >= VIEJO_SEGUNDOS)
|
|
1222
1250
|
// El `!` no es sólo severidad: también avisa que a este
|
|
1223
1251
|
// ritmo tocás el techo ANTES del reinicio.
|
|
1224
1252
|
let chocas = p.proyeccion?.chocas ?? false
|
package/bin/qm-indicator
CHANGED
|
@@ -117,6 +117,15 @@ ICONO_OK = "utilities-system-monitor-symbolic"
|
|
|
117
117
|
ICONO_AVISO = "dialog-warning-symbolic"
|
|
118
118
|
ICONO_GRAVE = "dialog-error-symbolic"
|
|
119
119
|
|
|
120
|
+
# Cuánto queda un aviso en pantalla. Todos se van solos, también el grave: la
|
|
121
|
+
# urgencia `critical` hace que GNOME lo deje clavado hasta que lo cerrás, y un
|
|
122
|
+
# aviso de cuota que tapa la esquina de la pantalla durante horas se termina
|
|
123
|
+
# cerrando sin leer. Lo grave se distingue por el ícono, no por quedarse. GNOME
|
|
124
|
+
# usa su propio tiempo para los normales (unos 4 s, y espera a que vuelvas si
|
|
125
|
+
# no estás tocando nada); KDE, dunst y mako respetan este. Queda en la lista de
|
|
126
|
+
# notificaciones igual.
|
|
127
|
+
AVISO_MS = 8_000
|
|
128
|
+
|
|
120
129
|
|
|
121
130
|
_ULTIMO_SELLO = 0
|
|
122
131
|
|
|
@@ -414,6 +423,36 @@ def cada_cuanto(historia: list) -> float | None:
|
|
|
414
423
|
return huecos[len(huecos) // 2] / 1000
|
|
415
424
|
|
|
416
425
|
|
|
426
|
+
def edad_de(v: dict | None, cuota: dict) -> int | None:
|
|
427
|
+
"""Los segundos desde que se leyó ESTA barra.
|
|
428
|
+
|
|
429
|
+
Desde `qm --statusline` una cuenta puede mezclar lecturas: la sesión y la
|
|
430
|
+
semanal recién llegadas por la statusline, y el resto de las barras de la
|
|
431
|
+
última lectura del endpoint. La barra que viene de una lectura más vieja
|
|
432
|
+
trae su propio `medidoEn`; las demás son de cuando dice la cuenta.
|
|
433
|
+
"""
|
|
434
|
+
if v and v.get("medidoEn"):
|
|
435
|
+
s = faltan(v["medidoEn"])
|
|
436
|
+
if s is not None:
|
|
437
|
+
return max(0, -s)
|
|
438
|
+
return cuota.get("edadSegundos")
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
def pie_de_barra(v: dict) -> str:
|
|
442
|
+
"""«reinicia en 3d7h · leída hace 24m». La edad sólo va cuando la barra
|
|
443
|
+
tiene la suya: si es de cuando dice la cuenta, ya la dice el renglón de
|
|
444
|
+
lecturas, y repetirla en cada barra es ruido."""
|
|
445
|
+
pie = reinicio(faltan(v.get("reinicia")))
|
|
446
|
+
if not v.get("medidoEn"):
|
|
447
|
+
return pie
|
|
448
|
+
s = faltan(v["medidoEn"])
|
|
449
|
+
if s is None:
|
|
450
|
+
return pie
|
|
451
|
+
e = max(0, -s)
|
|
452
|
+
edad = f"leída hace {duracion(e)}" + (" · vieja" if e >= VIEJO_SEGUNDOS else "")
|
|
453
|
+
return f"{pie} · {edad}" if pie else edad
|
|
454
|
+
|
|
455
|
+
|
|
417
456
|
def reinicio(segundos: int | None) -> str:
|
|
418
457
|
"""«reinicia en vencido» no es castellano. Cuando ya pasó, se dice que pasó."""
|
|
419
458
|
if segundos is None:
|
|
@@ -670,7 +709,8 @@ class VistaCuenta:
|
|
|
670
709
|
self.producto = p.get("producto") or "claude"
|
|
671
710
|
self.indice_color = indice_color
|
|
672
711
|
self.titulo = corto(p.get("perfil") or "?")
|
|
673
|
-
|
|
712
|
+
# planNombre es el que se dibuja; `plan` queda para un qm anterior.
|
|
713
|
+
partes = [x for x in (p.get("cuenta"), p.get("planNombre") or p.get("plan")) if x]
|
|
674
714
|
self.sub = " · ".join(partes)
|
|
675
715
|
self.hay_numero = cuota.get("estado") == "ok"
|
|
676
716
|
self.frase = None if self.hay_numero else (cuota.get("frase") or "sin cuota")
|
|
@@ -688,7 +728,7 @@ class VistaCuenta:
|
|
|
688
728
|
|
|
689
729
|
self.barras = []
|
|
690
730
|
for v in (cuota.get("mostrar") or []) if self.hay_numero else []:
|
|
691
|
-
pie =
|
|
731
|
+
pie = pie_de_barra(v)
|
|
692
732
|
es_la_que_frena = bool(frena and v.get("clave") == frena.get("clave"))
|
|
693
733
|
self.barras.append({
|
|
694
734
|
"nombre": nombre_ventana(v),
|
|
@@ -958,9 +998,14 @@ class VistaResumen:
|
|
|
958
998
|
héroe del tablero —qué me frena primero, en toda la máquina— y que si no
|
|
959
999
|
está acá hay que sacarla comparando las cuentas a ojo."""
|
|
960
1000
|
|
|
961
|
-
def __init__(self, cuenta: str, barra: str, pct: float, nivel: str, reinicia
|
|
1001
|
+
def __init__(self, cuenta: str, barra: str, pct: float, nivel: str, reinicia,
|
|
1002
|
+
medido_en: str | None = None) -> None:
|
|
962
1003
|
self.cuenta, self.barra, self.pct = cuenta, barra, pct
|
|
963
1004
|
self.nivel, self.reinicia = nivel, reinicia
|
|
1005
|
+
# La edad propia de la barra que encabeza, si es de una lectura más
|
|
1006
|
+
# vieja que su cuenta. Suele serlo: la statusline refresca la sesión y la
|
|
1007
|
+
# semanal, y lo que frena puede ser una barra que sólo trae el endpoint.
|
|
1008
|
+
self.medido_en = medido_en
|
|
964
1009
|
|
|
965
1010
|
@staticmethod
|
|
966
1011
|
def desde(datos: dict) -> "VistaResumen | None":
|
|
@@ -991,7 +1036,7 @@ class VistaResumen:
|
|
|
991
1036
|
nombre = p.get("perfil") or lider.get("perfil") or "?"
|
|
992
1037
|
return VistaResumen(corto(nombre), nombre_ventana(v), v["porcentaje"],
|
|
993
1038
|
nivel_de(v["porcentaje"], v.get("preocupa", False) or choca),
|
|
994
|
-
v.get("reinicia"))
|
|
1039
|
+
v.get("reinicia"), v.get("medidoEn"))
|
|
995
1040
|
|
|
996
1041
|
def pintar(self, cr, pluma: Pluma, arriba: float) -> float:
|
|
997
1042
|
color = TEMA.nivel(self.nivel)
|
|
@@ -1036,6 +1081,9 @@ class VistaResumen:
|
|
|
1036
1081
|
texto, urgente = f"libre en {duracion(seg)}", True
|
|
1037
1082
|
else:
|
|
1038
1083
|
texto, urgente = reinicio(seg), False
|
|
1084
|
+
edad = faltan(self.medido_en)
|
|
1085
|
+
if edad is not None:
|
|
1086
|
+
texto += f" · leída hace {duracion(max(0, -edad))}"
|
|
1039
1087
|
pluma.escribir(x, arriba + 54, texto, 11, color if urgente else TEMA.terciario,
|
|
1040
1088
|
Pango.Weight.MEDIUM if urgente else Pango.Weight.NORMAL,
|
|
1041
1089
|
ancho=ANCHO_PANEL - MARGEN - x, elipsis=True)
|
|
@@ -1140,7 +1188,10 @@ def piezas_de(datos, avisar=None) -> list[dict]:
|
|
|
1140
1188
|
# cuenta al 2 % que está quieta de una al 2 % que estás gastando
|
|
1141
1189
|
# ahora mismo: el número de la segunda se mueve, el de la primera no.
|
|
1142
1190
|
"ultimo_uso": p.get("ultimoUso"),
|
|
1143
|
-
|
|
1191
|
+
# La edad de la barra que se DIBUJA, no la de la cuenta: con la
|
|
1192
|
+
# statusline encima, la cuenta puede ser de recién y la ventana
|
|
1193
|
+
# corta venir de una lectura de ayer.
|
|
1194
|
+
"viejo": (edad_de(corta, cuota) or 0) >= VIEJO_SEGUNDOS,
|
|
1144
1195
|
})
|
|
1145
1196
|
if avisar is not None and not dormida:
|
|
1146
1197
|
# Todas las barras, no sólo la que frena: la semanal puede estar
|
|
@@ -1681,8 +1732,9 @@ class Avisos:
|
|
|
1681
1732
|
titulo,
|
|
1682
1733
|
cuerpo,
|
|
1683
1734
|
[],
|
|
1684
|
-
|
|
1685
|
-
|
|
1735
|
+
# 1 = normal, nunca 2: ver AVISO_MS.
|
|
1736
|
+
{"urgency": GLib.Variant("y", 1)},
|
|
1737
|
+
AVISO_MS,
|
|
1686
1738
|
),
|
|
1687
1739
|
),
|
|
1688
1740
|
GLib.VariantType("(u)"),
|
package/bin/qm-tray.ps1
CHANGED
|
@@ -490,6 +490,36 @@ function Reinicio($segundos) {
|
|
|
490
490
|
return "reinicia en $(Dur $segundos)"
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
+
function EdadDe($v, $cuota) {
|
|
494
|
+
# Los segundos desde que se leyó ESTA barra: la suya si la trae, la de la
|
|
495
|
+
# cuenta si no. Desde `qm --statusline` una cuenta puede mezclar lecturas —la
|
|
496
|
+
# sesión y la semanal recién llegadas, el resto de la última lectura del
|
|
497
|
+
# endpoint— y la barra que viene de la más vieja trae su propio `medidoEn`.
|
|
498
|
+
# Es edad_de() de bin/qm-indicator. Se pregunta por la propiedad antes de
|
|
499
|
+
# leerla: StrictMode revienta con un qm anterior que no la manda.
|
|
500
|
+
if ($null -ne $v -and $v.PSObject.Properties['medidoEn'] -and $v.medidoEn) {
|
|
501
|
+
$f = Faltan $v.medidoEn
|
|
502
|
+
if ($null -ne $f) { return [int][math]::Max(0, -$f) }
|
|
503
|
+
}
|
|
504
|
+
if ($cuota.PSObject.Properties['edadSegundos']) { return $cuota.edadSegundos }
|
|
505
|
+
return $null
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function PieBarra($v) {
|
|
509
|
+
# «reinicia en 3d7h · leída hace 24m». Es pie_de_barra() de
|
|
510
|
+
# bin/qm-indicator: la edad sólo va cuando la barra trae la suya. Si es la de
|
|
511
|
+
# la cuenta ya la dice el renglón de «lecturas», y repetirla en cada barra es
|
|
512
|
+
# ruido.
|
|
513
|
+
$pie = Reinicio (Faltan $v.reinicia)
|
|
514
|
+
if (-not ($v.PSObject.Properties['medidoEn'] -and $v.medidoEn)) { return $pie }
|
|
515
|
+
$f = Faltan $v.medidoEn
|
|
516
|
+
if ($null -eq $f) { return $pie }
|
|
517
|
+
$e = [int][math]::Max(0, -$f)
|
|
518
|
+
$edad = "leída hace $(Dur $e)" + $(if ($e -ge $VIEJO_SEGUNDOS) { ' · vieja' } else { '' })
|
|
519
|
+
if ($pie) { return "$pie · $edad" }
|
|
520
|
+
return $edad
|
|
521
|
+
}
|
|
522
|
+
|
|
493
523
|
function NombreVentana($v) {
|
|
494
524
|
if ($v.nombre) { return $v.nombre }
|
|
495
525
|
if ($v.alcance) { return "$($v.clave) ($($v.alcance))" }
|
|
@@ -740,11 +770,18 @@ function RevisarLiberada([string]$perfil, $v) {
|
|
|
740
770
|
$false
|
|
741
771
|
}
|
|
742
772
|
|
|
773
|
+
# Cuánto queda un globo en pantalla: el mismo para todos, también el grave
|
|
774
|
+
# (AVISO_MS de bin/qm-indicator). Windows 10 y 11 ignoran el número y usan el de
|
|
775
|
+
# Accesibilidad (5 s de fábrica), y después el aviso queda en el centro de
|
|
776
|
+
# notificaciones; las versiones viejas lo respetan entre 10 y 30 s. Lo grave se
|
|
777
|
+
# distingue por el ícono, no por quedarse.
|
|
778
|
+
$AVISO_MS = 8000
|
|
779
|
+
|
|
743
780
|
function SoltarGlobos {
|
|
744
781
|
if (-not $script:Ni) { $script:Globos = @(); return }
|
|
745
782
|
foreach ($gl in @($script:Globos)) {
|
|
746
783
|
$ico = if ($gl.urgente) { [System.Windows.Forms.ToolTipIcon]::Error } else { [System.Windows.Forms.ToolTipIcon]::Warning }
|
|
747
|
-
try { $script:Ni.ShowBalloonTip(
|
|
784
|
+
try { $script:Ni.ShowBalloonTip($AVISO_MS, $gl.titulo, $gl.cuerpo, $ico) } catch { }
|
|
748
785
|
}
|
|
749
786
|
$script:Globos = @()
|
|
750
787
|
}
|
|
@@ -1135,7 +1172,10 @@ function DibujarPerfil($p, [int]$indice) {
|
|
|
1135
1172
|
|
|
1136
1173
|
$partes = @()
|
|
1137
1174
|
if ($p.cuenta) { $partes += $p.cuenta }
|
|
1138
|
-
|
|
1175
|
+
# planNombre es el que se dibuja; un qm anterior no lo trae, y con StrictMode
|
|
1176
|
+
# leer un campo que falta tira.
|
|
1177
|
+
if ($p.PSObject.Properties['planNombre'] -and $p.planNombre) { $partes += $p.planNombre }
|
|
1178
|
+
elseif ($p.plan) { $partes += $p.plan }
|
|
1139
1179
|
Escribir $g ($partes -join ' · ') ($m + (Px 19)) $y $script:FSub $script:Tinta3 -1 $anchoCabecera
|
|
1140
1180
|
$y += Px 22
|
|
1141
1181
|
|
|
@@ -1180,7 +1220,9 @@ function DibujarPerfil($p, [int]$indice) {
|
|
|
1180
1220
|
# 40 m» es tranquilizador si se lee cada hora y alarmante si se lee cada
|
|
1181
1221
|
# cinco minutos— y encima la repetía una vez por perfil en el renglón de
|
|
1182
1222
|
# una barra que no es la suya.
|
|
1183
|
-
|
|
1223
|
+
# Con ancho: el pie ahora puede llevar la edad propia de la barra, y un
|
|
1224
|
+
# renglón largo se recorta con «…» en vez de salirse de la tarjeta.
|
|
1225
|
+
Escribir $g (PieBarra $v) $m $y $script:FPie $script:Tinta3 -1 ($der - $m)
|
|
1184
1226
|
$y += Px 19
|
|
1185
1227
|
|
|
1186
1228
|
# La curva va pegada a la barra que frena: es de ella, no del perfil.
|
|
@@ -2403,7 +2445,10 @@ function ModeloPaneles($datos, [bool]$avisar) {
|
|
|
2403
2445
|
$peor = $cuota.frena
|
|
2404
2446
|
$proy = $p.proyeccion
|
|
2405
2447
|
$chocas = [bool]($proy -and $proy.estado -eq 'sube' -and $proy.chocasAntesDelReinicio)
|
|
2406
|
-
|
|
2448
|
+
# El «~» va pegado al número de la sesión, así que es la edad de la sesión
|
|
2449
|
+
# y no la de la cuenta: con la statusline encima, la cuenta puede ser de
|
|
2450
|
+
# recién y la sesión venir de una lectura de ayer.
|
|
2451
|
+
$viejo = if ((EdadDe $cuota.sesion $cuota) -gt $VIEJO_SEGUNDOS) { '~' } else { '' }
|
|
2407
2452
|
|
|
2408
2453
|
# El medidor es la ventana CORTA, que es la que frena ahora: la sesión o, si
|
|
2409
2454
|
# el plan no tiene —Codex Pro, medido el 2026-09-27: `sesion: null` y sólo
|
package/bin/qm.cmd
CHANGED
|
@@ -39,10 +39,14 @@ rem -- dist\ si esta, src\ si no ------------------------------------------
|
|
|
39
39
|
rem No es una optimizacion: Node se NIEGA a hacer type stripping de archivos
|
|
40
40
|
rem bajo node_modules, y un `npm install -g` deja el paquete justo ahi. Solo el
|
|
41
41
|
rem tarball de npm lleva dist\; un clone y el instalador leen el TypeScript.
|
|
42
|
+
rem El aviso de SQLite experimental no es de qm ni para quien lo corre: bin/qm
|
|
43
|
+
rem lo apaga igual. Antes no se veia porque qm salia antes de que Node lo
|
|
44
|
+
rem escribiera (en Windows un pipe es asincronico); desde que qm espera a
|
|
45
|
+
rem vaciar stdout y stderr, llega, y PowerShell lo toma como un error.
|
|
42
46
|
if exist "%RAIZ%\dist\cli\qm.js" (
|
|
43
|
-
"%NODO%" "%RAIZ%\dist\cli\qm.js" %*
|
|
47
|
+
"%NODO%" --disable-warning=ExperimentalWarning "%RAIZ%\dist\cli\qm.js" %*
|
|
44
48
|
) else (
|
|
45
|
-
"%NODO%" "%RAIZ%\src\cli\qm.ts" %*
|
|
49
|
+
"%NODO%" --disable-warning=ExperimentalWarning "%RAIZ%\src\cli\qm.ts" %*
|
|
46
50
|
)
|
|
47
51
|
set "CODIGO=%ERRORLEVEL%"
|
|
48
52
|
|
package/bin/qm.mjs
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
// el Node viejo que justamente lo obliga a delegar.
|
|
25
25
|
|
|
26
26
|
import { spawnSync } from 'node:child_process';
|
|
27
|
-
import { existsSync } from 'node:fs';
|
|
27
|
+
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
28
28
|
import { dirname, join } from 'node:path';
|
|
29
29
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
30
30
|
|
|
@@ -42,7 +42,28 @@ function sirveEsteNode() {
|
|
|
42
42
|
const compilado = join(RAIZ, 'dist', 'cli', 'qm.js');
|
|
43
43
|
const fuente = join(RAIZ, 'src', 'cli', 'qm.ts');
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Algún .ts de src/ es más nuevo que el dist/: el dist/ es de una corrida
|
|
47
|
+
* anterior y no describe lo que está escrito. Sólo puede pasar en un clone
|
|
48
|
+
* (un `npm link`, por ejemplo): el tarball no lleva src/cli. En ese caso se
|
|
49
|
+
* delega al lanzador, que corre el src/ — misma regla que bin/qm.
|
|
50
|
+
*/
|
|
51
|
+
function distViejo() {
|
|
52
|
+
if (!existsSync(fuente)) return false;
|
|
53
|
+
const limite = statSync(compilado).mtimeMs;
|
|
54
|
+
const pila = [join(RAIZ, 'src')];
|
|
55
|
+
while (pila.length > 0) {
|
|
56
|
+
const dir = pila.pop();
|
|
57
|
+
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
|
58
|
+
const ruta = join(dir, e.name);
|
|
59
|
+
if (e.isDirectory()) pila.push(ruta);
|
|
60
|
+
else if (e.name.endsWith('.ts') && statSync(ruta).mtimeMs > limite) return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (sirveEsteNode() && existsSync(compilado) && !distViejo()) {
|
|
46
67
|
// `src/adapters/opencode.ts` usa node:sqlite, que es experimental, así que
|
|
47
68
|
// Node escribe dos renglones en stderr en cada corrida:
|
|
48
69
|
//
|
|
@@ -38,6 +38,7 @@ import { DatabaseSync } from 'node:sqlite';
|
|
|
38
38
|
import { homedir } from 'node:os';
|
|
39
39
|
import { join } from 'node:path';
|
|
40
40
|
import { CONSUMO_VACIO } from "../core/tipos.js";
|
|
41
|
+
import { tr } from "../core/idioma.js";
|
|
41
42
|
export const DIRECTORIO_GEMINI = join(homedir(), '.gemini');
|
|
42
43
|
export const DIRECTORIO_ANTIGRAVITY = join(DIRECTORIO_GEMINI, 'antigravity');
|
|
43
44
|
/** El `state.vscdb` del IDE, que es un fork de VS Code y guarda donde ellos. */
|
|
@@ -109,7 +110,7 @@ export function estadoCredencialAntigravity(dirGemini = DIRECTORIO_GEMINI) {
|
|
|
109
110
|
ubicacion,
|
|
110
111
|
expiraEn: null,
|
|
111
112
|
vencida: false,
|
|
112
|
-
error: e instanceof Error ? e.message : 'credencial ilegible',
|
|
113
|
+
error: e instanceof Error ? e.message : tr('credencial ilegible', 'unreadable credential'),
|
|
113
114
|
};
|
|
114
115
|
}
|
|
115
116
|
}
|