diffctx 1.17.0__cp310-abi3-win_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- diffctx/__init__.py +91 -0
- diffctx/__main__.py +17 -0
- diffctx/_app.py +667 -0
- diffctx/_diffctx.pyd +4 -0
- diffctx/_diffctx.pyi +109 -0
- diffctx/_native/__init__.py +7 -0
- diffctx/_native/graph_analytics.py +289 -0
- diffctx/_native/graph_export.py +48 -0
- diffctx/_native/pipeline.py +189 -0
- diffctx/_native/project_graph.py +39 -0
- diffctx/cli.py +892 -0
- diffctx/clipboard.py +81 -0
- diffctx/ignore.py +382 -0
- diffctx/logger.py +33 -0
- diffctx/mcp/__init__.py +0 -0
- diffctx/mcp/__main__.py +4 -0
- diffctx/mcp/fetch.py +270 -0
- diffctx/mcp/legacy.py +272 -0
- diffctx/mcp/security.py +75 -0
- diffctx/mcp/server.py +304 -0
- diffctx/py.typed +0 -0
- diffctx/tokens.py +46 -0
- diffctx/tree.py +333 -0
- diffctx/version.py +1 -0
- diffctx/writer.py +875 -0
- diffctx-1.17.0.dist-info/METADATA +366 -0
- diffctx-1.17.0.dist-info/RECORD +31 -0
- diffctx-1.17.0.dist-info/WHEEL +4 -0
- diffctx-1.17.0.dist-info/entry_points.txt +3 -0
- diffctx-1.17.0.dist-info/licenses/LICENSE +201 -0
- diffctx-1.17.0.dist-info/sboms/diffctx.cyclonedx.json +4935 -0
diffctx/__init__.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from ._app import run
|
|
8
|
+
from ._native import build_diff_context
|
|
9
|
+
from .ignore import get_ignore_specs, get_whitelist_spec
|
|
10
|
+
from .tree import TreeBuildContext, build_tree
|
|
11
|
+
from .version import __version__
|
|
12
|
+
from .writer import tree_to_string
|
|
13
|
+
|
|
14
|
+
logging.getLogger("diffctx").addHandler(logging.NullHandler())
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"__version__",
|
|
18
|
+
"build_diff_context",
|
|
19
|
+
"map_directory",
|
|
20
|
+
"run",
|
|
21
|
+
"to_json",
|
|
22
|
+
"to_markdown",
|
|
23
|
+
"to_text",
|
|
24
|
+
"to_yaml",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _root_display_name(user_path: str | Path, resolved: Path) -> str:
|
|
29
|
+
original_name = Path(user_path).name
|
|
30
|
+
if original_name:
|
|
31
|
+
return original_name
|
|
32
|
+
return str(resolved)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _resolve_path_if_exists(path: str | Path | None, label: str) -> Path | None:
|
|
36
|
+
if path is None:
|
|
37
|
+
return None
|
|
38
|
+
resolved = Path(path).resolve()
|
|
39
|
+
if not resolved.is_file():
|
|
40
|
+
raise FileNotFoundError(f"{label} '{path}' does not exist")
|
|
41
|
+
return resolved
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def map_directory(
|
|
45
|
+
path: str | Path,
|
|
46
|
+
*,
|
|
47
|
+
max_depth: int | None = None,
|
|
48
|
+
no_content: bool = False,
|
|
49
|
+
max_file_bytes: int | None = None,
|
|
50
|
+
ignore_file: str | Path | None = None,
|
|
51
|
+
no_default_ignores: bool = False,
|
|
52
|
+
whitelist_file: str | Path | None = None,
|
|
53
|
+
) -> dict[str, Any]:
|
|
54
|
+
root_dir = Path(path).resolve()
|
|
55
|
+
if not root_dir.is_dir():
|
|
56
|
+
raise ValueError(f"'{path}' is not a directory")
|
|
57
|
+
|
|
58
|
+
ignore_path = _resolve_path_if_exists(ignore_file, "Ignore file")
|
|
59
|
+
whitelist_path = _resolve_path_if_exists(whitelist_file, "Whitelist file")
|
|
60
|
+
|
|
61
|
+
ctx = TreeBuildContext(
|
|
62
|
+
base_dir=root_dir,
|
|
63
|
+
combined_spec=get_ignore_specs(root_dir, ignore_path, no_default_ignores, None),
|
|
64
|
+
output_file=None,
|
|
65
|
+
max_depth=max_depth,
|
|
66
|
+
no_content=no_content,
|
|
67
|
+
max_file_bytes=max_file_bytes,
|
|
68
|
+
whitelist_spec=get_whitelist_spec(whitelist_path, root_dir),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
"name": _root_display_name(path, root_dir),
|
|
73
|
+
"type": "directory",
|
|
74
|
+
"children": build_tree(root_dir, ctx),
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def to_yaml(tree: dict[str, Any]) -> str:
|
|
79
|
+
return tree_to_string(tree, "yaml")
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def to_json(tree: dict[str, Any]) -> str:
|
|
83
|
+
return tree_to_string(tree, "json")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def to_text(tree: dict[str, Any]) -> str:
|
|
87
|
+
return tree_to_string(tree, "txt")
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def to_markdown(tree: dict[str, Any]) -> str:
|
|
91
|
+
return tree_to_string(tree, "md")
|
diffctx/__main__.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
# Initialize logging early to avoid Python 3.13 issues with argparse
|
|
5
|
+
# This ensures logging's internal state is fully set up before argparse runs
|
|
6
|
+
try:
|
|
7
|
+
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.ERROR)
|
|
8
|
+
# Force initialization of logging internals
|
|
9
|
+
logging.getLogger()
|
|
10
|
+
except (OSError, ValueError) as e:
|
|
11
|
+
# If logging initialization fails, warn but continue
|
|
12
|
+
print(f"Warning: logging init failed: {e}", file=sys.stderr)
|
|
13
|
+
|
|
14
|
+
from diffctx.cli import main
|
|
15
|
+
|
|
16
|
+
if __name__ == "__main__":
|
|
17
|
+
main()
|