feat: workspace_context tool + preference persistence (closes #31)#33
Open
feat: workspace_context tool + preference persistence (closes #31)#33
Conversation
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>
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
workspace_contextMCP tool that assembles preferences, recent files, and activity summary in one call for session startget_context()toWorkspaceServiceand publicWorkspaceclassinstructionsto FastMCP for Claude Code preference persistence guidanceworkspace_contextfirst and persist preferencesscripts/session-start.jscloud mode to useworkspace_context.opencode/plugins/sayou.ts,opencode.json,AGENTS.md) with session-start context loading, activity capture, and system prompt injectionget_context(), e2e preference persistence tests, MCP-layer e2e tests simulating OpenCode agent integrationTest plan
pytestpasses (265 tests, 2 skipped smoke tests)workspace_contextreturns preferences, recent files, activity for a populated workspaceworkspace_writeguidancepreferences/folder appear in nextworkspace_contextcallopencode.json,.opencode/, andAGENTS.mdto project, runopencode, verifyworkspace_contextfires on session start and preferences persist across sessionsCloses #31
Closes #32
🤖 Generated with Claude Code