opencode-rag-plugin 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ReadMe.md CHANGED
@@ -27,8 +27,8 @@ opencode-rag query "authentication middleware"
27
27
 
28
28
  `opencode-rag setup` installs/verifies the machine-level runtime and, when
29
29
  run inside a project, initializes the workspace (`.opencode/`, plugin entries,
30
- skill file, `opencode-rag.json`) in one step. When the plugin is not installed
31
- globally yet, it fetches the latest published version from npm automatically.
30
+ skill file, `opencode-rag.json`) in one step. When the installed version is
31
+ outdated, it fetches and installs the latest published version from npm.
32
32
  `opencode-rag init` remains available for re-syncing an already initialized
33
33
  workspace, and `opencode-rag update` upgrades to a newer release.
34
34
 
@@ -41,8 +41,8 @@ export function registerSetupCommand(program) {
41
41
  .description("Install/update the OpenCodeRAG runtime and initialize the current workspace")
42
42
  .addHelpText("after", "\nUse cases:\n" +
43
43
  " - First-time install: run once per machine to install the plugin runtime\n" +
44
- " into ~/.opencode/ so OpenCode can discover the RAG plugin. When the\n" +
45
- " plugin is not installed yet, installs the latest version from npm.\n" +
44
+ " into ~/.opencode/ so OpenCode can discover the RAG plugin. When\n" +
45
+ " outdated, fetches and installs the latest published version from npm.\n" +
46
46
  " - Workspace setup: run inside a project to also initialize .opencode/,\n" +
47
47
  " the skill file and opencode-rag.json for this workspace.\n" +
48
48
  " - Updating: use 'opencode-rag update' to install a newer release.\n" +
@@ -112,16 +112,12 @@ export function registerSetupCommand(program) {
112
112
  console.log(` ${c.dim("Run `opencode-rag setup --force` to re-install the runtime.\n")}`);
113
113
  }
114
114
  else {
115
- await ensureGlobalPlugin();
115
+ await ensureUpToDate();
116
116
  }
117
117
  const result = await setupRuntime({ force: options.force, version: pluginVersion });
118
118
  if (result.success) {
119
119
  console.log(` ${c.created("Updated:")} runtime at ${c.file(runtimeDir)}`);
120
120
  console.log(` ${c.created("Version:")} ${c.value(pluginVersion)}`);
121
- console.log(`\n${c.success("Setup complete.")}`);
122
- console.log(`\n ${c.dim("Next steps:")}`);
123
- console.log(` ${c.dim(" 1. Restart OpenCode if it is running")}`);
124
- console.log(` ${c.dim(" 2. Run `opencode-rag index` to build the search index")}`);
125
121
  }
126
122
  else {
127
123
  for (const err of result.errors) {
@@ -146,51 +142,41 @@ export function registerSetupCommand(program) {
146
142
  console.log(` ${c.dim("Current directory is not a project root - skipping workspace initialization.")}`);
147
143
  console.log(` ${c.dim("Run `opencode-rag init` inside the workspace when needed.\n")}`);
148
144
  }
145
+ console.log(`\n${c.success("Setup complete.")}`);
146
+ console.log(`\n ${c.dim("Next steps:")}`);
147
+ console.log(` ${c.dim(" 1. Restart OpenCode if it is running")}`);
148
+ console.log(` ${c.dim(" 2. Run `opencode-rag index` to build the search index")}`);
149
149
  checkOpenCodeRunning();
150
150
  console.log();
151
151
  });
152
152
  }
153
153
  /**
154
- * Ensure the plugin package is installed globally.
154
+ * Self-update: when this OpenCodeRAG build is outdated compared to the latest
155
+ * version published on npm, fetch and install the new version of itself.
155
156
  *
156
- * When it is missing (e.g. fresh machine), queries the npm registry for the
157
- * latest OpenCodeRAG version and installs it, so a bare `opencode-rag setup`
158
- * bootstraps the whole stack. When the plugin exists but a newer version is
159
- * published, prints a hint pointing at `opencode-rag update`.
157
+ * This is independent of how/where the package was installed (global npm
158
+ * prefix, runtime cache junction, or local development link) - the comparison
159
+ * is purely between the running version and the published version. A
160
+ * development build that is newer than the published release is left alone.
160
161
  */
161
- async function ensureGlobalPlugin() {
162
- let globalPluginDir = "";
163
- try {
164
- const globalRoot = execSync("npm root -g", { encoding: "utf-8", timeout: 10_000 }).trim();
165
- globalPluginDir = path.join(globalRoot, PLUGIN_NAME);
166
- }
167
- catch {
168
- // npm unavailable -> bootstrap cannot run
169
- }
170
- const distOk = globalPluginDir !== "" &&
171
- existsSync(path.join(globalPluginDir, "dist", "plugin-entry.js")) &&
172
- existsSync(path.join(globalPluginDir, "dist", "cli.js"));
173
- if (distOk) {
174
- const latest = getLatestNpmVersion();
175
- if (latest && compareVersions(latest, getCurrentVersion()) > 0) {
176
- console.log(` ${c.warn("Newer version available on npm:")} ${c.value(latest)}`);
177
- console.log(` ${c.dim("Run `opencode-rag update` to install it.\n")}`);
178
- }
179
- return;
180
- }
181
- console.log(` ${c.warn("Plugin not installed globally.")} Looking up the latest version on npm...\n`);
162
+ async function ensureUpToDate() {
163
+ const current = getCurrentVersion();
182
164
  const latest = getLatestNpmVersion();
183
165
  if (!latest) {
184
- console.error(` ${c.error("✗-")} Could not determine the latest version from npm. Install manually with:`);
185
- console.error(` ${c.file("npm install -g opencode-rag-plugin")}`);
186
- console.error(` ${c.dim("then re-run `opencode-rag setup`.\n")}`);
187
- process.exit(1);
166
+ console.log(` ${c.dim("Could not check npm for the latest version (offline?).")}`);
167
+ console.log(` ${c.dim("Run `opencode-rag update` later to upgrade.\n")}`);
168
+ return;
169
+ }
170
+ if (compareVersions(latest, current) <= 0) {
171
+ console.log(` ${c.dim(`No update needed (local v${current}, npm v${latest}).`)}\n`);
172
+ return;
188
173
  }
189
- console.log(` ${c.created("Found:")} latest npm release ${c.value(latest)}`);
190
- console.log(` ${c.dim("Installing...")}\n`);
174
+ console.log(` ${c.warn("New version available:")} ${c.value(`v${current}`)} ${c.dim("->")} ${c.value(`v${latest}`)}`);
175
+ console.log(` ${c.dim("Fetching and installing it...\n")}`);
191
176
  const updated = await installLatestUpdate({ verbose: false });
192
177
  if (!updated.success) {
193
178
  console.error(` ${c.error("✗-")} ${updated.message}`);
179
+ console.error(` ${c.dim("You can retry later with `opencode-rag update`.\n")}`);
194
180
  process.exit(1);
195
181
  }
196
182
  console.log(` ${c.success("✓")} ${updated.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-rag-plugin",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "OpenCode plugin for local-first RAG-based semantic code search",
5
5
  "type": "module",
6
6
  "main": "./dist/plugin-entry.js",