MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / setup_ai_tools

Function setup_ai_tools

misc/python/materialize/scratch.py:275–336  ·  view source on GitHub ↗

Transfer local Claude Code and Codex configs to a scratch instance and install the materialize-docs skill.

(instance: Instance)

Source from the content-addressed store, hash-verified

273
274
275def setup_ai_tools(instance: Instance) -> None:
276 """Transfer local Claude Code and Codex configs to a scratch instance
277 and install the materialize-docs skill."""
278 import io
279 import pathlib
280 import tarfile
281
282 home = pathlib.Path.home()
283
284 # Collect only essential config files — skip session logs, caches, etc.
285 items: list[tuple[str, pathlib.Path]] = []
286
287 # Claude Code: settings, credentials, and project memory files
288 claude_dir = home / ".claude"
289 if claude_dir.is_dir():
290 for cfg_name in ("settings.json", ".credentials.json"):
291 p = claude_dir / cfg_name
292 if p.is_file():
293 items.append((f".claude/{cfg_name}", p))
294 # Transfer memory directories from all projects
295 projects_dir = claude_dir / "projects"
296 if projects_dir.is_dir():
297 for proj in projects_dir.iterdir():
298 if not proj.is_dir():
299 continue
300 memory_dir = proj / "memory"
301 if memory_dir.is_dir():
302 items.append((f".claude/projects/{proj.name}/memory", memory_dir))
303
304 if (home / ".claude.json").is_file():
305 items.append((".claude.json", home / ".claude.json"))
306
307 # Codex: only config, not session logs
308 codex_dir = home / ".codex"
309 if codex_dir.is_dir():
310 for cfg_name in ("config.json", "instructions.md"):
311 p = codex_dir / cfg_name
312 if p.is_file():
313 items.append((f".codex/{cfg_name}", p))
314
315 if items:
316 buf = io.BytesIO()
317 with tarfile.open(fileobj=buf, mode="w:gz") as tar:
318 for arcname, path in items:
319 tar.add(str(path), arcname=arcname)
320 mssh(instance, "tar xzf - -C ~", input=buf.getvalue(), quiet=True)
321
322 mssh(
323 instance,
324 "cd materialize && "
325 "NPM_CONFIG_UPDATE_NOTIFIER=false "
326 "npx -q -y skills add MaterializeInc/agent-skills -g -a claude-code --copy -y --skill materialize-docs 2>/dev/null || true",
327 quiet=True,
328 )
329
330 mssh(
331 instance,
332 "cd materialize && "

Callers 1

launch_clusterFunction · 0.85

Calls 4

msshFunction · 0.85
appendMethod · 0.45
openMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected