agentpack-cli 0.1.7__tar.gz → 0.1.9__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.
Files changed (88) hide show
  1. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/PKG-INFO +92 -53
  2. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/README.md +88 -47
  3. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/pyproject.toml +10 -9
  4. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/__init__.py +1 -1
  5. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/application/pack_service.py +1 -2
  6. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/cli.py +2 -2
  7. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/benchmark.py +0 -1
  8. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/explain.py +0 -2
  9. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/init.py +20 -2
  10. agentpack_cli-0.1.9/src/agentpack/commands/mcp_cmd.py +13 -0
  11. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/pack.py +2 -5
  12. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/session.py +36 -29
  13. agentpack_cli-0.1.9/src/agentpack/commands/summarize.py +51 -0
  14. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/watch.py +9 -4
  15. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/installers/claude.py +4 -1
  16. agentpack_cli-0.1.9/src/agentpack/mcp_server.py +195 -0
  17. agentpack_cli-0.1.9/src/agentpack/summaries/base.py +93 -0
  18. agentpack_cli-0.1.9/src/agentpack/summaries/offline.py +148 -0
  19. agentpack_cli-0.1.7/src/agentpack/commands/summarize.py +0 -64
  20. agentpack_cli-0.1.7/src/agentpack/summaries/base.py +0 -42
  21. agentpack_cli-0.1.7/src/agentpack/summaries/llm.py +0 -100
  22. agentpack_cli-0.1.7/src/agentpack/summaries/offline.py +0 -97
  23. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/.gitignore +0 -0
  24. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/LICENSE +0 -0
  25. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/adapters/__init__.py +0 -0
  26. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/adapters/antigravity.py +0 -0
  27. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/adapters/base.py +0 -0
  28. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/adapters/claude.py +0 -0
  29. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/adapters/codex.py +0 -0
  30. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/adapters/cursor.py +0 -0
  31. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/adapters/detect.py +0 -0
  32. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/adapters/generic.py +0 -0
  33. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/adapters/windsurf.py +0 -0
  34. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/analysis/__init__.py +0 -0
  35. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/analysis/dependency_graph.py +0 -0
  36. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/analysis/go_imports.py +0 -0
  37. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/analysis/java_imports.py +0 -0
  38. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/analysis/js_ts_imports.py +0 -0
  39. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/analysis/python_imports.py +0 -0
  40. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/analysis/ranking.py +0 -0
  41. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/analysis/rust_imports.py +0 -0
  42. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/analysis/symbols.py +0 -0
  43. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/analysis/tests.py +0 -0
  44. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/application/__init__.py +0 -0
  45. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/__init__.py +0 -0
  46. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/_shared.py +0 -0
  47. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/claude_cmd.py +0 -0
  48. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/diff.py +0 -0
  49. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/doctor.py +0 -0
  50. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/install.py +0 -0
  51. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/monitor.py +0 -0
  52. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/scan.py +0 -0
  53. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/stats.py +0 -0
  54. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/commands/status.py +0 -0
  55. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/__init__.py +0 -0
  56. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/bootstrap.py +0 -0
  57. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/cache.py +0 -0
  58. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/config.py +0 -0
  59. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/context_pack.py +0 -0
  60. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/diff.py +0 -0
  61. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/git.py +0 -0
  62. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/git_hooks.py +0 -0
  63. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/global_install.py +0 -0
  64. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/ignore.py +0 -0
  65. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/merkle.py +0 -0
  66. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/models.py +0 -0
  67. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/redactor.py +0 -0
  68. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/scanner.py +0 -0
  69. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/snapshot.py +0 -0
  70. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/token_estimator.py +0 -0
  71. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/core/vscode_tasks.py +0 -0
  72. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/data/agentpack.md +0 -0
  73. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/installers/__init__.py +0 -0
  74. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/installers/antigravity.py +0 -0
  75. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/installers/codex.py +0 -0
  76. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/installers/cursor.py +0 -0
  77. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/installers/windsurf.py +0 -0
  78. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/integrations/__init__.py +0 -0
  79. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/integrations/git_hooks.py +0 -0
  80. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/integrations/global_install.py +0 -0
  81. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/integrations/vscode_tasks.py +0 -0
  82. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/renderers/__init__.py +0 -0
  83. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/renderers/compact.py +0 -0
  84. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/renderers/markdown.py +0 -0
  85. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/renderers/receipts.py +0 -0
  86. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/session/__init__.py +0 -0
  87. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/session/state.py +0 -0
  88. {agentpack_cli-0.1.7 → agentpack_cli-0.1.9}/src/agentpack/summaries/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentpack-cli
3
- Version: 0.1.7
3
+ Version: 0.1.9
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
@@ -23,17 +23,15 @@ Requires-Dist: tomli-w>=1.0.0
23
23
  Requires-Dist: tomli>=2.0.0; python_version < '3.11'
24
24
  Requires-Dist: typer>=0.12.0
25
25
  Provides-Extra: all
26
- Requires-Dist: anthropic>=0.39.0; extra == 'all'
27
- Requires-Dist: openai>=1.0.0; extra == 'all'
26
+ Requires-Dist: mcp>=1.0.0; extra == 'all'
28
27
  Requires-Dist: watchdog>=4.0.0; extra == 'all'
29
28
  Provides-Extra: dev
30
29
  Requires-Dist: mypy; extra == 'dev'
31
30
  Requires-Dist: pytest; extra == 'dev'
32
31
  Requires-Dist: ruff; extra == 'dev'
33
32
  Requires-Dist: tomli>=2.0.0; (python_version < '3.11') and extra == 'dev'
34
- Provides-Extra: llm
35
- Requires-Dist: anthropic>=0.39.0; extra == 'llm'
36
- Requires-Dist: openai>=1.0.0; extra == 'llm'
33
+ Provides-Extra: mcp
34
+ Requires-Dist: mcp>=1.0.0; extra == 'mcp'
37
35
  Provides-Extra: watch
38
36
  Requires-Dist: watchdog>=4.0.0; extra == 'watch'
39
37
  Description-Content-Type: text/markdown
@@ -45,7 +43,7 @@ Description-Content-Type: text/markdown
45
43
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
46
44
  [![CI](https://github.com/vishal2612200/agentpack/actions/workflows/ci.yml/badge.svg)](https://github.com/vishal2612200/agentpack/actions/workflows/ci.yml)
47
45
 
48
- > **Status: alpha (v0.1.5).** 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.
46
+ > **Status: alpha (v0.1.9).** 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.
49
47
  >
50
48
  > **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.
51
49
 
@@ -81,12 +79,13 @@ The result: your agent starts every session with a focused, accurate picture of
81
79
  ```bash
82
80
  pip install agentpack-cli
83
81
 
84
- # Session mode: start once, then work normally
82
+ # One-time setup per project
85
83
  cd your-project
86
- agentpack init
87
- agentpack install # auto-detects your IDE
88
- agentpack session start
89
- agentpack watch # in another terminal — keeps context fresh automatically
84
+ agentpack init # creates config, session, task.md — nothing else needed
85
+ agentpack install # auto-detects your IDE (optional but recommended)
86
+
87
+ # Every terminal session
88
+ agentpack watch # keeps context fresh automatically — that's it
90
89
  ```
91
90
 
92
91
  Then open Claude Code / Cursor / Windsurf / Codex / Antigravity and write your task normally. AgentPack keeps `.agentpack/context.md` current.
@@ -221,17 +220,20 @@ Requires Python 3.10+.
221
220
 
222
221
  ## Start Once, Then Work Normally
223
222
 
224
- The recommended workflow for repeated development sessions:
223
+ The full workflow:
225
224
 
226
225
  ```bash
227
- agentpack install # configure your agent (once per project)
228
- agentpack session start # create session state + generate initial context
229
- agentpack watch # in another terminal refreshes context on file/task changes
226
+ # One-time project setup
227
+ agentpack init # creates config, session, task.md
228
+ agentpack install # configure your agent (optional but recommended)
229
+
230
+ # Every terminal session — just one command
231
+ agentpack watch # auto-resumes session, refreshes context on file/task changes
230
232
  ```
231
233
 
232
234
  Then open Claude Code / Cursor / Codex and write your coding task normally.
233
235
 
234
- - AgentPack keeps `.agentpack/context.md` fresh while `watch` is running.
236
+ - AgentPack keeps `.agentpack/context.md` and `.agentpack/context.claude.md` fresh while `watch` is running.
235
237
  - To change the task: `agentpack session refresh --task "new task"` — or just tell Claude and it updates `task.md` itself.
236
238
  - Check session state: `agentpack session status`
237
239
  - Force a refresh: `agentpack session refresh`
@@ -242,11 +244,11 @@ Then open Claude Code / Cursor / Codex and write your coding task normally.
242
244
  | Agent | Automation level | Method |
243
245
  |---|---|---|
244
246
  | Claude Code (hook) | Highest | `UserPromptSubmit` hook auto-injects context |
245
- | Claude Code (session) | High | `session start` + `watch` + read `context.md` |
246
- | Codex | Medium | `AGENTS.md` + `session start` + `watch` |
247
- | Cursor | Medium | `.cursor/rules/agentpack.mdc` + `session start` + `watch` |
248
- | Windsurf | Medium | `.windsurfrules` + `session start` + `watch` |
249
- | Antigravity | Medium | `.agent/skills/agentpack/SKILL.md` + `GEMINI.md` + `session start` + `watch` |
247
+ | Claude Code (session) | High | `init` + `watch` + read `context.md` |
248
+ | Codex | Medium | `AGENTS.md` + `init` + `watch` |
249
+ | Cursor | Medium | `.cursor/rules/agentpack.mdc` + `init` + `watch` |
250
+ | Windsurf | Medium | `.windsurfrules` + `init` + `watch` |
251
+ | Antigravity | Medium | `.agent/skills/agentpack/SKILL.md` + `GEMINI.md` + `init` + `watch` |
250
252
  | Generic | Basic | `watch` mode + read `context.md` |
251
253
 
252
254
  ### Honest limitations
@@ -263,10 +265,9 @@ Then open Claude Code / Cursor / Codex and write your coding task normally.
263
265
  ```bash
264
266
  pip install agentpack-cli
265
267
  cd your-project
266
- agentpack init
268
+ agentpack init # one-time setup: config + session + task.md
267
269
  agentpack install # auto-detects your IDE (Claude Code, Cursor, Windsurf, Codex, Antigravity)
268
- agentpack session start # generate initial context
269
- agentpack watch # in another terminal — keeps context fresh
270
+ agentpack watch # in another terminal — keeps context fresh automatically
270
271
  ```
271
272
 
272
273
  Then open your agent and write your task normally.
@@ -592,14 +593,14 @@ All installs are idempotent — safe to re-run, merge with existing config, neve
592
593
 
593
594
  ### `agentpack summarize`
594
595
 
595
- Build or refresh the offline summary cache. **No API calls.**
596
+ Build or refresh the offline summary cache. **No API calls, ever.**
596
597
 
597
598
  ```bash
598
599
  agentpack summarize # build summaries for all files not yet cached
599
600
  agentpack summarize --refresh # force rebuild all
600
601
  ```
601
602
 
602
- Run this once after `init`. After that, pack automatically rebuilds summaries only for changed files.
603
+ Summaries are built with parallel AST/regex analysis — no network, no tokens spent. Run once after `init`. After that, pack automatically rebuilds summaries only for changed files (hash-keyed cache).
603
604
 
604
605
  ---
605
606
 
@@ -629,6 +630,7 @@ Options:
629
630
  | `--since` | — | Only include files changed since this git ref |
630
631
  | `--session` | off | Re-pack on every file change (watch mode) |
631
632
  | `--refresh` | off | Force rebuild summaries before packing |
633
+ | `--budget` | 25000 | Token budget override |
632
634
 
633
635
  **Budget modes:**
634
636
 
@@ -642,22 +644,23 @@ Options:
642
644
 
643
645
  ### `agentpack session`
644
646
 
645
- Manage AgentPack sessions the "start once, work normally" workflow.
647
+ 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
648
 
647
649
  ```bash
648
- agentpack session start # create session, generate initial context
650
+ agentpack session start # re-run to change agent/mode or force refresh
649
651
  agentpack session start --agent claude # set agent (claude|cursor|codex|generic)
650
- agentpack session start --task "fix bug" # set initial task
652
+ agentpack session start --task "fix bug" # change task + refresh context
651
653
  agentpack session status # show session state + context size
652
654
  agentpack session refresh # regenerate context now
653
655
  agentpack session refresh --task "new task" # change task + refresh
654
656
  agentpack session stop # mark session inactive
655
657
  ```
656
658
 
657
- `session start` creates:
659
+ `agentpack init` creates (idempotently):
658
660
  - `.agentpack/session.json` — session state
659
- - `.agentpack/task.md` — current task (written by Claude or `session refresh --task`)
660
- - `.agentpack/context.md` — readable context pack
661
+ - `.agentpack/task.md` — current task (edit directly or use `session refresh --task`)
662
+ - `.agentpack/context.md` — readable context pack (updated by `watch`)
663
+ - `.agentpack/context.claude.md` — Claude Code format (always written alongside context.md)
661
664
  - `.agentpack/context.compact.md` — compact protocol format
662
665
 
663
666
  ---
@@ -688,7 +691,48 @@ Launch Claude CLI with an up-to-date context.
688
691
  agentpack claude
689
692
  ```
690
693
 
691
- 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.
694
+ 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.
695
+
696
+ ---
697
+
698
+ ### `agentpack mcp`
699
+
700
+ Run AgentPack as an MCP server — exposes context packing as tools that Claude Code (and any MCP-compatible agent) can call directly.
701
+
702
+ ```bash
703
+ pip install "agentpack-cli[mcp]"
704
+ agentpack mcp
705
+ ```
706
+
707
+ Register in Claude Code settings (`~/.claude/settings.json`):
708
+
709
+ ```json
710
+ {
711
+ "mcpServers": {
712
+ "agentpack": {
713
+ "command": "agentpack",
714
+ "args": ["mcp"]
715
+ }
716
+ }
717
+ }
718
+ ```
719
+
720
+ **Tools exposed:**
721
+
722
+ | Tool | Description |
723
+ |---|---|
724
+ | `pack_context(task, mode, budget, max_tokens)` | Generate a ranked context pack for a task. Returns packed markdown, truncated to `max_tokens` (default 20,000). |
725
+ | `get_context()` | Return the latest pre-built pack instantly (no repack). Prepends a freshness/staleness header so you know if it's stale. |
726
+ | `refresh()` | Refresh using the current `task.md` or git-inferred task. |
727
+
728
+ **Staleness detection:** `get_context()` compares the snapshot hash from when the pack was built against the current repo snapshot. If files changed since last pack, it prepends:
729
+ ```
730
+ > **Stale context** — repo changed since last pack (generated: ...). Run pack_context() to refresh.
731
+ ```
732
+
733
+ **Smart truncation:** `pack_context()` keeps headers intact and trims file content blocks to fit the token budget, appending a note about how many files were omitted.
734
+
735
+ Zero API calls — all analysis is offline. Summary cache keyed by file hash: cold run parallelises AST parsing across CPU cores; warm cache hits are instant.
692
736
 
693
737
  ---
694
738
 
@@ -913,10 +957,6 @@ include_tests = true
913
957
  include_configs = true
914
958
  include_receipts = true
915
959
 
916
- [summary]
917
- provider = "offline"
918
- schema_version = 1
919
-
920
960
  [agents.claude]
921
961
  output = ".agentpack/context.claude.md"
922
962
  patch_claude_md = true
@@ -1019,7 +1059,6 @@ Works like `.gitignore`. Default rules exclude:
1019
1059
  │ miss → build from AST/regex, cache it │
1020
1060
  │ │
1021
1061
  │ offline ── AST / regex extract │
1022
- │ claude ── Haiku API (optional) │
1023
1062
  └────────────────────┬────────────────────┘
1024
1063
 
1025
1064
  ┌────────────────────▼────────────────────┐
@@ -1120,8 +1159,7 @@ src/agentpack/
1120
1159
 
1121
1160
  summaries/
1122
1161
  offline.py # zero-API: AST/regex → imports, symbols, summary
1123
- llm.py # Claude Haiku API summaries (optional)
1124
- base.py # cache-or-build orchestration
1162
+ base.py # cache-or-build orchestration (parallel, ThreadPool+ProcessPool)
1125
1163
 
1126
1164
  adapters/ # context rendering only — no installation logic
1127
1165
  base.py # abstract BaseAdapter (output_path + render + write)
@@ -1240,13 +1278,14 @@ Add to `.github/workflows/agentpack-context.yml` — see the full example in [CI
1240
1278
  ### Session mode: keep context fresh while you work
1241
1279
 
1242
1280
  ```bash
1243
- # Terminal 1: start a session and watch for changes
1244
- agentpack session start --task "refactor auth"
1245
- agentpack watch # in a second terminal — refreshes context on every save
1281
+ # One-time project setup
1282
+ agentpack init --task "refactor auth" # or edit .agentpack/task.md directly
1283
+
1284
+ # Every terminal session — just one command
1285
+ agentpack watch # auto-resumes session, refreshes context on every save
1246
1286
 
1247
- # Terminal 2: your editor / agent
1248
- # Save a file context.md regenerates automatically
1249
- # Change task: agentpack session refresh --task "new task"
1287
+ # Change task mid-session
1288
+ agentpack session refresh --task "new task"
1250
1289
  ```
1251
1290
 
1252
1291
  ---
@@ -1316,8 +1355,8 @@ agentpack pack --task "fix bug" --budget 40000 # explicit token cap
1316
1355
  ### Watch mode for active sessions
1317
1356
 
1318
1357
  ```bash
1319
- agentpack session start --task "refactor auth"
1320
- agentpack watch # in another terminal
1358
+ agentpack init # one-time setup (creates session + task.md)
1359
+ agentpack watch # in another terminal — auto-resumes each time
1321
1360
  ```
1322
1361
 
1323
1362
  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.
@@ -1357,10 +1396,10 @@ config_file = 60 # was 25 — configs always matter here
1357
1396
 
1358
1397
  ## Principles
1359
1398
 
1360
- - **Local-first**: `init`, `scan`, `diff`, `pack`, `stats`, `summarize` make zero API calls by default
1399
+ - **Local-first**: `init`, `scan`, `diff`, `pack`, `stats`, `summarize` make zero API calls ever. No optional LLM paths, no per-file costs.
1361
1400
  - **Non-destructive**: never overwrites user files; config patching only touches agentpack-managed blocks
1362
1401
  - **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`; session management is opt-in via `agentpack session start`; git hooks run in the background and are opt-in via `install`
1402
+ - **No daemons**: file watching is opt-in via `agentpack watch`; git hooks run in the background and are opt-in via `install`
1364
1403
  - **Honest**: packed token count reflects real content, not raw repo size
1365
1404
 
1366
1405
  ---
@@ -1379,9 +1418,9 @@ config_file = 60 # was 25 — configs always matter here
1379
1418
  ## Optional dependencies
1380
1419
 
1381
1420
  ```bash
1382
- pip install "agentpack-cli[llm]" # anthropic — LLM summaries via Claude Haiku
1383
1421
  pip install "agentpack-cli[watch]" # watchdog — faster file watching for agentpack watch
1384
- pip install "agentpack-cli[all]" # llm + watch
1422
+ pip install "agentpack-cli[mcp]" # mcp expose agentpack as MCP server tools
1423
+ pip install "agentpack-cli[all]" # watch + mcp
1385
1424
  ```
1386
1425
 
1387
1426
  ---
@@ -5,7 +5,7 @@
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
  [![CI](https://github.com/vishal2612200/agentpack/actions/workflows/ci.yml/badge.svg)](https://github.com/vishal2612200/agentpack/actions/workflows/ci.yml)
7
7
 
8
- > **Status: alpha (v0.1.5).** 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.
8
+ > **Status: alpha (v0.1.9).** 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.
9
9
  >
10
10
  > **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.
11
11
 
@@ -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
- # Session mode: start once, then work normally
44
+ # One-time setup per project
45
45
  cd your-project
46
- agentpack init
47
- agentpack install # auto-detects your IDE
48
- agentpack session start
49
- agentpack watch # in another terminal — keeps context fresh automatically
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 recommended workflow for repeated development sessions:
185
+ The full workflow:
185
186
 
186
187
  ```bash
187
- agentpack install # configure your agent (once per project)
188
- agentpack session start # create session state + generate initial context
189
- agentpack watch # in another terminal refreshes context on file/task changes
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 | `session start` + `watch` + read `context.md` |
206
- | Codex | Medium | `AGENTS.md` + `session start` + `watch` |
207
- | Cursor | Medium | `.cursor/rules/agentpack.mdc` + `session start` + `watch` |
208
- | Windsurf | Medium | `.windsurfrules` + `session start` + `watch` |
209
- | Antigravity | Medium | `.agent/skills/agentpack/SKILL.md` + `GEMINI.md` + `session start` + `watch` |
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 session start # generate initial context
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.
@@ -552,14 +555,14 @@ All installs are idempotent — safe to re-run, merge with existing config, neve
552
555
 
553
556
  ### `agentpack summarize`
554
557
 
555
- Build or refresh the offline summary cache. **No API calls.**
558
+ Build or refresh the offline summary cache. **No API calls, ever.**
556
559
 
557
560
  ```bash
558
561
  agentpack summarize # build summaries for all files not yet cached
559
562
  agentpack summarize --refresh # force rebuild all
560
563
  ```
561
564
 
562
- Run this once after `init`. After that, pack automatically rebuilds summaries only for changed files.
565
+ Summaries are built with parallel AST/regex analysis — no network, no tokens spent. Run once after `init`. After that, pack automatically rebuilds summaries only for changed files (hash-keyed cache).
563
566
 
564
567
  ---
565
568
 
@@ -589,6 +592,7 @@ Options:
589
592
  | `--since` | — | Only include files changed since this git ref |
590
593
  | `--session` | off | Re-pack on every file change (watch mode) |
591
594
  | `--refresh` | off | Force rebuild summaries before packing |
595
+ | `--budget` | 25000 | Token budget override |
592
596
 
593
597
  **Budget modes:**
594
598
 
@@ -602,22 +606,23 @@ Options:
602
606
 
603
607
  ### `agentpack session`
604
608
 
605
- Manage AgentPack sessions the "start once, work normally" workflow.
609
+ 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
610
 
607
611
  ```bash
608
- agentpack session start # create session, generate initial context
612
+ agentpack session start # re-run to change agent/mode or force refresh
609
613
  agentpack session start --agent claude # set agent (claude|cursor|codex|generic)
610
- agentpack session start --task "fix bug" # set initial task
614
+ agentpack session start --task "fix bug" # change task + refresh context
611
615
  agentpack session status # show session state + context size
612
616
  agentpack session refresh # regenerate context now
613
617
  agentpack session refresh --task "new task" # change task + refresh
614
618
  agentpack session stop # mark session inactive
615
619
  ```
616
620
 
617
- `session start` creates:
621
+ `agentpack init` creates (idempotently):
618
622
  - `.agentpack/session.json` — session state
619
- - `.agentpack/task.md` — current task (written by Claude or `session refresh --task`)
620
- - `.agentpack/context.md` — readable context pack
623
+ - `.agentpack/task.md` — current task (edit directly or use `session refresh --task`)
624
+ - `.agentpack/context.md` — readable context pack (updated by `watch`)
625
+ - `.agentpack/context.claude.md` — Claude Code format (always written alongside context.md)
621
626
  - `.agentpack/context.compact.md` — compact protocol format
622
627
 
623
628
  ---
@@ -648,7 +653,48 @@ Launch Claude CLI with an up-to-date context.
648
653
  agentpack claude
649
654
  ```
650
655
 
651
- 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.
656
+ 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.
657
+
658
+ ---
659
+
660
+ ### `agentpack mcp`
661
+
662
+ Run AgentPack as an MCP server — exposes context packing as tools that Claude Code (and any MCP-compatible agent) can call directly.
663
+
664
+ ```bash
665
+ pip install "agentpack-cli[mcp]"
666
+ agentpack mcp
667
+ ```
668
+
669
+ Register in Claude Code settings (`~/.claude/settings.json`):
670
+
671
+ ```json
672
+ {
673
+ "mcpServers": {
674
+ "agentpack": {
675
+ "command": "agentpack",
676
+ "args": ["mcp"]
677
+ }
678
+ }
679
+ }
680
+ ```
681
+
682
+ **Tools exposed:**
683
+
684
+ | Tool | Description |
685
+ |---|---|
686
+ | `pack_context(task, mode, budget, max_tokens)` | Generate a ranked context pack for a task. Returns packed markdown, truncated to `max_tokens` (default 20,000). |
687
+ | `get_context()` | Return the latest pre-built pack instantly (no repack). Prepends a freshness/staleness header so you know if it's stale. |
688
+ | `refresh()` | Refresh using the current `task.md` or git-inferred task. |
689
+
690
+ **Staleness detection:** `get_context()` compares the snapshot hash from when the pack was built against the current repo snapshot. If files changed since last pack, it prepends:
691
+ ```
692
+ > **Stale context** — repo changed since last pack (generated: ...). Run pack_context() to refresh.
693
+ ```
694
+
695
+ **Smart truncation:** `pack_context()` keeps headers intact and trims file content blocks to fit the token budget, appending a note about how many files were omitted.
696
+
697
+ Zero API calls — all analysis is offline. Summary cache keyed by file hash: cold run parallelises AST parsing across CPU cores; warm cache hits are instant.
652
698
 
653
699
  ---
654
700
 
@@ -873,10 +919,6 @@ include_tests = true
873
919
  include_configs = true
874
920
  include_receipts = true
875
921
 
876
- [summary]
877
- provider = "offline"
878
- schema_version = 1
879
-
880
922
  [agents.claude]
881
923
  output = ".agentpack/context.claude.md"
882
924
  patch_claude_md = true
@@ -979,7 +1021,6 @@ Works like `.gitignore`. Default rules exclude:
979
1021
  │ miss → build from AST/regex, cache it │
980
1022
  │ │
981
1023
  │ offline ── AST / regex extract │
982
- │ claude ── Haiku API (optional) │
983
1024
  └────────────────────┬────────────────────┘
984
1025
 
985
1026
  ┌────────────────────▼────────────────────┐
@@ -1080,8 +1121,7 @@ src/agentpack/
1080
1121
 
1081
1122
  summaries/
1082
1123
  offline.py # zero-API: AST/regex → imports, symbols, summary
1083
- llm.py # Claude Haiku API summaries (optional)
1084
- base.py # cache-or-build orchestration
1124
+ base.py # cache-or-build orchestration (parallel, ThreadPool+ProcessPool)
1085
1125
 
1086
1126
  adapters/ # context rendering only — no installation logic
1087
1127
  base.py # abstract BaseAdapter (output_path + render + write)
@@ -1200,13 +1240,14 @@ Add to `.github/workflows/agentpack-context.yml` — see the full example in [CI
1200
1240
  ### Session mode: keep context fresh while you work
1201
1241
 
1202
1242
  ```bash
1203
- # Terminal 1: start a session and watch for changes
1204
- agentpack session start --task "refactor auth"
1205
- agentpack watch # in a second terminal — refreshes context on every save
1243
+ # One-time project setup
1244
+ agentpack init --task "refactor auth" # or edit .agentpack/task.md directly
1245
+
1246
+ # Every terminal session — just one command
1247
+ agentpack watch # auto-resumes session, refreshes context on every save
1206
1248
 
1207
- # Terminal 2: your editor / agent
1208
- # Save a file context.md regenerates automatically
1209
- # Change task: agentpack session refresh --task "new task"
1249
+ # Change task mid-session
1250
+ agentpack session refresh --task "new task"
1210
1251
  ```
1211
1252
 
1212
1253
  ---
@@ -1276,8 +1317,8 @@ agentpack pack --task "fix bug" --budget 40000 # explicit token cap
1276
1317
  ### Watch mode for active sessions
1277
1318
 
1278
1319
  ```bash
1279
- agentpack session start --task "refactor auth"
1280
- agentpack watch # in another terminal
1320
+ agentpack init # one-time setup (creates session + task.md)
1321
+ agentpack watch # in another terminal — auto-resumes each time
1281
1322
  ```
1282
1323
 
1283
1324
  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.
@@ -1317,10 +1358,10 @@ config_file = 60 # was 25 — configs always matter here
1317
1358
 
1318
1359
  ## Principles
1319
1360
 
1320
- - **Local-first**: `init`, `scan`, `diff`, `pack`, `stats`, `summarize` make zero API calls by default
1361
+ - **Local-first**: `init`, `scan`, `diff`, `pack`, `stats`, `summarize` make zero API calls ever. No optional LLM paths, no per-file costs.
1321
1362
  - **Non-destructive**: never overwrites user files; config patching only touches agentpack-managed blocks
1322
1363
  - **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`; session management is opt-in via `agentpack session start`; git hooks run in the background and are opt-in via `install`
1364
+ - **No daemons**: file watching is opt-in via `agentpack watch`; git hooks run in the background and are opt-in via `install`
1324
1365
  - **Honest**: packed token count reflects real content, not raw repo size
1325
1366
 
1326
1367
  ---
@@ -1339,9 +1380,9 @@ config_file = 60 # was 25 — configs always matter here
1339
1380
  ## Optional dependencies
1340
1381
 
1341
1382
  ```bash
1342
- pip install "agentpack-cli[llm]" # anthropic — LLM summaries via Claude Haiku
1343
1383
  pip install "agentpack-cli[watch]" # watchdog — faster file watching for agentpack watch
1344
- pip install "agentpack-cli[all]" # llm + watch
1384
+ pip install "agentpack-cli[mcp]" # mcp expose agentpack as MCP server tools
1385
+ pip install "agentpack-cli[all]" # watch + mcp
1345
1386
  ```
1346
1387
 
1347
1388
  ---
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "agentpack-cli"
3
- version = "0.1.7"
3
+ version = "0.1.9"
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"
@@ -31,19 +31,17 @@ dependencies = [
31
31
  agentpack = "agentpack.cli:app"
32
32
 
33
33
  [project.optional-dependencies]
34
- llm = [
35
- "anthropic>=0.39.0",
36
- "openai>=1.0.0"
37
- ]
38
-
39
34
  watch = [
40
35
  "watchdog>=4.0.0"
41
36
  ]
42
37
 
38
+ mcp = [
39
+ "mcp>=1.0.0"
40
+ ]
41
+
43
42
  all = [
44
- "anthropic>=0.39.0",
45
- "openai>=1.0.0",
46
- "watchdog>=4.0.0"
43
+ "watchdog>=4.0.0",
44
+ "mcp>=1.0.0"
47
45
  ]
48
46
 
49
47
  dev = [
@@ -55,6 +53,9 @@ dev = [
55
53
 
56
54
  [tool.pytest.ini_options]
57
55
  pythonpath = ["src"]
56
+ markers = [
57
+ "slow: marks tests as slow (deselect with '-m \"not slow\"')",
58
+ ]
58
59
 
59
60
  [build-system]
60
61
  requires = ["hatchling"]
@@ -1,3 +1,3 @@
1
1
  """AgentPack — token-aware context packing for AI coding agents."""
2
2
 
3
- __version__ = "0.1.6"
3
+ __version__ = "0.1.9"
@@ -31,7 +31,6 @@ class PackRequest:
31
31
  budget: int
32
32
  since: str | None
33
33
  refresh: bool
34
- summary_provider: str
35
34
 
36
35
 
37
36
  @dataclass
@@ -176,7 +175,7 @@ class PackPlanner:
176
175
  packable = scan_result.packable
177
176
 
178
177
  t0 = time.perf_counter()
179
- summaries_objs = build_all_summaries(packable, root, request.summary_provider)
178
+ summaries_objs = build_all_summaries(packable, root)
180
179
  summaries = {p: s.model_dump() for p, s in summaries_objs.items()}
181
180
  phase_times["summarize"] = time.perf_counter() - t0
182
181
 
@@ -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