Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 75462f3412 | |||
| 5d9efea7ab |
21
README.md
21
README.md
@@ -1,30 +1,14 @@
|
||||
# OpenCode
|
||||
|
||||
|
||||
## 📊 项目统计
|
||||
|
||||
- **15 个 CLI 命令** - 涵盖 Git 和 Gitea 操作
|
||||
- **7 个开发领域技能库** - Android、iOS、Go、Electron、MQTT 等
|
||||
- **4 套 CI/CD 工作流模板** - 适配多种项目类型
|
||||
|
||||
## 🌟 核心特性
|
||||
|
||||
- **智能命令系统** - 自动生成提交信息、管理版本标签、安全地暂存文件
|
||||
- **可复用技能** - 预定义的开发工作流,如 Git 工作流、Android 开发等
|
||||
- **安全优先** - 自动过滤敏感文件,防止意外泄露凭证
|
||||
- **中文友好** - 完整的中文支持和交互提示
|
||||
|
||||
## 目录
|
||||
|
||||
```
|
||||
opencode/
|
||||
├── command/ # CLI 命令定义
|
||||
│ ├── git-add.md # 智能暂存文件(自动过滤敏感文件)
|
||||
│ ├── git-commit.md # 自动生成提交信息并提交
|
||||
│ ├── git-pull.md # 拉取远程最新变更
|
||||
│ ├── git-push.md # 提交+创建标签+推送(一键完成)
|
||||
│ ├── git-push-tags.md # 推送所有标签到远程
|
||||
│ ├── git-status.md # 查看仓库状态
|
||||
│ ├── gitea-config.md # 查看 Gitea 配置和 Runner 状态
|
||||
│ ├── gitea-create-repo.md # 在 Gitea 创建新仓库
|
||||
│ ├── gitea-create-runner.md # 创建并启动 Gitea Actions Runner
|
||||
@@ -73,13 +57,8 @@ opencode/
|
||||
│ ├── mqtts-quick-reference.md # 快速参考
|
||||
│ └── USAGE_EXAMPLES.md # 使用示例
|
||||
│
|
||||
├── plugin/ # 插件扩展系统
|
||||
│ └── notification.ts # 通知插件(邮件、Slack、钉钉等)
|
||||
│
|
||||
├── README.md # 项目说明文档(当前文件)
|
||||
├── AGENTS.md # 全局开发规范和指南
|
||||
├── opencode.json # 项目配置文件
|
||||
├── package.json # Node.js 依赖配置
|
||||
└── .gitignore # Git 忽略文件配置
|
||||
```
|
||||
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
---
|
||||
description: Stage changes with automatic filtering of sensitive files
|
||||
---
|
||||
|
||||
Intelligently stage changes while automatically filtering security-sensitive files.
|
||||
|
||||
Please perform the following:
|
||||
|
||||
1. **Detect all unstaged changes:**
|
||||
- Modified files (M)
|
||||
- Deleted files (D)
|
||||
- Untracked files (??) - **重要:第一次就显示并提供选项**
|
||||
|
||||
2. **Filter sensitive files** - Automatically exclude:
|
||||
- `.env*` - Environment files
|
||||
- `*.key`, `*.pem`, `*.p8` - Private keys
|
||||
- `.aws/*`, `.gcloud/*`, `.ssh/*` - Cloud/SSH credentials
|
||||
- `credentials.json`, `secrets.json` - Credential files
|
||||
- `node_modules/`, `vendor/`, `.venv/` - Dependencies
|
||||
- `dist/`, `build/`, `.next/` - Build artifacts
|
||||
- `.DS_Store`, `Thumbs.db` - System files
|
||||
|
||||
3. **Categorize files:**
|
||||
- **已跟踪的修改/删除** (tracked modified/deleted)
|
||||
- **未跟踪的安全文件** (untracked safe files)
|
||||
- **敏感文件** (sensitive files - filtered)
|
||||
|
||||
4. **Display preview in Chinese:**
|
||||
```
|
||||
=== 将要暂存的文件 (N) ===
|
||||
M [tracked modified files]
|
||||
D [tracked deleted files]
|
||||
|
||||
=== 未跟踪的文件 (N) ===
|
||||
?? [untracked safe files]
|
||||
|
||||
=== 敏感文件已过滤 (N) ===
|
||||
⚠ [sensitive files with reasons]
|
||||
|
||||
=== 操作选项 ===
|
||||
- 输入 "y" 或 "yes" 暂存已修改/已删除的文件(不包括未跟踪文件)
|
||||
- 输入 "all" 或 "u" 暂存所有安全文件(包括未跟踪文件)✓ 推荐
|
||||
- 输入 "force" 强制暂存所有文件(包括敏感文件)⚠️ 谨慎使用
|
||||
- 输入 "no" 或 "cancel" 取消操作
|
||||
- 输入文件路径 暂存特定文件
|
||||
```
|
||||
|
||||
5. **Wait for user confirmation**
|
||||
|
||||
6. **Execute staging based on user choice:**
|
||||
- `y/yes`: Stage tracked modified/deleted only
|
||||
- `all/u`: Stage all safe files (including untracked)
|
||||
- `force`: Show warning, require "confirm" input, then stage everything
|
||||
- `no/cancel`: Abort
|
||||
- File path: Stage specific file(s)
|
||||
|
||||
7. **Display result in Chinese:**
|
||||
```
|
||||
✓ 暂存成功
|
||||
|
||||
已暂存 N 个文件:
|
||||
[列出已暂存的文件]
|
||||
|
||||
敏感文件已过滤并排除,保护了你的凭证信息。
|
||||
|
||||
下一步:
|
||||
- 运行 /git-commit 生成提交信息并提交
|
||||
- 运行 /git-status 查看暂存区状态
|
||||
```
|
||||
|
||||
**重要:第一次运行就显示所有选项,包括未跟踪文件的处理方式,不需要用户多次运行命令。**
|
||||
@@ -1,29 +0,0 @@
|
||||
---
|
||||
description: Check git working directory status and file changes
|
||||
---
|
||||
|
||||
Check the current git repository status and display file changes in a clear, organized format.
|
||||
|
||||
Please perform the following tasks:
|
||||
|
||||
1. **Run `git status`** to show the current state of the working tree
|
||||
2. **Display current branch** using `git branch --show-current`
|
||||
3. **List unstaged changes** with `git diff --name-only`
|
||||
4. **List staged changes** with `git diff --cached --name-only`
|
||||
|
||||
Present the information in Chinese with the following structure:
|
||||
|
||||
```
|
||||
当前分支: [branch_name]
|
||||
|
||||
暂存区文件 ([count]):
|
||||
[列出已暂存的文件]
|
||||
|
||||
未暂存的修改 ([count]):
|
||||
[列出未暂存的修改文件]
|
||||
|
||||
未跟踪的文件 ([count]):
|
||||
[列出未跟踪的文件]
|
||||
```
|
||||
|
||||
Use clear formatting and emoji indicators (✓, ⚠️, etc.) to make the output easy to read.
|
||||
@@ -1,5 +1,8 @@
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"mcp": {},
|
||||
"permission": "allow",
|
||||
"plugin": ["@mohak34/opencode-notifier@latest"],
|
||||
"provider": {
|
||||
"opencode": {
|
||||
"models": {
|
||||
@@ -10,19 +13,15 @@
|
||||
"budgetTokens": 16000
|
||||
}
|
||||
}
|
||||
},
|
||||
"claude-sonnet-4-5": {
|
||||
"options": {
|
||||
"thinking": {
|
||||
"type": "enabled",
|
||||
"budgetTokens": 16000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"zhipuai-coding-plan": {
|
||||
"options": {
|
||||
"apiKey": "0f76aea86295476dbfa98724013b0fe8.o2EaJVqcl4Cf7WLP"
|
||||
}
|
||||
}
|
||||
},
|
||||
"mcp": {
|
||||
},
|
||||
"permission": "allow"
|
||||
"model": "zhipuai-coding-plan/glm-4.7",
|
||||
"small_model": "zhipuai-coding-plan/glm-4.7"
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
import type { Plugin } from "@opencode-ai/plugin"
|
||||
|
||||
/**
|
||||
* 通知 Plugin
|
||||
* 在会话完成或发生错误时发送系统通知
|
||||
*/
|
||||
export const NotificationPlugin: Plugin = async ({ project, client, $ }) => {
|
||||
// 检测操作系统
|
||||
const platform = process.platform
|
||||
|
||||
/**
|
||||
* 发送系统通知
|
||||
* @param title 通知标题
|
||||
* @param message 通知内容
|
||||
* @param isError 是否为错误通知
|
||||
*/
|
||||
const sendNotification = async (title: string, message: string, isError: boolean = false) => {
|
||||
try {
|
||||
if (platform === "darwin") {
|
||||
// macOS - 使用 osascript
|
||||
const sound = isError ? ' sound name "Basso"' : ''
|
||||
await $`osascript -e 'display notification "${message}" with title "${title}"${sound}'`
|
||||
} else if (platform === "linux") {
|
||||
// Linux - 使用 notify-send
|
||||
const urgency = isError ? "-u critical" : ""
|
||||
await $`notify-send "${title}" "${message}" ${urgency}`
|
||||
} else if (platform === "win32") {
|
||||
// Windows - 使用 PowerShell
|
||||
const script = `Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('${message}', '${title}')`
|
||||
await $`powershell -Command "& {${script}}"`
|
||||
}
|
||||
|
||||
// 记录日志
|
||||
await client.app.log({
|
||||
service: "notification",
|
||||
level: "info",
|
||||
message: `已发送通知: ${title} - ${message}`,
|
||||
})
|
||||
} catch (error) {
|
||||
// 如果通知发送失败,记录错误但不中断流程
|
||||
await client.app.log({
|
||||
service: "notification",
|
||||
level: "error",
|
||||
message: `发送通知失败: ${error}`,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
event: async ({ event }) => {
|
||||
const projectName = project?.name || "OpenCode"
|
||||
|
||||
// 会话完成时发送通知
|
||||
if (event.type === "session.idle") {
|
||||
await sendNotification(
|
||||
projectName,
|
||||
"会话已完成!",
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
// 会话错误时发送通知
|
||||
if (event.type === "session.error") {
|
||||
await sendNotification(
|
||||
projectName,
|
||||
"会话发生错误!",
|
||||
true
|
||||
)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user