@zenobius/opencode-skillful 1.2.1 → 1.2.2-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 +287 -100
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -17763,9 +17763,10 @@ function createSkillFinder(provider) {
17763
17763
  }
17764
17764
 
17765
17765
  // src/tools/SkillResourceReader.ts
17766
- import path from "path";
17766
+ import path2 from "path";
17767
17767
 
17768
17768
  // src/services/SkillResourceResolver.ts
17769
+ import path from "path";
17769
17770
  function createSkillResourceResolver(provider) {
17770
17771
  const resolveResourceMap = (skill, type) => {
17771
17772
  if (type === "script" || type === "scripts") {
@@ -17787,7 +17788,7 @@ function createSkillResourceResolver(provider) {
17787
17788
  if (!resourceMap) {
17788
17789
  throw new Error(`Skill "${args.skill_name}" does not have any resources of type "${args.type}"`);
17789
17790
  }
17790
- const resourceEntry = resourceMap.get(args.relative_path);
17791
+ const resourceEntry = resourceMap.get(path.join(args.type, args.relative_path));
17791
17792
  if (!resourceEntry) {
17792
17793
  throw new Error(`Resource not found: Skill "${args.skill_name}" does not have a ${args.type} at path "${args.relative_path}"`);
17793
17794
  }
@@ -17813,7 +17814,7 @@ function createSkillResourceReader(provider) {
17813
17814
  const resource = await skillResourceResolver({
17814
17815
  skill_name: args.skill_name,
17815
17816
  type,
17816
- relative_path: path.join(...restPath)
17817
+ relative_path: path2.join(...restPath)
17817
17818
  });
17818
17819
  const injection = {
17819
17820
  skill_name: args.skill_name,
@@ -18326,10 +18327,10 @@ async function loadConfig({
18326
18327
  var defaultConfigDir = resolve(process.cwd(), "config");
18327
18328
  var defaultGeneratedDir = resolve(process.cwd(), "src/generated");
18328
18329
  function getProjectRoot(filePath, options2 = {}) {
18329
- let path2 = process2.cwd();
18330
- while (path2.includes("storage"))
18331
- path2 = resolve2(path2, "..");
18332
- const finalPath = resolve2(path2, filePath || "");
18330
+ let path3 = process2.cwd();
18331
+ while (path3.includes("storage"))
18332
+ path3 = resolve2(path3, "..");
18333
+ const finalPath = resolve2(path3, filePath || "");
18333
18334
  if (options2?.relative)
18334
18335
  return relative3(process2.cwd(), finalPath);
18335
18336
  return finalPath;
@@ -19776,10 +19777,10 @@ function applyEnvVarsToConfig(name, config3, verbose = false) {
19776
19777
  return config3;
19777
19778
  const envPrefix = name.toUpperCase().replace(/-/g, "_");
19778
19779
  const result = { ...config3 };
19779
- function processObject(obj, path2 = []) {
19780
+ function processObject(obj, path3 = []) {
19780
19781
  const result2 = { ...obj };
19781
19782
  for (const [key, value] of Object.entries(obj)) {
19782
- const envPath = [...path2, key];
19783
+ const envPath = [...path3, key];
19783
19784
  const formatKey = (k) => k.replace(/([A-Z])/g, "_$1").toUpperCase();
19784
19785
  const envKey = `${envPrefix}_${envPath.map(formatKey).join("_")}`;
19785
19786
  const oldEnvKey = `${envPrefix}_${envPath.map((p) => p.toUpperCase()).join("_")}`;
@@ -19961,10 +19962,10 @@ async function loadConfig3({
19961
19962
  var defaultConfigDir2 = resolve3(process6.cwd(), "config");
19962
19963
  var defaultGeneratedDir2 = resolve3(process6.cwd(), "src/generated");
19963
19964
  function getProjectRoot2(filePath, options2 = {}) {
19964
- let path2 = process7.cwd();
19965
- while (path2.includes("storage"))
19966
- path2 = resolve4(path2, "..");
19967
- const finalPath = resolve4(path2, filePath || "");
19965
+ let path3 = process7.cwd();
19966
+ while (path3.includes("storage"))
19967
+ path3 = resolve4(path3, "..");
19968
+ const finalPath = resolve4(path3, filePath || "");
19968
19969
  if (options2?.relative)
19969
19970
  return relative2(process7.cwd(), finalPath);
19970
19971
  return finalPath;
@@ -21401,10 +21402,10 @@ class EnvVarError extends BunfigError {
21401
21402
 
21402
21403
  class FileSystemError extends BunfigError {
21403
21404
  code = "FILE_SYSTEM_ERROR";
21404
- constructor(operation, path2, cause) {
21405
- super(`File system ${operation} failed for "${path2}": ${cause.message}`, {
21405
+ constructor(operation, path3, cause) {
21406
+ super(`File system ${operation} failed for "${path3}": ${cause.message}`, {
21406
21407
  operation,
21407
- path: path2,
21408
+ path: path3,
21408
21409
  originalError: cause.name,
21409
21410
  originalMessage: cause.message
21410
21411
  });
@@ -21477,8 +21478,8 @@ var ErrorFactory = {
21477
21478
  envVar(envKey, envValue, expectedType, configName) {
21478
21479
  return new EnvVarError(envKey, envValue, expectedType, configName);
21479
21480
  },
21480
- fileSystem(operation, path2, cause) {
21481
- return new FileSystemError(operation, path2, cause);
21481
+ fileSystem(operation, path3, cause) {
21482
+ return new FileSystemError(operation, path3, cause);
21482
21483
  },
21483
21484
  typeGeneration(configDir, outputPath, cause) {
21484
21485
  return new TypeGenerationError(configDir, outputPath, cause);
@@ -21614,9 +21615,9 @@ class EnvProcessor {
21614
21615
  }
21615
21616
  return key.replace(/([A-Z])/g, "_$1").toUpperCase();
21616
21617
  }
21617
- processObject(obj, path2, envPrefix, options2) {
21618
+ processObject(obj, path3, envPrefix, options2) {
21618
21619
  for (const [key, value] of Object.entries(obj)) {
21619
- const envPath = [...path2, key];
21620
+ const envPath = [...path3, key];
21620
21621
  const formattedKeys = envPath.map((k) => this.formatEnvKey(k, options2.useCamelCase));
21621
21622
  const envKey = `${envPrefix}_${formattedKeys.join("_")}`;
21622
21623
  const oldEnvKey = options2.useBackwardCompatibility ? `${envPrefix}_${envPath.map((p) => p.toUpperCase()).join("_")}` : null;
@@ -21701,9 +21702,9 @@ class EnvProcessor {
21701
21702
  return this.formatAsText(envVars, configName);
21702
21703
  }
21703
21704
  }
21704
- extractEnvVarInfo(obj, path2, prefix, envVars) {
21705
+ extractEnvVarInfo(obj, path3, prefix, envVars) {
21705
21706
  for (const [key, value] of Object.entries(obj)) {
21706
- const envPath = [...path2, key];
21707
+ const envPath = [...path3, key];
21707
21708
  const envKey = `${prefix}_${envPath.map((k) => this.formatEnvKey(k, true)).join("_")}`;
21708
21709
  if (typeof value === "object" && value !== null && !Array.isArray(value)) {
21709
21710
  this.extractEnvVarInfo(value, envPath, prefix, envVars);
@@ -22118,15 +22119,15 @@ class ConfigFileLoader {
22118
22119
  }
22119
22120
  async preloadConfigurations(configPaths, options2 = {}) {
22120
22121
  const preloaded = new Map;
22121
- await Promise.allSettled(configPaths.map(async (path2) => {
22122
+ await Promise.allSettled(configPaths.map(async (path3) => {
22122
22123
  try {
22123
- const result = await this.loadFromPath(path2, {}, options2);
22124
+ const result = await this.loadFromPath(path3, {}, options2);
22124
22125
  if (result) {
22125
- preloaded.set(path2, result.config);
22126
+ preloaded.set(path3, result.config);
22126
22127
  }
22127
22128
  } catch (error45) {
22128
22129
  if (options2.verbose) {
22129
- console.warn(`Failed to preload ${path2}:`, error45);
22130
+ console.warn(`Failed to preload ${path3}:`, error45);
22130
22131
  }
22131
22132
  }
22132
22133
  }));
@@ -22205,13 +22206,13 @@ class ConfigValidator {
22205
22206
  warnings
22206
22207
  };
22207
22208
  }
22208
- validateObjectAgainstSchema(value, schema, path2, errors3, warnings, options2) {
22209
+ validateObjectAgainstSchema(value, schema, path3, errors3, warnings, options2) {
22209
22210
  if (options2.validateTypes && schema.type) {
22210
22211
  const actualType = Array.isArray(value) ? "array" : typeof value;
22211
22212
  const expectedTypes = Array.isArray(schema.type) ? schema.type : [schema.type];
22212
22213
  if (!expectedTypes.includes(actualType)) {
22213
22214
  errors3.push({
22214
- path: path2,
22215
+ path: path3,
22215
22216
  message: `Expected type ${expectedTypes.join(" or ")}, got ${actualType}`,
22216
22217
  expected: expectedTypes.join(" or "),
22217
22218
  actual: actualType,
@@ -22223,7 +22224,7 @@ class ConfigValidator {
22223
22224
  }
22224
22225
  if (schema.enum && !schema.enum.includes(value)) {
22225
22226
  errors3.push({
22226
- path: path2,
22227
+ path: path3,
22227
22228
  message: `Value must be one of: ${schema.enum.join(", ")}`,
22228
22229
  expected: schema.enum.join(", "),
22229
22230
  actual: value,
@@ -22235,7 +22236,7 @@ class ConfigValidator {
22235
22236
  if (typeof value === "string") {
22236
22237
  if (schema.minLength !== undefined && value.length < schema.minLength) {
22237
22238
  errors3.push({
22238
- path: path2,
22239
+ path: path3,
22239
22240
  message: `String length must be at least ${schema.minLength}`,
22240
22241
  expected: `>= ${schema.minLength}`,
22241
22242
  actual: value.length,
@@ -22244,7 +22245,7 @@ class ConfigValidator {
22244
22245
  }
22245
22246
  if (schema.maxLength !== undefined && value.length > schema.maxLength) {
22246
22247
  errors3.push({
22247
- path: path2,
22248
+ path: path3,
22248
22249
  message: `String length must not exceed ${schema.maxLength}`,
22249
22250
  expected: `<= ${schema.maxLength}`,
22250
22251
  actual: value.length,
@@ -22255,7 +22256,7 @@ class ConfigValidator {
22255
22256
  const regex = new RegExp(schema.pattern);
22256
22257
  if (!regex.test(value)) {
22257
22258
  errors3.push({
22258
- path: path2,
22259
+ path: path3,
22259
22260
  message: `String does not match pattern ${schema.pattern}`,
22260
22261
  expected: schema.pattern,
22261
22262
  actual: value,
@@ -22267,7 +22268,7 @@ class ConfigValidator {
22267
22268
  if (typeof value === "number") {
22268
22269
  if (schema.minimum !== undefined && value < schema.minimum) {
22269
22270
  errors3.push({
22270
- path: path2,
22271
+ path: path3,
22271
22272
  message: `Value must be at least ${schema.minimum}`,
22272
22273
  expected: `>= ${schema.minimum}`,
22273
22274
  actual: value,
@@ -22276,7 +22277,7 @@ class ConfigValidator {
22276
22277
  }
22277
22278
  if (schema.maximum !== undefined && value > schema.maximum) {
22278
22279
  errors3.push({
22279
- path: path2,
22280
+ path: path3,
22280
22281
  message: `Value must not exceed ${schema.maximum}`,
22281
22282
  expected: `<= ${schema.maximum}`,
22282
22283
  actual: value,
@@ -22286,7 +22287,7 @@ class ConfigValidator {
22286
22287
  }
22287
22288
  if (Array.isArray(value) && schema.items) {
22288
22289
  for (let i = 0;i < value.length; i++) {
22289
- const itemPath = path2 ? `${path2}[${i}]` : `[${i}]`;
22290
+ const itemPath = path3 ? `${path3}[${i}]` : `[${i}]`;
22290
22291
  this.validateObjectAgainstSchema(value[i], schema.items, itemPath, errors3, warnings, options2);
22291
22292
  if (options2.stopOnFirstError && errors3.length > 0)
22292
22293
  return;
@@ -22298,7 +22299,7 @@ class ConfigValidator {
22298
22299
  for (const requiredProp of schema.required) {
22299
22300
  if (!(requiredProp in obj)) {
22300
22301
  errors3.push({
22301
- path: path2 ? `${path2}.${requiredProp}` : requiredProp,
22302
+ path: path3 ? `${path3}.${requiredProp}` : requiredProp,
22302
22303
  message: `Missing required property '${requiredProp}'`,
22303
22304
  expected: "required",
22304
22305
  rule: "required"
@@ -22311,7 +22312,7 @@ class ConfigValidator {
22311
22312
  if (schema.properties) {
22312
22313
  for (const [propName, propSchema] of Object.entries(schema.properties)) {
22313
22314
  if (propName in obj) {
22314
- const propPath = path2 ? `${path2}.${propName}` : propName;
22315
+ const propPath = path3 ? `${path3}.${propName}` : propName;
22315
22316
  this.validateObjectAgainstSchema(obj[propName], propSchema, propPath, errors3, warnings, options2);
22316
22317
  if (options2.stopOnFirstError && errors3.length > 0)
22317
22318
  return;
@@ -22323,7 +22324,7 @@ class ConfigValidator {
22323
22324
  for (const propName of Object.keys(obj)) {
22324
22325
  if (!allowedProps.has(propName)) {
22325
22326
  warnings.push({
22326
- path: path2 ? `${path2}.${propName}` : propName,
22327
+ path: path3 ? `${path3}.${propName}` : propName,
22327
22328
  message: `Additional property '${propName}' is not allowed`,
22328
22329
  rule: "additionalProperties"
22329
22330
  });
@@ -22357,12 +22358,12 @@ class ConfigValidator {
22357
22358
  warnings
22358
22359
  };
22359
22360
  }
22360
- validateWithRule(value, rule, path2) {
22361
+ validateWithRule(value, rule, path3) {
22361
22362
  const errors3 = [];
22362
22363
  if (rule.required && (value === undefined || value === null)) {
22363
22364
  errors3.push({
22364
- path: path2,
22365
- message: rule.message || `Property '${path2}' is required`,
22365
+ path: path3,
22366
+ message: rule.message || `Property '${path3}' is required`,
22366
22367
  expected: "required",
22367
22368
  rule: "required"
22368
22369
  });
@@ -22375,7 +22376,7 @@ class ConfigValidator {
22375
22376
  const actualType = Array.isArray(value) ? "array" : typeof value;
22376
22377
  if (actualType !== rule.type) {
22377
22378
  errors3.push({
22378
- path: path2,
22379
+ path: path3,
22379
22380
  message: rule.message || `Expected type ${rule.type}, got ${actualType}`,
22380
22381
  expected: rule.type,
22381
22382
  actual: actualType,
@@ -22387,7 +22388,7 @@ class ConfigValidator {
22387
22388
  const length = Array.isArray(value) ? value.length : typeof value === "string" ? value.length : typeof value === "number" ? value : 0;
22388
22389
  if (length < rule.min) {
22389
22390
  errors3.push({
22390
- path: path2,
22391
+ path: path3,
22391
22392
  message: rule.message || `Value must be at least ${rule.min}`,
22392
22393
  expected: `>= ${rule.min}`,
22393
22394
  actual: length,
@@ -22399,7 +22400,7 @@ class ConfigValidator {
22399
22400
  const length = Array.isArray(value) ? value.length : typeof value === "string" ? value.length : typeof value === "number" ? value : 0;
22400
22401
  if (length > rule.max) {
22401
22402
  errors3.push({
22402
- path: path2,
22403
+ path: path3,
22403
22404
  message: rule.message || `Value must not exceed ${rule.max}`,
22404
22405
  expected: `<= ${rule.max}`,
22405
22406
  actual: length,
@@ -22410,7 +22411,7 @@ class ConfigValidator {
22410
22411
  if (rule.pattern && typeof value === "string") {
22411
22412
  if (!rule.pattern.test(value)) {
22412
22413
  errors3.push({
22413
- path: path2,
22414
+ path: path3,
22414
22415
  message: rule.message || `Value does not match pattern ${rule.pattern}`,
22415
22416
  expected: rule.pattern.toString(),
22416
22417
  actual: value,
@@ -22420,7 +22421,7 @@ class ConfigValidator {
22420
22421
  }
22421
22422
  if (rule.enum && !rule.enum.includes(value)) {
22422
22423
  errors3.push({
22423
- path: path2,
22424
+ path: path3,
22424
22425
  message: rule.message || `Value must be one of: ${rule.enum.join(", ")}`,
22425
22426
  expected: rule.enum.join(", "),
22426
22427
  actual: value,
@@ -22431,7 +22432,7 @@ class ConfigValidator {
22431
22432
  const customError = rule.validator(value);
22432
22433
  if (customError) {
22433
22434
  errors3.push({
22434
- path: path2,
22435
+ path: path3,
22435
22436
  message: rule.message || customError,
22436
22437
  rule: "custom"
22437
22438
  });
@@ -22439,10 +22440,10 @@ class ConfigValidator {
22439
22440
  }
22440
22441
  return errors3;
22441
22442
  }
22442
- getValueByPath(obj, path2) {
22443
- if (!path2)
22443
+ getValueByPath(obj, path3) {
22444
+ if (!path3)
22444
22445
  return obj;
22445
- const keys = path2.split(".");
22446
+ const keys = path3.split(".");
22446
22447
  let current = obj;
22447
22448
  for (const key of keys) {
22448
22449
  if (current && typeof current === "object" && key in current) {
@@ -22868,10 +22869,10 @@ async function loadConfig5(options2) {
22868
22869
  function applyEnvVarsToConfig2(name, config4, verbose = false) {
22869
22870
  const _envProcessor = new EnvProcessor;
22870
22871
  const envPrefix = name.toUpperCase().replace(/[^A-Z0-9]/g, "_");
22871
- function processConfigLevel(obj, path2 = []) {
22872
+ function processConfigLevel(obj, path3 = []) {
22872
22873
  const result = { ...obj };
22873
22874
  for (const [key, value] of Object.entries(obj)) {
22874
- const currentPath = [...path2, key];
22875
+ const currentPath = [...path3, key];
22875
22876
  const envKeys = [
22876
22877
  `${envPrefix}_${currentPath.join("_").toUpperCase()}`,
22877
22878
  `${envPrefix}_${currentPath.map((k) => k.toUpperCase()).join("")}`,
@@ -22919,41 +22920,41 @@ var defaultGeneratedDir3 = resolve7(process12.cwd(), "src/generated");
22919
22920
  import { join as join4 } from "path";
22920
22921
 
22921
22922
  // node_modules/env-paths/index.js
22922
- import path2 from "path";
22923
+ import path3 from "path";
22923
22924
  import os from "os";
22924
22925
  import process13 from "process";
22925
22926
  var homedir3 = os.homedir();
22926
22927
  var tmpdir = os.tmpdir();
22927
22928
  var { env } = process13;
22928
22929
  var macos = (name) => {
22929
- const library = path2.join(homedir3, "Library");
22930
+ const library = path3.join(homedir3, "Library");
22930
22931
  return {
22931
- data: path2.join(library, "Application Support", name),
22932
- config: path2.join(library, "Preferences", name),
22933
- cache: path2.join(library, "Caches", name),
22934
- log: path2.join(library, "Logs", name),
22935
- temp: path2.join(tmpdir, name)
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)
22936
22937
  };
22937
22938
  };
22938
22939
  var windows = (name) => {
22939
- const appData = env.APPDATA || path2.join(homedir3, "AppData", "Roaming");
22940
- const localAppData = env.LOCALAPPDATA || path2.join(homedir3, "AppData", "Local");
22940
+ const appData = env.APPDATA || path3.join(homedir3, "AppData", "Roaming");
22941
+ const localAppData = env.LOCALAPPDATA || path3.join(homedir3, "AppData", "Local");
22941
22942
  return {
22942
- data: path2.join(localAppData, name, "Data"),
22943
- config: path2.join(appData, name, "Config"),
22944
- cache: path2.join(localAppData, name, "Cache"),
22945
- log: path2.join(localAppData, name, "Log"),
22946
- temp: path2.join(tmpdir, name)
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)
22947
22948
  };
22948
22949
  };
22949
22950
  var linux = (name) => {
22950
- const username = path2.basename(homedir3);
22951
+ const username = path3.basename(homedir3);
22951
22952
  return {
22952
- data: path2.join(env.XDG_DATA_HOME || path2.join(homedir3, ".local", "share"), name),
22953
- config: path2.join(env.XDG_CONFIG_HOME || path2.join(homedir3, ".config"), name),
22954
- cache: path2.join(env.XDG_CACHE_HOME || path2.join(homedir3, ".cache"), name),
22955
- log: path2.join(env.XDG_STATE_HOME || path2.join(homedir3, ".local", "state"), name),
22956
- temp: path2.join(tmpdir, username, name)
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)
22957
22958
  };
22958
22959
  };
22959
22960
  function envPaths(name, { suffix = "nodejs" } = {}) {
@@ -22994,22 +22995,27 @@ async function getPluginConfig(ctx) {
22994
22995
 
22995
22996
  // src/lib/renderers/JsonPromptRenderer.ts
22996
22997
  var createJsonPromptRenderer = () => {
22997
- const format = "json";
22998
- const render = (data, rootElement = "root") => {
22999
- return JSON.stringify({ [rootElement]: data }, null, 2);
23000
- };
23001
- return {
23002
- format,
23003
- render
22998
+ const renderer = {
22999
+ format: "json",
23000
+ render(args) {
23001
+ return JSON.stringify({ [args.type]: args.data }, null, 2);
23002
+ }
23004
23003
  };
23004
+ return renderer;
23005
23005
  };
23006
23006
 
23007
23007
  // src/lib/xml.ts
23008
23008
  function escapeXml(str2) {
23009
23009
  return String(str2).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
23010
23010
  }
23011
+ function mapToObject(map2) {
23012
+ return Object.fromEntries(map2.entries());
23013
+ }
23011
23014
  function jsonToXml(json2, rootElement = "root") {
23012
23015
  let xml = `<${rootElement}>`;
23016
+ if (json2 instanceof Map) {
23017
+ return jsonToXml(mapToObject(json2), rootElement);
23018
+ }
23013
23019
  for (const key in json2) {
23014
23020
  if (!Object.hasOwn(json2, key)) {
23015
23021
  continue;
@@ -23022,6 +23028,8 @@ function jsonToXml(json2, rootElement = "root") {
23022
23028
  for (const item of value) {
23023
23029
  xml += jsonToXml(item, key);
23024
23030
  }
23031
+ } else if (value instanceof Map) {
23032
+ xml += jsonToXml(mapToObject(value), key);
23025
23033
  } else if (typeof value === "object" && value !== null) {
23026
23034
  xml += jsonToXml(value, key);
23027
23035
  } else if (value !== undefined && value !== null) {
@@ -23034,21 +23042,174 @@ function jsonToXml(json2, rootElement = "root") {
23034
23042
  return xml;
23035
23043
  }
23036
23044
 
23045
+ // src/lib/renderers/resourceMapToArray.ts
23046
+ var resourceMapToArray = (resources) => {
23047
+ return Array.from(resources.entries()).map(([relativePath, data]) => ({
23048
+ relativePath,
23049
+ ...data
23050
+ }));
23051
+ };
23052
+
23037
23053
  // src/lib/renderers/XmlPromptRenderer.ts
23038
23054
  var createXmlPromptRenderer = () => {
23039
- const format = "xml";
23040
- const render = (data, rootElement = "root") => {
23041
- return jsonToXml(data, rootElement);
23055
+ const prepareSkill = (skill) => {
23056
+ return {
23057
+ ...skill,
23058
+ references: resourceMapToArray(skill.references),
23059
+ scripts: resourceMapToArray(skill.scripts),
23060
+ assets: resourceMapToArray(skill.assets)
23061
+ };
23042
23062
  };
23043
- return {
23044
- format,
23045
- render
23063
+ const prepareResource = (resource) => {
23064
+ return resource;
23046
23065
  };
23066
+ const prepareSearchResult = (result) => {
23067
+ return result;
23068
+ };
23069
+ const renderer = {
23070
+ format: "xml",
23071
+ render(args) {
23072
+ const rootElement = args.type || "root";
23073
+ if (args.type === "Skill") {
23074
+ return jsonToXml(prepareSkill(args.data), rootElement);
23075
+ }
23076
+ if (args.type === "SkillResource") {
23077
+ return jsonToXml(prepareResource(args.data), rootElement);
23078
+ }
23079
+ if (args.type === "SkillSearchResults") {
23080
+ return jsonToXml(prepareSearchResult(args.data), rootElement);
23081
+ }
23082
+ return jsonToXml({}, rootElement);
23083
+ }
23084
+ };
23085
+ return renderer;
23047
23086
  };
23048
23087
 
23088
+ // node_modules/dedent/dist/dedent.mjs
23089
+ function ownKeys(object2, enumerableOnly) {
23090
+ var keys = Object.keys(object2);
23091
+ if (Object.getOwnPropertySymbols) {
23092
+ var symbols = Object.getOwnPropertySymbols(object2);
23093
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
23094
+ return Object.getOwnPropertyDescriptor(object2, sym).enumerable;
23095
+ })), keys.push.apply(keys, symbols);
23096
+ }
23097
+ return keys;
23098
+ }
23099
+ function _objectSpread(target) {
23100
+ for (var i = 1;i < arguments.length; i++) {
23101
+ var source = arguments[i] != null ? arguments[i] : {};
23102
+ i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
23103
+ _defineProperty(target, key, source[key]);
23104
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
23105
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
23106
+ });
23107
+ }
23108
+ return target;
23109
+ }
23110
+ function _defineProperty(obj, key, value) {
23111
+ key = _toPropertyKey(key);
23112
+ if (key in obj) {
23113
+ Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
23114
+ } else {
23115
+ obj[key] = value;
23116
+ }
23117
+ return obj;
23118
+ }
23119
+ function _toPropertyKey(arg) {
23120
+ var key = _toPrimitive(arg, "string");
23121
+ return typeof key === "symbol" ? key : String(key);
23122
+ }
23123
+ function _toPrimitive(input, hint) {
23124
+ if (typeof input !== "object" || input === null)
23125
+ return input;
23126
+ var prim = input[Symbol.toPrimitive];
23127
+ if (prim !== undefined) {
23128
+ var res = prim.call(input, hint || "default");
23129
+ if (typeof res !== "object")
23130
+ return res;
23131
+ throw new TypeError("@@toPrimitive must return a primitive value.");
23132
+ }
23133
+ return (hint === "string" ? String : Number)(input);
23134
+ }
23135
+ var dedent = createDedent({});
23136
+ var dedent_default = dedent;
23137
+ function createDedent(options3) {
23138
+ dedent2.withOptions = (newOptions) => createDedent(_objectSpread(_objectSpread({}, options3), newOptions));
23139
+ return dedent2;
23140
+ function dedent2(strings, ...values) {
23141
+ const raw = typeof strings === "string" ? [strings] : strings.raw;
23142
+ const {
23143
+ alignValues = false,
23144
+ escapeSpecialCharacters = Array.isArray(strings),
23145
+ trimWhitespace = true
23146
+ } = options3;
23147
+ let result = "";
23148
+ for (let i = 0;i < raw.length; i++) {
23149
+ let next = raw[i];
23150
+ if (escapeSpecialCharacters) {
23151
+ next = next.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\\{/g, "{");
23152
+ }
23153
+ result += next;
23154
+ if (i < values.length) {
23155
+ const value = alignValues ? alignValue(values[i], result) : values[i];
23156
+ result += value;
23157
+ }
23158
+ }
23159
+ const lines = result.split(`
23160
+ `);
23161
+ let mindent = null;
23162
+ for (const l of lines) {
23163
+ const m = l.match(/^(\s+)\S+/);
23164
+ if (m) {
23165
+ const indent = m[1].length;
23166
+ if (!mindent) {
23167
+ mindent = indent;
23168
+ } else {
23169
+ mindent = Math.min(mindent, indent);
23170
+ }
23171
+ }
23172
+ }
23173
+ if (mindent !== null) {
23174
+ const m = mindent;
23175
+ result = lines.map((l) => l[0] === " " || l[0] === "\t" ? l.slice(m) : l).join(`
23176
+ `);
23177
+ }
23178
+ if (trimWhitespace) {
23179
+ result = result.trim();
23180
+ }
23181
+ if (escapeSpecialCharacters) {
23182
+ result = result.replace(/\\n/g, `
23183
+ `);
23184
+ }
23185
+ if (typeof Bun !== "undefined") {
23186
+ result = result.replace(/\\u(?:\{([\da-fA-F]{1,6})\}|([\da-fA-F]{4}))/g, (_, braced, unbraced) => {
23187
+ var _ref;
23188
+ const hex3 = (_ref = braced !== null && braced !== undefined ? braced : unbraced) !== null && _ref !== undefined ? _ref : "";
23189
+ return String.fromCodePoint(parseInt(hex3, 16));
23190
+ });
23191
+ }
23192
+ return result;
23193
+ }
23194
+ }
23195
+ function alignValue(value, precedingText) {
23196
+ if (typeof value !== "string" || !value.includes(`
23197
+ `)) {
23198
+ return value;
23199
+ }
23200
+ const currentLine = precedingText.slice(precedingText.lastIndexOf(`
23201
+ `) + 1);
23202
+ const indentMatch = currentLine.match(/^(\s+)/);
23203
+ if (indentMatch) {
23204
+ const indent = indentMatch[1];
23205
+ return value.replace(/\n/g, `
23206
+ ${indent}`);
23207
+ }
23208
+ return value;
23209
+ }
23210
+
23049
23211
  // src/lib/renderers/MdPromptRenderer.ts
23050
23212
  var createMdPromptRenderer = () => {
23051
- const format = "md";
23052
23213
  const renderObject = (obj, headingLevel, indentLevel = 0) => {
23053
23214
  const entries = Object.entries(obj);
23054
23215
  let output = "";
@@ -23114,25 +23275,51 @@ var createMdPromptRenderer = () => {
23114
23275
  const htmlEscape = (value) => {
23115
23276
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
23116
23277
  };
23117
- const render = (data, rootElement = "Prompt") => {
23118
- const { content, ...restData } = data;
23119
- return `# ${rootElement}
23278
+ const renderSkill = (skill) => {
23279
+ return dedent_default`
23280
+ # ${skill.name}
23120
23281
 
23121
- ${renderObject(restData, 3)}
23282
+ ${skill.content}
23122
23283
 
23123
- ${content && `---
23284
+ ## Metadata
23124
23285
 
23125
- ### Content
23286
+ ${skill.metadata ? renderObject(skill.metadata, 3) : ""}
23287
+
23288
+ ## References
23126
23289
 
23127
- ${content}
23290
+ ${skill.references ? renderArray(resourceMapToArray(skill.references), 1) : ""}
23128
23291
 
23129
- ` || ""}
23292
+ ## Scripts
23293
+
23294
+ ${skill.scripts ? renderArray(resourceMapToArray(skill.scripts), 1) : ""}
23295
+
23296
+ ## Assets
23297
+
23298
+ ${skill.assets ? renderArray(resourceMapToArray(skill.assets), 1) : ""}
23130
23299
  `;
23131
23300
  };
23132
- return {
23133
- format,
23134
- render
23301
+ const renderResource = (resource) => {
23302
+ return renderObject(resource, 3);
23303
+ };
23304
+ const renderSearchResult = (result) => {
23305
+ return renderObject(result, 3);
23306
+ };
23307
+ const renderer = {
23308
+ format: "md",
23309
+ render(args) {
23310
+ if (args.type === "Skill") {
23311
+ return renderSkill(args.data);
23312
+ }
23313
+ if (args.type === "SkillResource") {
23314
+ return renderResource(args.data);
23315
+ }
23316
+ if (args.type === "SkillSearchResults") {
23317
+ return renderSearchResult(args.data);
23318
+ }
23319
+ return renderObject({}, 3);
23320
+ }
23135
23321
  };
23322
+ return renderer;
23136
23323
  };
23137
23324
 
23138
23325
  // src/lib/createPromptRenderer.ts
@@ -23264,7 +23451,7 @@ var SkillsPlugin = async (ctx) => {
23264
23451
  const renderer = promptRenderer.getFormatter(format);
23265
23452
  const results = await api2.loadSkill(args.skill_names);
23266
23453
  for await (const skill of results.loaded) {
23267
- await sendPrompt(renderer(skill, "Skill"), {
23454
+ await sendPrompt(renderer({ data: skill, type: "Skill" }), {
23268
23455
  sessionId: toolCtx.sessionID
23269
23456
  });
23270
23457
  }
@@ -23290,7 +23477,7 @@ var SkillsPlugin = async (ctx) => {
23290
23477
  });
23291
23478
  const renderer = promptRenderer.getFormatter(format);
23292
23479
  const results = await api2.findSkills(args);
23293
- const output = renderer(results, "SkillSearchResults");
23480
+ const output = renderer({ data: results, type: "SkillSearchResults" });
23294
23481
  return output;
23295
23482
  }
23296
23483
  }),
@@ -23314,7 +23501,7 @@ var SkillsPlugin = async (ctx) => {
23314
23501
  if (!result.injection) {
23315
23502
  throw new Error("Failed to read resource");
23316
23503
  }
23317
- await sendPrompt(renderer(result.injection, "Resource"), {
23504
+ await sendPrompt(renderer({ data: result.injection, type: "SkillResource" }), {
23318
23505
  sessionId: toolCtx.sessionID
23319
23506
  });
23320
23507
  return JSON.stringify({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenobius/opencode-skillful",
3
- "version": "1.2.1",
3
+ "version": "1.2.2-next.2",
4
4
  "description": "OpenCode Skills Plugin - Anthropic Agent Skills Specification implementation",
5
5
  "type": "module",
6
6
  "module": "src/index.ts",
@@ -21,6 +21,7 @@
21
21
  "dependencies": {
22
22
  "@opencode-ai/plugin": "1.0.85",
23
23
  "bunfig": "^0.15.6",
24
+ "dedent": "^1.7.1",
24
25
  "env-paths": "^3.0.0",
25
26
  "gray-matter": "^4.0.3",
26
27
  "mime": "^4.1.0",