agy-insights 0.7.0 → 0.7.1
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.es.md +2 -2
- package/README.md +2 -2
- package/docs/how-it-works.md +4 -0
- package/lib/history.js +27 -4
- package/lib/i18n.js +2 -0
- package/lib/map.js +7 -6
- package/package.json +1 -1
package/README.es.md
CHANGED
|
@@ -36,7 +36,7 @@ npx agy-insights
|
|
|
36
36
|
npx agy-insights@latest --text
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
`@latest` hace que npx compruebe cada vez si hay una versión nueva. Sin él, una copia instalada globalmente (`npm install -g`) o en el proyecto actual tiene prioridad y no se actualiza nunca. Para fijar una versión concreta: `npx agy-insights@0.7.
|
|
39
|
+
`@latest` hace que npx compruebe cada vez si hay una versión nueva. Sin él, una copia instalada globalmente (`npm install -g`) o en el proyecto actual tiene prioridad y no se actualiza nunca. Para fijar una versión concreta: `npx agy-insights@0.7.1`.
|
|
40
40
|
|
|
41
41
|
**Instalándolo globalmente:**
|
|
42
42
|
|
|
@@ -87,7 +87,7 @@ Arriba están el selector de periodo y los totales. Después, una gráfica de **
|
|
|
87
87
|
| Hallazgo | Qué significa | Qué hacer |
|
|
88
88
|
|---|---|---|
|
|
89
89
|
| El agente vuelve a leer lo que ya tenía | Lee otra vez un trozo de fichero que ya estaba en la conversación | Sesiones más cortas, una por tarea, o `/compact`. No excluyas el fichero: lo necesita. |
|
|
90
|
-
| Ficheros generados, compilados o de dependencias | Lecturas de `bin/`, `obj/`, `dist/`, `node_modules`, migraciones, lockfiles o logs | Si no hacían falta, exclúyelos (ver abajo) |
|
|
90
|
+
| Ficheros generados, compilados o de dependencias | Lecturas de `bin/`, `obj/`, `dist/`, `node_modules`, migraciones, lockfiles o logs (nunca cuentan los ficheros propios de Antigravity en `~/.gemini`, como su brain, ni una carpeta `build/` o `bin/` que git mantiene en el repo, como una configuración de webpack) | Si no hacían falta, exclúyelos (ver abajo) |
|
|
91
91
|
| Los mismos ficheros entran en muchas sesiones | Un fichero se lee en varias conversaciones distintas | Si es código central es normal; si es grande, dile al agente qué parte mirar |
|
|
92
92
|
| Comandos con salidas muy largas | La salida de tests o builds entra entera | Pide ejecutar solo el test o proyecto afectado |
|
|
93
93
|
| Sesiones muy largas | Todo lo acumulado se reenvía en cada turno | Una conversación nueva por tarea |
|
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ npx agy-insights
|
|
|
36
36
|
npx agy-insights@latest --text
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
`@latest` makes npx check for the newest version every time. Without it, a copy installed globally (`npm install -g`) or in the current project takes precedence and is never updated. To pin a version instead: `npx agy-insights@0.7.
|
|
39
|
+
`@latest` makes npx check for the newest version every time. Without it, a copy installed globally (`npm install -g`) or in the current project takes precedence and is never updated. To pin a version instead: `npx agy-insights@0.7.1`.
|
|
40
40
|
|
|
41
41
|
**Globally:**
|
|
42
42
|
|
|
@@ -87,7 +87,7 @@ At the top, the period selector and the totals. Then a chart of **token usage pe
|
|
|
87
87
|
| Finding | What it means | What to do |
|
|
88
88
|
|---|---|---|
|
|
89
89
|
| The agent re-reads what it already had | It reads again a chunk of a file that was already in the conversation | Shorter sessions, one per task, or `/compact`. Don't exclude the file: the agent needs it. |
|
|
90
|
-
| Generated, build or dependency files are being read | Reads from `bin/`, `obj/`, `dist/`, `node_modules`, migrations, lockfiles or logs | If they weren't needed, exclude them (see below) |
|
|
90
|
+
| Generated, build or dependency files are being read | Reads from `bin/`, `obj/`, `dist/`, `node_modules`, migrations, lockfiles or logs (Antigravity's own files in `~/.gemini`, such as its brain, never count; nor does a `build/` or `bin/` folder that git keeps in the repo, like a webpack config) | If they weren't needed, exclude them (see below) |
|
|
91
91
|
| The same files enter many sessions | A file is read in several different conversations | Normal for core code; if it is large, tell the agent which part to look at |
|
|
92
92
|
| Commands with very long output | The full output of tests or builds enters the context | Ask it to run only the affected test or project |
|
|
93
93
|
| Very long sessions | Everything accumulated is resent on every turn | A new conversation per task |
|
package/docs/how-it-works.md
CHANGED
|
@@ -58,6 +58,10 @@ The project of each file is detected by walking up its path until a folder with
|
|
|
58
58
|
|
|
59
59
|
All user-facing text lives in `lib/i18n.js`, in an `en` and an `es` table with the same keys (a test checks it). Modules read it through `t`, which always points at the current language. The language comes from `--lang`, then the `lang` config key, then the system locale (`LC_ALL`, `LC_MESSAGES`, `LANG`, `LANGUAGE`, or `Intl`): Spanish if it starts with `es`, English otherwise. Numbers follow it too (`en-US` / `es-ES`).
|
|
60
60
|
|
|
61
|
+
Folder names alone are not enough for build output: `build/webpack/` or `bin/` often hold sources. When the file's repo is on this machine, `repoFiles()` asks git for the files it does not ignore (`git ls-files --cached --others --exclude-standard`, once per repo), and a file in that list is never kind `build`. `--map` does the same, since it lists files through git. Without git, or for a repo that is not on this machine, the folder name decides.
|
|
62
|
+
|
|
63
|
+
Anything under `~/.gemini/` is kind `agent`: the agent's own brain (plans, artifacts, its logs) and skills. It is checked first and is not in `NON_SOURCE`, so those reads are never reported as generated files or proposed for exclusion, even when a path contains `out/` or ends in `.log`.
|
|
64
|
+
|
|
61
65
|
Built-in file kinds are stable ids (`build`, `logs`, `generated`, `code .cs`…) and are only turned into text when shown, with `kindLabel()`. Kinds from `customKinds` are shown as the user wrote them.
|
|
62
66
|
|
|
63
67
|
To add a message, add it to both tables. To add a language, add a table and teach `detect()` to pick it.
|
package/lib/history.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const os = require('os');
|
|
7
7
|
const path = require('path');
|
|
8
|
+
const { spawnSync } = require('child_process');
|
|
8
9
|
|
|
9
10
|
const DEFAULT_DIR = path.join(os.homedir(), '.gemini', 'antigravity-cli', 'conversations');
|
|
10
11
|
const BYTES_PER_TOKEN = 4;
|
|
@@ -125,9 +126,18 @@ const key = (p) => norm(p).toLowerCase().replace(/\/+$/, '');
|
|
|
125
126
|
// Kinds are stable ids; i18n.kindLabel() turns them into text.
|
|
126
127
|
const NON_SOURCE = new Set(['node_modules', 'build', 'lockfiles', 'logs', 'generated']);
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
/**
|
|
130
|
+
* @param {string} p path with "/" separators
|
|
131
|
+
* @param {object} [opts]
|
|
132
|
+
* @param {boolean} [opts.inRepo] git says the file is part of the repo (not ignored): a build/ or bin/
|
|
133
|
+
* folder then holds sources (webpack config, CLI scripts), not build output.
|
|
134
|
+
*/
|
|
135
|
+
function kind(p, { inRepo = false } = {}) {
|
|
136
|
+
// Antigravity's own data (the agent's brain: plans, artifacts, logs; and skills): it needs them, so they
|
|
137
|
+
// are never reported as generated or proposed for exclusion, whatever their names look like.
|
|
138
|
+
if (/(^|\/)\.gemini\//i.test(p)) return 'agent';
|
|
129
139
|
if (/(^|\/)node_modules\//.test(p)) return 'node_modules';
|
|
130
|
-
if (/(^|\/)(dist|build|out|target|coverage|\.next|bin|obj)\//i.test(p)) return 'build';
|
|
140
|
+
if (!inRepo && /(^|\/)(dist|build|out|target|coverage|\.next|bin|obj)\//i.test(p)) return 'build';
|
|
131
141
|
if (/(package-lock\.json|yarn\.lock|pnpm-lock\.yaml|packages\.lock\.json|\.lock)$/.test(p)) return 'lockfiles';
|
|
132
142
|
if (/\.(log|map)$|\.min\.(js|css)$/.test(p)) return 'logs';
|
|
133
143
|
if (/(^|\/)(tests?|__tests__|specs?)\//i.test(p) || /\.(test|spec|tests?)\.\w+$/i.test(p) || /Tests?\//.test(p)) return 'tests';
|
|
@@ -136,6 +146,17 @@ function kind(p) {
|
|
|
136
146
|
return ext ? `code ${ext}` : 'other';
|
|
137
147
|
}
|
|
138
148
|
|
|
149
|
+
// Files of a git repo that git does not ignore (tracked, or untracked and not ignored), lowercased and
|
|
150
|
+
// relative to the root; null when git cannot tell (no git, or the repo is not on this machine).
|
|
151
|
+
const repoFilesCache = new Map();
|
|
152
|
+
function repoFiles(root) {
|
|
153
|
+
if (!repoFilesCache.has(root)) {
|
|
154
|
+
const git = spawnSync('git', ['ls-files', '--cached', '--others', '--exclude-standard', '-z'], { cwd: root, encoding: 'utf8', maxBuffer: 1 << 28, windowsHide: true });
|
|
155
|
+
repoFilesCache.set(root, git.status === 0 ? new Set(git.stdout.split('\0').filter(Boolean).map((f) => f.toLowerCase())) : null);
|
|
156
|
+
}
|
|
157
|
+
return repoFilesCache.get(root);
|
|
158
|
+
}
|
|
159
|
+
|
|
139
160
|
// Project root of a file: an explicit workspace containing it, or else the nearest folder with a .git
|
|
140
161
|
// entry, when the path exists on this machine. Null when unknown (e.g. a repo that was deleted).
|
|
141
162
|
const rootCache = new Map();
|
|
@@ -229,7 +250,9 @@ class Counter {
|
|
|
229
250
|
*/
|
|
230
251
|
async function analyze({ dir = DEFAULT_DIR, workspaces = [], customKinds = {}, since = null } = {}) {
|
|
231
252
|
const custom = Object.entries(customKinds).map(([re, label]) => [new RegExp(re, 'i'), label]);
|
|
232
|
-
|
|
253
|
+
// A file git keeps in the repo is never build output, whatever its folder is called.
|
|
254
|
+
const classify = (p, root, rel) => custom.find(([re]) => re.test(p))?.[1]
|
|
255
|
+
|| kind(p, { inRepo: Boolean(root && repoFiles(root)?.has(rel.toLowerCase())) });
|
|
233
256
|
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'agy-insights-'));
|
|
234
257
|
const r = {
|
|
235
258
|
dir, backend: nodeSqlite ? 'node:sqlite' : 'sql.js', conversations: 0, unreadable: 0, steps: 0, tokens: 0,
|
|
@@ -303,7 +326,7 @@ async function analyze({ dir = DEFAULT_DIR, workspaces = [], customKinds = {}, s
|
|
|
303
326
|
|
|
304
327
|
// Folders and files are keyed by absolute path: several projects can share relative paths.
|
|
305
328
|
const { root, project, rel, folderRel, folderAbs } = locate(file, workspaces);
|
|
306
|
-
const k = classify(file);
|
|
329
|
+
const k = classify(file, root, rel);
|
|
307
330
|
const fields = { calls, tokens, rereads: isNew ? reread : 0, rereadTokens: reread * tokens };
|
|
308
331
|
kinds.add(k, { ...fields, convs: once(seenKinds, k) }, { nonSource: NON_SOURCE.has(k) });
|
|
309
332
|
projects.add(root || '', { ...fields, convs: once(seenProjects, root || '') }, { project });
|
package/lib/i18n.js
CHANGED
|
@@ -36,6 +36,7 @@ Options:
|
|
|
36
36
|
done: (convs, found, out) => `${plural(convs, 'conversation', 'conversations')} analyzed, ${plural(found, 'finding', 'findings')}.\nReport: ${out}`,
|
|
37
37
|
|
|
38
38
|
kinds: {
|
|
39
|
+
agent: "Antigravity's own files (brain, skills)",
|
|
39
40
|
build: 'build output (dist, bin, obj…)', logs: 'logs, maps, minified', generated: 'generated code / migrations',
|
|
40
41
|
other: 'other', code: (ext) => `code ${ext}`,
|
|
41
42
|
},
|
|
@@ -197,6 +198,7 @@ Opciones:
|
|
|
197
198
|
done: (convs, found, out) => `${plural(convs, 'conversación analizada', 'conversaciones analizadas')}, ${plural(found, 'hallazgo', 'hallazgos')}.\nInforme: ${out}`,
|
|
198
199
|
|
|
199
200
|
kinds: {
|
|
201
|
+
agent: 'ficheros propios de Antigravity (brain, skills)',
|
|
200
202
|
build: 'build output (dist, bin, obj…)', logs: 'logs, maps, minificados', generated: 'código generado / migraciones',
|
|
201
203
|
other: 'otros', code: (ext) => `código ${ext}`,
|
|
202
204
|
},
|
package/lib/map.js
CHANGED
|
@@ -15,10 +15,10 @@ const SKIP_DIRS = new Set(['.git', 'node_modules', '.vs', '.vscode', '.idea', '.
|
|
|
15
15
|
const BYTES_PER_TOKEN = 4;
|
|
16
16
|
|
|
17
17
|
// Project files relative to `root`, with "/" separators: tracked plus untracked-but-not-ignored when
|
|
18
|
-
// it is a git repo, else a plain walk.
|
|
18
|
+
// it is a git repo (`inRepo`: none of them is ignored build output), else a plain walk.
|
|
19
19
|
function listFiles(root) {
|
|
20
20
|
const git = spawnSync('git', ['ls-files', '--cached', '--others', '--exclude-standard', '-z'], { cwd: root, encoding: 'utf8', maxBuffer: 1 << 28 });
|
|
21
|
-
if (git.status === 0) return [...new Set(git.stdout.split('\0').filter(Boolean))];
|
|
21
|
+
if (git.status === 0) return { files: [...new Set(git.stdout.split('\0').filter(Boolean))], inRepo: true };
|
|
22
22
|
const out = [];
|
|
23
23
|
const walk = (rel) => {
|
|
24
24
|
for (const e of fs.readdirSync(path.join(root, rel), { withFileTypes: true })) {
|
|
@@ -27,7 +27,7 @@ function listFiles(root) {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
walk('');
|
|
30
|
-
return out;
|
|
30
|
+
return { files: out, inRepo: false };
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// Line count of a text file; null for binaries or unreadable files.
|
|
@@ -71,11 +71,12 @@ function mainFolders(files, maxFolders) {
|
|
|
71
71
|
*/
|
|
72
72
|
function buildMap(root, opts = {}) {
|
|
73
73
|
const o = { ...DEFAULTS, ...opts };
|
|
74
|
-
const all = listFiles(root);
|
|
74
|
+
const { files: all, inRepo } = listFiles(root);
|
|
75
75
|
const generated = new Set(), source = [];
|
|
76
76
|
for (const f of all) {
|
|
77
|
-
const
|
|
78
|
-
|
|
77
|
+
const nonSource = NON_SOURCE.has(kind(f, { inRepo }));
|
|
78
|
+
const g = nonSource ? generatedFolder(f) : null;
|
|
79
|
+
if (g) generated.add(g); else if (!nonSource) source.push(f);
|
|
79
80
|
}
|
|
80
81
|
const reads = new Map((o.history || []).filter((h) => h.root).map((h) => [`${h.root}/${h.rel}`.toLowerCase(), h.calls]));
|
|
81
82
|
const rootNorm = root.replace(/[\\/]+/g, '/').replace(/\/$/, '');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agy-insights",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Measures Antigravity CLI token usage and shows which context is sent repeatedly or needlessly, in English or Spanish. Run: npx agy-insights@latest",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|