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.
- package/CHANGELOG.md +7 -0
- package/dist/index.js +62 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.cjs +63 -4
- package/dist/mcp-server.cjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [3.1.0](https://gitlab.com/vglafirov/opencode-gitlab-plugin/compare/v3.0.1...v3.1.0) (2026-10-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### ✨ Features
|
|
9
|
+
|
|
10
|
+
* **orbit:** derive neighbors default rel_types from the schema ([567a114](https://gitlab.com/vglafirov/opencode-gitlab-plugin/commit/567a114be061e6fc5e6d59984c497f8621a9a582))
|
|
11
|
+
|
|
5
12
|
## [3.0.1](https://gitlab.com/vglafirov/opencode-gitlab-plugin/compare/v3.0.0...v3.0.1) (2026-10-06)
|
|
6
13
|
|
|
7
14
|
|
package/dist/index.js
CHANGED
|
@@ -5450,6 +5450,65 @@ Examples:
|
|
|
5450
5450
|
// src/tools/orbit.ts
|
|
5451
5451
|
import { tool as tool18 } from "@opencode-ai/plugin";
|
|
5452
5452
|
var z18 = tool18.schema;
|
|
5453
|
+
var MAX_REL_TYPES = 10;
|
|
5454
|
+
var SCHEMA_CACHE_TTL_MS = 10 * 60 * 1e3;
|
|
5455
|
+
var schemaCache = /* @__PURE__ */ new Map();
|
|
5456
|
+
var schemaInflight = /* @__PURE__ */ new Map();
|
|
5457
|
+
async function loadOrbitSchema(client) {
|
|
5458
|
+
const key = process.env["GITLAB_INSTANCE_URL"] || "https://gitlab.com";
|
|
5459
|
+
const cached = schemaCache.get(key);
|
|
5460
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
5461
|
+
return cached.schema;
|
|
5462
|
+
}
|
|
5463
|
+
const inflight = schemaInflight.get(key);
|
|
5464
|
+
if (inflight) {
|
|
5465
|
+
return inflight;
|
|
5466
|
+
}
|
|
5467
|
+
const request = (async () => {
|
|
5468
|
+
try {
|
|
5469
|
+
const schema = await client.fetch("GET", "/orbit/schema");
|
|
5470
|
+
if (!schema || !Array.isArray(schema.edges)) {
|
|
5471
|
+
return void 0;
|
|
5472
|
+
}
|
|
5473
|
+
schemaCache.set(key, { schema, expiresAt: Date.now() + SCHEMA_CACHE_TTL_MS });
|
|
5474
|
+
return schema;
|
|
5475
|
+
} catch {
|
|
5476
|
+
return void 0;
|
|
5477
|
+
}
|
|
5478
|
+
})();
|
|
5479
|
+
schemaInflight.set(key, request);
|
|
5480
|
+
void request.finally(() => {
|
|
5481
|
+
if (schemaInflight.get(key) === request) {
|
|
5482
|
+
schemaInflight.delete(key);
|
|
5483
|
+
}
|
|
5484
|
+
});
|
|
5485
|
+
return request;
|
|
5486
|
+
}
|
|
5487
|
+
function deriveRelTypes(schema, entityType, preferred) {
|
|
5488
|
+
const touching = /* @__PURE__ */ new Set();
|
|
5489
|
+
for (const edge of schema.edges ?? []) {
|
|
5490
|
+
const touchesEntity = (edge.variants ?? []).some(
|
|
5491
|
+
(variant) => variant.source_type === entityType || variant.target_type === entityType
|
|
5492
|
+
);
|
|
5493
|
+
if (touchesEntity) {
|
|
5494
|
+
touching.add(edge.name);
|
|
5495
|
+
}
|
|
5496
|
+
}
|
|
5497
|
+
const rank = (name) => {
|
|
5498
|
+
const index = preferred.indexOf(name);
|
|
5499
|
+
return index === -1 ? preferred.length : index;
|
|
5500
|
+
};
|
|
5501
|
+
return [...touching].sort((a, b) => rank(a) - rank(b) || a.localeCompare(b)).slice(0, MAX_REL_TYPES);
|
|
5502
|
+
}
|
|
5503
|
+
async function defaultRelTypes(client, entityType) {
|
|
5504
|
+
const fallback = orbitRelTypes(entityType);
|
|
5505
|
+
const schema = await loadOrbitSchema(client);
|
|
5506
|
+
if (!schema) {
|
|
5507
|
+
return fallback;
|
|
5508
|
+
}
|
|
5509
|
+
const derived = deriveRelTypes(schema, entityType, fallback);
|
|
5510
|
+
return derived.length > 0 ? derived : fallback;
|
|
5511
|
+
}
|
|
5453
5512
|
function orbitRelTypes(entityType) {
|
|
5454
5513
|
switch (entityType) {
|
|
5455
5514
|
case "MergeRequest":
|
|
@@ -5786,15 +5845,15 @@ then use that ID (e.g., 377844873). For epics, use the work_item_id.`,
|
|
|
5786
5845
|
),
|
|
5787
5846
|
direction: z18.enum(["incoming", "outgoing", "both"]).optional().describe("Direction of relationships to traverse (default: both)"),
|
|
5788
5847
|
rel_types: z18.array(z18.string()).optional().describe(
|
|
5789
|
-
'Relationship types to follow. Required by the API to bound the lookup; if omitted, a
|
|
5848
|
+
'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.'
|
|
5790
5849
|
),
|
|
5791
5850
|
limit: z18.number().optional().describe("Maximum number of neighbors to return (default: 30)")
|
|
5792
5851
|
},
|
|
5793
5852
|
execute: async (args, _ctx) => {
|
|
5794
5853
|
const client = getGitLabClient();
|
|
5795
5854
|
const direction = args.direction || "both";
|
|
5796
|
-
const requestedRelTypes = args.rel_types?.length ? args.rel_types :
|
|
5797
|
-
const relTypes = requestedRelTypes.slice(0,
|
|
5855
|
+
const requestedRelTypes = args.rel_types?.length ? args.rel_types : await defaultRelTypes(client, args.entity_type);
|
|
5856
|
+
const relTypes = requestedRelTypes.slice(0, MAX_REL_TYPES);
|
|
5798
5857
|
const warnings = requestedRelTypes.length > relTypes.length ? [`rel_types truncated to 10 (got ${requestedRelTypes.length})`] : [];
|
|
5799
5858
|
const queryObj = {
|
|
5800
5859
|
query_type: "neighbors",
|