Fix auto-briefing path normalization, fingerprint caching, and doc annotation artifacts#159
Fix auto-briefing path normalization, fingerprint caching, and doc annotation artifacts#159
Conversation
- 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>
There was a problem hiding this comment.
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
editedFilePathto 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. |
| const autoBriefResult = lastBriefFingerprint != null | ||
| ? autoBriefResults.get(lastBriefFingerprint) | ||
| : undefined; |
There was a problem hiding this comment.
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.
| 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; |
| @@ -168,6 +168,7 @@ const kibiOpencodePlugin: Plugin = async ( | |||
| const toastedFingerprints = new Set<string>(); | |||
| let lastRiskClass: RiskClass | null = null; | |||
| let lastEditedFilePath: string | null = null; | |||
There was a problem hiding this comment.
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.
| let lastEditedFilePath: string | null = null; |
|
|
||
| 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. |
There was a problem hiding this comment.
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.
| > **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. |
|
|
||
| 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. |
There was a problem hiding this comment.
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.
| > **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. |
|
|
||
| 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. |
There was a problem hiding this comment.
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.
| > **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. |
Three bugs from PR review: relative
editedFilePathvalues fromfile.editedevents silently returned empty seed IDs;computeBriefIntent()re-readsymbols.yamlfrom disk on everysystem.transforminvocation; and accidental#YT|>prefixes were left in three v1 documentation files.Changes
brief-intent.ts— path normalization:deriveSeedIds()was passingeditedFilePathdirectly togetSourceLinkedRequirementIds(), which callspath.relative(worktree, editedAbsolutePath)and expects an absolute path. Relative paths (typical fromfile.edited) never matched symbol entries, silently returning[]. Now joins withworkspaceRootwhen not absolute;sourceFilesstill preserves the original value.index.ts— fingerprint caching:system.transformwas reconstructing acomputeBriefIntent()result solely to get a fingerprint forautoBriefResultslookup. That call synchronously parsessymbols.yamlon every transform. Now storeslastBriefFingerprintwhen the intent is computed in thefile.editedhandler and uses it directly in the transform hook.Documentation cleanup: Removed
#YT|>annotation prefixes from deprecated-note lines inREQ-opencode-kibi-briefing-v1.md,SCEN-opencode-kibi-briefing-v1.md, andTEST-opencode-kibi-briefing-v1.md.