-
Notifications
You must be signed in to change notification settings - Fork 9
Add simple scoped memory with global user scope and robust recall #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rohith50
wants to merge
1
commit into
ApplauseLab:main
Choose a base branch
from
rohith50:feat/simple-scoped-memory
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,140 @@ | ||
| # Agent Guidelines | ||
|
|
||
| ## Commands | ||
| - **Install**: `bun install` | ||
| - **Type check**: `bun run tsc --noEmit` | ||
| - **Run**: `bun run index.ts` | ||
| - **Test manually**: `bun -e "import { MemoryPlugin } from './index.ts'; ..."` | ||
|
|
||
| ## Code Style | ||
| - **Runtime**: Bun (use Bun APIs: `Bun.file()`, `Bun.write()`, `Bun.Glob`, `Bun.$`) | ||
| - **Imports**: Use `import type` for type-only imports (`verbatimModuleSyntax`) | ||
| - **Types**: Strict mode enabled, handle `undefined` from indexed access (`noUncheckedIndexedAccess`) | ||
| - **Naming**: camelCase for functions/variables, PascalCase for types/interfaces | ||
| - **Exports**: Re-export public API from `index.ts`, implementation in `src/` | ||
|
|
||
| ## Plugin Structure | ||
| - Tools use `@opencode-ai/plugin` `tool()` helper with Zod-like schema (`tool.schema`) | ||
| - Plugin exports async function returning `{ tool: { ... } }` | ||
| - Memories stored in `.opencode/memory/` as logfmt files | ||
| # Global OpenCode Instructions | ||
|
|
||
| ## Memory Behavior | ||
|
|
||
| You have access to persistent memory tools: | ||
| `memory_remember`, `memory_recall`, `memory_update`, `memory_forget`, and `memory_list`. | ||
|
|
||
| Memory storage is split into two layers: | ||
|
|
||
| - `scope="user"` → global cross-repo memory | ||
| - all other scopes → repo-local memory for the current project | ||
|
|
||
| Treat memory as long-term working context, not as a transcript or scratchpad. | ||
|
|
||
| ## Core Principle | ||
|
|
||
| Only save memories that are likely to matter in a future session. | ||
|
|
||
| Prefer saving: | ||
| - stable user preferences | ||
| - recurring workflow habits | ||
| - durable project conventions | ||
| - finalized design decisions | ||
| - recurring blockers or important gotchas | ||
|
|
||
| Do not save: | ||
| - temporary task state | ||
| - one-off conversational details | ||
| - speculative ideas | ||
| - transient errors | ||
| - secrets, credentials, tokens, or private endpoints | ||
|
|
||
| ## Session Start | ||
|
|
||
| Do not call unfiltered `memory_recall` at session start. | ||
|
|
||
| On the first meaningful user request in a session: | ||
|
|
||
| 1. Recall stable cross-project user context: | ||
| - `memory_recall(scope="user", limit=5)` | ||
|
|
||
| 2. If working inside a repository, recall repo-relevant memory with a small limit: | ||
| - `memory_recall(scope="<repo-name>", limit=8)` | ||
|
|
||
| 3. Only recall domain-specific memory when the task clearly touches that area: | ||
| - `memory_recall(scope="auth", query="token session cookie", limit=5)` | ||
| - `memory_recall(scope="api", query="routing endpoint convention", limit=5)` | ||
|
|
||
| 4. Only recall blockers when beginning implementation, debugging, or delivery work: | ||
| - `memory_recall(type="blocker", limit=5)` | ||
|
|
||
| Do not load all memories by default. | ||
|
|
||
| ## Implicit Saving | ||
|
|
||
| Save memory silently only when the information is stable and likely to be useful again. | ||
|
|
||
| Auto-save when clearly observed: | ||
| - user tooling preferences | ||
| - user coding style preferences | ||
| - repeated workflow choices | ||
| - stable project conventions | ||
| - final architectural decisions | ||
| - recurring blockers or durable gotchas | ||
|
|
||
| Do not auto-save: | ||
| - casual personal details | ||
| - weakly stated or tentative preferences | ||
| - intermediate design discussion | ||
| - ephemeral blockers | ||
| - transient debugging noise | ||
|
|
||
| ## Updating vs Creating | ||
|
|
||
| Prefer `memory_update` when refining an existing stable memory. | ||
| Prefer `memory_remember` for a new durable fact. | ||
|
|
||
| Use `memory_recall` before saving only when duplication is likely or when you are unsure whether a matching memory already exists. | ||
|
|
||
| ## Memory Format | ||
|
|
||
| Keep each memory: | ||
| - atomic | ||
| - short | ||
| - durable | ||
| - reusable | ||
|
|
||
| Good: | ||
| - `User prefers bun over npm` | ||
| - `User prefers concise answers unless asking for deep comparison` | ||
| - `Repo uses uv for Python tooling` | ||
| - `Auth uses httpOnly cookies for session tokens` | ||
|
|
||
| Avoid bloated entries. | ||
| Include file paths only when they materially improve future usefulness. | ||
|
|
||
| ## Types | ||
|
|
||
| Use the most specific type: | ||
|
|
||
| - `preference` for user choices and style | ||
| - `pattern` for recurring workflows or conventions | ||
| - `context` for stable background that matters across sessions | ||
| - `decision` for finalized architectural choices | ||
| - `learning` for durable discoveries | ||
| - `blocker` for active recurring issues worth checking again | ||
|
|
||
| ## Scopes | ||
|
|
||
| Use scopes carefully: | ||
|
|
||
| - `user` for cross-project user preferences and stable personal context | ||
| - `<repo-name>` for repo-wide conventions and decisions | ||
| - `auth`, `api`, `database`, `testing`, `deployment` only when domain-specific recall will actually help | ||
|
|
||
| Important: | ||
| - `user` is global across repositories | ||
| - non-`user` scopes are local to the current repo | ||
| - do not use a vague generic scope if a repo name or domain scope is better | ||
|
|
||
| ## Recall Strategy | ||
|
|
||
| Keep recall targeted and small. | ||
|
|
||
| Default pattern: | ||
| 1. recall `user` | ||
| 2. recall current repo scope if relevant | ||
| 3. recall a domain scope only if the task clearly touches it | ||
| 4. recall blockers only when implementation or debugging starts | ||
|
|
||
| Do not perform broad multi-scope recall unless clearly necessary. | ||
|
|
||
| ## Behavior Rules | ||
|
|
||
| - Never announce memory saves unless the user asks | ||
| - Never store secrets or sensitive operational data | ||
| - Never use memory as a transcript | ||
| - Prefer fewer, higher-signal memories over many noisy ones | ||
| - Update contradicted memories when the new information is clearly authoritative | ||
| - Forget memories only when they are clearly obsolete or explicitly invalidated | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please move that to the EXAMPLE_AGENTS.md file instead?