4141
4242 # Build full prompt YAML: splice user message into the messages array
4343 # (avoids yaml round-trip which reorders keys and changes scalar styles)
44- python3 -c "
45- with open('.github/prompts/classify-pr.prompt.yml') as f :
46- lines = f.readlines()
47- with open('/tmp/user-message.txt') as f :
48- user_msg = f.read()
49-
50- # Find where messages array ends: first non-blank top-level key after 'messages:'
51- insert_at = len(lines)
52- for i, line in enumerate(lines) :
53- if i == 0 :
54- continue
55- if line.strip() and not line[0].isspace() :
56- insert_at = i
57- break
58-
59- entry = [' - role : user\n', ' content: |\n']
60- for ln in user_msg.splitlines() :
61- entry.append(' ' + ln + '\n')
62-
63- lines[insert_at:insert_at] = entry
64- with open('/tmp/prompt.yml', 'w') as f :
65- f.writelines(lines)
66-
67- # Validate: last message must be the user message we just added
68- import yaml
69- doc = yaml.safe_load(open('/tmp/prompt.yml'))
70- assert doc['messages'][-1]['role'] == 'user', 'prompt splice failed : last message is not user'
71- "
44+ python3 .github/scripts/splice-prompt.py .github/prompts/classify-pr.prompt.yml /tmp/prompt.yml
7245
7346 - name : Classify
7447 id : classify
@@ -151,34 +124,7 @@ assert doc['messages'][-1]['role'] == 'user', 'prompt splice failed: last messag
151124
152125 # Build full prompt YAML: splice user message into the messages array
153126 # (avoids yaml round-trip which reorders keys and changes scalar styles)
154- python3 -c "
155- with open('.github/prompts/detect-breaking.prompt.yml') as f :
156- lines = f.readlines()
157- with open('/tmp/user-message.txt') as f :
158- user_msg = f.read()
159-
160- # Find where messages array ends: first non-blank top-level key after 'messages:'
161- insert_at = len(lines)
162- for i, line in enumerate(lines) :
163- if i == 0 :
164- continue
165- if line.strip() and not line[0].isspace() :
166- insert_at = i
167- break
168-
169- entry = [' - role : user\n', ' content: |\n']
170- for ln in user_msg.splitlines() :
171- entry.append(' ' + ln + '\n')
172-
173- lines[insert_at:insert_at] = entry
174- with open('/tmp/prompt.yml', 'w') as f :
175- f.writelines(lines)
176-
177- # Validate: last message must be the user message we just added
178- import yaml
179- doc = yaml.safe_load(open('/tmp/prompt.yml'))
180- assert doc['messages'][-1]['role'] == 'user', 'prompt splice failed : last message is not user'
181- "
127+ python3 .github/scripts/splice-prompt.py .github/prompts/detect-breaking.prompt.yml /tmp/prompt.yml
182128 echo "skip=false" >> $GITHUB_OUTPUT
183129 fi
184130
@@ -198,11 +144,13 @@ assert doc['messages'][-1]['role'] == 'user', 'prompt splice failed: last messag
198144 RESPONSE_FILE="${{ steps.detect.outputs.response-file }}"
199145 if ! jq empty "$RESPONSE_FILE" 2>/dev/null; then
200146 echo "::warning::Model response is not valid JSON; skipping breaking label. See step summary for details."
201- echo "## Breaking change detection failed" >> "$GITHUB_STEP_SUMMARY"
202- echo "Model returned invalid JSON. Breaking label was **not** applied." >> "$GITHUB_STEP_SUMMARY"
203- echo '```' >> "$GITHUB_STEP_SUMMARY"
204- cat "$RESPONSE_FILE" >> "$GITHUB_STEP_SUMMARY"
205- echo '```' >> "$GITHUB_STEP_SUMMARY"
147+ {
148+ echo "## Breaking change detection failed"
149+ echo "Model returned invalid JSON. Breaking label was **not** applied."
150+ echo '```'
151+ cat "$RESPONSE_FILE"
152+ echo '```'
153+ } >> "$GITHUB_STEP_SUMMARY"
206154 exit 0
207155 fi
208156 BREAKING=$(jq -r '.breaking' "$RESPONSE_FILE")
@@ -261,34 +209,7 @@ assert doc['messages'][-1]['role'] == 'user', 'prompt splice failed: last messag
261209
262210 # Build full prompt YAML: splice user message into the messages array
263211 # (avoids yaml round-trip which reorders keys and changes scalar styles)
264- python3 -c "
265- with open('.github/prompts/spec-impact.prompt.yml') as f :
266- lines = f.readlines()
267- with open('/tmp/user-message.txt') as f :
268- user_msg = f.read()
269-
270- # Find where messages array ends: first non-blank top-level key after 'messages:'
271- insert_at = len(lines)
272- for i, line in enumerate(lines) :
273- if i == 0 :
274- continue
275- if line.strip() and not line[0].isspace() :
276- insert_at = i
277- break
278-
279- entry = [' - role : user\n', ' content: |\n']
280- for ln in user_msg.splitlines() :
281- entry.append(' ' + ln + '\n')
282-
283- lines[insert_at:insert_at] = entry
284- with open('/tmp/prompt.yml', 'w') as f :
285- f.writelines(lines)
286-
287- # Validate: last message must be the user message we just added
288- import yaml
289- doc = yaml.safe_load(open('/tmp/prompt.yml'))
290- assert doc['messages'][-1]['role'] == 'user', 'prompt splice failed : last message is not user'
291- "
212+ python3 .github/scripts/splice-prompt.py .github/prompts/spec-impact.prompt.yml /tmp/prompt.yml
292213 echo "skip=false" >> $GITHUB_OUTPUT
293214 fi
294215
0 commit comments