opencode-gitlab-plugin 3.0.1 → 3.1.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.
@@ -34201,6 +34201,65 @@ Examples:
34201
34201
 
34202
34202
  // src/tools/orbit.ts
34203
34203
  var z18 = tool.schema;
34204
+ var MAX_REL_TYPES = 10;
34205
+ var SCHEMA_CACHE_TTL_MS = 10 * 60 * 1e3;
34206
+ var schemaCache = /* @__PURE__ */ new Map();
34207
+ var schemaInflight = /* @__PURE__ */ new Map();
34208
+ async function loadOrbitSchema(client) {
34209
+ const key = process.env["GITLAB_INSTANCE_URL"] || "https://gitlab.com";
34210
+ const cached2 = schemaCache.get(key);
34211
+ if (cached2 && cached2.expiresAt > Date.now()) {
34212
+ return cached2.schema;
34213
+ }
34214
+ const inflight = schemaInflight.get(key);
34215
+ if (inflight) {
34216
+ return inflight;
34217
+ }
34218
+ const request = (async () => {
34219
+ try {
34220
+ const schema = await client.fetch("GET", "/orbit/schema");
34221
+ if (!schema || !Array.isArray(schema.edges)) {
34222
+ return void 0;
34223
+ }
34224
+ schemaCache.set(key, { schema, expiresAt: Date.now() + SCHEMA_CACHE_TTL_MS });
34225
+ return schema;
34226
+ } catch {
34227
+ return void 0;
34228
+ }
34229
+ })();
34230
+ schemaInflight.set(key, request);
34231
+ void request.finally(() => {
34232
+ if (schemaInflight.get(key) === request) {
34233
+ schemaInflight.delete(key);
34234
+ }
34235
+ });
34236
+ return request;
34237
+ }
34238
+ function deriveRelTypes(schema, entityType, preferred) {
34239
+ const touching = /* @__PURE__ */ new Set();
34240
+ for (const edge of schema.edges ?? []) {
34241
+ const touchesEntity = (edge.variants ?? []).some(
34242
+ (variant) => variant.source_type === entityType || variant.target_type === entityType
34243
+ );
34244
+ if (touchesEntity) {
34245
+ touching.add(edge.name);
34246
+ }
34247
+ }
34248
+ const rank = (name) => {
34249
+ const index = preferred.indexOf(name);
34250
+ return index === -1 ? preferred.length : index;
34251
+ };
34252
+ return [...touching].sort((a, b) => rank(a) - rank(b) || a.localeCompare(b)).slice(0, MAX_REL_TYPES);
34253
+ }
34254
+ async function defaultRelTypes(client, entityType) {
34255
+ const fallback = orbitRelTypes(entityType);
34256
+ const schema = await loadOrbitSchema(client);
34257
+ if (!schema) {
34258
+ return fallback;
34259
+ }
34260
+ const derived = deriveRelTypes(schema, entityType, fallback);
34261
+ return derived.length > 0 ? derived : fallback;
34262
+ }
34204
34263
  function orbitRelTypes(entityType) {
34205
34264
  switch (entityType) {
34206
34265
  case "MergeRequest":
@@ -34537,15 +34596,15 @@ then use that ID (e.g., 377844873). For epics, use the work_item_id.`,
34537
34596
  ),
34538
34597
  direction: z18.enum(["incoming", "outgoing", "both"]).optional().describe("Direction of relationships to traverse (default: both)"),
34539
34598
  rel_types: z18.array(z18.string()).optional().describe(
34540
- 'Relationship types to follow. Required by the API to bound the lookup; if omitted, a sensible default set for the entity type is used. The API caps this at 10 per selector, so more than 10 entries are truncated to the first 10 and the response includes a "warnings" field. See gitlab_orbit_schema for valid edge types.'
34599
+ 'Relationship types to follow. Required by the API to bound the lookup; if omitted, up to 10 edge types that touch the entity type are taken from gitlab_orbit_schema (with a built-in default set as fallback if the schema is unavailable). The API caps this at 10 per selector, so more than 10 entries are truncated to the first 10 and the response includes a "warnings" field. See gitlab_orbit_schema for valid edge types.'
34541
34600
  ),
34542
34601
  limit: z18.number().optional().describe("Maximum number of neighbors to return (default: 30)")
34543
34602
  },
34544
34603
  execute: async (args, _ctx) => {
34545
34604
  const client = getGitLabClient();
34546
34605
  const direction = args.direction || "both";
34547
- const requestedRelTypes = args.rel_types?.length ? args.rel_types : orbitRelTypes(args.entity_type);
34548
- const relTypes = requestedRelTypes.slice(0, 10);
34606
+ const requestedRelTypes = args.rel_types?.length ? args.rel_types : await defaultRelTypes(client, args.entity_type);
34607
+ const relTypes = requestedRelTypes.slice(0, MAX_REL_TYPES);
34549
34608
  const warnings = requestedRelTypes.length > relTypes.length ? [`rel_types truncated to 10 (got ${requestedRelTypes.length})`] : [];
34550
34609
  const queryObj = {
34551
34610
  query_type: "neighbors",
@@ -34668,7 +34727,7 @@ async function main() {
34668
34727
  `);
34669
34728
  process.exit(1);
34670
34729
  }
34671
- const version2 = true ? "3.0.1" : "0.0.0";
34730
+ const version2 = true ? "3.1.0" : "0.0.0";
34672
34731
  const server = new McpServer({ name: "gitlab", version: version2 });
34673
34732
  adaptToolsToMcp(server, mcpTools);
34674
34733
  const transport = new StdioServerTransport();