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.cjs +61 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +61 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4018,6 +4018,7 @@ var import_child_process = require("child_process");
|
|
|
4018
4018
|
var import_fs2 = require("fs");
|
|
4019
4019
|
var import_path2 = require("path");
|
|
4020
4020
|
var import_os2 = require("os");
|
|
4021
|
+
var import_zlib = require("zlib");
|
|
4021
4022
|
var z6 = import_plugin6.tool.schema;
|
|
4022
4023
|
var PREFIX2 = "agents";
|
|
4023
4024
|
var SKILLS_PREFIX = `${PREFIX2}/skills`;
|
|
@@ -4113,6 +4114,22 @@ async function upsertPage(instanceUrl, token, scope, id, slug, content) {
|
|
|
4113
4114
|
}
|
|
4114
4115
|
}
|
|
4115
4116
|
var EMPTY_FILE_SENTINEL = "__EMPTY_FILE__";
|
|
4117
|
+
function packFiles(files) {
|
|
4118
|
+
const manifest = files.map((f) => ({
|
|
4119
|
+
path: f.path,
|
|
4120
|
+
content: f.content.trim() ? f.content : EMPTY_FILE_SENTINEL
|
|
4121
|
+
}));
|
|
4122
|
+
const json = JSON.stringify(manifest);
|
|
4123
|
+
return (0, import_zlib.gzipSync)(Buffer.from(json, "utf-8")).toString("base64");
|
|
4124
|
+
}
|
|
4125
|
+
function unpackFiles(packed) {
|
|
4126
|
+
const json = (0, import_zlib.gunzipSync)(Buffer.from(packed, "base64")).toString("utf-8");
|
|
4127
|
+
const manifest = JSON.parse(json);
|
|
4128
|
+
return manifest.map((f) => ({
|
|
4129
|
+
path: f.path,
|
|
4130
|
+
content: f.content === EMPTY_FILE_SENTINEL ? "" : f.content
|
|
4131
|
+
}));
|
|
4132
|
+
}
|
|
4116
4133
|
function isMarkdownFile(path) {
|
|
4117
4134
|
return path === "SKILL.md" || path.endsWith(".md") || path.endsWith(".markdown");
|
|
4118
4135
|
}
|
|
@@ -4278,8 +4295,9 @@ function makeSkillTools(ctx) {
|
|
|
4278
4295
|
`${prefix}/${args.name}/SKILL`
|
|
4279
4296
|
);
|
|
4280
4297
|
const pages = await listWikiPages(auth.instanceUrl, auth.token, scope, id);
|
|
4281
|
-
const
|
|
4282
|
-
const
|
|
4298
|
+
const skillPrefix = `${prefix}/${args.name}/`;
|
|
4299
|
+
const skillSlug = `${prefix}/${args.name}/SKILL`;
|
|
4300
|
+
const refs = pages.filter((p) => p.slug.startsWith(skillPrefix) && p.slug !== skillSlug).map((p) => p.slug.slice(skillPrefix.length));
|
|
4283
4301
|
const isDraft = prefix === DRAFTS_PREFIX;
|
|
4284
4302
|
let result = isDraft ? `[DRAFT SKILL]
|
|
4285
4303
|
|
|
@@ -4389,16 +4407,21 @@ Run \`gitlab_skill_setup(name="${args.name}")\` to extract them to .agents/skill
|
|
|
4389
4407
|
}
|
|
4390
4408
|
}),
|
|
4391
4409
|
gitlab_skill_discover: (0, import_plugin6.tool)({
|
|
4392
|
-
description: "Search for skills in the
|
|
4410
|
+
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.",
|
|
4393
4411
|
args: {
|
|
4394
|
-
project_id: z6.string().describe(PROJECT_ID_DESC2),
|
|
4395
4412
|
query: z6.string().describe("Search query (matches skill name and description)"),
|
|
4413
|
+
project_id: z6.string().optional().describe(PROJECT_ID_DESC2 + " Only needed for group wiki search."),
|
|
4396
4414
|
group_id: z6.string().optional().describe("Group path to search for shared skills (optional)")
|
|
4397
4415
|
},
|
|
4398
4416
|
execute: async (args) => {
|
|
4399
|
-
|
|
4417
|
+
let auth = null;
|
|
4418
|
+
if (args.project_id) {
|
|
4419
|
+
auth = authAndValidate(args.project_id);
|
|
4420
|
+
} else if (args.group_id) {
|
|
4421
|
+
return "Error: project_id is required when searching a group wiki.";
|
|
4422
|
+
}
|
|
4400
4423
|
const sections = [];
|
|
4401
|
-
if (args.group_id) {
|
|
4424
|
+
if (args.group_id && auth) {
|
|
4402
4425
|
try {
|
|
4403
4426
|
const entries = await readIndex(
|
|
4404
4427
|
auth.instanceUrl,
|
|
@@ -4476,7 +4499,7 @@ Install: \`gitlab_skill_install(name="${r.identifier}", source="skills.sh")\``
|
|
|
4476
4499
|
const mdFiles = downloaded.files.filter((f) => isMarkdownFile(f.path));
|
|
4477
4500
|
const scriptFiles = downloaded.files.filter((f) => !isMarkdownFile(f.path));
|
|
4478
4501
|
for (const file of mdFiles) {
|
|
4479
|
-
const slug = `${targetPrefix}/${downloaded.name}
|
|
4502
|
+
const slug = `${targetPrefix}/${downloaded.name}/${file.path.replace(/\.[^.]+$/, "")}`;
|
|
4480
4503
|
await upsertPage(
|
|
4481
4504
|
auth.instanceUrl,
|
|
4482
4505
|
auth.token,
|
|
@@ -4489,16 +4512,14 @@ Install: \`gitlab_skill_install(name="${r.identifier}", source="skills.sh")\``
|
|
|
4489
4512
|
}
|
|
4490
4513
|
let snippetId;
|
|
4491
4514
|
if (scriptFiles.length > 0) {
|
|
4515
|
+
const packed = packFiles(scriptFiles);
|
|
4492
4516
|
const snippet = await createProjectSnippet(
|
|
4493
4517
|
auth.instanceUrl,
|
|
4494
4518
|
auth.token,
|
|
4495
4519
|
args.project_id,
|
|
4496
4520
|
`skill:${downloaded.name}`,
|
|
4497
|
-
`Scripts for skill "${downloaded.name}" (installed from skills.sh:${args.name})`,
|
|
4498
|
-
|
|
4499
|
-
file_path: f.path,
|
|
4500
|
-
content: f.content.trim() ? f.content : EMPTY_FILE_SENTINEL
|
|
4501
|
-
})),
|
|
4521
|
+
`Scripts for skill "${downloaded.name}" (${scriptFiles.length} files, installed from skills.sh:${args.name})`,
|
|
4522
|
+
[{ file_path: `${downloaded.name}.bundle`, content: packed }],
|
|
4502
4523
|
"private"
|
|
4503
4524
|
);
|
|
4504
4525
|
snippetId = snippet.id;
|
|
@@ -4617,15 +4638,15 @@ Install: \`gitlab_skill_install(name="${r.identifier}", source="skills.sh")\``
|
|
|
4617
4638
|
const pages = await listWikiPages(auth.instanceUrl, auth.token, scope, id, true);
|
|
4618
4639
|
let refCount = 0;
|
|
4619
4640
|
for (const prefix of [SKILLS_PREFIX, DRAFTS_PREFIX]) {
|
|
4620
|
-
const
|
|
4621
|
-
const
|
|
4622
|
-
(p) => p.slug.startsWith(
|
|
4641
|
+
const skillPagePrefix = `${prefix}/${args.name}/`;
|
|
4642
|
+
const extraPages = pages.filter(
|
|
4643
|
+
(p) => p.slug.startsWith(skillPagePrefix) && p.slug !== `${prefix}/${args.name}/SKILL` && p.content
|
|
4623
4644
|
);
|
|
4624
|
-
for (const
|
|
4625
|
-
const
|
|
4626
|
-
const
|
|
4627
|
-
(0, import_fs2.mkdirSync)(
|
|
4628
|
-
(0, import_fs2.writeFileSync)(
|
|
4645
|
+
for (const page of extraPages) {
|
|
4646
|
+
const relPath = page.slug.slice(skillPagePrefix.length);
|
|
4647
|
+
const filePath = (0, import_path2.join)(targetDir, `${relPath}.md`);
|
|
4648
|
+
(0, import_fs2.mkdirSync)((0, import_path2.dirname)(filePath), { recursive: true });
|
|
4649
|
+
(0, import_fs2.writeFileSync)(filePath, page.content);
|
|
4629
4650
|
refCount++;
|
|
4630
4651
|
}
|
|
4631
4652
|
}
|
|
@@ -4646,27 +4667,37 @@ Install: \`gitlab_skill_install(name="${r.identifier}", source="skills.sh")\``
|
|
|
4646
4667
|
);
|
|
4647
4668
|
const entry = [...indexEntries, ...draftsEntries].find((e) => e.name === args.name);
|
|
4648
4669
|
if (entry?.snippetId) {
|
|
4649
|
-
const
|
|
4670
|
+
const bundleFiles = await listSnippetFiles(
|
|
4650
4671
|
auth.instanceUrl,
|
|
4651
4672
|
auth.token,
|
|
4652
4673
|
args.project_id,
|
|
4653
4674
|
entry.snippetId
|
|
4654
4675
|
);
|
|
4655
|
-
for (const
|
|
4656
|
-
const
|
|
4657
|
-
(0, import_fs2.mkdirSync)((0, import_path2.dirname)(filePath), { recursive: true });
|
|
4658
|
-
const content = await getSnippetFileRaw(
|
|
4676
|
+
for (const bf of bundleFiles) {
|
|
4677
|
+
const raw = await getSnippetFileRaw(
|
|
4659
4678
|
auth.instanceUrl,
|
|
4660
4679
|
auth.token,
|
|
4661
4680
|
args.project_id,
|
|
4662
4681
|
entry.snippetId,
|
|
4663
|
-
|
|
4682
|
+
bf.path
|
|
4664
4683
|
);
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
(
|
|
4684
|
+
if (bf.path.endsWith(".bundle")) {
|
|
4685
|
+
const unpacked = unpackFiles(raw);
|
|
4686
|
+
for (const file of unpacked) {
|
|
4687
|
+
const filePath = (0, import_path2.join)(targetDir, file.path);
|
|
4688
|
+
(0, import_fs2.mkdirSync)((0, import_path2.dirname)(filePath), { recursive: true });
|
|
4689
|
+
(0, import_fs2.writeFileSync)(filePath, file.content);
|
|
4690
|
+
if (file.path.endsWith(".sh")) {
|
|
4691
|
+
(0, import_fs2.chmodSync)(filePath, 493);
|
|
4692
|
+
}
|
|
4693
|
+
scriptCount++;
|
|
4694
|
+
}
|
|
4695
|
+
} else {
|
|
4696
|
+
const filePath = (0, import_path2.join)(targetDir, bf.path);
|
|
4697
|
+
(0, import_fs2.mkdirSync)((0, import_path2.dirname)(filePath), { recursive: true });
|
|
4698
|
+
(0, import_fs2.writeFileSync)(filePath, raw);
|
|
4699
|
+
scriptCount++;
|
|
4668
4700
|
}
|
|
4669
|
-
scriptCount++;
|
|
4670
4701
|
}
|
|
4671
4702
|
}
|
|
4672
4703
|
ensureGitignore(process.cwd());
|