agentpack-cli 0.1.0__py3-none-any.whl
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.
- agentpack/__init__.py +3 -0
- agentpack/adapters/__init__.py +0 -0
- agentpack/adapters/base.py +22 -0
- agentpack/adapters/claude.py +32 -0
- agentpack/adapters/codex.py +26 -0
- agentpack/adapters/cursor.py +29 -0
- agentpack/adapters/generic.py +18 -0
- agentpack/adapters/windsurf.py +26 -0
- agentpack/analysis/__init__.py +0 -0
- agentpack/analysis/dependency_graph.py +80 -0
- agentpack/analysis/go_imports.py +32 -0
- agentpack/analysis/java_imports.py +19 -0
- agentpack/analysis/js_ts_imports.py +53 -0
- agentpack/analysis/python_imports.py +45 -0
- agentpack/analysis/ranking.py +400 -0
- agentpack/analysis/rust_imports.py +32 -0
- agentpack/analysis/symbols.py +154 -0
- agentpack/analysis/tests.py +30 -0
- agentpack/application/__init__.py +0 -0
- agentpack/application/pack_service.py +352 -0
- agentpack/cli.py +33 -0
- agentpack/commands/__init__.py +0 -0
- agentpack/commands/_shared.py +13 -0
- agentpack/commands/benchmark.py +302 -0
- agentpack/commands/claude_cmd.py +55 -0
- agentpack/commands/diff.py +46 -0
- agentpack/commands/doctor.py +185 -0
- agentpack/commands/explain.py +238 -0
- agentpack/commands/init.py +79 -0
- agentpack/commands/install.py +252 -0
- agentpack/commands/monitor.py +105 -0
- agentpack/commands/pack.py +188 -0
- agentpack/commands/scan.py +51 -0
- agentpack/commands/session.py +204 -0
- agentpack/commands/stats.py +138 -0
- agentpack/commands/status.py +37 -0
- agentpack/commands/summarize.py +64 -0
- agentpack/commands/watch.py +185 -0
- agentpack/core/__init__.py +0 -0
- agentpack/core/bootstrap.py +46 -0
- agentpack/core/cache.py +41 -0
- agentpack/core/config.py +101 -0
- agentpack/core/context_pack.py +222 -0
- agentpack/core/diff.py +40 -0
- agentpack/core/git.py +145 -0
- agentpack/core/git_hooks.py +8 -0
- agentpack/core/global_install.py +14 -0
- agentpack/core/ignore.py +66 -0
- agentpack/core/merkle.py +8 -0
- agentpack/core/models.py +115 -0
- agentpack/core/redactor.py +99 -0
- agentpack/core/scanner.py +150 -0
- agentpack/core/snapshot.py +60 -0
- agentpack/core/token_estimator.py +26 -0
- agentpack/core/vscode_tasks.py +5 -0
- agentpack/data/agentpack.md +160 -0
- agentpack/installers/__init__.py +0 -0
- agentpack/installers/claude.py +160 -0
- agentpack/installers/codex.py +54 -0
- agentpack/installers/cursor.py +76 -0
- agentpack/installers/windsurf.py +50 -0
- agentpack/integrations/__init__.py +0 -0
- agentpack/integrations/git_hooks.py +109 -0
- agentpack/integrations/global_install.py +221 -0
- agentpack/integrations/vscode_tasks.py +85 -0
- agentpack/renderers/__init__.py +3 -0
- agentpack/renderers/compact.py +75 -0
- agentpack/renderers/markdown.py +144 -0
- agentpack/renderers/receipts.py +10 -0
- agentpack/session/__init__.py +33 -0
- agentpack/session/state.py +105 -0
- agentpack/summaries/__init__.py +0 -0
- agentpack/summaries/base.py +42 -0
- agentpack/summaries/llm.py +100 -0
- agentpack/summaries/offline.py +97 -0
- agentpack_cli-0.1.0.dist-info/METADATA +1391 -0
- agentpack_cli-0.1.0.dist-info/RECORD +80 -0
- agentpack_cli-0.1.0.dist-info/WHEEL +4 -0
- agentpack_cli-0.1.0.dist-info/entry_points.txt +2 -0
- agentpack_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,1391 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentpack-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Token-aware context packing for AI coding agents — Claude, Cursor, Windsurf, and Codex
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: ai,claude,codex,coding-agent,context,cursor,llm,packing,windsurf
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Requires-Dist: pathspec>=0.12.1
|
|
19
|
+
Requires-Dist: pydantic>=2.0.0
|
|
20
|
+
Requires-Dist: rich>=13.0.0
|
|
21
|
+
Requires-Dist: tiktoken>=0.7.0
|
|
22
|
+
Requires-Dist: tomli-w>=1.0.0
|
|
23
|
+
Requires-Dist: typer>=0.12.0
|
|
24
|
+
Provides-Extra: all
|
|
25
|
+
Requires-Dist: anthropic>=0.39.0; extra == 'all'
|
|
26
|
+
Requires-Dist: openai>=1.0.0; extra == 'all'
|
|
27
|
+
Requires-Dist: watchdog>=4.0.0; extra == 'all'
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
32
|
+
Provides-Extra: llm
|
|
33
|
+
Requires-Dist: anthropic>=0.39.0; extra == 'llm'
|
|
34
|
+
Requires-Dist: openai>=1.0.0; extra == 'llm'
|
|
35
|
+
Provides-Extra: watch
|
|
36
|
+
Requires-Dist: watchdog>=4.0.0; extra == 'watch'
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# AgentPack
|
|
40
|
+
|
|
41
|
+
> **Status: alpha (v0.1.0).** Works, tested, used in real sessions. Python and JavaScript/TypeScript are the best-supported languages. Not yet validated across a wide range of repos. API may change before 1.0.
|
|
42
|
+
>
|
|
43
|
+
> **Platform note:** macOS and Linux are fully supported. Windows support is not yet implemented (git hooks use POSIX shell; the Claude Code session hooks use `python3`/`rm -f`). Contributions welcome.
|
|
44
|
+
|
|
45
|
+
**Token-aware context packing for AI coding agents.**
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## The problem
|
|
50
|
+
|
|
51
|
+
Every time you start a task with an AI coding agent, it has no idea what's in your repo. It either:
|
|
52
|
+
|
|
53
|
+
1. **Reads files on demand** (Claude Code, Cursor, Windsurf) — dozens of tool calls, paying exploration cost every session, every turn, forever.
|
|
54
|
+
2. **Gets the whole repo dumped in** (repomix, gitingest) — 50k–500k tokens of noise, most of it irrelevant to the task at hand.
|
|
55
|
+
3. **Gets nothing** — you hand-copy the 5 files you think matter and hope you got it right.
|
|
56
|
+
|
|
57
|
+
None of these scale. On a 200-file codebase, option 1 wastes 5–10 turns just orienting. Option 2 degrades output quality (LLMs perform worse on long noisy context). Option 3 misses critical dependencies and configs constantly.
|
|
58
|
+
|
|
59
|
+
**The root cause:** agents don't know *what's relevant to your current task* without doing the work to figure that out — which costs tokens, time, and money on every session.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## The solution
|
|
64
|
+
|
|
65
|
+
AgentPack solves this with a one-time offline analysis pass:
|
|
66
|
+
|
|
67
|
+
1. **Scans your repo once** — builds a summary cache of every file (signatures, imports, responsibilities). No API calls. Takes a few seconds.
|
|
68
|
+
2. **On each task** — uses git diff + import graph traversal + keyword scoring to rank every file by relevance to what you're working on.
|
|
69
|
+
3. **Packs a tight context document** — changed files get full content, dependencies get summaries, everything else gets dropped. Typically 8k–20k tokens for a 200-file repo.
|
|
70
|
+
4. **Stays current** — auto-repacks silently on commit, so next session starts fresh.
|
|
71
|
+
|
|
72
|
+
The result: your agent starts every session with a focused, accurate picture of the relevant code — without you doing anything after opt-in.
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install agentpack-cli
|
|
76
|
+
|
|
77
|
+
# Session mode: start once, then work normally
|
|
78
|
+
cd your-project
|
|
79
|
+
agentpack init
|
|
80
|
+
agentpack install --agent claude
|
|
81
|
+
agentpack session start
|
|
82
|
+
agentpack watch # in another terminal — keeps context fresh automatically
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Then open Claude / Cursor / Codex and write your task normally. AgentPack keeps `.agentpack/context.md` current.
|
|
86
|
+
|
|
87
|
+
Or without any setup at all:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
agentpack pack --agent claude --task "fix auth session bug" --print | claude
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
For power users who want background repacking on every commit and cd:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Advanced: global automation (opt-in repos only — never touches repos without .agentpack/)
|
|
97
|
+
agentpack global-install --agent claude --dry-run # preview first
|
|
98
|
+
agentpack global-install --agent claude
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Supported agents: **Claude Code**, **Cursor**, **Windsurf**, **Codex**, or any LLM via pipe/API.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## AgentPack Results (7 days, 21 sessions)
|
|
106
|
+
|
|
107
|
+
### Token Compression
|
|
108
|
+
|
|
109
|
+
| Metric | Value |
|
|
110
|
+
|--------|-------|
|
|
111
|
+
| Sessions | 21 |
|
|
112
|
+
| Avg compression | 99.3% |
|
|
113
|
+
| Min / Max | 98.7% → 99.9% |
|
|
114
|
+
| Total raw (theoretical) | 116.9M tokens |
|
|
115
|
+
| Total packed (actual) | 683K tokens |
|
|
116
|
+
|
|
117
|
+
Per session: ~4.1M raw repo → ~35K packed context.
|
|
118
|
+
|
|
119
|
+
### Cost (Sonnet 4.6, input tokens only)
|
|
120
|
+
|
|
121
|
+
| Scenario | Cost |
|
|
122
|
+
|----------|------|
|
|
123
|
+
| Full repo dumped each run | ~$350 |
|
|
124
|
+
| With AgentPack | ~$2.05 |
|
|
125
|
+
| **Realistic** (10% manual cherry-pick baseline) | **~$33 saved** |
|
|
126
|
+
|
|
127
|
+
> Honest note: raw_tokens = full repo estimate. Real savings depend on how much context you'd pass manually. Compression ratio (99%+) is verifiable; dollar figure is scenario-dependent.
|
|
128
|
+
|
|
129
|
+
### Quality Signal
|
|
130
|
+
|
|
131
|
+
- 42 commits in 7 days (~6/day) vs 4.9/day before
|
|
132
|
+
- Shift from single-file fixes → multi-system coordinated fixes
|
|
133
|
+
- AgentPack provides dependent files + callers in context → fixes root cause, not symptom
|
|
134
|
+
- Correlation observed, causation not isolated
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## When it helps
|
|
139
|
+
|
|
140
|
+
| Workflow | Value |
|
|
141
|
+
|---|---|
|
|
142
|
+
| `agentpack pack --print \| claude` — piped, no tools | **High** — Claude has no file access; pack is its only context |
|
|
143
|
+
| `claude < .agentpack/context.claude.md` — stdin | **High** — same |
|
|
144
|
+
| Claude API calls without tool use | **High** — same |
|
|
145
|
+
| CI: generate pack per PR, attach as artifact | **High** — reviewers get instant focused context |
|
|
146
|
+
| Cursor / Windsurf / Codex sessions | **Medium** — context auto-injected on startup, repacked on commit |
|
|
147
|
+
| Large repos (>50k tokens) where exploration is slow | **Medium** — summary cache eliminates repeated file reads |
|
|
148
|
+
| Claude Code interactive session, small repo | **Low** — Claude reads files on demand already |
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## How it compares to alternatives
|
|
153
|
+
|
|
154
|
+
**The honest version.**
|
|
155
|
+
|
|
156
|
+
### repomix / gitingest / code2prompt
|
|
157
|
+
|
|
158
|
+
These are repo dumpers. They pack a repo (or subset) into a file and hand it to you. They do that job well.
|
|
159
|
+
|
|
160
|
+
What they don't do: decide what's relevant to *your task*. You specify the scope — files, globs, directories — and they package your decision. If you want "only the files that matter for fixing this auth bug", you have to figure that out yourself. On a 200-file repo, that's 80% of the work.
|
|
161
|
+
|
|
162
|
+
AgentPack does that selection automatically. You give it a task string; it uses git diff, import graph traversal, and keyword scoring to rank every file, then cuts to fit your token budget. You don't touch globs.
|
|
163
|
+
|
|
164
|
+
The other difference: all three pack uniformly (full content or nothing). AgentPack is selective by inclusion mode — changed files get full content, unchanged deps get summaries, unrelated files get dropped. A repomix dump of a 50k-token repo stays 50k tokens. An agentpack of the same repo for a specific task is typically 8k–20k.
|
|
165
|
+
|
|
166
|
+
**Use repomix/gitingest if:** you want to dump an entire small repo into a chat UI for a one-shot question. Zero setup, great for "explain this codebase."
|
|
167
|
+
|
|
168
|
+
**Use agentpack if:** you're running repeated tasks on a large repo and want automatic, task-driven file selection every time.
|
|
169
|
+
|
|
170
|
+
### aider
|
|
171
|
+
|
|
172
|
+
Different category. Aider is an interactive pair programmer — it reads, edits, and commits files directly. Its repo-map is genuinely smart. If you want an AI coding assistant making actual edits, aider is excellent.
|
|
173
|
+
|
|
174
|
+
AgentPack is not a coding assistant. It's a context preparation tool. The output is a markdown file you pipe somewhere.
|
|
175
|
+
|
|
176
|
+
**Use aider if:** you want interactive, supervised AI coding sessions in a terminal.
|
|
177
|
+
|
|
178
|
+
**Use agentpack if:** you're driving Claude via pipe or API without an interactive session — CI, scripts, batch workflows.
|
|
179
|
+
|
|
180
|
+
### Claude Code / Cursor / Windsurf / Codex (agentic IDEs)
|
|
181
|
+
|
|
182
|
+
These tools have native file access via tool calls. Claude reads exactly the files it needs, on demand, per turn. Pre-packing context adds overhead without much benefit on small-to-medium repos.
|
|
183
|
+
|
|
184
|
+
AgentPack's value here is different: `agentpack install --agent <x>` configures your agent to auto-inject a ranked context pack on session start and auto-repack whenever you commit. On large repos where tool-call exploration piles up across turns, this front-loads the cost once instead of paying per-turn.
|
|
185
|
+
|
|
186
|
+
### Where agentpack genuinely wins
|
|
187
|
+
|
|
188
|
+
| Scenario | repomix | gitingest | code2prompt | aider | agentpack |
|
|
189
|
+
|---|---|---|---|---|---|
|
|
190
|
+
| Piped CLI (`... \| claude`) | ✓ dump | ✓ dump | ✓ dump | ✗ | ✓ task-filtered |
|
|
191
|
+
| API call without tool use | ✓ dump | ✗ | ✓ | ✗ | ✓ task-filtered |
|
|
192
|
+
| CI per-PR context | ✓ dump | ✗ | ✓ | ✗ | ✓ task-filtered |
|
|
193
|
+
| Auto task inference from git | ✗ | ✗ | ✗ | partial | ✓ |
|
|
194
|
+
| Relevance ranking by task | ✗ | ✗ | ✗ | ✗ | ✓ |
|
|
195
|
+
| Import graph traversal | ✗ | ✗ | ✗ | ✓ | ✓ |
|
|
196
|
+
| Token budget enforcement | manual | manual | manual | ✓ | ✓ |
|
|
197
|
+
| Cursor / Windsurf / Codex install | ✗ | ✗ | ✗ | ✗ | ✓ |
|
|
198
|
+
| Zero API calls | ✓ | ✓ | ✓ | ✗ | ✓ |
|
|
199
|
+
| Interactive coding sessions | ✗ | ✗ | ✗ | ✓✓ | ✗ |
|
|
200
|
+
| Any LLM | ✓ | ✓ | ✓ | ✓ | partial* |
|
|
201
|
+
|
|
202
|
+
_*`--agent generic` outputs standard markdown. Claude adapter has richer instructions._
|
|
203
|
+
|
|
204
|
+
### What agentpack does NOT do well
|
|
205
|
+
|
|
206
|
+
- **Interactive sessions on small repos**: if your whole repo is <20k tokens, just use repomix
|
|
207
|
+
- **One-shot public repo questions**: gitingest's "replace hub with ingest" is faster for that
|
|
208
|
+
- **Semantic understanding**: keyword scoring + AST is not a language model — precise technical terms in your task description work better than vague ones
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Install
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
pip install agentpack-cli
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Requires Python 3.10+.
|
|
219
|
+
|
|
220
|
+
> **PyPI note:** The package is `agentpack-cli` (the name `agentpack` was already taken). The CLI command is still `agentpack`.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Start Once, Then Work Normally
|
|
225
|
+
|
|
226
|
+
The recommended workflow for repeated development sessions:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
agentpack install # configure your agent (once per project)
|
|
230
|
+
agentpack session start # create session state + generate initial context
|
|
231
|
+
agentpack watch # in another terminal — refreshes context on file/task changes
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Then open Claude Code / Cursor / Codex and write your coding task normally.
|
|
235
|
+
|
|
236
|
+
- AgentPack keeps `.agentpack/context.md` fresh while `watch` is running.
|
|
237
|
+
- To change the task: `agentpack session refresh --task "new task"` — or just tell Claude and it updates `task.md` itself.
|
|
238
|
+
- Check session state: `agentpack session status`
|
|
239
|
+
- Force a refresh: `agentpack session refresh`
|
|
240
|
+
- Stop: `agentpack session stop`
|
|
241
|
+
|
|
242
|
+
### Agent integration matrix
|
|
243
|
+
|
|
244
|
+
| Agent | Automation level | Method |
|
|
245
|
+
|---|---|---|
|
|
246
|
+
| Claude Code (hook) | Highest | `UserPromptSubmit` hook auto-injects context |
|
|
247
|
+
| Claude Code (session) | High | `session start` + `watch` + read `context.md` |
|
|
248
|
+
| Codex | Medium | `AGENTS.md` + `session start` + `watch` |
|
|
249
|
+
| Cursor | Medium | `.cursor/rules/agentpack.mdc` + `session start` + `watch` |
|
|
250
|
+
| Windsurf | Medium | `.windsurfrules` + `session start` + `watch` |
|
|
251
|
+
| Generic / piped | Basic | `watch` mode + read `context.md` |
|
|
252
|
+
|
|
253
|
+
### Honest limitations
|
|
254
|
+
|
|
255
|
+
- AgentPack cannot intercept prompts inside IDEs — Cursor/Windsurf rely on rules being followed.
|
|
256
|
+
- Claude wrapper (`agentpack claude`) is the most deterministic integration.
|
|
257
|
+
- If the task changes drastically mid-session, context needs one refresh cycle.
|
|
258
|
+
- AgentPack-selected files are ranked starting points, not absolute truth.
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Quickstart
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
pip install agentpack-cli
|
|
266
|
+
cd your-project
|
|
267
|
+
agentpack init
|
|
268
|
+
agentpack install --agent claude # or: cursor, windsurf, codex
|
|
269
|
+
agentpack session start # generate initial context
|
|
270
|
+
agentpack watch # in another terminal — keeps context fresh
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Then open Claude / Cursor / Codex and write your task normally.
|
|
274
|
+
|
|
275
|
+
**Just want to pipe?**
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
agentpack pack --agent claude --task "fix auth session bug" --print | claude
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Power users (global automation):**
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
agentpack global-install --agent claude --dry-run # preview
|
|
285
|
+
agentpack global-install --agent claude # apply
|
|
286
|
+
source ~/.zshrc
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Then opt each project in: `cd your-project && agentpack init`. After that git hooks repack on commit and the Claude Code hook injects context on every session start — no manual steps.
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Agent setup
|
|
294
|
+
|
|
295
|
+
Run once per project. Each command is idempotent — safe to re-run, never clobbers unrelated config.
|
|
296
|
+
|
|
297
|
+
### Claude Code
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
agentpack install --agent claude
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
Configures:
|
|
304
|
+
- `CLAUDE.md` — tells Claude to read the context pack before each task
|
|
305
|
+
- `.claude/settings.json` — two hooks:
|
|
306
|
+
- `SessionStart`: clears injection sentinel so first prompt gets context
|
|
307
|
+
- `UserPromptSubmit`: auto-repacks when stale, injects context once per session
|
|
308
|
+
|
|
309
|
+
After this, context is injected automatically into every Claude Code session. No `/agentpack` command needed — it just happens.
|
|
310
|
+
|
|
311
|
+
### Cursor
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
agentpack install --agent cursor
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Configures:
|
|
318
|
+
- `.cursorrules` — rule: read `.agentpack/context.md` before every conversation
|
|
319
|
+
- `.cursor/rules/agentpack.mdc` — `alwaysApply: true` rule (Cursor v0.43+)
|
|
320
|
+
- `.git/hooks/post-commit`, `post-merge`, `post-checkout` — background repack on tree change
|
|
321
|
+
- `.vscode/tasks.json` — "AgentPack: Repack context" in Command Palette + `runOn: folderOpen`
|
|
322
|
+
|
|
323
|
+
### Windsurf
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
agentpack install --agent windsurf
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Configures:
|
|
330
|
+
- `.windsurfrules` — rule: read `.agentpack/context.md` before every conversation
|
|
331
|
+
- `.git/hooks/post-commit`, `post-merge`, `post-checkout` — background repack on tree change
|
|
332
|
+
- `.vscode/tasks.json` — "AgentPack: Repack context" in Command Palette + `runOn: folderOpen`
|
|
333
|
+
|
|
334
|
+
### Codex
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
agentpack install --agent codex
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Configures:
|
|
341
|
+
- `AGENTS.md` — tells Codex to read the context pack before each task
|
|
342
|
+
- `.git/hooks/post-commit`, `post-merge`, `post-checkout` — background repack on tree change
|
|
343
|
+
|
|
344
|
+
### Auto-repack comparison
|
|
345
|
+
|
|
346
|
+
| Mechanism | Claude Code | Cursor | Windsurf | Codex |
|
|
347
|
+
|---|---|---|---|---|
|
|
348
|
+
| Config file patched | `CLAUDE.md` + `.claude/settings.json` | `.cursorrules` + `.cursor/rules/*.mdc` | `.windsurfrules` | `AGENTS.md` |
|
|
349
|
+
| Auto-inject on startup | ✅ `UserPromptSubmit` hook | ✅ `alwaysApply` | ✅ rules file | ✅ `AGENTS.md` |
|
|
350
|
+
| Auto-repack when stale | ✅ hook (snapshot hash, ~1ms when fresh) | ✅ git hooks | ✅ git hooks | ✅ git hooks |
|
|
351
|
+
| Manual repack shortcut | ✅ `/agentpack` slash cmd | ✅ VS Code task | ✅ VS Code task | `agentpack pack` |
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## The summary cache — the core feature
|
|
356
|
+
|
|
357
|
+
Run once, reuse forever:
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
agentpack summarize
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
Builds an offline summary of every file — no API calls, no network. Each summary captures:
|
|
364
|
+
- What the file does and its responsibility
|
|
365
|
+
- Exported classes, functions, signatures with extracted bodies
|
|
366
|
+
- Import dependencies
|
|
367
|
+
|
|
368
|
+
Summaries are stored in `.agentpack/cache/` keyed by file hash. Only changed files are re-summarized on the next pack.
|
|
369
|
+
|
|
370
|
+
**Team tip:** commit the cache so every developer and CI job gets summaries for free:
|
|
371
|
+
|
|
372
|
+
```bash
|
|
373
|
+
agentpack init --share-cache
|
|
374
|
+
git add .agentpack/cache/
|
|
375
|
+
git commit -m "chore: add agentpack summary cache"
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## Honest token framing
|
|
381
|
+
|
|
382
|
+
AgentPack's pack is typically 10,000–25,000 tokens. Comparing that to "raw repo size" (200k–2M tokens) is misleading — nobody dumps the whole repo into Claude.
|
|
383
|
+
|
|
384
|
+
The real comparison for a piped/API workflow: **what would you manually copy-paste** to give Claude enough context? For a typical bug fix touching 3 files with 10 relevant dependencies, that's ~30,000–80,000 tokens assembled by hand. AgentPack gets you there in one command.
|
|
385
|
+
|
|
386
|
+
Token counts use tiktoken `cl100k_base` — a close approximation to Claude's actual billing, but not exact.
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## CI/CD: pack per PR
|
|
391
|
+
|
|
392
|
+
Add to `.github/workflows/agentpack.yml`:
|
|
393
|
+
|
|
394
|
+
```yaml
|
|
395
|
+
name: AgentPack context
|
|
396
|
+
|
|
397
|
+
on:
|
|
398
|
+
pull_request:
|
|
399
|
+
types: [opened, synchronize]
|
|
400
|
+
|
|
401
|
+
jobs:
|
|
402
|
+
pack:
|
|
403
|
+
runs-on: ubuntu-latest
|
|
404
|
+
steps:
|
|
405
|
+
- uses: actions/checkout@v4
|
|
406
|
+
with:
|
|
407
|
+
fetch-depth: 0
|
|
408
|
+
|
|
409
|
+
- uses: actions/setup-python@v5
|
|
410
|
+
with:
|
|
411
|
+
python-version: "3.12"
|
|
412
|
+
|
|
413
|
+
- run: pip install agentpack-cli
|
|
414
|
+
|
|
415
|
+
- name: Generate context pack
|
|
416
|
+
run: |
|
|
417
|
+
agentpack init --yes
|
|
418
|
+
agentpack pack --agent claude \
|
|
419
|
+
--task "${{ github.event.pull_request.title }}" \
|
|
420
|
+
--since origin/${{ github.base_ref }} \
|
|
421
|
+
--mode balanced
|
|
422
|
+
|
|
423
|
+
- name: Upload context pack
|
|
424
|
+
uses: actions/upload-artifact@v4
|
|
425
|
+
with:
|
|
426
|
+
name: agentpack-context
|
|
427
|
+
path: .agentpack/context.claude.md
|
|
428
|
+
retention-days: 7
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
Reviewers download the artifact and run:
|
|
432
|
+
|
|
433
|
+
```bash
|
|
434
|
+
claude < context.claude.md
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
No repo clone needed. Claude gets focused context for exactly the PR's changes.
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
## Commands
|
|
442
|
+
|
|
443
|
+
### `agentpack global-install`
|
|
444
|
+
|
|
445
|
+
Install once — works in every repo from that point on. The recommended first step.
|
|
446
|
+
|
|
447
|
+
```bash
|
|
448
|
+
agentpack global-install --agent claude # Claude Code
|
|
449
|
+
agentpack global-install --agent cursor # Cursor
|
|
450
|
+
agentpack global-install --agent windsurf # Windsurf
|
|
451
|
+
agentpack global-install --agent codex # Codex
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
What it does:
|
|
455
|
+
- **Git template hooks** (`~/.git-templates/hooks/`) — git copies these into every repo on `git init` / `git clone`. On `post-commit`, `post-merge`, `post-checkout`: silently repacks **only if `.agentpack/config.toml` exists** — no-op in repos that haven't opted in.
|
|
456
|
+
- **Shell cd hook** (`~/.zshrc` or `~/.bashrc`) — on `cd`, repacks if stale **only in opted-in repos**. Never touches repos without `.agentpack/config.toml`. Never auto-inits.
|
|
457
|
+
- **Agent config** — same as `agentpack install --agent <x>` for the current project.
|
|
458
|
+
|
|
459
|
+
All changes are idempotent, reversible, and non-destructive. Existing hooks and rc files are appended to, never overwritten. Repos you haven't explicitly run `agentpack init` in are never touched.
|
|
460
|
+
|
|
461
|
+
Options:
|
|
462
|
+
|
|
463
|
+
| Flag | Default | Description |
|
|
464
|
+
|---|---|---|
|
|
465
|
+
| `--agent` | `claude` | Target agent |
|
|
466
|
+
| `--no-pipx` | — | Skip pipx install (if agentpack already installed) |
|
|
467
|
+
| `--no-shell-hook` | — | Skip shell rc patching |
|
|
468
|
+
| `--no-git-template` | — | Skip git template hooks |
|
|
469
|
+
| `--dry-run` | off | Show what would be changed without touching anything |
|
|
470
|
+
|
|
471
|
+
Preview before committing:
|
|
472
|
+
|
|
473
|
+
```bash
|
|
474
|
+
agentpack global-install --dry-run
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
---
|
|
478
|
+
|
|
479
|
+
### `agentpack global-uninstall`
|
|
480
|
+
|
|
481
|
+
Remove all global hooks — git templates and shell rc. Per-project `.agentpack/` directories are untouched.
|
|
482
|
+
|
|
483
|
+
```bash
|
|
484
|
+
agentpack global-uninstall
|
|
485
|
+
agentpack global-uninstall --no-shell-hook # remove only git template hooks
|
|
486
|
+
agentpack global-uninstall --no-git-template # remove only shell hook
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
---
|
|
490
|
+
|
|
491
|
+
### `agentpack doctor`
|
|
492
|
+
|
|
493
|
+
Diagnose your agentpack installation — checks CLI, git template hooks, git config, shell hook, per-repo state, and agent config.
|
|
494
|
+
|
|
495
|
+
```bash
|
|
496
|
+
agentpack doctor
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
Example output:
|
|
500
|
+
|
|
501
|
+
```
|
|
502
|
+
CLI
|
|
503
|
+
✓ agentpack found at /usr/local/bin/agentpack (0.1.0)
|
|
504
|
+
|
|
505
|
+
Git template hooks (~/.git-templates/hooks/)
|
|
506
|
+
✓ post-commit
|
|
507
|
+
✓ post-merge
|
|
508
|
+
✓ post-checkout
|
|
509
|
+
|
|
510
|
+
git config init.templateDir
|
|
511
|
+
✓ init.templateDir = /Users/you/.git-templates
|
|
512
|
+
|
|
513
|
+
Shell cd hook
|
|
514
|
+
✓ Hook present in /Users/you/.zshrc
|
|
515
|
+
|
|
516
|
+
Per-repo state
|
|
517
|
+
✓ .agentpack/config.toml present
|
|
518
|
+
✓ context pack present (age: 2m)
|
|
519
|
+
|
|
520
|
+
Agent config
|
|
521
|
+
✓ CLAUDE.md (agentpack configured)
|
|
522
|
+
- .cursorrules not present (optional)
|
|
523
|
+
✓ Claude hooks present (local): .claude/settings.json
|
|
524
|
+
! ~/.claude/settings.json has no agentpack hooks — run: agentpack install --agent claude --global
|
|
525
|
+
! Hooks local-only — context won't auto-inject in other repos. Run: agentpack install --agent claude --global
|
|
526
|
+
|
|
527
|
+
Slash command (/agentpack)
|
|
528
|
+
✓ Slash command installed (local): .claude/commands/agentpack.md
|
|
529
|
+
- Slash command not installed globally — run: agentpack install --agent claude --global
|
|
530
|
+
|
|
531
|
+
Some checks failed. Run the suggested commands above to fix.
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
The new checks in `doctor`:
|
|
535
|
+
- **Local vs global hooks**: warns when Claude hooks are only in the per-project `.claude/settings.json` — context won't auto-inject in other repos
|
|
536
|
+
- **Slash command presence**: checks both local (`.claude/commands/`) and global (`~/.claude/commands/`) installations
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
540
|
+
### `agentpack init`
|
|
541
|
+
|
|
542
|
+
Initialize AgentPack in the current directory.
|
|
543
|
+
|
|
544
|
+
```bash
|
|
545
|
+
agentpack init # interactive mode picker
|
|
546
|
+
agentpack init --yes # non-interactive, use defaults (good for CI)
|
|
547
|
+
agentpack init --share-cache # commit cache/ to git for team sharing
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
Creates:
|
|
551
|
+
```
|
|
552
|
+
.agentignore # gitignore-style file exclusion rules
|
|
553
|
+
.agentpack/
|
|
554
|
+
config.toml # configuration (safe to commit)
|
|
555
|
+
.gitignore # excludes cache/, snapshots/, context.* by default
|
|
556
|
+
cache/ # offline summary cache
|
|
557
|
+
snapshots/ # file hash snapshots
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
---
|
|
561
|
+
|
|
562
|
+
### `agentpack install`
|
|
563
|
+
|
|
564
|
+
Configure agentpack for your AI coding agent.
|
|
565
|
+
|
|
566
|
+
```bash
|
|
567
|
+
agentpack install --agent claude # CLAUDE.md + .claude/settings.json hooks
|
|
568
|
+
agentpack install --agent cursor # .cursorrules + .mdc + git hooks + VS Code tasks
|
|
569
|
+
agentpack install --agent windsurf # .windsurfrules + git hooks + VS Code tasks
|
|
570
|
+
agentpack install --agent codex # AGENTS.md + git hooks
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
All installs are idempotent — safe to re-run, merge with existing config, never duplicate.
|
|
574
|
+
|
|
575
|
+
---
|
|
576
|
+
|
|
577
|
+
### `agentpack summarize`
|
|
578
|
+
|
|
579
|
+
Build or refresh the offline summary cache. **No API calls.**
|
|
580
|
+
|
|
581
|
+
```bash
|
|
582
|
+
agentpack summarize # build summaries for all files not yet cached
|
|
583
|
+
agentpack summarize --refresh # force rebuild all
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
Run this once after `init`. After that, pack automatically rebuilds summaries only for changed files.
|
|
587
|
+
|
|
588
|
+
---
|
|
589
|
+
|
|
590
|
+
### `agentpack pack`
|
|
591
|
+
|
|
592
|
+
Generate a context pack.
|
|
593
|
+
|
|
594
|
+
```bash
|
|
595
|
+
# Pipe directly into Claude (primary workflow)
|
|
596
|
+
agentpack pack --agent claude --task "fix auth session bug" --print | claude
|
|
597
|
+
|
|
598
|
+
# Save to file
|
|
599
|
+
agentpack pack --agent claude --task "fix auth session bug"
|
|
600
|
+
claude < .agentpack/context.claude.md
|
|
601
|
+
|
|
602
|
+
# Only include changes since a git ref
|
|
603
|
+
agentpack pack --agent claude --task "review these changes" --since main
|
|
604
|
+
|
|
605
|
+
# Watch mode — re-packs on every file change
|
|
606
|
+
agentpack pack --agent claude --task "refactor auth" --session
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
Options:
|
|
610
|
+
|
|
611
|
+
| Flag | Default | Description |
|
|
612
|
+
|------|---------|-------------|
|
|
613
|
+
| `--agent` | `claude` | Target agent (`claude` \| `cursor` \| `windsurf` \| `codex` \| `generic`) |
|
|
614
|
+
| `--task` | `auto` | Task description, or `auto` to infer from git |
|
|
615
|
+
| `--mode` | `balanced` | Budget mode: `minimal`, `balanced`, `deep` |
|
|
616
|
+
| `--budget` | 25000 | Token budget |
|
|
617
|
+
| `--since` | — | Only include files changed since this git ref |
|
|
618
|
+
| `--print` | off | Print to stdout (use with pipe) |
|
|
619
|
+
| `--session` | off | Re-pack on every file change (watch mode) |
|
|
620
|
+
| `--refresh` | off | Force rebuild summaries before packing |
|
|
621
|
+
|
|
622
|
+
**Budget modes:**
|
|
623
|
+
|
|
624
|
+
| Mode | What's included |
|
|
625
|
+
|------|----------------|
|
|
626
|
+
| `minimal` | Changed files + direct configs only |
|
|
627
|
+
| `balanced` | Changed files + deps + reverse deps + tests + summaries |
|
|
628
|
+
| `deep` | Everything in balanced + docs + more full-content files |
|
|
629
|
+
|
|
630
|
+
---
|
|
631
|
+
|
|
632
|
+
### `agentpack session`
|
|
633
|
+
|
|
634
|
+
Manage AgentPack sessions — the "start once, work normally" workflow.
|
|
635
|
+
|
|
636
|
+
```bash
|
|
637
|
+
agentpack session start # create session, generate initial context
|
|
638
|
+
agentpack session start --agent claude # set agent (claude|cursor|codex|generic)
|
|
639
|
+
agentpack session start --task "fix bug" # set initial task
|
|
640
|
+
agentpack session status # show session state + context size
|
|
641
|
+
agentpack session refresh # regenerate context now
|
|
642
|
+
agentpack session refresh --task "new task" # change task + refresh
|
|
643
|
+
agentpack session stop # mark session inactive
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
`session start` creates:
|
|
647
|
+
- `.agentpack/session.json` — session state
|
|
648
|
+
- `.agentpack/task.md` — current task (written by Claude or `session refresh --task`)
|
|
649
|
+
- `.agentpack/context.md` — readable context pack
|
|
650
|
+
- `.agentpack/context.compact.md` — compact protocol format
|
|
651
|
+
|
|
652
|
+
---
|
|
653
|
+
|
|
654
|
+
### `agentpack watch`
|
|
655
|
+
|
|
656
|
+
Watch for file and task changes, refresh context automatically.
|
|
657
|
+
|
|
658
|
+
```bash
|
|
659
|
+
agentpack watch # uses session agent/mode if session active
|
|
660
|
+
agentpack watch --debounce 3.0 # wait 3s after last change before refresh
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
Uses `watchdog` if installed, falls back to polling. Context is refreshed whenever source files or `.agentpack/task.md` change.
|
|
664
|
+
|
|
665
|
+
Install watchdog for better performance:
|
|
666
|
+
```bash
|
|
667
|
+
pip install "agentpack-cli[watch]"
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
---
|
|
671
|
+
|
|
672
|
+
### `agentpack claude`
|
|
673
|
+
|
|
674
|
+
Launch Claude CLI with an up-to-date context.
|
|
675
|
+
|
|
676
|
+
```bash
|
|
677
|
+
agentpack claude
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
Requires an active session (`agentpack session start`). Refreshes context, prints the context path, then launches `claude` if found. Transparent about what it does — no fake prompt injection.
|
|
681
|
+
|
|
682
|
+
---
|
|
683
|
+
|
|
684
|
+
### `agentpack explain`
|
|
685
|
+
|
|
686
|
+
Debug file selection — show which files would be selected, why, and what was excluded — without writing a context pack.
|
|
687
|
+
|
|
688
|
+
```bash
|
|
689
|
+
agentpack explain --task "fix auth session bug"
|
|
690
|
+
agentpack explain --task auto
|
|
691
|
+
agentpack explain --file src/auth/session.py # per-file score breakdown
|
|
692
|
+
agentpack explain --omitted # top-10 excluded files
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
Per-file breakdown (`--file`):
|
|
696
|
+
|
|
697
|
+
```
|
|
698
|
+
src/auth/session.py
|
|
699
|
+
selected: yes
|
|
700
|
+
score: 310
|
|
701
|
+
include: full
|
|
702
|
+
tokens: 4,200
|
|
703
|
+
|
|
704
|
+
signals:
|
|
705
|
+
+100 modified
|
|
706
|
+
+80 filename keyword match
|
|
707
|
+
+60 content keyword match (6)
|
|
708
|
+
+50 direct dependency of changed file
|
|
709
|
+
+35 has related tests
|
|
710
|
+
|
|
711
|
+
symbols: create_session, revoke_session, validate_session
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
Use `--omitted` to see what was left out and why. Use `--file` when a file you expected isn't showing up.
|
|
715
|
+
|
|
716
|
+
---
|
|
717
|
+
|
|
718
|
+
### `agentpack benchmark`
|
|
719
|
+
|
|
720
|
+
Measure token efficiency, file selection quality, and speed across tasks.
|
|
721
|
+
|
|
722
|
+
```bash
|
|
723
|
+
agentpack benchmark --task "fix auth token expiry" # single task
|
|
724
|
+
agentpack benchmark --task "fix auth bug" --compare # compare minimal/balanced/deep
|
|
725
|
+
agentpack benchmark --init # scaffold .agentpack/benchmark.toml
|
|
726
|
+
agentpack benchmark # run all cases in benchmark.toml
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
Output per case:
|
|
730
|
+
|
|
731
|
+
```
|
|
732
|
+
fix auth token expiry mode=balanced
|
|
733
|
+
|
|
734
|
+
packed tokens 29,357
|
|
735
|
+
raw tokens 187,998
|
|
736
|
+
saving 84.4%
|
|
737
|
+
files selected 234
|
|
738
|
+
changed covered 2/2 (100%)
|
|
739
|
+
total time 0.45s
|
|
740
|
+
|
|
741
|
+
phase time
|
|
742
|
+
scan 0.257s
|
|
743
|
+
rank 0.027s
|
|
744
|
+
select 0.009s
|
|
745
|
+
|
|
746
|
+
top files: src/auth/token.py, src/auth/session.py, ...
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
**Compare mode** shows all three modes side-by-side:
|
|
750
|
+
|
|
751
|
+
```
|
|
752
|
+
Mode comparison: fix auth token expiry
|
|
753
|
+
|
|
754
|
+
mode tokens saving files time
|
|
755
|
+
minimal 29,882 84.1% 253 0.34s
|
|
756
|
+
balanced 29,882 84.1% 253 0.24s
|
|
757
|
+
deep 7,563 96.0% 43 0.24s
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
**With expected files** (add to `benchmark.toml`), you get precision/recall/F1:
|
|
761
|
+
|
|
762
|
+
```toml
|
|
763
|
+
[[cases]]
|
|
764
|
+
task = "fix auth token expiry"
|
|
765
|
+
mode = "balanced"
|
|
766
|
+
expected_files = [
|
|
767
|
+
"src/auth/token.py",
|
|
768
|
+
"src/auth/session.py",
|
|
769
|
+
]
|
|
770
|
+
```
|
|
771
|
+
|
|
772
|
+
```
|
|
773
|
+
precision 100.0% recall 100.0% F1 100.0%
|
|
774
|
+
hit: src/auth/session.py, src/auth/token.py
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
---
|
|
778
|
+
|
|
779
|
+
### `agentpack scan`
|
|
780
|
+
|
|
781
|
+
Scan the repo and report file statistics.
|
|
782
|
+
|
|
783
|
+
```
|
|
784
|
+
Files discovered: 1,248
|
|
785
|
+
Files ignored/binary: 230
|
|
786
|
+
Files scanned: 210
|
|
787
|
+
Raw estimated tokens: 940,000
|
|
788
|
+
Tokens after ignore: 210,000
|
|
789
|
+
```
|
|
790
|
+
|
|
791
|
+
---
|
|
792
|
+
|
|
793
|
+
### `agentpack stats`
|
|
794
|
+
|
|
795
|
+
Show session state and token statistics for the last pack.
|
|
796
|
+
|
|
797
|
+
```bash
|
|
798
|
+
agentpack stats
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
When a session is active, shows session panel (agent, mode, started, refresh count) above token stats. Also lists top included files by score.
|
|
802
|
+
|
|
803
|
+
---
|
|
804
|
+
|
|
805
|
+
### `agentpack status`
|
|
806
|
+
|
|
807
|
+
Check whether the context pack is stale.
|
|
808
|
+
|
|
809
|
+
```bash
|
|
810
|
+
agentpack status
|
|
811
|
+
# Context pack is up to date.
|
|
812
|
+
# Task: fix auth session bug
|
|
813
|
+
# Generated: 2026-04-29T12:00:00Z
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
---
|
|
817
|
+
|
|
818
|
+
### `agentpack diff`
|
|
819
|
+
|
|
820
|
+
Show changes since last snapshot.
|
|
821
|
+
|
|
822
|
+
```
|
|
823
|
+
Added: 3 files
|
|
824
|
+
Modified: 7 files
|
|
825
|
+
Deleted: 1 file
|
|
826
|
+
Unchanged: 202 files
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
---
|
|
830
|
+
|
|
831
|
+
### `agentpack monitor`
|
|
832
|
+
|
|
833
|
+
Show pack performance across runs — timing per phase, token savings trend.
|
|
834
|
+
|
|
835
|
+
```bash
|
|
836
|
+
agentpack monitor # last 20 runs
|
|
837
|
+
agentpack monitor --last 5
|
|
838
|
+
agentpack monitor --clear
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
---
|
|
842
|
+
|
|
843
|
+
## How it works
|
|
844
|
+
|
|
845
|
+
```
|
|
846
|
+
1. Scan repo → apply .agentignore → hash every file
|
|
847
|
+
2. Build current snapshot → diff against previous snapshot
|
|
848
|
+
3. Get git changed/staged files (+ --since <ref> if specified)
|
|
849
|
+
4. Build import dependency graph (Python/JS/TS: full; Go/Rust/Java: best-effort)
|
|
850
|
+
5. Detect related test files
|
|
851
|
+
6. Extract task keywords + concept synonym expansion
|
|
852
|
+
7. Enrich keywords from changed file content (high-frequency identifiers)
|
|
853
|
+
8. Score every file, rank by score
|
|
854
|
+
9. Select within token budget
|
|
855
|
+
10. For each selected file:
|
|
856
|
+
changed + small → full content
|
|
857
|
+
changed + large → symbol bodies (ast.get_source_segment)
|
|
858
|
+
unchanged dep → summary + signatures
|
|
859
|
+
low-score file → summary only
|
|
860
|
+
11. Generate context receipts (why each file included/excluded)
|
|
861
|
+
12. Render markdown for target agent → save context pack
|
|
862
|
+
13. Save snapshot + metadata + metrics
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
---
|
|
866
|
+
|
|
867
|
+
## File scoring
|
|
868
|
+
|
|
869
|
+
| Signal | Points |
|
|
870
|
+
|--------|-------:|
|
|
871
|
+
| Modified file | +100 |
|
|
872
|
+
| Staged file | +90 |
|
|
873
|
+
| Filename/path keyword match | +80 |
|
|
874
|
+
| Symbol keyword match | +70 |
|
|
875
|
+
| Content keyword match | +60 |
|
|
876
|
+
| Direct dependency of changed file | +50 |
|
|
877
|
+
| Reverse dependency | +40 |
|
|
878
|
+
| Has related tests | +35 |
|
|
879
|
+
| Config file | +25 |
|
|
880
|
+
| Recently modified | +20 |
|
|
881
|
+
| Large unrelated file | −50 |
|
|
882
|
+
| Ignored/binary | −100 |
|
|
883
|
+
|
|
884
|
+
Keyword scoring uses concept synonym expansion — "rate limiting" in the task expands to `throttle`, `leaky`, `bucket`, `quota` etc., so `leaky_bucket.py` ranks correctly even if the file name doesn't literally contain "rate".
|
|
885
|
+
|
|
886
|
+
---
|
|
887
|
+
|
|
888
|
+
## Configuration
|
|
889
|
+
|
|
890
|
+
`.agentpack/config.toml`:
|
|
891
|
+
|
|
892
|
+
```toml
|
|
893
|
+
[project]
|
|
894
|
+
root = "."
|
|
895
|
+
ignore_file = ".agentignore"
|
|
896
|
+
|
|
897
|
+
[context]
|
|
898
|
+
default_budget = 25000
|
|
899
|
+
default_mode = "balanced"
|
|
900
|
+
max_file_tokens = 4000
|
|
901
|
+
include_tests = true
|
|
902
|
+
include_configs = true
|
|
903
|
+
include_receipts = true
|
|
904
|
+
|
|
905
|
+
[summary]
|
|
906
|
+
provider = "offline"
|
|
907
|
+
schema_version = 1
|
|
908
|
+
|
|
909
|
+
[agents.claude]
|
|
910
|
+
output = ".agentpack/context.claude.md"
|
|
911
|
+
patch_claude_md = true
|
|
912
|
+
|
|
913
|
+
[agents.generic]
|
|
914
|
+
output = ".agentpack/context.md"
|
|
915
|
+
```
|
|
916
|
+
|
|
917
|
+
---
|
|
918
|
+
|
|
919
|
+
## Configurable scoring weights
|
|
920
|
+
|
|
921
|
+
```toml
|
|
922
|
+
# .agentpack/config.toml
|
|
923
|
+
[scoring]
|
|
924
|
+
modified = 100
|
|
925
|
+
staged = 90
|
|
926
|
+
filename_keyword = 80
|
|
927
|
+
symbol_keyword = 70
|
|
928
|
+
content_keyword_per_hit = 10
|
|
929
|
+
content_keyword_max = 60
|
|
930
|
+
direct_dep = 50
|
|
931
|
+
reverse_dep = 40
|
|
932
|
+
related_test = 35
|
|
933
|
+
config_file = 25
|
|
934
|
+
recently_modified = 20
|
|
935
|
+
large_unrelated_penalty = -50
|
|
936
|
+
ignored_penalty = -100
|
|
937
|
+
```
|
|
938
|
+
|
|
939
|
+
---
|
|
940
|
+
|
|
941
|
+
## .agentignore
|
|
942
|
+
|
|
943
|
+
Works like `.gitignore`. Default rules exclude:
|
|
944
|
+
|
|
945
|
+
- `node_modules/`, `.venv/`, `__pycache__/`
|
|
946
|
+
- `dist/`, `build/`, `.next/`, `coverage/`
|
|
947
|
+
- `*.lock`, `*.log`, `*.min.js`, `*.map`
|
|
948
|
+
- `.env`, `.env.*`, `*.pem`, `*.key`
|
|
949
|
+
- `*.csv`, `*.jsonl`, `*.parquet`
|
|
950
|
+
|
|
951
|
+
---
|
|
952
|
+
|
|
953
|
+
## Git integration
|
|
954
|
+
|
|
955
|
+
```
|
|
956
|
+
.agentignore ✓ commit
|
|
957
|
+
.agentpack/config.toml ✓ commit
|
|
958
|
+
.agentpack/cache/ ✓ commit if --share-cache (recommended for teams)
|
|
959
|
+
.agentpack/snapshots/ ✗ gitignored
|
|
960
|
+
.agentpack/context.* ✗ gitignored
|
|
961
|
+
```
|
|
962
|
+
|
|
963
|
+
---
|
|
964
|
+
|
|
965
|
+
## Architecture
|
|
966
|
+
|
|
967
|
+
### Data flow
|
|
968
|
+
|
|
969
|
+
```
|
|
970
|
+
┌─────────────────────────────────────────────────────────────────────┐
|
|
971
|
+
│ agentpack pack │
|
|
972
|
+
└──────────────────────────────┬──────────────────────────────────────┘
|
|
973
|
+
│
|
|
974
|
+
┌────────────────────▼────────────────────┐
|
|
975
|
+
│ SCAN LAYER │
|
|
976
|
+
│ │
|
|
977
|
+
│ pathlib.rglob() ──▶ .agentignore │
|
|
978
|
+
│ │ (pathspec) │
|
|
979
|
+
│ ▼ │
|
|
980
|
+
│ FileInfo[] (path, hash, tokens, lang) │
|
|
981
|
+
└────────────────────┬────────────────────┘
|
|
982
|
+
│
|
|
983
|
+
┌────────────────────▼────────────────────┐
|
|
984
|
+
│ ANALYSIS LAYER │
|
|
985
|
+
│ │
|
|
986
|
+
│ Import graph ── Python AST │
|
|
987
|
+
│ (6 languages) ─ JS/TS regex │
|
|
988
|
+
│ ─ Go regex │
|
|
989
|
+
│ ─ Rust regex │
|
|
990
|
+
│ ─ Java/Kotlin regex │
|
|
991
|
+
│ │
|
|
992
|
+
│ Symbol extract ── Python AST (full) │
|
|
993
|
+
│ (body via ── JS/TS (functions, │
|
|
994
|
+
│ ast.get_source_segment) classes, │
|
|
995
|
+
│ ── arrow fns w/ =>) │
|
|
996
|
+
│ │
|
|
997
|
+
│ Test detection ── name heuristics │
|
|
998
|
+
│ Task keywords ── stopwords + variants│
|
|
999
|
+
│ ── concept synonyms │
|
|
1000
|
+
│ ── content enrichment │
|
|
1001
|
+
└────────────────────┬────────────────────┘
|
|
1002
|
+
│
|
|
1003
|
+
┌────────────────────▼────────────────────┐
|
|
1004
|
+
│ SUMMARY CACHE (offline, local) │
|
|
1005
|
+
│ │
|
|
1006
|
+
│ key: path + hash + provider + schema │
|
|
1007
|
+
│ hit → instant, zero I/O │
|
|
1008
|
+
│ miss → build from AST/regex, cache it │
|
|
1009
|
+
│ │
|
|
1010
|
+
│ offline ── AST / regex extract │
|
|
1011
|
+
│ claude ── Haiku API (optional) │
|
|
1012
|
+
└────────────────────┬────────────────────┘
|
|
1013
|
+
│
|
|
1014
|
+
┌────────────────────▼────────────────────┐
|
|
1015
|
+
│ CHANGE DETECTION │
|
|
1016
|
+
│ │
|
|
1017
|
+
│ Snapshot diff (merkle root hash) │
|
|
1018
|
+
│ + │
|
|
1019
|
+
│ git diff / git diff --cached │
|
|
1020
|
+
│ + │
|
|
1021
|
+
│ git diff <ref> HEAD (--since flag) │
|
|
1022
|
+
└────────────────────┬────────────────────┘
|
|
1023
|
+
│
|
|
1024
|
+
┌────────────────────▼────────────────────┐
|
|
1025
|
+
│ RANKING │
|
|
1026
|
+
│ │
|
|
1027
|
+
│ Score each file (configurable weights) │
|
|
1028
|
+
│ +100 modified +80 filename match │
|
|
1029
|
+
│ +70 symbol +60 content match │
|
|
1030
|
+
│ +50 dep +40 rev-dep │
|
|
1031
|
+
│ +35 test +25 config +20 recent │
|
|
1032
|
+
│ -50 large unrelated │
|
|
1033
|
+
└────────────────────┬────────────────────┘
|
|
1034
|
+
│
|
|
1035
|
+
┌────────────────────▼────────────────────┐
|
|
1036
|
+
│ BUDGET SELECTION │
|
|
1037
|
+
│ │
|
|
1038
|
+
│ Sort by score, consume until budget │
|
|
1039
|
+
│ │
|
|
1040
|
+
│ changed + small ──▶ full content │
|
|
1041
|
+
│ changed + large ──▶ symbol bodies │
|
|
1042
|
+
│ unchanged dep ──▶ summary + sigs │
|
|
1043
|
+
│ low score ──▶ summary only │
|
|
1044
|
+
└────────────────────┬────────────────────┘
|
|
1045
|
+
│
|
|
1046
|
+
┌────────────────────▼────────────────────┐
|
|
1047
|
+
│ RENDERING │
|
|
1048
|
+
│ │
|
|
1049
|
+
│ Claude adapter ──▶ context.claude.md │
|
|
1050
|
+
│ Cursor adapter ──▶ context.md │
|
|
1051
|
+
│ Windsurf adapter ─▶ context.md │
|
|
1052
|
+
│ Codex adapter ──▶ context.md │
|
|
1053
|
+
│ Generic adapter ──▶ context.md │
|
|
1054
|
+
│ │
|
|
1055
|
+
│ Context receipts (why each file in/out)│
|
|
1056
|
+
│ Secret redaction (AWS/GH/OpenAI tokens)│
|
|
1057
|
+
└─────────────────────────────────────────┘
|
|
1058
|
+
```
|
|
1059
|
+
|
|
1060
|
+
### Package layout
|
|
1061
|
+
|
|
1062
|
+
```
|
|
1063
|
+
src/agentpack/
|
|
1064
|
+
cli.py # Typer CLI entry point (thin — delegates to commands/)
|
|
1065
|
+
|
|
1066
|
+
data/
|
|
1067
|
+
agentpack.md # bundled /agentpack slash command for Claude CLI
|
|
1068
|
+
|
|
1069
|
+
application/
|
|
1070
|
+
pack_service.py # PackPlanner: shared scan→rank→select pipeline
|
|
1071
|
+
# PackService: materializes plan → writes context file
|
|
1072
|
+
# AdapterRegistry: maps agent names to adapter instances
|
|
1073
|
+
# PackRequest / PackResult / PackPlan DTOs
|
|
1074
|
+
|
|
1075
|
+
domain/ (via core/models.py)
|
|
1076
|
+
FileInfo, ScanResult # scan output (packable / ignored / binary)
|
|
1077
|
+
Symbol, FileSummary # summary cache objects
|
|
1078
|
+
SelectedFile, Receipt # selection output with redaction_warnings
|
|
1079
|
+
ContextPack # final artifact with redaction_warnings
|
|
1080
|
+
DependencyNode # typed graph node (path, imports, imported_by, tests)
|
|
1081
|
+
DependencyGraph # typed graph container (nodes dict + dict-like accessors)
|
|
1082
|
+
|
|
1083
|
+
core/
|
|
1084
|
+
models.py # Pydantic domain models (see above)
|
|
1085
|
+
config.py # TOML config + ScoringWeights
|
|
1086
|
+
ignore.py # .agentignore / gitignore-style matching
|
|
1087
|
+
scanner.py # rglob → ScanResult (packable/ignored/binary split)
|
|
1088
|
+
snapshot.py # JSON snapshots + merkle root hash
|
|
1089
|
+
diff.py # added / modified / deleted / unchanged diff
|
|
1090
|
+
git.py # subprocess git + task inference from branch/commits
|
|
1091
|
+
merkle.py # root hash: sort(path:hash) → sha256
|
|
1092
|
+
cache.py # summary cache keyed path+hash+provider+version
|
|
1093
|
+
context_pack.py # select_files: budget selection + secret redaction
|
|
1094
|
+
token_estimator.py # tiktoken cl100k_base (approximate)
|
|
1095
|
+
redactor.py # redact_secrets: fires at content materialization
|
|
1096
|
+
bootstrap.py # is_initialized, bootstrap_if_needed
|
|
1097
|
+
|
|
1098
|
+
analysis/
|
|
1099
|
+
dependency_graph.py # build(): returns typed DependencyGraph over packable files
|
|
1100
|
+
python_imports.py # ast-based import extraction
|
|
1101
|
+
js_ts_imports.py # regex import extraction (ESM + CJS)
|
|
1102
|
+
go_imports.py # Go import / import(...) blocks
|
|
1103
|
+
rust_imports.py # use, mod, extern crate
|
|
1104
|
+
java_imports.py # Java import + Kotlin import
|
|
1105
|
+
symbols.py # AST symbols + body via ast.get_source_segment
|
|
1106
|
+
tests.py # source → test file mapping heuristics
|
|
1107
|
+
ranking.py # keyword extraction, concept synonyms, scoring
|
|
1108
|
+
|
|
1109
|
+
summaries/
|
|
1110
|
+
offline.py # zero-API: AST/regex → imports, symbols, summary
|
|
1111
|
+
llm.py # Claude Haiku API summaries (optional)
|
|
1112
|
+
base.py # cache-or-build orchestration
|
|
1113
|
+
|
|
1114
|
+
adapters/ # context rendering only — no installation logic
|
|
1115
|
+
base.py # abstract BaseAdapter (output_path + render + write)
|
|
1116
|
+
claude.py # renders context.claude.md via render_claude()
|
|
1117
|
+
cursor.py # renders context.md via render_generic()
|
|
1118
|
+
windsurf.py # renders context.md
|
|
1119
|
+
codex.py # renders context.md
|
|
1120
|
+
generic.py # renders context.md (any LLM)
|
|
1121
|
+
|
|
1122
|
+
installers/ # repo/tool configuration — separate from rendering
|
|
1123
|
+
claude.py # ClaudeInstaller: CLAUDE.md + .claude/settings.json
|
|
1124
|
+
cursor.py # CursorInstaller: .cursorrules + .mdc + auto-repack
|
|
1125
|
+
windsurf.py # WindsurfInstaller: .windsurfrules + auto-repack
|
|
1126
|
+
codex.py # CodexInstaller: AGENTS.md + git hooks
|
|
1127
|
+
|
|
1128
|
+
integrations/ # system/tool integration (not core domain)
|
|
1129
|
+
git_hooks.py # install/remove .git/hooks post-commit/merge/checkout
|
|
1130
|
+
vscode_tasks.py # install/remove .vscode/tasks.json entries
|
|
1131
|
+
global_install.py # global: git template hooks + shell rc hook
|
|
1132
|
+
|
|
1133
|
+
renderers/
|
|
1134
|
+
markdown.py # renders pre-redacted ContextPack to markdown
|
|
1135
|
+
compact.py # compact protocol format for session context files
|
|
1136
|
+
receipts.py # context receipt formatter
|
|
1137
|
+
|
|
1138
|
+
session/
|
|
1139
|
+
state.py # SessionState dataclass + load/save/create/stop helpers
|
|
1140
|
+
__init__.py # re-exports from state.py
|
|
1141
|
+
|
|
1142
|
+
commands/ # CLI only — parse args, call services/installers
|
|
1143
|
+
pack.py # agentpack pack → PackService.run()
|
|
1144
|
+
install.py # agentpack install / global-install → installers/
|
|
1145
|
+
init.py # agentpack init
|
|
1146
|
+
scan.py # agentpack scan
|
|
1147
|
+
diff.py # agentpack diff
|
|
1148
|
+
status.py # agentpack status
|
|
1149
|
+
stats.py # agentpack stats
|
|
1150
|
+
summarize.py # agentpack summarize
|
|
1151
|
+
monitor.py # agentpack monitor
|
|
1152
|
+
explain.py # agentpack explain
|
|
1153
|
+
doctor.py # agentpack doctor
|
|
1154
|
+
session.py # agentpack session start/stop/status/refresh
|
|
1155
|
+
watch.py # agentpack watch — file watcher with debounce
|
|
1156
|
+
claude_cmd.py # agentpack claude — refresh + launch claude
|
|
1157
|
+
benchmark.py # agentpack benchmark — token efficiency + selection quality
|
|
1158
|
+
```
|
|
1159
|
+
|
|
1160
|
+
### Key architectural properties
|
|
1161
|
+
|
|
1162
|
+
- **Redaction at materialization**: secrets are stripped inside `select_files()` before content reaches any renderer or adapter. Every output format gets redacted content automatically — no per-renderer redaction needed.
|
|
1163
|
+
- **`ScanResult` splits cleanly**: `scan()` returns `ScanResult(packable, ignored, binary)` — downstream code only processes `packable` files, eliminating `if f.ignored or f.binary` guards throughout.
|
|
1164
|
+
- **`PackPlanner` owns shared planning**: `PackPlanner.plan()` runs scan → summarize → graph → rank → select and returns a `PackPlan`. Both `pack` and `explain` use the same planner — no duplicated pipeline logic, no drift.
|
|
1165
|
+
- **`PackService` materializes a plan**: takes a `PackPlan`, builds the `ContextPack` artifact, delegates rendering to `AdapterRegistry`, persists snapshot + metadata + metrics.
|
|
1166
|
+
- **`AdapterRegistry` maps agent → adapter**: adding a new agent output format requires one entry in `AdapterRegistry.get()`, not changes to `PackService`.
|
|
1167
|
+
- **`DependencyGraph` is typed**: `dependency_graph.build()` returns `DependencyGraph(nodes: dict[str, DependencyNode])` — no more `dict[str, dict]` with stringly-typed keys like `"imported_by"`. Typos are caught at the model layer.
|
|
1168
|
+
- **`integrations/` vs `core/`**: git hooks, shell rc patching, and VS Code tasks are infrastructure concerns — they live in `integrations/`, not `core/`. `core/` is pure domain logic.
|
|
1169
|
+
- **Adapters render; installers configure**: `adapters/` knows how to write a context file for an agent. `installers/` knows how to configure the agent's tool (CLAUDE.md, .cursorrules, settings.json). They are separate concerns and separate classes.
|
|
1170
|
+
|
|
1171
|
+
---
|
|
1172
|
+
|
|
1173
|
+
## Practical examples
|
|
1174
|
+
|
|
1175
|
+
### Bug fix: "I have a failing test, help me fix it"
|
|
1176
|
+
|
|
1177
|
+
```bash
|
|
1178
|
+
# You're debugging a test failure in the auth module
|
|
1179
|
+
agentpack pack --agent claude --task "fix failing test in auth token validation" --print | claude
|
|
1180
|
+
```
|
|
1181
|
+
|
|
1182
|
+
AgentPack selects: the failing test file (modified), `auth/token.py` (dep), `auth/session.py` (dep), `config/settings.py` (config), skips 180 unrelated files. Claude gets 12k tokens of precisely relevant context and starts debugging immediately.
|
|
1183
|
+
|
|
1184
|
+
---
|
|
1185
|
+
|
|
1186
|
+
### Feature: "Add rate limiting to the API"
|
|
1187
|
+
|
|
1188
|
+
```bash
|
|
1189
|
+
# On a feature branch, nothing modified yet
|
|
1190
|
+
agentpack pack --agent claude --task "add rate limiting to REST API endpoints" --print | claude
|
|
1191
|
+
```
|
|
1192
|
+
|
|
1193
|
+
Keyword expansion activates: "rate limiting" → `throttle`, `leaky`, `bucket`, `quota`. AgentPack scores: `middleware/` directory (path keyword `api`), existing `throttle.py` or `leaky_bucket.py` (content keyword), `routes/*.py` (deps). Claude gets the full middleware stack and starts implementing, not exploring.
|
|
1194
|
+
|
|
1195
|
+
---
|
|
1196
|
+
|
|
1197
|
+
### Code review: "Review my PR before I push"
|
|
1198
|
+
|
|
1199
|
+
```bash
|
|
1200
|
+
# Review only what changed vs main
|
|
1201
|
+
agentpack pack --agent claude --task "code review auth refactor" --since main --print | claude
|
|
1202
|
+
```
|
|
1203
|
+
|
|
1204
|
+
Only files touched in this branch are included (full content). Everything else is summaries or omitted. Claude reviews exactly the diff-visible code, not the whole codebase.
|
|
1205
|
+
|
|
1206
|
+
---
|
|
1207
|
+
|
|
1208
|
+
### Refactor: "Help me refactor the database layer"
|
|
1209
|
+
|
|
1210
|
+
```bash
|
|
1211
|
+
agentpack pack --agent claude --task "refactor database connection pooling" --mode deep --print | claude
|
|
1212
|
+
```
|
|
1213
|
+
|
|
1214
|
+
`--mode deep` adds: related docs, more full-content files, broader dep tree. Use when the task touches many files and you want Claude to see more context upfront.
|
|
1215
|
+
|
|
1216
|
+
---
|
|
1217
|
+
|
|
1218
|
+
### CI: automated context on every PR
|
|
1219
|
+
|
|
1220
|
+
Add to `.github/workflows/agentpack.yml` — see the full example in [CI/CD: pack per PR](#cicd-pack-per-pr). Reviewers and CI bots get focused context without cloning the repo.
|
|
1221
|
+
|
|
1222
|
+
---
|
|
1223
|
+
|
|
1224
|
+
### Session mode: keep context fresh while you work
|
|
1225
|
+
|
|
1226
|
+
```bash
|
|
1227
|
+
# Terminal 1: start a session and watch for changes
|
|
1228
|
+
agentpack session start --task "refactor auth"
|
|
1229
|
+
agentpack watch # in a second terminal — refreshes context on every save
|
|
1230
|
+
|
|
1231
|
+
# Terminal 2: your editor / agent
|
|
1232
|
+
# Save a file → context.md regenerates automatically
|
|
1233
|
+
# Change task: agentpack session refresh --task "new task"
|
|
1234
|
+
```
|
|
1235
|
+
|
|
1236
|
+
---
|
|
1237
|
+
|
|
1238
|
+
### Pipe into any LLM
|
|
1239
|
+
|
|
1240
|
+
```bash
|
|
1241
|
+
# Claude CLI (piped)
|
|
1242
|
+
agentpack pack --task "fix SSE cancellation bug" --print | claude
|
|
1243
|
+
|
|
1244
|
+
# OpenAI CLI
|
|
1245
|
+
agentpack pack --task "fix SSE cancellation bug" --print | llm "fix this"
|
|
1246
|
+
|
|
1247
|
+
# Anthropic API via curl
|
|
1248
|
+
agentpack pack --task "debug memory leak" --print > /tmp/context.md
|
|
1249
|
+
# then reference /tmp/context.md in your API call
|
|
1250
|
+
```
|
|
1251
|
+
|
|
1252
|
+
---
|
|
1253
|
+
|
|
1254
|
+
### Debug why a file isn't showing up
|
|
1255
|
+
|
|
1256
|
+
```bash
|
|
1257
|
+
agentpack explain --task "fix rate limiting in auth middleware"
|
|
1258
|
+
# Top selected files:
|
|
1259
|
+
# 1. src/auth/middleware.py score=180 [full] modified, filename keyword match
|
|
1260
|
+
# 2. src/auth/limiter.py score=130 [symbols] dep + content keyword "throttle"
|
|
1261
|
+
# ...
|
|
1262
|
+
# Excluded:
|
|
1263
|
+
# - src/payments/billing.py score=8 score too low
|
|
1264
|
+
```
|
|
1265
|
+
|
|
1266
|
+
---
|
|
1267
|
+
|
|
1268
|
+
## Tips & tricks
|
|
1269
|
+
|
|
1270
|
+
### Let `--task auto` do the work
|
|
1271
|
+
|
|
1272
|
+
Skip writing a task description — agentpack infers it from your branch name, changed files, and recent commits:
|
|
1273
|
+
|
|
1274
|
+
```bash
|
|
1275
|
+
agentpack pack --task auto --print | claude
|
|
1276
|
+
```
|
|
1277
|
+
|
|
1278
|
+
Priority order: branch name → changed file paths → recent commit message. The more descriptive your branch names (`feat/add-rate-limiting` beats `dev`), the better the inferred task.
|
|
1279
|
+
|
|
1280
|
+
### Concept synonym expansion
|
|
1281
|
+
|
|
1282
|
+
AgentPack expands task keywords automatically — "rate limiting" expands to `throttle`, `leaky`, `bucket`, `quota`, `debounce`; "auth" expands to `jwt`, `bearer`, `token`, `oauth`; "cache" expands to `lru`, `memoize`, `redis`, `ttl`. Files that implement a concept but don't use its exact name still rank correctly.
|
|
1283
|
+
|
|
1284
|
+
### Content-based keyword enrichment
|
|
1285
|
+
|
|
1286
|
+
When you run `agentpack pack`, changed file content is scanned for high-frequency identifiers. If you're editing `session_manager.py` that mentions `validate_token` 30 times, `validate` and `token` are added as keywords — related files that use the same terms get a score boost even if your task string didn't mention them.
|
|
1287
|
+
|
|
1288
|
+
### Commit the summary cache for instant team packs
|
|
1289
|
+
|
|
1290
|
+
```bash
|
|
1291
|
+
agentpack init --share-cache
|
|
1292
|
+
git add .agentpack/cache/
|
|
1293
|
+
git commit -m "chore: add agentpack summary cache"
|
|
1294
|
+
```
|
|
1295
|
+
|
|
1296
|
+
Every teammate and CI job skips the summarize step. `agentpack pack` is significantly faster from a warm cache.
|
|
1297
|
+
|
|
1298
|
+
### Use `--since` for PR reviews
|
|
1299
|
+
|
|
1300
|
+
```bash
|
|
1301
|
+
agentpack pack --task "review auth changes" --since main --print | claude
|
|
1302
|
+
```
|
|
1303
|
+
|
|
1304
|
+
Only includes files changed since `main`. Cuts out noise from unrelated work in long-running branches.
|
|
1305
|
+
|
|
1306
|
+
### Tune the budget for your use case
|
|
1307
|
+
|
|
1308
|
+
```bash
|
|
1309
|
+
agentpack pack --task "fix bug" --mode minimal # changed files only, fewest tokens
|
|
1310
|
+
agentpack pack --task "refactor" --mode deep # everything including docs
|
|
1311
|
+
agentpack pack --task "fix bug" --budget 40000 # explicit token cap
|
|
1312
|
+
```
|
|
1313
|
+
|
|
1314
|
+
`balanced` (default) is right for most tasks. Use `minimal` for quick fixes, `deep` when architectural context matters.
|
|
1315
|
+
|
|
1316
|
+
### Watch mode for active sessions
|
|
1317
|
+
|
|
1318
|
+
```bash
|
|
1319
|
+
agentpack session start --task "refactor auth"
|
|
1320
|
+
agentpack watch # in another terminal
|
|
1321
|
+
```
|
|
1322
|
+
|
|
1323
|
+
Refreshes `.agentpack/context.md` every time you save a file. Change the task with `agentpack session refresh --task "..."` — or tell Claude and it writes `task.md` itself.
|
|
1324
|
+
|
|
1325
|
+
### Debug file selection with `explain`
|
|
1326
|
+
|
|
1327
|
+
```bash
|
|
1328
|
+
agentpack explain --task "fix auth session bug"
|
|
1329
|
+
```
|
|
1330
|
+
|
|
1331
|
+
Shows ranked scores and reasons before committing to a pack. Use when a file you expect isn't appearing.
|
|
1332
|
+
|
|
1333
|
+
### Check what got included and why
|
|
1334
|
+
|
|
1335
|
+
Every pack includes a context receipt explaining each file's inclusion or exclusion:
|
|
1336
|
+
|
|
1337
|
+
```
|
|
1338
|
+
- `src/auth.py` included because modified, filename keyword match
|
|
1339
|
+
- `tests/test_auth.py` summarized because test for src/auth.py
|
|
1340
|
+
- `src/unrelated_big.py` excluded because score too low
|
|
1341
|
+
```
|
|
1342
|
+
|
|
1343
|
+
Use this to tune your `.agentignore` or scoring weights when irrelevant files keep appearing.
|
|
1344
|
+
|
|
1345
|
+
### Tune scoring weights per project
|
|
1346
|
+
|
|
1347
|
+
If tests are always irrelevant to your tasks, drop their weight. If config files are critical, raise them:
|
|
1348
|
+
|
|
1349
|
+
```toml
|
|
1350
|
+
# .agentpack/config.toml
|
|
1351
|
+
[scoring]
|
|
1352
|
+
related_test = 5 # was 35 — tests rarely relevant
|
|
1353
|
+
config_file = 60 # was 25 — configs always matter here
|
|
1354
|
+
```
|
|
1355
|
+
|
|
1356
|
+
---
|
|
1357
|
+
|
|
1358
|
+
## Principles
|
|
1359
|
+
|
|
1360
|
+
- **Local-first**: `init`, `scan`, `diff`, `pack`, `stats`, `summarize` make zero API calls by default
|
|
1361
|
+
- **Non-destructive**: never overwrites user files; config patching only touches agentpack-managed blocks
|
|
1362
|
+
- **Agent-neutral**: architecture is generic; Claude is the primary target (deepest integration); Cursor, Windsurf, and Codex are supported but less battle-tested
|
|
1363
|
+
- **No daemons**: file watching is opt-in via `agentpack watch`; session management is opt-in via `agentpack session start`; git hooks run in the background and are opt-in via `install`
|
|
1364
|
+
- **Honest**: packed token count reflects real content, not raw repo size
|
|
1365
|
+
|
|
1366
|
+
---
|
|
1367
|
+
|
|
1368
|
+
## Known limitations
|
|
1369
|
+
|
|
1370
|
+
- **Windows**: not supported. Git hooks use POSIX shell (`#!/bin/sh`, `>/dev/null 2>&1 &`). The Claude Code session hooks use `python3` and `rm -f`. Contributions welcome.
|
|
1371
|
+
- **Monorepos**: single-root repos only. If you `agentpack pack` from a monorepo root, all packages are scanned together with no workspace awareness. Workaround: `cd packages/my-pkg && agentpack init && agentpack pack`.
|
|
1372
|
+
- **Symbol extraction**: Python (AST, full) and JavaScript/TypeScript (regex, arrow functions + classes) are well-supported. Go, Rust, Java, Kotlin have import graph traversal but no symbol extraction — they fall back to file-level summaries.
|
|
1373
|
+
- **Secret redaction**: covers AWS keys, GitHub tokens, OpenAI/Anthropic keys, JWTs, and private key blocks. Not a substitute for a dedicated secrets scanner on sensitive repos.
|
|
1374
|
+
- **Token estimates**: uses tiktoken `cl100k_base` — approximate, not exact for Claude's billing.
|
|
1375
|
+
- **Large repos (>5k files)**: global auto-bootstrap is skipped for repos over 5,000 files to avoid hangs. Run `agentpack init` explicitly in large codebases.
|
|
1376
|
+
|
|
1377
|
+
---
|
|
1378
|
+
|
|
1379
|
+
## Optional dependencies
|
|
1380
|
+
|
|
1381
|
+
```bash
|
|
1382
|
+
pip install "agentpack-cli[llm]" # anthropic — LLM summaries via Claude Haiku
|
|
1383
|
+
pip install "agentpack-cli[watch]" # watchdog — faster file watching for agentpack watch
|
|
1384
|
+
pip install "agentpack-cli[all]" # llm + watch
|
|
1385
|
+
```
|
|
1386
|
+
|
|
1387
|
+
---
|
|
1388
|
+
|
|
1389
|
+
## License
|
|
1390
|
+
|
|
1391
|
+
MIT
|