automaker / patch_api_docs.py
Leon4gr45's picture
Upload folder using huggingface_hub (part 2)
dbdcaee verified
Raw History Blame Contribute Delete
614 Bytes
import re
with open('apps/server/src/api-docs.ts', 'r') as f:
content = f.read()
new_endpoint = """
{
method: 'POST',
path: '/api/agent/chat',
purpose: 'Send a message to the AI agent',
request: { message: 'Hello agent', projectPath: '/app/data/projects/my-project' },
response: { sessionId: 'session-123', status: 'started' },
},"""
# Insert before /api/projects
content = re.sub(
r"(\s*\{\s*method: 'GET',\s*path: '/api/projects',)",
new_endpoint + r"\1",
content
)
with open('apps/server/src/api-docs.ts', 'w') as f:
f.write(content)