Spec review

This commit is contained in:
Mateusz Tymek
2026-01-17 10:46:21 +01:00
parent 4dd9af83c3
commit d9cee8be1a
4 changed files with 103 additions and 54 deletions

View File

@@ -6,11 +6,13 @@ Users working in Obsidian have multiple notes open that provide context for thei
## What Changes
- Add integration with OpenCode SDK (`@opencode-ai/sdk`) to communicate with the server
- Collect currently open note paths from Obsidian's workspace API
- Collect currently selected text from the active editor (if any)
- Create a new OpenCode session when the OpenCode view is first opened (per Obsidian run)
- Preserve and restore the last OpenCode iframe URL when the view is closed/reopened (until Obsidian is restarted)
- Resolve the target session by parsing the `sessionID` from the current iframe URL when context is about to be injected
- Inject open notes and selected text as context into the current OpenCode session using `session.prompt({ noReply: true })`
- Use revert + re-inject pattern to prevent context accumulation (each update replaces previous context)
- Replace previous injected context without using `session.revert()` (update/ignore the previous context part instead)
- Debounce workspace change events to avoid flooding the server
- Add settings to enable/disable the feature (enabled by default) and limit the number of notes included
@@ -18,9 +20,9 @@ Users working in Obsidian have multiple notes open that provide context for thei
- Affected specs: `001-mvp-opencode-embed`
- Affected code:
- `package.json` - new SDK dependency
- `src/types.ts` - new settings fields
- `src/main.ts` - workspace event registration, context injection orchestration
- `src/main.ts` - session tracking, URL persistence, context injection orchestration
- `src/OpenCodeView.ts` - use cached URL when available
- `src/SettingsTab.ts` - new settings UI
- `src/OpenCodeClient.ts` - **new file** for SDK wrapper
- `src/OpenCodeClient.ts` - **new file** for OpenCode HTTP client wrapper
- `src/WorkspaceContext.ts` - **new file** for workspace data collection (open notes + selection)