@zenobius/opencode-skillful 1.2.3 → 1.2.4-next.2

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.
Files changed (2) hide show
  1. package/dist/index.js +106 -69
  2. package/package.json +1 -2
package/dist/index.js CHANGED
@@ -16152,6 +16152,7 @@ function createInstructionInjector(ctx) {
16152
16152
  await ctx.client.session.prompt({
16153
16153
  path: { id: props.sessionId },
16154
16154
  body: {
16155
+ agent: props.agent,
16155
16156
  noReply: true,
16156
16157
  parts: [{ type: "text", text }]
16157
16158
  }
@@ -17565,6 +17566,17 @@ var SkillFrontmatterSchema = tool.schema.object({
17565
17566
  "allowed-tools": tool.schema.array(tool.schema.string()).optional(),
17566
17567
  metadata: tool.schema.record(tool.schema.string(), tool.schema.string()).optional()
17567
17568
  });
17569
+ var stripTrailingPathSeparators = (path) => path.replace(/[\\/]+$/, "");
17570
+ var suggestSkillsDirectoryPath = (path) => {
17571
+ const trimmedPath = stripTrailingPathSeparators(path);
17572
+ if (trimmedPath.toLowerCase() === "skill") {
17573
+ return "skills";
17574
+ }
17575
+ if (!/[\\/]skill$/i.test(trimmedPath)) {
17576
+ return null;
17577
+ }
17578
+ return trimmedPath.replace(/skill$/i, () => "skills");
17579
+ };
17568
17580
  function createSkillRegistryController() {
17569
17581
  const store = new Map;
17570
17582
  const controller = {
@@ -17602,6 +17614,19 @@ async function createSkillRegistry(config2, logger) {
17602
17614
  const existingBasePaths = config2.basePaths.filter(doesPathExist);
17603
17615
  if (existingBasePaths.length === 0) {
17604
17616
  logger.warn("[OpencodeSkillful] No valid base paths found for skill discovery:", config2.basePaths);
17617
+ const typoCandidates = config2.basePaths.flatMap((basePath) => {
17618
+ const suggestedPath = suggestSkillsDirectoryPath(basePath);
17619
+ if (!suggestedPath) {
17620
+ return [];
17621
+ }
17622
+ if (doesPathExist(suggestedPath)) {
17623
+ return [`${basePath} -> ${suggestedPath}`];
17624
+ }
17625
+ return [];
17626
+ });
17627
+ if (typoCandidates.length > 0) {
17628
+ logger.warn('[OpencodeSkillful] Detected possible "skill" vs "skills" typo in basePaths:', typoCandidates);
17629
+ }
17605
17630
  controller.ready.setStatus("ready");
17606
17631
  return;
17607
17632
  }
@@ -17881,7 +17906,7 @@ import { join as join2, relative as relative3, resolve as resolve2 } from "path"
17881
17906
  import process2 from "process";
17882
17907
  import { existsSync as existsSync22, mkdirSync, readdirSync, writeFileSync } from "fs";
17883
17908
  import { dirname as dirname4, resolve } from "path";
17884
- import process from "process";
17909
+ import process3 from "process";
17885
17910
  import { Buffer as Buffer2 } from "buffer";
17886
17911
  import { createCipheriv, createDecipheriv, randomBytes } from "crypto";
17887
17912
  import { closeSync, createReadStream, createWriteStream, existsSync as existsSync222, fsyncSync, openSync, writeFileSync as writeFileSync2 } from "fs";
@@ -17891,7 +17916,7 @@ import process5 from "process";
17891
17916
  import { pipeline } from "stream/promises";
17892
17917
  import { createGzip } from "zlib";
17893
17918
  import process4 from "process";
17894
- import process3 from "process";
17919
+ import process32 from "process";
17895
17920
  import { Buffer as Buffer22 } from "buffer";
17896
17921
  import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, randomBytes as randomBytes2 } from "crypto";
17897
17922
  import { closeSync as closeSync2, createReadStream as createReadStream2, createWriteStream as createWriteStream2, existsSync as existsSync4, fsyncSync as fsyncSync2, openSync as openSync2, writeFileSync as writeFileSync4 } from "fs";
@@ -18293,7 +18318,7 @@ async function loadConfig({
18293
18318
  cwd,
18294
18319
  defaultConfig
18295
18320
  }) {
18296
- const baseDir = cwd || process.cwd();
18321
+ const baseDir = cwd || process3.cwd();
18297
18322
  const extensions = [".ts", ".js", ".mjs", ".cjs", ".json"];
18298
18323
  const configPaths = [
18299
18324
  `${name}.config`,
@@ -18324,8 +18349,8 @@ async function loadConfig({
18324
18349
  } catch {}
18325
18350
  return defaultConfig;
18326
18351
  }
18327
- var defaultConfigDir = resolve(process.cwd(), "config");
18328
- var defaultGeneratedDir = resolve(process.cwd(), "src/generated");
18352
+ var defaultConfigDir = resolve(process3.cwd(), "config");
18353
+ var defaultGeneratedDir = resolve(process3.cwd(), "src/generated");
18329
18354
  function getProjectRoot(filePath, options2 = {}) {
18330
18355
  let path3 = process2.cwd();
18331
18356
  while (path3.includes("storage"))
@@ -18374,24 +18399,24 @@ async function loadConfig2() {
18374
18399
  }
18375
18400
  var config2 = await loadConfig2();
18376
18401
  function isBrowserProcess() {
18377
- if (process3.env.NODE_ENV === "test" || process3.env.BUN_ENV === "test") {
18402
+ if (process32.env.NODE_ENV === "test" || process32.env.BUN_ENV === "test") {
18378
18403
  return false;
18379
18404
  }
18380
18405
  return typeof window !== "undefined";
18381
18406
  }
18382
18407
  async function isServerProcess() {
18383
- if (process3.env.NODE_ENV === "test" || process3.env.BUN_ENV === "test") {
18408
+ if (process32.env.NODE_ENV === "test" || process32.env.BUN_ENV === "test") {
18384
18409
  return true;
18385
18410
  }
18386
18411
  if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
18387
18412
  return true;
18388
18413
  }
18389
- if (typeof process3 !== "undefined") {
18390
- const type = process3.type;
18414
+ if (typeof process32 !== "undefined") {
18415
+ const type = process32.type;
18391
18416
  if (type === "renderer" || type === "worker") {
18392
18417
  return false;
18393
18418
  }
18394
- return !!(process3.versions && (process3.versions.node || process3.versions.bun));
18419
+ return !!(process32.versions && (process32.versions.node || process32.versions.bun));
18395
18420
  }
18396
18421
  return false;
18397
18422
  }
@@ -22917,79 +22942,89 @@ var defaultConfigDir3 = resolve7(process12.cwd(), "config");
22917
22942
  var defaultGeneratedDir3 = resolve7(process12.cwd(), "src/generated");
22918
22943
 
22919
22944
  // src/config.ts
22920
- import { join as join4 } from "path";
22921
-
22922
- // node_modules/env-paths/index.js
22923
- import path3 from "path";
22924
- import os from "os";
22925
- import process13 from "process";
22926
- var homedir3 = os.homedir();
22927
- var tmpdir = os.tmpdir();
22928
- var { env } = process13;
22929
- var macos = (name) => {
22930
- const library = path3.join(homedir3, "Library");
22931
- return {
22932
- data: path3.join(library, "Application Support", name),
22933
- config: path3.join(library, "Preferences", name),
22934
- cache: path3.join(library, "Caches", name),
22935
- log: path3.join(library, "Logs", name),
22936
- temp: path3.join(tmpdir, name)
22937
- };
22938
- };
22939
- var windows = (name) => {
22940
- const appData = env.APPDATA || path3.join(homedir3, "AppData", "Roaming");
22941
- const localAppData = env.LOCALAPPDATA || path3.join(homedir3, "AppData", "Local");
22942
- return {
22943
- data: path3.join(localAppData, name, "Data"),
22944
- config: path3.join(appData, name, "Config"),
22945
- cache: path3.join(localAppData, name, "Cache"),
22946
- log: path3.join(localAppData, name, "Log"),
22947
- temp: path3.join(tmpdir, name)
22948
- };
22949
- };
22950
- var linux = (name) => {
22951
- const username = path3.basename(homedir3);
22952
- return {
22953
- data: path3.join(env.XDG_DATA_HOME || path3.join(homedir3, ".local", "share"), name),
22954
- config: path3.join(env.XDG_CONFIG_HOME || path3.join(homedir3, ".config"), name),
22955
- cache: path3.join(env.XDG_CACHE_HOME || path3.join(homedir3, ".cache"), name),
22956
- log: path3.join(env.XDG_STATE_HOME || path3.join(homedir3, ".local", "state"), name),
22957
- temp: path3.join(tmpdir, username, name)
22958
- };
22959
- };
22960
- function envPaths(name, { suffix = "nodejs" } = {}) {
22961
- if (typeof name !== "string") {
22962
- throw new TypeError(`Expected a string, got ${typeof name}`);
22945
+ import { homedir as homedir3 } from "os";
22946
+ import { isAbsolute as isAbsolute2, join as join4, normalize, resolve as resolve8 } from "path";
22947
+ function getOpenCodeConfigPaths() {
22948
+ const home = homedir3();
22949
+ const paths = [];
22950
+ const xdgConfig = process.env.XDG_CONFIG_HOME;
22951
+ if (xdgConfig) {
22952
+ paths.push(join4(xdgConfig, "opencode"));
22953
+ }
22954
+ if (process.platform === "win32") {
22955
+ const localAppData = process.env.LOCALAPPDATA;
22956
+ if (localAppData) {
22957
+ paths.push(join4(localAppData, "opencode"));
22958
+ }
22959
+ paths.push(join4(home, ".config", "opencode"));
22960
+ } else {
22961
+ paths.push(join4(home, ".config", "opencode"));
22963
22962
  }
22964
- if (suffix) {
22965
- name += `-${suffix}`;
22963
+ paths.push(join4(home, ".opencode"));
22964
+ return paths;
22965
+ }
22966
+ function expandTildePath(path3) {
22967
+ if (path3 === "~") {
22968
+ return homedir3();
22966
22969
  }
22967
- if (process13.platform === "darwin") {
22968
- return macos(name);
22970
+ if (path3.startsWith("~/")) {
22971
+ return join4(homedir3(), path3.slice(2));
22969
22972
  }
22970
- if (process13.platform === "win32") {
22971
- return windows(name);
22973
+ return path3;
22974
+ }
22975
+ var createPathKey = (absolutePath) => {
22976
+ const normalizedPath = normalize(absolutePath);
22977
+ if (process.platform === "win32") {
22978
+ return normalizedPath.toLowerCase();
22972
22979
  }
22973
- return linux(name);
22980
+ return normalizedPath;
22981
+ };
22982
+ function resolveBasePath(basePath, projectDirectory) {
22983
+ const trimmedPath = basePath.trim();
22984
+ if (trimmedPath.length === 0) {
22985
+ return "";
22986
+ }
22987
+ const expandedPath = expandTildePath(trimmedPath);
22988
+ if (isAbsolute2(expandedPath)) {
22989
+ return normalize(expandedPath);
22990
+ }
22991
+ return resolve8(projectDirectory, expandedPath);
22974
22992
  }
22975
-
22976
- // src/config.ts
22977
- var OpenCodePaths = envPaths("opencode", { suffix: "" });
22993
+ function normalizeBasePaths(basePaths, projectDirectory) {
22994
+ const uniquePaths = new Set;
22995
+ const normalizedPaths = [];
22996
+ for (const basePath of basePaths) {
22997
+ const normalizedPath = resolveBasePath(basePath, projectDirectory);
22998
+ if (!normalizedPath) {
22999
+ continue;
23000
+ }
23001
+ const key = createPathKey(normalizedPath);
23002
+ if (uniquePaths.has(key)) {
23003
+ continue;
23004
+ }
23005
+ uniquePaths.add(key);
23006
+ normalizedPaths.push(normalizedPath);
23007
+ }
23008
+ return normalizedPaths;
23009
+ }
23010
+ var defaultSkillBasePaths = getOpenCodeConfigPaths().map((configPath) => join4(configPath, "skills"));
22978
23011
  var options2 = {
22979
23012
  name: "opencode-skillful",
22980
23013
  cwd: "./",
22981
23014
  defaultConfig: {
22982
23015
  debug: false,
22983
- basePaths: [
22984
- join4(OpenCodePaths.config, "skills")
22985
- ],
23016
+ basePaths: defaultSkillBasePaths,
22986
23017
  promptRenderer: "xml",
22987
23018
  modelRenderers: {}
22988
23019
  }
22989
23020
  };
22990
23021
  async function getPluginConfig(ctx) {
22991
23022
  const resolvedConfig = await loadConfig5(options2);
22992
- resolvedConfig.basePaths.push(join4(ctx.directory, ".opencode", "skills"));
23023
+ const configuredBasePaths = [
23024
+ ...resolvedConfig.basePaths,
23025
+ join4(ctx.directory, ".opencode", "skills")
23026
+ ];
23027
+ resolvedConfig.basePaths = normalizeBasePaths(configuredBasePaths, ctx.directory);
22993
23028
  return resolvedConfig;
22994
23029
  }
22995
23030
 
@@ -23452,7 +23487,8 @@ var SkillsPlugin = async (ctx) => {
23452
23487
  const results = await api2.loadSkill(args.skill_names);
23453
23488
  for await (const skill of results.loaded) {
23454
23489
  await sendPrompt(renderer({ data: skill, type: "Skill" }), {
23455
- sessionId: toolCtx.sessionID
23490
+ sessionId: toolCtx.sessionID,
23491
+ agent: toolCtx.agent
23456
23492
  });
23457
23493
  }
23458
23494
  return JSON.stringify({
@@ -23502,7 +23538,8 @@ var SkillsPlugin = async (ctx) => {
23502
23538
  throw new Error("Failed to read resource");
23503
23539
  }
23504
23540
  await sendPrompt(renderer({ data: result.injection, type: "SkillResource" }), {
23505
- sessionId: toolCtx.sessionID
23541
+ sessionId: toolCtx.sessionID,
23542
+ agent: toolCtx.agent
23506
23543
  });
23507
23544
  return JSON.stringify({
23508
23545
  result: "Resource injected successfully",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenobius/opencode-skillful",
3
- "version": "1.2.3",
3
+ "version": "1.2.4-next.2",
4
4
  "description": "OpenCode Skills Plugin - Anthropic Agent Skills Specification implementation",
5
5
  "type": "module",
6
6
  "module": "src/index.ts",
@@ -22,7 +22,6 @@
22
22
  "@opencode-ai/plugin": "1.0.85",
23
23
  "bunfig": "^0.15.6",
24
24
  "dedent": "^1.7.1",
25
- "env-paths": "^3.0.0",
26
25
  "gray-matter": "^4.0.3",
27
26
  "mime": "^4.1.0",
28
27
  "ramda": "^0.30.0",