1111
1212import os
1313import re
14+ import json
1415from pathlib import Path
1516
1617import anyio
2324 TextBlock ,
2425)
2526
27+
28+ with open ("config.json" ) as cf :
29+ config_json_str = cf .read ()
30+ CONFIGS = json .loads (config_json_str )
31+
32+
2633app = FastAPI (
27- title = "OAPE API Implement " ,
28- description = "Invokes the /oape:api-implement Claude Code skill to generate "
34+ title = "OAPE Operator Feature Developer " ,
35+ description = "Invokes the /oape:api-implement Claude Code command to generate "
2936 "controller/reconciler code from an OpenShift enhancement proposal." ,
3037 version = "0.1.0" ,
3138)
3542)
3643
3744# Resolve the plugin directory (repo root) relative to this file.
38- PLUGIN_DIR = str (Path (__file__ ).resolve ().parent .parent )
45+ # The SDK expects the path to the plugin root (containing .claude-plugin/).
46+ PLUGIN_DIR = str (Path (__file__ ).resolve ().parent .parent / "plugins" / "oape" )
47+ print (PLUGIN_DIR )
3948
4049
4150@app .get ("/api-implement" )
@@ -75,22 +84,12 @@ async def api_implement(
7584 options = ClaudeAgentOptions (
7685 system_prompt = (
7786 "You are an OpenShift operator code generation assistant. "
78- "Execute the /oape:api-implement skill with the provided EP URL. "
79- "Generate production-ready controller code with zero TODOs."
87+ "Execute the oape:api-implement plugin with the provided EP URL. "
8088 ),
8189 cwd = working_dir ,
8290 permission_mode = "bypassPermissions" ,
83- allowed_tools = [
84- "Bash" ,
85- "Read" ,
86- "Write" ,
87- "Edit" ,
88- "Glob" ,
89- "Grep" ,
90- "WebFetch" ,
91- "Task" ,
92- ],
93- plugins = [PLUGIN_DIR ],
91+ allowed_tools = CONFIGS ['claude_allowed_tools' ],
92+ plugins = [{"type" : "local" , "path" : PLUGIN_DIR }],
9493 )
9594
9695 # --- Run the agent ---
@@ -100,6 +99,7 @@ async def api_implement(
10099 try :
101100 async for message in query (
102101 prompt = f"/oape:api-implement { ep_url } " ,
102+ # prompt="explain the enhancement proposal to me like I'm 5 in 10 sentences, {ep_url}",
103103 options = options ,
104104 ):
105105 if isinstance (message , AssistantMessage ):
@@ -108,6 +108,8 @@ async def api_implement(
108108 output_parts .append (block .text )
109109 elif isinstance (message , ResultMessage ):
110110 cost_usd = message .total_cost_usd
111+ if message .result :
112+ output_parts .append (message .result )
111113 except Exception as exc :
112114 raise HTTPException (
113115 status_code = 500 ,
0 commit comments