2026-05-23 23:24:56 +03:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
DNC_MD_CONTENT = """# dnc
|
|
|
|
|
|
|
|
|
|
This project uses dnc (dockernecontainer). When `.dnc` is present,
|
|
|
|
|
run ALL commands inside the container by prefixing them with `dnc -`:
|
|
|
|
|
|
|
|
|
|
dnc - nvim
|
|
|
|
|
dnc - npm install
|
|
|
|
|
dnc - python manage.py migrate
|
2026-05-25 03:01:46 +03:00
|
|
|
|
|
|
|
|
## Config
|
|
|
|
|
|
|
|
|
|
User config lives in `~/.config/dnc/` (mounted at `/run/host/config/`).
|
|
|
|
|
Images can read `/run/host/config/dnc.toml` for colors, keybinds, etc.
|
|
|
|
|
|
|
|
|
|
## Git / SSH
|
|
|
|
|
|
|
|
|
|
SSH agent socket is forwarded automatically. SSH keys from `~/.ssh/`
|
|
|
|
|
and gitconfig from `~/.gitconfig` are available inside the container.
|
|
|
|
|
git push/pull works without additional setup.
|
2026-05-23 23:24:56 +03:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
OPENCODE_INSTRUCTIONS = """## dnc
|
|
|
|
|
|
|
|
|
|
Refer to DNC.md for container usage instructions.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
CURSOR_RULES = """description: dnc container
|
|
|
|
|
globs: *
|
|
|
|
|
---
|
|
|
|
|
Refer to DNC.md for container usage instructions.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_dnc_md(project_dir: str):
|
|
|
|
|
path = os.path.join(project_dir, "DNC.md")
|
|
|
|
|
if os.path.exists(path):
|
|
|
|
|
print("DNC.md already exists (use --force to overwrite)")
|
|
|
|
|
return
|
|
|
|
|
with open(path, "w") as f:
|
|
|
|
|
f.write(DNC_MD_CONTENT)
|
|
|
|
|
print("Created DNC.md")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_opencode(project_dir: str):
|
|
|
|
|
opencode_dir = os.path.join(project_dir, ".opencode")
|
|
|
|
|
os.makedirs(opencode_dir, exist_ok=True)
|
|
|
|
|
path = os.path.join(opencode_dir, "instructions.md")
|
|
|
|
|
if os.path.exists(path):
|
|
|
|
|
print(".opencode/instructions.md already exists (use --force to overwrite)")
|
|
|
|
|
return
|
|
|
|
|
with open(path, "w") as f:
|
|
|
|
|
f.write(OPENCODE_INSTRUCTIONS)
|
|
|
|
|
print("Created .opencode/instructions.md")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_cursor(project_dir: str):
|
|
|
|
|
cursor_dir = os.path.join(project_dir, ".cursor", "rules")
|
|
|
|
|
os.makedirs(cursor_dir, exist_ok=True)
|
|
|
|
|
path = os.path.join(cursor_dir, "dnc.mdc")
|
|
|
|
|
if os.path.exists(path):
|
|
|
|
|
print(".cursor/rules/dnc.mdc already exists (use --force to overwrite)")
|
|
|
|
|
return
|
|
|
|
|
with open(path, "w") as f:
|
|
|
|
|
f.write(CURSOR_RULES)
|
|
|
|
|
print("Created .cursor/rules/dnc.mdc")
|