From 4ec979747b1019657924477e3417638f1085f294 Mon Sep 17 00:00:00 2001 From: Kjell Tore Guttormsen Date: Tue, 30 Jun 2026 13:44:37 +0200 Subject: [PATCH] feat(trekresearch): add deep-research in-context adapter + self-check --- commands/trekresearch.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/commands/trekresearch.md b/commands/trekresearch.md index 4a6d220..2fa5798 100644 --- a/commands/trekresearch.md +++ b/commands/trekresearch.md @@ -443,6 +443,45 @@ Write the brief to the `brief_destination` computed in Phase 1: Create the parent directory if it does not exist. +### Deep-research engine adapter (engine = deep-research only) + +**Only when `effective_engine == deep-research`.** The swarm path skips this +entirely — its findings already flow through Phases 6–7 unchanged (SC1). + +Transform the in-context `/deep-research` report INTO +`@${CLAUDE_PLUGIN_ROOT}/templates/research-brief-template.md` — do NOT paste the +raw report. Specifically: + +- Reduce the report to ≥ 1 `### {Dimension} -- Confidence: {high|medium|low}` + entry, each carrying **External findings** bullets with per-claim source URLs. + Local findings still come from the local agents (Phase 4) and are merged in per + dimension as usual. +- Emit a numeric `confidence ∈ [0,1]` in frontmatter and a 3-sentence + `## Executive Summary` (answer, confidence, key caveat). +- Populate `## Sources` from the report's citations. +- **If the report lacks per-claim URLs, lower the confidence and note the gap in + `## Open Questions` — do NOT fabricate URLs.** Provenance you cannot cite is not + provenance. +- If the report is large, bound the transform to the top dimensions to avoid + context truncation. + +### Output self-check (engine = deep-research only) + +**Only when `effective_engine == deep-research`.** After writing to +`brief_destination`, run the output validator and repair-or-fall-back. This mirrors +the trekplan Phase-8 write→validate→repair self-check; the swarm path does NOT run +it, so swarm behavior is unchanged (SC1): + +```bash +node ${CLAUDE_PLUGIN_ROOT}/lib/validators/research-validator.mjs --json "{brief_destination}" +``` + +On `valid: false`, repair the brief to satisfy the reported errors and re-run the +validator. If it cannot be made valid (e.g. the report was too thin to yield even +one dimension), set `effective_engine = swarm`, fall back to the swarm engine for +this run (and log the fallback per the Engine selection step), rather than emit an +invalid brief. + ## Phase 8 — Present and track Present a summary to the user: