Repository navigation
feat(auto-advisor): add OpenCode Auto Advisor - #61
Closed
capyBearista wants to merge 16 commits into
Closed
capyBearista wants to merge 16 commits into
capyBearista wants to merge 16 commits into
Conversation
This was referenced Sep 28, 2026
Implements #48: V2 server-only package, sparse global config, zero-arg advisor(), canonical context serialization with media placeholders, routing domain with fingerprinting, AdvisorRouter seam, AND policy and per-turn budget. Gate review passed with fixes applied.
Non-obvious discoveries from the Phase 1 build: four-file release registration coupling, first-publish 404 behavior, package-list sync, git-restore safety-net forms, turbo --force evidence rule, reviewer routing, plus auto-advisor router strictness and Phase 2 limits. Context: - Updated AGENTS.md with release, git, testing, and review-routing conventions - Updated packages/opencode-auto-advisor/AGENTS.md with router strictness and known limits
V2 table row, five-port counts, structure/context lists, V2-correct JIT patterns, and three repaired doc links from the bootstrap audit drift report. Context: - Updated AGENTS.md managed sections (structure, JIT index) and V2 boundary counts - Updated three package AGENTS.md files with corrected relative doc links
… context Automatic routing consumes the assembled session.context request instead of reconstructing persisted history; explicit advisor() merges a turn-matched hook snapshot with the current assistant delta. Fingerprints are SHA-256 digests, media names/URIs are sanitized, and snapshot/turn state is bounded. Context: - Updated packages/opencode-auto-advisor/AGENTS.md with the three-domain architecture, digest fingerprints, sanitization rules, and known limits
Route automatic consultations through OpenCode Zen behind the AdvisorRouter seam (free-first chain with bounded retry and per-class fallback), record digest-only observe telemetry with read-only RPC, and deliver accepted advice as system-role context with same-turn lifetime. Baseline moves to OpenCode 2.0.19 (upstream stateless-generation session-attribution fix); live off/observe/active validation passes on 2.0.19. Context: - Updated AGENTS.md with the gh-api PR-body workaround and self-contained delegation-briefs rule - Updated packages/opencode-auto-advisor/AGENTS.md with Zen adapter, delivery, telemetry, and host-contract notes
Replace the shared unbounded transcript with a canonical normalized state plus separate fingerprint, Jev routing, and Advisor consultation projections; make automatic consultation model-aware with a 25% reserve budget, priority retention, and lazy construction; tighten the Zen deadline to 5s with distinct retry/fallback/fail-open outcomes; skip paid models the public bearer rejects via a session ineligibility cache; fail the context hook open end to end; and reconcile the durable docs with the resulting behavior. Context: - Root AGENTS.md: gh issue-body endpoint, gh issue comment --jq gap, pipe-tail masking, delegated-lane validation protocol rule - Package AGENTS.md: state representations, model-aware budget, Zen chain semantics, RPC silent-strip note, telemetry label nuances
The host-path round-trip test imported effect directly, which resolves in local node_modules but not in a clean install, failing CI. Replace it with a dependency-free assertion that every emittable event field is declared in the schema.
share one stateless tool-free advisor service across explicit and automatic paths with model-aware projection, root-only eligibility and native permission checks. use privileged system delivery for new and retained advice, bounded history with exact compaction proof, soft timeout and operation lifetime guards. add optional TUI companion with lifecycle RPC plus reconnect and ordering fixes, alongside docs and coverage for the 18-case manual procedure. Context: - Updated packages/opencode-auto-advisor/AGENTS.md with live-verification findings (child-session identity, loopback host isolation, bundled Zen instrumentation, synthetic provenance)
…ke suite Replace multi-record advice history and the compaction-absorption protocol with one bounded latest retained review per session; persistence is best-effort and never suppresses same-dispatch delivery. Drop the custom permission engine (host 2.0.21 filtering suffices: root check plus advertised tool), collapse the TUI to one shared store, and shrink the built-artifact smoke to a seam check. All settled behavior preserved. Context: - Updated packages/opencode-auto-advisor/AGENTS.md (retained-review model, seam-check smoke, live-probe learnings) - Reconciled package README, governing plan, and manual-test checklist
| try { | ||
| clearTimeoutFn(pulseTimer); | ||
| } catch { | ||
| undefined; |
| try { | ||
| unsubscribe(); | ||
| } catch { | ||
| undefined; |
| try { | ||
| queryAbort?.abort(); | ||
| } catch { | ||
| undefined; |
| try { | ||
| queryAbort?.abort(); | ||
| } catch { | ||
| undefined; |
| try { | ||
| offConnected?.(); | ||
| } catch { | ||
| undefined; |
| try { | ||
| next.dispose(); | ||
| } catch { | ||
| undefined; |
| try { | ||
| off?.(); | ||
| } catch { | ||
| undefined; |
| try { | ||
| free?.(); | ||
| } catch { | ||
| undefined; |
| try { | ||
| unregisterFooter(); | ||
| } catch { | ||
| undefined; |
| try { | ||
| unregisterComposer(); | ||
| } catch { | ||
| undefined; |
…edes-old Retention leaves the Executor critical path: in-memory overlay is authoritative, durable writes are per-session best-effort, fresh advice ships alone, oversize tombstones, write failure keeps the new review. Parser hardened, TUI listeners isolated, smoke + docs reconciled.
…uidance Cold-start TUI discovery, smoke-scenario upkeep, free-Zen Advisor gate, and the 2.0.21 RPC path-param shape bit live verification; capture them where future probes will look. Context: - Updated packages/opencode-auto-advisor/AGENTS.md testing/TUI guidance with four non-obvious findings from real-host 2.0.21 probes
…cal path Telemetry is fire-and-forget (failures consumed); retained hydration is exactly-once background with sync cached peek, absence cached, late hydration loses to replace/forget, observe never hydrates. clear() now tombstones unknown sessions. 7 new tests (495/0); code-reviewer gate clean; root gates fresh green; 2.0.21 probes 4/4 PASS. Context: storage-critical-path remediation pass; branch manual-test-ready.
Reviewer-surfaced invariants from the hook-critical-path pass: telemetry queue backpressure, retained test-file coupling with reads() pins, the synchronous hydration-assignment mechanism, fail-open negative caching, and the clear-vs-forget cleanup contract. Context: - Updated packages/opencode-auto-advisor/AGENTS.md with 3 entries (telemetry backpressure, hook-contract pins, cleanup contract)
12 of 24 tasks
Owner
Author
|
Superseded by #94. OpenCode 2.2.0 removed the experimental Evaluation/System One API this PR is built on, so it can't run on current OpenCode. #94 rebuilds the plugin on 2.2.0's Decision API and instruction entries (see #47 and #50 for the updated scope). This branch stays for reference. Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Draft PR for
@capybearista/opencode-auto-advisor(unpublished2.0.0), rebuilt from currentmainafter the original planning branch diverged substantially. Supersedes #54.An OpenCode V2-only server plugin providing an independent Advisor through explicit consultation plus experimental automatic routing, with an optional TUI companion. Implementation is approved as of 2026-09-28 and may proceed on this draft PR.
Linked issues
Refs #47 (tracking)
Active execution contracts:
Issues #49, #51, and #52 are consolidated into the active contracts/epic.
Current design baseline
@opencode/plugin@2.0.21and@opencode/ai@2.0.21(verified against host source).advisor().off;observerecords telemetry only; v1 automatic routing uses OpenCode Zen only.AdvisorRouter; default chainjev-1.13-free->jev-1.13; every new opportunity restarts at the top; bounded transient retry; whole-chain failure fails open for that opportunity only.advisor_would_helpprobability and 0-4consequencescore through deterministic thresholds;routing.maxConsultationsPerTurndefault 1; explicitadvisor()does not consume the automatic budget.session.context.system; no fabricated tool call, synthetic message,Message.system, orsession.synthetic().observenever hydrates).latest; current release tooling already supports V2 packages onlatest.Configuration surface
Seven v1 knobs:
advisor.modeladvisor.timeoutMs(default 300000, soft)routing.mode(off | observe | active)routing.models(ordered Zen chain)routing.advisorWouldHelpThreshold(0.7)routing.consequenceThreshold(3)routing.maxConsultationsPerTurn(1)Internal retry timing, fingerprint mechanics, telemetry retention, and retention bounds are intentionally not additional user knobs in v1.
Implementation authorization
Implementation is approved as of 2026-09-28.
The coding orchestrator may proceed against the governing plan and active issue contracts. It should continue to re-check current repository/OpenCode V2 behavior, refine implementation details and tests from runtime evidence, document the initial routing thresholds/consequence anchors, and keep the durable plan synchronized with material findings.
No additional approval pause is required for work within the approved scope. Material changes to requirements, architecture, public interfaces, privacy/security behavior, configuration semantics, release strategy, or acceptance criteria require plan updates and explicit re-approval.
Quality / readiness
off/observe/activeruntime scenarios validatedbun run typecheck && bun run lint && bun run test && bun run build(package 495/0 + root fresh green)docs/plans/opencode-auto-advisor-manual-test.md, 19 cases) — next phaseHistory (labeled, preserved for context)
clear()tombstones unknown sessions); 7 new tests incl. guard-removal probes; code-reviewer gate 0 critical/important (1 minor remediated); suite 495/0; narrow live 2.0.21 probes 4/4 PASS (fresh delivery, in-process + restart reinjection with documented first-request miss, status RPC, headless).No merge/publish/dogfood in this pass — branch is manual-test-ready, awaiting USER manual testing.