Cleanup packaging
This commit is contained in:
83
AGENTS.md
83
AGENTS.md
@@ -1,22 +1,3 @@
|
|||||||
<!-- OPENSPEC:START -->
|
|
||||||
# OpenSpec Instructions
|
|
||||||
|
|
||||||
These instructions are for AI assistants working in this project.
|
|
||||||
|
|
||||||
Always open `@/openspec/AGENTS.md` when the request:
|
|
||||||
- Mentions planning or proposals (words like proposal, spec, change, plan)
|
|
||||||
- Introduces new capabilities, breaking changes, architecture shifts, or big performance/security work
|
|
||||||
- Sounds ambiguous and you need the authoritative spec before coding
|
|
||||||
|
|
||||||
Use `@/openspec/AGENTS.md` to learn:
|
|
||||||
- How to create and apply change proposals
|
|
||||||
- Spec format and conventions
|
|
||||||
- Project structure and guidelines
|
|
||||||
|
|
||||||
Keep this managed block so 'openspec update' can refresh the instructions.
|
|
||||||
|
|
||||||
<!-- OPENSPEC:END -->
|
|
||||||
|
|
||||||
# AGENTS.md - Obsidian OpenCode Plugin
|
# AGENTS.md - Obsidian OpenCode Plugin
|
||||||
|
|
||||||
Guidelines for AI coding agents working on the obsidian-opencode plugin.
|
Guidelines for AI coding agents working on the obsidian-opencode plugin.
|
||||||
@@ -31,19 +12,11 @@ Obsidian plugin that embeds the OpenCode AI assistant via an iframe. Spawns a lo
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
bun install # Install dependencies
|
bun install # Install dependencies
|
||||||
bun run dev # Development (watch mode)
|
|
||||||
bun run build # Production (type-check + bundle)
|
bun run build # Production (type-check + bundle)
|
||||||
```
|
```
|
||||||
|
|
||||||
Output: `main.js` (CommonJS bundle)
|
Output: `main.js` (CommonJS bundle)
|
||||||
|
|
||||||
## Testing & Linting
|
|
||||||
|
|
||||||
**Not configured.** If adding:
|
|
||||||
- Tests: Vitest, files in `src/__tests__/` or `*.test.ts`
|
|
||||||
- Linting: ESLint + `@typescript-eslint/parser`
|
|
||||||
- Scripts: `"test": "vitest run"`, `"lint": "eslint src"`
|
|
||||||
|
|
||||||
## Project Structure
|
## Project Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -55,25 +28,7 @@ src/
|
|||||||
└── SettingsTab.ts # Settings UI (PluginSettingTab)
|
└── SettingsTab.ts # Settings UI (PluginSettingTab)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Code Style
|
## Coding guidelines
|
||||||
|
|
||||||
### Imports
|
|
||||||
- ES modules with named imports
|
|
||||||
- Order: Obsidian API, Node.js builtins, local modules
|
|
||||||
- Use `type` for type-only imports
|
|
||||||
- Relative paths with `./` prefix
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
import { Plugin, WorkspaceLeaf, Notice } from "obsidian";
|
|
||||||
import { spawn, ChildProcess } from "child_process";
|
|
||||||
import type OpenCodePlugin from "./main";
|
|
||||||
import { OpenCodeSettings, DEFAULT_SETTINGS } from "./types";
|
|
||||||
```
|
|
||||||
|
|
||||||
### Exports
|
|
||||||
- `export default class` for main plugin
|
|
||||||
- Named exports for other classes/types/constants
|
|
||||||
- One class per file, filename matches class (PascalCase)
|
|
||||||
|
|
||||||
### Naming Conventions
|
### Naming Conventions
|
||||||
|
|
||||||
@@ -98,23 +53,6 @@ getProcessState(): ProcessState {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Error Handling
|
|
||||||
- try/catch for async operations
|
|
||||||
- `console.error()` for debugging
|
|
||||||
- `new Notice()` for user-facing errors
|
|
||||||
- Boolean returns for success/failure
|
|
||||||
- Silent catch for non-critical ops (health checks)
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
try {
|
|
||||||
await this.processManager.start();
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to start:", error);
|
|
||||||
new Notice(`Failed to start OpenCode: ${error.message}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Obsidian API Patterns
|
### Obsidian API Patterns
|
||||||
- Extend `Plugin` with `onload()`/`onunload()` lifecycle
|
- Extend `Plugin` with `onload()`/`onunload()` lifecycle
|
||||||
- Extend `ItemView` for views: `getViewType()`, `onOpen()`, `onClose()`
|
- Extend `ItemView` for views: `getViewType()`, `onOpen()`, `onClose()`
|
||||||
@@ -152,3 +90,22 @@ Uses Node.js APIs unavailable on mobile:
|
|||||||
- File system via vault adapter
|
- File system via vault adapter
|
||||||
|
|
||||||
Check for desktop environment before adding mobile-incompatible features.
|
Check for desktop environment before adding mobile-incompatible features.
|
||||||
|
|
||||||
|
<!-- OPENSPEC:START -->
|
||||||
|
# OpenSpec Instructions
|
||||||
|
|
||||||
|
These instructions are for AI assistants working in this project.
|
||||||
|
|
||||||
|
Always open `@/openspec/AGENTS.md` when the request:
|
||||||
|
- Mentions planning or proposals (words like proposal, spec, change, plan)
|
||||||
|
- Introduces new capabilities, breaking changes, architecture shifts, or big performance/security work
|
||||||
|
- Sounds ambiguous and you need the authoritative spec before coding
|
||||||
|
|
||||||
|
Use `@/openspec/AGENTS.md` to learn:
|
||||||
|
- How to create and apply change proposals
|
||||||
|
- Spec format and conventions
|
||||||
|
- Project structure and guidelines
|
||||||
|
|
||||||
|
Keep this managed block so 'openspec update' can refresh the instructions.
|
||||||
|
|
||||||
|
<!-- OPENSPEC:END -->
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 Mateusz Tymek
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
40
README.md
40
README.md
@@ -1,17 +1,30 @@
|
|||||||
# Obsidian OpenCode
|
# OpenCode plugin for Obsidian
|
||||||
|
|
||||||
Embed [OpenCode](https://opencode.ai) AI assistant directly in Obsidian's sidebar.
|
|
||||||
|
Give your notes AI capability by embedding Opencode [OpenCode](https://opencode.ai) AI assistant directly in Obsidian:
|
||||||
|
|
||||||
|
<img src="./assets/opencode_in_obsidian.png" alt="OpenCode embeded in Obsidian" />
|
||||||
|
|
||||||
|
**Use cases:**
|
||||||
|
- Summarize and distill long-form content
|
||||||
|
- Draft, edit, and refine your writing
|
||||||
|
- Query and explore your knowledge base
|
||||||
|
- Generate outlines and structured notes
|
||||||
|
|
||||||
|
_Note: plugin author is not afiliated with OpenCode or Obsidian - this is a 3rd party software._
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Desktop only (uses Node.js child processes)
|
- Desktop only (uses Node.js child processes)
|
||||||
- [OpenCode CLI](https://opencode.ai) installed and in your PATH
|
- [OpenCode CLI](https://opencode.ai) installed
|
||||||
|
- [Bun](https://bun.sh) installed
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. Clone to `.obsidian/plugins/obsidian-opencode`
|
1. Clone to `.obsidian/plugins/obsidian-opencode` subdirectory under your vault's root
|
||||||
2. `bun install && bun run build`
|
2. Run `bun install && bun run build`
|
||||||
3. Enable in Obsidian Settings > Community plugins
|
3. Enable in Obsidian Settings > Community plugins
|
||||||
|
4. Add AGENTS.md to the workspace root, use it to explain the structure
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -29,20 +42,5 @@ Embed [OpenCode](https://opencode.ai) AI assistant directly in Obsidian's sideba
|
|||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
|
|
||||||
| Setting | Default | Description |
|
<img src="./assets/plugin_settings.png" alt="Available plugin settings" />
|
||||||
|---------|---------|-------------|
|
|
||||||
| Port | 14096 | Server port |
|
|
||||||
| Hostname | 127.0.0.1 | Bind address |
|
|
||||||
| OpenCode path | opencode | Path to executable |
|
|
||||||
| Auto-start | off | Start server on Obsidian launch |
|
|
||||||
|
|
||||||
## Development
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bun run dev # Watch mode
|
|
||||||
bun run build # Production build
|
|
||||||
```
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
MIT
|
|
||||||
|
|||||||
BIN
assets/opencode_in_obsidian.png
Normal file
BIN
assets/opencode_in_obsidian.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 653 KiB |
BIN
assets/plugin_settings.png
Normal file
BIN
assets/plugin_settings.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 781 KiB |
@@ -5,7 +5,7 @@
|
|||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "node esbuild.config.mjs",
|
"dev": "node esbuild.config.mjs",
|
||||||
"build": "npx tsc -noEmit -skipLibCheck && node esbuild.config.mjs production"
|
"build": "bun run tsc -noEmit -skipLibCheck && bun run esbuild.config.mjs production"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"obsidian",
|
"obsidian",
|
||||||
|
|||||||
Reference in New Issue
Block a user