agent-context-packager 0.1.0__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 (38) hide show
  1. agent_context_packager-0.1.0/PKG-INFO +137 -0
  2. agent_context_packager-0.1.0/README.md +109 -0
  3. agent_context_packager-0.1.0/pyproject.toml +42 -0
  4. agent_context_packager-0.1.0/setup.cfg +4 -0
  5. agent_context_packager-0.1.0/src/agent_context_packager.egg-info/PKG-INFO +137 -0
  6. agent_context_packager-0.1.0/src/agent_context_packager.egg-info/SOURCES.txt +36 -0
  7. agent_context_packager-0.1.0/src/agent_context_packager.egg-info/dependency_links.txt +1 -0
  8. agent_context_packager-0.1.0/src/agent_context_packager.egg-info/entry_points.txt +2 -0
  9. agent_context_packager-0.1.0/src/agent_context_packager.egg-info/requires.txt +22 -0
  10. agent_context_packager-0.1.0/src/agent_context_packager.egg-info/top_level.txt +1 -0
  11. agent_context_packager-0.1.0/src/agentpack/__init__.py +1 -0
  12. agent_context_packager-0.1.0/src/agentpack/__main__.py +4 -0
  13. agent_context_packager-0.1.0/src/agentpack/audit.py +65 -0
  14. agent_context_packager-0.1.0/src/agentpack/chunker.py +80 -0
  15. agent_context_packager-0.1.0/src/agentpack/cli.py +148 -0
  16. agent_context_packager-0.1.0/src/agentpack/eval/__init__.py +1 -0
  17. agent_context_packager-0.1.0/src/agentpack/eval/baselines.py +134 -0
  18. agent_context_packager-0.1.0/src/agentpack/eval/benchmarks.py +94 -0
  19. agent_context_packager-0.1.0/src/agentpack/eval/generation.py +152 -0
  20. agent_context_packager-0.1.0/src/agentpack/eval/metrics.py +47 -0
  21. agent_context_packager-0.1.0/src/agentpack/eval/runner.py +93 -0
  22. agent_context_packager-0.1.0/src/agentpack/models.py +30 -0
  23. agent_context_packager-0.1.0/src/agentpack/pack.py +157 -0
  24. agent_context_packager-0.1.0/src/agentpack/parsers/__init__.py +1 -0
  25. agent_context_packager-0.1.0/src/agentpack/parsers/base.py +9 -0
  26. agent_context_packager-0.1.0/src/agentpack/parsers/csv_parser.py +52 -0
  27. agent_context_packager-0.1.0/src/agentpack/parsers/markdown_parser.py +82 -0
  28. agent_context_packager-0.1.0/src/agentpack/parsers/pdf_parser.py +57 -0
  29. agent_context_packager-0.1.0/src/agentpack/parsers/text_parser.py +43 -0
  30. agent_context_packager-0.1.0/src/agentpack/retrieve.py +260 -0
  31. agent_context_packager-0.1.0/src/agentpack/scanner.py +107 -0
  32. agent_context_packager-0.1.0/src/agentpack/validate.py +67 -0
  33. agent_context_packager-0.1.0/tests/test_chunker.py +68 -0
  34. agent_context_packager-0.1.0/tests/test_cli.py +42 -0
  35. agent_context_packager-0.1.0/tests/test_pack.py +43 -0
  36. agent_context_packager-0.1.0/tests/test_parsers.py +97 -0
  37. agent_context_packager-0.1.0/tests/test_retrieve.py +74 -0
  38. agent_context_packager-0.1.0/tests/test_scanner.py +49 -0
@@ -0,0 +1,137 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-context-packager
3
+ Version: 0.1.0
4
+ Summary: A document-to-agent-context compiler.
5
+ Author-email: Your Name <your.email@example.com>
6
+ Requires-Python: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: typer>=0.9.0
9
+ Requires-Dist: pydantic>=2.0.0
10
+ Requires-Dist: pymupdf>=1.23.0
11
+ Requires-Dist: pandas>=2.0.0
12
+ Requires-Dist: tiktoken>=0.5.0
13
+ Requires-Dist: pyyaml>=6.0
14
+ Requires-Dist: pyinstaller>=6.0.0
15
+ Requires-Dist: tabulate>=0.9.0
16
+ Requires-Dist: fastembed>=0.2.7
17
+ Requires-Dist: numpy>=1.24.0
18
+ Requires-Dist: datasets>=2.0.0
19
+ Requires-Dist: requests>=2.0.0
20
+ Requires-Dist: pathspec>=0.11.0
21
+ Requires-Dist: detect-secrets>=1.4.0
22
+ Provides-Extra: docs
23
+ Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
24
+ Requires-Dist: mkdocstrings[python]>=0.24.0; extra == "docs"
25
+ Provides-Extra: test
26
+ Requires-Dist: pytest>=7.0.0; extra == "test"
27
+ Requires-Dist: pytest-mock>=3.10.0; extra == "test"
28
+
29
+ # AgentPack
30
+
31
+ **AgentPack** improves the context pipeline for document-grounded agents.
32
+
33
+ Instead of forcing AI agents to parse messy, disparate file formats (PDFs, CSVs, Markdown, text) at runtime, AgentPack is an offline **document-to-agent-context compiler**. It takes unstructured knowledge bases, turns them into clean semantic chunks with citations, retrieves the right evidence, and sends only high-signal context to the model.
34
+
35
+ ## The Benchmark
36
+ **Given the same LLM, AgentPack provides better context than raw document stuffing or naive RAG.**
37
+
38
+ I benchmarked AgentPack against standard RAG baselines on 42 complex financial queries from [Patronus AI FinanceBench](https://github.com/patronus-ai/financebench). The results prove that AgentPack reduces context bloat, improves evidence retrieval, preserves citations, and helps the exact same LLM produce more grounded answers.
39
+
40
+ **Benchmark Highlights:**
41
+ * **161x Reduction in Token Cost:** Cut context token usage from 424k to 2.6k, saving ~$0.10 per query.
42
+ * **2x Context Relevance:** Vastly outperformed naive chunking in retrieving semantically complete financial tables.
43
+ * **"Lost in the Middle" Prevention:** Outperformed raw document stuffing in correctness by preventing the LLM from drowning in noise.
44
+
45
+ Read the full scientific methodology and results in [BENCHMARK.md](https://github.com/Vedant1202/agentpack/blob/main/BENCHMARK.md).
46
+
47
+ ## Installation
48
+
49
+ You can install AgentPack via pip or npm.
50
+
51
+ **Option 1: Using pip (Python)**
52
+ ```bash
53
+ pip install agent-context-packager
54
+ ```
55
+
56
+ **Option 2: Using npm (Node.js/CLI binary)**
57
+ ```bash
58
+ npm install -g agent-context-packager
59
+ ```
60
+
61
+ **Option 3: From Source**
62
+ ```bash
63
+ git clone https://github.com/Vedant1202/agentpack.git
64
+ cd agentpack
65
+ python3 -m venv venv
66
+ source venv/bin/activate
67
+ pip install -e .
68
+ ```
69
+
70
+ ## Quick Start
71
+
72
+ ### 1. Scan for Secrets (Recommended)
73
+ Before compiling a pack, ensure you aren't accidentally leaking API keys or secrets into the LLM context window. AgentPack automatically installs Yelp's `detect-secrets`.
74
+ ```bash
75
+ detect-secrets scan > .secrets.baseline
76
+ ```
77
+
78
+ ### 2. Compile a Pack
79
+ Point AgentPack at any folder containing your documents (`.txt`, `.md`, `.csv`, `.pdf`).
80
+
81
+ ```bash
82
+ agentpack pack ./my_docs --out ./agentpack-output
83
+ ```
84
+
85
+ **Key Compilation Options:**
86
+ - `--include "*.md,*.txt"`: Only pack specific files or extensions.
87
+ - `--ignore "tests/,drafts/"`: Exclude specific directories or files.
88
+ - `--remove-empty-lines`: Compress text files to save LLM tokens.
89
+ - `--no-gitignore`: Ignore `.gitignore` rules and pack everything.
90
+
91
+ ### 2. Retrieve
92
+ AgentPack comes with a built-in hybrid search engine (SQLite FTS5 + FastEmbed vector search) to test your chunks instantly.
93
+
94
+ ```bash
95
+ agentpack retrieve ./agentpack-output "eligibility criteria" --top-k 5
96
+ ```
97
+
98
+ ### 3. V1 Deterministic Eval
99
+ Benchmark AgentPack against naive chunking using our offline evaluation harness.
100
+
101
+ ```bash
102
+ agentpack eval ./benchmarks/my_dataset
103
+ ```
104
+
105
+ ## Comprehensive CLI Documentation
106
+
107
+ AgentPack provides a rich CLI for auditing, validating, and testing your context packs (including Generative QA evaluations).
108
+
109
+ **[📖 Read the full CLI Reference](https://github.com/Vedant1202/agentpack/blob/main/docs/cli-reference.md)**
110
+
111
+ ## Supported Parsers
112
+ - **TXT**: Paragraph-aware splitting.
113
+ - **Markdown**: Semantic heading-aware section path tracking.
114
+ - **CSV**: Uses Pandas & Tabulate to convert tabular data into Markdown tables.
115
+ - **PDF**: Accurate page-by-page PyMuPDF extraction.
116
+
117
+ ## Architecture Overview
118
+
119
+ ```mermaid
120
+ flowchart LR
121
+ Docs[Raw Docs] --> Parsers[Parsers]
122
+ Parsers --> Chunker[Chunker]
123
+ Chunker --> Pack[Context Pack]
124
+ Pack --> Agent[LLM Agent]
125
+ ```
126
+
127
+ For a deep dive into how AgentPack parses, chunks, and indexes data, see [Architecture & Internals](https://github.com/Vedant1202/agentpack/blob/main/docs/architecture.md).
128
+
129
+ ## Current Limitations & Roadmap
130
+ AgentPack is currently focused on text-based semantic extraction. The following features are on the roadmap but **not yet implemented**:
131
+ - **Image Understanding / Vision**: AgentPack does not currently run OCR or vision models on images embedded within PDFs or Markdown files. Images are currently ignored during the parsing phase.
132
+ - **Complex Table Structures**: While basic CSVs are supported, highly nested or merged-cell tables within PDFs are not perfectly reconstructed yet.
133
+ - **Web Crawling**: You currently need to provide local files. Direct URL scraping is planned.
134
+ - **Cloud Vector DB Integration**: Retrieval currently runs locally using SQLite FTS5 and FastEmbed. Connectors for Pinecone, Weaviate, or Qdrant are planned.
135
+
136
+ ---
137
+ *Built with ❤️ for Agents.*
@@ -0,0 +1,109 @@
1
+ # AgentPack
2
+
3
+ **AgentPack** improves the context pipeline for document-grounded agents.
4
+
5
+ Instead of forcing AI agents to parse messy, disparate file formats (PDFs, CSVs, Markdown, text) at runtime, AgentPack is an offline **document-to-agent-context compiler**. It takes unstructured knowledge bases, turns them into clean semantic chunks with citations, retrieves the right evidence, and sends only high-signal context to the model.
6
+
7
+ ## The Benchmark
8
+ **Given the same LLM, AgentPack provides better context than raw document stuffing or naive RAG.**
9
+
10
+ I benchmarked AgentPack against standard RAG baselines on 42 complex financial queries from [Patronus AI FinanceBench](https://github.com/patronus-ai/financebench). The results prove that AgentPack reduces context bloat, improves evidence retrieval, preserves citations, and helps the exact same LLM produce more grounded answers.
11
+
12
+ **Benchmark Highlights:**
13
+ * **161x Reduction in Token Cost:** Cut context token usage from 424k to 2.6k, saving ~$0.10 per query.
14
+ * **2x Context Relevance:** Vastly outperformed naive chunking in retrieving semantically complete financial tables.
15
+ * **"Lost in the Middle" Prevention:** Outperformed raw document stuffing in correctness by preventing the LLM from drowning in noise.
16
+
17
+ Read the full scientific methodology and results in [BENCHMARK.md](https://github.com/Vedant1202/agentpack/blob/main/BENCHMARK.md).
18
+
19
+ ## Installation
20
+
21
+ You can install AgentPack via pip or npm.
22
+
23
+ **Option 1: Using pip (Python)**
24
+ ```bash
25
+ pip install agent-context-packager
26
+ ```
27
+
28
+ **Option 2: Using npm (Node.js/CLI binary)**
29
+ ```bash
30
+ npm install -g agent-context-packager
31
+ ```
32
+
33
+ **Option 3: From Source**
34
+ ```bash
35
+ git clone https://github.com/Vedant1202/agentpack.git
36
+ cd agentpack
37
+ python3 -m venv venv
38
+ source venv/bin/activate
39
+ pip install -e .
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ ### 1. Scan for Secrets (Recommended)
45
+ Before compiling a pack, ensure you aren't accidentally leaking API keys or secrets into the LLM context window. AgentPack automatically installs Yelp's `detect-secrets`.
46
+ ```bash
47
+ detect-secrets scan > .secrets.baseline
48
+ ```
49
+
50
+ ### 2. Compile a Pack
51
+ Point AgentPack at any folder containing your documents (`.txt`, `.md`, `.csv`, `.pdf`).
52
+
53
+ ```bash
54
+ agentpack pack ./my_docs --out ./agentpack-output
55
+ ```
56
+
57
+ **Key Compilation Options:**
58
+ - `--include "*.md,*.txt"`: Only pack specific files or extensions.
59
+ - `--ignore "tests/,drafts/"`: Exclude specific directories or files.
60
+ - `--remove-empty-lines`: Compress text files to save LLM tokens.
61
+ - `--no-gitignore`: Ignore `.gitignore` rules and pack everything.
62
+
63
+ ### 2. Retrieve
64
+ AgentPack comes with a built-in hybrid search engine (SQLite FTS5 + FastEmbed vector search) to test your chunks instantly.
65
+
66
+ ```bash
67
+ agentpack retrieve ./agentpack-output "eligibility criteria" --top-k 5
68
+ ```
69
+
70
+ ### 3. V1 Deterministic Eval
71
+ Benchmark AgentPack against naive chunking using our offline evaluation harness.
72
+
73
+ ```bash
74
+ agentpack eval ./benchmarks/my_dataset
75
+ ```
76
+
77
+ ## Comprehensive CLI Documentation
78
+
79
+ AgentPack provides a rich CLI for auditing, validating, and testing your context packs (including Generative QA evaluations).
80
+
81
+ **[📖 Read the full CLI Reference](https://github.com/Vedant1202/agentpack/blob/main/docs/cli-reference.md)**
82
+
83
+ ## Supported Parsers
84
+ - **TXT**: Paragraph-aware splitting.
85
+ - **Markdown**: Semantic heading-aware section path tracking.
86
+ - **CSV**: Uses Pandas & Tabulate to convert tabular data into Markdown tables.
87
+ - **PDF**: Accurate page-by-page PyMuPDF extraction.
88
+
89
+ ## Architecture Overview
90
+
91
+ ```mermaid
92
+ flowchart LR
93
+ Docs[Raw Docs] --> Parsers[Parsers]
94
+ Parsers --> Chunker[Chunker]
95
+ Chunker --> Pack[Context Pack]
96
+ Pack --> Agent[LLM Agent]
97
+ ```
98
+
99
+ For a deep dive into how AgentPack parses, chunks, and indexes data, see [Architecture & Internals](https://github.com/Vedant1202/agentpack/blob/main/docs/architecture.md).
100
+
101
+ ## Current Limitations & Roadmap
102
+ AgentPack is currently focused on text-based semantic extraction. The following features are on the roadmap but **not yet implemented**:
103
+ - **Image Understanding / Vision**: AgentPack does not currently run OCR or vision models on images embedded within PDFs or Markdown files. Images are currently ignored during the parsing phase.
104
+ - **Complex Table Structures**: While basic CSVs are supported, highly nested or merged-cell tables within PDFs are not perfectly reconstructed yet.
105
+ - **Web Crawling**: You currently need to provide local files. Direct URL scraping is planned.
106
+ - **Cloud Vector DB Integration**: Retrieval currently runs locally using SQLite FTS5 and FastEmbed. Connectors for Pinecone, Weaviate, or Qdrant are planned.
107
+
108
+ ---
109
+ *Built with ❤️ for Agents.*
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agent-context-packager"
7
+ version = "0.1.0"
8
+ description = "A document-to-agent-context compiler."
9
+ authors = [
10
+ { name = "Your Name", email = "your.email@example.com" }
11
+ ]
12
+ readme = "README.md"
13
+ requires-python = ">=3.9"
14
+ dependencies = [
15
+ "typer>=0.9.0",
16
+ "pydantic>=2.0.0",
17
+ "pymupdf>=1.23.0",
18
+ "pandas>=2.0.0",
19
+ "tiktoken>=0.5.0",
20
+ "pyyaml>=6.0",
21
+ "pyinstaller>=6.0.0",
22
+ "tabulate>=0.9.0",
23
+ "fastembed>=0.2.7",
24
+ "numpy>=1.24.0",
25
+ "datasets>=2.0.0",
26
+ "requests>=2.0.0",
27
+ "pathspec>=0.11.0",
28
+ "detect-secrets>=1.4.0"
29
+ ]
30
+
31
+ [project.scripts]
32
+ agentpack = "agentpack.cli:app"
33
+
34
+ [project.optional-dependencies]
35
+ docs = [
36
+ "mkdocs-material>=9.0.0",
37
+ "mkdocstrings[python]>=0.24.0"
38
+ ]
39
+ test = [
40
+ "pytest>=7.0.0",
41
+ "pytest-mock>=3.10.0"
42
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,137 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-context-packager
3
+ Version: 0.1.0
4
+ Summary: A document-to-agent-context compiler.
5
+ Author-email: Your Name <your.email@example.com>
6
+ Requires-Python: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: typer>=0.9.0
9
+ Requires-Dist: pydantic>=2.0.0
10
+ Requires-Dist: pymupdf>=1.23.0
11
+ Requires-Dist: pandas>=2.0.0
12
+ Requires-Dist: tiktoken>=0.5.0
13
+ Requires-Dist: pyyaml>=6.0
14
+ Requires-Dist: pyinstaller>=6.0.0
15
+ Requires-Dist: tabulate>=0.9.0
16
+ Requires-Dist: fastembed>=0.2.7
17
+ Requires-Dist: numpy>=1.24.0
18
+ Requires-Dist: datasets>=2.0.0
19
+ Requires-Dist: requests>=2.0.0
20
+ Requires-Dist: pathspec>=0.11.0
21
+ Requires-Dist: detect-secrets>=1.4.0
22
+ Provides-Extra: docs
23
+ Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
24
+ Requires-Dist: mkdocstrings[python]>=0.24.0; extra == "docs"
25
+ Provides-Extra: test
26
+ Requires-Dist: pytest>=7.0.0; extra == "test"
27
+ Requires-Dist: pytest-mock>=3.10.0; extra == "test"
28
+
29
+ # AgentPack
30
+
31
+ **AgentPack** improves the context pipeline for document-grounded agents.
32
+
33
+ Instead of forcing AI agents to parse messy, disparate file formats (PDFs, CSVs, Markdown, text) at runtime, AgentPack is an offline **document-to-agent-context compiler**. It takes unstructured knowledge bases, turns them into clean semantic chunks with citations, retrieves the right evidence, and sends only high-signal context to the model.
34
+
35
+ ## The Benchmark
36
+ **Given the same LLM, AgentPack provides better context than raw document stuffing or naive RAG.**
37
+
38
+ I benchmarked AgentPack against standard RAG baselines on 42 complex financial queries from [Patronus AI FinanceBench](https://github.com/patronus-ai/financebench). The results prove that AgentPack reduces context bloat, improves evidence retrieval, preserves citations, and helps the exact same LLM produce more grounded answers.
39
+
40
+ **Benchmark Highlights:**
41
+ * **161x Reduction in Token Cost:** Cut context token usage from 424k to 2.6k, saving ~$0.10 per query.
42
+ * **2x Context Relevance:** Vastly outperformed naive chunking in retrieving semantically complete financial tables.
43
+ * **"Lost in the Middle" Prevention:** Outperformed raw document stuffing in correctness by preventing the LLM from drowning in noise.
44
+
45
+ Read the full scientific methodology and results in [BENCHMARK.md](https://github.com/Vedant1202/agentpack/blob/main/BENCHMARK.md).
46
+
47
+ ## Installation
48
+
49
+ You can install AgentPack via pip or npm.
50
+
51
+ **Option 1: Using pip (Python)**
52
+ ```bash
53
+ pip install agent-context-packager
54
+ ```
55
+
56
+ **Option 2: Using npm (Node.js/CLI binary)**
57
+ ```bash
58
+ npm install -g agent-context-packager
59
+ ```
60
+
61
+ **Option 3: From Source**
62
+ ```bash
63
+ git clone https://github.com/Vedant1202/agentpack.git
64
+ cd agentpack
65
+ python3 -m venv venv
66
+ source venv/bin/activate
67
+ pip install -e .
68
+ ```
69
+
70
+ ## Quick Start
71
+
72
+ ### 1. Scan for Secrets (Recommended)
73
+ Before compiling a pack, ensure you aren't accidentally leaking API keys or secrets into the LLM context window. AgentPack automatically installs Yelp's `detect-secrets`.
74
+ ```bash
75
+ detect-secrets scan > .secrets.baseline
76
+ ```
77
+
78
+ ### 2. Compile a Pack
79
+ Point AgentPack at any folder containing your documents (`.txt`, `.md`, `.csv`, `.pdf`).
80
+
81
+ ```bash
82
+ agentpack pack ./my_docs --out ./agentpack-output
83
+ ```
84
+
85
+ **Key Compilation Options:**
86
+ - `--include "*.md,*.txt"`: Only pack specific files or extensions.
87
+ - `--ignore "tests/,drafts/"`: Exclude specific directories or files.
88
+ - `--remove-empty-lines`: Compress text files to save LLM tokens.
89
+ - `--no-gitignore`: Ignore `.gitignore` rules and pack everything.
90
+
91
+ ### 2. Retrieve
92
+ AgentPack comes with a built-in hybrid search engine (SQLite FTS5 + FastEmbed vector search) to test your chunks instantly.
93
+
94
+ ```bash
95
+ agentpack retrieve ./agentpack-output "eligibility criteria" --top-k 5
96
+ ```
97
+
98
+ ### 3. V1 Deterministic Eval
99
+ Benchmark AgentPack against naive chunking using our offline evaluation harness.
100
+
101
+ ```bash
102
+ agentpack eval ./benchmarks/my_dataset
103
+ ```
104
+
105
+ ## Comprehensive CLI Documentation
106
+
107
+ AgentPack provides a rich CLI for auditing, validating, and testing your context packs (including Generative QA evaluations).
108
+
109
+ **[📖 Read the full CLI Reference](https://github.com/Vedant1202/agentpack/blob/main/docs/cli-reference.md)**
110
+
111
+ ## Supported Parsers
112
+ - **TXT**: Paragraph-aware splitting.
113
+ - **Markdown**: Semantic heading-aware section path tracking.
114
+ - **CSV**: Uses Pandas & Tabulate to convert tabular data into Markdown tables.
115
+ - **PDF**: Accurate page-by-page PyMuPDF extraction.
116
+
117
+ ## Architecture Overview
118
+
119
+ ```mermaid
120
+ flowchart LR
121
+ Docs[Raw Docs] --> Parsers[Parsers]
122
+ Parsers --> Chunker[Chunker]
123
+ Chunker --> Pack[Context Pack]
124
+ Pack --> Agent[LLM Agent]
125
+ ```
126
+
127
+ For a deep dive into how AgentPack parses, chunks, and indexes data, see [Architecture & Internals](https://github.com/Vedant1202/agentpack/blob/main/docs/architecture.md).
128
+
129
+ ## Current Limitations & Roadmap
130
+ AgentPack is currently focused on text-based semantic extraction. The following features are on the roadmap but **not yet implemented**:
131
+ - **Image Understanding / Vision**: AgentPack does not currently run OCR or vision models on images embedded within PDFs or Markdown files. Images are currently ignored during the parsing phase.
132
+ - **Complex Table Structures**: While basic CSVs are supported, highly nested or merged-cell tables within PDFs are not perfectly reconstructed yet.
133
+ - **Web Crawling**: You currently need to provide local files. Direct URL scraping is planned.
134
+ - **Cloud Vector DB Integration**: Retrieval currently runs locally using SQLite FTS5 and FastEmbed. Connectors for Pinecone, Weaviate, or Qdrant are planned.
135
+
136
+ ---
137
+ *Built with ❤️ for Agents.*
@@ -0,0 +1,36 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/agent_context_packager.egg-info/PKG-INFO
4
+ src/agent_context_packager.egg-info/SOURCES.txt
5
+ src/agent_context_packager.egg-info/dependency_links.txt
6
+ src/agent_context_packager.egg-info/entry_points.txt
7
+ src/agent_context_packager.egg-info/requires.txt
8
+ src/agent_context_packager.egg-info/top_level.txt
9
+ src/agentpack/__init__.py
10
+ src/agentpack/__main__.py
11
+ src/agentpack/audit.py
12
+ src/agentpack/chunker.py
13
+ src/agentpack/cli.py
14
+ src/agentpack/models.py
15
+ src/agentpack/pack.py
16
+ src/agentpack/retrieve.py
17
+ src/agentpack/scanner.py
18
+ src/agentpack/validate.py
19
+ src/agentpack/eval/__init__.py
20
+ src/agentpack/eval/baselines.py
21
+ src/agentpack/eval/benchmarks.py
22
+ src/agentpack/eval/generation.py
23
+ src/agentpack/eval/metrics.py
24
+ src/agentpack/eval/runner.py
25
+ src/agentpack/parsers/__init__.py
26
+ src/agentpack/parsers/base.py
27
+ src/agentpack/parsers/csv_parser.py
28
+ src/agentpack/parsers/markdown_parser.py
29
+ src/agentpack/parsers/pdf_parser.py
30
+ src/agentpack/parsers/text_parser.py
31
+ tests/test_chunker.py
32
+ tests/test_cli.py
33
+ tests/test_pack.py
34
+ tests/test_parsers.py
35
+ tests/test_retrieve.py
36
+ tests/test_scanner.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ agentpack = agentpack.cli:app
@@ -0,0 +1,22 @@
1
+ typer>=0.9.0
2
+ pydantic>=2.0.0
3
+ pymupdf>=1.23.0
4
+ pandas>=2.0.0
5
+ tiktoken>=0.5.0
6
+ pyyaml>=6.0
7
+ pyinstaller>=6.0.0
8
+ tabulate>=0.9.0
9
+ fastembed>=0.2.7
10
+ numpy>=1.24.0
11
+ datasets>=2.0.0
12
+ requests>=2.0.0
13
+ pathspec>=0.11.0
14
+ detect-secrets>=1.4.0
15
+
16
+ [docs]
17
+ mkdocs-material>=9.0.0
18
+ mkdocstrings[python]>=0.24.0
19
+
20
+ [test]
21
+ pytest>=7.0.0
22
+ pytest-mock>=3.10.0
@@ -0,0 +1 @@
1
+ """AgentPack compiler package."""
@@ -0,0 +1,4 @@
1
+ from agentpack.cli import app
2
+
3
+ if __name__ == "__main__":
4
+ app()
@@ -0,0 +1,65 @@
1
+ import yaml
2
+ from pathlib import Path
3
+
4
+ def audit_pack(pack_dir: str) -> str:
5
+ """Generates an audit report for an agentpack output directory."""
6
+ base_path = Path(pack_dir)
7
+ manifest_path = base_path / "manifest.yml"
8
+
9
+ if not manifest_path.exists():
10
+ return f"Error: Manifest not found at {manifest_path}"
11
+
12
+ try:
13
+ with open(manifest_path, "r", encoding="utf-8") as f:
14
+ manifest = yaml.safe_load(f)
15
+ except Exception as e:
16
+ return f"Error: Failed to parse manifest YAML: {e}"
17
+
18
+ sources = manifest.get("sources", [])
19
+ chunks = manifest.get("chunks", [])
20
+ tables = manifest.get("tables", [])
21
+
22
+ files_processed = len(sources)
23
+ total_chunks = len(chunks)
24
+ total_tables = len(tables)
25
+ total_tokens = sum(chunk.get("token_count", 0) for chunk in chunks)
26
+
27
+ max_chunk_size = 0
28
+ largest_chunk_id = None
29
+ for chunk in chunks:
30
+ if chunk.get("token_count", 0) > max_chunk_size:
31
+ max_chunk_size = chunk.get("token_count", 0)
32
+ largest_chunk_id = chunk.get("id")
33
+
34
+ warnings = []
35
+ for source in sources:
36
+ for warning in source.get("warnings", []):
37
+ warnings.append(f"Source {source.get('id')}: [{warning.get('type')}] {warning.get('message')}")
38
+
39
+ # Format report
40
+ report = [
41
+ f"# AgentPack Audit Report for '{manifest.get('pack', {}).get('name', 'Unknown')}'",
42
+ f"Generated at: {manifest.get('pack', {}).get('generated_at', 'Unknown')}\n",
43
+ "## Statistics",
44
+ f"- **Files Processed:** {files_processed}",
45
+ f"- **Total Chunks:** {total_chunks}",
46
+ f"- **Total Tables:** {total_tables}",
47
+ f"- **Total Tokens:** {total_tokens}",
48
+ f"- **Largest Chunk:** {max_chunk_size} tokens (ID: {largest_chunk_id})\n",
49
+ "## Extraction Warnings",
50
+ ]
51
+
52
+ if warnings:
53
+ for warning in warnings:
54
+ report.append(f"- {warning}")
55
+ else:
56
+ report.append("- No extraction warnings.")
57
+
58
+ # Write report
59
+ report_text = "\n".join(report)
60
+ report_path = base_path / "reports" / "validation_report.md"
61
+ report_path.parent.mkdir(exist_ok=True)
62
+ with open(report_path, "w", encoding="utf-8") as f:
63
+ f.write(report_text)
64
+
65
+ return report_text
@@ -0,0 +1,80 @@
1
+ import tiktoken
2
+ from typing import List
3
+ from agentpack.models import SourceDocument
4
+
5
+ class Chunk:
6
+ def __init__(self, chunk_id: str, source_id: str, path: str, token_count: int, content: str, metadata: dict):
7
+ self.chunk_id = chunk_id
8
+ self.source_id = source_id
9
+ self.path = path
10
+ self.token_count = token_count
11
+ self.content = content
12
+ self.metadata = metadata
13
+
14
+ def chunk_document(doc: SourceDocument, max_tokens: int = 800, overlap_percent: float = 0.15) -> List[Chunk]:
15
+ encoder = tiktoken.get_encoding("cl100k_base")
16
+ chunks = []
17
+
18
+ current_blocks = []
19
+ current_tokens = 0
20
+ current_metadata = {"source_path": doc.path}
21
+ chunk_index = 0
22
+
23
+ overlap_tokens_target = int(max_tokens * overlap_percent)
24
+
25
+ def create_chunk():
26
+ nonlocal current_blocks, current_tokens, chunk_index, current_metadata
27
+ if not current_blocks:
28
+ return
29
+ content_str = "\n\n".join([b["text"] for b in current_blocks])
30
+ chunk_id = f"{doc.source_id}_chunk_{chunk_index:03d}"
31
+ chunks.append(Chunk(
32
+ chunk_id=chunk_id,
33
+ source_id=doc.source_id,
34
+ path=f"chunks/{chunk_id}.md",
35
+ token_count=current_tokens,
36
+ content=content_str,
37
+ metadata=current_metadata.copy()
38
+ ))
39
+ chunk_index += 1
40
+
41
+ # Keep blocks for overlap
42
+ overlap_blocks = []
43
+ overlap_toks = 0
44
+ for b in reversed(current_blocks):
45
+ if overlap_toks + b["tokens"] > overlap_tokens_target:
46
+ break
47
+ # don't overlap tables to avoid duplicating massive tables
48
+ if b["type"] == "table" and overlap_toks > 0:
49
+ break
50
+ overlap_blocks.insert(0, b)
51
+ overlap_toks += b["tokens"]
52
+
53
+ current_blocks = overlap_blocks
54
+ current_tokens = overlap_toks
55
+
56
+ for block in doc.blocks:
57
+ if not block.text:
58
+ continue
59
+
60
+ block_tokens = len(encoder.encode(block.text))
61
+
62
+ # Update metadata
63
+ if block.section_path:
64
+ current_metadata["section"] = block.section_path[-1]
65
+ if block.page:
66
+ current_metadata["page"] = block.page
67
+
68
+ if block.row_range:
69
+ current_metadata["row_range"] = list(block.row_range)
70
+
71
+ # Very large blocks might exceed max_tokens, in a full implementation we'd split the block itself.
72
+ # For this MVP, we will just start a new chunk if adding this block pushes us over, unless we are empty.
73
+ if current_tokens + block_tokens > max_tokens and current_tokens > 0:
74
+ create_chunk()
75
+
76
+ current_blocks.append({"text": block.text, "tokens": block_tokens, "type": block.type})
77
+ current_tokens += block_tokens
78
+
79
+ create_chunk()
80
+ return chunks