-
Notifications
You must be signed in to change notification settings - Fork 5
#237: Fixed the opencode plugin in the doc #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| # Unreleased | ||
|
|
||
| ## Bug Fixes | ||
|
|
||
| * #237: Fixed the opencode plugin in the user guide. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,16 +53,40 @@ automatically at the start of every session. | |
|
|
||
| .. code-block:: javascript | ||
|
|
||
| // .opencode/plugins/install-exasol-skills.js | ||
| export default function (ctx) { | ||
| return { | ||
| "session:start": async () => { | ||
| await ctx.shell( | ||
| "exasol-install-skills --target-dir ~/.config/opencode/skills/" | ||
| ); | ||
| }, | ||
| }; | ||
| } | ||
| import { execSync } from "node:child_process"; | ||
| import { createInterface } from "node:readline"; | ||
|
|
||
| const TARGET = `${process.env.HOME}/.config/opencode/skills`; | ||
|
|
||
| const pressAnyKey = () => | ||
| new Promise((resolve) => { | ||
| if (!process.stdin.isTTY) return resolve(); | ||
| const rl = createInterface({ input: process.stdin }); | ||
| rl.once("line", () => { | ||
| rl.close(); | ||
| resolve(); | ||
| }); | ||
| }); | ||
|
|
||
| const installExasolPlugins = async () => { | ||
| console.log("[install-exasol-skills] Installing Exasol skills..."); | ||
| try { | ||
| execSync(`exasol-install-skills --target-dir ${TARGET}`, { | ||
| stdio: "inherit", | ||
| }); | ||
| } catch { | ||
| console.log( | ||
| "[install-exasol-skills] Failed to install skills.", | ||
| ); | ||
|
Comment on lines
+78
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also log stdout & stderr of the executed tool to simplify debugging. |
||
| console.log( | ||
| "[install-exasol-skills] Press any key to continue loading opencode...", | ||
| ); | ||
| await pressAnyKey(); | ||
| } | ||
| return {}; | ||
| }; | ||
|
|
||
| export default installExasolPlugins; | ||
|
|
||
| **Option B — fetch directly from GitHub** (no Python required): | ||
|
|
||
|
|
@@ -72,7 +96,7 @@ can download them with a plain ``fetch`` call — no additional tools needed. | |
|
|
||
| .. code-block:: javascript | ||
|
|
||
| // .opencode/plugins/install-exasol-skills.js | ||
| import { createInterface } from "node:readline"; | ||
| import { mkdirSync, writeFileSync } from "node:fs"; | ||
|
|
||
| const SKILLS = [ | ||
|
|
@@ -89,19 +113,52 @@ can download them with a plain ``fetch`` call — no additional tools needed. | |
| "/exasol/ai/mcp/server/skills"; | ||
| const TARGET = `${process.env.HOME}/.config/opencode/skills`; | ||
|
|
||
| export default function (_ctx) { | ||
| return { | ||
| "session:start": async () => { | ||
| for (const skill of SKILLS) { | ||
| const res = await fetch(`${BASE_URL}/${skill}/SKILL.md`); | ||
| if (res.ok) { | ||
| mkdirSync(`${TARGET}/${skill}`, { recursive: true }); | ||
| writeFileSync(`${TARGET}/${skill}/SKILL.md`, await res.text()); | ||
| } | ||
| const pressAnyKey = () => | ||
| new Promise((resolve) => { | ||
| if (!process.stdin.isTTY) return resolve(); | ||
| const rl = createInterface({ input: process.stdin }); | ||
| rl.once("line", () => { | ||
| rl.close(); | ||
| resolve(); | ||
| }); | ||
| }); | ||
|
|
||
| const downloadSkills = async () => { | ||
| let failed = false; | ||
| console.log("[install-exasol-skills] Installing Exasol skills..."); | ||
| mkdirSync(TARGET, { recursive: true }); | ||
| for (const skill of SKILLS) { | ||
| try { | ||
| const url = `${BASE_URL}/${skill}/SKILL.md`; | ||
| console.log(`[install-exasol-skills] fetching ${skill}...`); | ||
| const res = await fetch(url); | ||
| if (res.ok) { | ||
| const text = await res.text(); | ||
| mkdirSync(`${TARGET}/${skill}`, { recursive: true }); | ||
| writeFileSync(`${TARGET}/${skill}/SKILL.md`, text); | ||
| console.log(`[install-exasol-skills] ✓ ${skill} installed`); | ||
| } else { | ||
| failed = true; | ||
| console.warn(`[install-exasol-skills] ✗ ${skill} skipped (HTTP ${res.status})`); | ||
| } | ||
| }, | ||
| }; | ||
| } | ||
| } catch (err) { | ||
| failed = true; | ||
| console.error(`[install-exasol-skills] ✗ ${skill} failed:`, err); | ||
| } | ||
| } | ||
| if (failed) { | ||
| console.log("[install-exasol-skills] One or more skills failed to install."); | ||
| console.log("[install-exasol-skills] Press any key to continue loading opencode..."); | ||
| await pressAnyKey(); | ||
| } | ||
| }; | ||
|
|
||
| const installExasolPlugins = async () => { | ||
| await downloadSkills(); | ||
| return {}; | ||
| }; | ||
|
|
||
| export default installExasolPlugins; | ||
|
|
||
| To pin to a specific release instead of ``main``, replace ``main`` in ``BASE_URL`` | ||
| with the desired tag, e.g. ``refs/tags/1.9.0``. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General: untested code in documentation. Would it be possible to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it will be better, but it's a bit tricky, especially with the second script that downloads skills from GitHub. The skills might not be there at the time CI runs. It will probably be an overkill. After all, such a script is outside the scope of this project. It's only a kind of advice or suggestion.