opencode-gitlab-dap 1.15.2 → 1.15.4

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.cjs CHANGED
@@ -4105,83 +4105,6 @@ async function removeIndexEntry(instanceUrl, token, scope, id, indexSlug, name)
4105
4105
  await writeIndex(instanceUrl, token, scope, id, indexSlug, filtered);
4106
4106
  }
4107
4107
  }
4108
- function extractSkillNames(pages, prefix) {
4109
- const skillSuffix = "/SKILL";
4110
- const names = /* @__PURE__ */ new Set();
4111
- for (const p of pages) {
4112
- if (p.slug.startsWith(prefix + "/") && p.slug.endsWith(skillSuffix)) {
4113
- const middle = p.slug.slice(prefix.length + 1, -skillSuffix.length);
4114
- if (middle && !middle.includes("/")) {
4115
- names.add(middle);
4116
- }
4117
- }
4118
- }
4119
- return [...names];
4120
- }
4121
- async function rebuildIndex(instanceUrl, token, scope, id, prefix, indexSlug) {
4122
- const pages = await listWikiPages(instanceUrl, token, scope, id);
4123
- const actualNames = extractSkillNames(pages, prefix);
4124
- const currentEntries = await readIndex(instanceUrl, token, scope, id, indexSlug);
4125
- const indexed = new Set(currentEntries.map((e) => e.name));
4126
- const actual = new Set(actualNames);
4127
- let dirty = false;
4128
- const removed = currentEntries.filter((e) => !actual.has(e.name));
4129
- if (removed.length > 0) dirty = true;
4130
- const added = [];
4131
- for (const name of actualNames) {
4132
- if (!indexed.has(name)) {
4133
- added.push(name);
4134
- dirty = true;
4135
- }
4136
- }
4137
- const staleDescriptions = currentEntries.filter(
4138
- (e) => actual.has(e.name) && (e.description.startsWith("(auto-indexed") || e.description.startsWith("(no description"))
4139
- );
4140
- if (staleDescriptions.length > 0) dirty = true;
4141
- if (!dirty && added.length === 0) return currentEntries;
4142
- const kept = [];
4143
- for (const e of currentEntries) {
4144
- if (!actual.has(e.name)) continue;
4145
- if (e.description.startsWith("(auto-indexed") || e.description.startsWith("(no description")) {
4146
- let description = "";
4147
- try {
4148
- const page = await getWikiPage(instanceUrl, token, scope, id, `${prefix}/${e.name}/SKILL`);
4149
- const content = page.content ?? "";
4150
- const fmMatch = content.match(/^---\s*\n[\s\S]*?description:\s*(.+)\n[\s\S]*?---/);
4151
- if (fmMatch) {
4152
- description = fmMatch[1].trim();
4153
- } else {
4154
- description = content.replace(/^---[\s\S]*?---\s*\n/, "").replace(/^#[^\n]*\n+/, "").split("\n\n")[0].replace(/\n/g, " ").trim().slice(0, 200);
4155
- }
4156
- } catch {
4157
- }
4158
- kept.push({ ...e, description: description || e.description });
4159
- } else {
4160
- kept.push(e);
4161
- }
4162
- }
4163
- for (const name of added) {
4164
- let description = "";
4165
- try {
4166
- const page = await getWikiPage(instanceUrl, token, scope, id, `${prefix}/${name}/SKILL`);
4167
- const content = page.content ?? "";
4168
- const fmMatch = content.match(/^---\s*\n[\s\S]*?description:\s*(.+)\n[\s\S]*?---/);
4169
- if (fmMatch) {
4170
- description = fmMatch[1].trim();
4171
- } else {
4172
- description = content.replace(/^---[\s\S]*?---\s*\n/, "").replace(/^#[^\n]*\n+/, "").split("\n\n")[0].replace(/\n/g, " ").trim().slice(0, 200);
4173
- }
4174
- } catch {
4175
- }
4176
- kept.push({
4177
- name,
4178
- description: description || "(no description \u2014 update with gitlab_skill_save)",
4179
- draft: prefix === DRAFTS_PREFIX
4180
- });
4181
- }
4182
- await writeIndex(instanceUrl, token, scope, id, indexSlug, kept);
4183
- return kept;
4184
- }
4185
4108
  async function upsertPage(instanceUrl, token, scope, id, slug, content) {
4186
4109
  try {
4187
4110
  await updateWikiPage(instanceUrl, token, scope, id, slug, content);
@@ -4189,6 +4112,7 @@ async function upsertPage(instanceUrl, token, scope, id, slug, content) {
4189
4112
  await createWikiPage(instanceUrl, token, scope, id, slug, content);
4190
4113
  }
4191
4114
  }
4115
+ var EMPTY_FILE_SENTINEL = "__EMPTY_FILE__";
4192
4116
  function isMarkdownFile(path) {
4193
4117
  return path === "SKILL.md" || path.endsWith(".md") || path.endsWith(".markdown");
4194
4118
  }
@@ -4306,7 +4230,7 @@ function makeSkillTools(ctx) {
4306
4230
  }
4307
4231
  return {
4308
4232
  gitlab_skill_list: (0, import_plugin6.tool)({
4309
- description: "List available project skills and optionally draft skills.\nSkills define step-by-step procedures for common tasks (e.g., incident retros, debugging, deployments).\nAuto-rebuilds the skill index if it is out of sync with actual skill pages.",
4233
+ description: "List available project skills and optionally draft skills.\nSkills define step-by-step procedures for common tasks (e.g., incident retros, debugging, deployments).",
4310
4234
  args: {
4311
4235
  project_id: z6.string().describe(PROJECT_ID_DESC2),
4312
4236
  include_drafts: z6.boolean().optional().describe("Also list draft skills (default: false)"),
@@ -4317,25 +4241,12 @@ function makeSkillTools(ctx) {
4317
4241
  const auth = authAndValidate(args.project_id);
4318
4242
  const { scope, id } = resolveScope2(args);
4319
4243
  try {
4320
- const published = await rebuildIndex(
4321
- auth.instanceUrl,
4322
- auth.token,
4323
- scope,
4324
- id,
4325
- SKILLS_PREFIX,
4326
- SKILLS_INDEX
4327
- );
4244
+ const published = await readIndex(auth.instanceUrl, auth.token, scope, id, SKILLS_INDEX);
4328
4245
  let drafts = [];
4329
4246
  if (args.include_drafts) {
4330
- drafts = await rebuildIndex(
4331
- auth.instanceUrl,
4332
- auth.token,
4333
- scope,
4334
- id,
4335
- DRAFTS_PREFIX,
4336
- DRAFTS_INDEX
4247
+ drafts = (await readIndex(auth.instanceUrl, auth.token, scope, id, DRAFTS_INDEX)).map(
4248
+ (e) => ({ ...e, draft: true })
4337
4249
  );
4338
- drafts = drafts.map((e) => ({ ...e, draft: true }));
4339
4250
  }
4340
4251
  const all = [...published, ...drafts];
4341
4252
  if (all.length === 0) return "No skills found. Use gitlab_skill_save to create one.";
@@ -4584,7 +4495,10 @@ Install: \`gitlab_skill_install(name="${r.identifier}", source="skills.sh")\``
4584
4495
  args.project_id,
4585
4496
  `skill:${downloaded.name}`,
4586
4497
  `Scripts for skill "${downloaded.name}" (installed from skills.sh:${args.name})`,
4587
- scriptFiles.map((f) => ({ file_path: f.path, content: f.content || "\n" })),
4498
+ scriptFiles.map((f) => ({
4499
+ file_path: f.path,
4500
+ content: f.content.trim() ? f.content : EMPTY_FILE_SENTINEL
4501
+ })),
4588
4502
  "private"
4589
4503
  );
4590
4504
  snippetId = snippet.id;
@@ -4748,7 +4662,7 @@ Install: \`gitlab_skill_install(name="${r.identifier}", source="skills.sh")\``
4748
4662
  entry.snippetId,
4749
4663
  file.path
4750
4664
  );
4751
- (0, import_fs2.writeFileSync)(filePath, content);
4665
+ (0, import_fs2.writeFileSync)(filePath, content.trim() === EMPTY_FILE_SENTINEL ? "" : content);
4752
4666
  if (file.path.endsWith(".sh")) {
4753
4667
  (0, import_fs2.chmodSync)(filePath, 493);
4754
4668
  }