Luigit
repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

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", "maxLength": 2400 },
				"answer_shape": { "type": "string", "maxLength": 1600 },
				"blockers": {
					"type": "array",
					"maxItems": 12,
					"items": { "type": "string", "maxLength": 1600 }
				},
				"gaps": {
					"type": "array",
					"maxItems": 12,
					"items": { "type": "string", "maxLength": 1600 }
				},
				"angles": {
					"type": "array",
					"minItems": 3,
					"maxItems": 4,
					"items": {
						"type": "object",
						"properties": {
							"id": { "type": "string", "maxLength": 96 },
							"question": { "type": "string", "maxLength": 2400 },
							"source_strategy": { "type": "string", "maxLength": 1600 },
							"opposition_strategy": { "type": "string", "maxLength": 1600 },
							"instructions": {
								"type": "array",
								"maxItems": 12,
								"items": { "type": "string", "maxLength": 1600 }
							}
						},
						"required": [
							"id",
							"question",
							"source_strategy",
							"opposition_strategy",
							"instructions"
						]
					}
				}
			},
			"required": ["question", "answer_shape", "angles", "blockers", "gaps"]
		},
		"Evidence": {
			"type": "object",
			"properties": {
				"angle_id": { "type": "string", "maxLength": 96 },
				"angle": { "type": "string", "maxLength": 2400 },
				"findings": {
					"type": "array",
					"maxItems": 8,
					"items": {
						"type": "object",
						"properties": {
							"claim": { "type": "string", "maxLength": 2000 },
							"evidence": { "type": "string", "maxLength": 3200 },
							"source_url": { "type": "string", "maxLength": 2048 },
							"source_title": { "type": "string", "maxLength": 400 },
							"source_type": { "type": "string", "maxLength": 120 },
							"published_at": { "type": "string", "maxLength": 120 },
							"confidence": { "type": "string", "maxLength": 800 }
						},
						"required": [
							"claim",
							"evidence",
							"source_url",
							"source_title",
							"source_type",
							"confidence"
						]
					}
				},
				"contradictions": {
					"type": "array",
					"maxItems": 12,
					"items": { "type": "string", "maxLength": 1600 }
				},
				"gaps": {
					"type": "array",
					"maxItems": 12,
					"items": { "type": "string", "maxLength": 1600 }
				},
				"leads": {
					"type": "array",
					"maxItems": 12,
					"items": { "type": "string", "maxLength": 1600 }
				}
			},
			"required": [
				"angle_id",
				"angle",
				"findings",
				"contradictions",
				"gaps",
				"leads"
			]
		},
		"Audit": {
			"type": "object",
			"properties": {
				"assessment": { "type": "string", "maxLength": 3200 },
				"verification_tasks": {
					"type": "array",
					"maxItems": 3,
					"items": {
						"type": "object",
						"properties": {
							"id": { "type": "string", "maxLength": 96 },
							"claim": { "type": "string", "maxLength": 2000 },
							"why": { "type": "string", "maxLength": 2400 },
							"preferred_sources": { "type": "string", "maxLength": 1600 },
							"opposition_query": { "type": "string", "maxLength": 1600 },
							"instructions": {
								"type": "array",
								"maxItems": 12,
								"items": { "type": "string", "maxLength": 1600 }
							}
						},
						"required": [
							"id",
							"claim",
							"why",
							"preferred_sources",
							"opposition_query",
							"instructions"
						]
					}
				},
				"unresolved_gaps": {
					"type": "array",
					"maxItems": 24,
					"items": { "type": "string", "maxLength": 1600 }
				}
			},
			"required": ["assessment", "verification_tasks", "unresolved_gaps"]
		},
		"Verification": {
			"type": "object",
			"properties": {
				"id": { "type": "string", "maxLength": 96 },
				"claim": { "type": "string", "maxLength": 2000 },
				"verdict": {
					"type": "string",
					"enum": ["supported", "refuted", "qualified", "unresolved"]
				},
				"explanation": { "type": "string", "maxLength": 4000 },
				"sources": {
					"type": "array",
					"maxItems": 3,
					"items": {
						"type": "object",
						"properties": {
							"title": { "type": "string", "maxLength": 400 },
							"url": { "type": "string", "maxLength": 2048 },
							"source_type": { "type": "string", "maxLength": 120 }
						},
						"required": ["title", "url", "source_type"]
					}
				}
			},
			"required": ["id", "claim", "verdict", "explanation", "sources"]
		},
		"ResearchReport": {
			"type": "object",
			"properties": {
				"answer_status": {
					"type": "string",
					"enum": ["fully answered", "partially answered", "unresolved"]
				},
				"executive_summary": { "type": "string", "maxLength": 2400 },
				"analysis": { "type": "string", "maxLength": 6000 },
				"blockers": {
					"type": "array",
					"maxItems": 24,
					"items": { "type": "string", "maxLength": 1600 }
				},
				"findings": {
					"type": "array",
					"maxItems": 41,
					"items": {
						"type": "object",
						"properties": {
							"claim": { "type": "string", "maxLength": 2000 },
							"evidence": { "type": "string", "maxLength": 3200 },
							"confidence": { "type": "string", "maxLength": 800 },
							"citations": {
								"type": "array",
								"maxItems": 8,
								"items": { "type": "string", "maxLength": 2048 }
							}
						},
						"required": ["claim", "evidence", "confidence", "citations"]
					}
				},
				"contradictions": {
					"type": "array",
					"maxItems": 24,
					"items": { "type": "string", "maxLength": 1600 }
				},
				"gaps": {
					"type": "array",
					"maxItems": 32,
					"items": { "type": "string", "maxLength": 1600 }
				},
				"recommendations": {
					"type": "array",
					"maxItems": 16,
					"items": { "type": "string", "maxLength": 1600 }
				},
				"sources": {
					"type": "array",
					"maxItems": 41,
					"items": {
						"type": "object",
						"properties": {
							"title": { "type": "string", "maxLength": 400 },
							"url": { "type": "string", "maxLength": 2048 },
							"source_type": { "type": "string", "maxLength": 120 },
							"published_at": { "type": "string", "maxLength": 120 }
						},
						"required": ["title", "url", "source_type"]
					}
				}
			},
			"required": [
				"answer_status",
				"executive_summary",
				"analysis",
				"blockers",
				"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. Preserve applicable user instructions and constraints in each angle's instructions; do not rely on child history. For repository research, first read applicable AGENTS.md files in ancestors and relevant subdirectories and include source paths. Do not make unsupported assumptions; report missing decisions or access in blockers and gaps. Within schema bounds report overflow and unaddressed scope in gaps, never silently discard it. Return JSON matching ResearchPlan.",
				"tools": ["read", "grep", "find", "ls"],
				"model": "large",
				"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. Follow the packet's applicable instructions and constraints; for repository work first read applicable AGENTS.md files in ancestors and relevant subdirectories. Do not infer missing intent or make unsupported assumptions. Stay within 8 atomic findings; report blockers, inaccessible evidence, overflow and uninspected scope in gaps with exact source locators, never silently lose findings. Return JSON matching Evidence.",
				"tools": ["read", "grep", "find", "ls"],
				"model": "small",
				"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}. Plan failures: {plan.failures}. Gathering failures: {gather.failures}. 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. Preserve applicable instructions and constraints in each verification task's instructions, with relevant evidence URLs/paths in why or preferred_sources so the question plus item packet remains self-contained. For repository work first read applicable AGENTS.md files in ancestors and relevant subdirectories. Do not make unsupported assumptions: missing angles, failed workers, blockers and overflow are unresolved_gaps, not absence of counterevidence. Report exact uncovered scope and retrieval locators rather than silently omitting evidence to fit bounds. Return JSON matching Audit.",
				"tools": ["read", "grep", "find", "ls"],
				"model": "large",
				"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. Follow the packet's applicable instructions and constraints; for repository work first read applicable AGENTS.md files in ancestors and relevant subdirectories. Do not make unsupported assumptions: inaccessible evidence or insufficient scope means unresolved, never refuted. Include blockers, overflow and uninspected scope with precise retrieval locators in explanation. Return JSON matching Verification.",
				"tools": ["read", "grep", "find", "ls"],
				"model": "large",
				"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}. Plan failures: {plan.failures}. Gathering failures: {gather.failures}. Audit failures: {audit.failures}. Verification failures: {verify.failures}. 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. Preserve applicable user instructions and constraints; for repository inspection first read applicable AGENTS.md files in ancestors and relevant subdirectories. Do not make unsupported assumptions or treat absent/failed workers as clean evidence. Explicitly list blockers; carry failed or missing angles/tasks, unresolved verification and overflow into gaps with reasons. Fully answered requires no material outstanding gap or blocker; otherwise use partially answered or unresolved. Preserve independent findings and qualifications; source registry entries may share a single entry only when URL and metadata are identical, never merge distinct evidence or contradictory claims. Within schema bounds explicitly report overflow, uncovered scope/count and retrieval locators in gaps instead of silent omission. Never invent or alter URLs and never dump source JSON into prose. Return JSON matching ResearchReport.",
				"tools": ["read", "grep", "find", "ls"],
				"model": "large",
				"schema": "ResearchReport"
			}
		}
	],
	"return": "{report.results}",
	"report": "{report.results}"
}