Remove duplicate OpenCode plugin autoload and move examples
This commit is contained in:
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"dependencies": {
|
|
||||||
"@opencode-ai/plugin": "latest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,10 +5,17 @@
|
|||||||
## Что устанавливается
|
## Что устанавливается
|
||||||
|
|
||||||
- `src/ollama_swap_agent.py` и `src/ollama_swap_common.py`: Python-агент для macOS и Ubuntu.
|
- `src/ollama_swap_agent.py` и `src/ollama_swap_common.py`: Python-агент для macOS и Ubuntu.
|
||||||
- `.opencode/plugins/ollama-swap.js`: клиентский плагин OpenCode.
|
- `examples/opencode/ollama-swap.js`: канонический клиентский плагин OpenCode без зависимостей.
|
||||||
- `.opencode/plugins/ollama-swap.ts`: необязательный TypeScript-плагин с пользовательскими инструментами OpenCode.
|
- `examples/opencode/ollama-swap.ts`: необязательный TypeScript-плагин с пользовательскими инструментами и runtime-guard.
|
||||||
- Агент предоставляет `GET /health`, `GET /status` и `POST /restart`.
|
- Агент предоставляет `GET /health`, `GET /status` и `POST /restart`.
|
||||||
|
|
||||||
|
## Почему раньше дублировались плагины
|
||||||
|
|
||||||
|
OpenCode автоматически загружает все файлы плагинов из `.opencode/plugins/` проекта и из
|
||||||
|
`~/.config/opencode/plugins/`. Если один и тот же файл лежит в обоих местах, он загружается
|
||||||
|
дважды. Поэтому исходники перенесены в `examples/opencode/`, а устанавливается только один
|
||||||
|
глобальный файл.
|
||||||
|
|
||||||
## Установка клиента на текущий macOS
|
## Установка клиента на текущий macOS
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ async function request(control: Control, method: string, pathname: string, body?
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const OllamaSwapPlugin: Plugin = async (ctx) => {
|
export const OllamaSwapPlugin: Plugin = async (ctx) => {
|
||||||
|
const startedKey = Symbol.for("ollamaPlaginSwapStarted")
|
||||||
|
if ((globalThis as any)[startedKey]) {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
(globalThis as any)[startedKey] = true
|
||||||
|
|
||||||
return {
|
return {
|
||||||
event: async ({ event }) => {
|
event: async ({ event }) => {
|
||||||
if (event.type !== "server.connected") return
|
if (event.type !== "server.connected") return
|
||||||
@@ -7,7 +7,7 @@ OPENCODE_PLUGIN_DIR="${HOME}/.config/opencode/plugins"
|
|||||||
CLIENT_CONFIG="${CONFIG_DIR}/clients.json"
|
CLIENT_CONFIG="${CONFIG_DIR}/clients.json"
|
||||||
|
|
||||||
mkdir -p "${CONFIG_DIR}" "${OPENCODE_PLUGIN_DIR}"
|
mkdir -p "${CONFIG_DIR}" "${OPENCODE_PLUGIN_DIR}"
|
||||||
install -m 0755 "${ROOT}/.opencode/plugins/ollama-swap.js" "${OPENCODE_PLUGIN_DIR}/ollama-swap.js"
|
install -m 0755 "${ROOT}/examples/opencode/ollama-swap.js" "${OPENCODE_PLUGIN_DIR}/ollama-swap.js"
|
||||||
|
|
||||||
if [ ! -f "${CLIENT_CONFIG}" ]; then
|
if [ ! -f "${CLIENT_CONFIG}" ]; then
|
||||||
cat > "${CLIENT_CONFIG}" <<'JSON'
|
cat > "${CLIENT_CONFIG}" <<'JSON'
|
||||||
|
|||||||
Reference in New Issue
Block a user