agentpack-cli 0.1.7__tar.gz → 0.1.8__tar.gz
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_cli-0.1.7 → agentpack_cli-0.1.8}/PKG-INFO +43 -35
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/README.md +39 -34
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/pyproject.toml +7 -2
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/cli.py +2 -2
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/init.py +20 -2
- agentpack_cli-0.1.8/src/agentpack/commands/mcp_cmd.py +13 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/session.py +36 -28
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/watch.py +9 -4
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/installers/claude.py +4 -1
- agentpack_cli-0.1.8/src/agentpack/mcp_server.py +119 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/.gitignore +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/LICENSE +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/__init__.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/adapters/__init__.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/adapters/antigravity.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/adapters/base.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/adapters/claude.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/adapters/codex.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/adapters/cursor.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/adapters/detect.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/adapters/generic.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/adapters/windsurf.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/analysis/__init__.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/analysis/dependency_graph.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/analysis/go_imports.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/analysis/java_imports.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/analysis/js_ts_imports.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/analysis/python_imports.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/analysis/ranking.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/analysis/rust_imports.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/analysis/symbols.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/analysis/tests.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/application/__init__.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/application/pack_service.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/__init__.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/_shared.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/benchmark.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/claude_cmd.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/diff.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/doctor.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/explain.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/install.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/monitor.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/pack.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/scan.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/stats.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/status.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/commands/summarize.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/__init__.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/bootstrap.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/cache.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/config.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/context_pack.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/diff.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/git.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/git_hooks.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/global_install.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/ignore.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/merkle.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/models.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/redactor.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/scanner.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/snapshot.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/token_estimator.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/core/vscode_tasks.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/data/agentpack.md +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/installers/__init__.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/installers/antigravity.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/installers/codex.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/installers/cursor.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/installers/windsurf.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/integrations/__init__.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/integrations/git_hooks.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/integrations/global_install.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/integrations/vscode_tasks.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/renderers/__init__.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/renderers/compact.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/renderers/markdown.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/renderers/receipts.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/session/__init__.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/session/state.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/summaries/__init__.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/summaries/base.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/summaries/llm.py +0 -0
- {agentpack_cli-0.1.7 → agentpack_cli-0.1.8}/src/agentpack/summaries/offline.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentpack-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
4
|
Summary: Token-aware context packing for AI coding agents — Claude, Cursor, Windsurf, and Codex
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -24,6 +24,7 @@ Requires-Dist: tomli>=2.0.0; python_version < '3.11'
|
|
|
24
24
|
Requires-Dist: typer>=0.12.0
|
|
25
25
|
Provides-Extra: all
|
|
26
26
|
Requires-Dist: anthropic>=0.39.0; extra == 'all'
|
|
27
|
+
Requires-Dist: mcp>=1.0.0; extra == 'all'
|
|
27
28
|
Requires-Dist: openai>=1.0.0; extra == 'all'
|
|
28
29
|
Requires-Dist: watchdog>=4.0.0; extra == 'all'
|
|
29
30
|
Provides-Extra: dev
|
|
@@ -34,6 +35,8 @@ Requires-Dist: tomli>=2.0.0; (python_version < '3.11') and extra == 'dev'
|
|
|
34
35
|
Provides-Extra: llm
|
|
35
36
|
Requires-Dist: anthropic>=0.39.0; extra == 'llm'
|
|
36
37
|
Requires-Dist: openai>=1.0.0; extra == 'llm'
|
|
38
|
+
Provides-Extra: mcp
|
|
39
|
+
Requires-Dist: mcp>=1.0.0; extra == 'mcp'
|
|
37
40
|
Provides-Extra: watch
|
|
38
41
|
Requires-Dist: watchdog>=4.0.0; extra == 'watch'
|
|
39
42
|
Description-Content-Type: text/markdown
|
|
@@ -81,12 +84,13 @@ The result: your agent starts every session with a focused, accurate picture of
|
|
|
81
84
|
```bash
|
|
82
85
|
pip install agentpack-cli
|
|
83
86
|
|
|
84
|
-
#
|
|
87
|
+
# One-time setup per project
|
|
85
88
|
cd your-project
|
|
86
|
-
agentpack init
|
|
87
|
-
agentpack install # auto-detects your IDE
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
agentpack init # creates config, session, task.md — nothing else needed
|
|
90
|
+
agentpack install # auto-detects your IDE (optional but recommended)
|
|
91
|
+
|
|
92
|
+
# Every terminal session
|
|
93
|
+
agentpack watch # keeps context fresh automatically — that's it
|
|
90
94
|
```
|
|
91
95
|
|
|
92
96
|
Then open Claude Code / Cursor / Windsurf / Codex / Antigravity and write your task normally. AgentPack keeps `.agentpack/context.md` current.
|
|
@@ -221,17 +225,20 @@ Requires Python 3.10+.
|
|
|
221
225
|
|
|
222
226
|
## Start Once, Then Work Normally
|
|
223
227
|
|
|
224
|
-
The
|
|
228
|
+
The full workflow:
|
|
225
229
|
|
|
226
230
|
```bash
|
|
227
|
-
|
|
228
|
-
agentpack
|
|
229
|
-
agentpack
|
|
231
|
+
# One-time project setup
|
|
232
|
+
agentpack init # creates config, session, task.md
|
|
233
|
+
agentpack install # configure your agent (optional but recommended)
|
|
234
|
+
|
|
235
|
+
# Every terminal session — just one command
|
|
236
|
+
agentpack watch # auto-resumes session, refreshes context on file/task changes
|
|
230
237
|
```
|
|
231
238
|
|
|
232
239
|
Then open Claude Code / Cursor / Codex and write your coding task normally.
|
|
233
240
|
|
|
234
|
-
- AgentPack keeps `.agentpack/context.md` fresh while `watch` is running.
|
|
241
|
+
- AgentPack keeps `.agentpack/context.md` and `.agentpack/context.claude.md` fresh while `watch` is running.
|
|
235
242
|
- To change the task: `agentpack session refresh --task "new task"` — or just tell Claude and it updates `task.md` itself.
|
|
236
243
|
- Check session state: `agentpack session status`
|
|
237
244
|
- Force a refresh: `agentpack session refresh`
|
|
@@ -242,11 +249,11 @@ Then open Claude Code / Cursor / Codex and write your coding task normally.
|
|
|
242
249
|
| Agent | Automation level | Method |
|
|
243
250
|
|---|---|---|
|
|
244
251
|
| Claude Code (hook) | Highest | `UserPromptSubmit` hook auto-injects context |
|
|
245
|
-
| Claude Code (session) | High | `
|
|
246
|
-
| Codex | Medium | `AGENTS.md` + `
|
|
247
|
-
| Cursor | Medium | `.cursor/rules/agentpack.mdc` + `
|
|
248
|
-
| Windsurf | Medium | `.windsurfrules` + `
|
|
249
|
-
| Antigravity | Medium | `.agent/skills/agentpack/SKILL.md` + `GEMINI.md` + `
|
|
252
|
+
| Claude Code (session) | High | `init` + `watch` + read `context.md` |
|
|
253
|
+
| Codex | Medium | `AGENTS.md` + `init` + `watch` |
|
|
254
|
+
| Cursor | Medium | `.cursor/rules/agentpack.mdc` + `init` + `watch` |
|
|
255
|
+
| Windsurf | Medium | `.windsurfrules` + `init` + `watch` |
|
|
256
|
+
| Antigravity | Medium | `.agent/skills/agentpack/SKILL.md` + `GEMINI.md` + `init` + `watch` |
|
|
250
257
|
| Generic | Basic | `watch` mode + read `context.md` |
|
|
251
258
|
|
|
252
259
|
### Honest limitations
|
|
@@ -263,10 +270,9 @@ Then open Claude Code / Cursor / Codex and write your coding task normally.
|
|
|
263
270
|
```bash
|
|
264
271
|
pip install agentpack-cli
|
|
265
272
|
cd your-project
|
|
266
|
-
agentpack init
|
|
273
|
+
agentpack init # one-time setup: config + session + task.md
|
|
267
274
|
agentpack install # auto-detects your IDE (Claude Code, Cursor, Windsurf, Codex, Antigravity)
|
|
268
|
-
agentpack
|
|
269
|
-
agentpack watch # in another terminal — keeps context fresh
|
|
275
|
+
agentpack watch # in another terminal — keeps context fresh automatically
|
|
270
276
|
```
|
|
271
277
|
|
|
272
278
|
Then open your agent and write your task normally.
|
|
@@ -642,22 +648,23 @@ Options:
|
|
|
642
648
|
|
|
643
649
|
### `agentpack session`
|
|
644
650
|
|
|
645
|
-
|
|
651
|
+
Optional session management. `agentpack init` bootstraps the session automatically — `session start` is only needed to change agent/mode after init or force a fresh pack.
|
|
646
652
|
|
|
647
653
|
```bash
|
|
648
|
-
agentpack session start #
|
|
654
|
+
agentpack session start # re-run to change agent/mode or force refresh
|
|
649
655
|
agentpack session start --agent claude # set agent (claude|cursor|codex|generic)
|
|
650
|
-
agentpack session start --task "fix bug" #
|
|
656
|
+
agentpack session start --task "fix bug" # change task + refresh context
|
|
651
657
|
agentpack session status # show session state + context size
|
|
652
658
|
agentpack session refresh # regenerate context now
|
|
653
659
|
agentpack session refresh --task "new task" # change task + refresh
|
|
654
660
|
agentpack session stop # mark session inactive
|
|
655
661
|
```
|
|
656
662
|
|
|
657
|
-
`
|
|
663
|
+
`agentpack init` creates (idempotently):
|
|
658
664
|
- `.agentpack/session.json` — session state
|
|
659
|
-
- `.agentpack/task.md` — current task (
|
|
660
|
-
- `.agentpack/context.md` — readable context pack
|
|
665
|
+
- `.agentpack/task.md` — current task (edit directly or use `session refresh --task`)
|
|
666
|
+
- `.agentpack/context.md` — readable context pack (updated by `watch`)
|
|
667
|
+
- `.agentpack/context.claude.md` — Claude Code format (always written alongside context.md)
|
|
661
668
|
- `.agentpack/context.compact.md` — compact protocol format
|
|
662
669
|
|
|
663
670
|
---
|
|
@@ -688,7 +695,7 @@ Launch Claude CLI with an up-to-date context.
|
|
|
688
695
|
agentpack claude
|
|
689
696
|
```
|
|
690
697
|
|
|
691
|
-
Requires an
|
|
698
|
+
Requires an initialized project (`agentpack init`). Refreshes context, prints the context path, then launches `claude` if found. Transparent about what it does — no fake prompt injection.
|
|
692
699
|
|
|
693
700
|
---
|
|
694
701
|
|
|
@@ -1240,13 +1247,14 @@ Add to `.github/workflows/agentpack-context.yml` — see the full example in [CI
|
|
|
1240
1247
|
### Session mode: keep context fresh while you work
|
|
1241
1248
|
|
|
1242
1249
|
```bash
|
|
1243
|
-
#
|
|
1244
|
-
agentpack
|
|
1245
|
-
|
|
1250
|
+
# One-time project setup
|
|
1251
|
+
agentpack init --task "refactor auth" # or edit .agentpack/task.md directly
|
|
1252
|
+
|
|
1253
|
+
# Every terminal session — just one command
|
|
1254
|
+
agentpack watch # auto-resumes session, refreshes context on every save
|
|
1246
1255
|
|
|
1247
|
-
#
|
|
1248
|
-
|
|
1249
|
-
# Change task: agentpack session refresh --task "new task"
|
|
1256
|
+
# Change task mid-session
|
|
1257
|
+
agentpack session refresh --task "new task"
|
|
1250
1258
|
```
|
|
1251
1259
|
|
|
1252
1260
|
---
|
|
@@ -1316,8 +1324,8 @@ agentpack pack --task "fix bug" --budget 40000 # explicit token cap
|
|
|
1316
1324
|
### Watch mode for active sessions
|
|
1317
1325
|
|
|
1318
1326
|
```bash
|
|
1319
|
-
agentpack session
|
|
1320
|
-
agentpack watch
|
|
1327
|
+
agentpack init # one-time setup (creates session + task.md)
|
|
1328
|
+
agentpack watch # in another terminal — auto-resumes each time
|
|
1321
1329
|
```
|
|
1322
1330
|
|
|
1323
1331
|
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.
|
|
@@ -1360,7 +1368,7 @@ config_file = 60 # was 25 — configs always matter here
|
|
|
1360
1368
|
- **Local-first**: `init`, `scan`, `diff`, `pack`, `stats`, `summarize` make zero API calls by default
|
|
1361
1369
|
- **Non-destructive**: never overwrites user files; config patching only touches agentpack-managed blocks
|
|
1362
1370
|
- **Agent-neutral**: architecture is generic; Claude Code is the primary target (deepest integration); Cursor, Windsurf, Codex, and Antigravity are supported but less battle-tested
|
|
1363
|
-
- **No daemons**: file watching is opt-in via `agentpack watch`;
|
|
1371
|
+
- **No daemons**: file watching is opt-in via `agentpack watch`; git hooks run in the background and are opt-in via `install`
|
|
1364
1372
|
- **Honest**: packed token count reflects real content, not raw repo size
|
|
1365
1373
|
|
|
1366
1374
|
---
|
|
@@ -41,12 +41,13 @@ The result: your agent starts every session with a focused, accurate picture of
|
|
|
41
41
|
```bash
|
|
42
42
|
pip install agentpack-cli
|
|
43
43
|
|
|
44
|
-
#
|
|
44
|
+
# One-time setup per project
|
|
45
45
|
cd your-project
|
|
46
|
-
agentpack init
|
|
47
|
-
agentpack install # auto-detects your IDE
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
agentpack init # creates config, session, task.md — nothing else needed
|
|
47
|
+
agentpack install # auto-detects your IDE (optional but recommended)
|
|
48
|
+
|
|
49
|
+
# Every terminal session
|
|
50
|
+
agentpack watch # keeps context fresh automatically — that's it
|
|
50
51
|
```
|
|
51
52
|
|
|
52
53
|
Then open Claude Code / Cursor / Windsurf / Codex / Antigravity and write your task normally. AgentPack keeps `.agentpack/context.md` current.
|
|
@@ -181,17 +182,20 @@ Requires Python 3.10+.
|
|
|
181
182
|
|
|
182
183
|
## Start Once, Then Work Normally
|
|
183
184
|
|
|
184
|
-
The
|
|
185
|
+
The full workflow:
|
|
185
186
|
|
|
186
187
|
```bash
|
|
187
|
-
|
|
188
|
-
agentpack
|
|
189
|
-
agentpack
|
|
188
|
+
# One-time project setup
|
|
189
|
+
agentpack init # creates config, session, task.md
|
|
190
|
+
agentpack install # configure your agent (optional but recommended)
|
|
191
|
+
|
|
192
|
+
# Every terminal session — just one command
|
|
193
|
+
agentpack watch # auto-resumes session, refreshes context on file/task changes
|
|
190
194
|
```
|
|
191
195
|
|
|
192
196
|
Then open Claude Code / Cursor / Codex and write your coding task normally.
|
|
193
197
|
|
|
194
|
-
- AgentPack keeps `.agentpack/context.md` fresh while `watch` is running.
|
|
198
|
+
- AgentPack keeps `.agentpack/context.md` and `.agentpack/context.claude.md` fresh while `watch` is running.
|
|
195
199
|
- To change the task: `agentpack session refresh --task "new task"` — or just tell Claude and it updates `task.md` itself.
|
|
196
200
|
- Check session state: `agentpack session status`
|
|
197
201
|
- Force a refresh: `agentpack session refresh`
|
|
@@ -202,11 +206,11 @@ Then open Claude Code / Cursor / Codex and write your coding task normally.
|
|
|
202
206
|
| Agent | Automation level | Method |
|
|
203
207
|
|---|---|---|
|
|
204
208
|
| Claude Code (hook) | Highest | `UserPromptSubmit` hook auto-injects context |
|
|
205
|
-
| Claude Code (session) | High | `
|
|
206
|
-
| Codex | Medium | `AGENTS.md` + `
|
|
207
|
-
| Cursor | Medium | `.cursor/rules/agentpack.mdc` + `
|
|
208
|
-
| Windsurf | Medium | `.windsurfrules` + `
|
|
209
|
-
| Antigravity | Medium | `.agent/skills/agentpack/SKILL.md` + `GEMINI.md` + `
|
|
209
|
+
| Claude Code (session) | High | `init` + `watch` + read `context.md` |
|
|
210
|
+
| Codex | Medium | `AGENTS.md` + `init` + `watch` |
|
|
211
|
+
| Cursor | Medium | `.cursor/rules/agentpack.mdc` + `init` + `watch` |
|
|
212
|
+
| Windsurf | Medium | `.windsurfrules` + `init` + `watch` |
|
|
213
|
+
| Antigravity | Medium | `.agent/skills/agentpack/SKILL.md` + `GEMINI.md` + `init` + `watch` |
|
|
210
214
|
| Generic | Basic | `watch` mode + read `context.md` |
|
|
211
215
|
|
|
212
216
|
### Honest limitations
|
|
@@ -223,10 +227,9 @@ Then open Claude Code / Cursor / Codex and write your coding task normally.
|
|
|
223
227
|
```bash
|
|
224
228
|
pip install agentpack-cli
|
|
225
229
|
cd your-project
|
|
226
|
-
agentpack init
|
|
230
|
+
agentpack init # one-time setup: config + session + task.md
|
|
227
231
|
agentpack install # auto-detects your IDE (Claude Code, Cursor, Windsurf, Codex, Antigravity)
|
|
228
|
-
agentpack
|
|
229
|
-
agentpack watch # in another terminal — keeps context fresh
|
|
232
|
+
agentpack watch # in another terminal — keeps context fresh automatically
|
|
230
233
|
```
|
|
231
234
|
|
|
232
235
|
Then open your agent and write your task normally.
|
|
@@ -602,22 +605,23 @@ Options:
|
|
|
602
605
|
|
|
603
606
|
### `agentpack session`
|
|
604
607
|
|
|
605
|
-
|
|
608
|
+
Optional session management. `agentpack init` bootstraps the session automatically — `session start` is only needed to change agent/mode after init or force a fresh pack.
|
|
606
609
|
|
|
607
610
|
```bash
|
|
608
|
-
agentpack session start #
|
|
611
|
+
agentpack session start # re-run to change agent/mode or force refresh
|
|
609
612
|
agentpack session start --agent claude # set agent (claude|cursor|codex|generic)
|
|
610
|
-
agentpack session start --task "fix bug" #
|
|
613
|
+
agentpack session start --task "fix bug" # change task + refresh context
|
|
611
614
|
agentpack session status # show session state + context size
|
|
612
615
|
agentpack session refresh # regenerate context now
|
|
613
616
|
agentpack session refresh --task "new task" # change task + refresh
|
|
614
617
|
agentpack session stop # mark session inactive
|
|
615
618
|
```
|
|
616
619
|
|
|
617
|
-
`
|
|
620
|
+
`agentpack init` creates (idempotently):
|
|
618
621
|
- `.agentpack/session.json` — session state
|
|
619
|
-
- `.agentpack/task.md` — current task (
|
|
620
|
-
- `.agentpack/context.md` — readable context pack
|
|
622
|
+
- `.agentpack/task.md` — current task (edit directly or use `session refresh --task`)
|
|
623
|
+
- `.agentpack/context.md` — readable context pack (updated by `watch`)
|
|
624
|
+
- `.agentpack/context.claude.md` — Claude Code format (always written alongside context.md)
|
|
621
625
|
- `.agentpack/context.compact.md` — compact protocol format
|
|
622
626
|
|
|
623
627
|
---
|
|
@@ -648,7 +652,7 @@ Launch Claude CLI with an up-to-date context.
|
|
|
648
652
|
agentpack claude
|
|
649
653
|
```
|
|
650
654
|
|
|
651
|
-
Requires an
|
|
655
|
+
Requires an initialized project (`agentpack init`). Refreshes context, prints the context path, then launches `claude` if found. Transparent about what it does — no fake prompt injection.
|
|
652
656
|
|
|
653
657
|
---
|
|
654
658
|
|
|
@@ -1200,13 +1204,14 @@ Add to `.github/workflows/agentpack-context.yml` — see the full example in [CI
|
|
|
1200
1204
|
### Session mode: keep context fresh while you work
|
|
1201
1205
|
|
|
1202
1206
|
```bash
|
|
1203
|
-
#
|
|
1204
|
-
agentpack
|
|
1205
|
-
|
|
1207
|
+
# One-time project setup
|
|
1208
|
+
agentpack init --task "refactor auth" # or edit .agentpack/task.md directly
|
|
1209
|
+
|
|
1210
|
+
# Every terminal session — just one command
|
|
1211
|
+
agentpack watch # auto-resumes session, refreshes context on every save
|
|
1206
1212
|
|
|
1207
|
-
#
|
|
1208
|
-
|
|
1209
|
-
# Change task: agentpack session refresh --task "new task"
|
|
1213
|
+
# Change task mid-session
|
|
1214
|
+
agentpack session refresh --task "new task"
|
|
1210
1215
|
```
|
|
1211
1216
|
|
|
1212
1217
|
---
|
|
@@ -1276,8 +1281,8 @@ agentpack pack --task "fix bug" --budget 40000 # explicit token cap
|
|
|
1276
1281
|
### Watch mode for active sessions
|
|
1277
1282
|
|
|
1278
1283
|
```bash
|
|
1279
|
-
agentpack session
|
|
1280
|
-
agentpack watch
|
|
1284
|
+
agentpack init # one-time setup (creates session + task.md)
|
|
1285
|
+
agentpack watch # in another terminal — auto-resumes each time
|
|
1281
1286
|
```
|
|
1282
1287
|
|
|
1283
1288
|
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.
|
|
@@ -1320,7 +1325,7 @@ config_file = 60 # was 25 — configs always matter here
|
|
|
1320
1325
|
- **Local-first**: `init`, `scan`, `diff`, `pack`, `stats`, `summarize` make zero API calls by default
|
|
1321
1326
|
- **Non-destructive**: never overwrites user files; config patching only touches agentpack-managed blocks
|
|
1322
1327
|
- **Agent-neutral**: architecture is generic; Claude Code is the primary target (deepest integration); Cursor, Windsurf, Codex, and Antigravity are supported but less battle-tested
|
|
1323
|
-
- **No daemons**: file watching is opt-in via `agentpack watch`;
|
|
1328
|
+
- **No daemons**: file watching is opt-in via `agentpack watch`; git hooks run in the background and are opt-in via `install`
|
|
1324
1329
|
- **Honest**: packed token count reflects real content, not raw repo size
|
|
1325
1330
|
|
|
1326
1331
|
---
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "agentpack-cli"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.8"
|
|
4
4
|
description = "Token-aware context packing for AI coding agents — Claude, Cursor, Windsurf, and Codex"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
@@ -40,10 +40,15 @@ watch = [
|
|
|
40
40
|
"watchdog>=4.0.0"
|
|
41
41
|
]
|
|
42
42
|
|
|
43
|
+
mcp = [
|
|
44
|
+
"mcp>=1.0.0"
|
|
45
|
+
]
|
|
46
|
+
|
|
43
47
|
all = [
|
|
44
48
|
"anthropic>=0.39.0",
|
|
45
49
|
"openai>=1.0.0",
|
|
46
|
-
"watchdog>=4.0.0"
|
|
50
|
+
"watchdog>=4.0.0",
|
|
51
|
+
"mcp>=1.0.0"
|
|
47
52
|
]
|
|
48
53
|
|
|
49
54
|
dev = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import typer
|
|
4
|
-
from agentpack.commands import init, scan, diff, status, stats, summarize, pack, install, monitor, explain, doctor, session, watch, claude_cmd, benchmark
|
|
4
|
+
from agentpack.commands import init, scan, diff, status, stats, summarize, pack, install, monitor, explain, doctor, session, watch, claude_cmd, benchmark, mcp_cmd
|
|
5
5
|
from agentpack import __version__
|
|
6
6
|
|
|
7
7
|
|
|
@@ -21,7 +21,7 @@ def _main(
|
|
|
21
21
|
pass
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
for mod in [init, scan, diff, status, stats, summarize, pack, install, monitor, explain, doctor, session, watch, claude_cmd, benchmark]:
|
|
24
|
+
for mod in [init, scan, diff, status, stats, summarize, pack, install, monitor, explain, doctor, session, watch, claude_cmd, benchmark, mcp_cmd]:
|
|
25
25
|
mod.register(app)
|
|
26
26
|
|
|
27
27
|
|
|
@@ -8,6 +8,7 @@ import typer
|
|
|
8
8
|
from agentpack.core.config import DEFAULT_CONFIG, CONFIG_TEMPLATE, save_config
|
|
9
9
|
from agentpack.core.ignore import DEFAULT_AGENTIGNORE
|
|
10
10
|
from agentpack.commands._shared import console, _root
|
|
11
|
+
from agentpack.session.state import load_session, create_session, save_session, SESSION_FILE, TASK_FILE
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
def register(app: typer.Typer) -> None:
|
|
@@ -19,8 +20,12 @@ def register(app: typer.Typer) -> None:
|
|
|
19
20
|
yes: bool = typer.Option(False, "--yes", "-y", help="Skip interactive prompts, use defaults."),
|
|
20
21
|
silent: bool = typer.Option(False, "--silent", help="Suppress all output (for use in hooks/scripts)."),
|
|
21
22
|
share_cache: bool = typer.Option(False, "--share-cache", help="Commit summary cache to git (recommended for teams)."),
|
|
23
|
+
agent: str = typer.Option("auto", "--agent", help="Target agent (auto|claude|cursor|windsurf|codex|antigravity|generic)."),
|
|
22
24
|
) -> None:
|
|
23
|
-
"""Initialize AgentPack in the current directory.
|
|
25
|
+
"""Initialize AgentPack in the current directory.
|
|
26
|
+
|
|
27
|
+
One-time setup. After this, just run `agentpack watch` — no other commands needed.
|
|
28
|
+
"""
|
|
24
29
|
if silent:
|
|
25
30
|
yes = True
|
|
26
31
|
console.quiet = True
|
|
@@ -85,5 +90,18 @@ def register(app: typer.Typer) -> None:
|
|
|
85
90
|
else:
|
|
86
91
|
console.print("[dim]Skipped[/] .agentignore (exists)")
|
|
87
92
|
|
|
93
|
+
# Bootstrap session so `agentpack watch` works immediately — no separate `session start` needed
|
|
94
|
+
from agentpack.core.config import load_config
|
|
95
|
+
resolved_mode = load_config(root).context.default_mode
|
|
96
|
+
existing_session = load_session(root)
|
|
97
|
+
if existing_session is None or force:
|
|
98
|
+
from agentpack.adapters.detect import detect_agent
|
|
99
|
+
resolved_agent = agent if agent != "auto" else detect_agent(root)
|
|
100
|
+
session_state = create_session(root, agent=resolved_agent, mode=resolved_mode)
|
|
101
|
+
console.print(f"[green]Created[/] {SESSION_FILE} [dim]agent={resolved_agent} mode={resolved_mode}[/]")
|
|
102
|
+
console.print(f"[green]Created[/] {TASK_FILE} [dim]edit to set your task[/]")
|
|
103
|
+
else:
|
|
104
|
+
console.print(f"[dim]Skipped[/] {SESSION_FILE} (exists)")
|
|
105
|
+
|
|
88
106
|
console.print("\n[bold green]AgentPack initialized.[/]")
|
|
89
|
-
console.print("Run [bold]agentpack
|
|
107
|
+
console.print("Run [bold]agentpack watch[/] to start auto-refreshing context.")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
|
|
5
|
+
from agentpack.commands._shared import console
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def register(app: typer.Typer) -> None:
|
|
9
|
+
@app.command("mcp")
|
|
10
|
+
def mcp_server() -> None:
|
|
11
|
+
"""Start the AgentPack MCP server (tools: pack_context, get_context, refresh)."""
|
|
12
|
+
from agentpack.mcp_server import serve
|
|
13
|
+
serve()
|
|
@@ -28,41 +28,46 @@ def register(app: typer.Typer) -> None:
|
|
|
28
28
|
budget: int = typer.Option(0, "--budget", help="Token budget (0 = config default)."),
|
|
29
29
|
silent: bool = typer.Option(False, "--silent", help="Suppress all output (for use in hooks/scripts)."),
|
|
30
30
|
) -> None:
|
|
31
|
-
"""
|
|
31
|
+
"""Refresh session and generate context. Optional — `agentpack init` already bootstraps the session.
|
|
32
|
+
|
|
33
|
+
Use this to change agent/mode after init, or to force a fresh context pack.
|
|
34
|
+
Idempotent: resumes existing session rather than recreating it.
|
|
35
|
+
"""
|
|
32
36
|
root = _root()
|
|
33
37
|
if silent:
|
|
34
38
|
console.quiet = True
|
|
35
|
-
|
|
39
|
+
|
|
40
|
+
existing = load_session(root)
|
|
41
|
+
if existing is not None:
|
|
42
|
+
# Resume: update agent/mode only if explicitly passed, then refresh
|
|
43
|
+
if agent != "auto":
|
|
44
|
+
existing.agent = agent
|
|
45
|
+
if mode != "balanced" or existing.agent == "generic":
|
|
46
|
+
# only override mode if user explicitly chose non-default
|
|
47
|
+
if mode != "balanced":
|
|
48
|
+
existing.mode = mode
|
|
49
|
+
existing.active = True
|
|
50
|
+
save_session(root, existing)
|
|
51
|
+
state = existing
|
|
52
|
+
console.print("[dim]Session resumed.[/]")
|
|
53
|
+
else:
|
|
54
|
+
state = create_session(root, agent=agent, mode=mode)
|
|
55
|
+
console.print()
|
|
56
|
+
console.print("[bold green]AgentPack session initialized.[/]")
|
|
57
|
+
console.print()
|
|
58
|
+
console.print(f" [green]✓[/] {SESSION_FILE} [dim]session state[/]")
|
|
59
|
+
console.print(f" [green]✓[/] {TASK_FILE} [dim]edit to set your task[/]")
|
|
36
60
|
|
|
37
61
|
if task:
|
|
38
62
|
(root / TASK_FILE).write_text(f"# Current Task\n\n{task}\n", encoding="utf-8")
|
|
39
63
|
|
|
40
|
-
console.print()
|
|
41
|
-
console.print("[bold green]AgentPack session started.[/]")
|
|
42
|
-
console.print()
|
|
43
|
-
|
|
44
|
-
created: list[tuple[str, str]] = [
|
|
45
|
-
(SESSION_FILE, "session state"),
|
|
46
|
-
(TASK_FILE, "edit to set your task"),
|
|
47
|
-
]
|
|
48
|
-
|
|
49
64
|
result = _run_refresh(root, state.agent, state.mode, budget)
|
|
50
65
|
if result:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
(COMPACT_FILE, "compact protocol format"),
|
|
54
|
-
]
|
|
55
|
-
log_activity(root, f"session started — {result['files']} files, {result['tokens']:,} tokens")
|
|
66
|
+
console.print(f" [green]✓[/] {CONTEXT_FILE} [dim]{result['files']} files, {result['tokens']:,} tokens[/]")
|
|
67
|
+
log_activity(root, f"session start — {result['files']} files, {result['tokens']:,} tokens")
|
|
56
68
|
else:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
(COMPACT_FILE, "will generate on first refresh"),
|
|
60
|
-
]
|
|
61
|
-
log_activity(root, "session started (context generation deferred)")
|
|
62
|
-
|
|
63
|
-
console.print("[bold]Created:[/]")
|
|
64
|
-
for path, note in created:
|
|
65
|
-
console.print(f" [green]✓[/] {path} [dim]{note}[/]")
|
|
69
|
+
console.print(f" [dim]✗ context generation failed — run agentpack session refresh[/]")
|
|
70
|
+
log_activity(root, "session start (context generation failed)")
|
|
66
71
|
|
|
67
72
|
console.print()
|
|
68
73
|
console.print("[bold]Next:[/]")
|
|
@@ -176,11 +181,14 @@ def _run_refresh(
|
|
|
176
181
|
))
|
|
177
182
|
|
|
178
183
|
# Write context files atomically — avoids partial reads if interrupted mid-write
|
|
179
|
-
from agentpack.renderers.markdown import render_generic
|
|
180
|
-
context_text = render_generic(result.pack)
|
|
184
|
+
from agentpack.renderers.markdown import render_generic, render_claude
|
|
181
185
|
context_path = root / CONTEXT_FILE
|
|
182
186
|
context_path.parent.mkdir(parents=True, exist_ok=True)
|
|
183
|
-
_atomic_write(context_path,
|
|
187
|
+
_atomic_write(context_path, render_generic(result.pack))
|
|
188
|
+
|
|
189
|
+
# Always write the claude-specific format too — the Claude Code hook reads this
|
|
190
|
+
# regardless of which agent the session was started with.
|
|
191
|
+
_atomic_write(root / ".agentpack/context.claude.md", render_claude(result.pack))
|
|
184
192
|
|
|
185
193
|
compact_text = render_compact(result.pack)
|
|
186
194
|
compact_path = root / COMPACT_FILE
|
|
@@ -34,13 +34,18 @@ def register(app: typer.Typer) -> None:
|
|
|
34
34
|
root = _root()
|
|
35
35
|
state = load_session(root)
|
|
36
36
|
|
|
37
|
+
# Auto-resume: if session exists but inactive, reactivate without requiring `session start`
|
|
38
|
+
if state is not None and not state.active:
|
|
39
|
+
state.active = True
|
|
40
|
+
save_session(root, state)
|
|
41
|
+
console.print("[dim]Resumed session.[/]")
|
|
42
|
+
elif state is None:
|
|
43
|
+
console.print("[yellow]No session found — watching in stateless mode.[/]")
|
|
44
|
+
console.print("[dim]Run 'agentpack session start' to persist agent/mode preferences.[/]")
|
|
45
|
+
|
|
37
46
|
effective_agent = agent or (state.agent if state else "generic")
|
|
38
47
|
effective_mode = mode or (state.mode if state else "balanced")
|
|
39
48
|
|
|
40
|
-
if state is None:
|
|
41
|
-
console.print("[yellow]No session found — watching in stateless mode.[/]")
|
|
42
|
-
console.print("[dim]Run 'agentpack session start' for full session support.[/]")
|
|
43
|
-
|
|
44
49
|
console.print()
|
|
45
50
|
console.print("[bold]AgentPack watch active.[/]")
|
|
46
51
|
console.print("Press Ctrl+C to stop.")
|
|
@@ -72,9 +72,12 @@ class ClaudeInstaller:
|
|
|
72
72
|
|
|
73
73
|
# SessionStart: delete sentinel + kick off background repack so first prompt
|
|
74
74
|
# gets fresh context without blocking the session.
|
|
75
|
+
# Use session refresh if session exists (respects task.md), else fall back to pack.
|
|
75
76
|
sentinel_cmd = (
|
|
76
77
|
"rm -f .agentpack/.context_injected"
|
|
77
|
-
" &&
|
|
78
|
+
" && ([ -f .agentpack/session.json ]"
|
|
79
|
+
" && agentpack session refresh >/dev/null 2>&1"
|
|
80
|
+
" || agentpack pack --task auto --mode balanced >/dev/null 2>&1) &"
|
|
78
81
|
)
|
|
79
82
|
session_start = hooks.setdefault("SessionStart", [])
|
|
80
83
|
# Replace any stale agentpack session hooks (old cmd only deleted sentinel).
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""AgentPack MCP server — exposes context packing as MCP tools.
|
|
2
|
+
|
|
3
|
+
Start with:
|
|
4
|
+
agentpack mcp
|
|
5
|
+
|
|
6
|
+
Or register in Claude Code settings:
|
|
7
|
+
{
|
|
8
|
+
"mcpServers": {
|
|
9
|
+
"agentpack": {
|
|
10
|
+
"command": "agentpack",
|
|
11
|
+
"args": ["mcp"]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Tools exposed:
|
|
17
|
+
pack_context — generate/refresh a context pack for a task
|
|
18
|
+
get_context — read the latest context pack (no repack)
|
|
19
|
+
refresh — refresh using the current task.md
|
|
20
|
+
"""
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import sys
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _repo_root() -> Path:
|
|
28
|
+
"""Walk up from cwd until .agentpack/ found; fall back to cwd."""
|
|
29
|
+
cwd = Path.cwd()
|
|
30
|
+
for parent in [cwd, *cwd.parents]:
|
|
31
|
+
if (parent / ".agentpack").exists():
|
|
32
|
+
return parent
|
|
33
|
+
return cwd
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def serve() -> None:
|
|
37
|
+
try:
|
|
38
|
+
from mcp.server.fastmcp import FastMCP
|
|
39
|
+
except ImportError:
|
|
40
|
+
print(
|
|
41
|
+
"mcp package required for MCP server. "
|
|
42
|
+
"Install: pip install 'agentpack-cli[mcp]'",
|
|
43
|
+
file=sys.stderr,
|
|
44
|
+
)
|
|
45
|
+
sys.exit(1)
|
|
46
|
+
|
|
47
|
+
mcp = FastMCP("agentpack")
|
|
48
|
+
|
|
49
|
+
@mcp.tool()
|
|
50
|
+
def pack_context(task: str, mode: str = "balanced", budget: int = 0) -> str:
|
|
51
|
+
"""Generate a ranked context pack for the given task.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
task: Describe what you're working on (e.g. "fix auth token refresh").
|
|
55
|
+
mode: minimal | balanced (default) | deep
|
|
56
|
+
budget: Token budget, 0 = config default (usually 25000).
|
|
57
|
+
|
|
58
|
+
Returns the packed context as a markdown string.
|
|
59
|
+
"""
|
|
60
|
+
from agentpack.application.pack_service import PackService, PackRequest
|
|
61
|
+
from agentpack.adapters.detect import detect_agent
|
|
62
|
+
from agentpack.renderers.markdown import render_claude
|
|
63
|
+
|
|
64
|
+
root = _repo_root()
|
|
65
|
+
agent = detect_agent(root)
|
|
66
|
+
result = PackService().run(PackRequest(
|
|
67
|
+
root=root,
|
|
68
|
+
agent=agent,
|
|
69
|
+
task=task,
|
|
70
|
+
mode=mode,
|
|
71
|
+
budget=budget,
|
|
72
|
+
since=None,
|
|
73
|
+
refresh=False,
|
|
74
|
+
summary_provider="offline",
|
|
75
|
+
))
|
|
76
|
+
return render_claude(result.pack)
|
|
77
|
+
|
|
78
|
+
@mcp.tool()
|
|
79
|
+
def get_context() -> str:
|
|
80
|
+
"""Return the latest pre-built context pack without repacking.
|
|
81
|
+
|
|
82
|
+
Fast — just reads the cached file. Use pack_context() to regenerate.
|
|
83
|
+
Returns empty string if no pack exists yet.
|
|
84
|
+
"""
|
|
85
|
+
root = _repo_root()
|
|
86
|
+
for candidate in (
|
|
87
|
+
root / ".agentpack" / "context.claude.md",
|
|
88
|
+
root / ".agentpack" / "context.md",
|
|
89
|
+
):
|
|
90
|
+
if candidate.exists():
|
|
91
|
+
return candidate.read_text(encoding="utf-8")
|
|
92
|
+
return ""
|
|
93
|
+
|
|
94
|
+
@mcp.tool()
|
|
95
|
+
def refresh() -> str:
|
|
96
|
+
"""Refresh context using the current task.md (or git-inferred task).
|
|
97
|
+
|
|
98
|
+
Equivalent to running `agentpack session refresh`.
|
|
99
|
+
Returns summary of what was packed.
|
|
100
|
+
"""
|
|
101
|
+
from agentpack.commands.session import _run_refresh
|
|
102
|
+
from agentpack.session.state import load_session
|
|
103
|
+
from agentpack.adapters.detect import detect_agent
|
|
104
|
+
|
|
105
|
+
root = _repo_root()
|
|
106
|
+
state = load_session(root)
|
|
107
|
+
agent = state.agent if state else detect_agent(root)
|
|
108
|
+
mode = state.mode if state else "balanced"
|
|
109
|
+
|
|
110
|
+
result = _run_refresh(root, agent, mode, 0)
|
|
111
|
+
if result is None:
|
|
112
|
+
return "Refresh failed."
|
|
113
|
+
return (
|
|
114
|
+
f"Refreshed: {result['files']} files, "
|
|
115
|
+
f"{result['tokens']:,} tokens, "
|
|
116
|
+
f"{result['saving']:.1f}% saving"
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
mcp.run()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|