context-forge-local 1.0.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.
- context_forge_local-1.0.0/.gitignore +44 -0
- context_forge_local-1.0.0/LICENSE +21 -0
- context_forge_local-1.0.0/PKG-INFO +61 -0
- context_forge_local-1.0.0/README.md +52 -0
- context_forge_local-1.0.0/pyproject.toml +50 -0
- context_forge_local-1.0.0/src/context_forge/__init__.py +1 -0
- context_forge_local-1.0.0/src/context_forge/application/__init__.py +11 -0
- context_forge_local-1.0.0/src/context_forge/application/factory.py +69 -0
- context_forge_local-1.0.0/src/context_forge/application/service.py +62 -0
- context_forge_local-1.0.0/src/context_forge/classifier/__init__.py +1 -0
- context_forge_local-1.0.0/src/context_forge/classifier/project.py +131 -0
- context_forge_local-1.0.0/src/context_forge/comparison/__init__.py +29 -0
- context_forge_local-1.0.0/src/context_forge/comparison/models.py +391 -0
- context_forge_local-1.0.0/src/context_forge/comparison/service.py +978 -0
- context_forge_local-1.0.0/src/context_forge/config/__init__.py +56 -0
- context_forge_local-1.0.0/src/context_forge/config/audit.py +238 -0
- context_forge_local-1.0.0/src/context_forge/config/defaults.py +10 -0
- context_forge_local-1.0.0/src/context_forge/config/global_config.py +28 -0
- context_forge_local-1.0.0/src/context_forge/config/loader.py +78 -0
- context_forge_local-1.0.0/src/context_forge/config/loading.py +16 -0
- context_forge_local-1.0.0/src/context_forge/config/project.py +139 -0
- context_forge_local-1.0.0/src/context_forge/config/resolver.py +35 -0
- context_forge_local-1.0.0/src/context_forge/config/validation.py +347 -0
- context_forge_local-1.0.0/src/context_forge/context/__init__.py +89 -0
- context_forge_local-1.0.0/src/context_forge/context/assembly.py +21 -0
- context_forge_local-1.0.0/src/context_forge/context/budget_compression.py +55 -0
- context_forge_local-1.0.0/src/context_forge/context/candidate.py +26 -0
- context_forge_local-1.0.0/src/context_forge/context/candidates.py +441 -0
- context_forge_local-1.0.0/src/context_forge/context/compression.py +9 -0
- context_forge_local-1.0.0/src/context_forge/context/compression_models.py +23 -0
- context_forge_local-1.0.0/src/context_forge/context/compression_pipeline.py +25 -0
- context_forge_local-1.0.0/src/context_forge/context/depth.py +79 -0
- context_forge_local-1.0.0/src/context_forge/context/deterministic_compression.py +132 -0
- context_forge_local-1.0.0/src/context_forge/context/engine.py +107 -0
- context_forge_local-1.0.0/src/context_forge/context/enrichment.py +14 -0
- context_forge_local-1.0.0/src/context_forge/context/enrichment_pipeline.py +19 -0
- context_forge_local-1.0.0/src/context_forge/context/expansion.py +133 -0
- context_forge_local-1.0.0/src/context_forge/context/file_enrichment.py +70 -0
- context_forge_local-1.0.0/src/context_forge/context/git_relevance.py +31 -0
- context_forge_local-1.0.0/src/context_forge/context/models.py +56 -0
- context_forge_local-1.0.0/src/context_forge/context/package.py +164 -0
- context_forge_local-1.0.0/src/context_forge/context/prioritization.py +50 -0
- context_forge_local-1.0.0/src/context_forge/context/priority.py +11 -0
- context_forge_local-1.0.0/src/context_forge/context/priority_ordering.py +34 -0
- context_forge_local-1.0.0/src/context_forge/context/ranking.py +56 -0
- context_forge_local-1.0.0/src/context_forge/context/relationship_enrichment.py +43 -0
- context_forge_local-1.0.0/src/context_forge/context/request.py +12 -0
- context_forge_local-1.0.0/src/context_forge/context/retrieval.py +241 -0
- context_forge_local-1.0.0/src/context_forge/context/selection.py +44 -0
- context_forge_local-1.0.0/src/context_forge/context/serialization.py +67 -0
- context_forge_local-1.0.0/src/context_forge/context/signals.py +21 -0
- context_forge_local-1.0.0/src/context_forge/context/symbol_enrichment.py +82 -0
- context_forge_local-1.0.0/src/context_forge/context/types.py +7 -0
- context_forge_local-1.0.0/src/context_forge/evaluation/__init__.py +67 -0
- context_forge_local-1.0.0/src/context_forge/evaluation/baseline.py +188 -0
- context_forge_local-1.0.0/src/context_forge/evaluation/end_to_end.py +85 -0
- context_forge_local-1.0.0/src/context_forge/evaluation/ground_truth.py +47 -0
- context_forge_local-1.0.0/src/context_forge/evaluation/metrics.py +32 -0
- context_forge_local-1.0.0/src/context_forge/evaluation/models.py +46 -0
- context_forge_local-1.0.0/src/context_forge/evaluation/regression.py +103 -0
- context_forge_local-1.0.0/src/context_forge/evaluation/repositories.py +216 -0
- context_forge_local-1.0.0/src/context_forge/evaluation/retrieval.py +139 -0
- context_forge_local-1.0.0/src/context_forge/evaluation/selection.py +102 -0
- context_forge_local-1.0.0/src/context_forge/evaluation/structural.py +156 -0
- context_forge_local-1.0.0/src/context_forge/extractor/__init__.py +1 -0
- context_forge_local-1.0.0/src/context_forge/git/__init__.py +35 -0
- context_forge_local-1.0.0/src/context_forge/git/intelligence.py +28 -0
- context_forge_local-1.0.0/src/context_forge/git/models.py +137 -0
- context_forge_local-1.0.0/src/context_forge/git/navigation.py +560 -0
- context_forge_local-1.0.0/src/context_forge/git/repository.py +484 -0
- context_forge_local-1.0.0/src/context_forge/graph/__init__.py +1 -0
- context_forge_local-1.0.0/src/context_forge/graph/builder.py +565 -0
- context_forge_local-1.0.0/src/context_forge/inspection/__init__.py +13 -0
- context_forge_local-1.0.0/src/context_forge/inspection/models.py +103 -0
- context_forge_local-1.0.0/src/context_forge/inspection/workflow.py +679 -0
- context_forge_local-1.0.0/src/context_forge/main.py +4272 -0
- context_forge_local-1.0.0/src/context_forge/models/__init__.py +1 -0
- context_forge_local-1.0.0/src/context_forge/models/directory.py +20 -0
- context_forge_local-1.0.0/src/context_forge/models/enums.py +25 -0
- context_forge_local-1.0.0/src/context_forge/models/file.py +24 -0
- context_forge_local-1.0.0/src/context_forge/models/project.py +92 -0
- context_forge_local-1.0.0/src/context_forge/models/relationship.py +30 -0
- context_forge_local-1.0.0/src/context_forge/models/symbol.py +34 -0
- context_forge_local-1.0.0/src/context_forge/operational_logging.py +107 -0
- context_forge_local-1.0.0/src/context_forge/parser/__init__.py +15 -0
- context_forge_local-1.0.0/src/context_forge/parser/base.py +16 -0
- context_forge_local-1.0.0/src/context_forge/parser/detector.py +26 -0
- context_forge_local-1.0.0/src/context_forge/parser/language.py +13 -0
- context_forge_local-1.0.0/src/context_forge/parser/python.py +316 -0
- context_forge_local-1.0.0/src/context_forge/parser/registry.py +24 -0
- context_forge_local-1.0.0/src/context_forge/parser/result.py +56 -0
- context_forge_local-1.0.0/src/context_forge/pipeline/__init__.py +13 -0
- context_forge_local-1.0.0/src/context_forge/pipeline/analyzer.py +309 -0
- context_forge_local-1.0.0/src/context_forge/pipeline/freshness.py +643 -0
- context_forge_local-1.0.0/src/context_forge/preflight/__init__.py +11 -0
- context_forge_local-1.0.0/src/context_forge/preflight/readiness.py +519 -0
- context_forge_local-1.0.0/src/context_forge/query/__init__.py +194 -0
- context_forge_local-1.0.0/src/context_forge/query/architecture.py +70 -0
- context_forge_local-1.0.0/src/context_forge/query/architecture_report.py +417 -0
- context_forge_local-1.0.0/src/context_forge/query/changeset.py +820 -0
- context_forge_local-1.0.0/src/context_forge/query/health.py +318 -0
- context_forge_local-1.0.0/src/context_forge/query/impact.py +1103 -0
- context_forge_local-1.0.0/src/context_forge/query/locator.py +663 -0
- context_forge_local-1.0.0/src/context_forge/query/package_boundary.py +519 -0
- context_forge_local-1.0.0/src/context_forge/query/path.py +532 -0
- context_forge_local-1.0.0/src/context_forge/query/post_change.py +641 -0
- context_forge_local-1.0.0/src/context_forge/query/project.py +1515 -0
- context_forge_local-1.0.0/src/context_forge/query/regression_rules.py +738 -0
- context_forge_local-1.0.0/src/context_forge/query/result.py +20 -0
- context_forge_local-1.0.0/src/context_forge/query/risk.py +862 -0
- context_forge_local-1.0.0/src/context_forge/query/unused.py +1012 -0
- context_forge_local-1.0.0/src/context_forge/query/verification.py +900 -0
- context_forge_local-1.0.0/src/context_forge/reporting/__init__.py +37 -0
- context_forge_local-1.0.0/src/context_forge/reporting/contract.py +396 -0
- context_forge_local-1.0.0/src/context_forge/reporting/errors.py +223 -0
- context_forge_local-1.0.0/src/context_forge/reporting/formatter.py +68 -0
- context_forge_local-1.0.0/src/context_forge/scanner/__init__.py +1 -0
- context_forge_local-1.0.0/src/context_forge/scanner/repository.py +278 -0
- context_forge_local-1.0.0/src/context_forge/storage/__init__.py +1 -0
- context_forge_local-1.0.0/src/context_forge/storage/cache.py +192 -0
- context_forge_local-1.0.0/src/context_forge/storage/database.py +180 -0
- context_forge_local-1.0.0/src/context_forge/storage/repository.py +1009 -0
- context_forge_local-1.0.0/src/context_forge/task/__init__.py +31 -0
- context_forge_local-1.0.0/src/context_forge/task/grounding.py +188 -0
- context_forge_local-1.0.0/src/context_forge/task/models.py +92 -0
- context_forge_local-1.0.0/src/context_forge/task/repository_grounding.py +95 -0
- context_forge_local-1.0.0/src/context_forge/task/service.py +99 -0
- context_forge_local-1.0.0/src/context_forge/task/validation.py +56 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Virtual environment
|
|
2
|
+
.venv/
|
|
3
|
+
|
|
4
|
+
# Python cache
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.py[cod]
|
|
7
|
+
*$py.class
|
|
8
|
+
|
|
9
|
+
# Testing
|
|
10
|
+
.pytest_cache/
|
|
11
|
+
.coverage
|
|
12
|
+
.coverage.*
|
|
13
|
+
htmlcov/
|
|
14
|
+
|
|
15
|
+
# Ruff
|
|
16
|
+
.ruff_cache/
|
|
17
|
+
|
|
18
|
+
# Build / packaging
|
|
19
|
+
build/
|
|
20
|
+
dist/
|
|
21
|
+
*.egg-info/
|
|
22
|
+
|
|
23
|
+
# Environment / secrets
|
|
24
|
+
.env
|
|
25
|
+
.env.*
|
|
26
|
+
!.env.example
|
|
27
|
+
|
|
28
|
+
# IDE
|
|
29
|
+
.vscode/
|
|
30
|
+
.idea/
|
|
31
|
+
|
|
32
|
+
# macOS
|
|
33
|
+
.DS_Store
|
|
34
|
+
|
|
35
|
+
# Local project data
|
|
36
|
+
data/
|
|
37
|
+
.context_forge*.db
|
|
38
|
+
|
|
39
|
+
#other test files
|
|
40
|
+
tp*.py
|
|
41
|
+
tp*.md
|
|
42
|
+
tp*.txt
|
|
43
|
+
/docs/
|
|
44
|
+
/tp_docs/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 VEX
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: context-forge-local
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Deterministic, local-first repository intelligence and memory vault for Python projects.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.13
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# Context Forge
|
|
11
|
+
|
|
12
|
+
Context Forge is a deterministic, local-first repository intelligence and a memory vault for Python projects.
|
|
13
|
+
|
|
14
|
+
It helps developers understand codebases by analyzing repository structure, relationships, and code context through a command-line interface.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
### Using uv
|
|
19
|
+
|
|
20
|
+
Install Context Forge as a standalone CLI tool:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
uv tool install context-forge-local
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Using pip
|
|
27
|
+
|
|
28
|
+
Install Context Forge inside an active Python virtual environment:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
python -m pip install context-forge-local
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Requirements:** Python 3.13 or newer.
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
Context Forge provides two command names:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
cf --help
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
or
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
context-forge --help
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Use the help output to explore the available commands and options.
|
|
51
|
+
|
|
52
|
+
## Design Principles
|
|
53
|
+
|
|
54
|
+
- **Local-first:** Designed to work locally with your repositories.
|
|
55
|
+
- **Deterministic:** Aims to produce consistent results for the same inputs and repository state.
|
|
56
|
+
- **Repository-aware:** Analyzes project structure and code relationships.
|
|
57
|
+
- **Developer-focused:** Provides command-line tools for repository intelligence and code context.
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
See the `LICENSE` file for licensing information.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Context Forge
|
|
2
|
+
|
|
3
|
+
Context Forge is a deterministic, local-first repository intelligence and a memory vault for Python projects.
|
|
4
|
+
|
|
5
|
+
It helps developers understand codebases by analyzing repository structure, relationships, and code context through a command-line interface.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
### Using uv
|
|
10
|
+
|
|
11
|
+
Install Context Forge as a standalone CLI tool:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
uv tool install context-forge-local
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Using pip
|
|
18
|
+
|
|
19
|
+
Install Context Forge inside an active Python virtual environment:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
python -m pip install context-forge-local
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Requirements:** Python 3.13 or newer.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
Context Forge provides two command names:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
cf --help
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
or
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
context-forge --help
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Use the help output to explore the available commands and options.
|
|
42
|
+
|
|
43
|
+
## Design Principles
|
|
44
|
+
|
|
45
|
+
- **Local-first:** Designed to work locally with your repositories.
|
|
46
|
+
- **Deterministic:** Aims to produce consistent results for the same inputs and repository state.
|
|
47
|
+
- **Repository-aware:** Analyzes project structure and code relationships.
|
|
48
|
+
- **Developer-focused:** Provides command-line tools for repository intelligence and code context.
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
See the `LICENSE` file for licensing information.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "context-forge-local"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "Deterministic, local-first repository intelligence and memory vault for Python projects."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
dependencies = []
|
|
9
|
+
|
|
10
|
+
[project.scripts]
|
|
11
|
+
context-forge = "context_forge.main:main"
|
|
12
|
+
cf = "context_forge.main:main"
|
|
13
|
+
|
|
14
|
+
[dependency-groups]
|
|
15
|
+
dev = [
|
|
16
|
+
"pytest",
|
|
17
|
+
"ruff",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[build-system]
|
|
21
|
+
requires = ["hatchling"]
|
|
22
|
+
build-backend = "hatchling.build"
|
|
23
|
+
|
|
24
|
+
[tool.hatch.build.targets.wheel]
|
|
25
|
+
packages = ["src/context_forge"]
|
|
26
|
+
exclude = [
|
|
27
|
+
"**/.DS_Store",
|
|
28
|
+
"**/__pycache__/**",
|
|
29
|
+
"**/*.py[cod]",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[tool.hatch.build.targets.sdist]
|
|
33
|
+
only-include = [
|
|
34
|
+
"LICENSE",
|
|
35
|
+
"README.md",
|
|
36
|
+
"pyproject.toml",
|
|
37
|
+
"src/context_forge",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[tool.ruff]
|
|
41
|
+
line-length = 88
|
|
42
|
+
|
|
43
|
+
[tool.pytest.ini_options]
|
|
44
|
+
pythonpath = ["src"]
|
|
45
|
+
markers = [
|
|
46
|
+
"integration: tests requiring external services",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[tool.ruff.lint.per-file-ignores]
|
|
50
|
+
"test-projects/full_projects/01_task_management/src/task_mgmt/repositories/base.py" = ["UP046"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from context_forge.application.factory import (
|
|
2
|
+
build_context_engine,
|
|
3
|
+
build_context_service,
|
|
4
|
+
)
|
|
5
|
+
from context_forge.application.service import RepositoryContextService
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"RepositoryContextService",
|
|
9
|
+
"build_context_engine",
|
|
10
|
+
"build_context_service",
|
|
11
|
+
]
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from context_forge.application.service import RepositoryContextService
|
|
2
|
+
from context_forge.context import (
|
|
3
|
+
CandidateGenerator,
|
|
4
|
+
ContextAssembler,
|
|
5
|
+
ContextBudgetCompressor,
|
|
6
|
+
ContextCompressionPipeline,
|
|
7
|
+
ContextEnrichmentPipeline,
|
|
8
|
+
ContextPackageBuilder,
|
|
9
|
+
ContextPriorityOrdering,
|
|
10
|
+
ContextSelector,
|
|
11
|
+
DefaultContextEngine,
|
|
12
|
+
DeterministicContextCompressor,
|
|
13
|
+
DeterministicPrioritizer,
|
|
14
|
+
DeterministicRanker,
|
|
15
|
+
FileContextEnricher,
|
|
16
|
+
GraphExpander,
|
|
17
|
+
RelationshipContextEnricher,
|
|
18
|
+
SymbolContextEnricher,
|
|
19
|
+
)
|
|
20
|
+
from context_forge.context.depth import ContextDepthSelector
|
|
21
|
+
from context_forge.task import (
|
|
22
|
+
TaskGroundingService,
|
|
23
|
+
TaskRepositoryGroundingService,
|
|
24
|
+
TaskUnderstandingService,
|
|
25
|
+
TaskValidator,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def build_context_engine(
|
|
30
|
+
max_context_units: int = 20,
|
|
31
|
+
) -> DefaultContextEngine:
|
|
32
|
+
return DefaultContextEngine(
|
|
33
|
+
candidate_generator=CandidateGenerator(),
|
|
34
|
+
ranker=DeterministicRanker(),
|
|
35
|
+
selector=ContextSelector(),
|
|
36
|
+
depth_selector=ContextDepthSelector(),
|
|
37
|
+
expander=GraphExpander(),
|
|
38
|
+
package_builder=ContextPackageBuilder(),
|
|
39
|
+
enrichment_pipeline=ContextEnrichmentPipeline(
|
|
40
|
+
enrichers=[
|
|
41
|
+
FileContextEnricher(),
|
|
42
|
+
SymbolContextEnricher(),
|
|
43
|
+
RelationshipContextEnricher(),
|
|
44
|
+
],
|
|
45
|
+
),
|
|
46
|
+
compression_pipeline=ContextCompressionPipeline(
|
|
47
|
+
compressor=DeterministicContextCompressor(),
|
|
48
|
+
budget_compressor=ContextBudgetCompressor(),
|
|
49
|
+
),
|
|
50
|
+
assembly=ContextAssembler(
|
|
51
|
+
ContextPriorityOrdering(
|
|
52
|
+
DeterministicPrioritizer(),
|
|
53
|
+
),
|
|
54
|
+
),
|
|
55
|
+
max_context_units=max_context_units,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def build_context_service(
|
|
60
|
+
max_context_units: int = 20,
|
|
61
|
+
) -> RepositoryContextService:
|
|
62
|
+
engine = build_context_engine(max_context_units=max_context_units)
|
|
63
|
+
return RepositoryContextService(
|
|
64
|
+
engine=engine,
|
|
65
|
+
task_understanding=TaskUnderstandingService(),
|
|
66
|
+
task_validator=TaskValidator(),
|
|
67
|
+
task_grounding=TaskGroundingService(),
|
|
68
|
+
task_repository_grounding=TaskRepositoryGroundingService(),
|
|
69
|
+
)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from context_forge.context.engine import ContextEngine
|
|
2
|
+
from context_forge.context.models import ContextPackage
|
|
3
|
+
from context_forge.context.request import ContextRequest
|
|
4
|
+
from context_forge.models.project import Project
|
|
5
|
+
from context_forge.task import (
|
|
6
|
+
TaskGroundingService,
|
|
7
|
+
TaskRepositoryGroundingService,
|
|
8
|
+
TaskState,
|
|
9
|
+
TaskUnderstandingService,
|
|
10
|
+
TaskValidator,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class RepositoryContextService:
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
engine: ContextEngine,
|
|
18
|
+
task_understanding: TaskUnderstandingService | None = None,
|
|
19
|
+
task_validator: TaskValidator | None = None,
|
|
20
|
+
task_grounding: TaskGroundingService | None = None,
|
|
21
|
+
task_repository_grounding: TaskRepositoryGroundingService | None = None,
|
|
22
|
+
) -> None:
|
|
23
|
+
self.engine = engine
|
|
24
|
+
self.task_understanding = task_understanding or TaskUnderstandingService()
|
|
25
|
+
self.task_validator = task_validator or TaskValidator()
|
|
26
|
+
self.task_grounding = task_grounding or TaskGroundingService()
|
|
27
|
+
self.task_repository_grounding = (
|
|
28
|
+
task_repository_grounding or TaskRepositoryGroundingService()
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
def retrieve_context(
|
|
32
|
+
self,
|
|
33
|
+
project: Project,
|
|
34
|
+
task: str,
|
|
35
|
+
) -> ContextPackage:
|
|
36
|
+
if not task.strip():
|
|
37
|
+
raise ValueError("task must not be empty")
|
|
38
|
+
|
|
39
|
+
interpretation = self.task_understanding.understand(task)
|
|
40
|
+
validation = self.task_validator.validate(interpretation)
|
|
41
|
+
|
|
42
|
+
if validation.state != TaskState.CLEAR:
|
|
43
|
+
raise ValueError(f"task validation failed: {validation.state.value}")
|
|
44
|
+
|
|
45
|
+
grounded_task = self.task_grounding.ground(
|
|
46
|
+
project,
|
|
47
|
+
interpretation,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
grounding = self.task_repository_grounding.ground(
|
|
51
|
+
project,
|
|
52
|
+
grounded_task,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
return self.engine.build(
|
|
56
|
+
ContextRequest(
|
|
57
|
+
project=project,
|
|
58
|
+
task=task,
|
|
59
|
+
interpretation=interpretation,
|
|
60
|
+
grounding=grounding,
|
|
61
|
+
)
|
|
62
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
from context_forge.models.enums import FileType
|
|
2
|
+
from context_forge.models.project import Project
|
|
3
|
+
|
|
4
|
+
LANGUAGE_BY_EXTENSION = {
|
|
5
|
+
".py": "Python",
|
|
6
|
+
".js": "JavaScript",
|
|
7
|
+
".jsx": "JavaScript",
|
|
8
|
+
".ts": "TypeScript",
|
|
9
|
+
".tsx": "TypeScript",
|
|
10
|
+
".java": "Java",
|
|
11
|
+
".cpp": "C++",
|
|
12
|
+
".cc": "C++",
|
|
13
|
+
".hpp": "C++",
|
|
14
|
+
".c": "C",
|
|
15
|
+
".h": "C",
|
|
16
|
+
".go": "Go",
|
|
17
|
+
".rs": "Rust",
|
|
18
|
+
".rb": "Ruby",
|
|
19
|
+
".swift": "Swift",
|
|
20
|
+
".kt": "Kotlin",
|
|
21
|
+
".php": "PHP",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
DOCUMENTATION_EXTENSIONS = {".md", ".rst", ".txt"}
|
|
25
|
+
|
|
26
|
+
CONFIGURATION_FILES = {
|
|
27
|
+
"pyproject.toml",
|
|
28
|
+
"package.json",
|
|
29
|
+
"package-lock.json",
|
|
30
|
+
"uv.lock",
|
|
31
|
+
"Cargo.toml",
|
|
32
|
+
"go.mod",
|
|
33
|
+
"requirements.txt",
|
|
34
|
+
"Makefile",
|
|
35
|
+
".gitignore",
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
FRAMEWORK_INDICATORS = {
|
|
39
|
+
"fastapi": "FASTAPI",
|
|
40
|
+
"django": "Django",
|
|
41
|
+
"flask": "Flask",
|
|
42
|
+
"react": "React",
|
|
43
|
+
"next": "Next.js",
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ProjectClassifier:
|
|
48
|
+
def classify(self, project: Project) -> Project:
|
|
49
|
+
self._classify_files(project)
|
|
50
|
+
self._detect_languages(project)
|
|
51
|
+
self._detect_project_types(project)
|
|
52
|
+
self._detect_package_manager(project)
|
|
53
|
+
self._detect_frameworks(project)
|
|
54
|
+
|
|
55
|
+
return project
|
|
56
|
+
|
|
57
|
+
def _detect_project_types(self, project: Project) -> None:
|
|
58
|
+
file_names = {file.name for file in project.files}
|
|
59
|
+
|
|
60
|
+
if "pyproject.toml" in file_names:
|
|
61
|
+
project.project_type = "python_project"
|
|
62
|
+
elif "package.json" in file_names:
|
|
63
|
+
project.project_type = "javascript_project"
|
|
64
|
+
elif "Cargo.toml" in file_names:
|
|
65
|
+
project.project_type = "rust_project"
|
|
66
|
+
elif "go.mod" in file_names:
|
|
67
|
+
project.project_type = "go_project"
|
|
68
|
+
elif "pom.xml" in file_names:
|
|
69
|
+
project.project_type = "java_project"
|
|
70
|
+
else:
|
|
71
|
+
project.project_type = "unknown"
|
|
72
|
+
|
|
73
|
+
def _classify_files(self, project: Project) -> None:
|
|
74
|
+
for file in project.files:
|
|
75
|
+
if file.name in CONFIGURATION_FILES:
|
|
76
|
+
file.file_type = FileType.CONFIGURATION
|
|
77
|
+
elif file.extension in DOCUMENTATION_EXTENSIONS:
|
|
78
|
+
file.file_type = FileType.DOCUMENTATION
|
|
79
|
+
elif file.path.parts and "tests" in file.path.parts:
|
|
80
|
+
file.file_type = FileType.TEST
|
|
81
|
+
elif file.extension in LANGUAGE_BY_EXTENSION:
|
|
82
|
+
file.file_type = FileType.SOURCE
|
|
83
|
+
else:
|
|
84
|
+
file.file_type = FileType.UNKNOWN
|
|
85
|
+
|
|
86
|
+
def _detect_languages(self, project: Project):
|
|
87
|
+
languages = {
|
|
88
|
+
LANGUAGE_BY_EXTENSION[file.extension]
|
|
89
|
+
for file in project.files
|
|
90
|
+
if file.extension in LANGUAGE_BY_EXTENSION
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
project.languages = sorted(languages)
|
|
94
|
+
|
|
95
|
+
def _detect_package_manager(self, project: Project) -> None:
|
|
96
|
+
file_names = {file.name for file in project.files}
|
|
97
|
+
|
|
98
|
+
if "uv.lock" in file_names:
|
|
99
|
+
project.package_manager = "uv"
|
|
100
|
+
elif "requirements.txt" in file_names:
|
|
101
|
+
project.package_manager = "pip"
|
|
102
|
+
elif "package-lock.json" in file_names:
|
|
103
|
+
project.package_manager = "npm"
|
|
104
|
+
elif "pnpm-lock.yaml" in file_names:
|
|
105
|
+
project.package_manager = "pnpm"
|
|
106
|
+
elif "yarn.lock" in file_names:
|
|
107
|
+
project.package_manager = "yarn"
|
|
108
|
+
elif "Cargo.toml" in file_names:
|
|
109
|
+
project.package_manager = "cargo"
|
|
110
|
+
elif "go.mod" in file_names:
|
|
111
|
+
project.package_manager = "go"
|
|
112
|
+
|
|
113
|
+
def _detect_frameworks(self, project: Project) -> None:
|
|
114
|
+
detected: set[str] = set()
|
|
115
|
+
|
|
116
|
+
for file in project.files:
|
|
117
|
+
if file.extension != ".py":
|
|
118
|
+
continue
|
|
119
|
+
|
|
120
|
+
try:
|
|
121
|
+
content = (project.root_path / file.path).read_text(encoding="utf-8")
|
|
122
|
+
except (OSError, UnicodeDecodeError):
|
|
123
|
+
continue
|
|
124
|
+
|
|
125
|
+
content_lower = content.lower()
|
|
126
|
+
|
|
127
|
+
for indicator, framework in FRAMEWORK_INDICATORS.items():
|
|
128
|
+
if f"import {indicator}" in content_lower:
|
|
129
|
+
detected.add(framework)
|
|
130
|
+
|
|
131
|
+
project.frameworks = sorted(detected)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from context_forge.comparison.models import (
|
|
4
|
+
AffectedComponent,
|
|
5
|
+
AmbiguousMatch,
|
|
6
|
+
ComparisonState,
|
|
7
|
+
FileDiff,
|
|
8
|
+
RelationshipDiff,
|
|
9
|
+
StateValidationResult,
|
|
10
|
+
StructuralComparisonResult,
|
|
11
|
+
SymbolDiff,
|
|
12
|
+
)
|
|
13
|
+
from context_forge.comparison.service import (
|
|
14
|
+
compare_states,
|
|
15
|
+
validate_comparison_states,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"AffectedComponent",
|
|
20
|
+
"AmbiguousMatch",
|
|
21
|
+
"ComparisonState",
|
|
22
|
+
"FileDiff",
|
|
23
|
+
"RelationshipDiff",
|
|
24
|
+
"StateValidationResult",
|
|
25
|
+
"StructuralComparisonResult",
|
|
26
|
+
"SymbolDiff",
|
|
27
|
+
"compare_states",
|
|
28
|
+
"validate_comparison_states",
|
|
29
|
+
]
|