Skip to content

feat: workspace_context tool + preference persistence (closes #31)#33

Open
syumpx wants to merge 6 commits intomainfrom
feat/workspace-context
Open

feat: workspace_context tool + preference persistence (closes #31)#33
syumpx wants to merge 6 commits intomainfrom
feat/workspace-context

Conversation

@syumpx
Copy link
Copy Markdown
Member

@syumpx syumpx commented Feb 23, 2026

Summary

  • Add workspace_context MCP tool that assembles preferences, recent files, and activity summary in one call for session start
  • Add get_context() to WorkspaceService and public Workspace class
  • Add server instructions to FastMCP for Claude Code preference persistence guidance
  • Make tool descriptions self-guiding so generic MCP clients (OpenCode, Cline, aider) know to call workspace_context first and persist preferences
  • Simplify scripts/session-start.js cloud mode to use workspace_context
  • Add OpenCode plugin (.opencode/plugins/sayou.ts, opencode.json, AGENTS.md) with session-start context loading, activity capture, and system prompt injection
  • Add comprehensive tests: unit tests for get_context(), e2e preference persistence tests, MCP-layer e2e tests simulating OpenCode agent integration

Test plan

  • pytest passes (265 tests, 2 skipped smoke tests)
  • workspace_context returns preferences, recent files, activity for a populated workspace
  • Empty workspace returns onboarding message with workspace_write guidance
  • Preferences written to preferences/ folder appear in next workspace_context call
  • Preference updates (overwrite) replace old version
  • Tool descriptions contain self-guiding text for generic MCP clients
  • Server instructions mention preference persistence
  • OpenCode user: copy opencode.json, .opencode/, and AGENTS.md to project, run opencode, verify workspace_context fires on session start and preferences persist across sessions

Closes #31
Closes #32

🤖 Generated with Claude Code

syumpx and others added 5 commits February 23, 2026 22:44
Adds a single MCP tool that assembles preferences, recent files, and
activity summary in one call — replacing the multi-call manual assembly
in session-start.js. Server instructions now guide agents to persist
user preferences automatically to preferences/ folder.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Validates the core use case: user says "I don't like X" → agent persists
preference to preferences/ → next session loads it via workspace_context.

8 scenarios covering: single preference, accumulation across sessions,
preference updates, formatted output, separation from work files,
onboarding message, server instructions, and full 3-session agent sim.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
workspace_context description now explicitly instructs any LLM to call it
at session start and follow returned preferences. workspace_write describes
the preferences/ convention. This ensures agents connected via plain MCP
(OpenCode, Cline, aider) can discover the preference pattern from tool
descriptions alone, without needing platform-specific hooks or instructions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests the exact code path an OpenCode user would hit by calling through
FastMCP.call_tool() — the same interface any MCP client uses. 6 tests:

1. Full 3-session loop: empty workspace → user expresses preferences →
   next session loads them via workspace_context → system prompt injection
2. Preference update: user corrects preference → only new version loads
3. Tool descriptions: verify they're self-guiding for generic MCP clients
4. Server instructions: verify preference persistence guidance
5. Incremental rule learning: 5 sessions accumulating 4 preferences
6. Context + search: load context then search past decisions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds OpenCode integration so users get the same preference persistence
and session-start context loading that Claude Code and Cursor users get.

- .opencode/plugins/sayou.ts: Plugin with session.created context loading,
  tool.execute.after activity capture, and system.transform prompt injection
- opencode.json: MCP server config pointing to sayou CLI
- AGENTS.md: Workspace usage instructions (OpenCode equivalent of CLAUDE.md)
- .opencode/package.json: Plugin package manifest

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tion, dedup, toasts

Borrowed 5 ideas from HarKro753/opencode-agent-context:

1. /remember command — explicit save shortcut for preferences
2. Compaction-aware injection — re-injects preferences on
   experimental.session.compacting so they survive long sessions
3. Toast notifications — showToast when preferences are saved
4. Deduplication — checks existing preferences before saving duplicates
5. Auto-extraction on idle — spawns throwaway LLM session on
   session.idle to analyze user messages and extract preferences
   automatically, no agent self-direction needed

Also adds /context command to view all saved preferences.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Add workspace_context MCP tool + server instructions for universal preference persistence feat: OpenCode plugin for sayou

1 participant