0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00
mastra/integrations/opencode/tsconfig.build.json
Abhi Aiyer cb8c38e6f8
feat(memory, opencode): add @mastra/opencode plugin and standalone observe() API (#12925)
Adds `@mastra/opencode` — a plugin that brings Mastra Observational
Memory into [OpenCode](https://opencode.ai) sessions. Also enhances the
core `observe()` API to support external integrations.

The plugin hooks into OpenCode's lifecycle to automatically observe
conversations, inject compressed observations into the system prompt,
and discard already-observed messages — keeping context lean as
conversations grow.

```ts
// .opencode/mastra.json
{ "model": "google/gemini-2.5-flash", "scope": "thread" }
```

```ts
// Standalone observe() with external messages and lifecycle hooks
await om.observe({
  threadId,
  messages: externalMessages,
  hooks: {
    onObservationStart: () => showToast('Observing...'),
    onObservationEnd: () => showToast('Done!'),
  },
});
```

Core `@mastra/memory` changes: `observe()` now takes object params
(breaking), accepts external messages without double-storing, includes
threshold checks, and exports `OBSERVATION_CONTEXT_PROMPT` /
`OBSERVATION_CONTINUATION_HINT` for reuse by integrations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* OpenCode plugin integration for Observational Memory with session
wiring and status reporting
* Standalone observe() API that accepts external messages and lifecycle
hooks
(onObservationStart/onObservationEnd/onReflectionStart/onReflectionEnd)
* New public observation helpers and prompts for injecting observations
and continuation hints
* Progress/status tools and a memory observations command plus an
example standalone observe script

* **Breaking**
* observe() signature changed to an object parameter: update calls to
use { threadId, resourceId, messages, hooks }

* **Tests**
* Added test suite covering the standalone observe() API and hook
behavior
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Tyler Barnes <tylerdbarnes@gmail.com>
Co-authored-by: Mastra Code <noreply@mastra.ai>
2026-02-11 14:20:05 -08:00

9 lines
215 B