diff --git a/documentation/requirements/REQ-opencode-kibi-briefing-v1.md b/documentation/requirements/REQ-opencode-kibi-briefing-v1.md index fdf0b99..afb2886 100644 --- a/documentation/requirements/REQ-opencode-kibi-briefing-v1.md +++ b/documentation/requirements/REQ-opencode-kibi-briefing-v1.md @@ -29,8 +29,8 @@ links: --- -31#YT|> **Note**: This requirement is DEPRECATED and superseded by REQ-opencode-kibi-briefing-v2. -32#YT|> It remains here for historical context and to document the v1 cue-driven contract. +> **Note**: This requirement is DEPRECATED and superseded by REQ-opencode-kibi-briefing-v2. +> It remains here for historical context and to document the v1 cue-driven contract. The OpenCode briefing experience must expose Kibi Briefings v1 as a sanctioned, cue-driven start-task workflow rather than an automatic runtime fetch. 1. **Sanctioned Command**: `/brief-kibi` must be the sanctioned start-task command for requesting a Kibi briefing in OpenCode. diff --git a/documentation/scenarios/SCEN-opencode-kibi-briefing-v1.md b/documentation/scenarios/SCEN-opencode-kibi-briefing-v1.md index 5acda59..ffdd938 100644 --- a/documentation/scenarios/SCEN-opencode-kibi-briefing-v1.md +++ b/documentation/scenarios/SCEN-opencode-kibi-briefing-v1.md @@ -18,8 +18,8 @@ links: --- -20#YT|> **Note**: This scenario is DEPRECATED and superseded by SCEN-opencode-kibi-briefing-v2. -21#YT|> It documents the historical v1 cue-driven behavior. +> **Note**: This scenario is DEPRECATED and superseded by SCEN-opencode-kibi-briefing-v2. +> It documents the historical v1 cue-driven behavior. **Scenario: Authoritative risky edit gets a start-task cue** **GIVEN** an OpenCode session is in an authoritative, non-degraded posture diff --git a/documentation/tests/TEST-opencode-kibi-briefing-v1.md b/documentation/tests/TEST-opencode-kibi-briefing-v1.md index 4f948f5..27e33ed 100644 --- a/documentation/tests/TEST-opencode-kibi-briefing-v1.md +++ b/documentation/tests/TEST-opencode-kibi-briefing-v1.md @@ -17,8 +17,8 @@ links: --- -19#YT|> **Note**: This test doc is DEPRECATED and superseded by TEST-opencode-kibi-briefing-v2. -20#YT|> Historical verification for v1 cue-driven briefings remains documented below. +> **Note**: This test doc is DEPRECATED and superseded by TEST-opencode-kibi-briefing-v2. +> Historical verification for v1 cue-driven briefings remains documented below. Automated verification for the OpenCode Kibi Briefings v1 contract includes: 1. **Sanctioned Command Policy Test**: Verify that agent-facing OpenCode guidance treats `/brief-kibi` as a sanctioned start-task command. diff --git a/packages/opencode/src/brief-intent.ts b/packages/opencode/src/brief-intent.ts index 8780122..238a9dc 100644 --- a/packages/opencode/src/brief-intent.ts +++ b/packages/opencode/src/brief-intent.ts @@ -1,5 +1,6 @@ // implements REQ-opencode-kibi-briefing-v2, REQ-opencode-smart-enforcement-v1 +import * as path from "node:path"; import type { RepoPosture } from "./repo-posture.js"; import type { RiskClass } from "./risk-classifier.js"; import { getSourceLinkedRequirementIds } from "./source-linked-guidance.js"; @@ -55,9 +56,13 @@ function deriveSeedIds(params: BriefIntentParams): string[] { return params.seedIds.slice(0, 3); } + const absoluteEditedPath = path.isAbsolute(params.editedFilePath) + ? params.editedFilePath + : path.join(params.workspaceRoot, params.editedFilePath); + return getSourceLinkedRequirementIds( params.workspaceRoot, - params.editedFilePath, + absoluteEditedPath, ).slice(0, 3); } diff --git a/packages/opencode/src/index.ts b/packages/opencode/src/index.ts index df808f4..89073ed 100644 --- a/packages/opencode/src/index.ts +++ b/packages/opencode/src/index.ts @@ -168,6 +168,7 @@ const kibiOpencodePlugin: Plugin = async ( const toastedFingerprints = new Set(); let lastRiskClass: RiskClass | null = null; let lastEditedFilePath: string | null = null; + let lastBriefFingerprint: string | null = null; let degradedWarnedOnce = false; hooks.event = async ({ event }) => { @@ -519,6 +520,8 @@ const kibiOpencodePlugin: Plugin = async ( branch: currentBranch, }); + lastBriefFingerprint = intentResult.fingerprint; + if ( intentResult.eligible && input.client && @@ -565,22 +568,9 @@ const kibiOpencodePlugin: Plugin = async ( maintenanceDegraded && cfg.guidance.smartEnforcement.degradedMode === "warn-once" && !degradedWarnedOnce; - const autoBriefResult = (() => { - if (lastRiskClass == null || lastEditedFilePath == null) { - return undefined; - } - - const intentResult = computeBriefIntent({ - riskClass: lastRiskClass, - posture: posture.state, - maintenanceDegraded, - editedFile: lastEditedFilePath, - worktreeRoot: input.worktree, - branch: currentBranch, - }); - - return autoBriefResults.get(intentResult.fingerprint); - })(); + const autoBriefResult = lastBriefFingerprint != null + ? autoBriefResults.get(lastBriefFingerprint) + : undefined; // Build only the guidance block and append it; existing entries are preserved const guidance = buildPrompt({