Skip to content

Commit cf936bf

Browse files
Add agent context analysis harness
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 6f569bf commit cf936bf

25 files changed

Lines changed: 3078 additions & 111 deletions

.claude-plugin/marketplace.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "context-profiler-marketplace",
3+
"owner": {
4+
"name": "Yanpeng Wang"
5+
},
6+
"metadata": {
7+
"description": "context-profiler skills for analyzing LLM agent traces and context evolution",
8+
"version": "0.1.0"
9+
},
10+
"plugins": [
11+
{
12+
"name": "context-profiler",
13+
"description": "Analyze agent traces, transcripts, Langfuse exports, OpenTelemetry spans, and raw provider requests with context-profiler.",
14+
"source": "./",
15+
"strict": false,
16+
"skills": [
17+
"./skills/analyze-agent-context"
18+
]
19+
}
20+
]
21+
}

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
name: CI
22

3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version:
15+
- "3.10"
16+
- "3.11"
17+
- "3.12"
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: astral-sh/setup-uv@v5
23+
24+
- name: Set up Python
25+
run: uv python install ${{ matrix.python-version }}
26+
27+
- name: Run smoke tests
28+
run: uv run --python ${{ matrix.python-version }} --with pytest pytest tests/test_smoke.py -v
29+
30+
- name: Smoke test CLI help
31+
run: uv run --python ${{ matrix.python-version }} context-profiler --help
32+
name: CI
33+
334
on:
435
push:
536
branches: [main]

.plugin/plugin.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "context-profiler",
3+
"description": "Agent context analysis harness for diagnosing context growth, tool bloat, repeated content, and turn-to-turn trace evolution.",
4+
"version": "0.1.0",
5+
"author": {
6+
"name": "Yanpeng Wang"
7+
},
8+
"skills": [
9+
"./skills/analyze-agent-context"
10+
]
11+
}

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Changelog
2+
3+
## 0.2.0 - Unreleased
4+
5+
### Added
6+
7+
- Agent-friendly CLI harness commands:
8+
- `formats list`
9+
- `formats describe`
10+
- `schema`
11+
- `validate`
12+
- `normalize`
13+
- `diagnose`
14+
- Cursor and Claude Code transcript JSONL ingestion.
15+
- Agent-readable diagnosis reports with input scope, confidence, limitations, issue codes, and recommendations.
16+
- Context diff evidence:
17+
- turn-to-turn added/removed/retained token summary
18+
- large addition hints
19+
- high tool-use addition hints
20+
- possible artifact churn hints
21+
- Tool context hotspot diagnosis:
22+
- `TOOL_USE_DOMINATES_CONTEXT`
23+
- `TOP_TOOL_CONTEXT_HOTSPOT`
24+
- Agent Skill distribution:
25+
- `skills/analyze-agent-context/SKILL.md`
26+
- `.plugin/plugin.json`
27+
- `.claude-plugin/marketplace.json`
28+
- HTML timeline markers for large additions and high tool-use turns.
29+
30+
### Changed
31+
32+
- Default analysis now includes content repeat and field repeat analyzers.
33+
- README repositioned the project as a trace-source agnostic context analysis harness.
34+
- Examples focus on raw provider requests, coding-agent transcripts, Langfuse exports, and multi-turn trajectory adapters.

CONTRIBUTING.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Contributing
2+
3+
Thanks for helping improve `context-profiler`.
4+
5+
## Development Setup
6+
7+
```bash
8+
git clone https://github.com/Turdot/context-profiler.git
9+
cd context-profiler
10+
pip install -e .
11+
```
12+
13+
For tests, this repository uses `pytest`:
14+
15+
```bash
16+
PYTHONPATH=src uv run --with pytest pytest tests/test_smoke.py -v
17+
```
18+
19+
## Project Boundaries
20+
21+
`context-profiler` analyzes traces; it does not fetch or replay them.
22+
23+
Prefer changes that improve one of these surfaces:
24+
25+
- supported input formats
26+
- validation and schema guidance for agents
27+
- context/token analyzers
28+
- machine-readable diagnosis output
29+
- HTML report clarity
30+
- Agent Skills / plugin distribution
31+
32+
Avoid adding provider-specific fetch clients unless there is a strong reason. Agents can use existing CLIs, SDKs, or APIs to fetch traces and pass the result to `context-profiler`.
33+
34+
## Adding a Format
35+
36+
When adding a new input format:
37+
38+
1. Add format metadata in `src/context_profiler/formats.py`.
39+
2. Include `input_kind`, `confidence`, `analysis_scope`, `limitations`, and `agent_conversion_guidance`.
40+
3. Add parser/normalizer code in `src/context_profiler/adapters/` or an adjacent focused module.
41+
4. Add a small synthetic fixture under `tests/fixtures/`.
42+
5. Add smoke tests for `validate`, `normalize`, `diagnose`, and `analyze --html` if applicable.
43+
44+
## Adding an Analyzer
45+
46+
Analyzers should produce evidence, not overconfident claims.
47+
48+
Good analyzer outputs:
49+
50+
- stable issue codes
51+
- token counts
52+
- request/message indices
53+
- tool names
54+
- artifact keys
55+
- confidence and limitations when heuristic
56+
57+
Avoid vague warnings without evidence.
58+
59+
## Agent Skill Changes
60+
61+
Canonical public skills live under `skills/`.
62+
63+
Do not put product-distribution skills under `.agents/skills/` or `.claude/skills/`; those paths are for project-local agent behavior.
64+
65+
If you add or rename skills, update:
66+
67+
- `.plugin/plugin.json`
68+
- `.claude-plugin/marketplace.json`
69+
- `README.md`
70+
- tests covering the distribution files

0 commit comments

Comments
 (0)