aboutsummaryrefslogtreecommitdiff
path: root/src/deep-research.ts
blob: 9445cf84152f6ae7b1bd972c1b922237b9be81e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";

export function buildDeepResearchPrompt(question: string): string {
  return (
    `Do deep research on the following question and produce a cited Markdown report. ` +
    `Use the deep-research skill: decompose it into sub-questions, fan out web-search-researcher ` +
    `subagents to research each against the live web, then synthesize a source-cited report file.\n\n` +
    `Question: ${question}`
  );
}

export function registerDeepResearchCommand(pi: ExtensionAPI): void {
  pi.registerCommand("deep-research", {
    description: "Research a question on the web and write a cited report",
    handler: async (args, ctx) => {
      const question = args.trim();
      if (question.length === 0) {
        ctx.ui.notify('Usage: /deep-research <question>. Example: /deep-research "compare CDP vs WebDriver"', "warning");
        return;
      }
      ctx.ui.notify(`Starting deep research: ${question}`, "info");
      pi.sendUserMessage(buildDeepResearchPrompt(question));
    },
  });
}