Skip to content

Enhance auto briefing functionality and documentation for v2#158

Merged
Looted merged 19 commits intomasterfrom
develop
Apr 23, 2026
Merged

Enhance auto briefing functionality and documentation for v2#158
Looted merged 19 commits intomasterfrom
develop

Conversation

@Looted
Copy link
Copy Markdown
Owner

@Looted Looted commented Apr 23, 2026

No description provided.

Looted added 16 commits April 23, 2026 10:38
…nsform hook

- Integrate computeBriefIntent into file.edited handler to assess eligible risk classes
- Store BriefingRuntimeResult in autoBriefResults map keyed by fingerprint
- Send toast via sendToast when fetchBriefingResult resolves
- Pass autoBriefResult into buildPrompt context for prompt block rendering
- Add PromptContext.autoBriefResult field
- Add computeBriefIntent traceability link to REQ-opencode-kibi-briefing-v2
- Add 496 lines of integration tests covering all eligibility/ineligibility paths
…mbol docs

Replace schema-invalid supersedes edges (scenario→scenario, test→test) with
relates_to in SCEN-opencode-kibi-briefing-v2 and TEST-opencode-kibi-briefing-v2.
Remove plain string links arrays from SYM-cli-status-pre-first-sync-test and
SYM-mcp-cli-help-test that were being mis-imported as invalid implements edges;
executable_for relationships are preserved.
Copilot AI review requested due to automatic review settings April 23, 2026 14:57
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 introduces v2 “auto-briefing” for the OpenCode plugin: it fetches citation-backed briefing guidance asynchronously on file.edited for authoritative risky edits, renders a dedicated “Kibi briefing available” guidance block in the prompt, and updates supporting docs/tests across opencode and mcp.

Changes:

  • Add auto-brief intent derivation + background worker runtime (brief-intent, briefing-runtime) and integrate it into the OpenCode plugin event/transform flow.
  • Update prompt rendering to support auto-brief blocks, cue suppression, and bullet-budget behavior under completion reminders.
  • Expand/adjust tests and documentation for v2 briefing behavior; add toast utility and update MCP tool tests.

Reviewed changes

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

Show a summary per file
File Description
packages/opencode/src/index.ts Triggers auto-brief fetch on file.edited, stores results/toast dedupe, passes cached result into prompt transform.
packages/opencode/src/prompt.ts Renders auto-brief blocks, adjusts bullet budgeting when reminders append, suppresses cue/micro-brief as appropriate.
packages/opencode/src/brief-intent.ts Computes eligibility + fingerprint + seed IDs for auto-briefing.
packages/opencode/src/briefing-runtime.ts Implements worker session prompting, payload parsing, caching, and runtime result normalization.
packages/opencode/src/toast.ts Centralizes toast capability detection + sending (showToast vs legacy toast).
packages/opencode/src/startup-notifier.ts Refactors startup toast handling to use the new toast utility.
packages/opencode/tests/prompt.test.ts Adds prompt-level tests for auto-brief rendering/cue suppression/budgeting.
packages/opencode/tests/index.test.ts Adds integration tests covering event-triggered fetch, toast behavior, dedupe, and transform rendering.
packages/opencode/tests/hook-contract.test.ts Tightens hook output policy to avoid embedding briefing execution/payload artifacts.
packages/opencode/tests/brief-intent.test.ts Adds unit tests for intent eligibility/fingerprint/seed derivation behavior.
packages/opencode/tests/briefing-auto-render.test.ts Adds runtime-level tests for worker prompting, parsing, caching, and concurrency dedupe.
packages/opencode/tests/agent-surface-policy.test.ts Registers v2 requirement/scenario/test docs in the surface policy allowlist.
packages/mcp/tests/tools/briefing-generate.test.ts Ensures “no briefing” responses include a consistent text content payload.
documentation/** Adds v2 REQ/SCEN/TEST docs; deprecates v1 docs.
packages/opencode/package.json, packages/mcp/package.json, CHANGELOG.md Version/changelog updates aligned with the new feature set.
Comments suppressed due to low confidence (1)

packages/opencode/src/index.ts:378

  • The cache logger reports a miss even when cache.isSatisfied(cacheKey) is true for auto-brief risk classes, because execution falls through to the unconditional "cache_state: "miss"" log after the hit branch. This makes telemetry misleading and can also cause cache-hit behavior to execute twice. Consider restructuring this block so the miss log only runs when the cache is not satisfied (e.g., else), and if auto-brief work must still run on cache hits, run that work in the hit branch and return afterward.
    // Cache check: after critical signals have been emitted
    if (cache.isSatisfied(cacheKey)) {
      logger.info("smart-enforcement.cache", {
        event: "smart_enforcement_cache",
        cache_hit: true,
        cache_state: "hit",
        file: filePath,
        risk_class: effectiveRiskClass,
        posture: posture.state,
        posture_state: posture.state,
      });
      if (!isAutoBriefRisk) {
        return;
      }
    }

    logger.info("smart-enforcement.cache", {
      event: "smart_enforcement_cache",
      cache_hit: false,
      cache_state: "miss",
      file: filePath,
      risk_class: effectiveRiskClass,
      posture: posture.state,
      posture_state: posture.state,
    });

Comment on lines +54 to +61
if (params.seedIds !== undefined) {
return params.seedIds.slice(0, 3);
}

return getSourceLinkedRequirementIds(
params.workspaceRoot,
params.editedFilePath,
).slice(0, 3);
Comment thread packages/opencode/src/index.ts Outdated
Comment on lines +568 to +583
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);
})();
Comment on lines +20 to +21
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.
Comment on lines +21 to +22
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.
Comment on lines +32 to +33
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.
@Looted
Copy link
Copy Markdown
Owner Author

Looted commented Apr 23, 2026

@copilot apply changes based on the comments in this thread in a separate PR

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 23, 2026

@Looted I've opened a new pull request, #159, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits April 23, 2026 15:48
- 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>
[WIP] Enhance auto briefing functionality and documentation for v2
@Looted
Copy link
Copy Markdown
Owner Author

Looted commented Apr 23, 2026

@copilot I might have merged before you addressed all the comments. Could you open another PR with the rest?

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 23, 2026

@Looted I've opened a new pull request, #160, to work on those changes. Once the pull request is ready, I'll request review from you.

@Looted Looted merged commit 18b491c into master Apr 23, 2026
6 checks passed
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