Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions documentation/requirements/REQ-opencode-kibi-briefing-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line ends with trailing whitespace. The repo’s .editorconfig sets trim_trailing_whitespace = true for *.md, so please remove the extra space at the end of the line.

Suggested change
> **Note**: This requirement is DEPRECATED and superseded by REQ-opencode-kibi-briefing-v2.
> **Note**: This requirement is DEPRECATED and superseded by REQ-opencode-kibi-briefing-v2.

Copilot uses AI. Check for mistakes.
> 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.
Expand Down
4 changes: 2 additions & 2 deletions documentation/scenarios/SCEN-opencode-kibi-briefing-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line ends with trailing whitespace. The repo’s .editorconfig sets trim_trailing_whitespace = true for *.md, so please remove the extra space at the end of the line.

Suggested change
> **Note**: This scenario is DEPRECATED and superseded by SCEN-opencode-kibi-briefing-v2.
> **Note**: This scenario is DEPRECATED and superseded by SCEN-opencode-kibi-briefing-v2.

Copilot uses AI. Check for mistakes.
> 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
Expand Down
4 changes: 2 additions & 2 deletions documentation/tests/TEST-opencode-kibi-briefing-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line ends with trailing whitespace. The repo’s .editorconfig sets trim_trailing_whitespace = true for *.md, so please remove the extra space at the end of the line.

Suggested change
> **Note**: This test doc is DEPRECATED and superseded by TEST-opencode-kibi-briefing-v2.
> **Note**: This test doc is DEPRECATED and superseded by TEST-opencode-kibi-briefing-v2.

Copilot uses AI. Check for mistakes.
> 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.
Expand Down
7 changes: 6 additions & 1 deletion packages/opencode/src/brief-intent.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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);
}

Expand Down
22 changes: 6 additions & 16 deletions packages/opencode/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const kibiOpencodePlugin: Plugin = async (
const toastedFingerprints = new Set<string>();
let lastRiskClass: RiskClass | null = null;
let lastEditedFilePath: string | null = null;
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastEditedFilePath is now assigned but never read (it was previously only used to recompute the auto-brief fingerprint). This looks like leftover state and will likely trigger an unused-variable lint/TS error; remove it or reintroduce a use that matches the intended behavior.

Suggested change
let lastEditedFilePath: string | null = null;

Copilot uses AI. Check for mistakes.
let lastBriefFingerprint: string | null = null;
let degradedWarnedOnce = false;

hooks.event = async ({ event }) => {
Expand Down Expand Up @@ -519,6 +520,8 @@ const kibiOpencodePlugin: Plugin = async (
branch: currentBranch,
});

lastBriefFingerprint = intentResult.fingerprint;

if (
intentResult.eligible &&
input.client &&
Expand Down Expand Up @@ -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;
Comment on lines +571 to +573
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastBriefFingerprint is only updated inside the isAutoBriefRisk branch, but the system.transform hook always uses it to fetch autoBriefResult. After a subsequent non-auto-brief edit (e.g. safe_docs_only / safe_test_only), this can keep showing a stale auto-brief result from an earlier risky edit. Consider clearing lastBriefFingerprint whenever an edit is processed that won’t compute/fetch a new briefing (or updating it for every edit), so the guidance reflects the current context.

Suggested change
const autoBriefResult = lastBriefFingerprint != null
? autoBriefResults.get(lastBriefFingerprint)
: undefined;
const shouldUseAutoBriefResult =
lastRiskClass !== "safe_docs_only" &&
lastRiskClass !== "safe_test_only";
if (!shouldUseAutoBriefResult) {
lastBriefFingerprint = undefined;
}
const autoBriefResult =
shouldUseAutoBriefResult && lastBriefFingerprint != null
? autoBriefResults.get(lastBriefFingerprint)
: undefined;

Copilot uses AI. Check for mistakes.

// Build only the guidance block and append it; existing entries are preserved
const guidance = buildPrompt({
Expand Down