opencode-gitlab-dap 1.15.4 → 1.15.6

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/dist/index.js CHANGED
@@ -3859,6 +3859,7 @@ import {
3859
3859
  } from "fs";
3860
3860
  import { join as join2, dirname } from "path";
3861
3861
  import { tmpdir } from "os";
3862
+ import { gzipSync, gunzipSync } from "zlib";
3862
3863
  var z6 = tool6.schema;
3863
3864
  var PREFIX2 = "agents";
3864
3865
  var SKILLS_PREFIX = `${PREFIX2}/skills`;
@@ -3954,6 +3955,22 @@ async function upsertPage(instanceUrl, token, scope, id, slug, content) {
3954
3955
  }
3955
3956
  }
3956
3957
  var EMPTY_FILE_SENTINEL = "__EMPTY_FILE__";
3958
+ function packFiles(files) {
3959
+ const manifest = files.map((f) => ({
3960
+ path: f.path,
3961
+ content: f.content.trim() ? f.content : EMPTY_FILE_SENTINEL
3962
+ }));
3963
+ const json = JSON.stringify(manifest);
3964
+ return gzipSync(Buffer.from(json, "utf-8")).toString("base64");
3965
+ }
3966
+ function unpackFiles(packed) {
3967
+ const json = gunzipSync(Buffer.from(packed, "base64")).toString("utf-8");
3968
+ const manifest = JSON.parse(json);
3969
+ return manifest.map((f) => ({
3970
+ path: f.path,
3971
+ content: f.content === EMPTY_FILE_SENTINEL ? "" : f.content
3972
+ }));
3973
+ }
3957
3974
  function isMarkdownFile(path) {
3958
3975
  return path === "SKILL.md" || path.endsWith(".md") || path.endsWith(".markdown");
3959
3976
  }
@@ -4119,8 +4136,9 @@ function makeSkillTools(ctx) {
4119
4136
  `${prefix}/${args.name}/SKILL`
4120
4137
  );
4121
4138
  const pages = await listWikiPages(auth.instanceUrl, auth.token, scope, id);
4122
- const refPrefix = `${prefix}/${args.name}/references/`;
4123
- const refs = pages.filter((p) => p.slug.startsWith(refPrefix)).map((p) => p.slug.slice(refPrefix.length));
4139
+ const skillPrefix = `${prefix}/${args.name}/`;
4140
+ const skillSlug = `${prefix}/${args.name}/SKILL`;
4141
+ const refs = pages.filter((p) => p.slug.startsWith(skillPrefix) && p.slug !== skillSlug).map((p) => p.slug.slice(skillPrefix.length));
4124
4142
  const isDraft = prefix === DRAFTS_PREFIX;
4125
4143
  let result = isDraft ? `[DRAFT SKILL]
4126
4144
 
@@ -4230,16 +4248,21 @@ Run \`gitlab_skill_setup(name="${args.name}")\` to extract them to .agents/skill
4230
4248
  }
4231
4249
  }),
4232
4250
  gitlab_skill_discover: tool6({
4233
- description: "Search for skills in the group wiki and the skills.sh public registry.\nGroup wiki skills are searched first, then skills.sh for community skills.\nUse gitlab_skill_install to install a discovered skill into your project.",
4251
+ description: "Search for skills in the skills.sh public registry and optionally a group wiki.\nUse gitlab_skill_install to install a discovered skill into your project.\nIMPORTANT: project_id is only needed when searching a group wiki. For skills.sh only, it is optional.",
4234
4252
  args: {
4235
- project_id: z6.string().describe(PROJECT_ID_DESC2),
4236
4253
  query: z6.string().describe("Search query (matches skill name and description)"),
4254
+ project_id: z6.string().optional().describe(PROJECT_ID_DESC2 + " Only needed for group wiki search."),
4237
4255
  group_id: z6.string().optional().describe("Group path to search for shared skills (optional)")
4238
4256
  },
4239
4257
  execute: async (args) => {
4240
- const auth = authAndValidate(args.project_id);
4258
+ let auth = null;
4259
+ if (args.project_id) {
4260
+ auth = authAndValidate(args.project_id);
4261
+ } else if (args.group_id) {
4262
+ return "Error: project_id is required when searching a group wiki.";
4263
+ }
4241
4264
  const sections = [];
4242
- if (args.group_id) {
4265
+ if (args.group_id && auth) {
4243
4266
  try {
4244
4267
  const entries = await readIndex(
4245
4268
  auth.instanceUrl,
@@ -4317,7 +4340,7 @@ Install: \`gitlab_skill_install(name="${r.identifier}", source="skills.sh")\``
4317
4340
  const mdFiles = downloaded.files.filter((f) => isMarkdownFile(f.path));
4318
4341
  const scriptFiles = downloaded.files.filter((f) => !isMarkdownFile(f.path));
4319
4342
  for (const file of mdFiles) {
4320
- const slug = `${targetPrefix}/${downloaded.name}/references/${file.path.replace(/\.[^.]+$/, "")}`;
4343
+ const slug = `${targetPrefix}/${downloaded.name}/${file.path.replace(/\.[^.]+$/, "")}`;
4321
4344
  await upsertPage(
4322
4345
  auth.instanceUrl,
4323
4346
  auth.token,
@@ -4330,16 +4353,14 @@ Install: \`gitlab_skill_install(name="${r.identifier}", source="skills.sh")\``
4330
4353
  }
4331
4354
  let snippetId;
4332
4355
  if (scriptFiles.length > 0) {
4356
+ const packed = packFiles(scriptFiles);
4333
4357
  const snippet = await createProjectSnippet(
4334
4358
  auth.instanceUrl,
4335
4359
  auth.token,
4336
4360
  args.project_id,
4337
4361
  `skill:${downloaded.name}`,
4338
- `Scripts for skill "${downloaded.name}" (installed from skills.sh:${args.name})`,
4339
- scriptFiles.map((f) => ({
4340
- file_path: f.path,
4341
- content: f.content.trim() ? f.content : EMPTY_FILE_SENTINEL
4342
- })),
4362
+ `Scripts for skill "${downloaded.name}" (${scriptFiles.length} files, installed from skills.sh:${args.name})`,
4363
+ [{ file_path: `${downloaded.name}.bundle`, content: packed }],
4343
4364
  "private"
4344
4365
  );
4345
4366
  snippetId = snippet.id;
@@ -4458,15 +4479,15 @@ Install: \`gitlab_skill_install(name="${r.identifier}", source="skills.sh")\``
4458
4479
  const pages = await listWikiPages(auth.instanceUrl, auth.token, scope, id, true);
4459
4480
  let refCount = 0;
4460
4481
  for (const prefix of [SKILLS_PREFIX, DRAFTS_PREFIX]) {
4461
- const refPrefix = `${prefix}/${args.name}/references/`;
4462
- const refPages = pages.filter(
4463
- (p) => p.slug.startsWith(refPrefix) && p.content
4482
+ const skillPagePrefix = `${prefix}/${args.name}/`;
4483
+ const extraPages = pages.filter(
4484
+ (p) => p.slug.startsWith(skillPagePrefix) && p.slug !== `${prefix}/${args.name}/SKILL` && p.content
4464
4485
  );
4465
- for (const ref of refPages) {
4466
- const refName = ref.slug.slice(refPrefix.length);
4467
- const refDir = join2(targetDir, "references");
4468
- mkdirSync(refDir, { recursive: true });
4469
- writeFileSync(join2(refDir, `${refName}.md`), ref.content);
4486
+ for (const page of extraPages) {
4487
+ const relPath = page.slug.slice(skillPagePrefix.length);
4488
+ const filePath = join2(targetDir, `${relPath}.md`);
4489
+ mkdirSync(dirname(filePath), { recursive: true });
4490
+ writeFileSync(filePath, page.content);
4470
4491
  refCount++;
4471
4492
  }
4472
4493
  }
@@ -4487,27 +4508,37 @@ Install: \`gitlab_skill_install(name="${r.identifier}", source="skills.sh")\``
4487
4508
  );
4488
4509
  const entry = [...indexEntries, ...draftsEntries].find((e) => e.name === args.name);
4489
4510
  if (entry?.snippetId) {
4490
- const files = await listSnippetFiles(
4511
+ const bundleFiles = await listSnippetFiles(
4491
4512
  auth.instanceUrl,
4492
4513
  auth.token,
4493
4514
  args.project_id,
4494
4515
  entry.snippetId
4495
4516
  );
4496
- for (const file of files) {
4497
- const filePath = join2(targetDir, file.path);
4498
- mkdirSync(dirname(filePath), { recursive: true });
4499
- const content = await getSnippetFileRaw(
4517
+ for (const bf of bundleFiles) {
4518
+ const raw = await getSnippetFileRaw(
4500
4519
  auth.instanceUrl,
4501
4520
  auth.token,
4502
4521
  args.project_id,
4503
4522
  entry.snippetId,
4504
- file.path
4523
+ bf.path
4505
4524
  );
4506
- writeFileSync(filePath, content.trim() === EMPTY_FILE_SENTINEL ? "" : content);
4507
- if (file.path.endsWith(".sh")) {
4508
- chmodSync(filePath, 493);
4525
+ if (bf.path.endsWith(".bundle")) {
4526
+ const unpacked = unpackFiles(raw);
4527
+ for (const file of unpacked) {
4528
+ const filePath = join2(targetDir, file.path);
4529
+ mkdirSync(dirname(filePath), { recursive: true });
4530
+ writeFileSync(filePath, file.content);
4531
+ if (file.path.endsWith(".sh")) {
4532
+ chmodSync(filePath, 493);
4533
+ }
4534
+ scriptCount++;
4535
+ }
4536
+ } else {
4537
+ const filePath = join2(targetDir, bf.path);
4538
+ mkdirSync(dirname(filePath), { recursive: true });
4539
+ writeFileSync(filePath, raw);
4540
+ scriptCount++;
4509
4541
  }
4510
- scriptCount++;
4511
4542
  }
4512
4543
  }
4513
4544
  ensureGitignore(process.cwd());