Skip to content

feat(plugins): add ov-usage, an opt-in Claude Code plugin showing OpenViking sources per answer - #5652

Closed
wongzw wants to merge 5 commits into
volcengine:mainfrom
wongzw:feat/claude-code-usage-plugin
Closed

wongzw wants to merge 5 commits into
volcengine:mainfrom
wongzw:feat/claude-code-usage-plugin

Conversation

@wongzw

@wongzw wongzw commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds OV-Usage (examples/claude-code-usage-plugin/), an opt-in Claude Code plugin that shows which OpenViking sources each answer consulted: what auto-recall added for the prompt, and what Claude searched for and read on its own. It shows this in a sidebar or as cards under each answer, plus a status line, with totals for the session and across sessions.

It's opt-in: listed in the root Claude marketplace as ov-usage@openviking, not installed by the installer, and it doesn't change how openviking-memory recalls or captures (apart from memories a user mutes for the current session).

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

Related Issue

None opened yet. Happy to open one if maintainers prefer to agree the design first (see Additional Notes).

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

  • New plugin examples/claude-code-usage-plugin/: hooks module (hooks/register.tsx) plus pure modules (parse.ts, sources.ts, openviking.ts, strings.ts), state contract (types/index.d.ts), 88 tests, and README / README_CN covering requirements, what it reads and stores, and limitations.
  • .claude-plugin/marketplace.json: adds the ov-usage entry (git-subdir, examples/claude-code-usage-plugin).
  • .github/scripts/check-plugin-version-bumps.sh: registers the plugin so later changes must bump its version.
  • docs/{en,zh}/agent-integrations/02-claude-code.md: short "Optional: OV-Usage" section with the install command.
  • Not added to examples/.claude-plugin/marketplace.json: that file ships in the installer archive, which doesn't include this folder, so it would point at a missing directory.

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: passes
  • claude plugin test examples/claude-code-usage-plugin: 88 pass
  • tsc -p examples/claude-code-usage-plugin --noUnusedLocals (after Claude Code generates its types): passes
  • node --test examples/claude-code-memory-plugin/scripts/marketplace.test.mjs: 8 pass
  • bash .github/scripts/check-plugin-version-bumps.sh upstream/main: passes
  • git diff --check: clean
  • Manual: used locally in Claude Code 2.1.289 on macOS with openviking-memory installed.

The plugin's tests run on Claude Code's plugin test runner (claude plugin test), not node --test, so the repository's Node CI doesn't run them.

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 (not applicable: no dependent changes)

Screenshots (if applicable)

Text examples of the sidebar, cards and status line are in the plugin README.

Additional Notes

Points for reviewers (area: Integration / agent plugins, cc @t0saki @ZaynJarvis):

  • Host requirement. Built on Claude Code plugin hooks (hooks.json with modules), which need Claude Code 2.1.286+ and are still early access. On older versions the plugin installs but shows nothing.
  • Dependency on openviking-memory internals. It reads openviking-memory's state files (last_inject.md, last-recall.json, last-capture.json) and runs its scripts/config.mjs, located through Claude Code's plugin registry. These aren't a published interface; the README says so. If maintainers prefer, a follow-up could have openviking-memory publish one documented, versioned snapshot for tools like this to read.
  • Muting removes a memory from openviking-memory's recall context for the current session only. Nothing in OpenViking changes. It could later move to openviking-memory's recallExcludeUris.
  • Code layout. Everything that uses Claude Code's engine handle $ stays in register.tsx, because Claude Code traces $ only within the module hooks.json names and refuses a module that passes it to an imported function. Pure code is split into the other modules.
  • Size. About 4,300 added lines, of which ~1,450 are tests and ~400 are the two READMEs. Happy to split it if that helps review.

zw-bd and others added 4 commits October 5, 2026 23:37
…nViking sources per answer

OV-Usage shows which OpenViking sources each Claude Code answer consulted:
what auto-recall added and what Claude searched for and read on its own, in
a sidebar or as cards under each answer, with a status line. It is opt-in:
listed in the root Claude marketplace as ov-usage@openviking, not installed
by the installer, and not added to the installer's directory marketplace,
whose archive does not ship this folder.

It reads openviking-memory's own state files and runs its config loader from
the install Claude Code's plugin registry names. The plugin README documents
this dependency and the plugin's other limits.

Tests run on Claude Code's plugin test runner (claude plugin test), not the
repository's Node CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the code that never touches Claude Code's engine handle into its own
modules: labels (strings.ts), parsing of recall blocks, the startup context,
URIs, redaction and fingerprints (parse.ts), what a source is and what an
answer consulted (sources.ts), and the formats of openviking-memory's settings
and the totals across sessions (openviking.ts).

Everything that uses $ stays in register.tsx: Claude Code traces $ only within
the module hooks.json names and refuses a module that passes it to an imported
function. The sidebar render moves out of its hook into renderPane.

Removes code nothing used: LAYER_COLOR, headline() and an unused read in the
sidebar. Behavior is unchanged; the 88 plugin tests pass as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n one owner

- Settings now reads commitTokenThreshold and says "saves to memory every
  20,000 tokens". openviking-memory's Claude Code capture commits by tokens;
  the commitTurnThreshold it showed before is not used there.
- classifyToolCall in sources.ts decides whether a tool call is an OpenViking
  lookup or write (MCP tool or `ov` CLI), replacing checks spread across
  parse.ts, sources.ts and register.tsx.
- replyFor moves to parse.ts, beside the fingerprints it matches on.
- tool.call reads the Bash command through Claude Code's narrowed type, not a
  cast; MCP arguments are read by name, since the tool names vary by install.
- Turn.lookups and the saved-session fields are required: there are no earlier
  saved formats to fall back for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…READMEs

Settings shows openviking-memory's commitTokenThreshold, and the Development
section names classifyToolCall in sources.ts and the transcript-row matching
in parse.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
t0saki pushed a commit that referenced this pull request Oct 6, 2026
…er (#5653)

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>
@wongzw wongzw closed this Oct 6, 2026
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