@unified-product-graph/cloud-server 0.9.15 → 0.9.17

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
@@ -1332,6 +1332,59 @@ var getChanges = async (args, { store }) => {
1332
1332
  return text(JSON.stringify({ changes: filtered, total: filtered.length }, null, 2));
1333
1333
  };
1334
1334
 
1335
+ // src/tools/tree.ts
1336
+ import { getTreePattern, UPG_TREE_PATTERNS } from "@unified-product-graph/core";
1337
+ import { assembleTree } from "@unified-product-graph/sdk";
1338
+ var getTree = async (args, { store }) => {
1339
+ if (!args.product_id) return textError("Missing required parameter: product_id");
1340
+ const productId = args.product_id;
1341
+ const patternId = args.pattern;
1342
+ if (!patternId) {
1343
+ return textError(
1344
+ `Missing required parameter: pattern. One of: ${UPG_TREE_PATTERNS.map((p) => p.id).join(", ")}.`
1345
+ );
1346
+ }
1347
+ const pattern = getTreePattern(patternId);
1348
+ if (!pattern) {
1349
+ return textError(
1350
+ `Unknown tree pattern: "${patternId}". Valid patterns: ${UPG_TREE_PATTERNS.map((p) => p.id).join(", ")}.`
1351
+ );
1352
+ }
1353
+ const includeProperties = Array.isArray(args.include_properties) ? args.include_properties : void 0;
1354
+ const allNodes = await store.getAllNodes(productId);
1355
+ const allEdges = await store.getAllEdges(productId);
1356
+ const nodeById = new Map(allNodes.map((n) => [n.id, n]));
1357
+ const edgesByNode = /* @__PURE__ */ new Map();
1358
+ for (const e of allEdges) {
1359
+ let src = edgesByNode.get(e.source);
1360
+ if (!src) {
1361
+ src = [];
1362
+ edgesByNode.set(e.source, src);
1363
+ }
1364
+ src.push(e);
1365
+ if (e.target !== e.source) {
1366
+ let tgt = edgesByNode.get(e.target);
1367
+ if (!tgt) {
1368
+ tgt = [];
1369
+ edgesByNode.set(e.target, tgt);
1370
+ }
1371
+ tgt.push(e);
1372
+ }
1373
+ }
1374
+ const reader = {
1375
+ getNode: (id) => nodeById.get(id),
1376
+ getAllNodes: () => allNodes,
1377
+ getEdgesForNode: (id) => edgesByNode.get(id) ?? []
1378
+ };
1379
+ const result = assembleTree(reader, pattern, {
1380
+ from_id: args.from_id,
1381
+ depth: args.depth,
1382
+ include_properties: includeProperties,
1383
+ max_nodes: args.max_nodes
1384
+ });
1385
+ return text(JSON.stringify(result, null, 2));
1386
+ };
1387
+
1335
1388
  // src/tools/nodes.ts
1336
1389
  import { getLifecycleForType as getLifecycleForType2, resolveEntityType as resolveEntityType2, UnknownEntityTypeError as UnknownEntityTypeError2 } from "@unified-product-graph/core";
1337
1390
  import {
@@ -2084,6 +2137,9 @@ import {
2084
2137
  UPG_REGIONS,
2085
2138
  UPG_REGION_MAP,
2086
2139
  UPG_REGION_COUNT,
2140
+ UPG_AREA_TAXONOMY,
2141
+ getCoverageKeysForRegion,
2142
+ getBusinessAreasForRegion,
2087
2143
  UPG_LENSES,
2088
2144
  UPG_TYPE_LABELS,
2089
2145
  UPG_TYPE_LABELS_MAP,
@@ -2358,10 +2414,12 @@ var listRegions = () => {
2358
2414
  composes_atomic_domains: r.composes_atomic_domains,
2359
2415
  entity_count: r.entities.length,
2360
2416
  intra_edge_count: r.intra_edges.length,
2361
- boundary_edge_count: r.boundary_edges.length
2417
+ boundary_edge_count: r.boundary_edges.length,
2418
+ coverage_keys: getCoverageKeysForRegion(r.id),
2419
+ business_areas: getBusinessAreasForRegion(r.id)
2362
2420
  }));
2363
2421
  return text(
2364
- JSON.stringify({ count: UPG_REGION_COUNT, regions }, null, 2)
2422
+ JSON.stringify({ count: UPG_REGION_COUNT, regions, area_taxonomy: UPG_AREA_TAXONOMY }, null, 2)
2365
2423
  );
2366
2424
  };
2367
2425
  var getRegion = (args) => {
@@ -2369,7 +2427,11 @@ var getRegion = (args) => {
2369
2427
  if (!id) return textError("Missing required parameter: id");
2370
2428
  const region = UPG_REGION_MAP[id];
2371
2429
  if (!region) return textError(`Unknown region id: ${id}`);
2372
- return text(JSON.stringify(region, null, 2));
2430
+ return text(JSON.stringify({
2431
+ ...region,
2432
+ coverage_keys: getCoverageKeysForRegion(id),
2433
+ business_areas: getBusinessAreasForRegion(id)
2434
+ }, null, 2));
2373
2435
  };
2374
2436
  var getRegionForEntity = (args) => {
2375
2437
  const entityType = args.entity_type;
@@ -4235,6 +4297,46 @@ var TOOL_DEFINITIONS = [
4235
4297
  ]
4236
4298
  }
4237
4299
  },
4300
+ {
4301
+ "name": "get_tree",
4302
+ "description": "Assemble a canonical tree pattern (ost, okr, user, product, validation, strategy, feature_areas) from the product graph. Walks the pattern's type-driven child map over the live graph (drift-proof, follows whatever edge wired each parent to a child of the expected type), roots at the pattern anchor with fallback, and reports structural gaps. Returns nested data, not rendered text.",
4303
+ "inputSchema": {
4304
+ "type": "object",
4305
+ "properties": {
4306
+ "product_id": {
4307
+ "type": "string",
4308
+ "description": "The product ID"
4309
+ },
4310
+ "pattern": {
4311
+ "type": "string",
4312
+ "description": "Tree pattern id: ost, okr, user, product, validation, strategy, feature_areas"
4313
+ },
4314
+ "from_id": {
4315
+ "type": "string",
4316
+ "description": "Explicit root node id. Defaults to the pattern's canonical anchor type."
4317
+ },
4318
+ "depth": {
4319
+ "type": "number",
4320
+ "description": "Max levels. Defaults to the pattern's natural depth."
4321
+ },
4322
+ "include_properties": {
4323
+ "type": "array",
4324
+ "items": {
4325
+ "type": "string"
4326
+ },
4327
+ "description": "Node property keys to inline on each tree node."
4328
+ },
4329
+ "max_nodes": {
4330
+ "type": "number",
4331
+ "description": "Cap on assembled nodes. The tree is summarised (stats.truncated) rather than silently cut."
4332
+ }
4333
+ },
4334
+ "required": [
4335
+ "product_id",
4336
+ "pattern"
4337
+ ]
4338
+ }
4339
+ },
4238
4340
  {
4239
4341
  "name": "get_graph_digest",
4240
4342
  "description": "Pre-computed graph analytics: counts, health metrics, chain completeness, business area coverage, lifecycle balance. ~500 tokens vs ~5-8K for equivalent manual fetches.",
@@ -5221,6 +5323,7 @@ var HANDLERS = {
5221
5323
  get_product_context: getProductContext,
5222
5324
  get_graph_digest: getGraphDigest,
5223
5325
  query,
5326
+ get_tree: getTree,
5224
5327
  get_changes: getChanges,
5225
5328
  list_nodes: listNodes,
5226
5329
  export_upg_document: exportUpgDocument,