MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / load_directory

Function load_directory

core/context.py:101–123  ·  view source on GitHub ↗
(path, extensions=None, max_files=10)

Source from the content-addressed store, hash-verified

99 return loaded
100
101def load_directory(path, extensions=None, max_files=10):
102 default_exts = {".py",".js",".ts",".sh",".md",".json",
103 ".yaml",".yml",".toml",".txt",".html",".css",
104 ".c",".cpp",".h",".rs",".go"}
105 exts = set(extensions) if extensions else default_exts
106 p = Path(path).expanduser()
107 if not p.is_dir():
108 warning(f"Not a directory: {path}")
109 return []
110 files = sorted([
111 f for f in p.rglob("*")
112 if f.is_file()
113 and f.suffix in exts
114 and not is_ignored(f)
115 ])[:max_files]
116 loaded = []
117 for f in files:
118 r = load_file(str(f))
119 if not r.startswith("[ERROR]"):
120 loaded.append(str(f))
121 if loaded:
122 info(f"Loaded {len(loaded)} files from {path}")
123 return loaded
124
125def unload_file(path):
126 p = Path(path).expanduser().resolve()

Callers

nothing calls this directly

Calls 7

warningFunction · 0.90
infoFunction · 0.90
is_ignoredFunction · 0.85
load_fileFunction · 0.85
is_dirMethod · 0.80
is_fileMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected