File size: 614 Bytes
dbdcaee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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)