agent-profiler 0.1.0 → 1.0.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/README.md +66 -0
- package/dist/cli.js +5 -4
- package/dist/commands/init.js +4 -0
- package/dist/commands/status.js +36 -9
- package/dist/core/db.js +164 -28
- package/dist/core/gitWorkspace.js +46 -5
- package/dist/core/packageMeta.js +20 -0
- package/dist/core/schema.sql +8 -0
- package/package.json +57 -3
- package/agent-profiler-0.1.0.tgz +0 -0
- package/docs/agent-profiler-mvp-handoff.md +0 -980
- package/google-home.png +0 -0
- package/src/adapters/codex.ts +0 -131
- package/src/adapters/cursor.ts +0 -115
- package/src/cli.ts +0 -109
- package/src/commands/auditContext.ts +0 -62
- package/src/commands/hook.ts +0 -104
- package/src/commands/init.ts +0 -324
- package/src/commands/last.ts +0 -326
- package/src/commands/status.ts +0 -345
- package/src/core/contextAudit.ts +0 -102
- package/src/core/db.ts +0 -491
- package/src/core/eventMetadata.ts +0 -184
- package/src/core/gitWorkspace.ts +0 -92
- package/src/core/normalize.ts +0 -29
- package/src/core/profile.ts +0 -35
- package/src/core/schema.sql +0 -56
- package/src/core/tokens.ts +0 -4
- package/src/types/better-sqlite3.d.ts +0 -26
- package/tsconfig.json +0 -15
|
@@ -1,980 +0,0 @@
|
|
|
1
|
-
# Agent Profiler MVP 0.1 Handoff
|
|
2
|
-
|
|
3
|
-
We should start with a tight MVP that proves the value in one painful developer moment:
|
|
4
|
-
|
|
5
|
-
> “What just happened in my last agent session, and what should I fix?”
|
|
6
|
-
|
|
7
|
-
## Product Name
|
|
8
|
-
|
|
9
|
-
**Agent Profiler**
|
|
10
|
-
|
|
11
|
-
## Product Positioning
|
|
12
|
-
|
|
13
|
-
Agent Profiler is a local-first observability toolkit for AI coding agents. It helps developers identify context bloat, tool noise, retry loops, oversized repo instructions, and inefficient agent usage patterns across tools like Cursor, Claude Code, Codex, and MCP workflows.
|
|
14
|
-
|
|
15
|
-
## Important Framing
|
|
16
|
-
|
|
17
|
-
Agent Profiler should not claim to measure official billing or exact provider token spend.
|
|
18
|
-
|
|
19
|
-
Use this framing:
|
|
20
|
-
|
|
21
|
-
> Agent Profiler does not replace official provider billing. It profiles observable local agent behavior so teams can improve token efficiency before costs show up in dashboards.
|
|
22
|
-
|
|
23
|
-
The goal is not billing accuracy.
|
|
24
|
-
|
|
25
|
-
The goal is:
|
|
26
|
-
|
|
27
|
-
- local observability
|
|
28
|
-
- token hygiene
|
|
29
|
-
- context footprint awareness
|
|
30
|
-
- workflow pattern detection
|
|
31
|
-
- practical remediation recommendations
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## MVP Goal
|
|
36
|
-
|
|
37
|
-
Create a local-first CLI that captures observable AI coding-agent events, stores them in SQLite, and produces a useful “last session” report.
|
|
38
|
-
|
|
39
|
-
The first major command should be:
|
|
40
|
-
|
|
41
|
-
~~~bash
|
|
42
|
-
npx agent-profiler last
|
|
43
|
-
~~~
|
|
44
|
-
|
|
45
|
-
It should answer:
|
|
46
|
-
|
|
47
|
-
~~~txt
|
|
48
|
-
What happened in my most recent agent session?
|
|
49
|
-
How much observable context/output/tool noise did it produce?
|
|
50
|
-
Were there obvious waste patterns?
|
|
51
|
-
What should I change?
|
|
52
|
-
~~~
|
|
53
|
-
|
|
54
|
-
This one report proves the product.
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## Initial Supported Environment
|
|
59
|
-
|
|
60
|
-
Start with **Cursor** first because the immediate pain point is Cursor local usage, token limits, and observable agent behavior.
|
|
61
|
-
|
|
62
|
-
However, the architecture should treat Cursor as an adapter, not as the whole product.
|
|
63
|
-
|
|
64
|
-
Design for future support of:
|
|
65
|
-
|
|
66
|
-
~~~txt
|
|
67
|
-
Cursor
|
|
68
|
-
Claude Code
|
|
69
|
-
Codex
|
|
70
|
-
Generic CLI wrappers
|
|
71
|
-
MCP tools
|
|
72
|
-
~~~
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
## Core Architecture
|
|
77
|
-
|
|
78
|
-
~~~txt
|
|
79
|
-
agent-profiler/
|
|
80
|
-
core/
|
|
81
|
-
event schema
|
|
82
|
-
SQLite store
|
|
83
|
-
token estimator
|
|
84
|
-
session analyzer
|
|
85
|
-
red flag engine
|
|
86
|
-
report generator
|
|
87
|
-
|
|
88
|
-
adapters/
|
|
89
|
-
cursor/
|
|
90
|
-
claude-code/
|
|
91
|
-
codex/
|
|
92
|
-
generic-cli/
|
|
93
|
-
|
|
94
|
-
dashboard/
|
|
95
|
-
optional Express server later
|
|
96
|
-
|
|
97
|
-
skills/
|
|
98
|
-
cursor/
|
|
99
|
-
claude-code/
|
|
100
|
-
codex/
|
|
101
|
-
shared/
|
|
102
|
-
~~~
|
|
103
|
-
|
|
104
|
-
The main architectural principle:
|
|
105
|
-
|
|
106
|
-
~~~txt
|
|
107
|
-
Each supported environment gets its own collector.
|
|
108
|
-
All collectors normalize into the same local event schema.
|
|
109
|
-
~~~
|
|
110
|
-
|
|
111
|
-
The database should not care whether an event came from Cursor, Claude Code, Codex, or another source.
|
|
112
|
-
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
## MVP Command Set
|
|
116
|
-
|
|
117
|
-
For version `0.1`, implement only the essentials.
|
|
118
|
-
|
|
119
|
-
~~~bash
|
|
120
|
-
agent-profiler init cursor
|
|
121
|
-
agent-profiler hook cursor <eventName>
|
|
122
|
-
agent-profiler status
|
|
123
|
-
agent-profiler last
|
|
124
|
-
agent-profiler audit context
|
|
125
|
-
~~~
|
|
126
|
-
|
|
127
|
-
### Command: `init cursor`
|
|
128
|
-
|
|
129
|
-
Purpose:
|
|
130
|
-
|
|
131
|
-
Create local configuration, local SQLite DB, and Cursor hook wiring.
|
|
132
|
-
|
|
133
|
-
It should create or update:
|
|
134
|
-
|
|
135
|
-
~~~txt
|
|
136
|
-
~/.agent-profiler/config.json
|
|
137
|
-
~/.agent-profiler/events.sqlite
|
|
138
|
-
.cursor/hooks.json or ~/.cursor/hooks.json
|
|
139
|
-
~~~
|
|
140
|
-
|
|
141
|
-
Cursor hook entries should call something like:
|
|
142
|
-
|
|
143
|
-
~~~bash
|
|
144
|
-
agent-profiler hook cursor beforeSubmitPrompt
|
|
145
|
-
~~~
|
|
146
|
-
|
|
147
|
-
### Command: `hook cursor <eventName>`
|
|
148
|
-
|
|
149
|
-
Purpose:
|
|
150
|
-
|
|
151
|
-
Read JSON from stdin, normalize the event, estimate observable token usage, and store it in SQLite.
|
|
152
|
-
|
|
153
|
-
The hook command should:
|
|
154
|
-
|
|
155
|
-
~~~txt
|
|
156
|
-
1. Read stdin
|
|
157
|
-
2. Parse JSON safely
|
|
158
|
-
3. Normalize through the Cursor adapter
|
|
159
|
-
4. Estimate tokens from observable text
|
|
160
|
-
5. Hash the raw payload
|
|
161
|
-
6. Insert event into SQLite
|
|
162
|
-
7. Exit cleanly so Cursor can continue
|
|
163
|
-
~~~
|
|
164
|
-
|
|
165
|
-
### Command: `status`
|
|
166
|
-
|
|
167
|
-
Purpose:
|
|
168
|
-
|
|
169
|
-
Show whether Agent Profiler is configured and receiving events.
|
|
170
|
-
|
|
171
|
-
Example output:
|
|
172
|
-
|
|
173
|
-
~~~txt
|
|
174
|
-
Agent Profiler Status
|
|
175
|
-
|
|
176
|
-
Database:
|
|
177
|
-
~/.agent-profiler/events.sqlite
|
|
178
|
-
|
|
179
|
-
Configured adapters:
|
|
180
|
-
Cursor: yes
|
|
181
|
-
|
|
182
|
-
Last event:
|
|
183
|
-
2026-05-10 19:22:41
|
|
184
|
-
source: cursor
|
|
185
|
-
event: afterAgentResponse
|
|
186
|
-
estimated tokens: 1,842
|
|
187
|
-
|
|
188
|
-
Dashboard:
|
|
189
|
-
not running
|
|
190
|
-
~~~
|
|
191
|
-
|
|
192
|
-
### Command: `last`
|
|
193
|
-
|
|
194
|
-
Purpose:
|
|
195
|
-
|
|
196
|
-
Generate a report for the most recent observed session.
|
|
197
|
-
|
|
198
|
-
This is the most important MVP command.
|
|
199
|
-
|
|
200
|
-
### Command: `audit context`
|
|
201
|
-
|
|
202
|
-
Purpose:
|
|
203
|
-
|
|
204
|
-
Scan the current repo for likely always-on agent context files and estimate their token footprint.
|
|
205
|
-
|
|
206
|
-
Files to scan initially:
|
|
207
|
-
|
|
208
|
-
~~~txt
|
|
209
|
-
AGENTS.md
|
|
210
|
-
CLAUDE.md
|
|
211
|
-
.cursorrules
|
|
212
|
-
.cursor/rules/**
|
|
213
|
-
.cursor/skills/**
|
|
214
|
-
.codex/config.toml
|
|
215
|
-
.codex/hooks.json
|
|
216
|
-
.claude/settings.json
|
|
217
|
-
.claude/commands/**
|
|
218
|
-
.claude/agents/**
|
|
219
|
-
.claude/skills/**
|
|
220
|
-
~~~
|
|
221
|
-
|
|
222
|
-
---
|
|
223
|
-
|
|
224
|
-
## Suggested Repo Structure
|
|
225
|
-
|
|
226
|
-
~~~txt
|
|
227
|
-
agent-profiler/
|
|
228
|
-
package.json
|
|
229
|
-
tsconfig.json
|
|
230
|
-
README.md
|
|
231
|
-
src/
|
|
232
|
-
cli.ts
|
|
233
|
-
|
|
234
|
-
commands/
|
|
235
|
-
init.ts
|
|
236
|
-
hook.ts
|
|
237
|
-
status.ts
|
|
238
|
-
last.ts
|
|
239
|
-
auditContext.ts
|
|
240
|
-
|
|
241
|
-
core/
|
|
242
|
-
db.ts
|
|
243
|
-
schema.sql
|
|
244
|
-
tokens.ts
|
|
245
|
-
normalize.ts
|
|
246
|
-
sessions.ts
|
|
247
|
-
redFlags.ts
|
|
248
|
-
scoring.ts
|
|
249
|
-
|
|
250
|
-
adapters/
|
|
251
|
-
cursor.ts
|
|
252
|
-
claude.ts
|
|
253
|
-
codex.ts
|
|
254
|
-
|
|
255
|
-
reporters/
|
|
256
|
-
lastSessionReport.ts
|
|
257
|
-
~~~
|
|
258
|
-
|
|
259
|
-
Keep it boring and maintainable:
|
|
260
|
-
|
|
261
|
-
~~~txt
|
|
262
|
-
TypeScript
|
|
263
|
-
Node
|
|
264
|
-
SQLite
|
|
265
|
-
Commander
|
|
266
|
-
better-sqlite3
|
|
267
|
-
~~~
|
|
268
|
-
|
|
269
|
-
---
|
|
270
|
-
|
|
271
|
-
## Initial Project Setup
|
|
272
|
-
|
|
273
|
-
From the laptop:
|
|
274
|
-
|
|
275
|
-
~~~bash
|
|
276
|
-
mkdir agent-profiler
|
|
277
|
-
cd agent-profiler
|
|
278
|
-
git init
|
|
279
|
-
npm init -y
|
|
280
|
-
npm install commander better-sqlite3
|
|
281
|
-
npm install -D typescript tsx @types/node
|
|
282
|
-
~~~
|
|
283
|
-
|
|
284
|
-
Create `tsconfig.json`:
|
|
285
|
-
|
|
286
|
-
~~~json
|
|
287
|
-
{
|
|
288
|
-
"compilerOptions": {
|
|
289
|
-
"target": "ES2022",
|
|
290
|
-
"module": "NodeNext",
|
|
291
|
-
"moduleResolution": "NodeNext",
|
|
292
|
-
"outDir": "dist",
|
|
293
|
-
"rootDir": "src",
|
|
294
|
-
"strict": true,
|
|
295
|
-
"esModuleInterop": true,
|
|
296
|
-
"forceConsistentCasingInFileNames": true,
|
|
297
|
-
"skipLibCheck": true
|
|
298
|
-
},
|
|
299
|
-
"include": ["src"]
|
|
300
|
-
}
|
|
301
|
-
~~~
|
|
302
|
-
|
|
303
|
-
Update `package.json`:
|
|
304
|
-
|
|
305
|
-
~~~json
|
|
306
|
-
{
|
|
307
|
-
"name": "agent-profiler",
|
|
308
|
-
"version": "0.1.0",
|
|
309
|
-
"description": "Local-first profiling for AI coding agents.",
|
|
310
|
-
"type": "module",
|
|
311
|
-
"bin": {
|
|
312
|
-
"agent-profiler": "./dist/cli.js"
|
|
313
|
-
},
|
|
314
|
-
"scripts": {
|
|
315
|
-
"dev": "tsx src/cli.ts",
|
|
316
|
-
"build": "tsc",
|
|
317
|
-
"start": "node dist/cli.js"
|
|
318
|
-
},
|
|
319
|
-
"dependencies": {
|
|
320
|
-
"better-sqlite3": "^11.0.0",
|
|
321
|
-
"commander": "^12.0.0"
|
|
322
|
-
},
|
|
323
|
-
"devDependencies": {
|
|
324
|
-
"@types/node": "^22.0.0",
|
|
325
|
-
"tsx": "^4.0.0",
|
|
326
|
-
"typescript": "^5.0.0"
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
~~~
|
|
330
|
-
|
|
331
|
-
---
|
|
332
|
-
|
|
333
|
-
## SQLite Schema, Version 1
|
|
334
|
-
|
|
335
|
-
Create `src/core/schema.sql`:
|
|
336
|
-
|
|
337
|
-
~~~sql
|
|
338
|
-
CREATE TABLE IF NOT EXISTS events (
|
|
339
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
340
|
-
created_at TEXT NOT NULL,
|
|
341
|
-
source TEXT NOT NULL,
|
|
342
|
-
source_event TEXT NOT NULL,
|
|
343
|
-
repo_path TEXT,
|
|
344
|
-
session_id TEXT,
|
|
345
|
-
turn_id TEXT,
|
|
346
|
-
model TEXT,
|
|
347
|
-
role TEXT NOT NULL,
|
|
348
|
-
estimated_input_tokens INTEGER DEFAULT 0,
|
|
349
|
-
estimated_output_tokens INTEGER DEFAULT 0,
|
|
350
|
-
estimated_total_tokens INTEGER DEFAULT 0,
|
|
351
|
-
payload_hash TEXT NOT NULL,
|
|
352
|
-
raw_payload TEXT NOT NULL
|
|
353
|
-
);
|
|
354
|
-
|
|
355
|
-
CREATE INDEX IF NOT EXISTS idx_events_session
|
|
356
|
-
ON events(session_id, created_at);
|
|
357
|
-
|
|
358
|
-
CREATE INDEX IF NOT EXISTS idx_events_source
|
|
359
|
-
ON events(source, created_at);
|
|
360
|
-
~~~
|
|
361
|
-
|
|
362
|
-
Do not overdesign the DB yet.
|
|
363
|
-
|
|
364
|
-
---
|
|
365
|
-
|
|
366
|
-
## Normalized Event Model
|
|
367
|
-
|
|
368
|
-
Create a shared internal shape that every adapter maps into.
|
|
369
|
-
|
|
370
|
-
~~~ts
|
|
371
|
-
export type AgentEventSource =
|
|
372
|
-
| "cursor"
|
|
373
|
-
| "claude-code"
|
|
374
|
-
| "codex"
|
|
375
|
-
| "generic";
|
|
376
|
-
|
|
377
|
-
export type AgentEventRole =
|
|
378
|
-
| "user_prompt"
|
|
379
|
-
| "assistant_output"
|
|
380
|
-
| "tool_call"
|
|
381
|
-
| "tool_result"
|
|
382
|
-
| "shell_command"
|
|
383
|
-
| "shell_output"
|
|
384
|
-
| "file_edit"
|
|
385
|
-
| "session_start"
|
|
386
|
-
| "session_stop"
|
|
387
|
-
| "unknown";
|
|
388
|
-
|
|
389
|
-
export type NormalizedAgentEvent = {
|
|
390
|
-
source: AgentEventSource;
|
|
391
|
-
sourceEvent: string;
|
|
392
|
-
repoPath?: string;
|
|
393
|
-
sessionId?: string;
|
|
394
|
-
turnId?: string;
|
|
395
|
-
model?: string;
|
|
396
|
-
role: AgentEventRole;
|
|
397
|
-
observableText: string;
|
|
398
|
-
estimatedInputTokens: number;
|
|
399
|
-
estimatedOutputTokens: number;
|
|
400
|
-
estimatedTotalTokens: number;
|
|
401
|
-
rawPayload: unknown;
|
|
402
|
-
};
|
|
403
|
-
~~~
|
|
404
|
-
|
|
405
|
-
Everything adapters do should reduce to this model.
|
|
406
|
-
|
|
407
|
-
---
|
|
408
|
-
|
|
409
|
-
## Token Estimation
|
|
410
|
-
|
|
411
|
-
Start simple.
|
|
412
|
-
|
|
413
|
-
Create `src/core/tokens.ts`:
|
|
414
|
-
|
|
415
|
-
~~~ts
|
|
416
|
-
export function estimateTokens(text: string): number {
|
|
417
|
-
if (!text) return 0;
|
|
418
|
-
return Math.max(1, Math.ceil(text.length / 4));
|
|
419
|
-
}
|
|
420
|
-
~~~
|
|
421
|
-
|
|
422
|
-
Do not block the MVP on perfect tokenization.
|
|
423
|
-
|
|
424
|
-
Later versions can add:
|
|
425
|
-
|
|
426
|
-
~~~txt
|
|
427
|
-
model-aware tokenizers
|
|
428
|
-
provider-specific estimates
|
|
429
|
-
cached-token approximations
|
|
430
|
-
tool-specific accounting
|
|
431
|
-
~~~
|
|
432
|
-
|
|
433
|
-
But version `0.1` only needs a rough observable estimate.
|
|
434
|
-
|
|
435
|
-
---
|
|
436
|
-
|
|
437
|
-
## Cursor Adapter, First Pass
|
|
438
|
-
|
|
439
|
-
Create `src/adapters/cursor.ts`.
|
|
440
|
-
|
|
441
|
-
The adapter should accept:
|
|
442
|
-
|
|
443
|
-
~~~txt
|
|
444
|
-
eventName
|
|
445
|
-
raw payload
|
|
446
|
-
~~~
|
|
447
|
-
|
|
448
|
-
And return a normalized event.
|
|
449
|
-
|
|
450
|
-
Initial mapping idea:
|
|
451
|
-
|
|
452
|
-
~~~txt
|
|
453
|
-
Cursor beforeSubmitPrompt -> user_prompt
|
|
454
|
-
Cursor afterAgentResponse -> assistant_output
|
|
455
|
-
Cursor afterShellExecution -> shell_output
|
|
456
|
-
Cursor afterFileEdit -> file_edit
|
|
457
|
-
Cursor stop -> session_stop
|
|
458
|
-
Unknown events -> unknown
|
|
459
|
-
~~~
|
|
460
|
-
|
|
461
|
-
The adapter should defensively extract observable text from common fields:
|
|
462
|
-
|
|
463
|
-
~~~txt
|
|
464
|
-
prompt
|
|
465
|
-
message
|
|
466
|
-
response
|
|
467
|
-
content
|
|
468
|
-
command
|
|
469
|
-
stdout
|
|
470
|
-
stderr
|
|
471
|
-
diff
|
|
472
|
-
filePath
|
|
473
|
-
~~~
|
|
474
|
-
|
|
475
|
-
Do not assume Cursor payloads are stable.
|
|
476
|
-
|
|
477
|
-
Write the adapter so missing fields do not crash the hook.
|
|
478
|
-
|
|
479
|
-
---
|
|
480
|
-
|
|
481
|
-
## Hook Behavior
|
|
482
|
-
|
|
483
|
-
The hook command should be safe and quiet.
|
|
484
|
-
|
|
485
|
-
Requirements:
|
|
486
|
-
|
|
487
|
-
~~~txt
|
|
488
|
-
- Never crash Cursor if JSON parsing fails.
|
|
489
|
-
- Store raw payload, even if normalization is incomplete.
|
|
490
|
-
- Use "unknown" role when unsure.
|
|
491
|
-
- Always exit successfully unless there is a severe local filesystem/database issue.
|
|
492
|
-
- Avoid logging noisy output unless debugging is enabled.
|
|
493
|
-
~~~
|
|
494
|
-
|
|
495
|
-
Pseudo-flow:
|
|
496
|
-
|
|
497
|
-
~~~ts
|
|
498
|
-
const eventName = args.eventName;
|
|
499
|
-
const rawStdin = await readStdin();
|
|
500
|
-
|
|
501
|
-
let payload: unknown;
|
|
502
|
-
|
|
503
|
-
try {
|
|
504
|
-
payload = JSON.parse(rawStdin);
|
|
505
|
-
} catch {
|
|
506
|
-
payload = { _raw: rawStdin };
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
const normalized = normalizeCursorEvent(eventName, payload);
|
|
510
|
-
await insertEvent(normalized);
|
|
511
|
-
~~~
|
|
512
|
-
|
|
513
|
-
---
|
|
514
|
-
|
|
515
|
-
## First Report Format
|
|
516
|
-
|
|
517
|
-
The `agent-profiler last` report should look roughly like this:
|
|
518
|
-
|
|
519
|
-
~~~txt
|
|
520
|
-
Agent Profiler: Last Session
|
|
521
|
-
|
|
522
|
-
Source:
|
|
523
|
-
Cursor
|
|
524
|
-
|
|
525
|
-
Repo:
|
|
526
|
-
/repos/sfw-mcp-chirp
|
|
527
|
-
|
|
528
|
-
Duration:
|
|
529
|
-
38 minutes
|
|
530
|
-
|
|
531
|
-
Observable usage:
|
|
532
|
-
Input: ~32,400 tokens
|
|
533
|
-
Output: ~18,900 tokens
|
|
534
|
-
Tool results: ~11,200 tokens
|
|
535
|
-
Shell output: ~7,800 tokens
|
|
536
|
-
Total: ~70,300 tokens
|
|
537
|
-
|
|
538
|
-
Session shape:
|
|
539
|
-
Turns: 14
|
|
540
|
-
File edits: 27
|
|
541
|
-
Shell calls: 9
|
|
542
|
-
Tool calls: 6
|
|
543
|
-
|
|
544
|
-
Efficiency score:
|
|
545
|
-
64 / 100
|
|
546
|
-
|
|
547
|
-
Red flags:
|
|
548
|
-
HIGH same-file churn
|
|
549
|
-
ProductCard.tsx was edited 9 times.
|
|
550
|
-
|
|
551
|
-
HIGH shell output noise
|
|
552
|
-
npm test produced ~6,800 observable tokens across 4 runs.
|
|
553
|
-
|
|
554
|
-
MEDIUM context bloat
|
|
555
|
-
Always-on repo instructions estimate: ~9,400 tokens.
|
|
556
|
-
|
|
557
|
-
Recommendations:
|
|
558
|
-
1. Add a focused rule for ProductCard layering and anchor semantics.
|
|
559
|
-
2. Cap or summarize repeated test output before asking the agent to continue.
|
|
560
|
-
3. Move long design-system references into an on-demand skill.
|
|
561
|
-
~~~
|
|
562
|
-
|
|
563
|
-
This is the heart of the product.
|
|
564
|
-
|
|
565
|
-
---
|
|
566
|
-
|
|
567
|
-
## Red Flags for MVP
|
|
568
|
-
|
|
569
|
-
Implement simple, explainable heuristics first.
|
|
570
|
-
|
|
571
|
-
### `same_file_churn`
|
|
572
|
-
|
|
573
|
-
Trigger when:
|
|
574
|
-
|
|
575
|
-
~~~txt
|
|
576
|
-
same file edited 5+ times in one session
|
|
577
|
-
~~~
|
|
578
|
-
|
|
579
|
-
### `large_shell_output`
|
|
580
|
-
|
|
581
|
-
Trigger when:
|
|
582
|
-
|
|
583
|
-
~~~txt
|
|
584
|
-
shell output exceeds 4,000 estimated tokens
|
|
585
|
-
~~~
|
|
586
|
-
|
|
587
|
-
### `large_tool_result`
|
|
588
|
-
|
|
589
|
-
Trigger when:
|
|
590
|
-
|
|
591
|
-
~~~txt
|
|
592
|
-
tool result exceeds 4,000 estimated tokens
|
|
593
|
-
~~~
|
|
594
|
-
|
|
595
|
-
### `oversized_prompt`
|
|
596
|
-
|
|
597
|
-
Trigger when:
|
|
598
|
-
|
|
599
|
-
~~~txt
|
|
600
|
-
single prompt exceeds 8,000 estimated tokens
|
|
601
|
-
~~~
|
|
602
|
-
|
|
603
|
-
### `context_bloat`
|
|
604
|
-
|
|
605
|
-
Trigger when:
|
|
606
|
-
|
|
607
|
-
~~~txt
|
|
608
|
-
repo instruction files exceed 6,000 estimated tokens
|
|
609
|
-
~~~
|
|
610
|
-
|
|
611
|
-
### `thrashing_loop`
|
|
612
|
-
|
|
613
|
-
Trigger when:
|
|
614
|
-
|
|
615
|
-
~~~txt
|
|
616
|
-
same command runs 3+ times with similar failure text
|
|
617
|
-
~~~
|
|
618
|
-
|
|
619
|
-
### `low_signal_session`
|
|
620
|
-
|
|
621
|
-
Trigger when:
|
|
622
|
-
|
|
623
|
-
~~~txt
|
|
624
|
-
high total observable tokens but few or no file edits
|
|
625
|
-
~~~
|
|
626
|
-
|
|
627
|
-
These are simple, explainable, and useful.
|
|
628
|
-
|
|
629
|
-
---
|
|
630
|
-
|
|
631
|
-
## Efficiency Score, First Pass
|
|
632
|
-
|
|
633
|
-
The score should be opinionated but transparent.
|
|
634
|
-
|
|
635
|
-
Start at `100`.
|
|
636
|
-
|
|
637
|
-
Subtract points:
|
|
638
|
-
|
|
639
|
-
~~~txt
|
|
640
|
-
- 5 to 25 points for always-on context bloat
|
|
641
|
-
- 5 to 20 points for repeated shell error loops
|
|
642
|
-
- 5 to 20 points for same-file edit thrashing
|
|
643
|
-
- 5 to 15 points for oversized MCP/tool responses
|
|
644
|
-
- 5 to 15 points for repeated tool calls with similar output
|
|
645
|
-
- 5 to 10 points for very large average prompt size
|
|
646
|
-
- 5 to 10 points for low edit-to-output ratio
|
|
647
|
-
~~~
|
|
648
|
-
|
|
649
|
-
Do not pretend the score is scientific.
|
|
650
|
-
|
|
651
|
-
Use language like:
|
|
652
|
-
|
|
653
|
-
~~~txt
|
|
654
|
-
Efficiency score: 68 / 100
|
|
655
|
-
|
|
656
|
-
Interpretation:
|
|
657
|
-
This was a moderately wasteful session. Most waste came from large tool responses and repeated edits to the same files.
|
|
658
|
-
~~~
|
|
659
|
-
|
|
660
|
-
---
|
|
661
|
-
|
|
662
|
-
## Context Audit
|
|
663
|
-
|
|
664
|
-
The `audit context` command should scan likely always-on or frequently referenced agent instruction files.
|
|
665
|
-
|
|
666
|
-
Initial file patterns:
|
|
667
|
-
|
|
668
|
-
~~~txt
|
|
669
|
-
AGENTS.md
|
|
670
|
-
CLAUDE.md
|
|
671
|
-
.cursorrules
|
|
672
|
-
.cursor/rules/**
|
|
673
|
-
.cursor/skills/**
|
|
674
|
-
.codex/config.toml
|
|
675
|
-
.codex/hooks.json
|
|
676
|
-
.claude/settings.json
|
|
677
|
-
.claude/commands/**
|
|
678
|
-
.claude/agents/**
|
|
679
|
-
.claude/skills/**
|
|
680
|
-
~~~
|
|
681
|
-
|
|
682
|
-
Example output:
|
|
683
|
-
|
|
684
|
-
~~~txt
|
|
685
|
-
Agent Profiler: Context Audit
|
|
686
|
-
|
|
687
|
-
Estimated always-on / agent-adjacent context:
|
|
688
|
-
~14,800 tokens
|
|
689
|
-
|
|
690
|
-
Largest contributors:
|
|
691
|
-
.cursor/rules/design-system.mdc ~5,900
|
|
692
|
-
.cursor/rules/architecture.mdc ~3,400
|
|
693
|
-
AGENTS.md ~2,700
|
|
694
|
-
.cursor/rules/testing.mdc ~1,900
|
|
695
|
-
|
|
696
|
-
Recommendations:
|
|
697
|
-
1. Move design-system.mdc into an on-demand skill unless it is needed for every task.
|
|
698
|
-
2. Keep always-on rules short, direct, and behavioral.
|
|
699
|
-
3. Move long examples and reference docs behind explicit commands or skills.
|
|
700
|
-
~~~
|
|
701
|
-
|
|
702
|
-
---
|
|
703
|
-
|
|
704
|
-
## Future Dashboard
|
|
705
|
-
|
|
706
|
-
Do not build this first.
|
|
707
|
-
|
|
708
|
-
Later command:
|
|
709
|
-
|
|
710
|
-
~~~bash
|
|
711
|
-
agent-profiler dashboard
|
|
712
|
-
~~~
|
|
713
|
-
|
|
714
|
-
Could launch:
|
|
715
|
-
|
|
716
|
-
~~~txt
|
|
717
|
-
http://localhost:3737
|
|
718
|
-
~~~
|
|
719
|
-
|
|
720
|
-
Future dashboard views:
|
|
721
|
-
|
|
722
|
-
~~~txt
|
|
723
|
-
Overview
|
|
724
|
-
Daily observable token estimate
|
|
725
|
-
Sessions by repo
|
|
726
|
-
Top noisy repos
|
|
727
|
-
Top noisy tools
|
|
728
|
-
Recent red flags
|
|
729
|
-
|
|
730
|
-
Sessions
|
|
731
|
-
Timeline of events
|
|
732
|
-
Prompt/response size trends
|
|
733
|
-
Tool calls
|
|
734
|
-
Shell calls
|
|
735
|
-
File edit churn
|
|
736
|
-
|
|
737
|
-
Repos
|
|
738
|
-
Context footprint
|
|
739
|
-
Rule size
|
|
740
|
-
Skill usage
|
|
741
|
-
Recommendations
|
|
742
|
-
|
|
743
|
-
MCP
|
|
744
|
-
Tool response sizes
|
|
745
|
-
Error loops
|
|
746
|
-
Repeated calls
|
|
747
|
-
Bloat sources
|
|
748
|
-
|
|
749
|
-
Doctor
|
|
750
|
-
Hook health
|
|
751
|
-
DB health
|
|
752
|
-
Cursor config health
|
|
753
|
-
Known limitations
|
|
754
|
-
~~~
|
|
755
|
-
|
|
756
|
-
But the MVP should prove itself through CLI reports first.
|
|
757
|
-
|
|
758
|
-
---
|
|
759
|
-
|
|
760
|
-
## Future Remediation Skills
|
|
761
|
-
|
|
762
|
-
After reporting works, add installable skills.
|
|
763
|
-
|
|
764
|
-
Possible command:
|
|
765
|
-
|
|
766
|
-
~~~bash
|
|
767
|
-
agent-profiler skills install cursor
|
|
768
|
-
~~~
|
|
769
|
-
|
|
770
|
-
Potential skills:
|
|
771
|
-
|
|
772
|
-
~~~txt
|
|
773
|
-
token-hygiene
|
|
774
|
-
context-audit
|
|
775
|
-
mcp-response-budget
|
|
776
|
-
rule-refactor
|
|
777
|
-
thrash-detection
|
|
778
|
-
~~~
|
|
779
|
-
|
|
780
|
-
Example generated recommendation file:
|
|
781
|
-
|
|
782
|
-
~~~md
|
|
783
|
-
# Agent Profiler Recommendation
|
|
784
|
-
|
|
785
|
-
## Problem
|
|
786
|
-
|
|
787
|
-
The repository appears to attach approximately 18,000 tokens of rules and reference material before the user prompt is considered.
|
|
788
|
-
|
|
789
|
-
## Evidence
|
|
790
|
-
|
|
791
|
-
- `.cursor/rules/design-system.mdc`: ~7,100 tokens
|
|
792
|
-
- `.cursor/rules/accessibility.mdc`: ~4,900 tokens
|
|
793
|
-
- `.cursor/rules/testing.mdc`: ~3,800 tokens
|
|
794
|
-
- `AGENTS.md`: ~2,200 tokens
|
|
795
|
-
|
|
796
|
-
## Recommendation
|
|
797
|
-
|
|
798
|
-
Split these into:
|
|
799
|
-
|
|
800
|
-
- short always-on rule summaries
|
|
801
|
-
- on-demand skills
|
|
802
|
-
- command-triggered references
|
|
803
|
-
- task-specific checklists
|
|
804
|
-
|
|
805
|
-
## Suggested Agent Task
|
|
806
|
-
|
|
807
|
-
Audit our Cursor rules for always-on context bloat. Preserve intent, but split large reference material into on-demand skills. Keep always-on rules under 2,000 tokens total.
|
|
808
|
-
~~~
|
|
809
|
-
|
|
810
|
-
---
|
|
811
|
-
|
|
812
|
-
## MVP Acceptance Criteria
|
|
813
|
-
|
|
814
|
-
Version `0.1` is successful when this works:
|
|
815
|
-
|
|
816
|
-
~~~bash
|
|
817
|
-
agent-profiler init cursor
|
|
818
|
-
~~~
|
|
819
|
-
|
|
820
|
-
Then the developer uses Cursor normally for one session.
|
|
821
|
-
|
|
822
|
-
Then:
|
|
823
|
-
|
|
824
|
-
~~~bash
|
|
825
|
-
agent-profiler last
|
|
826
|
-
~~~
|
|
827
|
-
|
|
828
|
-
Produces:
|
|
829
|
-
|
|
830
|
-
~~~txt
|
|
831
|
-
- estimated observable usage
|
|
832
|
-
- event counts
|
|
833
|
-
- largest events
|
|
834
|
-
- obvious red flags
|
|
835
|
-
- practical recommendations
|
|
836
|
-
~~~
|
|
837
|
-
|
|
838
|
-
That is enough to demo.
|
|
839
|
-
|
|
840
|
-
---
|
|
841
|
-
|
|
842
|
-
## First Commit
|
|
843
|
-
|
|
844
|
-
Suggested first commit:
|
|
845
|
-
|
|
846
|
-
~~~txt
|
|
847
|
-
feat: add local event store and cursor hook collector
|
|
848
|
-
~~~
|
|
849
|
-
|
|
850
|
-
Include:
|
|
851
|
-
|
|
852
|
-
~~~txt
|
|
853
|
-
- CLI shell with commander
|
|
854
|
-
- SQLite schema
|
|
855
|
-
- hook command that reads stdin
|
|
856
|
-
- Cursor adapter stub
|
|
857
|
-
- token estimator
|
|
858
|
-
- event insertion
|
|
859
|
-
- status command
|
|
860
|
-
~~~
|
|
861
|
-
|
|
862
|
-
---
|
|
863
|
-
|
|
864
|
-
## Second Commit
|
|
865
|
-
|
|
866
|
-
Suggested second commit:
|
|
867
|
-
|
|
868
|
-
~~~txt
|
|
869
|
-
feat: add last-session report with basic red flags
|
|
870
|
-
~~~
|
|
871
|
-
|
|
872
|
-
Include:
|
|
873
|
-
|
|
874
|
-
~~~txt
|
|
875
|
-
- session lookup
|
|
876
|
-
- event aggregation
|
|
877
|
-
- token totals
|
|
878
|
-
- red flag detection
|
|
879
|
-
- simple efficiency score
|
|
880
|
-
- text report output
|
|
881
|
-
~~~
|
|
882
|
-
|
|
883
|
-
---
|
|
884
|
-
|
|
885
|
-
## Third Commit
|
|
886
|
-
|
|
887
|
-
Suggested third commit:
|
|
888
|
-
|
|
889
|
-
~~~txt
|
|
890
|
-
feat: add repo context audit
|
|
891
|
-
~~~
|
|
892
|
-
|
|
893
|
-
Include:
|
|
894
|
-
|
|
895
|
-
~~~txt
|
|
896
|
-
- scan common agent instruction files
|
|
897
|
-
- estimate token footprint
|
|
898
|
-
- rank largest files
|
|
899
|
-
- generate context bloat recommendations
|
|
900
|
-
~~~
|
|
901
|
-
|
|
902
|
-
---
|
|
903
|
-
|
|
904
|
-
## Development Priority
|
|
905
|
-
|
|
906
|
-
Build in this order:
|
|
907
|
-
|
|
908
|
-
~~~txt
|
|
909
|
-
1. Package skeleton
|
|
910
|
-
2. SQLite setup
|
|
911
|
-
3. CLI shell
|
|
912
|
-
4. Hook command
|
|
913
|
-
5. Cursor adapter
|
|
914
|
-
6. Event insertion
|
|
915
|
-
7. Status command
|
|
916
|
-
8. Last-session report
|
|
917
|
-
9. Red flag detection
|
|
918
|
-
10. Context audit
|
|
919
|
-
~~~
|
|
920
|
-
|
|
921
|
-
Do not build the dashboard until the CLI is clearly useful.
|
|
922
|
-
|
|
923
|
-
---
|
|
924
|
-
|
|
925
|
-
## Product Language
|
|
926
|
-
|
|
927
|
-
Use this language:
|
|
928
|
-
|
|
929
|
-
~~~txt
|
|
930
|
-
Agent Profiler is a local-first profiler for AI coding agents.
|
|
931
|
-
It observes local agent events, estimates visible context and output size, and identifies patterns that make agent sessions expensive, noisy, or inefficient.
|
|
932
|
-
~~~
|
|
933
|
-
|
|
934
|
-
Avoid this language:
|
|
935
|
-
|
|
936
|
-
~~~txt
|
|
937
|
-
Tracks exact Cursor spend.
|
|
938
|
-
Measures official token billing.
|
|
939
|
-
Replaces provider dashboards.
|
|
940
|
-
Guarantees token accuracy.
|
|
941
|
-
~~~
|
|
942
|
-
|
|
943
|
-
Preferred disclaimer:
|
|
944
|
-
|
|
945
|
-
~~~txt
|
|
946
|
-
Agent Profiler estimates observable local usage. It does not replace official provider billing or admin dashboards.
|
|
947
|
-
~~~
|
|
948
|
-
|
|
949
|
-
---
|
|
950
|
-
|
|
951
|
-
## Long-Term Direction
|
|
952
|
-
|
|
953
|
-
Agent Profiler should eventually support:
|
|
954
|
-
|
|
955
|
-
~~~txt
|
|
956
|
-
Cursor
|
|
957
|
-
Claude Code
|
|
958
|
-
Codex
|
|
959
|
-
MCP tools
|
|
960
|
-
generic CLI workflows
|
|
961
|
-
local dashboards
|
|
962
|
-
installable remediation skills
|
|
963
|
-
team-level export
|
|
964
|
-
repo-level context linting
|
|
965
|
-
agent instruction refactoring
|
|
966
|
-
~~~
|
|
967
|
-
|
|
968
|
-
The strategic goal is to move teams from vague complaints like:
|
|
969
|
-
|
|
970
|
-
~~~txt
|
|
971
|
-
Cursor is expensive.
|
|
972
|
-
~~~
|
|
973
|
-
|
|
974
|
-
To actionable diagnosis like:
|
|
975
|
-
|
|
976
|
-
~~~txt
|
|
977
|
-
This repo has a 9,000-token always-on rule file, a noisy MCP tool returning 12,000-token responses, and an agent loop editing the same file 11 times.
|
|
978
|
-
~~~
|
|
979
|
-
|
|
980
|
-
That is the value proposition.
|