update
This commit is contained in:
58
plugin/README.md
Normal file
58
plugin/README.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# OpenCode TypeScript Plugin 测试说明
|
||||
|
||||
## 概述
|
||||
本示例演示 OpenCode Plugin 可以使用 TypeScript 编写,并且可以直接使用 Bun 运行。
|
||||
|
||||
## 项目结构
|
||||
```
|
||||
plugin/
|
||||
├── package.json # 项目配置
|
||||
├── build.ts # Bun 构建脚本
|
||||
├── src/
|
||||
│ └── index.ts # TypeScript Plugin 源码
|
||||
└── dist/ # 构建输出目录(自动生成)
|
||||
```
|
||||
|
||||
## 安装依赖
|
||||
```bash
|
||||
cd plugin
|
||||
bun install
|
||||
```
|
||||
|
||||
## 直接运行(使用 Bun TypeScript 支持)
|
||||
```bash
|
||||
bun run src/index.ts
|
||||
```
|
||||
|
||||
## 构建
|
||||
```bash
|
||||
bun run build
|
||||
```
|
||||
|
||||
## Plugin 配置
|
||||
在项目的 `opencode.json` 中添加 plugin 引用:
|
||||
|
||||
```json
|
||||
{
|
||||
"plugin": [
|
||||
"./plugin/src/index.ts"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
OpenCode 会自动识别 TypeScript 文件并使用 Bun 运行,无需预先编译。
|
||||
|
||||
## 功能说明
|
||||
这个示例 plugin 定义了一个 `greet` 工具,用于打招呼。
|
||||
|
||||
TypeScript 优势:
|
||||
- 类型安全
|
||||
- 智能提示
|
||||
- 编译时错误检查
|
||||
- 更好的代码维护性
|
||||
|
||||
## 核心特性
|
||||
1. **原生 TypeScript 支持**:OpenCode 可以直接加载和运行 `.ts` 文件
|
||||
2. **Bun 运行时**:使用 Bun 的内置 TypeScript 编译器,无需配置 tsc
|
||||
3. **热重载**:修改源码后自动重新加载
|
||||
4. **零配置**:只需在 `opencode.json` 中指定 `.ts` 文件路径
|
||||
Reference in New Issue
Block a user