Skip to content

feat(plugins): add ov-usage cards showing OpenViking sources per answer - #5653

Merged
t0saki merged 1 commit into
mainfrom
feat/ov-usage-cards
Oct 6, 2026
Merged

t0saki merged 1 commit into
mainfrom
feat/ov-usage-cards

Conversation

@ZaynJarvis

Copy link
Copy Markdown
Collaborator

Description

Adds OV-Usage, an opt-in Claude Code plugin at examples/claude-code-usage-plugin. Under each answer it draws a card listing the OpenViking sources that answer drew on: what auto-recall injected for the prompt, plus what Claude searched for and read itself through the OpenViking MCP tools or the ov CLI.

  • The card is collapsed by default to one line, e.g. OV · 14 sources · 6 past events · 5 work memories · 2 team docs · 1 skill · 1 read in full [Expand].
  • Expanded, it lists every source and Claude's own lookups.
  • Each card has an [Expand]/[Collapse] button, and /openviking-usage expand|collapse applies to every card.
  • The plugin makes no network calls, writes nothing to OpenViking, and adds no tokens.

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

The maintainer (@ZaynJarvis) set the scope for this first release. @wongzw wrote #5652 and agreed to this co-authored version.

Related Issue

Supersedes #5652 by @wongzw. The commit is co-authored with him and builds on his plugin. Its parsing, lookup classification and card idea come from #5652.

These were cut from #5652, as agreed with the maintainer, to keep the first release small:

Cut Why
Sidebar pane, history paging, overview card above the first prompt Conversation cards only for now
Status line ($.ui.status) Not needed next to the card. It also rendered with a ⚠ prefix
Settings panel, plus running openviking-memory's config.mjs through node Read openviking-memory's private config and files
All-sessions totals (last-capture.json, lifetime store) Cross-session stats belong in Studio
Mute, unmute and clear No write or management operations in the first release. Mute also rewrote openviking-memory's recall context
Low/high card detail and +N more Two states only: collapsed and expanded
i18n and macOS locale detection English only
Render tests (1442 lines) Replaced by small pure-function tests

These #5652 issues are fixed here:

  • An ov find/search call through the CLI was counted as "read in full", along with every result. Now only read, cat, abstract and overview, via CLI or MCP read, count as read in full. Search hits are listed as found.
  • Directory fragments such as viking://resources showed up as fake sources. URIs ending in / or in a scope or top-level directory are dropped.
  • The ov CLI wraps long URIs onto the next line, which truncated titles (web版本 instead of web版本未更新排查请求). Wrapped URIs are now joined.
  • Hyphens in file names were turned into spaces in titles. Names now stay as they are.
  • Cards disappeared after claude --continue because the last answer's row mapping was never saved. Each session's cards are now saved at the end of every turn and restored on resume. Verified live.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • examples/claude-code-usage-plugin/hooks/register.tsx:
    • hooks: classic.UserPromptSubmit for the recall block, tool.call for lookups, session.append for the row the card attaches to, turn.complete to save.
    • the card, drawn through ui.render on AssistantMessage.
    • per-session persistence in $.store.
  • examples/claude-code-usage-plugin/hooks/sources.ts: pure parsing of recall blocks, tool output URIs, lookup classification, and what an answer consulted.
  • examples/claude-code-usage-plugin/tests/sources.test.ts: pure-function tests.
  • Short README.md and README_CN.md. They state which openviking-memory output the plugin depends on: the <openviking-context> block its UserPromptSubmit hook returns.
  • .claude-plugin/marketplace.json: adds the ov-usage entry.
  • .github/scripts/check-plugin-version-bumps.sh: registers the plugin.
  • docs/{en,zh}/agent-integrations/02-claude-code.md: a short optional section.

The whole PR is +722 lines (#5652 was +4312). The plugin code is 223 + 193 lines.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Commands run:

  • claude plugin validate examples/claude-code-usage-plugin (Claude Code 2.1.289): passed. The validator lists the calls as $.command.register, $.session.id, $.state.*, $.store.* and $.ui.resolve. There is no $.ui.status, $.fs, $.process or $.env.
  • claude plugin test examples/claude-code-usage-plugin: 5 pass, 0 fail.
  • tsc -p examples/claude-code-usage-plugin: no errors.
  • .github/scripts/check-plugin-version-bumps.sh origin/main: passed.
  • node --test examples/claude-code-memory-plugin/scripts/marketplace.test.mjs: 8 pass. release-marketplace.test.mjs fails the same 5 cases on a clean main on this machine, because there is no zip binary. Not related to this PR.

Live run: a real Claude Code 2.1.289 session with openviking-memory 0.5.2, auto-capture off and no OpenViking writes.

  • One answer showed OV · 14 sources · 6 past events · 5 work memories · 2 team docs · 1 skill · 1 read in full. Claude ran two ov find calls and one ov read, so only the read counted as read in full.
  • /openviking-usage expand and collapse worked.
  • The card was still under the answer after claude --continue.
  • No status line was drawn.
  • The button was not clicked in this run. The terminal's classic renderer has no mouse, so the command was used.

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Screenshots of the live run (the same answer card, collapsed and then expanded) were taken locally. They can be added on request.

Additional Notes

The plugin depends on the format of openviking-memory's <openviking-context> recall block. If that format changes, auto-recalled items stop showing. Claude's own lookups keep working.

🤖 Generated with Claude Code

OV-Usage is an opt-in Claude Code plugin. Under each answer it draws a
one-line card with the OpenViking sources the answer drew on: what
auto-recall injected, and what Claude searched for and read itself.
The card expands to the full source list and Claude's lookups, with a
button or /openviking-usage expand|collapse.

It reads only the <openviking-context> block openviking-memory's
UserPromptSubmit hook returns, and Claude's OpenViking MCP and `ov` CLI
calls. Only real reads count as "read in full"; search hits do not.
Cards are kept per session in the plugin store, so they survive
`claude --continue`.

This is a slimmer first release of #5652: conversation cards only, no
sidebar, status line, settings panel, cross-session totals or mute.

Co-authored-by: zhou.wong <zhou.wong@bytedance.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@t0saki t0saki left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@t0saki
t0saki merged commit ba7ca66 into main Oct 6, 2026
11 checks passed
@t0saki
t0saki deleted the feat/ov-usage-cards branch October 6, 2026 02:47
t0saki pushed a commit that referenced this pull request Oct 6, 2026
…nswers (#5663)

Move the ov-usage cards (#5653) into openviking-memory as a Claude Code
hooks module, so there is one plugin to install instead of two. The
module lives in mods/usage/ and is registered through `modules` in
hooks/hooks.json, next to the existing command hooks. Cards stay
collapsed by default; `/openviking-usage expand|collapse` and the card
button are unchanged. This includes #5662's fix for titles with a
literal "%".

Claude Code ignores the module when it has no hooks modules or has them
switched off, and the command hooks run as before. On modules-capable
builds older than 2.1.286, the module fails to load (it uses
`session.append`), Claude Code logs it, and the command hooks still
register.

- Remove examples/claude-code-usage-plugin and its marketplace and
  version-bump entries.
- Bump openviking-memory to 0.7.0.
- The archive check follows a hooks module's .ts/.tsx entry and its
  extensionless imports.
- The shared-runtime sync emits .d.mts copies only for targets whose
  TypeScript imports them, so the module doesn't add declaration files
  to the memory plugin.
- Rewrite the docs sections and add a "Source cards" section to the
  plugin READMEs.

Co-authored-by: zhou.wong <zhou.wong@bytedance.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chaucerj added a commit to chaucerj/OpenViking that referenced this pull request Oct 6, 2026
volcengine#5653/volcengine#5663/volcengine#5664 moved claude-code to 0.7.1; this PR's shared-lib
change still requires a bump relative to the new base, so it lands on
0.7.2. No content conflicts — the usage-card work touches different
files than the recall exclude fallback.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants