opencode-gitlab-dap 1.8.4 → 1.10.0

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
@@ -2090,7 +2090,47 @@ This project may have persistent memory and skills available via knowledge tools
2090
2090
  Use gitlab_memory_load to check for existing project context (facts, decisions, patterns).
2091
2091
  Use gitlab_skill_list to discover available task-specific skills.
2092
2092
  When you learn something new about the project, use gitlab_memory_record to preserve it.
2093
- When you complete a significant task, consider using gitlab_memory_log_session to log learnings.`;
2093
+ When you complete a significant task, consider using gitlab_memory_log_session to log learnings.
2094
+
2095
+ ### Bootstrap Project Memory
2096
+ When the user says "bootstrap project memory", "initialize memory", or "build project knowledge":
2097
+ 1. FIRST: Determine the project path by running \`run_git_command("remote", ["-v"])\` and extracting the path from the git remote URL (e.g., "git@gitlab.com:my-group/my-project.git" \u2192 "my-group/my-project"). NEVER guess the project path.
2098
+ 2. Call gitlab_memory_load with the extracted project path to check if memory already exists.
2099
+ 3. **If memory is empty** \u2014 do a full bootstrap:
2100
+ a. Gather project knowledge:
2101
+ - Read the project README, key config files, and codebase structure (use file/repo tools).
2102
+ - Fetch project details via gitlab_get_project.
2103
+ - List open issues (gitlab_list_issues, state=opened, limit=20).
2104
+ - List open merge requests (gitlab_list_merge_requests, state=opened, limit=10).
2105
+ - Check recent pipelines (gitlab_list_pipelines, limit=5).
2106
+ - List project members (gitlab_list_project_members).
2107
+ b. Record each category as separate memory entries using gitlab_memory_record:
2108
+ - fact: project overview (name, purpose, tech stack, language, dependencies)
2109
+ - fact: architecture and codebase structure (key files, modules, patterns)
2110
+ - fact: CI/CD pipeline configuration (stages, jobs, deployment targets)
2111
+ - fact: open issues summary (count, key issues, labels)
2112
+ - fact: open MRs summary (count, key MRs, review status)
2113
+ - fact: team and contributors
2114
+ - pattern: development workflow observations (branching, review process, release cycle)
2115
+ c. Log a session with gitlab_memory_log_session summarizing the bootstrap.
2116
+ 4. **If memory exists** \u2014 do a smart refresh:
2117
+ a. Show a brief summary of existing memory to the user (how many facts, decisions, patterns, date range).
2118
+ b. Gather CURRENT project state (same data as step 3a).
2119
+ c. Compare current state with each stored fact. For each record:
2120
+ - If the fact is still accurate \u2192 keep it (no action).
2121
+ - If the fact is outdated \u2192 call gitlab_memory_update(slug, corrected_content).
2122
+ - If the fact is no longer relevant (e.g., closed issue) \u2192 call gitlab_memory_archive(slug, reason).
2123
+ - If something new is found that's not in memory \u2192 call gitlab_memory_record.
2124
+ d. Log a session with gitlab_memory_log_session summarizing the refresh (what was updated, archived, added).
2125
+
2126
+ ### Memory Consolidation
2127
+ When the user says "consolidate memory", "clean up memory", or "review memory":
2128
+ 1. Call gitlab_memory_consolidate to load all records with review instructions.
2129
+ 2. Follow the returned instructions to identify stale, duplicate, or contradictory entries.
2130
+ 3. Use gitlab_memory_update, gitlab_memory_archive, and gitlab_memory_record as needed.
2131
+ 4. Log a consolidation session.
2132
+
2133
+ IMPORTANT: Always extract the project path from git remote \u2014 never guess it. Fire multiple gitlab_memory_record calls in parallel \u2014 each creates its own page, so parallel writes are safe.`;
2094
2134
 
2095
2135
  // src/hooks.ts
2096
2136
  function buildFlowSubagentPrompt(flow, projectPath, projectUrl) {
@@ -3443,17 +3483,20 @@ async function searchWikiPages(instanceUrl, token, scope, id, query) {
3443
3483
  // src/tools/memory-tools.ts
3444
3484
  var z5 = tool5.schema;
3445
3485
  var PREFIX = "agents";
3486
+ var ARCHIVE_DIR = `${PREFIX}/memory/archive`;
3446
3487
  var MEMORY_DIRS = {
3447
3488
  all: [`${PREFIX}/memory/facts`, `${PREFIX}/memory/decisions`, `${PREFIX}/memory/patterns`],
3448
3489
  facts: [`${PREFIX}/memory/facts`],
3449
3490
  decisions: [`${PREFIX}/memory/decisions`],
3450
- patterns: [`${PREFIX}/memory/patterns`]
3491
+ patterns: [`${PREFIX}/memory/patterns`],
3492
+ archive: [ARCHIVE_DIR]
3451
3493
  };
3452
3494
  var RECORD_DIR = {
3453
3495
  fact: `${PREFIX}/memory/facts`,
3454
3496
  decision: `${PREFIX}/memory/decisions`,
3455
3497
  pattern: `${PREFIX}/memory/patterns`
3456
3498
  };
3499
+ var PROJECT_ID_DESC = 'FULL project path with namespace (e.g., "gitlab-org/gitlab"). Must contain a slash. Never use just the project name.';
3457
3500
  function today() {
3458
3501
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
3459
3502
  }
@@ -3486,12 +3529,12 @@ function makeMemoryTools(ctx) {
3486
3529
  }
3487
3530
  return {
3488
3531
  gitlab_memory_load: tool5({
3489
- description: "Load project memory to understand context, known facts, past decisions, and observed patterns.\nUse this at the start of complex tasks to check what is already known about the project.\nReturns accumulated knowledge from previous sessions.",
3532
+ description: "Load project memory to understand context, known facts, past decisions, and observed patterns.\nUse this at the start of complex tasks to check what is already known about the project.\nReturns accumulated knowledge from previous sessions.\nEach entry includes its slug (page path) which can be used with gitlab_memory_update or gitlab_memory_archive.",
3490
3533
  args: {
3491
- project_id: z5.string().describe(
3492
- 'FULL project path with namespace (e.g., "gitlab-org/gitlab"). Must contain a slash. Never use just the project name.'
3534
+ project_id: z5.string().describe(PROJECT_ID_DESC),
3535
+ type: z5.enum(["all", "facts", "decisions", "patterns", "archive"]).optional().describe(
3536
+ 'Which memory to load: "all" (default), "facts", "decisions", "patterns", or "archive" (retired entries)'
3493
3537
  ),
3494
- type: z5.enum(["all", "facts", "decisions", "patterns"]).optional().describe('Which memory to load: "all" (default), "facts", "decisions", or "patterns"'),
3495
3538
  scope: z5.enum(["projects", "groups"]).optional().describe("Scope (default: projects)"),
3496
3539
  group_id: z5.string().optional().describe("Group path (required when scope is groups)")
3497
3540
  },
@@ -3514,7 +3557,8 @@ function makeMemoryTools(ctx) {
3514
3557
  const label = dir.split("/").pop();
3515
3558
  const pages = allPages.filter((p) => p.slug.startsWith(dir + "/") && p.content);
3516
3559
  if (pages.length === 0) continue;
3517
- const entries = pages.map((p) => p.content).join("\n\n---\n\n");
3560
+ const entries = pages.map((p) => `### ${p.slug}
3561
+ ${p.content}`).join("\n\n---\n\n");
3518
3562
  sections.push(
3519
3563
  `## ${label.charAt(0).toUpperCase() + label.slice(1)} (${pages.length})
3520
3564
 
@@ -3532,9 +3576,7 @@ ${entries}`
3532
3576
  gitlab_memory_record: tool5({
3533
3577
  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.",
3534
3578
  args: {
3535
- project_id: z5.string().describe(
3536
- 'FULL project path with namespace (e.g., "gitlab-org/gitlab"). Must contain a slash. Never use just the project name.'
3537
- ),
3579
+ project_id: z5.string().describe(PROJECT_ID_DESC),
3538
3580
  type: z5.enum(["fact", "decision", "pattern"]).describe("Type of knowledge to record"),
3539
3581
  content: z5.string().describe("The knowledge to record (markdown)"),
3540
3582
  scope: z5.enum(["projects", "groups"]).optional().describe("Scope (default: projects)"),
@@ -3560,12 +3602,159 @@ ${entries}`
3560
3602
  }
3561
3603
  }
3562
3604
  }),
3605
+ gitlab_memory_update: tool5({
3606
+ description: "Update an existing memory record with new content.\nUse this to correct stale facts, update issue counts, or refine decisions.\nThe slug is the page path shown in gitlab_memory_load output (e.g., agents/memory/facts/2026-04-05-project-overview).",
3607
+ args: {
3608
+ project_id: z5.string().describe(PROJECT_ID_DESC),
3609
+ slug: z5.string().describe(
3610
+ 'Page slug from gitlab_memory_load output (e.g., "agents/memory/facts/2026-04-05-project-overview")'
3611
+ ),
3612
+ content: z5.string().describe("New content to replace the existing record (markdown)"),
3613
+ scope: z5.enum(["projects", "groups"]).optional().describe("Scope (default: projects)"),
3614
+ group_id: z5.string().optional().describe("Group path (required when scope is groups)")
3615
+ },
3616
+ execute: async (args) => {
3617
+ const auth = authAndValidate(args.project_id);
3618
+ const { scope, id } = resolveScope(args);
3619
+ try {
3620
+ await getWikiPage(auth.instanceUrl, auth.token, scope, id, args.slug);
3621
+ } catch {
3622
+ return `Memory record not found: ${args.slug}. Use gitlab_memory_load to see available records.`;
3623
+ }
3624
+ const date = today();
3625
+ const header = `*Updated: ${date}*
3626
+
3627
+ `;
3628
+ try {
3629
+ await updateWikiPage(
3630
+ auth.instanceUrl,
3631
+ auth.token,
3632
+ scope,
3633
+ id,
3634
+ args.slug,
3635
+ header + args.content
3636
+ );
3637
+ return `Updated memory record: ${args.slug}`;
3638
+ } catch (err) {
3639
+ return `Error updating memory: ${err.message}`;
3640
+ }
3641
+ }
3642
+ }),
3643
+ gitlab_memory_archive: tool5({
3644
+ description: "Archive an outdated memory record.\nMoves the record to the archive directory so it is no longer loaded by default.\nArchived records are still searchable via gitlab_memory_recall and loadable via gitlab_memory_load(type='archive').\nUse this for facts that are no longer true, decisions that were reversed, or patterns that stopped occurring.",
3645
+ args: {
3646
+ project_id: z5.string().describe(PROJECT_ID_DESC),
3647
+ slug: z5.string().describe(
3648
+ 'Page slug to archive (e.g., "agents/memory/facts/2026-04-05-open-issues-summary")'
3649
+ ),
3650
+ reason: z5.string().optional().describe(
3651
+ 'Why this record is being archived (e.g., "issue was fixed", "no longer relevant")'
3652
+ ),
3653
+ scope: z5.enum(["projects", "groups"]).optional().describe("Scope (default: projects)"),
3654
+ group_id: z5.string().optional().describe("Group path (required when scope is groups)")
3655
+ },
3656
+ execute: async (args) => {
3657
+ const auth = authAndValidate(args.project_id);
3658
+ const { scope, id } = resolveScope(args);
3659
+ let originalContent;
3660
+ try {
3661
+ const page = await getWikiPage(auth.instanceUrl, auth.token, scope, id, args.slug);
3662
+ originalContent = page.content;
3663
+ } catch {
3664
+ return `Memory record not found: ${args.slug}. Use gitlab_memory_load to see available records.`;
3665
+ }
3666
+ const date = today();
3667
+ const suffix = args.slug.split("/").slice(3).join("/");
3668
+ const archiveSlug = `${ARCHIVE_DIR}/${suffix}`;
3669
+ const reasonLine = args.reason ? `
3670
+ *Reason: ${args.reason}*` : "";
3671
+ const archiveHeader = `*Archived: ${date} | Original: ${args.slug}*${reasonLine}
3672
+
3673
+ `;
3674
+ try {
3675
+ await createWikiPage(
3676
+ auth.instanceUrl,
3677
+ auth.token,
3678
+ scope,
3679
+ id,
3680
+ archiveSlug,
3681
+ archiveHeader + originalContent
3682
+ );
3683
+ await deleteWikiPage(auth.instanceUrl, auth.token, scope, id, args.slug);
3684
+ return `Archived: ${args.slug} \u2192 ${archiveSlug}`;
3685
+ } catch (err) {
3686
+ return `Error archiving memory: ${err.message}`;
3687
+ }
3688
+ }
3689
+ }),
3690
+ gitlab_memory_consolidate: tool5({
3691
+ description: "Review all memory records and get consolidation instructions.\nLoads all records of the specified type and returns them with their slugs,\nalong with instructions to identify and fix stale, duplicate, or contradictory entries.\nUse this periodically to keep project memory clean and accurate.",
3692
+ args: {
3693
+ project_id: z5.string().describe(PROJECT_ID_DESC),
3694
+ type: z5.enum(["all", "facts", "decisions", "patterns"]).optional().describe(
3695
+ 'Which memory to consolidate: "all" (default), "facts", "decisions", or "patterns"'
3696
+ ),
3697
+ scope: z5.enum(["projects", "groups"]).optional().describe("Scope (default: projects)"),
3698
+ group_id: z5.string().optional().describe("Group path (required when scope is groups)")
3699
+ },
3700
+ execute: async (args) => {
3701
+ const auth = authAndValidate(args.project_id);
3702
+ const { scope, id } = resolveScope(args);
3703
+ const memType = args.type ?? "all";
3704
+ const dirs = MEMORY_DIRS[memType];
3705
+ if (!dirs) return `Unknown memory type: ${memType}`;
3706
+ try {
3707
+ const allPages = await listWikiPages(
3708
+ auth.instanceUrl,
3709
+ auth.token,
3710
+ scope,
3711
+ id,
3712
+ true
3713
+ );
3714
+ const entries = [];
3715
+ for (const dir of dirs) {
3716
+ const pages = allPages.filter((p) => p.slug.startsWith(dir + "/") && p.content);
3717
+ for (const p of pages) {
3718
+ entries.push({ slug: p.slug, content: p.content });
3719
+ }
3720
+ }
3721
+ if (entries.length === 0) return "No memory records to consolidate.";
3722
+ const listing = entries.map((e, i) => `### [${i + 1}] ${e.slug}
3723
+ ${e.content}`).join("\n\n---\n\n");
3724
+ const instructions = [
3725
+ `## Memory Consolidation Review`,
3726
+ ``,
3727
+ `Found **${entries.length} records** to review. For each record:`,
3728
+ ``,
3729
+ `1. **Stale?** \u2014 Is the information still current? If not, either:`,
3730
+ ` - Call \`gitlab_memory_update(slug, new_content)\` with corrected info`,
3731
+ ` - Call \`gitlab_memory_archive(slug, reason)\` if no longer relevant`,
3732
+ ``,
3733
+ `2. **Duplicate?** \u2014 Does another record cover the same information?`,
3734
+ ` - Keep the better one, archive the other`,
3735
+ ``,
3736
+ `3. **Contradictory?** \u2014 Do two records disagree?`,
3737
+ ` - Verify which is correct, update one, archive the other`,
3738
+ ``,
3739
+ `4. **Mergeable?** \u2014 Are there many small records about the same topic?`,
3740
+ ` - Create one consolidated record, archive the originals`,
3741
+ ``,
3742
+ `After reviewing, log a session with gitlab_memory_log_session summarizing what was cleaned up.`,
3743
+ ``,
3744
+ `---`,
3745
+ ``,
3746
+ listing
3747
+ ].join("\n");
3748
+ return instructions;
3749
+ } catch (err) {
3750
+ return `Error loading memory for consolidation: ${err.message}`;
3751
+ }
3752
+ }
3753
+ }),
3563
3754
  gitlab_memory_recall: tool5({
3564
3755
  description: "Search project knowledge for relevant information.\nSearches across all memory pages, session logs, and skills.\nUse this to check if something is already known before investigating.",
3565
3756
  args: {
3566
- project_id: z5.string().describe(
3567
- 'FULL project path with namespace (e.g., "gitlab-org/gitlab"). Must contain a slash. Never use just the project name.'
3568
- ),
3757
+ project_id: z5.string().describe(PROJECT_ID_DESC),
3569
3758
  query: z5.string().describe("What to search for"),
3570
3759
  scope: z5.enum(["projects", "groups"]).optional().describe("Scope (default: projects)"),
3571
3760
  group_id: z5.string().optional().describe("Group path (required when scope is groups)")
@@ -3595,9 +3784,7 @@ ${entries}`
3595
3784
  gitlab_memory_log_session: tool5({
3596
3785
  description: "Log a session summary including what was accomplished, what was learned, and any suggestions.\nUse this at the end of significant work sessions to preserve context for future sessions.",
3597
3786
  args: {
3598
- project_id: z5.string().describe(
3599
- 'FULL project path with namespace (e.g., "gitlab-org/gitlab"). Must contain a slash. Never use just the project name.'
3600
- ),
3787
+ project_id: z5.string().describe(PROJECT_ID_DESC),
3601
3788
  title: z5.string().describe('Brief session title (e.g., "fix-ai-gateway-healthcheck")'),
3602
3789
  summary: z5.string().describe(
3603
3790
  "Session summary in markdown (what happened, what was learned, what went wrong)"