repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

extensions/ultra/workflows/research.json

Raw
{
	"name": "research",
	"description": "Research a generic question through parallel evidence gathering, gap analysis, adversarial verification, and cited synthesis.",
	"args": { "hint": "<question>", "params": ["question"] },
	"schemas": {
		"ResearchPlan": {
			"type": "object",
			"properties": {
				"question": { "type": "string" },
				"answer_shape": { "type": "string" },
				"angles": {
					"type": "array",
					"minItems": 3,
					"maxItems": 4,
					"items": {
						"type": "object",
						"properties": {
							"id": { "type": "string" },
							"question": { "type": "string" },
							"source_strategy": { "type": "string" },
							"opposition_strategy": { "type": "string" }
						},
						"required": [
							"id",
							"question",
							"source_strategy",
							"opposition_strategy"
						]
					}
				}
			},
			"required": ["question", "answer_shape", "angles"]
		},
		"Evidence": {
			"type": "object",
			"properties": {
				"angle_id": { "type": "string" },
				"angle": { "type": "string" },
				"findings": {
					"type": "array",
					"items": {
						"type": "object",
						"properties": {
							"claim": { "type": "string" },
							"evidence": { "type": "string" },
							"source_url": { "type": "string" },
							"source_title": { "type": "string" },
							"source_type": { "type": "string" },
							"published_at": { "type": "string" },
							"confidence": { "type": "string" }
						},
						"required": [
							"claim",
							"evidence",
							"source_url",
							"source_title",
							"source_type",
							"confidence"
						]
					}
				},
				"contradictions": { "type": "array", "items": { "type": "string" } },
				"gaps": { "type": "array", "items": { "type": "string" } },
				"leads": { "type": "array", "items": { "type": "string" } }
			},
			"required": [
				"angle_id",
				"angle",
				"findings",
				"contradictions",
				"gaps",
				"leads"
			]
		},
		"Audit": {
			"type": "object",
			"properties": {
				"assessment": { "type": "string" },
				"verification_tasks": {
					"type": "array",
					"maxItems": 3,
					"items": {
						"type": "object",
						"properties": {
							"id": { "type": "string" },
							"claim": { "type": "string" },
							"why": { "type": "string" },
							"preferred_sources": { "type": "string" },
							"opposition_query": { "type": "string" }
						},
						"required": [
							"id",
							"claim",
							"why",
							"preferred_sources",
							"opposition_query"
						]
					}
				},
				"unresolved_gaps": { "type": "array", "items": { "type": "string" } }
			},
			"required": ["assessment", "verification_tasks", "unresolved_gaps"]
		},
		"Verification": {
			"type": "object",
			"properties": {
				"id": { "type": "string" },
				"claim": { "type": "string" },
				"verdict": { "type": "string" },
				"explanation": { "type": "string" },
				"sources": {
					"type": "array",
					"items": {
						"type": "object",
						"properties": {
							"title": { "type": "string" },
							"url": { "type": "string" },
							"source_type": { "type": "string" }
						},
						"required": ["title", "url", "source_type"]
					}
				}
			},
			"required": ["id", "claim", "verdict", "explanation", "sources"]
		},
		"ResearchReport": {
			"type": "object",
			"properties": {
				"answer_status": { "type": "string" },
				"executive_summary": { "type": "string" },
				"analysis": { "type": "string" },
				"findings": {
					"type": "array",
					"items": {
						"type": "object",
						"properties": {
							"claim": { "type": "string" },
							"evidence": { "type": "string" },
							"confidence": { "type": "string" },
							"citations": { "type": "array", "items": { "type": "string" } }
						},
						"required": ["claim", "evidence", "confidence", "citations"]
					}
				},
				"contradictions": { "type": "array", "items": { "type": "string" } },
				"gaps": { "type": "array", "items": { "type": "string" } },
				"recommendations": { "type": "array", "items": { "type": "string" } },
				"sources": {
					"type": "array",
					"items": {
						"type": "object",
						"properties": {
							"title": { "type": "string" },
							"url": { "type": "string" },
							"source_type": { "type": "string" },
							"published_at": { "type": "string" }
						},
						"required": ["title", "url", "source_type"]
					}
				}
			},
			"required": [
				"answer_status",
				"executive_summary",
				"analysis",
				"findings",
				"contradictions",
				"gaps",
				"recommendations",
				"sources"
			]
		}
	},
	"phases": [
		{
			"id": "plan",
			"kind": "single",
			"step": {
				"summary": "Plan research for: {args.question}",
				"prompt": "Reframe this research request into the actual question or decision it must answer: {args.question}. Define the most useful answer shape, then produce 3 to 4 orthogonal research angles. Each angle must have a stable short id, a focused question, a source strategy favoring primary and authoritative evidence, and an opposition strategy for finding disconfirming evidence. Avoid overlapping angles. Return JSON matching ResearchPlan.",
				"model": "big",
				"thinkingLevel": "high",
				"schema": "ResearchPlan"
			}
		},
		{
			"id": "gather",
			"kind": "fanout",
			"over": "{plan.results[].angles[]}",
			"step": {
				"summary": "Gather evidence for research angle {item}",
				"prompt": "Research this angle for the broader question: {args.question}. Angle: {item}. Do not modify local files or remote systems. Use at least two meaningfully different searches. Prefer primary sources, official documentation, papers, direct data, and reputable independent analysis. Read the two strongest sources rather than relying on summaries. Keep each source retrieval targeted; do not dump whole large pages into context. Seek contrary evidence using the angle's opposition strategy. Record one atomic finding per source-backed claim with exact URL, title, source type, publication date when available, and confidence based on source quality and corroboration. Explicitly return contradictions, gaps, and promising leads. Never fabricate a URL or claim. Echo the angle id and question. Return JSON matching Evidence.",
				"model": "small",
				"thinkingLevel": "medium",
				"schema": "Evidence"
			}
		},
		{
			"id": "audit",
			"kind": "single",
			"step": {
				"summary": "Audit evidence and identify verification targets",
				"prompt": "Audit the gathered evidence for this question: {args.question}. Research plan: {plan.results}. Evidence by angle: {gather.results}. Compare claims across angles and sources. Identify material contradictions, important single-source claims, source monocultures, stale evidence, circular citations, and decision-relevant gaps. Create at most 3 concrete verification tasks whose resolution could materially change the answer; prioritize contradictions and high-impact weak claims. Each task needs a stable id, exact claim, why it matters, preferred source types, and an opposition query. Put gaps that cannot be verified into unresolved_gaps. Return JSON matching Audit.",
				"model": "big",
				"thinkingLevel": "high",
				"schema": "Audit"
			}
		},
		{
			"id": "verify",
			"kind": "fanout",
			"when": "{audit.results[].verification_tasks[]}",
			"over": "{audit.results[].verification_tasks[]}",
			"step": {
				"summary": "Verify research claim {item}",
				"prompt": "Adversarially verify this research task for the broader question: {args.question}. Task: {item}. Do not modify local files or remote systems. Search for primary, authoritative, independent, and disconfirming evidence. Read at most 3 substantive sources and inspect what they actually support. Keep each source retrieval targeted; do not dump whole large pages into context. Use one verdict string: supported, refuted, qualified, or unresolved. Echo the task id and claim exactly. Explain the verdict and return every source used with title, URL, and source type. Never fabricate a URL. Return JSON matching Verification.",
				"model": "big",
				"thinkingLevel": "high",
				"schema": "Verification"
			}
		},
		{
			"id": "report",
			"kind": "single",
			"step": {
				"summary": "Synthesize cited research answer",
				"prompt": "Write the final research answer for: {args.question}. Plan: {plan.results}. Gathered evidence: {gather.results}. Evidence audit: {audit.results}. Verification verdicts: {verify.results}. Lead with a direct executive answer and state answer_status as fully answered, partially answered, or unresolved. Synthesize by theme and question rather than source order. Include only claims traceable to supplied URLs, calibrate confidence from source quality, independence, agreement, and verification, and preserve material qualifications. Explain contradictions and whether they were resolved. List remaining gaps and concrete next research or decision steps. Deduplicate the source registry. Never invent or alter URLs and never dump source JSON into prose. Return JSON matching ResearchReport.",
				"model": "big",
				"thinkingLevel": "high",
				"schema": "ResearchReport"
			}
		}
	],
	"return": "{report.results}"
}