MCPcopy Create free account
hub / github.com/vercel/examples / sync_project_files

Function sync_project_files

python/vibe-coding-ide/backend/src/sandbox/utils.py:90–119  ·  view source on GitHub ↗

Write project files to sandbox. If paths is provided, limits writes to those project-relative files; otherwise writes the entire project mapping.

(
    ctx: RunContextWrapper[IDEContext], sandbox: Sandbox, paths: list[str] | None = None
)

Source from the content-addressed store, hash-verified

88
89
90async def sync_project_files(
91 ctx: RunContextWrapper[IDEContext], sandbox: Sandbox, paths: list[str] | None = None
92) -> int:
93 """Write project files to sandbox.
94
95 If paths is provided, limits writes to those project-relative files;
96 otherwise writes the entire project mapping.
97 """
98 to_write: list[dict[str, Any]] = []
99 written = 0
100 project = ctx.context.project or {}
101 if paths is None:
102 iterator = ((p, c) for p, c in project.items())
103 else:
104 norm = {str(p).lstrip("./") for p in paths}
105 iterator = ((p, project[p]) for p in norm if p in project)
106 for path, content in iterator:
107 p = str(path).lstrip("./")
108 if not p:
109 continue
110 try:
111 b = content.encode("utf-8")
112 except Exception:
113 b = bytes(str(content), "utf-8")
114 to_write.append({"path": p, "content": b})
115 written += 1
116 for i in range(0, len(to_write), 64):
117 chunk = to_write[i : i + 64]
118 await sandbox.write_files(chunk)
119 return written
120
121
122def parse_env_list(env_list: list[str] | None) -> dict[str, str]:

Callers 4

sandbox_createFunction · 0.90
sandbox_runFunction · 0.90
get_sandbox_by_nameFunction · 0.85
autosync_after_fs_changeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected