fix: avoid opencode structured output session breakage

Replace server-enforced structured output with local JSON parsing for Git generation
Render generated commit and PR JSON responses as compact chat cards
Tighten generation prompts while preserving active session context
This commit is contained in:
Bohdan Triapitsyn
2026-05-14 02:16:52 +03:00
parent bac655ddb4
commit 92f1fa7dfe
17 changed files with 282 additions and 47 deletions
+11 -2
View File
@@ -60,7 +60,9 @@ export const MAGIC_PROMPT_DEFINITIONS: readonly MagicPromptDefinition[] = [
placeholders: [
{ key: 'selected_files', description: 'Bullet list of currently selected file paths.' },
],
template: `Return JSON with exactly this shape:
template: `Return exactly one JSON object and nothing else. Do not include prose, markdown, explanations, or code fences.
The JSON object must have exactly this shape:
{"subject": string, "highlights": string[]}
Rules:
@@ -69,6 +71,8 @@ Rules:
- no scope in subject
- keep subject concise and user-facing
- highlights: 0-3 concise user-facing points
- use double quotes for all JSON strings
- do not include trailing commas or comments
Selected files:
{{selected_files}}`,
@@ -92,13 +96,18 @@ Selected files:
{ key: 'changed_files', description: 'Bullet list of changed files in base...head.' },
{ key: 'additional_context_block', description: 'Optional Additional context block (already formatted).' },
],
template: `Return JSON with exactly this shape:
template: `Return exactly one JSON object and nothing else. Do not include prose, markdown outside JSON, explanations, or code fences.
The JSON object must have exactly this shape:
{"title": string, "body": string}
Rules:
- title: concise, outcome-first, conventional style
- body: markdown with sections: ## Summary, ## Why, ## Testing
- keep output concrete and user-facing
- put all markdown inside the body string
- use double quotes for all JSON strings and escape newlines as \\n
- do not include trailing commas or comments
Base branch: {{base_branch}}
Head branch: {{head_branch}}