-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync_src.py
More file actions
106 lines (88 loc) · 3.2 KB
/
Copy pathsync_src.py
File metadata and controls
106 lines (88 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
"""Быстрая синхронизация src/ из dev-репо в install-папку Zed.
Использование:
python scripts/sync_src.py [--full]
Копирует только src/, tests/, scripts/, pyproject.toml, requirements.txt.
venv, .git, .codebase_indices, AGENT_DIARY.md — НЕ трогает.
После sync нужно перезапустить Zed (или хотя бы перезапустить MCP-процесс).
"""
import argparse
import shutil
import sys
from pathlib import Path
SOURCE = Path(__file__).resolve().parent.parent # D:\Project\MSCodeBase
TARGET = Path(r"C:\Users\misha\AppData\Local\Zed\extensions\mscodebase-intelligence")
# Что копировать (относительно SOURCE)
COPY_DIRS = ["src", "tests", "scripts", "docs"]
COPY_FILES = [
"pyproject.toml",
"requirements.txt",
"MANIFEST.in",
"AGENTS.md",
"AGENT_DIARY.md", # на случай если в install пусто
"CHANGELOG.md",
"README.md",
"SECURITY.md",
"CONTRIBUTING.md",
"QUICKSTART.md",
"fix_zed_settings.bat",
"sync_to_installed.bat",
"install.bat",
".zed.settings.json.example",
"install.py",
]
# Что НЕ копировать (даже если попало в COPY_DIRS)
IGNORE = shutil.ignore_patterns(
"__pycache__", "*.pyc", "*.pyo", "*.pyd",
".pytest_cache", ".mypy_cache", ".ruff_cache",
".codebase_indices", # индекс не копируем
".env", # секреты
"node_modules",
)
def sync_dir(rel: str) -> int:
src = SOURCE / rel
dst = TARGET / rel
if not src.exists():
print(f" [skip] {rel} — not in source")
return 0
if dst.exists():
shutil.rmtree(dst)
shutil.copytree(src, dst, ignore=IGNORE)
n = sum(1 for _ in dst.rglob("*") if _.is_file())
print(f" [ok] {rel}/ -> {dst} ({n} files)")
return n
def sync_file(rel: str) -> int:
src = SOURCE / rel
dst = TARGET / rel
if not src.exists():
print(f" [skip] {rel} — not in source")
return 0
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(src, dst)
print(f" [ok] {rel} -> {dst}")
return 1
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--full", action="store_true", help="Полная синхронизация (по умолчанию — только src/)")
args = parser.parse_args()
if not TARGET.exists():
print(f"[ERROR] Install dir not found: {TARGET}")
print(f" Сначала запустите install.bat")
sys.exit(1)
print(f"Source: {SOURCE}")
print(f"Target: {TARGET}")
print(f"Mode: {'FULL' if args.full else 'src/ only'}")
print()
total = 0
for d in COPY_DIRS:
total += sync_dir(d)
for f in COPY_FILES:
total += sync_file(f)
print()
print(f"=== Synced {total} files ===")
print()
print("Next steps:")
print(" 1. Закройте Zed (все окна)")
print(" 2. Откройте Zed снова — MCP/LSP подхватят новый код")
print(" 3. Или убейте python.exe и подождите пока Zed перезапустит")
if __name__ == "__main__":
main()