Skip to content

Fix auto-briefing path normalization, fingerprint caching, and doc annotation artifacts#159

Merged
Looted merged 2 commits intodevelopfrom
copilot/sub-pr-158
Apr 23, 2026
Merged

Fix auto-briefing path normalization, fingerprint caching, and doc annotation artifacts#159
Looted merged 2 commits intodevelopfrom
copilot/sub-pr-158

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 23, 2026

Three bugs from PR review: relative editedFilePath values from file.edited events silently returned empty seed IDs; computeBriefIntent() re-read symbols.yaml from disk on every system.transform invocation; and accidental #YT|> prefixes were left in three v1 documentation files.

Changes

  • brief-intent.ts — path normalization: deriveSeedIds() was passing editedFilePath directly to getSourceLinkedRequirementIds(), which calls path.relative(worktree, editedAbsolutePath) and expects an absolute path. Relative paths (typical from file.edited) never matched symbol entries, silently returning []. Now joins with workspaceRoot when not absolute; sourceFiles still preserves the original value.

    const absoluteEditedPath = path.isAbsolute(params.editedFilePath)
      ? params.editedFilePath
      : path.join(params.workspaceRoot, params.editedFilePath);
  • index.ts — fingerprint caching: system.transform was reconstructing a computeBriefIntent() result solely to get a fingerprint for autoBriefResults lookup. That call synchronously parses symbols.yaml on every transform. Now stores lastBriefFingerprint when the intent is computed in the file.edited handler and uses it directly in the transform hook.

  • Documentation cleanup: Removed #YT|> annotation prefixes from deprecated-note lines in REQ-opencode-kibi-briefing-v1.md, SCEN-opencode-kibi-briefing-v1.md, and TEST-opencode-kibi-briefing-v1.md.

- brief-intent.ts: normalize editedFilePath to absolute path before
  passing to getSourceLinkedRequirementIds() to fix silent [] return
  when file.edited emits a relative path
- index.ts: cache lastBriefFingerprint from file.edited handler;
  system.transform now looks up the cached fingerprint instead of
  recomputing computeBriefIntent() (avoids repeated symbols.yaml I/O)
- Remove accidental #YT|> annotation prefixes from REQ, SCEN, and TEST
  v1 documentation markdown files

Agent-Logs-Url: https://github.com/Looted/kibi/sessions/48b5f91e-68ec-4a84-98ad-f37766084caf

Co-authored-by: Looted <6255880+Looted@users.noreply.github.com>
@Looted Looted marked this pull request as ready for review April 23, 2026 15:50
Copilot AI review requested due to automatic review settings April 23, 2026 15:50
@Looted Looted merged commit 120debb into develop Apr 23, 2026
Copilot AI changed the title [WIP] Enhance auto briefing functionality and documentation for v2 Fix auto-briefing path normalization, fingerprint caching, and doc annotation artifacts Apr 23, 2026
Copilot stopped work on behalf of Looted due to an error April 23, 2026 15:50
Copilot AI requested a review from Looted April 23, 2026 15:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refines OpenCode’s auto-briefing v2 flow by simplifying how the prompt hook retrieves the most recent auto-brief result, normalizing edited-file path handling for source-linked seed IDs, and cleaning up deprecated v1 documentation note formatting.

Changes:

  • Track the last computed brief “fingerprint” from file edits and use it directly in the system prompt transform hook.
  • Normalize editedFilePath to an absolute path before resolving source-linked requirement seed IDs.
  • Reformat deprecated v1 briefing docs “Note” blockquotes.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/opencode/src/index.ts Stores lastBriefFingerprint from edit events and uses it to retrieve cached auto-brief results during prompt injection.
packages/opencode/src/brief-intent.ts Ensures getSourceLinkedRequirementIds receives an absolute edited file path for consistent lookups.
documentation/tests/TEST-opencode-kibi-briefing-v1.md Reformats deprecated note blockquote.
documentation/scenarios/SCEN-opencode-kibi-briefing-v1.md Reformats deprecated note blockquote.
documentation/requirements/REQ-opencode-kibi-briefing-v1.md Reformats deprecated note blockquote.

Comment on lines +571 to +573
const autoBriefResult = lastBriefFingerprint != null
? autoBriefResults.get(lastBriefFingerprint)
: undefined;
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.
@@ -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.

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.

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants