aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoramankumarsingh77 <amankumarsingh7702@gmail.com>2026-07-08 21:41:47 +0530
committeramankumarsingh77 <amankumarsingh7702@gmail.com>2026-07-08 21:41:47 +0530
commit1c12b43a674ae51a39c430ed8cfa138dbdf4dc71 (patch)
tree45d256d77c478d5cd1bae0620d5965d889bf4cce /src
parent3f65a30e3f78e749110ad0d883e265b3a59dec13 (diff)
feat: add deep-research skill, /deep-research command, fix web-search-researcher
deep-research skill fans out to isolated web-search-researcher subagents (now using browser_web_search + browser_read_page instead of the non-existent web_search/web_fetch), coverage-driven loop with a hard ceiling, synthesizes a cited Markdown report. /deep-research command as explicit entry point. Docs updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'src')
-rw-r--r--src/deep-research.ts41
-rw-r--r--src/index.ts3
2 files changed, 44 insertions, 0 deletions
diff --git a/src/deep-research.ts b/src/deep-research.ts
new file mode 100644
index 0000000..5034fe4
--- /dev/null
+++ b/src/deep-research.ts
@@ -0,0 +1,41 @@
+/**
+ * Deep research — the /deep-research slash command. An explicit entry point
+ * (alongside the auto-triggering deep-research skill) that kicks off a research
+ * run for a given question.
+ *
+ * The command is thin: it validates a non-empty question and injects a user
+ * message that starts the deep-research flow. The actual orchestration
+ * (decompose → fan out web-search-researcher subagents → synthesize a cited
+ * report) lives in skills/deep-research/SKILL.md, which the injected prompt
+ * triggers. pi.sendUserMessage always starts a turn.
+ */
+
+import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
+
+// ── Shared core: build the prompt that starts a deep-research run ───────────
+
+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}`
+ );
+}
+
+// ── Public: register the /deep-research slash command ──────────────────────
+
+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));
+ },
+ });
+}
diff --git a/src/index.ts b/src/index.ts
index 7265263..0991c5d 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -14,6 +14,7 @@
* /browser-setup — guided setup wizard
* /browser-status — show client status and current page
* /browser-reload-daemon — restart the browser client
+ * /deep-research <q> — research a question on the web, write a cited report
*
* Flags:
* --browser-namespace <name> — override namespace (default: auto)
@@ -24,6 +25,7 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
import { type BrowserClient, createBrowserClient } from "./client";
import { getBrowserSystemPrompt } from "./prompt";
import { registerSetupCommand } from "./setup";
+import { registerDeepResearchCommand } from "./deep-research";
import { type BrowserState, defaultState, persistState, restoreState } from "./state";
import { registerAllTools } from "./registry";
import { cleanupTempDirs } from "./util/truncate";
@@ -141,6 +143,7 @@ export default function browserHarnessExtension(pi: ExtensionAPI): void {
toolsRegistered = true;
}
registerSetupCommand(pi, client);
+ registerDeepResearchCommand(pi);
ctx.ui.setStatus(
"browser",
client.status().alive ? "🟢 Browser connected" : "🔴 Browser — run /browser-setup",