opencode-gitlab-dap 1.8.2 → 1.8.3

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
@@ -3637,12 +3637,43 @@ async function safeRead(instanceUrl, token, scope, id, slug) {
3637
3637
  return null;
3638
3638
  }
3639
3639
  }
3640
+ var MAX_RETRIES = 3;
3641
+ var RETRY_DELAY_MS = 1e3;
3642
+ async function sleep2(ms) {
3643
+ return new Promise((resolve) => setTimeout(resolve, ms));
3644
+ }
3640
3645
  async function appendToPage(instanceUrl, token, scope, id, slug, newContent) {
3646
+ for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3647
+ const existing2 = await safeRead(instanceUrl, token, scope, id, slug);
3648
+ if (existing2 !== null) {
3649
+ try {
3650
+ await updateWikiPage(instanceUrl, token, scope, id, slug, existing2 + "\n\n" + newContent);
3651
+ return;
3652
+ } catch (err) {
3653
+ if (attempt < MAX_RETRIES - 1 && err.message?.includes("reference update")) {
3654
+ await sleep2(RETRY_DELAY_MS * (attempt + 1));
3655
+ continue;
3656
+ }
3657
+ throw err;
3658
+ }
3659
+ } else {
3660
+ try {
3661
+ await createWikiPage(instanceUrl, token, scope, id, slug, newContent);
3662
+ return;
3663
+ } catch (err) {
3664
+ if (err.message?.includes("Duplicate page") || err.message?.includes("reference update")) {
3665
+ await sleep2(RETRY_DELAY_MS * (attempt + 1));
3666
+ continue;
3667
+ }
3668
+ throw err;
3669
+ }
3670
+ }
3671
+ }
3641
3672
  const existing = await safeRead(instanceUrl, token, scope, id, slug);
3642
3673
  if (existing !== null) {
3643
3674
  await updateWikiPage(instanceUrl, token, scope, id, slug, existing + "\n\n" + newContent);
3644
3675
  } else {
3645
- await createWikiPage(instanceUrl, token, scope, id, slug, newContent);
3676
+ throw new Error(`Failed to append to ${slug} after ${MAX_RETRIES} retries`);
3646
3677
  }
3647
3678
  }
3648
3679
  function validateProjectId(projectId) {
@@ -3784,20 +3815,32 @@ ${args.content}`;
3784
3815
  const { scope, id } = resolveScope(args);
3785
3816
  const date = today();
3786
3817
  const slug = `${PREFIX}/memory/sessions/${date}-${slugify(args.title)}`;
3787
- try {
3788
- await createWikiPage(auth.instanceUrl, auth.token, scope, id, slug, args.summary);
3789
- return `Session logged: ${slug}`;
3790
- } 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}`;
3818
+ for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3819
+ try {
3820
+ await createWikiPage(auth.instanceUrl, auth.token, scope, id, slug, args.summary);
3821
+ return `Session logged: ${slug}`;
3822
+ } catch (err) {
3823
+ const msg = err.message ?? "";
3824
+ if (msg.includes("Duplicate page") || msg.includes("already exists") || msg.includes("422")) {
3825
+ try {
3826
+ await updateWikiPage(auth.instanceUrl, auth.token, scope, id, slug, args.summary);
3827
+ return `Session log updated: ${slug}`;
3828
+ } catch (err2) {
3829
+ if (attempt < MAX_RETRIES - 1 && err2.message?.includes("reference update")) {
3830
+ await sleep2(RETRY_DELAY_MS * (attempt + 1));
3831
+ continue;
3832
+ }
3833
+ return `Error logging session: ${err2.message}`;
3834
+ }
3835
+ }
3836
+ if (attempt < MAX_RETRIES - 1 && msg.includes("reference update")) {
3837
+ await sleep2(RETRY_DELAY_MS * (attempt + 1));
3838
+ continue;
3797
3839
  }
3840
+ return `Error logging session: ${msg}`;
3798
3841
  }
3799
- return `Error logging session: ${err.message}`;
3800
3842
  }
3843
+ return `Error logging session: failed after ${MAX_RETRIES} retries`;
3801
3844
  }
3802
3845
  })
3803
3846
  };
@@ -3925,17 +3968,26 @@ ${draft.content}`;
3925
3968
  const { scope, id } = resolveScope2(args);
3926
3969
  const prefix = args.draft ? DRAFTS_PREFIX : SKILLS_PREFIX;
3927
3970
  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 {
3971
+ const label = args.draft ? "draft " : "";
3972
+ for (let attempt = 0; attempt < 3; attempt++) {
3932
3973
  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}`;
3974
+ await updateWikiPage(auth.instanceUrl, auth.token, scope, id, slug, args.content);
3975
+ return `Updated ${label}skill: ${args.name}`;
3976
+ } catch {
3977
+ try {
3978
+ await createWikiPage(auth.instanceUrl, auth.token, scope, id, slug, args.content);
3979
+ return `Created ${label}skill: ${args.name}`;
3980
+ } catch (err) {
3981
+ const msg = err.message ?? "";
3982
+ if (msg.includes("Duplicate page") || msg.includes("reference update")) {
3983
+ await new Promise((r) => setTimeout(r, 1e3 * (attempt + 1)));
3984
+ continue;
3985
+ }
3986
+ return `Error saving skill: ${msg}`;
3987
+ }
3937
3988
  }
3938
3989
  }
3990
+ return `Error saving skill: failed after 3 retries`;
3939
3991
  }
3940
3992
  }),
3941
3993
  gitlab_skill_promote: (0, import_plugin6.tool)({