@@ -45,7 +45,7 @@ const MAX_FILES = 5;
4545const MAX_AI_TOKENS = 8192 ;
4646const OWNER = "ArcadeAI" ;
4747const REPO = "docs" ;
48- const EDITORIAL_COMMENT_REGEX = / < ! - - E d i t o r i a l : ( . + ? ) - - > / ;
48+ const SUMMARY_DELIMITER = "---SUMMARY---" ;
4949const CODE_FENCE_OPEN_REGEX = / ^ ` ` ` (?: m d x ? | m a r k d o w n ) ? \n / ;
5050const CODE_FENCE_CLOSE_REGEX = / \n ` ` ` $ / ;
5151const HTTP_UNPROCESSABLE_ENTITY = 422 ;
@@ -254,11 +254,35 @@ ${content}
254254If the doc already conforms to the style guide, return exactly: NO_CHANGES_NEEDED
255255
256256If changes are needed to conform to the style guide:
257- 1. Return ONLY the revised markdown content, no explanations
257+ 1. Return ONLY the revised markdown content, no explanations or comments
2582582. Preserve all code blocks exactly as they are
2592593. Preserve frontmatter exactly as it is
260- 4. Add a brief HTML comment at the top (after frontmatter) citing which style guide sections required changes:
261- <!-- Editorial: [Style guide section] - [what was changed] -->` ;
260+ 4. After the content, add a delimiter line "---SUMMARY---" followed by a brief summary of which style guide sections required changes
261+
262+ Example format:
263+ [revised markdown content here]
264+ ---SUMMARY---
265+ Voice and tone - Changed "we" references; Structure - Added intro line` ;
266+ }
267+
268+ // Extract content and summary from AI response
269+ function extractContentAndSummary ( rawResponse : string ) : {
270+ content : string ;
271+ summary : string ;
272+ } {
273+ const stripped = stripCodeFences ( rawResponse ) ;
274+ const delimiterIndex = stripped . lastIndexOf ( SUMMARY_DELIMITER ) ;
275+
276+ if ( delimiterIndex === - 1 ) {
277+ return { content : stripped , summary : "Structural improvements" } ;
278+ }
279+
280+ const content = stripped . slice ( 0 , delimiterIndex ) . trim ( ) ;
281+ const summary =
282+ stripped . slice ( delimiterIndex + SUMMARY_DELIMITER . length ) . trim ( ) ||
283+ "Structural improvements" ;
284+
285+ return { content, summary } ;
262286}
263287
264288// Get editorial suggestions from Anthropic
@@ -280,15 +304,14 @@ async function getEditorialFromAnthropic(
280304 return null ;
281305 }
282306
283- const revisedContent = stripCodeFences ( textBlock . text ) ;
307+ const rawResponse = textBlock . text ;
284308
285- if ( revisedContent === "NO_CHANGES_NEEDED" ) {
309+ if ( stripCodeFences ( rawResponse ) === "NO_CHANGES_NEEDED" ) {
286310 return null ;
287311 }
288312
289- // Extract summary from the HTML comment if present
290- const commentMatch = revisedContent . match ( EDITORIAL_COMMENT_REGEX ) ;
291- const summary = commentMatch ? commentMatch [ 1 ] : "Structural improvements" ;
313+ const { content : revisedContent , summary } =
314+ extractContentAndSummary ( rawResponse ) ;
292315
293316 return {
294317 filename,
@@ -312,17 +335,17 @@ async function getEditorialFromOpenAI(
312335 messages : [ { role : "user" , content : prompt } ] ,
313336 } ) ;
314337
315- const rawContent = response . choices [ 0 ] ?. message ?. content ;
316- if ( ! rawContent ) {
338+ const rawResponse = response . choices [ 0 ] ?. message ?. content ;
339+ if ( ! rawResponse ) {
317340 return null ;
318341 }
319- const revisedContent = stripCodeFences ( rawContent ) ;
320- if ( revisedContent === "NO_CHANGES_NEEDED" ) {
342+
343+ if ( stripCodeFences ( rawResponse ) === "NO_CHANGES_NEEDED" ) {
321344 return null ;
322345 }
323346
324- const commentMatch = revisedContent . match ( EDITORIAL_COMMENT_REGEX ) ;
325- const summary = commentMatch ? commentMatch [ 1 ] : "Structural improvements" ;
347+ const { content : revisedContent , summary } =
348+ extractContentAndSummary ( rawResponse ) ;
326349
327350 return {
328351 filename,
0 commit comments