Skip to content

Commit bb2dfa1

Browse files
committed
fix: revert auto-update command that caused launch delays
Reverts command file version tracking feature that was causing OpenCode to hang indefinitely on launch.
1 parent ba7e7f7 commit bb2dfa1

File tree

5 files changed

+20
-49
lines changed

5 files changed

+20
-49
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.5.1] - 2026-01-08
9+
10+
### Fixed
11+
- **Reverted auto-update**: Removed command file version tracking that caused OpenCode launch delays
12+
813
## [0.5.0] - 2026-01-08
914

1015
### Added
1116
- **Observability**: Dedicated log file at `~/.local/share/opencode/toolbox.log`
1217
- **Status Tool**: New `toolbox_status` tool for checking plugin and server health
1318
- **Slash Command**: Auto-creates `/toolbox-status` command on first launch
14-
- **Auto-Update Command**: Slash command file auto-updates when plugin version changes
1519
- **Health Metrics**: Track search count, execution count, and success rate
1620
- **Server Connection Tracking**: Log MCP server initialization and connection status
1721
- **Error Logging**: Detailed error messages for failed operations
1822
- **Status Indicators**: Connection ratio (e.g., "2/3") to highlight failures
1923
- **Tests**: Comprehensive test suite for `toolbox_status` tool (9 new tests)
2024

2125
### Changed
22-
- Version now imported from package.json (single source of truth)
2326
- Updated README with observability section and logging documentation
2427
- Added troubleshooting guidance using `toolbox_status` and logs
2528
- Silent logging (no screen output) to prevent UI flickering

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,12 @@ Returns a comprehensive status object:
207207

208208
### /toolbox-status Slash Command
209209

210-
The plugin automatically creates and maintains a `/toolbox-status` slash command:
210+
The plugin automatically creates a `/toolbox-status` slash command on first launch:
211211

212212
```
213213
~/.config/opencode/command/toolbox-status.md
214214
```
215215

216-
- **Auto-created** on first plugin launch
217-
- **Auto-updated** when plugin version changes (tracked via `toolbox_version` in frontmatter)
218-
219216
Use it in OpenCode by typing `/toolbox-status` to get a formatted status report.
220217

221218
## Search Modes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opencode-toolbox",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"description": "Tool Search Tool Plugin for OpenCode - search and execute tools from MCP servers on-demand",
55
"main": "dist/index.js",
66
"module": "dist/index.js",

src/plugin.ts

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import type { Plugin, PluginInput } from "@opencode-ai/plugin";
22
import { tool } from "@opencode-ai/plugin";
3-
import { appendFile, mkdir, writeFile, readFile } from "fs/promises";
3+
import { appendFile, mkdir, writeFile, access } from "fs/promises";
44
import { loadConfig } from "./config";
55
import { MCPManager } from "./mcp-client";
66
import { BM25Index, searchWithRegex, MAX_REGEX_LENGTH } from "./search";
77
import type { CatalogTool, SearchResult } from "./catalog";
8-
import pkg from "../package.json";
9-
10-
// Plugin version from package.json
11-
const PLUGIN_VERSION = pkg.version;
128

139
const DEFAULT_CONFIG_PATH = `${process.env.HOME}/.config/opencode/toolbox.jsonc`;
1410
const LOG_FILE_PATH = `${process.env.HOME}/.local/share/opencode/toolbox.log`;
@@ -17,19 +13,12 @@ const LOG_DIR = `${process.env.HOME}/.local/share/opencode`;
1713
// Slash command paths
1814
const COMMAND_DIR = `${process.env.HOME}/.config/opencode/command`;
1915
const COMMAND_FILE_PATH = `${COMMAND_DIR}/toolbox-status.md`;
20-
21-
/**
22-
* Generate command file content with version in frontmatter
23-
*/
24-
function getCommandContent(): string {
25-
return `---
16+
const COMMAND_CONTENT = `---
2617
description: Check toolbox plugin status and server health
27-
toolbox_version: ${PLUGIN_VERSION}
2818
---
29-
Run toolbox_status({}) and show me the results in a readable format.
19+
Run toolbox_status({}) tool and show me the results in a readable format.
3020
Highlight any failed servers or issues.
3121
`;
32-
}
3322

3423
/**
3524
* Parse tool name into server and original tool name
@@ -115,36 +104,19 @@ function log(level: string, message: string, extra?: any) {
115104
}
116105

117106
/**
118-
* Create or update /toolbox-status slash command
119-
* Updates when plugin version changes
107+
* Create /toolbox-status slash command if it doesn't exist
120108
* Non-blocking, fire and forget
121109
*/
122110
function ensureCommandFile() {
123-
const content = getCommandContent();
124-
125-
readFile(COMMAND_FILE_PATH, "utf-8")
126-
.then((existing) => {
127-
// Check if version matches
128-
const versionMatch = existing.match(/toolbox_version:\s*([^\n]+)/);
129-
const existingVersion = versionMatch?.[1]?.trim() ?? null;
130-
131-
if (existingVersion !== PLUGIN_VERSION) {
132-
// Version changed, update file
133-
return writeFile(COMMAND_FILE_PATH, content).then(() => {
134-
log("info", `Updated /toolbox-status command (${existingVersion} -> ${PLUGIN_VERSION})`);
135-
});
136-
}
137-
// Version matches, no update needed
138-
})
139-
.catch(() => {
140-
// File doesn't exist, create it
141-
mkdir(COMMAND_DIR, { recursive: true })
142-
.then(() => writeFile(COMMAND_FILE_PATH, content))
143-
.then(() => log("info", `Created /toolbox-status command (v${PLUGIN_VERSION})`))
144-
.catch(() => {
145-
// Ignore errors - non-critical
146-
});
147-
});
111+
access(COMMAND_FILE_PATH).catch(() => {
112+
// File doesn't exist, create it
113+
mkdir(COMMAND_DIR, { recursive: true })
114+
.then(() => writeFile(COMMAND_FILE_PATH, COMMAND_CONTENT))
115+
.then(() => log("info", "Created /toolbox-status command file"))
116+
.catch(() => {
117+
// Ignore errors - non-critical
118+
});
119+
});
148120
}
149121

150122
/**

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"moduleResolution": "bundler",
1313
"allowImportingTsExtensions": true,
1414
"verbatimModuleSyntax": true,
15-
"resolveJsonModule": true,
1615
"noEmit": true,
1716

1817
// Best practices

0 commit comments

Comments
 (0)