opencode-gitlab-dap 1.8.2 → 1.8.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
@@ -3612,13 +3612,13 @@ async function searchWikiPages(instanceUrl, token, scope, id, query) {
3612
3612
  // src/tools/memory-tools.ts
3613
3613
  var z5 = import_plugin5.tool.schema;
3614
3614
  var PREFIX = "agents";
3615
- var MEMORY_SLUGS = {
3615
+ var MEMORY_DIRS = {
3616
3616
  all: [`${PREFIX}/memory/facts`, `${PREFIX}/memory/decisions`, `${PREFIX}/memory/patterns`],
3617
3617
  facts: [`${PREFIX}/memory/facts`],
3618
3618
  decisions: [`${PREFIX}/memory/decisions`],
3619
3619
  patterns: [`${PREFIX}/memory/patterns`]
3620
3620
  };
3621
- var RECORD_SLUG = {
3621
+ var RECORD_DIR = {
3622
3622
  fact: `${PREFIX}/memory/facts`,
3623
3623
  decision: `${PREFIX}/memory/decisions`,
3624
3624
  pattern: `${PREFIX}/memory/patterns`
@@ -3629,21 +3629,9 @@ function today() {
3629
3629
  function slugify(text) {
3630
3630
  return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
3631
3631
  }
3632
- async function safeRead(instanceUrl, token, scope, id, slug) {
3633
- try {
3634
- const page = await getWikiPage(instanceUrl, token, scope, id, slug);
3635
- return page.content;
3636
- } catch {
3637
- return null;
3638
- }
3639
- }
3640
- async function appendToPage(instanceUrl, token, scope, id, slug, newContent) {
3641
- const existing = await safeRead(instanceUrl, token, scope, id, slug);
3642
- if (existing !== null) {
3643
- await updateWikiPage(instanceUrl, token, scope, id, slug, existing + "\n\n" + newContent);
3644
- } else {
3645
- await createWikiPage(instanceUrl, token, scope, id, slug, newContent);
3646
- }
3632
+ function titleFromContent(content) {
3633
+ const first = content.split("\n")[0].replace(/^[#*\->\s]+/, "").trim();
3634
+ return first.slice(0, 80) || "untitled";
3647
3635
  }
3648
3636
  function validateProjectId(projectId) {
3649
3637
  if (!projectId.includes("/")) {
@@ -3680,25 +3668,38 @@ function makeMemoryTools(ctx) {
3680
3668
  const auth = authAndValidate(args.project_id);
3681
3669
  const { scope, id } = resolveScope(args);
3682
3670
  const memType = args.type ?? "all";
3683
- const slugs = MEMORY_SLUGS[memType];
3684
- if (!slugs) return `Unknown memory type: ${memType}`;
3685
- const sections = [];
3686
- for (const slug of slugs) {
3687
- const content = await safeRead(auth.instanceUrl, auth.token, scope, id, slug);
3688
- if (content) {
3689
- const label = slug.split("/").pop();
3690
- sections.push(`## ${label.charAt(0).toUpperCase() + label.slice(1)}
3671
+ const dirs = MEMORY_DIRS[memType];
3672
+ if (!dirs) return `Unknown memory type: ${memType}`;
3673
+ try {
3674
+ const allPages = await listWikiPages(
3675
+ auth.instanceUrl,
3676
+ auth.token,
3677
+ scope,
3678
+ id,
3679
+ true
3680
+ );
3681
+ const sections = [];
3682
+ for (const dir of dirs) {
3683
+ const label = dir.split("/").pop();
3684
+ const pages = allPages.filter((p) => p.slug.startsWith(dir + "/") && p.content);
3685
+ if (pages.length === 0) continue;
3686
+ const entries = pages.map((p) => p.content).join("\n\n---\n\n");
3687
+ sections.push(
3688
+ `## ${label.charAt(0).toUpperCase() + label.slice(1)} (${pages.length})
3691
3689
 
3692
- ${content}`);
3690
+ ${entries}`
3691
+ );
3693
3692
  }
3693
+ if (sections.length === 0)
3694
+ return "No project memory found. Use gitlab_memory_record to start building project knowledge.";
3695
+ return sections.join("\n\n---\n\n");
3696
+ } catch (err) {
3697
+ return `Error loading memory: ${err.message}`;
3694
3698
  }
3695
- if (sections.length === 0)
3696
- return "No project memory found. Use gitlab_memory_record to start building project knowledge.";
3697
- return sections.join("\n\n---\n\n");
3698
3699
  }
3699
3700
  }),
3700
3701
  gitlab_memory_record: (0, import_plugin5.tool)({
3701
- description: "Record a fact, decision, or pattern in project memory.\nFacts: stable truths about the project (e.g., deploy targets, tech stack, team conventions).\nDecisions: architectural choices with reasoning (why X was chosen over Y).\nPatterns: recurring observations that may evolve into skills over time.\nEntries are automatically timestamped and appended to the appropriate memory page.\nMultiple facts can be recorded in a single call by separating them with newlines.",
3702
+ description: "Record a fact, decision, or pattern in project memory.\nFacts: stable truths about the project (e.g., deploy targets, tech stack, team conventions).\nDecisions: architectural choices with reasoning (why X was chosen over Y).\nPatterns: recurring observations that may evolve into skills over time.\nEach record creates its own page \u2014 safe for parallel writes.",
3702
3703
  args: {
3703
3704
  project_id: z5.string().describe(
3704
3705
  'FULL project path with namespace (e.g., "gitlab-org/gitlab"). Must contain a slash. Never use just the project name.'
@@ -3711,24 +3712,18 @@ ${content}`);
3711
3712
  execute: async (args) => {
3712
3713
  const auth = authAndValidate(args.project_id);
3713
3714
  const { scope, id } = resolveScope(args);
3714
- const slug = RECORD_SLUG[args.type];
3715
- if (!slug) return `Unknown memory type: ${args.type}`;
3715
+ const dir = RECORD_DIR[args.type];
3716
+ if (!dir) return `Unknown memory type: ${args.type}`;
3716
3717
  const date = today();
3717
- let formatted;
3718
- if (args.type === "decision") {
3719
- const firstLine = args.content.split("\n")[0];
3720
- const rest = args.content.split("\n").slice(1).join("\n").trim();
3721
- formatted = `## ${date}: ${firstLine}${rest ? "\n" + rest : ""}`;
3722
- } else if (args.type === "fact") {
3723
- formatted = `## ${date}
3724
- - ${args.content.replace(/\n/g, "\n- ")}`;
3725
- } else {
3726
- formatted = `## ${date}
3727
- ${args.content}`;
3728
- }
3718
+ const title = titleFromContent(args.content);
3719
+ const slug = `${dir}/${date}-${slugify(title)}`;
3720
+ const header = `*Recorded: ${date} | Type: ${args.type}*
3721
+
3722
+ `;
3723
+ const body = header + args.content;
3729
3724
  try {
3730
- await appendToPage(auth.instanceUrl, auth.token, scope, id, slug, formatted);
3731
- return `Recorded ${args.type} in project memory.`;
3725
+ await createWikiPage(auth.instanceUrl, auth.token, scope, id, slug, body);
3726
+ return `Recorded ${args.type} in project memory: ${slug}`;
3732
3727
  } catch (err) {
3733
3728
  return `Error recording ${args.type}: ${err.message}`;
3734
3729
  }
@@ -3788,14 +3783,6 @@ ${args.content}`;
3788
3783
  await createWikiPage(auth.instanceUrl, auth.token, scope, id, slug, args.summary);
3789
3784
  return `Session logged: ${slug}`;
3790
3785
  } catch (err) {
3791
- if (err.message?.includes("already exists") || err.message?.includes("422")) {
3792
- try {
3793
- await updateWikiPage(auth.instanceUrl, auth.token, scope, id, slug, args.summary);
3794
- return `Session log updated: ${slug}`;
3795
- } catch (err2) {
3796
- return `Error logging session: ${err2.message}`;
3797
- }
3798
- }
3799
3786
  return `Error logging session: ${err.message}`;
3800
3787
  }
3801
3788
  }
@@ -3925,17 +3912,26 @@ ${draft.content}`;
3925
3912
  const { scope, id } = resolveScope2(args);
3926
3913
  const prefix = args.draft ? DRAFTS_PREFIX : SKILLS_PREFIX;
3927
3914
  const slug = `${prefix}/${args.name}`;
3928
- try {
3929
- await updateWikiPage(auth.instanceUrl, auth.token, scope, id, slug, args.content);
3930
- return `Updated ${args.draft ? "draft " : ""}skill: ${args.name}`;
3931
- } catch {
3915
+ const label = args.draft ? "draft " : "";
3916
+ for (let attempt = 0; attempt < 3; attempt++) {
3932
3917
  try {
3933
- await createWikiPage(auth.instanceUrl, auth.token, scope, id, slug, args.content);
3934
- return `Created ${args.draft ? "draft " : ""}skill: ${args.name}`;
3935
- } catch (err) {
3936
- return `Error saving skill: ${err.message}`;
3918
+ await updateWikiPage(auth.instanceUrl, auth.token, scope, id, slug, args.content);
3919
+ return `Updated ${label}skill: ${args.name}`;
3920
+ } catch {
3921
+ try {
3922
+ await createWikiPage(auth.instanceUrl, auth.token, scope, id, slug, args.content);
3923
+ return `Created ${label}skill: ${args.name}`;
3924
+ } catch (err) {
3925
+ const msg = err.message ?? "";
3926
+ if (msg.includes("Duplicate page") || msg.includes("reference update")) {
3927
+ await new Promise((r) => setTimeout(r, 1e3 * (attempt + 1)));
3928
+ continue;
3929
+ }
3930
+ return `Error saving skill: ${msg}`;
3931
+ }
3937
3932
  }
3938
3933
  }
3934
+ return `Error saving skill: failed after 3 retries`;
3939
3935
  }
3940
3936
  }),
3941
3937
  gitlab_skill_promote: (0, import_plugin6.tool)({