- Rewrite system prompt: structured sections, explicit tool descriptions with full SKILL.md descriptions, multi-agent awareness - Add write_file skill for creating/modifying workspace files - Per-template config passthrough: temperature, num_predict, context_size, compress settings, max_tool_rounds, max_response_lines - Bump defaults: 1024 output tokens (was 512), 500-char deque (was 200), 250-token summaries (was 150), compress threshold 16 (was 12), keep 8 (was 4) - Cache compression by content hash — no redundant summarization - Update all 5 templates with tuned settings per role
33 lines
902 B
Python
33 lines
902 B
Python
#!/usr/bin/env python3
|
|
"""Write content to a file under /workspace."""
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
args = json.loads(sys.stdin.read())
|
|
path = args.get("path", "")
|
|
content = args.get("content", "")
|
|
append = args.get("append", False)
|
|
|
|
WORKSPACE = os.environ.get("WORKSPACE", "/workspace")
|
|
|
|
resolved = os.path.realpath(path)
|
|
if not resolved.startswith(WORKSPACE + "/") and resolved != WORKSPACE:
|
|
print(f"[error: path must be under {WORKSPACE}]")
|
|
sys.exit(0)
|
|
|
|
if os.path.isdir(resolved):
|
|
print(f"[error: {path} is a directory]")
|
|
sys.exit(0)
|
|
|
|
try:
|
|
os.makedirs(os.path.dirname(resolved), exist_ok=True)
|
|
mode = "a" if append else "w"
|
|
with open(resolved, mode) as f:
|
|
f.write(content)
|
|
size = os.path.getsize(resolved)
|
|
action = "appended to" if append else "wrote"
|
|
print(f"[{action} {path} ({size} bytes)]")
|
|
except Exception as e:
|
|
print(f"[error: {e}]")
|