@radicaltools/mcp 0.4.0 → 0.5.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/README.md +12 -8
- package/dist/{chunk-4TBML7BC.js → chunk-DSR2PAMW.js} +135 -2
- package/dist/{chunk-DPGHTQAV.js → chunk-ULUOEM3X.js} +1 -1
- package/dist/{dist-654J2OGG.js → dist-4NNGZXOU.js} +2 -2
- package/dist/{elkLayout-Y2SV7NDJ.js → elkLayout-YXJWF5QP.js} +2 -2
- package/dist/hub-catalogue/concern/concern-api-collections.radical +24 -12
- package/dist/hub-catalogue/concern/concern-api-errors.radical +26 -13
- package/dist/hub-catalogue/concern/concern-api-evolution.radical +26 -13
- package/dist/hub-catalogue/concern/concern-api-idempotency.radical +28 -14
- package/dist/hub-catalogue/concern/concern-api-resource-design.radical +24 -12
- package/dist/hub-catalogue/concern/concern-api-style-guide.radical +26 -13
- package/dist/hub-catalogue/concern/concern-architecture-style.radical +26 -13
- package/dist/hub-catalogue/concern/concern-audit-trail.radical +26 -13
- package/dist/hub-catalogue/concern/concern-authentication.radical +18 -9
- package/dist/hub-catalogue/concern/concern-authorization.radical +34 -17
- package/dist/hub-catalogue/concern/concern-availability.radical +20 -10
- package/dist/hub-catalogue/concern/concern-backend-stack.radical +16 -8
- package/dist/hub-catalogue/concern/concern-backup-recovery.radical +30 -15
- package/dist/hub-catalogue/concern/concern-caching.radical +28 -14
- package/dist/hub-catalogue/concern/concern-capacity.radical +18 -9
- package/dist/hub-catalogue/concern/concern-code-documentation.radical +32 -16
- package/dist/hub-catalogue/concern/concern-code-quality-gate.radical +30 -15
- package/dist/hub-catalogue/concern/concern-code-review-branching.radical +32 -16
- package/dist/hub-catalogue/concern/concern-code-style.radical +24 -12
- package/dist/hub-catalogue/concern/concern-communication-style.radical +28 -14
- package/dist/hub-catalogue/concern/concern-data-classification.radical +20 -10
- package/dist/hub-catalogue/concern/concern-data-consistency.radical +20 -10
- package/dist/hub-catalogue/concern/concern-data-store.radical +24 -12
- package/dist/hub-catalogue/concern/concern-decomposition.radical +28 -14
- package/dist/hub-catalogue/concern/concern-definition-of-done.radical +26 -13
- package/dist/hub-catalogue/concern/concern-delivery-metrics.radical +22 -11
- package/dist/hub-catalogue/concern/concern-dependency-hygiene.radical +28 -14
- package/dist/hub-catalogue/concern/concern-deployment.radical +24 -12
- package/dist/hub-catalogue/concern/concern-encryption.radical +28 -14
- package/dist/hub-catalogue/concern/concern-error-handling-logging.radical +28 -14
- package/dist/hub-catalogue/concern/concern-eu-dora.radical +26 -13
- package/dist/hub-catalogue/concern/concern-frontend-stack.radical +28 -14
- package/dist/hub-catalogue/concern/concern-incident-management.radical +26 -13
- package/dist/hub-catalogue/concern/concern-infrastructure.radical +34 -17
- package/dist/hub-catalogue/concern/concern-integration-resilience.radical +26 -13
- package/dist/hub-catalogue/concern/concern-messaging.radical +18 -9
- package/dist/hub-catalogue/concern/concern-module-boundaries.radical +18 -9
- package/dist/hub-catalogue/concern/concern-observability.radical +22 -11
- package/dist/hub-catalogue/concern/concern-operational-readiness.radical +28 -14
- package/dist/hub-catalogue/concern/concern-personal-data.radical +42 -21
- package/dist/hub-catalogue/concern/concern-quality-priorities.radical +24 -12
- package/dist/hub-catalogue/concern/concern-rate-limiting.radical +30 -15
- package/dist/hub-catalogue/concern/concern-release-versioning.radical +28 -14
- package/dist/hub-catalogue/concern/concern-retention.radical +28 -14
- package/dist/hub-catalogue/concern/concern-secrets.radical +32 -16
- package/dist/hub-catalogue/concern/concern-secure-coding.radical +28 -14
- package/dist/hub-catalogue/concern/concern-secure-development.radical +26 -13
- package/dist/hub-catalogue/concern/concern-security-detection.radical +22 -11
- package/dist/hub-catalogue/concern/concern-supply-chain.radical +28 -14
- package/dist/hub-catalogue/concern/concern-technical-debt.radical +30 -15
- package/dist/hub-catalogue/concern/concern-technology-lifecycle.radical +26 -13
- package/dist/hub-catalogue/concern/concern-tenant-isolation.radical +26 -13
- package/dist/hub-catalogue/concern/concern-test-strategy.radical +26 -13
- package/dist/hub-catalogue/concern/concern-threat-modelling.radical +26 -13
- package/dist/index.js +2330 -340
- package/dist/{pdfjs-QB56DH5V.js → pdfjs-7X3VKNRD.js} +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -57,10 +57,12 @@ import {
|
|
|
57
57
|
newPseudostateKind,
|
|
58
58
|
nodeTypeSize,
|
|
59
59
|
normalizeViewFolder,
|
|
60
|
+
notedPlacesOnly,
|
|
60
61
|
outgoingTransitionCount,
|
|
61
62
|
pinnedNodeIds,
|
|
62
63
|
placeNewNode,
|
|
63
64
|
placeOf,
|
|
65
|
+
placeUnplaced,
|
|
64
66
|
projectToVisibleGraph,
|
|
65
67
|
propertyKeyProblem,
|
|
66
68
|
refIds,
|
|
@@ -81,13 +83,13 @@ import {
|
|
|
81
83
|
viewShowsEveryNode,
|
|
82
84
|
wikiDepthOf,
|
|
83
85
|
withCanvasPositions
|
|
84
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-DSR2PAMW.js";
|
|
85
87
|
import {
|
|
86
88
|
__commonJS,
|
|
87
89
|
__toESM,
|
|
88
90
|
define_RADICAL_BUILD_default,
|
|
89
91
|
init_define_RADICAL_BUILD
|
|
90
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-ULUOEM3X.js";
|
|
91
93
|
|
|
92
94
|
// ../../node_modules/webcola/dist/src/powergraph.js
|
|
93
95
|
var require_powergraph = __commonJS({
|
|
@@ -1996,9 +1998,9 @@ var require_rectangle = __commonJS({
|
|
|
1996
1998
|
}
|
|
1997
1999
|
function generateConstraints(rs, vars, rect, minSep) {
|
|
1998
2000
|
var i, n = rs.length;
|
|
1999
|
-
var
|
|
2001
|
+
var N2 = 2 * n;
|
|
2000
2002
|
console.assert(vars.length >= n);
|
|
2001
|
-
var events = new Array(
|
|
2003
|
+
var events = new Array(N2);
|
|
2002
2004
|
for (i = 0; i < n; ++i) {
|
|
2003
2005
|
var r = rs[i];
|
|
2004
2006
|
var v = new Node(vars[i], r, rect.getCentre(r));
|
|
@@ -2008,7 +2010,7 @@ var require_rectangle = __commonJS({
|
|
|
2008
2010
|
events.sort(compareEvents);
|
|
2009
2011
|
var cs = new Array();
|
|
2010
2012
|
var scanline = makeRBTree();
|
|
2011
|
-
for (i = 0; i <
|
|
2013
|
+
for (i = 0; i < N2; ++i) {
|
|
2012
2014
|
var e = events[i];
|
|
2013
2015
|
var v = e.v;
|
|
2014
2016
|
if (e.isOpen) {
|
|
@@ -3547,8 +3549,8 @@ var require_layout = __commonJS({
|
|
|
3547
3549
|
if (centerGraph === void 0) {
|
|
3548
3550
|
centerGraph = true;
|
|
3549
3551
|
}
|
|
3550
|
-
var i, j, n = this.nodes().length,
|
|
3551
|
-
var x = new Array(
|
|
3552
|
+
var i, j, n = this.nodes().length, N2 = n + 2 * this._groups.length, m = this._links.length, w = this._canvasSize[0], h = this._canvasSize[1];
|
|
3553
|
+
var x = new Array(N2), y = new Array(N2);
|
|
3552
3554
|
var G = null;
|
|
3553
3555
|
var ao = this._avoidOverlaps;
|
|
3554
3556
|
this._nodes.forEach(function(v, i2) {
|
|
@@ -3564,10 +3566,10 @@ var require_layout = __commonJS({
|
|
|
3564
3566
|
if (this._distanceMatrix) {
|
|
3565
3567
|
distances = this._distanceMatrix;
|
|
3566
3568
|
} else {
|
|
3567
|
-
distances = new shortestpaths_1.Calculator(
|
|
3569
|
+
distances = new shortestpaths_1.Calculator(N2, this._links, Layout4.getSourceIndex, Layout4.getTargetIndex, function(l) {
|
|
3568
3570
|
return _this.getLinkLength(l);
|
|
3569
3571
|
}).DistanceMatrix();
|
|
3570
|
-
G = descent_1.Descent.createSquareMatrix(
|
|
3572
|
+
G = descent_1.Descent.createSquareMatrix(N2, function() {
|
|
3571
3573
|
return 2;
|
|
3572
3574
|
});
|
|
3573
3575
|
this._links.forEach(function(l) {
|
|
@@ -3581,7 +3583,7 @@ var require_layout = __commonJS({
|
|
|
3581
3583
|
G[u][v] = G[v][u] = e.weight || 1;
|
|
3582
3584
|
});
|
|
3583
3585
|
}
|
|
3584
|
-
var D = descent_1.Descent.createSquareMatrix(
|
|
3586
|
+
var D = descent_1.Descent.createSquareMatrix(N2, function(i2, j2) {
|
|
3585
3587
|
return distances[i2][j2];
|
|
3586
3588
|
});
|
|
3587
3589
|
if (this._rootGroup && typeof this._rootGroup.groups !== "undefined") {
|
|
@@ -3636,8 +3638,8 @@ var require_layout = __commonJS({
|
|
|
3636
3638
|
this._descent.snapStrength = 1e3;
|
|
3637
3639
|
this._descent.snapGridSize = this._nodes[0].width;
|
|
3638
3640
|
this._descent.numGridSnapNodes = n;
|
|
3639
|
-
this._descent.scaleSnapByMaxH = n !=
|
|
3640
|
-
var G0 = descent_1.Descent.createSquareMatrix(
|
|
3641
|
+
this._descent.scaleSnapByMaxH = n != N2;
|
|
3642
|
+
var G0 = descent_1.Descent.createSquareMatrix(N2, function(i2, j2) {
|
|
3641
3643
|
if (i2 >= n || j2 >= n)
|
|
3642
3644
|
return G[i2][j2];
|
|
3643
3645
|
return 0;
|
|
@@ -5003,7 +5005,7 @@ function aggregateRefusal(part, root2, relations, nodes, exceptId) {
|
|
|
5003
5005
|
}
|
|
5004
5006
|
var relationList = (relations) => Array.isArray(relations) ? relations : Object.values(relations);
|
|
5005
5007
|
var relationRecord = (relations) => Array.isArray(relations) ? Object.fromEntries(relations.map((r) => [r.id, r])) : relations;
|
|
5006
|
-
function relationRefusal(ctx, rel, exceptId,
|
|
5008
|
+
function relationRefusal(ctx, rel, exceptId, kept2) {
|
|
5007
5009
|
const src = ctx.nodes[rel.sourceId];
|
|
5008
5010
|
const dst = ctx.nodes[rel.targetId];
|
|
5009
5011
|
if (!src || !dst) return `Relation not allowed: "${!src ? rel.sourceId : rel.targetId}" is no element of the model (it may have been deleted meanwhile).`;
|
|
@@ -5015,8 +5017,8 @@ function relationRefusal(ctx, rel, exceptId, kept) {
|
|
|
5015
5017
|
if (def && !relationTypeAllows(def, src.type, dst.type)) {
|
|
5016
5018
|
return `Relation not allowed: "${def.label}" does not connect ${typeLabel(mm, src.type)} \u2192 ${typeLabel(mm, dst.type)}.`;
|
|
5017
5019
|
}
|
|
5018
|
-
const keptDef =
|
|
5019
|
-
const type2 = rel.relationType ?? (keptDef && relationTypeAllows(keptDef, src.type, dst.type) ?
|
|
5020
|
+
const keptDef = kept2 ? mm?.relationTypes[kept2] : void 0;
|
|
5021
|
+
const type2 = rel.relationType ?? (keptDef && relationTypeAllows(keptDef, src.type, dst.type) ? kept2 : inferRelationType(mm, src.type, dst.type));
|
|
5020
5022
|
const holder = relationMayJoinHolder(mm, type2) ? void 0 : holderOf(ctx.nodes, src, dst);
|
|
5021
5023
|
if (holder) return `Relation not allowed: ${holder.label} holds ${(holder === src ? dst : src).label}, and containment already joins them.`;
|
|
5022
5024
|
if (type2 === "part-of") {
|
|
@@ -5218,9 +5220,11 @@ function nodeList(nodes) {
|
|
|
5218
5220
|
var nodeLists = /* @__PURE__ */ new WeakMap();
|
|
5219
5221
|
function pipelineSource(view, ctx) {
|
|
5220
5222
|
const all = nodeList(ctx.nodes);
|
|
5221
|
-
|
|
5223
|
+
const scope = view?.originScope;
|
|
5224
|
+
const ofScope = scope ? all.filter((n) => inOriginScope(scope, n)) : all;
|
|
5225
|
+
if (!view || viewShowsEveryNode(view)) return ofScope;
|
|
5222
5226
|
const ids = new Set(view.nodeIds);
|
|
5223
|
-
return
|
|
5227
|
+
return ofScope.filter((n) => ids.has(n.id));
|
|
5224
5228
|
}
|
|
5225
5229
|
function runChain(source, raw, ctx) {
|
|
5226
5230
|
const pipeline = readPipeline(raw);
|
|
@@ -5229,7 +5233,7 @@ function runChain(source, raw, ctx) {
|
|
|
5229
5233
|
if (!levels.length) return { source, relationIds: /* @__PURE__ */ new Set(), levels: [], rows: null, nodes: sortNodes(source, sort, ctx) };
|
|
5230
5234
|
const inSource = new Set(source.map((n) => n.id));
|
|
5231
5235
|
const results = [];
|
|
5232
|
-
const
|
|
5236
|
+
const kept2 = [];
|
|
5233
5237
|
let above = [];
|
|
5234
5238
|
levels.forEach((level, i) => {
|
|
5235
5239
|
const seen = /* @__PURE__ */ new Map();
|
|
@@ -5244,7 +5248,7 @@ function runChain(source, raw, ctx) {
|
|
|
5244
5248
|
const candidates2 = [...seen.values()];
|
|
5245
5249
|
const { nodes: nodes2, counts } = applyFilters(candidates2, level.filters, ctx);
|
|
5246
5250
|
results.push({ candidates: candidates2.length, input: candidates2, counts, shown: sortNodes(nodes2, sort, ctx) });
|
|
5247
|
-
|
|
5251
|
+
kept2.push(new Set(nodes2.map((n) => n.id)));
|
|
5248
5252
|
above = nodes2;
|
|
5249
5253
|
});
|
|
5250
5254
|
const rows = [];
|
|
@@ -5254,7 +5258,7 @@ function runChain(source, raw, ctx) {
|
|
|
5254
5258
|
const childrenOf2 = (node, at) => {
|
|
5255
5259
|
const kids = /* @__PURE__ */ new Map();
|
|
5256
5260
|
for (const way of levels[at]?.ways ?? []) {
|
|
5257
|
-
for (const n of followWay(node, way, ctx)) if (
|
|
5261
|
+
for (const n of followWay(node, way, ctx)) if (kept2[at].has(n.id)) kids.set(n.id, n);
|
|
5258
5262
|
const via = way.via;
|
|
5259
5263
|
if (via && "anyRelation" in via) {
|
|
5260
5264
|
for (const r of index.out.get(node.id) ?? []) if (kids.has(r.targetId) && ofTypes(way, ctx.nodes[r.targetId])) relationIds.add(r.id);
|
|
@@ -5308,7 +5312,10 @@ function viewShownNodes(view, nodes, relations) {
|
|
|
5308
5312
|
const cacheable = Object.isFrozen(nodes) && Object.isFrozen(relations) && Object.isFrozen(view.nodeIds);
|
|
5309
5313
|
if (cacheable) {
|
|
5310
5314
|
const hit = shownCache.get(view.nodeIds);
|
|
5311
|
-
if (hit && hit.relations === relations && hit.pipeline === view.pipeline && hit.kind === view.kind && hit.empty === view.empty && sameForChain(hit.nodes, nodes, chainKeys(view.pipeline)))
|
|
5315
|
+
if (hit && hit.relations === relations && hit.pipeline === view.pipeline && hit.kind === view.kind && hit.empty === view.empty && sameForChain(hit.nodes, nodes, chainKeys(view.pipeline))) {
|
|
5316
|
+
hit.nodes = nodes;
|
|
5317
|
+
return hit.shown;
|
|
5318
|
+
}
|
|
5312
5319
|
}
|
|
5313
5320
|
let shown;
|
|
5314
5321
|
if (view.originScope) {
|
|
@@ -5319,12 +5326,15 @@ function viewShownNodes(view, nodes, relations) {
|
|
|
5319
5326
|
return shown;
|
|
5320
5327
|
}
|
|
5321
5328
|
function scopedTo(scope, nodes, relations) {
|
|
5322
|
-
const inScope = (item) =>
|
|
5329
|
+
const inScope = (item) => inOriginScope(scope, item);
|
|
5323
5330
|
return [
|
|
5324
5331
|
Object.fromEntries(Object.entries(nodes).filter(([, n]) => inScope(n))),
|
|
5325
5332
|
Object.fromEntries(Object.entries(relations).filter(([, r]) => inScope(r)))
|
|
5326
5333
|
];
|
|
5327
5334
|
}
|
|
5335
|
+
function inOriginScope(scope, item) {
|
|
5336
|
+
return !!item.origin && scope.includes(item.origin.slice(0, item.origin.lastIndexOf("@")));
|
|
5337
|
+
}
|
|
5328
5338
|
var shownCache = /* @__PURE__ */ new WeakMap();
|
|
5329
5339
|
function chainKeys(pipeline) {
|
|
5330
5340
|
if (!pipeline || typeof pipeline !== "object") return BASE_KEYS;
|
|
@@ -5351,6 +5361,7 @@ var BASE_KEYS = "type,parentId";
|
|
|
5351
5361
|
var keysOfChain = /* @__PURE__ */ new WeakMap();
|
|
5352
5362
|
function sameForChain(a, b, keys) {
|
|
5353
5363
|
if (a === b) return true;
|
|
5364
|
+
if (!PLACE_KEY.test(keys) && notedPlacesOnly(a, b)) return true;
|
|
5354
5365
|
let byB = sameAnswers.get(a);
|
|
5355
5366
|
if (!byB) sameAnswers.set(a, byB = /* @__PURE__ */ new WeakMap());
|
|
5356
5367
|
let byKeys = byB.get(b);
|
|
@@ -5362,6 +5373,7 @@ function sameForChain(a, b, keys) {
|
|
|
5362
5373
|
return same3;
|
|
5363
5374
|
}
|
|
5364
5375
|
var sameAnswers = /* @__PURE__ */ new WeakMap();
|
|
5376
|
+
var PLACE_KEY = /(^|,)(x|y|width|height)(,|$)/;
|
|
5365
5377
|
function compareFor(a, b, keys) {
|
|
5366
5378
|
const listA = nodeList(a);
|
|
5367
5379
|
const listB = nodeList(b);
|
|
@@ -5446,6 +5458,45 @@ function viewDrawnIds(view, nodes, relations) {
|
|
|
5446
5458
|
if (!view || !pipelineOf(view)?.levels?.length || view.kind === "dynamic") return void 0;
|
|
5447
5459
|
return viewShownNodes(view, nodes, relations);
|
|
5448
5460
|
}
|
|
5461
|
+
function canvasCount(view, nodes, relations) {
|
|
5462
|
+
if (view.kind === "explore") return view.nodeIds.filter((id) => id in nodes).length;
|
|
5463
|
+
return unfoldedCount(view, viewShownNodes(view, nodes, relations), nodes);
|
|
5464
|
+
}
|
|
5465
|
+
function unfoldedCount(view, shown, nodes) {
|
|
5466
|
+
const key = shown ?? view.nodeIds;
|
|
5467
|
+
const cacheable = Object.isFrozen(nodes);
|
|
5468
|
+
const hit = cacheable ? unfoldedCache.get(key) : void 0;
|
|
5469
|
+
if (hit && hit.folded === view.collapsedNodeIds && hit.opened === view.expandedNodeIds && sameForChain(hit.nodes, nodes, FOLD_KEYS)) {
|
|
5470
|
+
hit.nodes = nodes;
|
|
5471
|
+
return hit.count;
|
|
5472
|
+
}
|
|
5473
|
+
const ids = shown ? [...shown] : Object.keys(nodes);
|
|
5474
|
+
const opened = new Set(view.expandedNodeIds ?? []);
|
|
5475
|
+
const foldedHere = new Set(view.collapsedNodeIds ?? []);
|
|
5476
|
+
const folds2 = new Set(ids.filter((id) => !opened.has(id) && (nodes[id]?.collapsed || foldedHere.has(id))));
|
|
5477
|
+
let count2 = ids.length;
|
|
5478
|
+
if (folds2.size) {
|
|
5479
|
+
const hidden = /* @__PURE__ */ new Map();
|
|
5480
|
+
const isHidden = (id) => {
|
|
5481
|
+
const known = hidden.get(id);
|
|
5482
|
+
if (known !== void 0) return known;
|
|
5483
|
+
const parent = nodes[id]?.parentId;
|
|
5484
|
+
const out = !!parent && !!nodes[parent] && (folds2.has(parent) || isHidden(parent));
|
|
5485
|
+
hidden.set(id, out);
|
|
5486
|
+
return out;
|
|
5487
|
+
};
|
|
5488
|
+
count2 = ids.filter((id) => !isHidden(id)).length;
|
|
5489
|
+
}
|
|
5490
|
+
if (cacheable) unfoldedCache.set(key, { nodes, folded: view.collapsedNodeIds, opened: view.expandedNodeIds, count: count2 });
|
|
5491
|
+
return count2;
|
|
5492
|
+
}
|
|
5493
|
+
var FOLD_KEYS = "type,parentId,collapsed";
|
|
5494
|
+
var unfoldedCache = /* @__PURE__ */ new WeakMap();
|
|
5495
|
+
function canvasOverflow(view, nodes, relations) {
|
|
5496
|
+
if (!view || (view.kind ?? "static") !== "static" && view.kind !== "explore") return null;
|
|
5497
|
+
const count2 = canvasCount(view, nodes, relations);
|
|
5498
|
+
return count2 > CANVAS_MAX_ELEMENTS ? count2 : null;
|
|
5499
|
+
}
|
|
5449
5500
|
function withAncestors(ids, nodes) {
|
|
5450
5501
|
const out = /* @__PURE__ */ new Set();
|
|
5451
5502
|
for (const first of ids) {
|
|
@@ -5960,13 +6011,13 @@ function leaveAncestorAlignments(state, moved) {
|
|
|
5960
6011
|
let changed = false;
|
|
5961
6012
|
for (const c of constraints) {
|
|
5962
6013
|
const members = new Set(c.nodeIds);
|
|
5963
|
-
const
|
|
5964
|
-
if (
|
|
6014
|
+
const kept2 = c.type === "pin" ? c.nodeIds : c.nodeIds.filter((id) => !inMoved.has(id) || !ancestorsOf2(id).some((a) => members.has(a)));
|
|
6015
|
+
if (kept2.length === c.nodeIds.length) {
|
|
5965
6016
|
out.push(c);
|
|
5966
6017
|
continue;
|
|
5967
6018
|
}
|
|
5968
6019
|
changed = true;
|
|
5969
|
-
if (
|
|
6020
|
+
if (kept2.length >= 2) out.push({ ...c, nodeIds: kept2 });
|
|
5970
6021
|
}
|
|
5971
6022
|
return changed ? out : constraints;
|
|
5972
6023
|
};
|
|
@@ -6073,8 +6124,8 @@ function forgetNodesInReferences(state, removed) {
|
|
|
6073
6124
|
if (p.type !== "ref" || item[p.key] === void 0) continue;
|
|
6074
6125
|
const ids = refIds(item[p.key]);
|
|
6075
6126
|
if (!ids.some((id) => removed.has(id))) continue;
|
|
6076
|
-
const
|
|
6077
|
-
if (
|
|
6127
|
+
const kept2 = ids.filter((id) => !removed.has(id));
|
|
6128
|
+
if (kept2.length) item[p.key] = p.multiple ? kept2 : kept2[0];
|
|
6078
6129
|
else delete item[p.key];
|
|
6079
6130
|
}
|
|
6080
6131
|
};
|
|
@@ -6297,7 +6348,7 @@ function planViewGroups(state) {
|
|
|
6297
6348
|
const defs = new Map(viewpointsOf(state.metamodel).map((t) => [t.id, t]));
|
|
6298
6349
|
const add = [];
|
|
6299
6350
|
const remove2 = [];
|
|
6300
|
-
const views = Object.values(state.views);
|
|
6351
|
+
const views = Object.values(state.views).filter((v) => !originOf(v));
|
|
6301
6352
|
const groups = new Map(views.filter((v) => isViewGroup(v, state.metamodel)).map((v) => [v.id, v]));
|
|
6302
6353
|
const members = /* @__PURE__ */ new Map();
|
|
6303
6354
|
const refolder = [];
|
|
@@ -6320,9 +6371,9 @@ function planViewGroups(state) {
|
|
|
6320
6371
|
const unlist = views.filter((v) => v.partOf ? !remove2.includes(v.id) && (v.nodeIds.length > 0 || v.empty) : groups.has(v.id) && (v.nodeIds.length > 0 || v.empty || Object.keys(v.positions ?? {}).length > 0 || v.viewport)).map((v) => v.id);
|
|
6321
6372
|
for (const group of groups.values()) {
|
|
6322
6373
|
const def = defs.get(group.viewpoint);
|
|
6323
|
-
const
|
|
6374
|
+
const has2 = members.get(group.id) ?? /* @__PURE__ */ new Set();
|
|
6324
6375
|
for (const node of Object.values(state.c4Nodes)) {
|
|
6325
|
-
if (!node.external && canBeSubject(def, node) && !
|
|
6376
|
+
if (!node.external && canBeSubject(def, node) && !has2.has(node.id)) add.push({ groupId: group.id, subjectId: node.id });
|
|
6326
6377
|
}
|
|
6327
6378
|
}
|
|
6328
6379
|
return { add, remove: remove2, refolder, unlist, rename: rename2 };
|
|
@@ -6373,7 +6424,7 @@ function syncViewpoints(state) {
|
|
|
6373
6424
|
const types2 = viewpointsOf(state.metamodel);
|
|
6374
6425
|
const changed = [];
|
|
6375
6426
|
for (const view of Object.values(state.views)) {
|
|
6376
|
-
if (!view.viewpoint) continue;
|
|
6427
|
+
if (!view.viewpoint || originOf(view)) continue;
|
|
6377
6428
|
const type2 = types2.find((t) => t.id === view.viewpoint);
|
|
6378
6429
|
if (!type2) {
|
|
6379
6430
|
delete view.viewpoint;
|
|
@@ -6422,8 +6473,8 @@ function setViewEdgeStyle(state, viewId, style) {
|
|
|
6422
6473
|
function setViewContinuousLayout(state, viewId, on) {
|
|
6423
6474
|
const view = state.views[viewId];
|
|
6424
6475
|
if (!view) return;
|
|
6425
|
-
if (on) view.continuousLayout
|
|
6426
|
-
else
|
|
6476
|
+
if (on === null) delete view.continuousLayout;
|
|
6477
|
+
else view.continuousLayout = on;
|
|
6427
6478
|
}
|
|
6428
6479
|
function setViewPipeline(state, viewId, raw) {
|
|
6429
6480
|
const view = state.views[viewId];
|
|
@@ -6549,14 +6600,14 @@ function checkMembers(state, viewId, nodeIds) {
|
|
|
6549
6600
|
}
|
|
6550
6601
|
return null;
|
|
6551
6602
|
}
|
|
6552
|
-
function checkLines(state,
|
|
6603
|
+
function checkLines(state, others2, added2) {
|
|
6553
6604
|
const label = (id) => state.c4Nodes[id]?.label || id;
|
|
6554
|
-
const all = [...
|
|
6605
|
+
const all = [...others2, ...added2];
|
|
6555
6606
|
for (const axis of ["horizontal", "vertical"]) {
|
|
6556
6607
|
const conflict = orderConflict(all, axis);
|
|
6557
6608
|
if (conflict) return `Another ${AXIS_NOUN[axis]} keeps "${label(conflict[1])}" before "${label(conflict[0])}"; this order contradicts it.`;
|
|
6558
6609
|
}
|
|
6559
|
-
for (const line of
|
|
6610
|
+
for (const line of added2) {
|
|
6560
6611
|
if (line.nodeIds.length < 2) continue;
|
|
6561
6612
|
const along = alignmentLines(all, line.axis);
|
|
6562
6613
|
const cross = alignmentLines(all, across(line.axis));
|
|
@@ -6681,8 +6732,13 @@ var stepsGone = (n) => n > 0 ? ` and ${n} sequence step${n === 1 ? "" : "s"} alo
|
|
|
6681
6732
|
|
|
6682
6733
|
// ../../packages/common/src/ai/tools/layoutTools.ts
|
|
6683
6734
|
var AXIS_ENUM = ["horizontal", "vertical"];
|
|
6684
|
-
function noCanvasLayout(tool, view) {
|
|
6685
|
-
if (!view.kind || view.kind === "static")
|
|
6735
|
+
function noCanvasLayout(tool, view, nodes, relations) {
|
|
6736
|
+
if (!view.kind || view.kind === "static") {
|
|
6737
|
+
const count2 = canvasOverflow(view, nodes, relations);
|
|
6738
|
+
if (count2 === null) return null;
|
|
6739
|
+
const tooLarge = `${tool}: "${view.name}" shows ${count2.toLocaleString("en")} elements; a canvas draws up to ${CANVAS_MAX_ELEMENTS.toLocaleString("en")}, and Studio neither draws nor lays out a larger view`;
|
|
6740
|
+
return view.partOf && view.viewpoint ? `${tooLarge}. It is one of the views of a group per element, whose viewpoint "${view.viewpoint}" sets its view type and filter: show the group's views as tables (upsert_viewpoint with id "${view.viewpoint}" and kind "table"), which show any number, or narrow the viewpoint's filter` : `${tooLarge}. Show it as a table (update_view with kind "table"), which shows any number, or narrow its filter`;
|
|
6741
|
+
}
|
|
6686
6742
|
if (view.kind === "explore") return `${tool}: "${view.name}" is an explore view, laid out by Studio level by level from its start element; only static views have a canvas layout`;
|
|
6687
6743
|
return `${tool}: "${view.name}" is a ${view.kind} view; only static views have a canvas layout${view.kind === "dynamic" ? " (a dynamic view plays its sequence, drawn in order, with no positions of its own)" : ""}`;
|
|
6688
6744
|
}
|
|
@@ -6692,7 +6748,7 @@ function canvasFor(ctx, tool, raw, removing = false) {
|
|
|
6692
6748
|
const viewId = ctx.resolveId(raw);
|
|
6693
6749
|
const view = ctx.diagram.getViews?.()[viewId];
|
|
6694
6750
|
if (!view) return { error: `${tool}: unknown view id "${raw}"` };
|
|
6695
|
-
const refused2 = removing ? null : noCanvasLayout(tool, view);
|
|
6751
|
+
const refused2 = removing ? null : noCanvasLayout(tool, view, ctx.diagram.getNodes(), ctx.diagram.getRelations());
|
|
6696
6752
|
if (refused2) return { error: refused2 };
|
|
6697
6753
|
return { viewId };
|
|
6698
6754
|
}
|
|
@@ -6701,7 +6757,7 @@ function buildLayoutToolDefs() {
|
|
|
6701
6757
|
return [
|
|
6702
6758
|
{
|
|
6703
6759
|
name: "smart_layout",
|
|
6704
|
-
description:
|
|
6760
|
+
description: `Run Smart Layout and keep the new positions and container sizes. Without viewId it arranges the All elements canvas; with the id of a static view it arranges that view's own positions (a dynamic view plays its sequence and has no canvas layout, nor has a table, wiki or other kind); a view whose layout mode is a hierarchical nested tree is laid out as a tree, as Studio does; a view that shows more than ${CANVAS_MAX_ELEMENTS.toLocaleString("en")} elements, more than a canvas draws, is refused, as Studio neither draws nor lays it out. Alignments and grids hold; the canvas's pins (elements a Studio user dropped after a drag) are removed, since every element gets a new place. A large view gets as much work as one Smart Layout in Studio, the same layout, and the result says 'run it again for more' when more would help. Call it after adding or moving several nodes.`,
|
|
6705
6761
|
inputSchema: {
|
|
6706
6762
|
type: "object",
|
|
6707
6763
|
properties: {
|
|
@@ -6713,7 +6769,7 @@ function buildLayoutToolDefs() {
|
|
|
6713
6769
|
},
|
|
6714
6770
|
{
|
|
6715
6771
|
name: "align_nodes",
|
|
6716
|
-
description: "Keep two or more elements on one line on a canvas: a row (axis 'horizontal', equal centre y) or a column (axis 'vertical', equal centre x). Every later layout keeps it: drags and the live physics in Studio, Smart Layout. Without viewId it applies to the All elements canvas; with the id of a static view, to that view only (other kinds have no canvas). Elements hidden on the canvas are skipped until shown. Studio lines them up when it shows the canvas; smart_layout does too.",
|
|
6772
|
+
description: "Keep two or more elements on one line on a canvas: a row (axis 'horizontal', equal centre y) or a column (axis 'vertical', equal centre x). Every later layout keeps it: drags and the live physics in Studio, Smart Layout. Without viewId it applies to the All elements canvas; with the id of a static view, to that view only (other kinds have no canvas, nor has a view of more elements than a canvas draws). Elements hidden on the canvas are skipped until shown. Studio lines them up when it shows the canvas; smart_layout does too.",
|
|
6717
6773
|
inputSchema: {
|
|
6718
6774
|
type: "object",
|
|
6719
6775
|
properties: {
|
|
@@ -6728,7 +6784,7 @@ function buildLayoutToolDefs() {
|
|
|
6728
6784
|
},
|
|
6729
6785
|
{
|
|
6730
6786
|
name: "grid_nodes",
|
|
6731
|
-
description: "Keep elements in a grid on a canvas: `columns` columns, filled row by row in the order of nodeIds (left to right, then the next row). Every row stays a row and every column a column, in that order, through every later layout. Without viewId it applies to the All elements canvas; with the id of a static view, to that view only (other kinds have no canvas). Studio arranges them when it shows the canvas; smart_layout keeps the grid. Remove it with remove_alignment.",
|
|
6787
|
+
description: "Keep elements in a grid on a canvas: `columns` columns, filled row by row in the order of nodeIds (left to right, then the next row). Every row stays a row and every column a column, in that order, through every later layout. Without viewId it applies to the All elements canvas; with the id of a static view, to that view only (other kinds have no canvas, nor has a view of more elements than a canvas draws). Studio arranges them when it shows the canvas; smart_layout keeps the grid. Remove it with remove_alignment.",
|
|
6732
6788
|
inputSchema: {
|
|
6733
6789
|
type: "object",
|
|
6734
6790
|
properties: {
|
|
@@ -6766,10 +6822,10 @@ function buildAlignmentToolHandlers() {
|
|
|
6766
6822
|
const canvas2 = canvasFor(ctx, "align_nodes", input.viewId);
|
|
6767
6823
|
if ("error" in canvas2) return fail(canvas2.error);
|
|
6768
6824
|
const nodeIds = input.nodeIds.map((id) => ctx.resolveId(id));
|
|
6769
|
-
const
|
|
6770
|
-
if ("error" in
|
|
6825
|
+
const added2 = ctx.diagram.addAlignment(canvas2.viewId, input.axis, nodeIds, input.keepOrder === true);
|
|
6826
|
+
if ("error" in added2) return fail(`align_nodes: ${added2.error}`);
|
|
6771
6827
|
const order = input.keepOrder === true ? ", in the order given" : "";
|
|
6772
|
-
return { ok: true, resultText: `Aligned ${nodeIds.length} elements in a ${input.axis === "horizontal" ? "row" : "column"}${order}. Alignment ID: ${
|
|
6828
|
+
return { ok: true, resultText: `Aligned ${nodeIds.length} elements in a ${input.axis === "horizontal" ? "row" : "column"}${order}. Alignment ID: ${added2.id}.`, updated: { views: 1 } };
|
|
6773
6829
|
},
|
|
6774
6830
|
grid_nodes: (rawInput, ctx) => {
|
|
6775
6831
|
const input = rawInput ?? {};
|
|
@@ -6780,9 +6836,9 @@ function buildAlignmentToolHandlers() {
|
|
|
6780
6836
|
if ("error" in canvas2) return fail(canvas2.error);
|
|
6781
6837
|
const nodeIds = input.nodeIds.map((id) => ctx.resolveId(id));
|
|
6782
6838
|
const columns = input.columns ?? defaultGridColumns(nodeIds.length);
|
|
6783
|
-
const
|
|
6784
|
-
if ("error" in
|
|
6785
|
-
return { ok: true, resultText: `Kept ${nodeIds.length} elements in a grid of ${columns} columns. Alignment ID: ${
|
|
6839
|
+
const added2 = ctx.diagram.addGrid(canvas2.viewId, nodeIds, columns);
|
|
6840
|
+
if ("error" in added2) return fail(`grid_nodes: ${added2.error}`);
|
|
6841
|
+
return { ok: true, resultText: `Kept ${nodeIds.length} elements in a grid of ${columns} columns. Alignment ID: ${added2.id}.`, updated: { views: 1 } };
|
|
6786
6842
|
},
|
|
6787
6843
|
remove_alignment: (rawInput, ctx) => {
|
|
6788
6844
|
const input = rawInput ?? {};
|
|
@@ -6822,7 +6878,7 @@ function buildLayoutToolHandlers() {
|
|
|
6822
6878
|
viewId = ctx.resolveId(input.viewId);
|
|
6823
6879
|
const view = ctx.diagram.getViews?.()[viewId];
|
|
6824
6880
|
if (!view) return fail(`smart_layout: unknown view id "${input.viewId}"`);
|
|
6825
|
-
const refused2 = noCanvasLayout("smart_layout", view);
|
|
6881
|
+
const refused2 = noCanvasLayout("smart_layout", view, ctx.diagram.getNodes(), ctx.diagram.getRelations());
|
|
6826
6882
|
if (refused2) return fail(refused2);
|
|
6827
6883
|
}
|
|
6828
6884
|
const outcome = await ctx.diagram.runLayout(viewId, around);
|
|
@@ -6971,7 +7027,7 @@ function buildViewToolDefs() {
|
|
|
6971
7027
|
inputSchema: {
|
|
6972
7028
|
type: "object",
|
|
6973
7029
|
properties: {
|
|
6974
|
-
continuousLayout: { type: "boolean", description: "Static views:
|
|
7030
|
+
continuousLayout: { type: "boolean", description: "Static views, Keep smart: true, Studio tidies the whole view after each change to what it shows (yours too, as it reloads the folder), keeping pinned elements, and glides the elements into place; false, it never does. Left out, the view follows the Keep smart default of each Studio that opens it (off unless its user turns it on)." },
|
|
6975
7031
|
edgeStyle: { type: "string", enum: ["curved", "orthogonal", "model"], description: `How the view draws relations: curved, orthogonal (horizontal and vertical segments), or "model" for the model's default.` },
|
|
6976
7032
|
folder: { type: "string", description: 'The folder the view sits in in the list of views, a path such as "C4/Components"; "" puts it at the top.' },
|
|
6977
7033
|
tempId: { type: "string" },
|
|
@@ -6997,7 +7053,7 @@ function buildViewToolDefs() {
|
|
|
6997
7053
|
inputSchema: {
|
|
6998
7054
|
type: "object",
|
|
6999
7055
|
properties: {
|
|
7000
|
-
continuousLayout: { type: "boolean", description: "Static views:
|
|
7056
|
+
continuousLayout: { type: ["boolean", "null"], description: "Static views, Keep smart: true, Studio tidies the whole view after each change to what it shows (yours too, as it reloads the folder), keeping pinned elements, and glides the elements into place; false, it never does; null takes the view's setting away, so it follows the Keep smart default of each Studio that opens it (off unless its user turns it on)." },
|
|
7001
7057
|
edgeStyle: { type: "string", enum: ["curved", "orthogonal", "model"], description: `How the view draws relations: curved, orthogonal (horizontal and vertical segments), or "model" for the model's default.` },
|
|
7002
7058
|
folder: { type: "string", description: 'The folder the view sits in in the list of views, a path such as "C4/Components"; "" puts it at the top.' },
|
|
7003
7059
|
id: { type: "string" },
|
|
@@ -7108,9 +7164,9 @@ function buildViewToolHandlers() {
|
|
|
7108
7164
|
if (!ctx.diagram.setViewEdgeStyle) return fail("create_view: line styles are not available in this context");
|
|
7109
7165
|
ctx.diagram.setViewEdgeStyle(realId, input.edgeStyle);
|
|
7110
7166
|
}
|
|
7111
|
-
if (input.continuousLayout ===
|
|
7167
|
+
if (typeof input.continuousLayout === "boolean") {
|
|
7112
7168
|
if (!ctx.diagram.setViewContinuousLayout) return fail("create_view: continuous layout is not available in this context");
|
|
7113
|
-
ctx.diagram.setViewContinuousLayout(realId,
|
|
7169
|
+
ctx.diagram.setViewContinuousLayout(realId, input.continuousLayout);
|
|
7114
7170
|
}
|
|
7115
7171
|
if (typeof input.folder === "string" && input.folder.trim()) {
|
|
7116
7172
|
if (!ctx.diagram.setViewFolder) return fail("create_view: folders of views are not available in this context");
|
|
@@ -7160,7 +7216,7 @@ function buildViewToolHandlers() {
|
|
|
7160
7216
|
changes.push(() => ctx.diagram.setViewEdgeStyle(vId, style));
|
|
7161
7217
|
}
|
|
7162
7218
|
if (input.continuousLayout !== void 0) {
|
|
7163
|
-
if (typeof input.continuousLayout !== "boolean") return fail("update_view: continuousLayout must be true or
|
|
7219
|
+
if (typeof input.continuousLayout !== "boolean" && input.continuousLayout !== null) return fail("update_view: continuousLayout must be true, false or null");
|
|
7164
7220
|
if (!ctx.diagram.setViewContinuousLayout) return fail("update_view: continuous layout is not available in this context");
|
|
7165
7221
|
const on = input.continuousLayout;
|
|
7166
7222
|
changes.push(() => ctx.diagram.setViewContinuousLayout(vId, on));
|
|
@@ -7196,7 +7252,7 @@ function buildViewToolHandlers() {
|
|
|
7196
7252
|
changes.push(() => ctx.diagram.setViewCollapsed(vId, ids, collapsed));
|
|
7197
7253
|
}
|
|
7198
7254
|
if (view.partOf && (input.viewpoint !== void 0 || input.kind !== void 0 || input.pipeline !== void 0 || input.folder !== void 0 || input.name !== void 0)) {
|
|
7199
|
-
return fail(`update_view: ${view.name} is one of the views of the group ${ctx.diagram.getViews()[view.partOf]?.name ?? view.partOf}: its name follows its element, and its viewpoint, kind, filter and folder are the group's (move the group's folder instead)`);
|
|
7255
|
+
return fail(`update_view: ${view.name} is one of the views of the group ${ctx.diagram.getViews()[view.partOf]?.name ?? view.partOf}: its name follows its element, and its viewpoint, kind, filter and folder are the group's (move the group's folder instead, or change the viewpoint${view.viewpoint ? ` "${view.viewpoint}"` : ""} with upsert_viewpoint: every view of the group follows it)`);
|
|
7200
7256
|
}
|
|
7201
7257
|
if (isViewGroup(view, ctx.diagram.getMetamodel?.()) && (input.viewpoint !== void 0 || input.kind !== void 0 || input.pipeline !== void 0)) {
|
|
7202
7258
|
return fail(`update_view: ${view.name} is a group of views per element; its viewpoint sets its views. Delete it (delete_view) to make another kind of view`);
|
|
@@ -7775,7 +7831,7 @@ function describeChanges(changes, before, after) {
|
|
|
7775
7831
|
function describeSequenceChanges(before, after) {
|
|
7776
7832
|
const name = (q) => `${q.name} (${q.id})`;
|
|
7777
7833
|
const same3 = (a, b) => JSON.stringify(a ?? []) === JSON.stringify(b ?? []);
|
|
7778
|
-
const
|
|
7834
|
+
const added2 = Object.values(after).filter((q) => !before[q.id]).map(name);
|
|
7779
7835
|
const removed = Object.values(before).filter((q) => !after[q.id]).map(name);
|
|
7780
7836
|
const changed = Object.values(after).filter((q) => before[q.id]).map((q) => {
|
|
7781
7837
|
const was = before[q.id];
|
|
@@ -7791,7 +7847,7 @@ function describeSequenceChanges(before, after) {
|
|
|
7791
7847
|
const section = (title, items) => {
|
|
7792
7848
|
if (items.length) lines.push(`${title}:`, ...items.map((item) => `- ${item}`));
|
|
7793
7849
|
};
|
|
7794
|
-
section("Sequences added",
|
|
7850
|
+
section("Sequences added", added2);
|
|
7795
7851
|
section("Sequences removed", removed);
|
|
7796
7852
|
section("Sequences changed", changed);
|
|
7797
7853
|
return lines.join("\n");
|
|
@@ -8245,39 +8301,33 @@ function searchModel(data, query) {
|
|
|
8245
8301
|
}
|
|
8246
8302
|
const scope = parsed.scope;
|
|
8247
8303
|
const inScope = (id) => !scope?.nodes || scope.nodes.has(id);
|
|
8304
|
+
const narrow = narrowing(data, parsed);
|
|
8305
|
+
if (!narrow) fullScans++;
|
|
8306
|
+
const foundElements = [];
|
|
8307
|
+
const foundRelations = [];
|
|
8248
8308
|
if (wants(parsed, "element")) {
|
|
8249
|
-
for (const n of Object.values(data.nodes)) {
|
|
8309
|
+
for (const n of narrow?.elements ?? Object.values(data.nodes)) {
|
|
8250
8310
|
if (!inScope(n.id)) continue;
|
|
8251
8311
|
if (parsed.types && !parsed.types.includes(n.type)) continue;
|
|
8252
8312
|
const props = propertyFields(n, mm);
|
|
8253
8313
|
if (parsed.properties.length && !parsed.properties.every((p) => props.some((f) => f.key === p.key && foldText(f.text).includes(p.value)))) continue;
|
|
8254
|
-
const hit = hitFor(
|
|
8255
|
-
{ text: n.label || typeName(n.type), weight: 3, label: true },
|
|
8256
|
-
{ text: typeName(n.type), weight: 1.2 },
|
|
8257
|
-
{ text: n.technology ?? "", weight: 1.5, name: "Technology" },
|
|
8258
|
-
{ text: n.description ?? "", weight: 1, name: "Description", snippet: true },
|
|
8259
|
-
...props.map((p) => ({ text: p.text, weight: 1, name: p.name, snippet: true }))
|
|
8260
|
-
], parsed, true);
|
|
8314
|
+
const hit = hitFor(elementFields(n, mm, props), parsed, true);
|
|
8261
8315
|
if (!hit) continue;
|
|
8316
|
+
foundElements.push(n);
|
|
8262
8317
|
const path = pathOf(data.nodes, n.id);
|
|
8263
8318
|
push({ kind: "element", id: n.id, label: n.label || typeName(n.type), detail: [typeName(n.type), path].filter(Boolean).join(" \xB7 "), type: n.type, ...hit });
|
|
8264
8319
|
}
|
|
8265
8320
|
}
|
|
8266
8321
|
if (wants(parsed, "relation") && !parsed.types && !parsed.properties.length) {
|
|
8267
|
-
for (const r of Object.values(data.relations)) {
|
|
8322
|
+
for (const r of narrow?.relations ?? Object.values(data.relations)) {
|
|
8268
8323
|
const src = data.nodes[r.sourceId];
|
|
8269
8324
|
const tgt = data.nodes[r.targetId];
|
|
8270
8325
|
if (!src || !tgt || !inScope(r.sourceId) || !inScope(r.targetId)) continue;
|
|
8271
8326
|
const label = r.label || `${src.label} \u2192 ${tgt.label}`;
|
|
8272
8327
|
const kindName = r.relationType ? mm?.relationTypes[r.relationType]?.label ?? r.relationType : "";
|
|
8273
|
-
const hit = hitFor(
|
|
8274
|
-
{ text: label, weight: 3, label: true },
|
|
8275
|
-
{ text: src.label, weight: 1.5 },
|
|
8276
|
-
{ text: tgt.label, weight: 1.5 },
|
|
8277
|
-
{ text: r.technology ?? "", weight: 1.5, name: "Technology" },
|
|
8278
|
-
{ text: kindName, weight: 1 }
|
|
8279
|
-
], parsed, false);
|
|
8328
|
+
const hit = hitFor(relationFields(r, src, tgt, mm), parsed, false);
|
|
8280
8329
|
if (!hit) continue;
|
|
8330
|
+
foundRelations.push(r);
|
|
8281
8331
|
push({ kind: "relation", id: r.id, label, detail: [kindName, `${src.label} \u2192 ${tgt.label}`].filter(Boolean).join(" \xB7 "), ...hit, score: hit.score - 2 });
|
|
8282
8332
|
}
|
|
8283
8333
|
}
|
|
@@ -8312,8 +8362,39 @@ function searchModel(data, query) {
|
|
|
8312
8362
|
}
|
|
8313
8363
|
}
|
|
8314
8364
|
result.hits.sort((a, b) => b.score - a.score || a.label.localeCompare(b.label));
|
|
8365
|
+
lastSearch = Object.isFrozen(data.nodes) && Object.isFrozen(data.relations) ? { nodes: data.nodes, relations: data.relations, metamodel: data.metamodel, filters: filtersOf(parsed), scopeNodes: parsed.scope?.nodes ?? null, words: parsed.words, elements: foundElements, relationsFound: foundRelations } : null;
|
|
8315
8366
|
return result;
|
|
8316
8367
|
}
|
|
8368
|
+
function elementFields(n, mm, props = propertyFields(n, mm)) {
|
|
8369
|
+
const typeName = mm?.nodeTypes[n.type]?.label ?? n.type;
|
|
8370
|
+
return [
|
|
8371
|
+
{ text: n.label || typeName, weight: 3, label: true },
|
|
8372
|
+
{ text: typeName, weight: 1.2 },
|
|
8373
|
+
{ text: n.technology ?? "", weight: 1.5, name: "Technology" },
|
|
8374
|
+
{ text: n.description ?? "", weight: 1, name: "Description", snippet: true },
|
|
8375
|
+
...props.map((p) => ({ text: p.text, weight: 1, name: p.name, snippet: true }))
|
|
8376
|
+
];
|
|
8377
|
+
}
|
|
8378
|
+
function relationFields(r, src, tgt, mm) {
|
|
8379
|
+
return [
|
|
8380
|
+
{ text: r.label || `${src.label} \u2192 ${tgt.label}`, weight: 3, label: true },
|
|
8381
|
+
{ text: src.label, weight: 1.5 },
|
|
8382
|
+
{ text: tgt.label, weight: 1.5 },
|
|
8383
|
+
{ text: r.technology ?? "", weight: 1.5, name: "Technology" },
|
|
8384
|
+
{ text: r.relationType ? mm?.relationTypes[r.relationType]?.label ?? r.relationType : "", weight: 1 }
|
|
8385
|
+
];
|
|
8386
|
+
}
|
|
8387
|
+
var fullScans = 0;
|
|
8388
|
+
var lastSearch = null;
|
|
8389
|
+
var filtersOf = (p) => JSON.stringify([p.command, p.kinds, p.scope?.viewId ?? null, p.scope?.name ?? null, p.missingView ?? null, p.types, p.properties]);
|
|
8390
|
+
function narrowing(data, parsed) {
|
|
8391
|
+
const last = lastSearch;
|
|
8392
|
+
if (!last || last.nodes !== data.nodes || last.relations !== data.relations || last.metamodel !== data.metamodel) return null;
|
|
8393
|
+
if (last.scopeNodes !== (parsed.scope?.nodes ?? null) || last.filters !== filtersOf(parsed)) return null;
|
|
8394
|
+
if (!last.words.length || parsed.words.length < last.words.length) return null;
|
|
8395
|
+
if (!last.words.every((w, i) => parsed.words[i].startsWith(w))) return null;
|
|
8396
|
+
return { elements: last.elements, relations: last.relationsFound };
|
|
8397
|
+
}
|
|
8317
8398
|
|
|
8318
8399
|
// ../../packages/common/src/ai/queryLanguage.ts
|
|
8319
8400
|
var MODEL_QUERY_LANGUAGE_HELP = `Query the CURRENT diagram structure with a small built-in query language \u2014
|
|
@@ -8330,7 +8411,7 @@ Syntax:
|
|
|
8330
8411
|
- LIST VIEWS WHERE <expr> [LIMIT n]
|
|
8331
8412
|
- LIST SEQUENCES
|
|
8332
8413
|
- LIST TECHNOLOGIES
|
|
8333
|
-
- GET NODE <id>
|
|
8414
|
+
- GET NODE <id> \u2014 the element whole, with its ancestors, children and relations
|
|
8334
8415
|
- GET VIEW <id>
|
|
8335
8416
|
- GET SEQUENCE <id>
|
|
8336
8417
|
- GET CHILDREN OF <id>
|
|
@@ -8353,6 +8434,15 @@ Boolean logic in WHERE:
|
|
|
8353
8434
|
- AND, OR, NOT
|
|
8354
8435
|
- Parentheses are supported: ( ... )
|
|
8355
8436
|
|
|
8437
|
+
Answers to search_model are in brief: LIST NODES, LIST RELATIONS, GET
|
|
8438
|
+
CHILDREN OF and the traversals give each element its id, type, label,
|
|
8439
|
+
parent, technology, origin, its short properties (enums, numbers, yes/no:
|
|
8440
|
+
status, kind, order, ears_type, \u2026) and one sentence (a requirement's EARS
|
|
8441
|
+
sentence, an ADR's decision, a scenario's given/when/then, else its
|
|
8442
|
+
description, cut to 160 characters), and each relation once. GET NODE <id>
|
|
8443
|
+
gives one element whole; FULL at the end of a query gives every field of
|
|
8444
|
+
every row ("LIST NODES WHERE type = "adr" FULL").
|
|
8445
|
+
|
|
8356
8446
|
Supported node fields:
|
|
8357
8447
|
- id, type, label, description, technology, parentId, external,
|
|
8358
8448
|
plus any custom/governance property key for that node's type
|
|
@@ -8745,8 +8835,91 @@ function summarizeTraversalResults(startNodeId, reached, nodes, relations) {
|
|
|
8745
8835
|
relations: relationRows
|
|
8746
8836
|
};
|
|
8747
8837
|
}
|
|
8838
|
+
var BRIEF_SENTENCE_CHARS = 160;
|
|
8839
|
+
var BRIEF_NOTE = "In brief: GET NODE <id> gives an element whole, FULL at the end of the query every field of every row.";
|
|
8840
|
+
var cut = (text3) => {
|
|
8841
|
+
const flat2 = text3.replace(/\s+/g, " ").trim();
|
|
8842
|
+
return flat2.length <= BRIEF_SENTENCE_CHARS ? flat2 : `${flat2.slice(0, BRIEF_SENTENCE_CHARS - 1).trimEnd()}\u2026`;
|
|
8843
|
+
};
|
|
8844
|
+
function briefSentence(node, ctx) {
|
|
8845
|
+
const p = node;
|
|
8846
|
+
const str2 = (key) => typeof p[key] === "string" ? p[key].trim() : "";
|
|
8847
|
+
if (node.type === "requirement" && str2("action")) return cut(composeEarsSentence(p, void 0, requirementStatePhrase(node, ctx.nodes, ctx.relations)).sentence);
|
|
8848
|
+
if (node.type === "adr" && str2("decision")) return cut(str2("decision"));
|
|
8849
|
+
if (node.type === "scenario" && (str2("given") || str2("when") || str2("then"))) {
|
|
8850
|
+
return cut([str2("given") && `Given ${str2("given")}`, str2("when") && `when ${str2("when")}`, str2("then") && `then ${str2("then")}`].filter(Boolean).join(", "));
|
|
8851
|
+
}
|
|
8852
|
+
return node.description ? cut(node.description) : "";
|
|
8853
|
+
}
|
|
8854
|
+
function shortProperties(node, ctx) {
|
|
8855
|
+
const p = node;
|
|
8856
|
+
const defs = ctx.metamodel?.nodeTypes[node.type]?.properties ?? [];
|
|
8857
|
+
const keys = defs.filter((d) => d.type === "enum" || d.type === "number" || d.type === "boolean").map((d) => d.key);
|
|
8858
|
+
if (!ctx.metamodel && typeof p.status === "string") keys.push("status");
|
|
8859
|
+
return Object.fromEntries(keys.filter((k) => p[k] !== void 0 && p[k] !== "" && p[k] !== null).map((k) => [k, p[k]]));
|
|
8860
|
+
}
|
|
8861
|
+
function briefNode(node, ctx) {
|
|
8862
|
+
const p = node;
|
|
8863
|
+
const sentence2 = briefSentence(node, ctx);
|
|
8864
|
+
return {
|
|
8865
|
+
id: node.id,
|
|
8866
|
+
type: node.type,
|
|
8867
|
+
label: node.label,
|
|
8868
|
+
...node.parentId ? { parentId: node.parentId } : {},
|
|
8869
|
+
...node.technology ? { technology: node.technology } : {},
|
|
8870
|
+
...node.external ? { external: true } : {},
|
|
8871
|
+
...typeof p.origin === "string" && p.origin ? { origin: p.origin } : {},
|
|
8872
|
+
...shortProperties(node, ctx),
|
|
8873
|
+
...sentence2 ? { text: sentence2 } : {}
|
|
8874
|
+
};
|
|
8875
|
+
}
|
|
8876
|
+
function briefRelation(rel, nodes, labels) {
|
|
8877
|
+
return {
|
|
8878
|
+
id: rel.id,
|
|
8879
|
+
relationType: rel.relationType ?? null,
|
|
8880
|
+
sourceId: rel.sourceId,
|
|
8881
|
+
...labels ? { sourceLabel: nodes[rel.sourceId]?.label ?? null } : {},
|
|
8882
|
+
targetId: rel.targetId,
|
|
8883
|
+
...labels ? { targetLabel: nodes[rel.targetId]?.label ?? null } : {},
|
|
8884
|
+
...rel.label ? { label: rel.label } : {},
|
|
8885
|
+
// A relation's own properties are short (a guard, an event, a note): kept, long text cut.
|
|
8886
|
+
...Object.fromEntries(Object.entries(rel).filter(([key, value]) => !RELATION_BASE_KEYS.has(key) && value !== void 0 && value !== "" && value !== null).map(([key, value]) => [key, typeof value === "string" ? cut(value) : value]))
|
|
8887
|
+
};
|
|
8888
|
+
}
|
|
8889
|
+
var RELATION_BASE_KEYS = /* @__PURE__ */ new Set(["id", "relationType", "sourceId", "targetId", "label", "technology", "sourceHandle", "targetHandle", "waypoints", "labelPosition"]);
|
|
8890
|
+
function inBrief(result, ctx) {
|
|
8891
|
+
const r = result.result;
|
|
8892
|
+
const node = (row) => briefNode(ctx.nodes[row.id] ?? row, ctx);
|
|
8893
|
+
switch (result.command) {
|
|
8894
|
+
case "LIST NODES":
|
|
8895
|
+
case "GET CHILDREN OF":
|
|
8896
|
+
return { ...result, result: { total: r.total, rows: r.rows.map(node), note: BRIEF_NOTE } };
|
|
8897
|
+
case "LIST RELATIONS":
|
|
8898
|
+
return { ...result, result: { total: r.total, rows: r.rows.map((row) => briefRelation(ctx.relations[row.id] ?? row, ctx.nodes, true)), note: BRIEF_NOTE } };
|
|
8899
|
+
case "GET NEIGHBORS OF":
|
|
8900
|
+
case "GET DEPENDENCIES OF":
|
|
8901
|
+
case "GET DEPENDENTS OF":
|
|
8902
|
+
return {
|
|
8903
|
+
...result,
|
|
8904
|
+
result: {
|
|
8905
|
+
nodeId: r.nodeId,
|
|
8906
|
+
total: r.total,
|
|
8907
|
+
neighbors: r.rows.map((row) => ({ ...node(row.node), depth: row.depth })),
|
|
8908
|
+
relations: r.relations.map((row) => briefRelation(ctx.relations[row.id] ?? row, ctx.nodes, false)),
|
|
8909
|
+
note: BRIEF_NOTE
|
|
8910
|
+
}
|
|
8911
|
+
};
|
|
8912
|
+
default:
|
|
8913
|
+
return result;
|
|
8914
|
+
}
|
|
8915
|
+
}
|
|
8748
8916
|
function runModelQuery(query, ctx) {
|
|
8749
|
-
const
|
|
8917
|
+
const full = /\s+FULL\s*$/i.test(query.trim());
|
|
8918
|
+
const raw = full ? query.trim().replace(/\s+FULL\s*$/i, "") : query.trim();
|
|
8919
|
+
const result = runFullQuery(raw, ctx);
|
|
8920
|
+
return ctx.brief && !full ? inBrief(result, ctx) : result;
|
|
8921
|
+
}
|
|
8922
|
+
function runFullQuery(raw, ctx) {
|
|
8750
8923
|
const upper = raw.toUpperCase();
|
|
8751
8924
|
const views = ctx.views ?? {};
|
|
8752
8925
|
const relations = Object.values(ctx.relations);
|
|
@@ -8773,11 +8946,8 @@ function runModelQuery(query, ctx) {
|
|
|
8773
8946
|
}
|
|
8774
8947
|
const listNodes = parseListQuery(raw, "NODES");
|
|
8775
8948
|
if (listNodes) {
|
|
8776
|
-
const rows = applyWhere(
|
|
8777
|
-
|
|
8778
|
-
listNodes.expr,
|
|
8779
|
-
getNodeField
|
|
8780
|
-
);
|
|
8949
|
+
const rows = applyWhere(Object.values(ctx.nodes), listNodes.expr, getNodeField);
|
|
8950
|
+
if (!ctx.unordered || listNodes.limit) rows.sort((a, b) => a.label.localeCompare(b.label) || a.id.localeCompare(b.id));
|
|
8781
8951
|
const limited = listNodes.limit ? rows.slice(0, listNodes.limit) : rows;
|
|
8782
8952
|
return {
|
|
8783
8953
|
query: raw,
|
|
@@ -8787,11 +8957,8 @@ function runModelQuery(query, ctx) {
|
|
|
8787
8957
|
}
|
|
8788
8958
|
const listRelations = parseListQuery(raw, "RELATIONS");
|
|
8789
8959
|
if (listRelations) {
|
|
8790
|
-
const rows = applyWhere(
|
|
8791
|
-
|
|
8792
|
-
listRelations.expr,
|
|
8793
|
-
(rel, field) => getRelationField(rel, field, ctx.nodes)
|
|
8794
|
-
);
|
|
8960
|
+
const rows = applyWhere(relations, listRelations.expr, (rel, field) => getRelationField(rel, field, ctx.nodes));
|
|
8961
|
+
if (!ctx.unordered || listRelations.limit) rows.sort((a, b) => a.id.localeCompare(b.id));
|
|
8795
8962
|
const limited = listRelations.limit ? rows.slice(0, listRelations.limit) : rows;
|
|
8796
8963
|
return {
|
|
8797
8964
|
query: raw,
|
|
@@ -9009,7 +9176,8 @@ function buildModelToolHandlers() {
|
|
|
9009
9176
|
relations: ctx.diagram.getRelations(),
|
|
9010
9177
|
views: ctx.diagram.getViews?.(),
|
|
9011
9178
|
sequences: ctx.diagram.getSequences?.(),
|
|
9012
|
-
metamodel: ctx.diagram.getMetamodel?.()
|
|
9179
|
+
metamodel: ctx.diagram.getMetamodel?.(),
|
|
9180
|
+
brief: true
|
|
9013
9181
|
});
|
|
9014
9182
|
return { ok: true, resultText: JSON.stringify(result.result) };
|
|
9015
9183
|
} catch (err2) {
|
|
@@ -9364,13 +9532,13 @@ function parseSlides(tool, raw, ctx, existing) {
|
|
|
9364
9532
|
if (!Array.isArray(raw)) return `${tool}: slides must be an array`;
|
|
9365
9533
|
const views = ctx.diagram.getViews?.() ?? {};
|
|
9366
9534
|
const milestones = ctx.diagram.getMilestones?.() ?? [];
|
|
9367
|
-
const
|
|
9535
|
+
const kept2 = new Map(existing.map((slide2) => [slide2.id, slide2]));
|
|
9368
9536
|
const slides = [];
|
|
9369
9537
|
const used = /* @__PURE__ */ new Set();
|
|
9370
9538
|
for (const [i, item] of raw.entries()) {
|
|
9371
9539
|
const s = item;
|
|
9372
9540
|
if (typeof s?.name !== "string" || !s.name.trim()) return `${tool}: slide ${i + 1} needs a name`;
|
|
9373
|
-
const previous = typeof s.id === "string" ?
|
|
9541
|
+
const previous = typeof s.id === "string" ? kept2.get(s.id) : void 0;
|
|
9374
9542
|
if (typeof s.id === "string" && !previous) return `${tool}: slide ${i + 1} has unknown id "${s.id}"`;
|
|
9375
9543
|
if (typeof s.id === "string" && used.has(s.id)) return `${tool}: slide ${i + 1} repeats the id "${s.id}" of an earlier slide; leave the id out for a new slide`;
|
|
9376
9544
|
if (typeof s.id === "string") used.add(s.id);
|
|
@@ -10165,6 +10333,79 @@ function buildMetamodelMessage(mm, relevantTypeIds, nodes) {
|
|
|
10165
10333
|
"```"
|
|
10166
10334
|
].join("\n");
|
|
10167
10335
|
}
|
|
10336
|
+
var BRIEF_ENUM_CHARS = 90;
|
|
10337
|
+
function briefProperty(p) {
|
|
10338
|
+
if (p.type === "enum" && p.options?.length) {
|
|
10339
|
+
const options = p.options.join("|");
|
|
10340
|
+
return options.length <= BRIEF_ENUM_CHARS ? `${p.key} (${options})` : `${p.key} (enum, ${p.options.length} options)`;
|
|
10341
|
+
}
|
|
10342
|
+
if (p.type === "ref") return `${p.key} (\u2192 ${p.refType ?? "node"}${p.multiple ? "[]" : ""})`;
|
|
10343
|
+
return p.key;
|
|
10344
|
+
}
|
|
10345
|
+
function briefPairs(pairs2) {
|
|
10346
|
+
const targets = /* @__PURE__ */ new Map();
|
|
10347
|
+
for (const p of pairs2) targets.set(p.from, [...targets.get(p.from) ?? [], p.to]);
|
|
10348
|
+
const bySet = /* @__PURE__ */ new Map();
|
|
10349
|
+
for (const [from, to] of targets) {
|
|
10350
|
+
const key = to.join(", ");
|
|
10351
|
+
bySet.set(key, [...bySet.get(key) ?? [], from]);
|
|
10352
|
+
}
|
|
10353
|
+
return [...bySet].map(([to, from]) => `${from.join(", ")} \u2192 ${to}`).join("; ");
|
|
10354
|
+
}
|
|
10355
|
+
function buildMetamodelBrief(mm) {
|
|
10356
|
+
if (!mm) return buildMetamodelMessage(mm);
|
|
10357
|
+
const nodeLines = Object.values(mm.nodeTypes).map((t) => {
|
|
10358
|
+
const parents = t.allowedParents?.length ? t.allowedParents : [];
|
|
10359
|
+
const atRoot = t.allowedAtRoot ?? parents.length === 0;
|
|
10360
|
+
const where = [parents.length ? `in ${parents.join(", ")}` : "", atRoot ? "at the root" : ""].filter(Boolean).join(" or ");
|
|
10361
|
+
const props = (t.properties ?? []).map(briefProperty);
|
|
10362
|
+
const max2 = t.cardinality?.max !== void 0 ? `; at most ${t.cardinality.max}` : "";
|
|
10363
|
+
return `- ${t.id} (${t.label}): ${where || "nowhere"}${max2}${props.length ? `; properties: ${props.join(", ")}` : ""}`;
|
|
10364
|
+
});
|
|
10365
|
+
const relationLines = Object.values(mm.relationTypes).map((r) => {
|
|
10366
|
+
const props = (r.properties ?? []).map(briefProperty);
|
|
10367
|
+
return `- ${r.id} (${r.label}${r.governance ? ", governance" : ""}): ${briefPairs(r.allowedPairs ?? []) || "any pair"}${props.length ? `; properties: ${props.join(", ")}` : ""}`;
|
|
10368
|
+
});
|
|
10369
|
+
const viewpoints = viewpointsOf(mm);
|
|
10370
|
+
const groups = /* @__PURE__ */ new Map();
|
|
10371
|
+
for (const v of viewpoints) groups.set(v.group ?? "", [...groups.get(v.group ?? "") ?? [], v.label]);
|
|
10372
|
+
return [
|
|
10373
|
+
`Metamodel "${mm.name}", in brief. Use ONLY these node and relation types. A node type`,
|
|
10374
|
+
"goes where its line says (in a parent of those types, or at the root); a relation only",
|
|
10375
|
+
"between the pairs its line names. A `group` only gathers elements and holds what its",
|
|
10376
|
+
"place allows. Between an element and one that holds it, only a governance relation may",
|
|
10377
|
+
"be added. `properties` lists the keys valid in a type's `properties` bag, with enum",
|
|
10378
|
+
"options when short and `\u2192 type` for a reference (the id of a node of that type).",
|
|
10379
|
+
"get_model_summary with `types` (node, relation or viewpoint ids or names) gives those",
|
|
10380
|
+
"types in full: labels, every enum option, visibility, layout, a viewpoint's chain.",
|
|
10381
|
+
"",
|
|
10382
|
+
"Node types:",
|
|
10383
|
+
...nodeLines,
|
|
10384
|
+
"",
|
|
10385
|
+
"Relation types:",
|
|
10386
|
+
...relationLines,
|
|
10387
|
+
...viewpoints.length ? ["", "Viewpoints (create_view and update_view take one as `viewpoint`, by id or name):", ...[...groups].map(([group, labels]) => `- ${group ? `${group}: ` : ""}${labels.join(", ")}`)] : []
|
|
10388
|
+
].join("\n");
|
|
10389
|
+
}
|
|
10390
|
+
function metamodelDetail(mm, ids) {
|
|
10391
|
+
const wanted = ids.map((id) => id.trim()).filter(Boolean);
|
|
10392
|
+
const nodeTypes = Object.values(mm?.nodeTypes ?? {});
|
|
10393
|
+
const relationTypes = Object.values(mm?.relationTypes ?? {});
|
|
10394
|
+
const viewpoints = viewpointsOf(mm);
|
|
10395
|
+
const matches = (t, id) => t.id === id || t.label.toLowerCase() === id.toLowerCase();
|
|
10396
|
+
const unknown = wanted.filter((id) => ![...nodeTypes, ...relationTypes, ...viewpoints].some((t) => matches(t, id)));
|
|
10397
|
+
const pick = (list) => list.filter((t) => wanted.some((id) => matches(t, id)));
|
|
10398
|
+
const detail = {
|
|
10399
|
+
...pick(nodeTypes).length ? { nodeTypes: pick(nodeTypes) } : {},
|
|
10400
|
+
...pick(relationTypes).length ? { relationTypes: pick(relationTypes) } : {},
|
|
10401
|
+
...pick(viewpoints).length ? { viewpoints: pick(viewpoints) } : {}
|
|
10402
|
+
};
|
|
10403
|
+
const text3 = [
|
|
10404
|
+
...Object.keys(detail).length ? ["```json", JSON.stringify(detail), "```"] : [],
|
|
10405
|
+
...unknown.length ? [`Not in the metamodel "${mm?.name ?? "none"}": ${unknown.join(", ")}.`] : []
|
|
10406
|
+
].join("\n");
|
|
10407
|
+
return { text: text3, unknown };
|
|
10408
|
+
}
|
|
10168
10409
|
|
|
10169
10410
|
// ../../packages/common/src/ai/systemPrompt.ts
|
|
10170
10411
|
init_define_RADICAL_BUILD();
|
|
@@ -10173,7 +10414,7 @@ var AI_MODELLING_RULES = [
|
|
|
10173
10414
|
"STRICTLY follow the metamodel rules in the context block below: a node/relation that violates allowedParents/allowedAtRoot/cardinality/allowedPairs will be rejected. Call search_model or re-read the metamodel context if unsure.",
|
|
10174
10415
|
"Views are FILTERS over the model graph: a view only stores which nodes are visible. Relations whose both endpoints are visible are shown automatically.",
|
|
10175
10416
|
'When decomposing a requirement into sub-requirements, create each child with add_node (type "requirement") and a `properties` bag setting `ears_type` plus the fields it implies (trigger/precondition/unwanted_condition/feature/action/rationale \u2014 see the metamodel context for the exact set), then link child \u2192 parent with add_relation using relationType "derives".',
|
|
10176
|
-
'A `need` node holds raw free-text input (a brief, user story, notes, raw requirements) in its `description`. Never rewrite it into EARS in place: when asked to turn a need into requirements, create new `requirement` nodes and link each requirement \u2192 need with relationType "derives".',
|
|
10417
|
+
'A `need` node holds raw free-text input (a brief, user story, notes, raw requirements) in its `description`. Never rewrite it into EARS in place: when asked to turn a need into requirements, create new `requirement` nodes and link each requirement \u2192 need with relationType "derives". When you ask a person about it, add your question and their answer to the need\'s description word for word, not a summary: the question on a line that starts with "Q:", the answer on the next line, starting with "A:". Never change an answer once written: when a later answer replaces it, mark the old one "(superseded)" and add the new one. Requirements derive from what the person said, and are checked against it. On each requirement\'s "derives" relation to a need, set `quote` to the words of the need it rests on, copied verbatim, at least two words, one fragment per line, so that each paragraph and list item of an answer is quoted: radical check finds a quote the need does not hold, a part of an answer no requirement quotes, an answer changed since the base, a value the requirement drops or turns round (a limit, a unit, an order), and an example of the person no scenario holds; the MCP server names what each write brings in.',
|
|
10177
10418
|
'A domain model has `domain` nodes (bounded contexts; kind core, supporting or generic) holding `entity` nodes: kind "aggregate-root" for one changed as a whole, "entity" for a part, linked to its root with "part-of". Aggregates refer to each other with "references" (property `cardinality`: one or many), never with "part-of"; plain values (an address, an amount) are not entities. Domains relate through "depends-on" or "partnership" (with its `pattern`).',
|
|
10178
10419
|
'A `state-machine` models the lifecycle of one entity, with SCXML semantics. Put `state` nodes inside it (parentId); a state with child states is compound, kind "parallel" makes its child states regions that are active at once, kind "final" ends the machine or its parent state. Give the machine and every compound state that is not parallel one `pseudostate` of kind "initial" with a single transition to its default child. Add the `event` nodes first, then connect states with relationType "transition", whose `properties` hold `event` (the trigger: the event node\'s id or tempId), an optional `guard`, `actions`, and `raises` (an array of the event ids it publishes). A state that publishes an event links to it with "emits" (property `on`: entry, exit or do). A machine is the lifecycle of one domain `entity` (Reservation, Order): link machine \u2192 entity with "lifecycle-of" (one machine per entity). The C4 elements that run it link to the machine with "implements", and the one that owns the entity\'s data links to the entity with "realises". A state-driven requirement ("While \u2026") whose precondition is a state of a machine points at it with `precondition_state` (the state\'s id).',
|
|
10179
10420
|
'Process logic (a procedure, a workflow, an algorithm) is a `process` holding `step` nodes (parentId), steps nesting in steps. Give each step its `order` among its siblings (1, 2, 3, \u2026: the folder keeps no order), `repeat` ("1", "0..1" optional, "1..n" or "0..n" repeated) with the `condition` it repeats or runs for ("for each order line"), and on a process or step whose children are alternatives `children` "choice" (exactly one runs), or "concurrent" when they run at once. Link a step to who does it with "performed-by" (person, system, container, component or web app), the process to the requirements it meets with "satisfies", and scenarios to it with "verifies". A view of the viewpoint "Process (Warnier)" draws it as a Warnier\u2013Orr diagram; kind "warnier" draws any view\'s hierarchy that way.'
|
|
@@ -10282,9 +10523,9 @@ function migrateNodeType(def) {
|
|
|
10282
10523
|
function migrateCategory(def) {
|
|
10283
10524
|
if (def.id !== "fitness-fn" || !def.properties?.some((p) => p.key === "category")) return def;
|
|
10284
10525
|
const at = def.properties.findIndex((p) => p.key === "category");
|
|
10285
|
-
const
|
|
10286
|
-
const missing = FITNESS_CLASSIFICATION_PROPERTIES.filter((p) => !
|
|
10287
|
-
const properties = [...
|
|
10526
|
+
const kept2 = def.properties.filter((p) => p.key !== "category");
|
|
10527
|
+
const missing = FITNESS_CLASSIFICATION_PROPERTIES.filter((p) => !kept2.some((k) => k.key === p.key));
|
|
10528
|
+
const properties = [...kept2.slice(0, at), ...missing, ...kept2.slice(at)];
|
|
10288
10529
|
const wizard = def.wizard && {
|
|
10289
10530
|
...def.wizard,
|
|
10290
10531
|
steps: def.wizard.steps.map((step) => step.kind === "fields" && step.fields.includes("category") ? { ...step, fields: [...new Set(step.fields.map((f) => f === "category" ? "characteristic" : f))] } : step)
|
|
@@ -10294,9 +10535,9 @@ function migrateCategory(def) {
|
|
|
10294
10535
|
function migrateOldKeys(def) {
|
|
10295
10536
|
if (!CHECKED_TYPES.has(def.id) || !def.properties?.some((p) => OLD_KEYS.includes(p.key))) return def;
|
|
10296
10537
|
const at = def.properties.findIndex((p) => OLD_KEYS.includes(p.key));
|
|
10297
|
-
const
|
|
10298
|
-
const missing = METRICS_PROPERTIES.filter((p) => !
|
|
10299
|
-
const properties = [...
|
|
10538
|
+
const kept2 = def.properties.filter((p) => !OLD_KEYS.includes(p.key));
|
|
10539
|
+
const missing = METRICS_PROPERTIES.filter((p) => !kept2.some((k) => k.key === p.key));
|
|
10540
|
+
const properties = [...kept2.slice(0, at), ...missing, ...kept2.slice(at)];
|
|
10300
10541
|
const wizard = def.wizard && {
|
|
10301
10542
|
...def.wizard,
|
|
10302
10543
|
steps: def.wizard.steps.map((step) => step.kind === "fields" && step.fields.some((f) => OLD_KEYS.includes(f)) ? { ...step, fields: [...new Set(step.fields.map((f) => OLD_KEYS.includes(f) ? "metrics" : f))] } : step)
|
|
@@ -10871,9 +11112,9 @@ function mergeById(base, ours, theirs, where, ctx, layout, idKey = "id") {
|
|
|
10871
11112
|
const out = [];
|
|
10872
11113
|
for (const id of ids) {
|
|
10873
11114
|
const name = entryName(t.get(id) ?? o.get(id) ?? b.get(id), id, ctx);
|
|
10874
|
-
const
|
|
11115
|
+
const kept2 = o.get(id) ?? t.get(id);
|
|
10875
11116
|
if (b.has(id) && !(o.has(id) && t.has(id))) {
|
|
10876
|
-
if (!layout &&
|
|
11117
|
+
if (!layout && kept2 && !sameApartFromLayout(b.get(id), kept2)) ctx.dropped.push({ name, by: o.has(id) ? "ours" : "theirs" });
|
|
10877
11118
|
continue;
|
|
10878
11119
|
}
|
|
10879
11120
|
const value = merge3(b.get(id), o.get(id), t.get(id), [...where.slice(0, -1), name], ctx, layout);
|
|
@@ -10924,8 +11165,8 @@ function mergeIdSet(base, ours, theirs) {
|
|
|
10924
11165
|
const b = new Set(base ?? []);
|
|
10925
11166
|
const o = new Set(ours ?? []);
|
|
10926
11167
|
const t = new Set(theirs ?? []);
|
|
10927
|
-
const
|
|
10928
|
-
return mergeOrder([...b], [...o], [...t], [], null).filter(
|
|
11168
|
+
const kept2 = (id) => o.has(id) && t.has(id) || o.has(id) && !b.has(id) || t.has(id) && !b.has(id);
|
|
11169
|
+
return mergeOrder([...b], [...o], [...t], [], null).filter(kept2);
|
|
10929
11170
|
}
|
|
10930
11171
|
var stepsOf = (seq2) => {
|
|
10931
11172
|
const rels = Array.isArray(seq2?.relationIds) ? seq2.relationIds : [];
|
|
@@ -10957,23 +11198,23 @@ function alignSteps(a, b) {
|
|
|
10957
11198
|
function mergeSteps(base, ours, theirs) {
|
|
10958
11199
|
const b = stepsOf(base), o = stepsOf(ours), t = stepsOf(theirs);
|
|
10959
11200
|
const toO = alignSteps(b, o), toT = alignSteps(b, t);
|
|
10960
|
-
const
|
|
10961
|
-
const
|
|
11201
|
+
const added2 = (side, to) => {
|
|
11202
|
+
const kept2 = /* @__PURE__ */ new Map();
|
|
10962
11203
|
to.forEach((j, i) => {
|
|
10963
|
-
if (j >= 0)
|
|
11204
|
+
if (j >= 0) kept2.set(j, i);
|
|
10964
11205
|
});
|
|
10965
11206
|
const out2 = /* @__PURE__ */ new Map();
|
|
10966
11207
|
let after = -1;
|
|
10967
11208
|
side.forEach((step, j) => {
|
|
10968
|
-
if (
|
|
10969
|
-
after =
|
|
11209
|
+
if (kept2.has(j)) {
|
|
11210
|
+
after = kept2.get(j);
|
|
10970
11211
|
return;
|
|
10971
11212
|
}
|
|
10972
11213
|
out2.set(after, [...out2.get(after) ?? [], step]);
|
|
10973
11214
|
});
|
|
10974
11215
|
return out2;
|
|
10975
11216
|
};
|
|
10976
|
-
const addedO =
|
|
11217
|
+
const addedO = added2(o, toO), addedT = added2(t, toT);
|
|
10977
11218
|
let conflict = false;
|
|
10978
11219
|
const dropped = [];
|
|
10979
11220
|
const out = [];
|
|
@@ -11128,8 +11369,12 @@ function dropStrays(merged, base, ours, theirs, ctx) {
|
|
|
11128
11369
|
merged.relations = merged.relations.filter((r) => {
|
|
11129
11370
|
const end = [r.sourceId, r.targetId].find((id) => !nodes.has(id) && hadNode(id));
|
|
11130
11371
|
if (end === void 0) return true;
|
|
11131
|
-
const by = ours.nodes?.some((n) => n.id === end) ? "ours" : "theirs";
|
|
11132
|
-
|
|
11372
|
+
const by = ours.nodes?.some((n) => n.id === end) ? "ours" : theirs.nodes?.some((n) => n.id === end) ? "theirs" : null;
|
|
11373
|
+
const drawn = by && (by === "ours" ? ours : theirs).relations?.find((x) => x.id === r.id);
|
|
11374
|
+
const was = base.relations?.find((x) => x.id === r.id);
|
|
11375
|
+
if (by && drawn && !(was && sameApartFromLayout(was, drawn))) {
|
|
11376
|
+
ctx.dropped.push({ name: label(end), by, change: `the relation ${label(r.sourceId)} \u2192 ${label(r.targetId)} made to it` });
|
|
11377
|
+
}
|
|
11133
11378
|
gone.add(r.id);
|
|
11134
11379
|
return false;
|
|
11135
11380
|
});
|
|
@@ -11717,9 +11962,9 @@ function needLabelFromDescription(description) {
|
|
|
11717
11962
|
const first = description.split("\n").map((l) => l.replace(/^\s*(#+|[-*+]|\d+[.)])\s+/, "").trim()).find(Boolean);
|
|
11718
11963
|
if (!first) return "Forge brief";
|
|
11719
11964
|
if (first.length <= NEED_LABEL_MAX) return first.replace(/[.:;,]+$/, "");
|
|
11720
|
-
const
|
|
11721
|
-
const space =
|
|
11722
|
-
return `${(space > NEED_LABEL_MAX / 2 ?
|
|
11965
|
+
const cut2 = first.slice(0, NEED_LABEL_MAX);
|
|
11966
|
+
const space = cut2.lastIndexOf(" ");
|
|
11967
|
+
return `${(space > NEED_LABEL_MAX / 2 ? cut2.slice(0, space) : cut2).replace(/[.:;,]+$/, "")}\u2026`;
|
|
11723
11968
|
}
|
|
11724
11969
|
var FORGE_MODEL_LANGUAGE = "English";
|
|
11725
11970
|
function describeForgeLanguages(languages = {}) {
|
|
@@ -12037,12 +12282,33 @@ function serializeForgeRun(status, now4 = /* @__PURE__ */ new Date()) {
|
|
|
12037
12282
|
}
|
|
12038
12283
|
var STAGE_IDS = new Set(FORGE_STAGES.map((s) => s.id));
|
|
12039
12284
|
|
|
12285
|
+
// ../../packages/common/src/formats/assayRunStatus.ts
|
|
12286
|
+
init_define_RADICAL_BUILD();
|
|
12287
|
+
var ASSAY_RUN_FILE = `${STATE_DIR}/assay-run.json`;
|
|
12288
|
+
var ASSAY_STAGES = [
|
|
12289
|
+
{ id: "c4", title: "C4 model", short: "C4" },
|
|
12290
|
+
{ id: "explore", title: "Explore", short: "Explore" },
|
|
12291
|
+
{ id: "documents", title: "Documents", short: "Documents" },
|
|
12292
|
+
{ id: "domain", title: "Domain", short: "Domain" },
|
|
12293
|
+
{ id: "processes", title: "Processes", short: "Processes" },
|
|
12294
|
+
{ id: "states", title: "State machines", short: "States" },
|
|
12295
|
+
{ id: "scenarios", title: "Scenarios", short: "Scenarios" }
|
|
12296
|
+
];
|
|
12297
|
+
function serializeAssayRun(status, now4 = /* @__PURE__ */ new Date()) {
|
|
12298
|
+
const out = { version: 1, ...status, updatedAt: now4.toISOString() };
|
|
12299
|
+
return `${JSON.stringify(out, null, 2)}
|
|
12300
|
+
`;
|
|
12301
|
+
}
|
|
12302
|
+
var STAGE_IDS2 = new Set(ASSAY_STAGES.map((s) => s.id));
|
|
12303
|
+
|
|
12040
12304
|
// ../../packages/common/src/check/index.ts
|
|
12041
12305
|
init_define_RADICAL_BUILD();
|
|
12042
12306
|
|
|
12043
12307
|
// ../../packages/common/src/repositoryMapping.ts
|
|
12044
12308
|
init_define_RADICAL_BUILD();
|
|
12045
12309
|
var REPOSITORY_FILE = ".radical/radical.json";
|
|
12310
|
+
var others = (value, known) => value && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).filter(([k]) => !known.includes(k))) : {};
|
|
12311
|
+
var TOP_KEYS = ["model", "tests", "ci", "implements", "verifies"];
|
|
12046
12312
|
var strings = (v) => typeof v === "string" ? [v] : Array.isArray(v) && v.every((x) => typeof x === "string") ? v : null;
|
|
12047
12313
|
function parseRepositoryFile(text3, file = REPOSITORY_FILE) {
|
|
12048
12314
|
let raw;
|
|
@@ -12061,7 +12327,7 @@ function parseRepositoryFile(text3, file = REPOSITORY_FILE) {
|
|
|
12061
12327
|
const value = raw?.[key];
|
|
12062
12328
|
if (value === void 0) return void 0;
|
|
12063
12329
|
if (!value || typeof value !== "object") throw new Error(`${file}: "${key}" is no object`);
|
|
12064
|
-
const out =
|
|
12330
|
+
const out = others(value, lists);
|
|
12065
12331
|
for (const list2 of lists) {
|
|
12066
12332
|
const v = value[list2];
|
|
12067
12333
|
if (v === void 0) continue;
|
|
@@ -12078,33 +12344,36 @@ function parseRepositoryFile(text3, file = REPOSITORY_FILE) {
|
|
|
12078
12344
|
throw new Error(`${file}: "model" needs "repo" (the address of the model's repository), and "ref" is a branch or tag`);
|
|
12079
12345
|
}
|
|
12080
12346
|
return {
|
|
12081
|
-
...
|
|
12347
|
+
...others(raw, TOP_KEYS),
|
|
12348
|
+
...model ? { model: { repo: model.repo, ...model.ref ? { ref: model.ref } : {}, ...others(model, ["repo", "ref"]) } } : {},
|
|
12082
12349
|
...tests ? { tests } : {},
|
|
12083
12350
|
...ci ? { ci } : {},
|
|
12084
12351
|
implements: list("implements").map((e, i) => {
|
|
12085
12352
|
const paths = strings(e?.paths);
|
|
12086
12353
|
if (typeof e?.element !== "string" || !e.element || !paths) throw new Error(`${file}: implements[${i}] needs "element" (an id) and "paths" (a list of folders)`);
|
|
12087
|
-
return { element: e.element, ...name(e), paths };
|
|
12354
|
+
return { element: e.element, ...name(e), paths, ...others(e, ["element", "name", "paths"]) };
|
|
12088
12355
|
}),
|
|
12089
12356
|
verifies: list("verifies").map((e, i) => {
|
|
12090
12357
|
const tests2 = strings(e?.tests);
|
|
12091
12358
|
if (typeof e?.element !== "string" || !e.element || !tests2) throw new Error(`${file}: verifies[${i}] needs "element" (an id) and "tests" (a list of test ids)`);
|
|
12092
|
-
return { element: e.element, ...name(e), tests: tests2 };
|
|
12359
|
+
return { element: e.element, ...name(e), tests: tests2, ...others(e, ["element", "name", "tests"]) };
|
|
12093
12360
|
})
|
|
12094
12361
|
};
|
|
12095
12362
|
}
|
|
12096
12363
|
function serializeRepositoryFile(file) {
|
|
12364
|
+
const inline = (v) => Array.isArray(v) ? `[${v.map(inline).join(", ")}]` : v && typeof v === "object" ? Object.keys(v).length ? `{ ${Object.entries(v).filter(([, x]) => x !== void 0).map(([k, x]) => `${JSON.stringify(k)}: ${inline(x)}`).join(", ")} }` : "{}" : JSON.stringify(v);
|
|
12365
|
+
const more = (v, known) => Object.entries(others(v, known)).filter(([, x]) => x !== void 0).map(([k, x]) => `, ${JSON.stringify(k)}: ${inline(x)}`).join("");
|
|
12097
12366
|
const head = (m) => `"element": ${JSON.stringify(m.element)}${m.name !== void 0 ? `, "name": ${JSON.stringify(m.name)}` : ""}`;
|
|
12098
|
-
const implemented = file.implements.map((m) => ` { ${head(m)}, "paths": [${m.paths.map((p) => JSON.stringify(p)).join(", ")}] }`);
|
|
12367
|
+
const implemented = file.implements.map((m) => ` { ${head(m)}, "paths": [${m.paths.map((p) => JSON.stringify(p)).join(", ")}]${more(m, ["element", "name", "paths"])} }`);
|
|
12099
12368
|
const verified = file.verifies.map((v) => ` { ${head(v)}, "tests": [${v.tests.length ? `
|
|
12100
12369
|
${v.tests.map((t) => ` ${JSON.stringify(t)}`).join(",\n")}
|
|
12101
|
-
` : ""}] }`);
|
|
12370
|
+
` : ""}]${more(v, ["element", "name", "tests"])} }`);
|
|
12102
12371
|
const section = (key, lines) => ` "${key}": [${lines.length ? `
|
|
12103
12372
|
${lines.join(",\n")}
|
|
12104
12373
|
` : ""}]`;
|
|
12105
|
-
const inline = (v) => `{ ${Object.entries(v).map(([k, list]) => `${JSON.stringify(k)}: [${list.map((x) => JSON.stringify(x)).join(", ")}]`).join(", ")} }`;
|
|
12106
12374
|
const settings = [
|
|
12107
|
-
...
|
|
12375
|
+
...Object.entries(others(file, TOP_KEYS)).filter(([, v]) => v !== void 0).map(([k, v]) => ` ${JSON.stringify(k)}: ${inline(v)}`),
|
|
12376
|
+
...file.model ? [` "model": ${inline(file.model)}`] : [],
|
|
12108
12377
|
...file.tests ? [` "tests": ${inline(file.tests)}`] : [],
|
|
12109
12378
|
...file.ci ? [` "ci": ${inline(file.ci)}`] : []
|
|
12110
12379
|
];
|
|
@@ -12164,7 +12433,30 @@ init_define_RADICAL_BUILD();
|
|
|
12164
12433
|
|
|
12165
12434
|
// ../../packages/common/src/check/reports.ts
|
|
12166
12435
|
init_define_RADICAL_BUILD();
|
|
12436
|
+
var MESSAGE_LINES = 12;
|
|
12437
|
+
var MESSAGE_CHARS = 2e3;
|
|
12438
|
+
var ANSI = /\u001b\[[0-9;]*[A-Za-z]/g;
|
|
12439
|
+
function failureMessage(text3) {
|
|
12440
|
+
if (typeof text3 !== "string") return void 0;
|
|
12441
|
+
const lines = text3.replace(ANSI, "").replace(/\r\n?/g, "\n").split("\n");
|
|
12442
|
+
while (lines.length && !lines[0].trim()) lines.shift();
|
|
12443
|
+
while (lines.length && !lines[lines.length - 1].trim()) lines.pop();
|
|
12444
|
+
if (!lines.length) return void 0;
|
|
12445
|
+
let kept2 = lines.slice(0, MESSAGE_LINES).join("\n");
|
|
12446
|
+
if (kept2.length > MESSAGE_CHARS) kept2 = kept2.slice(0, MESSAGE_CHARS);
|
|
12447
|
+
return kept2.length < lines.join("\n").length ? `${kept2}
|
|
12448
|
+
\u2026` : kept2;
|
|
12449
|
+
}
|
|
12450
|
+
var details = (message, durationMs, line) => {
|
|
12451
|
+
const m = failureMessage(message);
|
|
12452
|
+
return {
|
|
12453
|
+
...m ? { message: m } : {},
|
|
12454
|
+
...typeof durationMs === "number" && Number.isFinite(durationMs) && durationMs >= 0 ? { durationMs: Math.round(durationMs) } : {},
|
|
12455
|
+
...typeof line === "number" && Number.isInteger(line) && line > 0 ? { line } : {}
|
|
12456
|
+
};
|
|
12457
|
+
};
|
|
12167
12458
|
var SEPARATOR = /\s+›\s+/;
|
|
12459
|
+
var ASCII_SEPARATOR = /\s+>\s+/;
|
|
12168
12460
|
var JUNIT_SEPARATOR = /\s+[›>]\s+/;
|
|
12169
12461
|
var normalize = (path) => path.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
12170
12462
|
function parseTestReport(content, name) {
|
|
@@ -12185,10 +12477,14 @@ function parseJestJson(report) {
|
|
|
12185
12477
|
const cases = [];
|
|
12186
12478
|
for (const file of report.testResults) {
|
|
12187
12479
|
for (const a of file.assertionResults ?? []) {
|
|
12480
|
+
const status = a.status === "passed" ? "passed" : a.status === "failed" ? "failed" : "skipped";
|
|
12481
|
+
const messages = Array.isArray(a.failureMessages) ? a.failureMessages.filter((m) => typeof m === "string") : [];
|
|
12188
12482
|
cases.push({
|
|
12189
12483
|
file: normalize(file.name),
|
|
12190
12484
|
title: [...a.ancestorTitles ?? [], a.title],
|
|
12191
|
-
status
|
|
12485
|
+
status,
|
|
12486
|
+
// Vitest writes the location only with includeTaskLocation.
|
|
12487
|
+
...details(status === "failed" ? messages.join("\n") : void 0, a.duration, a.location?.line)
|
|
12192
12488
|
});
|
|
12193
12489
|
}
|
|
12194
12490
|
}
|
|
@@ -12201,11 +12497,16 @@ function parsePlaywrightJson(report) {
|
|
|
12201
12497
|
const walk = (suite, titles, file) => {
|
|
12202
12498
|
for (const spec of suite.specs ?? []) {
|
|
12203
12499
|
const statuses = (spec.tests ?? []).map((t) => t.status);
|
|
12500
|
+
const status = statuses.includes("unexpected") ? "failed" : statuses.length && statuses.every((s) => s === "skipped") ? "skipped" : "passed";
|
|
12501
|
+
const last = (spec.tests ?? []).map((t) => t.results?.[t.results.length - 1]).filter((r) => !!r);
|
|
12502
|
+
const failedTry = (spec.tests ?? []).filter((t) => t.status === "unexpected").map((t) => t.results?.[t.results.length - 1]).find((r) => r);
|
|
12503
|
+
const message = failedTry ? failedTry.error?.message ?? failedTry.errors?.find((e) => e.message)?.message : void 0;
|
|
12504
|
+
const durations = last.map((r) => r.duration).filter((d) => typeof d === "number");
|
|
12204
12505
|
cases.push({
|
|
12205
12506
|
file: root2 ? `${root2}/${normalize(spec.file ?? file)}` : normalize(spec.file ?? file),
|
|
12206
12507
|
title: [...titles, spec.title],
|
|
12207
|
-
|
|
12208
|
-
status
|
|
12508
|
+
status,
|
|
12509
|
+
...details(status === "failed" ? message : void 0, durations.length ? Math.max(...durations) : void 0, spec.line)
|
|
12209
12510
|
});
|
|
12210
12511
|
}
|
|
12211
12512
|
for (const child of suite.suites ?? []) walk(child, [...titles, child.title], file);
|
|
@@ -12223,29 +12524,86 @@ function parseJUnit(xml) {
|
|
|
12223
12524
|
const body = m[3] ?? "";
|
|
12224
12525
|
const file = attrs.file ?? attrs.classname ?? "";
|
|
12225
12526
|
const title = (attrs.name ?? "").split(JUNIT_SEPARATOR);
|
|
12527
|
+
const failure = /<(failure|error)\b([^>]*?)(\/>|>([\s\S]*?)<\/\1>)/.exec(body);
|
|
12528
|
+
const raw = failure?.[4] ?? "";
|
|
12529
|
+
const text3 = /<!\[CDATA\[/.test(raw) ? raw.replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, "$1") : unescapeXml(raw);
|
|
12530
|
+
const message = failure ? text3.trim() ? text3 : attributes(failure[2]).message : void 0;
|
|
12531
|
+
const seconds = attrs.time !== void 0 ? Number(attrs.time) : void 0;
|
|
12532
|
+
const line = attrs.line !== void 0 ? Number(attrs.line) : void 0;
|
|
12226
12533
|
cases.push({
|
|
12227
12534
|
file: normalize(file),
|
|
12228
12535
|
title,
|
|
12229
|
-
status:
|
|
12536
|
+
status: failure ? "failed" : /<skipped\b/.test(body) ? "skipped" : "passed",
|
|
12537
|
+
...details(message, seconds !== void 0 ? seconds * 1e3 : void 0, line)
|
|
12230
12538
|
});
|
|
12231
12539
|
}
|
|
12232
12540
|
return cases;
|
|
12233
12541
|
}
|
|
12542
|
+
var RUNNER_PREFIX = /^(?:(?:\[[^\]]*\]|\|[^|]*\|)(?:\s+|$))+/;
|
|
12543
|
+
var FILE_LOCATION = /:\d+(?::\d+)?$/;
|
|
12544
|
+
function testIdParts(raw) {
|
|
12545
|
+
const parts2 = raw.split(SEPARATOR.test(raw) ? SEPARATOR : ASCII_SEPARATOR).map((part) => part.trim());
|
|
12546
|
+
const file = parts2[0].replace(RUNNER_PREFIX, "");
|
|
12547
|
+
if (!file && parts2.length > 1) parts2.shift();
|
|
12548
|
+
else parts2[0] = file;
|
|
12549
|
+
parts2[0] = parts2[0].replace(FILE_LOCATION, "");
|
|
12550
|
+
return parts2;
|
|
12551
|
+
}
|
|
12552
|
+
var canonicalTestId = (raw) => testIdParts(raw.trim()).filter(Boolean).join(" \u203A ");
|
|
12553
|
+
function rebindTests(bound, adds, drops) {
|
|
12554
|
+
const dropped = new Set(drops.map(canonicalTestId));
|
|
12555
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12556
|
+
const tests = [];
|
|
12557
|
+
for (const [test, id] of [...bound.map((t) => [t, canonicalTestId(t)]), ...adds.map((t) => [canonicalTestId(t), canonicalTestId(t)])]) {
|
|
12558
|
+
if (!id || dropped.has(id) || seen.has(id)) continue;
|
|
12559
|
+
seen.add(id);
|
|
12560
|
+
tests.push(test);
|
|
12561
|
+
}
|
|
12562
|
+
return tests;
|
|
12563
|
+
}
|
|
12234
12564
|
function parseTestIds(text3) {
|
|
12235
12565
|
if (typeof text3 !== "string") return [];
|
|
12236
12566
|
return text3.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((raw) => {
|
|
12237
|
-
const [file, ...title] = raw
|
|
12567
|
+
const [file, ...title] = testIdParts(raw);
|
|
12238
12568
|
return { raw, file: normalize(file), title };
|
|
12239
12569
|
});
|
|
12240
12570
|
}
|
|
12241
12571
|
var fileMatches = (reportFile, idFile) => reportFile === idFile || reportFile.endsWith("/" + idFile) || idFile.endsWith("/" + reportFile);
|
|
12242
12572
|
function findTests(id, cases) {
|
|
12573
|
+
let found = FOUND.get(cases);
|
|
12574
|
+
if (!found) {
|
|
12575
|
+
found = /* @__PURE__ */ new Map();
|
|
12576
|
+
FOUND.set(cases, found);
|
|
12577
|
+
}
|
|
12578
|
+
const key = `${id.file}\0${id.title.join("\0")}`;
|
|
12579
|
+
let result = found.get(key);
|
|
12580
|
+
if (!result) {
|
|
12581
|
+
result = findTestsIn(id, cases);
|
|
12582
|
+
found.set(key, result);
|
|
12583
|
+
}
|
|
12584
|
+
return result;
|
|
12585
|
+
}
|
|
12586
|
+
var FOUND = /* @__PURE__ */ new WeakMap();
|
|
12587
|
+
var BY_NAME = /* @__PURE__ */ new WeakMap();
|
|
12588
|
+
var baseName = (file) => file.slice(file.lastIndexOf("/") + 1);
|
|
12589
|
+
function findTestsIn(id, cases) {
|
|
12243
12590
|
const n = id.title.length;
|
|
12244
12591
|
if (!n) {
|
|
12245
12592
|
const under = cases.filter((c) => fileMatches(c.file, id.file) || c.file.includes(`/${id.file.replace(/\/$/, "")}/`) || c.file.startsWith(`${id.file.replace(/\/$/, "")}/`));
|
|
12246
12593
|
return { fileSeen: under.length > 0, matches: under };
|
|
12247
12594
|
}
|
|
12248
|
-
|
|
12595
|
+
let byName = BY_NAME.get(cases);
|
|
12596
|
+
if (!byName) {
|
|
12597
|
+
byName = /* @__PURE__ */ new Map();
|
|
12598
|
+
for (const c of cases) {
|
|
12599
|
+
const name = baseName(c.file);
|
|
12600
|
+
const list = byName.get(name);
|
|
12601
|
+
if (list) list.push(c);
|
|
12602
|
+
else byName.set(name, [c]);
|
|
12603
|
+
}
|
|
12604
|
+
BY_NAME.set(cases, byName);
|
|
12605
|
+
}
|
|
12606
|
+
const inFile = (byName.get(baseName(id.file)) ?? []).filter((c) => fileMatches(c.file, id.file));
|
|
12249
12607
|
const key = id.title.join(" \u203A ");
|
|
12250
12608
|
const tail = inFile.filter((c) => c.title.length >= n && c.title.slice(-n).join(" \u203A ") === key);
|
|
12251
12609
|
const matches = tail.length ? tail : inFile.filter((c) => c.title.length > n && c.title.slice(0, n).join(" \u203A ") === key);
|
|
@@ -12268,6 +12626,17 @@ function globMatch(glob, file) {
|
|
|
12268
12626
|
|
|
12269
12627
|
// ../../packages/common/src/check/metrics.ts
|
|
12270
12628
|
init_define_RADICAL_BUILD();
|
|
12629
|
+
var isStringMap = (v) => !!v && typeof v === "object" && !Array.isArray(v) && Object.values(v).every((x) => typeof x === "string");
|
|
12630
|
+
function parseMeasurementStore(text3) {
|
|
12631
|
+
let data;
|
|
12632
|
+
try {
|
|
12633
|
+
data = JSON.parse(text3);
|
|
12634
|
+
} catch {
|
|
12635
|
+
return [];
|
|
12636
|
+
}
|
|
12637
|
+
if (data?.version !== 1 || !Array.isArray(data.measurements)) return [];
|
|
12638
|
+
return data.measurements.filter((m) => !!m && typeof m.metric === "string" && typeof m.value === "number" && Number.isFinite(m.value) && isStringMap(m.labels) && typeof m.source === "string" && typeof m.at === "string" && !Number.isNaN(Date.parse(m.at)));
|
|
12639
|
+
}
|
|
12271
12640
|
var TEST_LINE = /^test\((.+)\)(?:\s+passed)?$/;
|
|
12272
12641
|
var REVIEW_LINE = /^review\((.+)\)\s+passed$/i;
|
|
12273
12642
|
var REVIEW_METRIC = "review";
|
|
@@ -12398,17 +12767,18 @@ var BOUND_TESTS = "boundTests";
|
|
|
12398
12767
|
function withBoundTests(nodes, verifies) {
|
|
12399
12768
|
if (!verifies?.length) return nodes;
|
|
12400
12769
|
const bound = /* @__PURE__ */ new Map();
|
|
12401
|
-
for (const v of verifies) bound.set(v.element, [...bound.get(v.element) ?? [], ...v.tests]);
|
|
12770
|
+
for (const v of verifies) bound.set(v.element, rebindTests([...bound.get(v.element) ?? [], ...v.tests], [], []));
|
|
12402
12771
|
return nodes.map((n) => bound.has(n.id) ? { ...n, [BOUND_TESTS]: bound.get(n.id) } : n);
|
|
12403
12772
|
}
|
|
12404
|
-
var
|
|
12773
|
+
var boundConditions = (node) => {
|
|
12405
12774
|
const bound = node[BOUND_TESTS];
|
|
12406
|
-
return [
|
|
12407
|
-
...parseConditions(node.metrics),
|
|
12408
|
-
...Array.isArray(bound) ? bound.map((id) => parseCondition(`test(${id}) passed`)) : []
|
|
12409
|
-
];
|
|
12775
|
+
return Array.isArray(bound) ? bound.map((id) => parseCondition(`test(${id}) passed`)) : [];
|
|
12410
12776
|
};
|
|
12411
|
-
var
|
|
12777
|
+
var conditionsOf = (node) => [
|
|
12778
|
+
...parseConditions(node.metrics),
|
|
12779
|
+
...boundConditions(node)
|
|
12780
|
+
];
|
|
12781
|
+
var testIdsOf = (node) => (originOf(node) ? boundConditions(node) : conditionsOf(node)).flatMap((c) => c.kind === "test" ? [c.id] : []);
|
|
12412
12782
|
var testOutcome = (id, model) => {
|
|
12413
12783
|
const { fileSeen, matches } = findTests(id, model.tests ?? []);
|
|
12414
12784
|
return matches.length ? outcomeOf(matches) : fileSeen ? "not-found" : "not-run";
|
|
@@ -12427,6 +12797,21 @@ function conditionResults(node, model, element) {
|
|
|
12427
12797
|
return { condition: c.raw, outcome: e.outcome, ...e.measurement ? { measurement: e.measurement } : {}, ...e.detail ? { detail: e.detail } : {} };
|
|
12428
12798
|
});
|
|
12429
12799
|
}
|
|
12800
|
+
var boundResults = (node, model) => boundConditions(node).map((c) => c.kind === "test" ? { condition: c.raw, test: c.id.raw, outcome: testOutcome(c.id, model) } : { condition: c.raw, outcome: "invalid", ...c.kind === "invalid" ? { detail: c.problem } : {} });
|
|
12801
|
+
var PASSED = (o) => o === "passed";
|
|
12802
|
+
var FAILING = (o) => o === "failed" || o === "not-found" || o === "invalid";
|
|
12803
|
+
function checkedStatus(outcomes, combine = { kind: "all" }) {
|
|
12804
|
+
if (!outcomes.length) return "no-checks";
|
|
12805
|
+
const list = outcomes.map((o) => o.outcome);
|
|
12806
|
+
const passed = list.filter(PASSED).length;
|
|
12807
|
+
const failing = list.filter(FAILING).length;
|
|
12808
|
+
const pending = () => list.includes("stale") ? "stale" : "not-run";
|
|
12809
|
+
if (combine.kind === "any") return passed ? "passed" : failing === list.length ? "failed" : pending();
|
|
12810
|
+
const need = combine.kind === "all" ? list.length : Math.min(combine.n, list.length);
|
|
12811
|
+
if (passed >= need) return "passed";
|
|
12812
|
+
if (list.length - failing < need) return "failed";
|
|
12813
|
+
return pending();
|
|
12814
|
+
}
|
|
12430
12815
|
var ELEMENT_LABEL = "element";
|
|
12431
12816
|
function appliedElements(model, ff) {
|
|
12432
12817
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -12442,8 +12827,79 @@ function elementConditions(node, model, element) {
|
|
|
12442
12827
|
const metricLines = new Set(conditionsOf(node).flatMap((c) => c.kind === "metric" ? [c.raw] : []));
|
|
12443
12828
|
return conditionResults(node, model, element).filter((r) => metricLines.has(r.condition));
|
|
12444
12829
|
}
|
|
12830
|
+
var combineOf = (node) => parseCombine(node.combine) ?? { kind: "all" };
|
|
12831
|
+
function combineElements(statuses) {
|
|
12832
|
+
if (statuses.includes("failed")) return "failed";
|
|
12833
|
+
if (statuses.every((s) => s === "passed")) return "passed";
|
|
12834
|
+
return statuses.includes("stale") ? "stale" : "not-run";
|
|
12835
|
+
}
|
|
12836
|
+
var RELATION_INDEX = /* @__PURE__ */ new WeakMap();
|
|
12837
|
+
var NO_RELATIONS = { from: /* @__PURE__ */ new Map(), to: /* @__PURE__ */ new Map() };
|
|
12838
|
+
function relationsOf(model, type2) {
|
|
12839
|
+
let byType = RELATION_INDEX.get(model.relations);
|
|
12840
|
+
if (!byType) {
|
|
12841
|
+
const built = /* @__PURE__ */ new Map();
|
|
12842
|
+
for (const r of Object.values(model.relations)) {
|
|
12843
|
+
if (r.relationType === void 0) continue;
|
|
12844
|
+
let index = built.get(r.relationType);
|
|
12845
|
+
if (!index) {
|
|
12846
|
+
index = { from: /* @__PURE__ */ new Map(), to: /* @__PURE__ */ new Map() };
|
|
12847
|
+
built.set(r.relationType, index);
|
|
12848
|
+
}
|
|
12849
|
+
const from = index.from.get(r.sourceId);
|
|
12850
|
+
if (from) from.push(r);
|
|
12851
|
+
else index.from.set(r.sourceId, [r]);
|
|
12852
|
+
const to = index.to.get(r.targetId);
|
|
12853
|
+
if (to) to.push(r);
|
|
12854
|
+
else index.to.set(r.targetId, [r]);
|
|
12855
|
+
}
|
|
12856
|
+
byType = built;
|
|
12857
|
+
RELATION_INDEX.set(model.relations, byType);
|
|
12858
|
+
}
|
|
12859
|
+
return byType.get(type2) ?? NO_RELATIONS;
|
|
12860
|
+
}
|
|
12445
12861
|
function linkedNodes(model, id, relationType, end, type2) {
|
|
12446
|
-
|
|
12862
|
+
const index = relationsOf(model, relationType);
|
|
12863
|
+
return ((end === "source" ? index.to.get(id) : index.from.get(id)) ?? []).map((r) => model.nodes[end === "source" ? r.sourceId : r.targetId]).filter((n) => !!n && (!type2 || n.type === type2));
|
|
12864
|
+
}
|
|
12865
|
+
function computeEvidence(model) {
|
|
12866
|
+
const nodes = {};
|
|
12867
|
+
for (const node of Object.values(model.nodes)) {
|
|
12868
|
+
if (!TESTED_TYPES.includes(node.type)) continue;
|
|
12869
|
+
const origin = originOf(node);
|
|
12870
|
+
const elements = measuredElements(model, node).map((element) => {
|
|
12871
|
+
const conditions2 = elementConditions(node, model, element);
|
|
12872
|
+
return { id: element.id, label: element.label, status: checkedStatus(conditions2, combineOf(node)), conditions: conditions2 };
|
|
12873
|
+
});
|
|
12874
|
+
const bound = origin ? boundResults(node, model) : [];
|
|
12875
|
+
if (origin && !elements.length && !bound.length) continue;
|
|
12876
|
+
const conditions = origin ? bound : elements.length ? conditionResults(node, model).filter((r) => r.test) : conditionResults(node, model);
|
|
12877
|
+
const own = elements.length && conditions.length ? [checkedStatus(conditions)] : [];
|
|
12878
|
+
nodes[node.id] = {
|
|
12879
|
+
type: node.type,
|
|
12880
|
+
label: node.label,
|
|
12881
|
+
status: elements.length ? combineElements([...own, ...elements.map((e) => e.status)]) : checkedStatus(conditions, origin ? void 0 : combineOf(node)),
|
|
12882
|
+
tests: testOutcomes(node, model).map((o) => ({ id: o.id.raw, outcome: o.outcome })),
|
|
12883
|
+
conditions,
|
|
12884
|
+
...elements.length ? { elements } : {},
|
|
12885
|
+
...origin ? { origin } : {}
|
|
12886
|
+
};
|
|
12887
|
+
}
|
|
12888
|
+
const verified = (node, checkers) => {
|
|
12889
|
+
const statuses = checkers.map((c) => nodes[c.id]?.status);
|
|
12890
|
+
nodes[node.id] = {
|
|
12891
|
+
type: node.type,
|
|
12892
|
+
label: node.label,
|
|
12893
|
+
status: statuses.includes("failed") ? "broken" : statuses.length && statuses.every((s) => s === "passed") ? "verified" : "unverified",
|
|
12894
|
+
by: checkers.map((c) => c.id)
|
|
12895
|
+
};
|
|
12896
|
+
};
|
|
12897
|
+
for (const node of Object.values(model.nodes)) {
|
|
12898
|
+
if (originOf(node)) continue;
|
|
12899
|
+
if (node.type === "requirement") verified(node, linkedNodes(model, node.id, "verifies", "source", "scenario"));
|
|
12900
|
+
else if (node.type === "adr") verified(node, linkedNodes(model, node.id, "implements", "source", "fitness-fn"));
|
|
12901
|
+
}
|
|
12902
|
+
return { version: 1, testCases: model.tests?.length ?? 0, ...model.measurements ? { measurements: model.measurements.length } : {}, nodes };
|
|
12447
12903
|
}
|
|
12448
12904
|
|
|
12449
12905
|
// ../../packages/common/src/concerns.ts
|
|
@@ -12623,7 +13079,9 @@ function buildConceptInsert(concept, options) {
|
|
|
12623
13079
|
if (!srcId || !dstId) continue;
|
|
12624
13080
|
const relId = newId();
|
|
12625
13081
|
if (typeof raw.id === "string") relIdMap.set(raw.id, relId);
|
|
13082
|
+
const { id: _id, sourceId: _source, targetId: _target, ...own } = raw;
|
|
12626
13083
|
relations[relId] = {
|
|
13084
|
+
...own,
|
|
12627
13085
|
id: relId,
|
|
12628
13086
|
sourceId: srcId,
|
|
12629
13087
|
targetId: dstId,
|
|
@@ -12713,9 +13171,13 @@ function questionLine(param) {
|
|
|
12713
13171
|
const choices = param.options?.length ? ` (${param.options.map((o) => `${o.value}: ${o.label}`).join(" | ")})` : "";
|
|
12714
13172
|
return `${param.label}${choices}`;
|
|
12715
13173
|
}
|
|
12716
|
-
function concernTargets(pack, nodes, relations) {
|
|
12717
|
-
|
|
12718
|
-
|
|
13174
|
+
function concernTargets(pack, nodes, relations, asked) {
|
|
13175
|
+
let rows = asked?.get(pack.concern.trigger);
|
|
13176
|
+
if (!rows) {
|
|
13177
|
+
const { result } = runModelQuery(pack.concern.trigger, { nodes, relations, unordered: true });
|
|
13178
|
+
rows = result.rows ?? [];
|
|
13179
|
+
asked?.set(pack.concern.trigger, rows);
|
|
13180
|
+
}
|
|
12719
13181
|
const key = /^\s*LIST\s+RELATIONS/i.test(pack.concern.trigger) ? pack.concern.applyTo === "source" ? "sourceId" : "targetId" : "id";
|
|
12720
13182
|
const ids = new Set(rows.map((row) => row[key]).filter((id) => typeof id === "string" && !!nodes[id]));
|
|
12721
13183
|
return [...ids].sort((a, b) => nodes[a].label.localeCompare(nodes[b].label) || a.localeCompare(b));
|
|
@@ -12723,14 +13185,29 @@ function concernTargets(pack, nodes, relations) {
|
|
|
12723
13185
|
var holdsConcerns = (metamodel) => !!metamodel?.nodeTypes.adr?.properties?.some((p) => p.key === CONCERN_KEY);
|
|
12724
13186
|
function concernStatuses(packs, nodes, relations) {
|
|
12725
13187
|
const out = [];
|
|
13188
|
+
const adrsBy = /* @__PURE__ */ new Map();
|
|
13189
|
+
for (const n of Object.values(nodes)) {
|
|
13190
|
+
if (n.type !== "adr") continue;
|
|
13191
|
+
const concern = prop(n, CONCERN_KEY);
|
|
13192
|
+
const list = adrsBy.get(concern);
|
|
13193
|
+
if (list) list.push(n);
|
|
13194
|
+
else adrsBy.set(concern, [n]);
|
|
13195
|
+
}
|
|
13196
|
+
const constrained = /* @__PURE__ */ new Map();
|
|
13197
|
+
for (const r of Object.values(relations)) {
|
|
13198
|
+
if (r.relationType !== "constrains") continue;
|
|
13199
|
+
const list = constrained.get(r.sourceId);
|
|
13200
|
+
if (list) list.push(r.targetId);
|
|
13201
|
+
else constrained.set(r.sourceId, [r.targetId]);
|
|
13202
|
+
}
|
|
13203
|
+
const asked = /* @__PURE__ */ new Map();
|
|
12726
13204
|
for (const pack of packs) {
|
|
12727
|
-
const targets = concernTargets(pack, nodes, relations);
|
|
13205
|
+
const targets = concernTargets(pack, nodes, relations, asked);
|
|
12728
13206
|
if (!targets.length) continue;
|
|
12729
|
-
const marked =
|
|
12730
|
-
const accepted = new Set(marked.filter((n) => prop(n, "status") === "accepted").map((n) => n.id));
|
|
13207
|
+
const marked = adrsBy.get(pack.concern.id) ?? [];
|
|
12731
13208
|
const settled = /* @__PURE__ */ new Set();
|
|
12732
|
-
for (const
|
|
12733
|
-
if (
|
|
13209
|
+
for (const n of marked) {
|
|
13210
|
+
if (prop(n, "status") === "accepted") for (const id of constrained.get(n.id) ?? []) settled.add(id);
|
|
12734
13211
|
}
|
|
12735
13212
|
const covered = (id) => {
|
|
12736
13213
|
for (let cur = id; cur; cur = nodes[cur]?.parentId) if (settled.has(cur)) return true;
|
|
@@ -12783,8 +13260,8 @@ function pickVariant(concept, values) {
|
|
|
12783
13260
|
const { [HUB_WHEN_KEY]: _when, ...rest } = n;
|
|
12784
13261
|
return rest;
|
|
12785
13262
|
});
|
|
12786
|
-
const
|
|
12787
|
-
const relations = (concept.relations ?? []).filter((r) =>
|
|
13263
|
+
const kept2 = new Set(nodes.map((n) => n.id));
|
|
13264
|
+
const relations = (concept.relations ?? []).filter((r) => kept2.has(r.sourceId) && kept2.has(r.targetId));
|
|
12788
13265
|
return { ...concept, nodes, relations };
|
|
12789
13266
|
}
|
|
12790
13267
|
function metamodelProblem(concept, metamodel) {
|
|
@@ -12802,8 +13279,8 @@ function metamodelProblem(concept, metamodel) {
|
|
|
12802
13279
|
}
|
|
12803
13280
|
function bindProblem(element, metamodel) {
|
|
12804
13281
|
if (!element) return "no such element";
|
|
12805
|
-
const
|
|
12806
|
-
if (!
|
|
13282
|
+
const allows2 = (type2, from, to) => !metamodel || !!metamodel.relationTypes[type2]?.allowedPairs.some((p) => p.from === from && p.to === to);
|
|
13283
|
+
if (!allows2("constrains", "adr", element.type) || !allows2("satisfies", element.type, "requirement")) {
|
|
12807
13284
|
return `${/^[aeiou]/.test(element.type) ? "an" : "a"} ${element.type} ("${element.label}") cannot be constrained by an ADR and satisfy requirements`;
|
|
12808
13285
|
}
|
|
12809
13286
|
return null;
|
|
@@ -12902,21 +13379,405 @@ function answerTexts(params, values) {
|
|
|
12902
13379
|
}));
|
|
12903
13380
|
}
|
|
12904
13381
|
|
|
13382
|
+
// ../../packages/common/src/check/words.ts
|
|
13383
|
+
init_define_RADICAL_BUILD();
|
|
13384
|
+
function kept(read2) {
|
|
13385
|
+
const found = /* @__PURE__ */ new Map();
|
|
13386
|
+
return (text3) => {
|
|
13387
|
+
let r = found.get(text3);
|
|
13388
|
+
if (r === void 0) {
|
|
13389
|
+
if (found.size > 2e4) found.clear();
|
|
13390
|
+
r = read2(text3);
|
|
13391
|
+
found.set(text3, r);
|
|
13392
|
+
}
|
|
13393
|
+
return r;
|
|
13394
|
+
};
|
|
13395
|
+
}
|
|
13396
|
+
var plainWords = kept((text3) => text3.replace(/\r/g, "").replace(/^[ \t]*#{1,6}[ \t]+/gm, "").replace(/^[ \t]*(?:[-*+>]|\d+[.)])[ \t]+/gm, "").replace(/\*\*|__|`/g, "").replace(/(^|[\s([{"'])[*_](?=\S)/g, "$1").replace(/(\S)[*_](?=[\s)\]}"'.,;:!?]|$)/g, "$1").replace(/[‐-―−]/g, "-").replace(/[‘’‚]/g, "'").replace(/[“”„]/g, '"').replace(/[ ]/g, " ").toLowerCase().replace(/\s+/g, " ").trim());
|
|
13397
|
+
var WORD = /[\p{L}\p{N}]/u;
|
|
13398
|
+
var DIGIT = /\d/;
|
|
13399
|
+
function wordsAt(text3, piece, from = 0) {
|
|
13400
|
+
if (!piece) return -1;
|
|
13401
|
+
for (let i = text3.indexOf(piece, from); i >= 0; i = text3.indexOf(piece, i + 1)) {
|
|
13402
|
+
const end = i + piece.length;
|
|
13403
|
+
const first = piece[0];
|
|
13404
|
+
const last = piece[piece.length - 1];
|
|
13405
|
+
const before = text3[i - 1] ?? "";
|
|
13406
|
+
const after = text3[end] ?? "";
|
|
13407
|
+
const startOk = !WORD.test(first) || !before || !WORD.test(before) && !(DIGIT.test(first) && /[.,]/.test(before) && DIGIT.test(text3[i - 2] ?? ""));
|
|
13408
|
+
const endOk = !WORD.test(last) || !after || !WORD.test(after) && !(DIGIT.test(last) && /[.,]/.test(after) && DIGIT.test(text3[end + 1] ?? ""));
|
|
13409
|
+
if (startOk && endOk) return end;
|
|
13410
|
+
}
|
|
13411
|
+
return -1;
|
|
13412
|
+
}
|
|
13413
|
+
var QA_START = /^[ \t]*(?:[-*+>][ \t]*)?(?:\*\*|__)?[ \t]*(Q|A|Question|Answer)[ \t]*\d*[ \t]*(?:\*\*|__)?[ \t]*:(?:[ \t]*(?:\*\*|__)(?=\s|$))?[ \t]*/i;
|
|
13414
|
+
var INLINE_ANSWER = /([?.!)"'*_])[ \t]+(?:\*\*|__)?(?:A|Answer)[ \t]*\d*[ \t]*(?:\*\*|__)?[ \t]*:(?:[ \t]*(?:\*\*|__)(?=\s|$))?[ \t]*/;
|
|
13415
|
+
var unwrap = (text3) => {
|
|
13416
|
+
let t = text3.trim();
|
|
13417
|
+
if ((t.match(/\*\*/g) ?? []).length % 2) t = t.replace(/^\*\*\s*|\s*\*\*$/g, "");
|
|
13418
|
+
if ((t.match(/__/g) ?? []).length % 2) t = t.replace(/^__\s*|\s*__$/g, "");
|
|
13419
|
+
return t.trim();
|
|
13420
|
+
};
|
|
13421
|
+
var needParts = kept(readNeedParts);
|
|
13422
|
+
function readNeedParts(text3) {
|
|
13423
|
+
const parts2 = [{ kind: "intro", lines: [] }];
|
|
13424
|
+
for (const line of text3.split("\n")) {
|
|
13425
|
+
const m = QA_START.exec(line);
|
|
13426
|
+
if (!m) {
|
|
13427
|
+
parts2[parts2.length - 1].lines.push(line);
|
|
13428
|
+
continue;
|
|
13429
|
+
}
|
|
13430
|
+
const rest = line.slice(m[0].length);
|
|
13431
|
+
if (/^a/i.test(m[1])) {
|
|
13432
|
+
parts2.push({ kind: "answer", lines: [rest] });
|
|
13433
|
+
continue;
|
|
13434
|
+
}
|
|
13435
|
+
const inline = INLINE_ANSWER.exec(rest);
|
|
13436
|
+
if (inline) {
|
|
13437
|
+
parts2.push({ kind: "question", lines: [rest.slice(0, inline.index + inline[1].length)] });
|
|
13438
|
+
parts2.push({ kind: "answer", lines: [rest.slice(inline.index + inline[0].length)] });
|
|
13439
|
+
} else parts2.push({ kind: "question", lines: [rest] });
|
|
13440
|
+
}
|
|
13441
|
+
return parts2.map((p) => ({ kind: p.kind, text: unwrap(p.lines.join("\n")) })).filter((p) => p.text);
|
|
13442
|
+
}
|
|
13443
|
+
var needAnswers = (text3) => needParts(text3).filter((p) => p.kind === "answer").map((p) => p.text);
|
|
13444
|
+
var quoteFragments = (quote3) => typeof quote3 === "string" ? fragmentsOf(quote3) : [];
|
|
13445
|
+
var fragmentsOf = kept((quote3) => {
|
|
13446
|
+
return quote3.split("\n").map((line) => line.trim().replace(/^["'“‘„>]+|["'”’]+$/g, "").trim()).filter(Boolean).map((line) => line.split(/…|\.\.\./).map((piece) => plainWords(piece).replace(/^["']+|["']+$/g, "").trim()).filter(Boolean)).filter((pieces) => pieces.length);
|
|
13447
|
+
});
|
|
13448
|
+
function quoteFound(needText, pieces) {
|
|
13449
|
+
if (pieces.length === 1) return wordsAt(plainWords(needText), pieces[0]) >= 0;
|
|
13450
|
+
return needParts(needText).some((part) => {
|
|
13451
|
+
const text3 = plainWords(part.text);
|
|
13452
|
+
let at = 0;
|
|
13453
|
+
for (const piece of pieces) {
|
|
13454
|
+
at = wordsAt(text3, piece, at);
|
|
13455
|
+
if (at < 0) return false;
|
|
13456
|
+
}
|
|
13457
|
+
return true;
|
|
13458
|
+
});
|
|
13459
|
+
}
|
|
13460
|
+
var fragmentWords = (pieces) => pieces.join(" ").split(" ").filter((w) => WORD.test(w)).length;
|
|
13461
|
+
var UNITS = { zero: 0, one: 1, two: 2, three: 3, four: 4, five: 5, six: 6, seven: 7, eight: 8, nine: 9, ten: 10, eleven: 11, twelve: 12, thirteen: 13, fourteen: 14, fifteen: 15, sixteen: 16, seventeen: 17, eighteen: 18, nineteen: 19 };
|
|
13462
|
+
var TENS = { twenty: 20, thirty: 30, forty: 40, fifty: 50, sixty: 60, seventy: 70, eighty: 80, ninety: 90 };
|
|
13463
|
+
var SCALES = { hundred: 100, thousand: 1e3, million: 1e6 };
|
|
13464
|
+
var has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
|
13465
|
+
var isNumberWord = (w) => has(UNITS, w) || has(TENS, w) || has(SCALES, w);
|
|
13466
|
+
function numerals(text3) {
|
|
13467
|
+
return text3.replace(/\b(?:(?:zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety|hundred|thousand|million)(?:[ -]+(?:and[ -]+)?|\b))+/gi, (run) => {
|
|
13468
|
+
const words2 = run.toLowerCase().split(/[ -]+/).filter((w) => w && w !== "and");
|
|
13469
|
+
if (!words2.length || words2.some((w) => !isNumberWord(w))) return run;
|
|
13470
|
+
if (words2.length === 1 && words2[0] === "one") return run;
|
|
13471
|
+
if (has(SCALES, words2[0])) return run;
|
|
13472
|
+
let total = 0;
|
|
13473
|
+
let current = 0;
|
|
13474
|
+
for (const w of words2) {
|
|
13475
|
+
if (has(UNITS, w)) current += UNITS[w];
|
|
13476
|
+
else if (has(TENS, w)) current += TENS[w];
|
|
13477
|
+
else if (w === "hundred") current = (current || 1) * 100;
|
|
13478
|
+
else {
|
|
13479
|
+
total += (current || 1) * SCALES[w];
|
|
13480
|
+
current = 0;
|
|
13481
|
+
}
|
|
13482
|
+
}
|
|
13483
|
+
return `${total + current}${/\s$/.test(run) ? " " : ""}`;
|
|
13484
|
+
});
|
|
13485
|
+
}
|
|
13486
|
+
var DURATION = [
|
|
13487
|
+
[/^(?:ms|msecs?|milliseconds?)$/, 1e-3],
|
|
13488
|
+
[/^(?:s|secs?|seconds?)$/, 1],
|
|
13489
|
+
[/^(?:mins?|minutes?)$/, 60],
|
|
13490
|
+
[/^(?:h|hrs?|hours?)$/, 3600],
|
|
13491
|
+
[/^(?:d|days?)$/, 86400],
|
|
13492
|
+
[/^(?:weeks?|wks?)$/, 604800],
|
|
13493
|
+
[/^(?:months?|mos?)$/, 2628e3],
|
|
13494
|
+
[/^(?:years?|yrs?)$/, 31536e3]
|
|
13495
|
+
];
|
|
13496
|
+
var MONEY_AFTER = /^(?:€|eur|euros?|zł|zl|pln|usd|\$|£|gbp|chf|dollars?|pounds?)$/;
|
|
13497
|
+
var CENTS = /^(?:cents?|ct|grosz[ey]?|pence|p)$/;
|
|
13498
|
+
var MONEY_BEFORE = /(?:€|\$|£|eur|usd|pln|gbp|chf)\s?$/;
|
|
13499
|
+
var CURRENCIES = [
|
|
13500
|
+
[/€|\beur\b|\beuros?\b/, "EUR"],
|
|
13501
|
+
[/zł|\bzl\b|\bpln\b/, "PLN"],
|
|
13502
|
+
[/\$|\busd\b|\bdollars?\b/, "USD"],
|
|
13503
|
+
[/£|\bgbp\b|\bpounds?\b/, "GBP"],
|
|
13504
|
+
[/\bchf\b/, "CHF"]
|
|
13505
|
+
];
|
|
13506
|
+
var currencyOf = (text3) => CURRENCIES.find(([re]) => re.test(text3))?.[1];
|
|
13507
|
+
var SIGN_AFTER = /(?:^|[^\w\s%€$£)\]]|\b(?:is|are|was|were|be|been|becomes?|became|reach(?:es|ed)?|show(?:s|n|ed)?|reads?|equals?|stays?|remains?|falls?|fell|drops?|dropped|sinks?|goes|went|gets?|of|at|to|from|in|on|by|as|than|above|below|under|over|between|and|or|until|till|down|least|most|minimum|maximum|around|about|approximately|only|still|with))\s*$/i;
|
|
13508
|
+
var minusSigns = (text3) => text3.replace(/[‐‑‒–−]/g, "-");
|
|
13509
|
+
var numberValue = (raw) => {
|
|
13510
|
+
const sign = /^(?:[-−]|minus\s+)/i.exec(raw)?.[0] ?? "";
|
|
13511
|
+
const digits = raw.slice(sign.length);
|
|
13512
|
+
let n = /^\d{1,3}(,\d{3})+$/.test(digits) ? digits.replace(/,/g, "") : digits.replace(",", ".");
|
|
13513
|
+
if (/^\d+\.\d+$/.test(n)) n = n.replace(/0+$/, "").replace(/\.$/, "");
|
|
13514
|
+
return sign && Number(n) !== 0 ? `-${n}` : n;
|
|
13515
|
+
};
|
|
13516
|
+
var fmt = (n) => String(Math.round(n * 1e3) / 1e3);
|
|
13517
|
+
var readValues = kept(valuesOf);
|
|
13518
|
+
function valuesOf(text3) {
|
|
13519
|
+
const values = /* @__PURE__ */ new Set();
|
|
13520
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
13521
|
+
const also = /* @__PURE__ */ new Set();
|
|
13522
|
+
const quantities = [];
|
|
13523
|
+
const alias = (value, ...more) => {
|
|
13524
|
+
aliases.set(value, [.../* @__PURE__ */ new Set([...aliases.get(value) ?? [], ...more])]);
|
|
13525
|
+
more.forEach((m) => also.add(m));
|
|
13526
|
+
};
|
|
13527
|
+
let t = text3.replace(/[“”]/g, '"').replace(/[‘’]/g, "'").replace(/[ ]/g, " ");
|
|
13528
|
+
for (const m of t.matchAll(/`([^`\s][^`\n]{0,38}[^`\s]|[^`\s])`|"([^"\s][^"\n]{0,38}[^"\s]|[^"\s])"|(?<![\w])'([a-z0-9][a-z0-9_-]{0,39})'(?![\w])/gi)) {
|
|
13529
|
+
const id = (m[1] ?? m[2] ?? m[3]).trim().toLowerCase();
|
|
13530
|
+
if (/^[a-z0-9][a-z0-9_-]*$/.test(id) && !/^\d+$/.test(id)) values.add(id);
|
|
13531
|
+
}
|
|
13532
|
+
t = t.replace(/\b(\d{4}-\d{2}-\d{2})(?:[t ](\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?z?)?\b/gi, (_, date, time) => {
|
|
13533
|
+
values.add(date);
|
|
13534
|
+
if (time) values.add(time);
|
|
13535
|
+
return " ";
|
|
13536
|
+
});
|
|
13537
|
+
t = t.replace(/(?<![\d:])(\d{1,2}:\d{2})(?![\d:])/g, (_, time) => {
|
|
13538
|
+
values.add(time.padStart(5, "0"));
|
|
13539
|
+
return " ";
|
|
13540
|
+
});
|
|
13541
|
+
t = minusSigns(numerals(t));
|
|
13542
|
+
for (const m of t.matchAll(/((?:(?<![\w.,)\]])-|\bminus\s+)?(?<![\w.,]|[a-z]-)(?:\d{1,3}(?:,\d{3})+|\d+(?:[.,]\d+)?))(?:\s?(%|percent\b|per cent\b)|(st|nd|rd|th)\b|\s?([a-zżł€$£]+\b|€|\$|£))?(?![\w])/gi)) {
|
|
13543
|
+
const raw = /^minus/i.test(m[1]) && !SIGN_AFTER.test(t.slice(Math.max(0, (m.index ?? 0) - 40), m.index ?? 0)) ? m[1].replace(/^minus\s+/i, "") : m[1];
|
|
13544
|
+
const n = numberValue(raw);
|
|
13545
|
+
if (m[2]) {
|
|
13546
|
+
values.add(`${n}%`);
|
|
13547
|
+
alias(`${n}%`, n, ...n.startsWith("-") ? [`${n.slice(1)}%`] : []);
|
|
13548
|
+
continue;
|
|
13549
|
+
}
|
|
13550
|
+
values.add(n);
|
|
13551
|
+
if (/[.,]\d\d$/.test(raw) && !/^\D*\d{1,3}(,\d{3})+$/.test(raw)) alias(n, fmt(Number(n) * 100));
|
|
13552
|
+
if (!/%$/.test(n)) alias(n, `${n}%`);
|
|
13553
|
+
const unit = (m[4] ?? "").toLowerCase();
|
|
13554
|
+
const before = t.slice(Math.max(0, (m.index ?? 0) - 4), m.index ?? 0).toLowerCase();
|
|
13555
|
+
const duration = DURATION.find(([re]) => re.test(unit));
|
|
13556
|
+
if (duration) {
|
|
13557
|
+
const base = `${fmt(Number(n) * duration[1])}s`;
|
|
13558
|
+
alias(n, base);
|
|
13559
|
+
quantities.push({ value: n, dimension: "time", base, text: `${raw} ${unit}` });
|
|
13560
|
+
} else if (MONEY_AFTER.test(unit) || MONEY_BEFORE.test(before)) {
|
|
13561
|
+
const cents = fmt(Number(n) * 100);
|
|
13562
|
+
alias(n, `${cents}\xA2`, cents);
|
|
13563
|
+
const sign = MONEY_AFTER.test(unit) ? unit : MONEY_BEFORE.exec(before)[0].trim();
|
|
13564
|
+
quantities.push({ value: n, dimension: "money", base: `${cents}\xA2`, text: sign === unit ? `${raw} ${unit}` : `${sign}${/\w$/.test(sign) ? " " : ""}${raw}`, currency: currencyOf(sign) });
|
|
13565
|
+
} else if (CENTS.test(unit)) {
|
|
13566
|
+
alias(n, `${n}\xA2`);
|
|
13567
|
+
quantities.push({ value: n, dimension: "money", base: `${n}\xA2`, text: `${raw} ${unit}` });
|
|
13568
|
+
}
|
|
13569
|
+
}
|
|
13570
|
+
const lower2 = t.toLowerCase();
|
|
13571
|
+
for (const m of lower2.matchAll(/\b(null|true|false)\b/g)) values.add(m[1]);
|
|
13572
|
+
if (/\bone\b|\bonce\b|\bsingle\b/.test(lower2)) also.add("1");
|
|
13573
|
+
if (/\btwice\b/.test(lower2)) also.add("2");
|
|
13574
|
+
if (/\bdozen\b/.test(lower2)) also.add("12");
|
|
13575
|
+
return { values, aliases, also, quantities };
|
|
13576
|
+
}
|
|
13577
|
+
var says = (reading2, value) => reading2.values.has(value) || reading2.also.has(value);
|
|
13578
|
+
var saysValueOf = (from, value, to) => says(to, value) || (from.aliases.get(value) ?? []).some((a) => says(to, a));
|
|
13579
|
+
var COMPLEMENT = { "<=": ">", "<": ">=", ">=": "<", ">": "<=" };
|
|
13580
|
+
var N = String.raw`((?:(?<![\w.,])-|minus )?\d+(?:[.,]\d+)?)`;
|
|
13581
|
+
var LIMIT_BEFORE = [
|
|
13582
|
+
[new RegExp(String.raw`\b(?:at most|no more than|not more than|up to|maximum of|a maximum of|max(?:imum)?\.?|no longer than|not over)\s+${N}`, "g"), "<="],
|
|
13583
|
+
[new RegExp(String.raw`(?:≤|<=)\s*${N}`, "g"), "<="],
|
|
13584
|
+
[new RegExp(String.raw`\b(?:at least|no less than|no fewer than|not less than|not fewer than|minimum of|a minimum of|min(?:imum)?\.?)\s+${N}`, "g"), ">="],
|
|
13585
|
+
[new RegExp(String.raw`(?:≥|>=)\s*${N}`, "g"), ">="],
|
|
13586
|
+
[new RegExp(String.raw`\b(?:more than|greater than|longer than|larger than|higher than|over|above|exceeds?|exceeding|beyond)\s+${N}`, "g"), ">"],
|
|
13587
|
+
[new RegExp(String.raw`(?<![<>=-])>\s*${N}`, "g"), ">"],
|
|
13588
|
+
[new RegExp(String.raw`\b(?:less than|fewer than|shorter than|smaller than|lower than|below|under)\s+${N}`, "g"), "<"],
|
|
13589
|
+
[new RegExp(String.raw`(?<![<>=-])<\s*${N}(?![\d=])`, "g"), "<"]
|
|
13590
|
+
];
|
|
13591
|
+
var LIMIT_AFTER = [
|
|
13592
|
+
[new RegExp(String.raw`${N}(?:\s*[a-z%€$£]+)?\s+or\s+(?:less|fewer|below|under|lower|smaller|shorter)\b`, "g"), "<="],
|
|
13593
|
+
[new RegExp(String.raw`${N}(?:\s*[a-z%€$£]+)?\s+or\s+(?:more|above|over|higher|greater|larger|longer)\b`, "g"), ">="]
|
|
13594
|
+
];
|
|
13595
|
+
var CLAUSE = /(?<!\d),|,(?!\d)|;|(?<!\bbetween (?:-|minus )?\d+(?:[.,]\d+)?)\s(?:and|but|so|then|otherwise)\s/;
|
|
13596
|
+
var RANGE = new RegExp(String.raw`\b(?:from|between)\s+${N}\s+(?:to|and)\s+${N}|(?<![\d.,-])${N}\s?(?:-|to)\s?${N}(?![\d.,-])`, "g");
|
|
13597
|
+
var NEGATION = /\b(?:not|never|neither|nor|cannot|\w+n't)\b/g;
|
|
13598
|
+
var negates = (before) => {
|
|
13599
|
+
const text3 = before.replace(/\bnot (?:allowed|accepted|permitted)\b/g, " ");
|
|
13600
|
+
if (/\bno\s*$/.test(text3)) return true;
|
|
13601
|
+
const last = [...text3.matchAll(NEGATION)].pop();
|
|
13602
|
+
return !!last && !ownClause(text3.slice(0, last.index), text3.slice((last.index ?? 0) + last[0].length));
|
|
13603
|
+
};
|
|
13604
|
+
var OPENER = /\b(?:who|which|that|whose|whom|where|when|whenever|if|while|until|unless|because|since|once)\b/;
|
|
13605
|
+
var MODAL = /* @__PURE__ */ new Set(["can", "could", "may", "might", "must", "shall", "should", "will", "would", "to"]);
|
|
13606
|
+
var CARRIER = /* @__PURE__ */ new Set([
|
|
13607
|
+
...MODAL,
|
|
13608
|
+
"a",
|
|
13609
|
+
"an",
|
|
13610
|
+
"the",
|
|
13611
|
+
"its",
|
|
13612
|
+
"their",
|
|
13613
|
+
"his",
|
|
13614
|
+
"her",
|
|
13615
|
+
"my",
|
|
13616
|
+
"our",
|
|
13617
|
+
"your",
|
|
13618
|
+
"this",
|
|
13619
|
+
"that",
|
|
13620
|
+
"these",
|
|
13621
|
+
"those",
|
|
13622
|
+
"each",
|
|
13623
|
+
"every",
|
|
13624
|
+
"any",
|
|
13625
|
+
"some",
|
|
13626
|
+
"be",
|
|
13627
|
+
"been",
|
|
13628
|
+
"being",
|
|
13629
|
+
"is",
|
|
13630
|
+
"are",
|
|
13631
|
+
"was",
|
|
13632
|
+
"were",
|
|
13633
|
+
"am",
|
|
13634
|
+
"do",
|
|
13635
|
+
"does",
|
|
13636
|
+
"did",
|
|
13637
|
+
"have",
|
|
13638
|
+
"has",
|
|
13639
|
+
"had",
|
|
13640
|
+
"yet",
|
|
13641
|
+
"ever",
|
|
13642
|
+
"always",
|
|
13643
|
+
"still",
|
|
13644
|
+
"also",
|
|
13645
|
+
"even",
|
|
13646
|
+
"just",
|
|
13647
|
+
"only",
|
|
13648
|
+
"already",
|
|
13649
|
+
"again",
|
|
13650
|
+
"now",
|
|
13651
|
+
"later",
|
|
13652
|
+
"really",
|
|
13653
|
+
"in",
|
|
13654
|
+
"on",
|
|
13655
|
+
"at",
|
|
13656
|
+
"of",
|
|
13657
|
+
"with",
|
|
13658
|
+
"for",
|
|
13659
|
+
"by",
|
|
13660
|
+
"from",
|
|
13661
|
+
"into",
|
|
13662
|
+
"out",
|
|
13663
|
+
"up",
|
|
13664
|
+
"off"
|
|
13665
|
+
]);
|
|
13666
|
+
function ownClause(before, after) {
|
|
13667
|
+
if (!OPENER.test(before)) return false;
|
|
13668
|
+
const words2 = after.split(/[^\p{L}\p{N}']+/u).filter(Boolean);
|
|
13669
|
+
const verb = words2[words2.length - 1];
|
|
13670
|
+
if (!verb || CARRIER.has(verb) || words2.filter((w) => !CARRIER.has(w)).length < 2) return false;
|
|
13671
|
+
return MODAL.has(words2[words2.length - 2]) || /[^s']s$/.test(verb);
|
|
13672
|
+
}
|
|
13673
|
+
var REFUSAL = /\b(?:refus\w*|reject\w*|declin\w*|den(?:y|ies|ied)|invalid|not (?:allowed|accepted|permitted)|forbidden|disallow\w*|error|too (?:long|short|many|few|high|low|big|small))\b/;
|
|
13674
|
+
function refusalBefore(clause, at) {
|
|
13675
|
+
const last = [...clause.matchAll(new RegExp(REFUSAL.source, "g"))].pop();
|
|
13676
|
+
if (!last) return false;
|
|
13677
|
+
const end = (last.index ?? 0) + last[0].length;
|
|
13678
|
+
return end <= at && ownClause(clause.slice(0, last.index), clause.slice(end, at));
|
|
13679
|
+
}
|
|
13680
|
+
var readLimits = (text3, refusing = false) => (refusing ? refusedLimits : allowedLimits)(text3);
|
|
13681
|
+
var allowedLimits = kept((text3) => limitsOf(text3, false));
|
|
13682
|
+
var refusedLimits = kept((text3) => limitsOf(text3, true));
|
|
13683
|
+
function limitsOf(text3, refusing) {
|
|
13684
|
+
const limits = [];
|
|
13685
|
+
const plain = numerals(plainWords(text3)).replace(/\b\d{4}-\d{2}-\d{2}\S*|\b\d{1,2}:\d{2}\b/g, " ");
|
|
13686
|
+
for (const sentence2 of plain.split(/(?<=[.;!?])\s+(?=\D)/)) {
|
|
13687
|
+
const clauses = sentence2.split(CLAUSE).filter((c) => c.trim());
|
|
13688
|
+
clauses.forEach((clause, i) => {
|
|
13689
|
+
const refused2 = refusing || REFUSAL.test(clause) || /^\s*(?:if|when|whenever|where|once|should)\b/.test(clause) && REFUSAL.test(clauses[i + 1] ?? "");
|
|
13690
|
+
const read2 = [];
|
|
13691
|
+
for (const [re, op] of [...LIMIT_BEFORE, ...LIMIT_AFTER]) {
|
|
13692
|
+
for (const m of clause.matchAll(re)) {
|
|
13693
|
+
const start = m.index ?? 0;
|
|
13694
|
+
const end = start + m[0].length;
|
|
13695
|
+
if (read2.some(([from, to]) => from <= start && end <= to)) continue;
|
|
13696
|
+
read2.push([start, end]);
|
|
13697
|
+
const negated = negates(clause.slice(0, start));
|
|
13698
|
+
const turned = refused2 && !(!refusing && refusalBefore(clause, start));
|
|
13699
|
+
limits.push({ value: numberValue(m[1]), op: turned !== negated ? COMPLEMENT[op] : op, text: m[0].trim() });
|
|
13700
|
+
}
|
|
13701
|
+
}
|
|
13702
|
+
if (refused2) return;
|
|
13703
|
+
for (const m of clause.matchAll(RANGE)) {
|
|
13704
|
+
const [low, high] = m[1] !== void 0 ? [m[1], m[2]] : [m[3], m[4]];
|
|
13705
|
+
if (Number(numberValue(low)) >= Number(numberValue(high))) continue;
|
|
13706
|
+
limits.push({ value: numberValue(low), op: ">=", text: m[0].trim() }, { value: numberValue(high), op: "<=", text: m[0].trim() });
|
|
13707
|
+
}
|
|
13708
|
+
});
|
|
13709
|
+
}
|
|
13710
|
+
return limits;
|
|
13711
|
+
}
|
|
13712
|
+
var ORDERS = [
|
|
13713
|
+
[/\b(?:oldest|earliest)(?: \w+)? first\b|\bin (?:the )?order (?:they|it) (?:came|were|was) \w+/, "oldest-first"],
|
|
13714
|
+
[/\b(?:newest|latest|most recent)(?: \w+)? first\b|\breverse chronological\b/, "newest-first"],
|
|
13715
|
+
[/\bascending\b|\b(?:lowest|smallest|cheapest) first\b|\ba to z\b/, "ascending"],
|
|
13716
|
+
[/\bdescending\b|\b(?:highest|largest|biggest|dearest) first\b|\bz to a\b/, "descending"]
|
|
13717
|
+
];
|
|
13718
|
+
var OPPOSITE = { "oldest-first": "newest-first", "newest-first": "oldest-first", ascending: "descending", descending: "ascending" };
|
|
13719
|
+
var oppositeOrder = (o) => OPPOSITE[o];
|
|
13720
|
+
var readOrders = kept(ordersOf);
|
|
13721
|
+
function ordersOf(text3) {
|
|
13722
|
+
const t = plainWords(text3);
|
|
13723
|
+
return new Set(ORDERS.filter(([re]) => re.test(t)).map(([, o]) => o));
|
|
13724
|
+
}
|
|
13725
|
+
var readRoundings = kept(roundingsOf);
|
|
13726
|
+
function roundingsOf(text3) {
|
|
13727
|
+
let t = plainWords(text3);
|
|
13728
|
+
const found = /* @__PURE__ */ new Set();
|
|
13729
|
+
t = t.replace(/\b(?:round(?:ed|s|ing)? )?half(?:[ -]way)?[ -](up|down|even)\b|\bbanker'?s rounding\b/g, (m, kind) => {
|
|
13730
|
+
found.add(`half ${kind ?? "even"}`);
|
|
13731
|
+
return " ";
|
|
13732
|
+
});
|
|
13733
|
+
for (const m of t.matchAll(/\bround(?:ed|s|ing)?(?: \w+){0,3} (up|down)\b/g)) found.add(m[1]);
|
|
13734
|
+
return found;
|
|
13735
|
+
}
|
|
13736
|
+
var EXAMPLE = /\b(?:for example|for instance|e\.g\.|example:|examples:)/i;
|
|
13737
|
+
function exampleSentences(text3) {
|
|
13738
|
+
const out = [];
|
|
13739
|
+
for (const line of text3.split("\n")) {
|
|
13740
|
+
const sentences = line.split(/(?<=[.!?])\s+(?=[A-Z(*`"“-])/);
|
|
13741
|
+
for (const s of sentences) {
|
|
13742
|
+
const clean = s.replace(/\*\*|__|`/g, "").replace(/^[\s>*+-]+/, "").replace(/(^|[\s,;:(])\d{1,2}[.)](?=\s+[a-z])/g, "$1").trim();
|
|
13743
|
+
if (EXAMPLE.test(clean) && (clean.match(/\d+(?:[.,]\d+)?/g) ?? []).length >= 2) out.push(clean);
|
|
13744
|
+
}
|
|
13745
|
+
}
|
|
13746
|
+
return out;
|
|
13747
|
+
}
|
|
13748
|
+
var SUPERSEDED = /\(superseded\b[^)]*\)/i;
|
|
13749
|
+
function answerBlocks(answer) {
|
|
13750
|
+
return answer.split(/\n\s*\n|\n(?=[ \t]*(?:[-*+]|\d+[.)])[ \t]+)/).map((block) => block.trim()).filter((block) => block && !/:\s*$/.test(plainWords(block)) && plainWords(block).split(" ").filter((w) => WORD.test(w)).length >= 4);
|
|
13751
|
+
}
|
|
13752
|
+
function currentNeedText(text3) {
|
|
13753
|
+
const parts2 = needParts(text3);
|
|
13754
|
+
if (!parts2.some((p) => p.kind === "answer" && SUPERSEDED.test(p.text))) return text3;
|
|
13755
|
+
return parts2.filter((p) => !(p.kind === "answer" && SUPERSEDED.test(p.text))).map((p) => p.kind === "question" ? `Q: ${p.text}` : p.kind === "answer" ? `A: ${p.text}` : p.text).join("\n");
|
|
13756
|
+
}
|
|
13757
|
+
var answerKey = (answer) => plainWords(answer.replace(SUPERSEDED, " "));
|
|
13758
|
+
|
|
12905
13759
|
// ../../packages/common/src/check/rules.ts
|
|
12906
13760
|
var prop2 = (node, key) => {
|
|
12907
13761
|
const value = node[key];
|
|
12908
13762
|
return typeof value === "string" ? value.trim() : value == null ? "" : String(value);
|
|
12909
13763
|
};
|
|
12910
|
-
|
|
12911
|
-
|
|
12912
|
-
|
|
12913
|
-
|
|
12914
|
-
|
|
12915
|
-
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
|
|
13764
|
+
var linked = (model, type2, end) => end === "in" ? relationsOf(model, type2).to : relationsOf(model, type2).from;
|
|
13765
|
+
var NODES_BY_TYPE = /* @__PURE__ */ new WeakMap();
|
|
13766
|
+
var NO_NODES = [];
|
|
13767
|
+
var nodesOf = (model, type2) => {
|
|
13768
|
+
if (!model.metamodel.nodeTypes[type2]) return NO_NODES;
|
|
13769
|
+
let byType = NODES_BY_TYPE.get(model.nodes);
|
|
13770
|
+
if (!byType) {
|
|
13771
|
+
byType = /* @__PURE__ */ new Map();
|
|
13772
|
+
for (const n of Object.values(model.nodes)) {
|
|
13773
|
+
const list = byType.get(n.type);
|
|
13774
|
+
if (list) list.push(n);
|
|
13775
|
+
else byType.set(n.type, [n]);
|
|
13776
|
+
}
|
|
13777
|
+
NODES_BY_TYPE.set(model.nodes, byType);
|
|
13778
|
+
}
|
|
13779
|
+
return byType.get(type2) ?? NO_NODES;
|
|
13780
|
+
};
|
|
12920
13781
|
var hasRelationType = (model, type2) => !!model.metamodel.relationTypes[type2];
|
|
12921
13782
|
function unlinked(model, type2, relation, end, otherTypes) {
|
|
12922
13783
|
if (!hasRelationType(model, relation)) return [];
|
|
@@ -12927,6 +13788,11 @@ function unlinked(model, type2, relation, end, otherTypes) {
|
|
|
12927
13788
|
}));
|
|
12928
13789
|
}
|
|
12929
13790
|
var quote = (n) => `"${n.label}"`;
|
|
13791
|
+
function inheritedDecisions(model) {
|
|
13792
|
+
const waived = new Set(Object.values(model.relations).filter((r) => r.relationType === "waives" && !originOf(model.nodes[r.sourceId]) && model.nodes[r.sourceId] && prop2(model.nodes[r.sourceId], "status") === "accepted").map((r) => r.targetId));
|
|
13793
|
+
return nodesOf(model, "adr").filter((n) => originOf(n) && prop2(n, "status") === "accepted" && !waived.has(n.id)).map((adr) => ({ adr, origin: originOf(adr), elements: linkedNodes(model, adr.id, "constrains", "target").filter((e) => !originOf(e)) }));
|
|
13794
|
+
}
|
|
13795
|
+
var namesCheck = (ff) => conditionsOf(ff).some((c) => c.kind !== "invalid");
|
|
12930
13796
|
var TYPE_NAME = { scenario: "Scenario", "fitness-fn": "Fitness function" };
|
|
12931
13797
|
var TYPE_LABEL = (node) => TYPE_NAME[node.type] ?? node.type.charAt(0).toUpperCase() + node.type.slice(1);
|
|
12932
13798
|
var affectedBy = (model, node) => node.type === "scenario" ? linkedNodes(model, node.id, "verifies", "target", "requirement") : linkedNodes(model, node.id, "implements", "target", "adr");
|
|
@@ -12936,6 +13802,7 @@ function brokenWith(model, node) {
|
|
|
12936
13802
|
const what = node.type === "scenario" ? "requirement" : "ADR";
|
|
12937
13803
|
return ` Not verified now: ${what}${affected.length === 1 ? "" : "s"} ${affected.map(quote).join(", ")}.`;
|
|
12938
13804
|
}
|
|
13805
|
+
var testedName = (node) => `${TYPE_NAME[node.type]} ${quote(node)}${originOf(node) ? ` of ${originOf(node)}` : ""}`;
|
|
12939
13806
|
function testRule(outcome, message) {
|
|
12940
13807
|
const failing = outcome === "failed" || outcome === "not-found";
|
|
12941
13808
|
return (model) => {
|
|
@@ -13017,6 +13884,169 @@ function invalidChecks(model) {
|
|
|
13017
13884
|
return found;
|
|
13018
13885
|
});
|
|
13019
13886
|
}
|
|
13887
|
+
var READINGS = /* @__PURE__ */ new Map();
|
|
13888
|
+
function reading(text3) {
|
|
13889
|
+
let found = READINGS.get(text3);
|
|
13890
|
+
if (!found) {
|
|
13891
|
+
if (READINGS.size > 2e4) READINGS.clear();
|
|
13892
|
+
found = readValues(text3);
|
|
13893
|
+
READINGS.set(text3, found);
|
|
13894
|
+
}
|
|
13895
|
+
return found;
|
|
13896
|
+
}
|
|
13897
|
+
var relationQuote = (r) => {
|
|
13898
|
+
const q = r.quote;
|
|
13899
|
+
return typeof q === "string" ? q : "";
|
|
13900
|
+
};
|
|
13901
|
+
var requirementToNeed = (model) => Object.values(model.relations).filter((r) => r.relationType === "derives" && model.nodes[r.sourceId]?.type === "requirement" && model.nodes[r.targetId]?.type === "need" && !originOf(model.nodes[r.targetId]));
|
|
13902
|
+
var CONDITION_FIELDS = ["trigger", "precondition", "unwanted_condition"];
|
|
13903
|
+
var RESPONSE_FIELDS = ["feature", "action"];
|
|
13904
|
+
var requirementText = (n) => [...CONDITION_FIELDS, ...RESPONSE_FIELDS].map((k) => prop2(n, k)).join(" \n ");
|
|
13905
|
+
var scenarioText = (n) => ["given", "when", "then", "gherkin"].map((k) => prop2(n, k)).join(" \n ");
|
|
13906
|
+
function quoteOf(model, r) {
|
|
13907
|
+
const q = relationQuote(r);
|
|
13908
|
+
const need = model.nodes[r.targetId];
|
|
13909
|
+
if (!q || need?.type !== "need") return "";
|
|
13910
|
+
const text3 = need.description ?? "";
|
|
13911
|
+
return plainWords(q) === plainWords(text3) && !needAnswers(text3).length ? "" : q;
|
|
13912
|
+
}
|
|
13913
|
+
var GAPS = /* @__PURE__ */ new WeakMap();
|
|
13914
|
+
function quoteValueGaps(model, req) {
|
|
13915
|
+
let byRelations = GAPS.get(model.nodes);
|
|
13916
|
+
if (!byRelations) {
|
|
13917
|
+
byRelations = /* @__PURE__ */ new WeakMap();
|
|
13918
|
+
GAPS.set(model.nodes, byRelations);
|
|
13919
|
+
}
|
|
13920
|
+
let byReq = byRelations.get(model.relations);
|
|
13921
|
+
if (!byReq) {
|
|
13922
|
+
byReq = /* @__PURE__ */ new Map();
|
|
13923
|
+
byRelations.set(model.relations, byReq);
|
|
13924
|
+
}
|
|
13925
|
+
let gaps = byReq.get(req.id);
|
|
13926
|
+
if (!gaps) {
|
|
13927
|
+
gaps = computeGaps(model, req);
|
|
13928
|
+
byReq.set(req.id, gaps);
|
|
13929
|
+
}
|
|
13930
|
+
return gaps;
|
|
13931
|
+
}
|
|
13932
|
+
function computeGaps(model, req) {
|
|
13933
|
+
const derives = relationsOf(model, "derives");
|
|
13934
|
+
const own = reading(requirementText(req));
|
|
13935
|
+
const missing = [];
|
|
13936
|
+
const carried = /* @__PURE__ */ new Set();
|
|
13937
|
+
for (const r of derives.from.get(req.id) ?? []) {
|
|
13938
|
+
const q = reading(quoteOf(model, r));
|
|
13939
|
+
for (const value of q.values) {
|
|
13940
|
+
if (saysValueOf(q, value, own)) carried.add(value);
|
|
13941
|
+
else missing.push({ value, relationId: r.id });
|
|
13942
|
+
}
|
|
13943
|
+
}
|
|
13944
|
+
const allowed = [];
|
|
13945
|
+
const seen = /* @__PURE__ */ new Set([req.id]);
|
|
13946
|
+
const queue = [req.id];
|
|
13947
|
+
while (queue.length) {
|
|
13948
|
+
const id = queue.shift();
|
|
13949
|
+
for (const r of derives.from.get(id) ?? []) {
|
|
13950
|
+
const q = quoteOf(model, r);
|
|
13951
|
+
if (q) allowed.push(reading(q));
|
|
13952
|
+
if (!seen.has(r.targetId) && model.nodes[r.targetId]?.type === "requirement") {
|
|
13953
|
+
seen.add(r.targetId);
|
|
13954
|
+
queue.push(r.targetId);
|
|
13955
|
+
}
|
|
13956
|
+
}
|
|
13957
|
+
}
|
|
13958
|
+
if (!allowed.length) return { missing, unsupported: [], carried: [...carried] };
|
|
13959
|
+
allowed.push(reading(prop2(req, "rationale")));
|
|
13960
|
+
return { missing, unsupported: [...own.values].filter((v) => !allowed.some((a) => saysValueOf(own, v, a))), carried: [...carried] };
|
|
13961
|
+
}
|
|
13962
|
+
var OP_TEXT = { "<=": "up to and with", "<": "below", ">=": "from and with", ">": "above" };
|
|
13963
|
+
var allows = (l) => `${OP_TEXT[l.op]} ${l.value}`;
|
|
13964
|
+
function requirementLimits(req) {
|
|
13965
|
+
const response = RESPONSE_FIELDS.map((k) => prop2(req, k)).join(" \n ");
|
|
13966
|
+
const refuses = REFUSAL.test(plainWords(response));
|
|
13967
|
+
return [
|
|
13968
|
+
...CONDITION_FIELDS.flatMap((k) => readLimits(prop2(req, k), refuses)),
|
|
13969
|
+
...readLimits(response)
|
|
13970
|
+
];
|
|
13971
|
+
}
|
|
13972
|
+
function quoteSenseGaps(model, req) {
|
|
13973
|
+
const out = [];
|
|
13974
|
+
const text3 = requirementText(req);
|
|
13975
|
+
const limits = requirementLimits(req);
|
|
13976
|
+
const own = reading(text3);
|
|
13977
|
+
const orders = readOrders(text3);
|
|
13978
|
+
const roundings = readRoundings(text3);
|
|
13979
|
+
for (const r of relationsOf(model, "derives").from.get(req.id) ?? []) {
|
|
13980
|
+
const q = quoteOf(model, r);
|
|
13981
|
+
if (!q) continue;
|
|
13982
|
+
const need = quoteLabel(model.nodes[r.targetId]);
|
|
13983
|
+
for (const l of readLimits(q)) {
|
|
13984
|
+
const same3 = limits.filter((m) => m.value === l.value);
|
|
13985
|
+
if (same3.length && !same3.some((m) => m.op === l.op)) {
|
|
13986
|
+
out.push({ relationId: r.id, about: [`limit ${l.op}${l.value}`], message: `Requirement ${quoteLabel(req)} allows ${same3.map(allows).join(" and ")} ("${same3[0].text}") where the words it quotes from ${need} allow ${allows(l)} ("${l.text}"): check on which side of ${l.value} the limit is.` });
|
|
13987
|
+
}
|
|
13988
|
+
}
|
|
13989
|
+
for (const qty of reading(q).quantities) {
|
|
13990
|
+
if (own.quantities.some((m) => m.dimension === qty.dimension && m.base === qty.base && sameCurrency(m, qty))) continue;
|
|
13991
|
+
const other = own.quantities.find((m) => m.dimension === qty.dimension && m.value === qty.value);
|
|
13992
|
+
if (other) out.push({ relationId: r.id, about: [`unit ${qty.text}`], message: `Requirement ${quoteLabel(req)} says "${other.text}" where the words it quotes from ${need} say "${qty.text}".` });
|
|
13993
|
+
}
|
|
13994
|
+
for (const o of readOrders(q)) {
|
|
13995
|
+
if (!orders.has(o) && orders.has(oppositeOrder(o))) out.push({ relationId: r.id, about: [`order ${o}`], message: `Requirement ${quoteLabel(req)} lists ${oppositeOrder(o).replace("-", " ")} where the words it quotes from ${need} say ${o.replace("-", " ")}.` });
|
|
13996
|
+
}
|
|
13997
|
+
const said = readRoundings(q);
|
|
13998
|
+
if (said.size && roundings.size && ![...said].some((x) => roundings.has(x))) {
|
|
13999
|
+
out.push({ relationId: r.id, about: [...said].map((x) => `rounding ${x}`), message: `Requirement ${quoteLabel(req)} rounds ${[...roundings].join(", ")} where the words it quotes from ${need} say ${[...said].join(", ")}.` });
|
|
14000
|
+
}
|
|
14001
|
+
}
|
|
14002
|
+
return out;
|
|
14003
|
+
}
|
|
14004
|
+
var quoteLabel = (n) => `"${n.label}"`;
|
|
14005
|
+
var sameCurrency = (a, b) => !a.currency || !b.currency || a.currency === b.currency;
|
|
14006
|
+
function unquotedBlocks(answer, fragments) {
|
|
14007
|
+
const blocks = answerBlocks(answer);
|
|
14008
|
+
const parts2 = blocks.length ? blocks : [answer];
|
|
14009
|
+
const plain = parts2.map((b) => plainWords(b));
|
|
14010
|
+
const text3 = plain.join(" ");
|
|
14011
|
+
const ranges = [];
|
|
14012
|
+
let at = 0;
|
|
14013
|
+
for (const p of plain) {
|
|
14014
|
+
ranges.push([at, at + p.length]);
|
|
14015
|
+
at += p.length + 1;
|
|
14016
|
+
}
|
|
14017
|
+
const covered = /* @__PURE__ */ new Set();
|
|
14018
|
+
for (const piece of fragments.flat()) {
|
|
14019
|
+
for (let end = wordsAt(text3, piece); end >= 0; end = wordsAt(text3, piece, end - piece.length + 1)) {
|
|
14020
|
+
const start = end - piece.length;
|
|
14021
|
+
ranges.forEach(([from, to], i) => {
|
|
14022
|
+
if (start < to && end > from) covered.add(i);
|
|
14023
|
+
});
|
|
14024
|
+
}
|
|
14025
|
+
}
|
|
14026
|
+
return parts2.filter((_, i) => !covered.has(i));
|
|
14027
|
+
}
|
|
14028
|
+
function requirementsOfNeed(model, needId) {
|
|
14029
|
+
const derives = relationsOf(model, "derives");
|
|
14030
|
+
const found = /* @__PURE__ */ new Map();
|
|
14031
|
+
const parts2 = /* @__PURE__ */ new Set([needId]);
|
|
14032
|
+
const queue = [needId];
|
|
14033
|
+
while (queue.length) {
|
|
14034
|
+
for (const r of derives.to.get(queue.shift()) ?? []) {
|
|
14035
|
+
const n = model.nodes[r.sourceId];
|
|
14036
|
+
if (n?.type === "requirement" && !found.has(n.id)) {
|
|
14037
|
+
found.set(n.id, n);
|
|
14038
|
+
queue.push(n.id);
|
|
14039
|
+
} else if (n?.type === "need" && !parts2.has(n.id) && model.nodes[r.targetId]?.type === "need") {
|
|
14040
|
+
parts2.add(n.id);
|
|
14041
|
+
queue.push(n.id);
|
|
14042
|
+
}
|
|
14043
|
+
}
|
|
14044
|
+
}
|
|
14045
|
+
return [...found.values()];
|
|
14046
|
+
}
|
|
14047
|
+
var scenariosOf = (model, reqId) => (relationsOf(model, "verifies").to.get(reqId) ?? []).map((r) => model.nodes[r.sourceId]).filter((n) => n?.type === "scenario");
|
|
14048
|
+
var telling = (v) => !/^\d$/.test(v) && !(/^[a-z]+$/.test(v) && v.length < 3) && !/^\d{4}-\d{2}-\d{2}$|^\d{2}:\d{2}$/.test(v);
|
|
14049
|
+
var sourceReading = (text3) => reading(text3.replace(/(\d)_(?=\d)/g, "$1").replace(/\b(?:toBe|is|assert)(Null|True|False)\b/g, " $1 ").replace(/(\d)([a-z])/gi, "$1 $2").replace(/([a-z/])(\d)/gi, "$1 $2"));
|
|
13020
14050
|
var CHECK_RULES = [
|
|
13021
14051
|
{
|
|
13022
14052
|
id: "metamodel",
|
|
@@ -13061,10 +14091,148 @@ var CHECK_RULES = [
|
|
|
13061
14091
|
},
|
|
13062
14092
|
{
|
|
13063
14093
|
id: "need-without-requirement",
|
|
13064
|
-
description: "Every need has at least one requirement derived from it.",
|
|
14094
|
+
description: "Every need has at least one requirement derived from it, or from a need inside it (a need that derives from it, Part of).",
|
|
14095
|
+
severity: "warning",
|
|
14096
|
+
dimension: "traceability",
|
|
14097
|
+
run: (model) => unlinked(model, "need", "derives", "in", ["requirement"]).filter((n) => !requirementsOfNeed(model, n.id).length).map((n) => ({ nodeId: n.id, message: `No requirement derives from need ${quote(n)}.` }))
|
|
14098
|
+
},
|
|
14099
|
+
{
|
|
14100
|
+
id: "derives-quote-missing",
|
|
14101
|
+
description: "A requirement's derives relation to a need quotes the words of the need it rests on (property quote, one verbatim fragment per line). Off unless check.json turns it on; the goal requirements-quoting-need follows it in percent.",
|
|
14102
|
+
severity: "warning",
|
|
14103
|
+
off: true,
|
|
14104
|
+
dimension: "traceability",
|
|
14105
|
+
run: (model) => requirementToNeed(model).filter((r) => !quoteFragments(relationQuote(r)).length).map((r) => ({ nodeId: r.sourceId, message: `Requirement ${quote(model.nodes[r.sourceId])} derives from need ${quote(model.nodes[r.targetId])} without quoting the words it rests on.` }))
|
|
14106
|
+
},
|
|
14107
|
+
{
|
|
14108
|
+
id: "derives-quote-not-in-need",
|
|
14109
|
+
description: "Every fragment a derives relation quotes is in the need's text outside its superseded answers, as whole words (case, white space, Markdown marks, dashes and quotation marks aside; an ellipsis joins pieces that must be there in that order, within one question, answer or the text before the questions), and holds at least two words; only a relation to a need quotes.",
|
|
14110
|
+
severity: "error",
|
|
14111
|
+
dimension: "traceability",
|
|
14112
|
+
run: (model) => Object.values(model.relations).filter((r) => r.relationType === "derives" && relationQuote(r).trim() && model.nodes[r.sourceId]?.type === "requirement" && !originOf(model.nodes[r.sourceId])).flatMap((r) => {
|
|
14113
|
+
const req = model.nodes[r.sourceId];
|
|
14114
|
+
const target = model.nodes[r.targetId];
|
|
14115
|
+
if (!target) return [];
|
|
14116
|
+
if (target.type !== "need") return [{ relationId: r.id, message: `Requirement ${quote(req)} quotes words on its relation to ${target.type} ${quote(target)}: only a need holds a person's words. Quote them on the requirement's relation to the need.` }];
|
|
14117
|
+
if (originOf(target)) return [];
|
|
14118
|
+
const text3 = target.description ?? "";
|
|
14119
|
+
return quoteFragments(relationQuote(r)).flatMap((pieces) => fragmentWords(pieces) < 2 ? [{ relationId: r.id, message: `Requirement ${quote(req)} quotes "${pieces.join(" \u2026 ")}", too short to say which words of need ${quote(target)} it rests on: quote the words around it.` }] : quoteFound(currentNeedText(text3), pieces) ? [] : quoteFound(text3, pieces) ? [{ relationId: r.id, message: `Requirement ${quote(req)} quotes "${pieces.join(" \u2026 ")}" from an answer of need ${quote(target)} marked (superseded): quote the answer that replaces it.` }] : [{ relationId: r.id, message: `Requirement ${quote(req)} quotes "${pieces.join(" \u2026 ")}", which need ${quote(target)} does not say${pieces.length > 1 ? " in that order within one answer" : ""}.` }]);
|
|
14120
|
+
})
|
|
14121
|
+
},
|
|
14122
|
+
{
|
|
14123
|
+
id: "quote-value-missing",
|
|
14124
|
+
description: "Every hard value a derives relation quotes (a number, null, true or false, a date or time, an identifier in backticks or quotation marks) is in the requirement's sentence, in that form or another (20 percent as 20%, 15 minutes as 900 seconds, 12.30 \u20AC as 1230 cents).",
|
|
14125
|
+
severity: "warning",
|
|
14126
|
+
dimension: "traceability",
|
|
14127
|
+
run: (model) => nodesOf(model, "requirement").filter((n) => !originOf(n)).flatMap((req) => {
|
|
14128
|
+
const byRelation = /* @__PURE__ */ new Map();
|
|
14129
|
+
for (const g of quoteValueGaps(model, req).missing) byRelation.set(g.relationId, [...byRelation.get(g.relationId) ?? [], g.value]);
|
|
14130
|
+
return [...byRelation].map(([relationId, values]) => ({ relationId, about: values, message: `Requirement ${quote(req)} does not say ${values.map((v) => `"${v}"`).join(", ")}, which the words it quotes from ${quote(model.nodes[model.relations[relationId].targetId])} say.` }));
|
|
14131
|
+
})
|
|
14132
|
+
},
|
|
14133
|
+
{
|
|
14134
|
+
id: "quote-value-differs",
|
|
14135
|
+
description: "A requirement keeps the sense the words it quotes give a value: the same side of a limit (at most, more than, from \u2026 to; a refusal speaks of the other side), the same unit, the same order of a list, the same rounding.",
|
|
14136
|
+
severity: "warning",
|
|
14137
|
+
dimension: "traceability",
|
|
14138
|
+
run: (model) => nodesOf(model, "requirement").filter((n) => !originOf(n)).flatMap((req) => quoteSenseGaps(model, req))
|
|
14139
|
+
},
|
|
14140
|
+
{
|
|
14141
|
+
id: "requirement-value-unquoted",
|
|
14142
|
+
description: "Every hard value a requirement states that quotes its need is in those quotes (or in those of the requirements it derives from), in that form or another, or its rationale names it as a decision of the model.",
|
|
14143
|
+
severity: "warning",
|
|
14144
|
+
dimension: "traceability",
|
|
14145
|
+
run: (model) => nodesOf(model, "requirement").filter((n) => !originOf(n)).flatMap((req) => {
|
|
14146
|
+
const { unsupported } = quoteValueGaps(model, req);
|
|
14147
|
+
return unsupported.length ? [{ nodeId: req.id, about: unsupported, message: `Requirement ${quote(req)} says ${unsupported.map((v) => `"${v}"`).join(", ")}, which none of the words it quotes say: correct it to what the person said, or say in its rationale that ${unsupported.length === 1 ? "it is" : "they are"} the model's decision.` }] : [];
|
|
14148
|
+
})
|
|
14149
|
+
},
|
|
14150
|
+
{
|
|
14151
|
+
id: "scenario-value-missing",
|
|
14152
|
+
description: "Every hard value a requirement takes from the words it quotes is in a scenario that verifies it (its given, when, then or Gherkin text): what the person said reaches a check.",
|
|
13065
14153
|
severity: "warning",
|
|
13066
14154
|
dimension: "traceability",
|
|
13067
|
-
run: (model) =>
|
|
14155
|
+
run: (model) => nodesOf(model, "requirement").filter((n) => !originOf(n)).flatMap((req) => {
|
|
14156
|
+
const scenarios = scenariosOf(model, req.id);
|
|
14157
|
+
if (!scenarios.length) return [];
|
|
14158
|
+
const gaps = quoteValueGaps(model, req);
|
|
14159
|
+
if (!gaps.carried.length) return [];
|
|
14160
|
+
const quoted2 = relationsOf(model, "derives").from.get(req.id) ?? [];
|
|
14161
|
+
const from = quoted2.map((r) => reading(quoteOf(model, r)));
|
|
14162
|
+
const readings = scenarios.map((sc) => reading(scenarioText(sc)));
|
|
14163
|
+
const missing = gaps.carried.filter((v) => !readings.some((sc) => from.some((q) => q.values.has(v) && saysValueOf(q, v, sc))));
|
|
14164
|
+
return missing.length ? [{ nodeId: req.id, relatedIds: scenarios.map((sc) => sc.id), about: missing, message: `Requirement ${quote(req)} takes ${missing.map((v) => `"${v}"`).join(", ")} from the words it quotes, which ${scenarios.length === 1 ? `its scenario ${quote(scenarios[0])} does not say` : `none of its ${scenarios.length} scenarios says`}: a scenario that checks the requirement names the values the person gave.` }] : [];
|
|
14165
|
+
})
|
|
14166
|
+
},
|
|
14167
|
+
{
|
|
14168
|
+
id: "example-not-in-scenario",
|
|
14169
|
+
description: `Every example a need gives with values ("for example", "e.g.", "Example:") is whole in one scenario of the requirements derived from the need: the person's own case checks what they meant.`,
|
|
14170
|
+
severity: "warning",
|
|
14171
|
+
dimension: "traceability",
|
|
14172
|
+
run: (model) => nodesOf(model, "need").filter((n) => !originOf(n)).flatMap((need) => {
|
|
14173
|
+
const scenarios = [...new Map(requirementsOfNeed(model, need.id).flatMap((req) => scenariosOf(model, req.id)).map((sc) => [sc.id, sc])).values()];
|
|
14174
|
+
if (!scenarios.length) return [];
|
|
14175
|
+
const readings = scenarios.map((sc) => ({ sc, reading: reading(scenarioText(sc)) }));
|
|
14176
|
+
return needParts(need.description ?? "").filter((part) => part.kind !== "question" && !/\(no requirement\)/i.test(part.text) && !SUPERSEDED.test(part.text)).flatMap((part) => exampleSentences(part.text)).flatMap((example) => {
|
|
14177
|
+
const ex = reading(example);
|
|
14178
|
+
const closest = readings.map(({ sc, reading: r }) => ({ sc, missing: [...ex.values].filter((v) => !saysValueOf(ex, v, r)) })).sort((x, y) => x.missing.length - y.missing.length)[0];
|
|
14179
|
+
if (!closest.missing.length) return [];
|
|
14180
|
+
const shown = example.length > 140 ? `${example.slice(0, 139)}\u2026` : example;
|
|
14181
|
+
return [{ nodeId: need.id, relatedIds: [closest.sc.id], about: [example], message: `Need ${quote(need)} gives the example "${shown}", which no scenario of its requirements holds whole: the closest, ${quote(closest.sc)}, does not say ${closest.missing.map((v) => `"${v}"`).join(", ")}. A scenario with the person's own example checks what they meant.` }];
|
|
14182
|
+
});
|
|
14183
|
+
})
|
|
14184
|
+
},
|
|
14185
|
+
{
|
|
14186
|
+
id: "scenario-value-untested",
|
|
14187
|
+
description: "With the test sources (radical check reads the files of the tests .radical/radical.json binds): every hard value a scenario names that tells a case apart (not a count below 10) is in the file of a test bound to it.",
|
|
14188
|
+
severity: "warning",
|
|
14189
|
+
dimension: "traceability",
|
|
14190
|
+
run: (model) => {
|
|
14191
|
+
const sources = model.testSources;
|
|
14192
|
+
if (!sources) return [];
|
|
14193
|
+
return nodesOf(model, "scenario").filter((n) => !originOf(n)).flatMap((sc) => {
|
|
14194
|
+
const bound = sc[BOUND_TESTS];
|
|
14195
|
+
const tests = Array.isArray(bound) ? bound.filter((id) => typeof sources[id] === "string") : [];
|
|
14196
|
+
if (!tests.length) return [];
|
|
14197
|
+
const said = reading(scenarioText(sc));
|
|
14198
|
+
const source = sourceReading(tests.map((id) => sources[id]).join("\n"));
|
|
14199
|
+
const text3 = tests.map((id) => sources[id]).join("\n").toLowerCase();
|
|
14200
|
+
const missing = [...said.values].filter((v) => telling(v) && !saysValueOf(said, v, source) && !(/[a-z]/.test(v) && text3.includes(v)));
|
|
14201
|
+
return missing.length ? [{ nodeId: sc.id, details: tests, message: `Scenario ${quote(sc)} names ${missing.map((v) => `"${v}"`).join(", ")}, which ${tests.length === 1 ? "the file of the test bound to it does not use" : `the files of the ${tests.length} tests bound to it do not use`}: a test that checks the scenario uses the values it names, or the scenario says what the test checks.` }] : [];
|
|
14202
|
+
});
|
|
14203
|
+
}
|
|
14204
|
+
},
|
|
14205
|
+
{
|
|
14206
|
+
id: "need-answer-unquoted",
|
|
14207
|
+
description: "Every paragraph and list item of an answer of a person in a need (from a line that starts with A:, Answer: or A1:, or an answer on its question's line; lead-ins and lines of fewer than four words aside) is quoted by a requirement that derives from the need, or the answer is marked (no requirement) or (superseded).",
|
|
14208
|
+
severity: "warning",
|
|
14209
|
+
dimension: "traceability",
|
|
14210
|
+
run: (model) => {
|
|
14211
|
+
const quotes = /* @__PURE__ */ new Map();
|
|
14212
|
+
for (const r of requirementToNeed(model)) quotes.set(r.targetId, [...quotes.get(r.targetId) ?? [], ...quoteFragments(relationQuote(r))]);
|
|
14213
|
+
return nodesOf(model, "need").filter((n) => !originOf(n)).flatMap((need) => needAnswers(need.description ?? "").filter((answer) => !/\(no requirement\)/i.test(answer) && !SUPERSEDED.test(answer)).flatMap((answer) => {
|
|
14214
|
+
const open = unquotedBlocks(answer, quotes.get(need.id) ?? []);
|
|
14215
|
+
if (!open.length) return [];
|
|
14216
|
+
const blocks = answerBlocks(answer);
|
|
14217
|
+
const start = (t) => `"${t.replace(/\s+/g, " ").slice(0, 90)}${t.length > 90 ? "\u2026" : ""}"`;
|
|
14218
|
+
if (open.length === Math.max(1, blocks.length)) return [{ nodeId: need.id, about: open, message: `No requirement quotes this answer in need ${quote(need)}: ${start(answer)} Quote it on a requirement's derives relation, or mark it (no requirement).` }];
|
|
14219
|
+
return [{ nodeId: need.id, details: open.map(start), about: open, message: `No requirement quotes ${open.length} of the ${blocks.length} parts of this answer in need ${quote(need)}: ${open.map(start).join(", ")}. Quote each on a requirement's derives relation, or mark the answer (no requirement).` }];
|
|
14220
|
+
}));
|
|
14221
|
+
}
|
|
14222
|
+
},
|
|
14223
|
+
{
|
|
14224
|
+
id: "need-answer-changed",
|
|
14225
|
+
description: "With the model at the base (radical check in git, the Inspector with the branch's base): every answer of a person a need held there it still holds, word for word; a person's words are only added to, and an answer a later one replaces is marked (superseded).",
|
|
14226
|
+
severity: "error",
|
|
14227
|
+
dimension: "traceability",
|
|
14228
|
+
run: (model) => {
|
|
14229
|
+
const base = model.baseNodes;
|
|
14230
|
+
if (!base) return [];
|
|
14231
|
+
return nodesOf(model, "need").filter((n) => !originOf(n) && base[n.id]?.type === "need").flatMap((need) => {
|
|
14232
|
+
const now4 = new Set(needAnswers(need.description ?? "").map(answerKey));
|
|
14233
|
+
return needAnswers(base[need.id].description ?? "").filter((answer) => !now4.has(answerKey(answer))).map((answer) => ({ nodeId: need.id, message: `Need ${quote(need)} no longer holds the answer "${answer.replace(/\s+/g, " ").slice(0, 90)}${answer.length > 90 ? "\u2026" : ""}" it held at the base: a person's words are only added to. Restore it as it was, and mark it (superseded) if a later answer replaces it.` }));
|
|
14234
|
+
});
|
|
14235
|
+
}
|
|
13068
14236
|
},
|
|
13069
14237
|
{
|
|
13070
14238
|
id: "scenario-verifies-nothing",
|
|
@@ -13078,7 +14246,31 @@ var CHECK_RULES = [
|
|
|
13078
14246
|
description: "Every accepted ADR is implemented by a fitness function that checks it.",
|
|
13079
14247
|
severity: "warning",
|
|
13080
14248
|
dimension: "decisions",
|
|
13081
|
-
run: (model) => model.metamodel.nodeTypes["fitness-fn"] ? unlinked(model, "adr", "implements", "in", ["fitness-fn"]).filter((n) => prop2(n, "status") === "accepted").map((n) => ({ nodeId: n.id, message: `No fitness function implements accepted ADR ${quote(n)}.` })) : []
|
|
14249
|
+
run: (model) => model.metamodel.nodeTypes["fitness-fn"] ? unlinked(model, "adr", "implements", "in", ["fitness-fn"]).filter((n) => prop2(n, "status") === "accepted").filter((n) => !relationsOf(model, "waives").from.has(n.id)).map((n) => ({ nodeId: n.id, message: `No fitness function implements accepted ADR ${quote(n)}.` })) : []
|
|
14250
|
+
},
|
|
14251
|
+
{
|
|
14252
|
+
id: "inherited-adr-unapplied",
|
|
14253
|
+
description: "Every accepted ADR of a model this one depends on (deps.json) binds it: it constrains at least one of this model's elements, or an accepted ADR of this model waives it and says why.",
|
|
14254
|
+
severity: "error",
|
|
14255
|
+
dimension: "decisions",
|
|
14256
|
+
run: (model) => inheritedDecisions(model).filter((d) => !d.elements.length).map(({ adr, origin }) => ({
|
|
14257
|
+
relatedIds: [adr.id],
|
|
14258
|
+
message: `ADR ${quote(adr)} of ${origin} binds this model and applies to none of its elements: link it with constrains to the elements it governs, or record an accepted ADR of this model that waives it and says why.`
|
|
14259
|
+
}))
|
|
14260
|
+
},
|
|
14261
|
+
{
|
|
14262
|
+
id: "inherited-adr-unchecked",
|
|
14263
|
+
description: "Every element an accepted ADR of a model this one depends on constrains is checked: a fitness function implements the ADR (this model's or the other's) and names its check (metric conditions, or tests .radical/radical.json binds to it).",
|
|
14264
|
+
severity: "error",
|
|
14265
|
+
dimension: "decisions",
|
|
14266
|
+
run: (model) => inheritedDecisions(model).flatMap(({ adr, origin, elements }) => {
|
|
14267
|
+
if (!model.metamodel.nodeTypes["fitness-fn"] || linkedNodes(model, adr.id, "implements", "source", "fitness-fn").some(namesCheck)) return [];
|
|
14268
|
+
return elements.map((e) => ({
|
|
14269
|
+
nodeId: e.id,
|
|
14270
|
+
relatedIds: [adr.id],
|
|
14271
|
+
message: `Nothing checks ADR ${quote(adr)} of ${origin} on ${e.type} ${quote(e)}: add a fitness function that implements the ADR and names its check (metrics, or tests .radical/radical.json binds to it).`
|
|
14272
|
+
}));
|
|
14273
|
+
})
|
|
13082
14274
|
},
|
|
13083
14275
|
{
|
|
13084
14276
|
id: "adr-incomplete",
|
|
@@ -13248,7 +14440,7 @@ var CHECK_RULES = [
|
|
|
13248
14440
|
severity: "error",
|
|
13249
14441
|
dimension: "tests",
|
|
13250
14442
|
readsReports: true,
|
|
13251
|
-
run: testRule("failed", (node, id, model) => `${
|
|
14443
|
+
run: testRule("failed", (node, id, model) => `${testedName(node)}: test ${id} failed.${brokenWith(model, node)}`)
|
|
13252
14444
|
},
|
|
13253
14445
|
{
|
|
13254
14446
|
id: "test-not-found",
|
|
@@ -13256,7 +14448,7 @@ var CHECK_RULES = [
|
|
|
13256
14448
|
severity: "error",
|
|
13257
14449
|
dimension: "tests",
|
|
13258
14450
|
readsReports: true,
|
|
13259
|
-
run: (model) => testRule("not-found", (node, id) => model.testsReadAt ? `${
|
|
14451
|
+
run: (model) => testRule("not-found", (node, id) => model.testsReadAt ? `${testedName(node)}: no test ${id} in the test results read ${model.testsReadAt.slice(0, 10)}, ${formatAge((model.now ?? Date.now()) - Date.parse(model.testsReadAt))} ago; added since, renamed or deleted? radical check --report reads the tests again.` : `${testedName(node)}: no test ${id} in the reports, though its file ran; renamed or deleted?${brokenWith(model, node)}`)(model).map((f) => model.testsReadAt ? { ...f, asOf: model.testsReadAt } : f)
|
|
13260
14452
|
},
|
|
13261
14453
|
{
|
|
13262
14454
|
id: "test-skipped",
|
|
@@ -13264,7 +14456,7 @@ var CHECK_RULES = [
|
|
|
13264
14456
|
severity: "warning",
|
|
13265
14457
|
dimension: "tests",
|
|
13266
14458
|
readsReports: true,
|
|
13267
|
-
run: testRule("skipped", (node, id) => `${
|
|
14459
|
+
run: testRule("skipped", (node, id) => `${testedName(node)}: test ${id} was skipped.`)
|
|
13268
14460
|
},
|
|
13269
14461
|
{
|
|
13270
14462
|
id: "test-not-run",
|
|
@@ -13272,7 +14464,7 @@ var CHECK_RULES = [
|
|
|
13272
14464
|
severity: "warning",
|
|
13273
14465
|
dimension: "tests",
|
|
13274
14466
|
readsReports: true,
|
|
13275
|
-
run: testRule("not-run", (node, id) => `${
|
|
14467
|
+
run: testRule("not-run", (node, id) => `${testedName(node)}: no report has the file of test ${id}.`)
|
|
13276
14468
|
},
|
|
13277
14469
|
{
|
|
13278
14470
|
id: "metric-failed",
|
|
@@ -13335,6 +14527,10 @@ function testBinding(model) {
|
|
|
13335
14527
|
}
|
|
13336
14528
|
return byFile;
|
|
13337
14529
|
}
|
|
14530
|
+
var WORD_RULES = /* @__PURE__ */ new Set(["derives-quote-not-in-need", "quote-value-missing", "quote-value-differs", "requirement-value-unquoted", "scenario-value-missing", "example-not-in-scenario", "need-answer-unquoted"]);
|
|
14531
|
+
function wordFindings(model, off = /* @__PURE__ */ new Set()) {
|
|
14532
|
+
return CHECK_RULES.filter((r) => WORD_RULES.has(r.id) && !off.has(r.id)).flatMap((rule) => rule.run(model).map((f) => ({ rule: rule.id, severity: f.severity ?? rule.severity, message: f.message, ...f.nodeId ? { nodeId: f.nodeId } : {}, ...f.relationId ? { relationId: f.relationId } : {}, ...f.about ? { about: f.about } : {} })));
|
|
14533
|
+
}
|
|
13338
14534
|
|
|
13339
14535
|
// ../../packages/common/src/check/goals.ts
|
|
13340
14536
|
init_define_RADICAL_BUILD();
|
|
@@ -13369,8 +14565,14 @@ var CHECK_METRICS = [
|
|
|
13369
14565
|
byRule("elements-valid", "Elements the metamodel allows", "Elements no metamodel issue points at.", "consistency", "metamodel", (m) => Object.values(m.nodes)),
|
|
13370
14566
|
byRule("requirements-complete", "Complete requirements", "Requirements with an action and every field their EARS type reads.", "completeness", "requirement-incomplete", (m) => nodesOf(m, "requirement")),
|
|
13371
14567
|
byRule("adrs-complete", "Complete accepted ADRs", "Accepted ADRs with a date, context, decision and consequences.", "completeness", "adr-incomplete", acceptedAdrs),
|
|
13372
|
-
byRule("needs-with-requirement", "Needs with a requirement", "Needs at least one requirement derives from.", "traceability", "need-without-requirement", (m) => nodesOf(m, "need")),
|
|
14568
|
+
byRule("needs-with-requirement", "Needs with a requirement", "Needs at least one requirement derives from, directly or through a need inside them.", "traceability", "need-without-requirement", (m) => nodesOf(m, "need")),
|
|
13373
14569
|
byRule("requirements-with-origin", "Requirements with an origin", "Requirements that derive from a need or another requirement.", "traceability", "requirement-without-origin", (m) => nodesOf(m, "requirement")),
|
|
14570
|
+
byRule("requirements-quoting-need", "Requirements that quote their need", "Requirements derived from a need whose Derives from relation quotes the words they rest on; measured once a relation of the model quotes.", "traceability", "derives-quote-missing", (m) => {
|
|
14571
|
+
const toNeed = Object.values(m.relations).filter((r) => r.relationType === "derives" && m.nodes[r.targetId]?.type === "need");
|
|
14572
|
+
if (!toNeed.some((r) => typeof r.quote === "string" && r.quote.trim())) return null;
|
|
14573
|
+
const derived = new Set(toNeed.map((r) => r.sourceId));
|
|
14574
|
+
return nodesOf(m, "requirement").filter((n) => derived.has(n.id));
|
|
14575
|
+
}),
|
|
13374
14576
|
byRule("requirements-satisfied", "Requirements satisfied", "Requirements an element of the architecture satisfies.", "traceability", "requirement-unsatisfied", (m) => nodesOf(m, "requirement")),
|
|
13375
14577
|
byRule("requirements-with-scenario", "Requirements with a scenario", "Requirements at least one scenario verifies.", "traceability", "requirement-without-scenario", (m) => hasType(m, "scenario") ? nodesOf(m, "requirement") : null),
|
|
13376
14578
|
byRule("scenarios-verifying", "Scenarios that verify something", "Scenarios that verify a requirement or a state machine.", "traceability", "scenario-verifies-nothing", (m) => nodesOf(m, "scenario")),
|
|
@@ -13438,10 +14640,223 @@ var CHECK_METRICS = [
|
|
|
13438
14640
|
];
|
|
13439
14641
|
var METRIC_IDS = new Set(CHECK_METRICS.map((m) => m.id));
|
|
13440
14642
|
|
|
14643
|
+
// ../../packages/common/src/check/testSource.ts
|
|
14644
|
+
init_define_RADICAL_BUILD();
|
|
14645
|
+
|
|
14646
|
+
// ../../packages/common/src/check/trace.ts
|
|
14647
|
+
init_define_RADICAL_BUILD();
|
|
14648
|
+
var TRACE_TYPES = ["need", "requirement", "scenario", "adr", "fitness-fn"];
|
|
14649
|
+
var UP = [
|
|
14650
|
+
{ relationType: "derives", from: "requirement", to: ["need", "requirement"] },
|
|
14651
|
+
// A need inside a broader one (Part of): the path goes up to the broadest.
|
|
14652
|
+
{ relationType: "derives", from: "need", to: ["need"] },
|
|
14653
|
+
{ relationType: "verifies", from: "scenario", to: ["requirement"] },
|
|
14654
|
+
{ relationType: "implements", from: "fitness-fn", to: ["adr"] }
|
|
14655
|
+
];
|
|
14656
|
+
var RANK = {
|
|
14657
|
+
failed: 0,
|
|
14658
|
+
broken: 0,
|
|
14659
|
+
"not-found": 0,
|
|
14660
|
+
invalid: 0,
|
|
14661
|
+
stale: 1,
|
|
14662
|
+
"not-run": 2,
|
|
14663
|
+
skipped: 2,
|
|
14664
|
+
unverified: 2,
|
|
14665
|
+
"no-checks": 3,
|
|
14666
|
+
passed: 4,
|
|
14667
|
+
verified: 4
|
|
14668
|
+
};
|
|
14669
|
+
var rankOf = (status) => status ? RANK[status] ?? 3 : 3;
|
|
14670
|
+
function rollUp(children2) {
|
|
14671
|
+
const statuses = children2.map((c) => c.status).filter((s) => !!s);
|
|
14672
|
+
if (!statuses.length) return children2.length ? void 0 : "unverified";
|
|
14673
|
+
if (statuses.includes("broken") || statuses.includes("failed")) return "broken";
|
|
14674
|
+
return statuses.length === children2.length && statuses.every((s) => s === "verified" || s === "passed") ? "verified" : "unverified";
|
|
14675
|
+
}
|
|
14676
|
+
function resultsOf(conditions, cases) {
|
|
14677
|
+
return (conditions ?? []).map((c) => {
|
|
14678
|
+
const id = c.test ? parseTestIds(c.test)[0] : void 0;
|
|
14679
|
+
const found = id && cases ? findTests(id, cases).matches : [];
|
|
14680
|
+
return {
|
|
14681
|
+
condition: c.condition,
|
|
14682
|
+
outcome: c.outcome,
|
|
14683
|
+
...c.test ? { test: c.test } : {},
|
|
14684
|
+
...c.measurement ? { measurement: c.measurement } : {},
|
|
14685
|
+
...c.detail ? { detail: c.detail } : {},
|
|
14686
|
+
...found.length ? { cases: [...found].sort((a, b) => rankOf(a.status) - rankOf(b.status)) } : {}
|
|
14687
|
+
};
|
|
14688
|
+
}).sort((a, b) => rankOf(a.outcome) - rankOf(b.outcome));
|
|
14689
|
+
}
|
|
14690
|
+
var unjudged = (node) => (originOf(node) ? boundConditions(node) : conditionsOf(node)).map((c) => ({ condition: c.raw, ...c.kind === "test" ? { test: c.id.raw } : {} }));
|
|
14691
|
+
function verifiedFrom(checkers) {
|
|
14692
|
+
if (!checkers.some((s) => s)) return void 0;
|
|
14693
|
+
if (checkers.includes("failed")) return "broken";
|
|
14694
|
+
return checkers.every((s) => s === "passed") ? "verified" : "unverified";
|
|
14695
|
+
}
|
|
14696
|
+
var CHECKER = { requirement: "scenario", adr: "fitness-fn" };
|
|
14697
|
+
function traceOf(input, id) {
|
|
14698
|
+
const { nodes, relations } = input;
|
|
14699
|
+
const target = nodes[id];
|
|
14700
|
+
if (!target || !TRACE_TYPES.includes(target.type)) return { id, roots: [] };
|
|
14701
|
+
const up = /* @__PURE__ */ new Map();
|
|
14702
|
+
const down = /* @__PURE__ */ new Map();
|
|
14703
|
+
for (const r of Object.values(relations)) {
|
|
14704
|
+
const s = nodes[r.sourceId];
|
|
14705
|
+
const t = nodes[r.targetId];
|
|
14706
|
+
if (!s || !t || s.id === t.id) continue;
|
|
14707
|
+
if (!UP.some((u) => u.relationType === r.relationType && u.from === s.type && u.to.includes(t.type))) continue;
|
|
14708
|
+
up.set(s.id, [...up.get(s.id) ?? [], t.id]);
|
|
14709
|
+
down.set(t.id, [...down.get(t.id) ?? [], s.id]);
|
|
14710
|
+
}
|
|
14711
|
+
const above = /* @__PURE__ */ new Set();
|
|
14712
|
+
const roots = [];
|
|
14713
|
+
const climb = (n, seen) => {
|
|
14714
|
+
const parents = (up.get(n) ?? []).filter((p) => !seen.has(p));
|
|
14715
|
+
if (!parents.length) {
|
|
14716
|
+
if (!roots.includes(n)) roots.push(n);
|
|
14717
|
+
return;
|
|
14718
|
+
}
|
|
14719
|
+
for (const p of parents) {
|
|
14720
|
+
above.add(p);
|
|
14721
|
+
climb(p, /* @__PURE__ */ new Set([...seen, p]));
|
|
14722
|
+
}
|
|
14723
|
+
};
|
|
14724
|
+
climb(id, /* @__PURE__ */ new Set([id]));
|
|
14725
|
+
const ev = input.evidence?.nodes;
|
|
14726
|
+
const build = (n, path, under) => {
|
|
14727
|
+
const node = nodes[n];
|
|
14728
|
+
const e = ev?.[n];
|
|
14729
|
+
const isTarget = n === id;
|
|
14730
|
+
const below = under || isTarget;
|
|
14731
|
+
const base = { id: n, type: node.type, label: node.label, ...isTarget ? { target: true } : {}, children: [], results: [] };
|
|
14732
|
+
if (path.has(n)) return { ...base, status: e?.status, repeated: true };
|
|
14733
|
+
const next = /* @__PURE__ */ new Set([...path, n]);
|
|
14734
|
+
const kids = (down.get(n) ?? []).filter((k, i, all) => all.indexOf(k) === i && (below || k === id || above.has(k)));
|
|
14735
|
+
const children2 = kids.map((k) => build(k, next, below)).sort((a, b) => rankOf(a.status) - rankOf(b.status) || Number(a.type === b.type ? 0 : a.type === "requirement") - Number(a.type === b.type ? 0 : b.type === "requirement") || a.label.localeCompare(b.label));
|
|
14736
|
+
const elements = e?.elements?.map((el) => ({ id: el.id, label: el.label, status: el.status, results: resultsOf(el.conditions, input.cases) })).sort((a, b) => rankOf(a.status) - rankOf(b.status));
|
|
14737
|
+
const checkers = !e && ev && CHECKER[node.type] ? (down.get(n) ?? []).filter((k) => nodes[k].type === CHECKER[node.type]).map((k) => ev[k]?.status) : [];
|
|
14738
|
+
return {
|
|
14739
|
+
...base,
|
|
14740
|
+
status: e?.status ?? (node.type === "need" && ev ? rollUp(children2) : checkers.length ? verifiedFrom(checkers) : void 0),
|
|
14741
|
+
children: children2,
|
|
14742
|
+
results: e || !TESTED_TYPES.includes(node.type) ? resultsOf(e?.conditions, input.cases) : unjudged(node),
|
|
14743
|
+
...elements?.length ? { elements } : {}
|
|
14744
|
+
};
|
|
14745
|
+
};
|
|
14746
|
+
return {
|
|
14747
|
+
id,
|
|
14748
|
+
roots: roots.map((r) => build(r, /* @__PURE__ */ new Set(), false)).sort((a, b) => rankOf(a.status) - rankOf(b.status) || a.label.localeCompare(b.label))
|
|
14749
|
+
};
|
|
14750
|
+
}
|
|
14751
|
+
var TYPE_LABEL2 = { need: "Need", requirement: "Requirement", scenario: "Scenario", adr: "ADR", "fitness-fn": "Fitness function" };
|
|
14752
|
+
var traceTypeLabel = (type2) => TYPE_LABEL2[type2] ?? type2;
|
|
14753
|
+
function traceGap(node) {
|
|
14754
|
+
if (node.repeated || node.children.length || node.results.length || node.elements?.length) return null;
|
|
14755
|
+
switch (node.type) {
|
|
14756
|
+
case "need":
|
|
14757
|
+
return "no requirement derives from it";
|
|
14758
|
+
case "requirement":
|
|
14759
|
+
return "no scenario verifies it";
|
|
14760
|
+
case "adr":
|
|
14761
|
+
return "no fitness function implements it";
|
|
14762
|
+
case "scenario":
|
|
14763
|
+
case "fitness-fn":
|
|
14764
|
+
return "names no check";
|
|
14765
|
+
default:
|
|
14766
|
+
return null;
|
|
14767
|
+
}
|
|
14768
|
+
}
|
|
14769
|
+
function resultLine(r, now4) {
|
|
14770
|
+
const what = r.test ?? r.condition;
|
|
14771
|
+
const m = r.measurement;
|
|
14772
|
+
const measured2 = m ? ` \xB7 ${m.value}${m.unit ? ` ${m.unit}` : ""} by ${m.source}, ${Math.max(0, Math.round((now4 - Date.parse(m.at)) / 36e5))} h ago` : "";
|
|
14773
|
+
return `${what} \u2014 ${r.outcome ?? "no results"}${measured2}${r.detail && !m ? ` (${r.detail})` : ""}`;
|
|
14774
|
+
}
|
|
14775
|
+
function formatTrace(trace, nodes, now4 = Date.now()) {
|
|
14776
|
+
const asked = nodes[trace.id];
|
|
14777
|
+
if (!asked) return `No element ${trace.id} in the model.`;
|
|
14778
|
+
const out = [];
|
|
14779
|
+
if (!trace.roots.length) return `${asked.label} (${asked.type}) is on no verification path: paths are made of ${TRACE_TYPES.join(", ")}.`;
|
|
14780
|
+
out.push(`Verification path of ${asked.label} [${asked.id}]`);
|
|
14781
|
+
const walk = (n, depth2) => {
|
|
14782
|
+
const pad = " ".repeat(depth2);
|
|
14783
|
+
out.push(`${pad}${n.target ? "\u25B6 " : "- "}${traceTypeLabel(n.type)}: ${n.label} [${n.id}] \u2014 ${n.status ?? "no results"}${n.repeated ? " (again, see above)" : ""}`);
|
|
14784
|
+
const gap = traceGap(n);
|
|
14785
|
+
if (gap) out.push(`${pad} (${gap})`);
|
|
14786
|
+
for (const r of n.results) {
|
|
14787
|
+
out.push(`${pad} \xB7 ${resultLine(r, now4)}`);
|
|
14788
|
+
for (const c of r.cases ?? []) {
|
|
14789
|
+
if (c.status !== "failed" || !c.message) continue;
|
|
14790
|
+
for (const line of c.message.split("\n").slice(0, 4)) out.push(`${pad} ${line}`);
|
|
14791
|
+
}
|
|
14792
|
+
}
|
|
14793
|
+
for (const el of n.elements ?? []) {
|
|
14794
|
+
out.push(`${pad} for ${el.label} [${el.id}] \u2014 ${el.status}`);
|
|
14795
|
+
for (const r of el.results) out.push(`${pad} \xB7 ${resultLine(r, now4)}`);
|
|
14796
|
+
}
|
|
14797
|
+
for (const c of n.children) walk(c, depth2 + 1);
|
|
14798
|
+
};
|
|
14799
|
+
for (const r of trace.roots) walk(r, 0);
|
|
14800
|
+
return out.join("\n");
|
|
14801
|
+
}
|
|
14802
|
+
|
|
13441
14803
|
// ../../packages/common/src/check/files.ts
|
|
13442
14804
|
init_define_RADICAL_BUILD();
|
|
14805
|
+
var CHECK_CONFIG_FILE = "check.json";
|
|
13443
14806
|
var TEST_RESULTS_FILE = `${STATE_DIR}/test-results.json`;
|
|
13444
14807
|
var MEASUREMENTS_FILE = `${STATE_DIR}/measurements.json`;
|
|
14808
|
+
function testsRanAt(results) {
|
|
14809
|
+
const runs = results.ci?.runs.map((r) => r.ranAt).filter((at) => !Number.isNaN(Date.parse(at))).sort() ?? [];
|
|
14810
|
+
return runs.length ? runs[runs.length - 1] : results.readAt;
|
|
14811
|
+
}
|
|
14812
|
+
function ciSourceOf(value) {
|
|
14813
|
+
const ci = value;
|
|
14814
|
+
if (!ci || ci.provider !== "github" || typeof ci.commit !== "string" || typeof ci.behind !== "number" || !Array.isArray(ci.runs)) return void 0;
|
|
14815
|
+
const runs = ci.runs.filter((r) => !!r && typeof r.id === "number" && typeof r.url === "string" && typeof r.sha === "string" && typeof r.ranAt === "string" && typeof r.workflow === "string" && Array.isArray(r.artifacts));
|
|
14816
|
+
return { provider: "github", commit: ci.commit, behind: ci.behind, runs };
|
|
14817
|
+
}
|
|
14818
|
+
var STATUSES = /* @__PURE__ */ new Set(["passed", "failed", "skipped"]);
|
|
14819
|
+
function parseTestResults(text3) {
|
|
14820
|
+
let data;
|
|
14821
|
+
try {
|
|
14822
|
+
data = JSON.parse(text3);
|
|
14823
|
+
} catch {
|
|
14824
|
+
return null;
|
|
14825
|
+
}
|
|
14826
|
+
const r = data;
|
|
14827
|
+
if (r?.version !== 1 || typeof r.readAt !== "string" || !Array.isArray(r.cases)) return null;
|
|
14828
|
+
const cases = r.cases.filter((c) => !!c && typeof c.file === "string" && Array.isArray(c.title) && c.title.every((t) => typeof t === "string") && STATUSES.has(c.status));
|
|
14829
|
+
const ci = ciSourceOf(r.ci);
|
|
14830
|
+
return {
|
|
14831
|
+
version: 1,
|
|
14832
|
+
readAt: r.readAt,
|
|
14833
|
+
reports: Array.isArray(r.reports) ? r.reports.filter((x) => typeof x === "string") : [],
|
|
14834
|
+
cases,
|
|
14835
|
+
...typeof r.commit === "string" ? { commit: r.commit } : {},
|
|
14836
|
+
...ci ? { ci } : {}
|
|
14837
|
+
};
|
|
14838
|
+
}
|
|
14839
|
+
function parseCheckConfig(text3) {
|
|
14840
|
+
const data = JSON.parse(stripBom(text3));
|
|
14841
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) throw new Error("a config is a JSON object");
|
|
14842
|
+
const rules = data.rules;
|
|
14843
|
+
if (rules !== void 0 && (typeof rules !== "object" || rules === null || Array.isArray(rules))) throw new Error('"rules" is an object of rule settings');
|
|
14844
|
+
const goals = data.goals;
|
|
14845
|
+
if (goals !== void 0) {
|
|
14846
|
+
if (typeof goals !== "object" || goals === null || Array.isArray(goals)) throw new Error('"goals" is an object of goals by metric');
|
|
14847
|
+
for (const [id, goal] of Object.entries(goals)) {
|
|
14848
|
+
const min = goal?.min;
|
|
14849
|
+
if (typeof min !== "number" || !(min >= 0 && min <= 100)) throw new Error(`goal "${id}" needs a "min" from 0 to 100 (percent)`);
|
|
14850
|
+
}
|
|
14851
|
+
}
|
|
14852
|
+
const ci = data.ci;
|
|
14853
|
+
if (ci !== void 0) {
|
|
14854
|
+
const artifacts = ci?.artifacts;
|
|
14855
|
+
if (typeof ci !== "object" || ci === null || Array.isArray(ci) || artifacts !== void 0 && !(Array.isArray(artifacts) && artifacts.every((a) => typeof a === "string" && a)))
|
|
14856
|
+
throw new Error('"ci" is an object whose "artifacts" lists the names of the CI artifacts that hold test reports');
|
|
14857
|
+
}
|
|
14858
|
+
return data;
|
|
14859
|
+
}
|
|
13445
14860
|
|
|
13446
14861
|
// ../../packages/common/src/check/reviews.ts
|
|
13447
14862
|
init_define_RADICAL_BUILD();
|
|
@@ -13466,6 +14881,7 @@ var MODEL_RULE_IDS = /* @__PURE__ */ new Set([STALE_REFERENCE, ...CHECK_RULES.ma
|
|
|
13466
14881
|
var ALL_RULES = [...FOLDER_RULES, ...CHECK_RULES, GOAL_RULE];
|
|
13467
14882
|
var RULE_IDS = new Set(ALL_RULES.map((r) => r.id));
|
|
13468
14883
|
var DEFAULT_SEVERITY = new Map(ALL_RULES.map((r) => [r.id, r.severity]));
|
|
14884
|
+
var DEFAULT_OFF = new Set(ALL_RULES.filter((r) => r.off).map((r) => r.id));
|
|
13469
14885
|
|
|
13470
14886
|
// ../../packages/common/src/federation.ts
|
|
13471
14887
|
init_define_RADICAL_BUILD();
|
|
@@ -13503,9 +14919,14 @@ function withOtherModels(data, file) {
|
|
|
13503
14919
|
walk(name);
|
|
13504
14920
|
return [...scope];
|
|
13505
14921
|
};
|
|
13506
|
-
const
|
|
14922
|
+
const kept2 = (file.views ?? []).filter((v) => !ownViews.has(v.id) && originOf(v));
|
|
14923
|
+
const groups = new Set(kept2.filter((v) => !v.partOf).map((v) => `${v.origin}
|
|
14924
|
+
${v.id}`));
|
|
14925
|
+
const views = kept2.map((v) => {
|
|
13507
14926
|
const model = originModel(v.origin);
|
|
13508
|
-
|
|
14927
|
+
const { partOf, ...rest } = v;
|
|
14928
|
+
return { ...rest, ...partOf && groups.has(`${v.origin}
|
|
14929
|
+
${partOf}`) ? { partOf } : {}, folder: normalizeViewFolder(v.folder ? `${model}/${v.folder}` : model), originScope: scopeOf(model) };
|
|
13509
14930
|
});
|
|
13510
14931
|
return {
|
|
13511
14932
|
...data,
|
|
@@ -13520,9 +14941,14 @@ function withOtherModels(data, file) {
|
|
|
13520
14941
|
init_define_RADICAL_BUILD();
|
|
13521
14942
|
import { readFile, readdir, stat } from "fs/promises";
|
|
13522
14943
|
import { basename, dirname as dirname2, join, resolve } from "path";
|
|
14944
|
+
|
|
14945
|
+
// ../../packages/common/src/modelFolders.ts
|
|
14946
|
+
init_define_RADICAL_BUILD();
|
|
13523
14947
|
var RADICAL_DIR = ".radical";
|
|
13524
14948
|
var MODEL_FOLDER = `${RADICAL_DIR}/model`;
|
|
13525
14949
|
var OLD_MODEL_FOLDER = "architecture";
|
|
14950
|
+
|
|
14951
|
+
// ../../packages/node-files/src/repositoryLayout.ts
|
|
13526
14952
|
var SENSORS_FILE = `${RADICAL_DIR}/sensors/sensors.json`;
|
|
13527
14953
|
var CRUCIBLE_FILE = `${RADICAL_DIR}/crucible/crucible.json`;
|
|
13528
14954
|
var CRUCIBLE_FINDINGS = `${RADICAL_DIR}/crucible/findings`;
|
|
@@ -13570,6 +14996,12 @@ async function mappingRoot(folder) {
|
|
|
13570
14996
|
const at = resolve(folder);
|
|
13571
14997
|
return await repositoryRoot(at) ?? (basename(dirname2(at)) === RADICAL_DIR ? dirname2(dirname2(at)) : dirname2(at));
|
|
13572
14998
|
}
|
|
14999
|
+
async function repositoryFileOf(folder) {
|
|
15000
|
+
const found = await findRepositoryFile(folder, REPOSITORY_FILE, REPOSITORY_FILE);
|
|
15001
|
+
if (found) return { file: found.path, root: repositoryFileRoot(found.path) };
|
|
15002
|
+
const root2 = await mappingRoot(folder);
|
|
15003
|
+
return { file: join(root2, REPOSITORY_FILE), root: root2 };
|
|
15004
|
+
}
|
|
13573
15005
|
async function readRepositoryMapping(from) {
|
|
13574
15006
|
const found = await findRepositoryFile(from, REPOSITORY_FILE, REPOSITORY_FILE);
|
|
13575
15007
|
if (!found) return null;
|
|
@@ -13618,6 +15050,9 @@ async function readEditorStateFile(root2, path) {
|
|
|
13618
15050
|
async function writeForgeRunFile(root2, content) {
|
|
13619
15051
|
await writeEditorStateFile(root2, FORGE_RUN_FILE, content);
|
|
13620
15052
|
}
|
|
15053
|
+
async function writeAssayRunFile(root2, content) {
|
|
15054
|
+
await writeEditorStateFile(root2, ASSAY_RUN_FILE, content);
|
|
15055
|
+
}
|
|
13621
15056
|
|
|
13622
15057
|
// ../../packages/node-files/src/diskFolderStorage.ts
|
|
13623
15058
|
var WRITE_LOCK = "write.lock";
|
|
@@ -14625,7 +16060,7 @@ function separateParallelSegments(routes) {
|
|
|
14625
16060
|
if (list.length < 2) continue;
|
|
14626
16061
|
list.sort((a, b) => a.lo - b.lo);
|
|
14627
16062
|
let cluster = [];
|
|
14628
|
-
let
|
|
16063
|
+
let reach2 = -Infinity;
|
|
14629
16064
|
const spread = () => {
|
|
14630
16065
|
const ids = new Set(cluster.map((c) => c.id));
|
|
14631
16066
|
if (ids.size > 1) {
|
|
@@ -14646,9 +16081,9 @@ function separateParallelSegments(routes) {
|
|
|
14646
16081
|
cluster = [];
|
|
14647
16082
|
};
|
|
14648
16083
|
for (const seg of list) {
|
|
14649
|
-
if (cluster.length > 0 && seg.lo >=
|
|
16084
|
+
if (cluster.length > 0 && seg.lo >= reach2 - 1) spread();
|
|
14650
16085
|
cluster.push(seg);
|
|
14651
|
-
|
|
16086
|
+
reach2 = cluster.length === 1 ? seg.hi : Math.max(reach2, seg.hi);
|
|
14652
16087
|
}
|
|
14653
16088
|
spread();
|
|
14654
16089
|
}
|
|
@@ -16108,6 +17543,20 @@ function centre2(nodes, boxes, parents, id, axis) {
|
|
|
16108
17543
|
for (let p = nodes[id]?.parentId; p && boxes[p]; p = nodes[p]?.parentId) c += boxes[p][axis];
|
|
16109
17544
|
return c;
|
|
16110
17545
|
}
|
|
17546
|
+
function heldByPins(nodes, pinned) {
|
|
17547
|
+
const out = /* @__PURE__ */ new Set();
|
|
17548
|
+
if (!pinned.length) return out;
|
|
17549
|
+
const within2 = (id) => {
|
|
17550
|
+
for (let cur = id; cur && nodes[cur]; cur = nodes[cur].parentId) if (pinned.includes(cur)) return true;
|
|
17551
|
+
return false;
|
|
17552
|
+
};
|
|
17553
|
+
for (const id of Object.keys(nodes)) {
|
|
17554
|
+
if (!within2(id)) continue;
|
|
17555
|
+
out.add(id);
|
|
17556
|
+
for (let p = nodes[id].parentId; p && nodes[p]; p = nodes[p].parentId) out.add(p);
|
|
17557
|
+
}
|
|
17558
|
+
return out;
|
|
17559
|
+
}
|
|
16111
17560
|
function enforceAlignments(nodes, positions, alignments, fixed = /* @__PURE__ */ new Set()) {
|
|
16112
17561
|
if (!alignments.length) return positions;
|
|
16113
17562
|
const boxes = boxesOf(nodes, positions);
|
|
@@ -16145,38 +17594,49 @@ function enforceAlignments(nodes, positions, alignments, fixed = /* @__PURE__ */
|
|
|
16145
17594
|
const parts2 = lines.map((l) => l[common2]);
|
|
16146
17595
|
return chain.map((id, k) => parts2.filter((p) => p === parts2[k]).length === 1 ? parts2[k] : id);
|
|
16147
17596
|
};
|
|
17597
|
+
const touched = /* @__PURE__ */ new Set();
|
|
17598
|
+
const shift = (id, axis, d) => {
|
|
17599
|
+
if (Math.abs(d) < 0.01) return;
|
|
17600
|
+
boxes[id][axis] += d;
|
|
17601
|
+
touched.add(id);
|
|
17602
|
+
};
|
|
16148
17603
|
const snap3 = () => {
|
|
16149
17604
|
for (const lines of rankedLines(alignments)) {
|
|
17605
|
+
if (lines.some((a) => a.ids.some((id) => fixed.has(id)))) continue;
|
|
16150
17606
|
const at = lines.map((a) => lineAt(nodes, boxes, parents, a));
|
|
16151
17607
|
if (at.every((c, k) => k === 0 || c - at[k - 1] >= MIN_STEP)) continue;
|
|
16152
17608
|
const slots = [...at].sort((p, q) => p - q);
|
|
16153
17609
|
for (let k = 1; k < slots.length; k++) slots[k] = Math.max(slots[k], slots[k - 1] + MIN_STEP);
|
|
16154
17610
|
lines.forEach((a, k) => {
|
|
16155
|
-
for (const id of a.ids)
|
|
17611
|
+
for (const id of a.ids) shift(id, a.axis, slots[k] - at[k]);
|
|
16156
17612
|
});
|
|
16157
17613
|
}
|
|
16158
17614
|
for (const a of alignments) {
|
|
16159
17615
|
const centres = a.ids.map((id) => centre2(nodes, boxes, parents, id, a.axis));
|
|
16160
|
-
const
|
|
17616
|
+
const held = centres.filter((_, i) => fixed.has(a.ids[i]));
|
|
17617
|
+
if (held.length === a.ids.length || held.length && Math.max(...held) - Math.min(...held) > TOLERANCE) continue;
|
|
17618
|
+
const on = held.length ? held : centres;
|
|
17619
|
+
const target = on.reduce((s, c) => s + c, 0) / on.length;
|
|
16161
17620
|
a.ids.forEach((id, i) => {
|
|
16162
|
-
|
|
17621
|
+
if (!fixed.has(id)) shift(id, a.axis, target - centres[i]);
|
|
16163
17622
|
});
|
|
16164
17623
|
const along = alongAxis(a);
|
|
16165
17624
|
for (const chain of a.orders) {
|
|
16166
17625
|
const cs = chain.map((id) => centre2(nodes, boxes, parents, id, along));
|
|
16167
17626
|
if (cs.every((c, k) => k === 0 || c - cs[k - 1] >= MIN_STEP)) continue;
|
|
17627
|
+
const movers = chainMovers(chain);
|
|
17628
|
+
if (movers.some((m) => fixed.has(m))) continue;
|
|
16168
17629
|
const slots = [...cs].sort((x, y) => x - y);
|
|
16169
17630
|
for (let k = 1; k < slots.length; k++) slots[k] = Math.max(slots[k], slots[k - 1] + MIN_STEP);
|
|
16170
|
-
const movers = chainMovers(chain);
|
|
16171
17631
|
chain.forEach((id, k) => {
|
|
16172
|
-
|
|
17632
|
+
shift(movers[k], along, slots[k] - cs[k]);
|
|
16173
17633
|
});
|
|
16174
17634
|
}
|
|
16175
17635
|
}
|
|
16176
17636
|
};
|
|
16177
17637
|
const fit = (pid) => {
|
|
16178
17638
|
const children2 = byParent.get(pid) ?? [];
|
|
16179
|
-
if (!children2.
|
|
17639
|
+
if (!children2.some((id) => touched.has(id))) return;
|
|
16180
17640
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
16181
17641
|
for (const id of children2) {
|
|
16182
17642
|
const b = boxes[id];
|
|
@@ -16190,6 +17650,7 @@ function enforceAlignments(nodes, positions, alignments, fixed = /* @__PURE__ */
|
|
|
16190
17650
|
const dx = minX - pad.side;
|
|
16191
17651
|
const dy = minY - pad.top;
|
|
16192
17652
|
const p = boxes[pid];
|
|
17653
|
+
const was = { ...p };
|
|
16193
17654
|
p.x += dx;
|
|
16194
17655
|
p.y += dy;
|
|
16195
17656
|
for (const id of children2) {
|
|
@@ -16199,6 +17660,7 @@ function enforceAlignments(nodes, positions, alignments, fixed = /* @__PURE__ */
|
|
|
16199
17660
|
const min = NODE_SIZES[parent.type] ?? { width: 0, height: 0 };
|
|
16200
17661
|
p.width = Math.max(maxX - minX + 2 * pad.side, min.width);
|
|
16201
17662
|
p.height = Math.max(maxY - minY + pad.top + pad.bottom, min.height);
|
|
17663
|
+
if (Math.abs(p.x - was.x) > 0.01 || Math.abs(p.y - was.y) > 0.01 || Math.abs(p.width - was.width) > 0.01 || Math.abs(p.height - was.height) > 0.01) touched.add(pid);
|
|
16202
17664
|
};
|
|
16203
17665
|
const drawnMid = (id, axis) => {
|
|
16204
17666
|
const b = boxes[id];
|
|
@@ -16244,12 +17706,13 @@ function enforceAlignments(nodes, positions, alignments, fixed = /* @__PURE__ */
|
|
|
16244
17706
|
const group = (id, axis) => cluster[axis].get(id) ?? [id];
|
|
16245
17707
|
const movable = (id, axis) => !group(id, axis).some((m) => locked[axis].has(m) || fixed.has(m));
|
|
16246
17708
|
const move = (id, axis, d) => {
|
|
16247
|
-
for (const m of group(id, axis))
|
|
17709
|
+
for (const m of group(id, axis)) shift(m, axis, d);
|
|
16248
17710
|
};
|
|
16249
17711
|
for (let pass = 0; pass < 200; pass++) {
|
|
16250
17712
|
let moved = false;
|
|
16251
17713
|
for (let i = 0; i < ids.length; i++) {
|
|
16252
17714
|
for (let j = i + 1; j < ids.length; j++) {
|
|
17715
|
+
if (!touched.has(ids[i]) && !touched.has(ids[j])) continue;
|
|
16253
17716
|
const a = boxes[ids[i]];
|
|
16254
17717
|
const b = boxes[ids[j]];
|
|
16255
17718
|
const ox = Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) + gap;
|
|
@@ -17795,8 +19258,8 @@ var LiveColaEngine = class {
|
|
|
17795
19258
|
* into; what they cover is pushed clear (rebuild). `covered`: only what
|
|
17796
19259
|
* they lie on, not what stands nearer to them than a drop leaves (a new
|
|
17797
19260
|
* parent round what stood there: "Wrap into…"). */
|
|
17798
|
-
invalidate(
|
|
17799
|
-
if (this._running) this.rebuild("local", [],
|
|
19261
|
+
invalidate(added2 = [], covered = false) {
|
|
19262
|
+
if (this._running) this.rebuild("local", [], added2, covered);
|
|
17800
19263
|
}
|
|
17801
19264
|
/**
|
|
17802
19265
|
* The store's positions were replaced wholesale (view switch, undo,
|
|
@@ -18253,15 +19716,15 @@ var LiveColaEngine = class {
|
|
|
18253
19716
|
frameOf(g) {
|
|
18254
19717
|
const b = g.bounds;
|
|
18255
19718
|
if (!b || !Number.isFinite(b.x)) return void 0;
|
|
18256
|
-
const
|
|
18257
|
-
if (
|
|
18258
|
-
const first =
|
|
19719
|
+
const kept2 = this.keptFrames.get(g.c4id);
|
|
19720
|
+
if (kept2) {
|
|
19721
|
+
const first = kept2.leaves[0];
|
|
18259
19722
|
const dx = first ? first.node.x - first.x : 0;
|
|
18260
19723
|
const dy = first ? first.node.y - first.y : 0;
|
|
18261
|
-
if (!this.carriedInside(g.c4id) && movedAlike(
|
|
18262
|
-
return { x:
|
|
19724
|
+
if (!this.carriedInside(g.c4id) && movedAlike(kept2.leaves, dx, dy, RIGID_PX)) {
|
|
19725
|
+
return { x: kept2.frame.x + dx, X: kept2.frame.X + dx, y: kept2.frame.y + dy, Y: kept2.frame.Y + dy };
|
|
18263
19726
|
}
|
|
18264
|
-
return this.heldIn(g,
|
|
19727
|
+
return this.heldIn(g, kept2);
|
|
18265
19728
|
}
|
|
18266
19729
|
const s = g.visualShrink ?? 0;
|
|
18267
19730
|
const box = { x: b.x + s, X: b.X - s, y: b.y + s, Y: b.Y - s };
|
|
@@ -18280,18 +19743,18 @@ var LiveColaEngine = class {
|
|
|
18280
19743
|
/** A kept frame grown to hold the children of `g` that moved since it
|
|
18281
19744
|
* was kept, as drawn, with the room it had round its children on each
|
|
18282
19745
|
* side (KeptFrame.room). It does not grow for what did not move. */
|
|
18283
|
-
heldIn(g,
|
|
18284
|
-
const box = { ...
|
|
18285
|
-
const moved = new Set(
|
|
19746
|
+
heldIn(g, kept2) {
|
|
19747
|
+
const box = { ...kept2.frame };
|
|
19748
|
+
const moved = new Set(kept2.leaves.filter((l) => l.node.x !== l.x || l.node.y !== l.y).map((l) => l.node));
|
|
18286
19749
|
if (!moved.size) return box;
|
|
18287
19750
|
for (const id of this.childrenOf.get(g.c4id) ?? []) {
|
|
18288
19751
|
if (!this.leavesOf(id).some((leaf) => moved.has(leaf))) continue;
|
|
18289
19752
|
const inner = this.boxOf(id);
|
|
18290
19753
|
if (!inner) continue;
|
|
18291
|
-
box.x = Math.min(box.x, inner.x -
|
|
18292
|
-
box.X = Math.max(box.X, inner.X +
|
|
18293
|
-
box.y = Math.min(box.y, inner.y -
|
|
18294
|
-
box.Y = Math.max(box.Y, inner.Y +
|
|
19754
|
+
box.x = Math.min(box.x, inner.x - kept2.room.x);
|
|
19755
|
+
box.X = Math.max(box.X, inner.X + kept2.room.X);
|
|
19756
|
+
box.y = Math.min(box.y, inner.y - kept2.room.y);
|
|
19757
|
+
box.Y = Math.max(box.Y, inner.Y + kept2.room.Y);
|
|
18295
19758
|
}
|
|
18296
19759
|
return box;
|
|
18297
19760
|
}
|
|
@@ -18343,9 +19806,9 @@ var LiveColaEngine = class {
|
|
|
18343
19806
|
/** The tick handler: groups whose leaves the physics moved are framed by
|
|
18344
19807
|
* it from here on, at their bounds (frameOf). */
|
|
18345
19808
|
framesOfPhysics() {
|
|
18346
|
-
for (const [id,
|
|
18347
|
-
const first =
|
|
18348
|
-
if (!first || !movedAlike(
|
|
19809
|
+
for (const [id, kept2] of this.keptFrames) {
|
|
19810
|
+
const first = kept2.leaves[0];
|
|
19811
|
+
if (!first || !movedAlike(kept2.leaves, first.node.x - first.x, first.node.y - first.y, REPORT_PX)) this.keptFrames.delete(id);
|
|
18349
19812
|
}
|
|
18350
19813
|
}
|
|
18351
19814
|
/** A frame's box (LiveColaModel.frames): moved with what is in it when
|
|
@@ -18502,10 +19965,10 @@ var LiveColaEngine = class {
|
|
|
18502
19965
|
}
|
|
18503
19966
|
if (!stray) return;
|
|
18504
19967
|
const S = this.boxOf(stray);
|
|
18505
|
-
const
|
|
19968
|
+
const others2 = kids.filter((k) => k !== stray).map((k) => this.boxOf(k)).filter((b) => !!b);
|
|
18506
19969
|
const axis = this.pushAxis(stray, "y");
|
|
18507
|
-
if (axis === "y") this.translate(stray, "y", Math.max(...
|
|
18508
|
-
else if (axis === "x") this.translate(stray, "x", Math.max(...
|
|
19970
|
+
if (axis === "y") this.translate(stray, "y", Math.max(...others2.map((b) => b.Y)) + CALM_GAP - S.y);
|
|
19971
|
+
else if (axis === "x") this.translate(stray, "x", Math.max(...others2.map((b) => b.X)) + CALM_GAP - S.x);
|
|
18509
19972
|
else stuck.add(stray);
|
|
18510
19973
|
moved.add(stray);
|
|
18511
19974
|
}
|
|
@@ -18646,8 +20109,8 @@ var LiveColaEngine = class {
|
|
|
18646
20109
|
* 'whole' leaves everything free (relax, relaxLive). Of the new ones,
|
|
18647
20110
|
* those in `added` (new to the model) stay where they are put.
|
|
18648
20111
|
*/
|
|
18649
|
-
rebuild(run, free = [],
|
|
18650
|
-
const newIds = new Set(
|
|
20112
|
+
rebuild(run, free = [], added2 = [], covered = false) {
|
|
20113
|
+
const newIds = new Set(added2);
|
|
18651
20114
|
if (this.cola) this.cola.stop();
|
|
18652
20115
|
this.resetPace();
|
|
18653
20116
|
this.reported.clear();
|
|
@@ -19438,11 +20901,11 @@ function filterForView(allNodes, allRelations, viewFilter, viewCollapsedSet) {
|
|
|
19438
20901
|
const s = inView(r.sourceId), t = inView(r.targetId);
|
|
19439
20902
|
if (!s || !t || s === t || isAncestor2(s, t) || isAncestor2(t, s)) continue;
|
|
19440
20903
|
const key = `${s}\0${t}`;
|
|
19441
|
-
const
|
|
19442
|
-
if (
|
|
19443
|
-
if (r.label) relations[
|
|
20904
|
+
const kept2 = rolledUpLine.get(key);
|
|
20905
|
+
if (kept2) {
|
|
20906
|
+
if (r.label) relations[kept2] = { ...relations[kept2], label: relations[kept2].label ? `${relations[kept2].label}
|
|
19444
20907
|
${r.label}` : r.label };
|
|
19445
|
-
if (relations[
|
|
20908
|
+
if (relations[kept2].technology !== r.technology) relations[kept2] = { ...relations[kept2], technology: void 0 };
|
|
19446
20909
|
continue;
|
|
19447
20910
|
}
|
|
19448
20911
|
rolledUpLine.set(key, id);
|
|
@@ -19468,7 +20931,14 @@ function viewLayoutInput(view, allNodes, allRelations, constraints = view?.layou
|
|
|
19468
20931
|
for (const [id, r] of Object.entries(lines)) {
|
|
19469
20932
|
if (!hidden.has(id)) relations[id] = r;
|
|
19470
20933
|
}
|
|
19471
|
-
return { nodes, relations, viewFilter, viewCollapsedSet, expandedSet, alignments: resolveAlignments(constraints, nodes), frames: new Set([...frames].filter((id) => nodes[id])) };
|
|
20934
|
+
return { nodes, relations, viewFilter, viewCollapsedSet, expandedSet, alignments: resolveAlignments(constraints, nodes), frames: new Set([...frames].filter((id) => nodes[id])), pinned: pinnedNodeIds(constraints).filter((id) => nodes[id]) };
|
|
20935
|
+
}
|
|
20936
|
+
function placeOnViewCanvas(nodes, positions, view, relations, wrap) {
|
|
20937
|
+
const shown = view ? computeViewNodeSet(view, nodes, relations) ?? void 0 : void 0;
|
|
20938
|
+
const childless = computeViewCollapsedSet(shown, nodes);
|
|
20939
|
+
const folded = view ? (n) => n.collapsed && !(view.expandedNodeIds?.includes(n.id) ?? false) || (view.collapsedNodeIds?.includes(n.id) ?? false) || childless.has(n.id) : void 0;
|
|
20940
|
+
const frames = viewFrames(view, nodes, relations);
|
|
20941
|
+
return placeUnplaced(nodes, positions, shown, folded, { frames, wrap: wrap?.ids, wrapped: wrap?.wrapped });
|
|
19472
20942
|
}
|
|
19473
20943
|
function applyLayoutPositions(c4Nodes, positions, input) {
|
|
19474
20944
|
for (const [id, pos] of Object.entries(positions)) {
|
|
@@ -19485,10 +20955,50 @@ function applyAlignments(c4Nodes, input) {
|
|
|
19485
20955
|
if (!input.alignments.length) return false;
|
|
19486
20956
|
const { nodes } = projectToVisibleGraph(input.nodes, input.relations);
|
|
19487
20957
|
if (alignmentError(nodes, {}, input.alignments) <= 0.5) return false;
|
|
19488
|
-
|
|
19489
|
-
|
|
20958
|
+
const held = heldByPins(nodes, input.pinned);
|
|
20959
|
+
let positions = enforceAlignments(nodes, {}, input.alignments, held);
|
|
20960
|
+
let off = input.alignments.filter((a) => alignmentError(nodes, positions, [a]) > 0.5).flatMap((a) => a.ids);
|
|
20961
|
+
if (!off.length && alignmentError(nodes, positions, input.alignments) > 0.5) off = input.alignments.filter((a) => a.rank).flatMap((a) => a.ids);
|
|
20962
|
+
if (off.length) positions = enforceAlignments(nodes, {}, input.alignments, new Set([...held].filter((id) => !off.includes(id))));
|
|
20963
|
+
const changed = {};
|
|
20964
|
+
for (const [id, p] of Object.entries(positions)) {
|
|
20965
|
+
const n = nodes[id];
|
|
20966
|
+
if (Math.abs(p.x - n.x) > 0.01 || Math.abs(p.y - n.y) > 0.01 || Math.abs((p.width ?? n.width) - n.width) > 0.01 || Math.abs((p.height ?? n.height) - n.height) > 0.01) changed[id] = p;
|
|
20967
|
+
}
|
|
20968
|
+
applyLayoutPositions(c4Nodes, changed, input);
|
|
20969
|
+
return Object.keys(changed).length > 0;
|
|
20970
|
+
}
|
|
20971
|
+
function keptFrames(drawn, positions, tight) {
|
|
20972
|
+
const near = (a, b) => a === void 0 || b === void 0 || Math.abs(a - b) < 0.5;
|
|
20973
|
+
const at = (id, after) => {
|
|
20974
|
+
let x = 0, y = 0;
|
|
20975
|
+
for (let c = id; c && drawn[c]; c = drawn[c].parentId) {
|
|
20976
|
+
const p = after && positions[c] || drawn[c];
|
|
20977
|
+
x += p.x;
|
|
20978
|
+
y += p.y;
|
|
20979
|
+
}
|
|
20980
|
+
return { x, y };
|
|
20981
|
+
};
|
|
20982
|
+
const same3 = (id) => {
|
|
20983
|
+
const n = drawn[id], p = positions[id];
|
|
20984
|
+
if (!p) return true;
|
|
20985
|
+
const was = at(id, false), now4 = at(id, true);
|
|
20986
|
+
return near(was.x, now4.x) && near(was.y, now4.y) && near(n.width, p.width) && near(n.height, p.height);
|
|
20987
|
+
};
|
|
20988
|
+
const children2 = /* @__PURE__ */ new Map();
|
|
20989
|
+
for (const n of Object.values(drawn)) if (n.parentId && drawn[n.parentId]) children2.set(n.parentId, [...children2.get(n.parentId) ?? [], n.id]);
|
|
20990
|
+
const kept2 = /* @__PURE__ */ new Map();
|
|
20991
|
+
const keeps = (id) => {
|
|
20992
|
+
let hit = kept2.get(id);
|
|
20993
|
+
if (hit === void 0) {
|
|
20994
|
+
hit = same3(id) && (children2.get(id) ?? []).every(keeps);
|
|
20995
|
+
kept2.set(id, hit);
|
|
20996
|
+
}
|
|
20997
|
+
return hit;
|
|
20998
|
+
};
|
|
20999
|
+
return new Set([...children2.keys()].filter((id) => !tight.has(id) && keeps(id)));
|
|
19490
21000
|
}
|
|
19491
|
-
function resizeParentsBottomUp(nodes, input) {
|
|
21001
|
+
function resizeParentsBottomUp(nodes, input, keep) {
|
|
19492
21002
|
const { viewFilter, viewCollapsedSet, expandedSet } = input;
|
|
19493
21003
|
const inView = (n) => !viewFilter || viewFilter.has(n.id);
|
|
19494
21004
|
const size = (n) => isContainerType(n.type) && isEffectivelyCollapsed(n, viewCollapsedSet, expandedSet) ? { width: COLLAPSED_WIDTH[n.type], height: COLLAPSED_HEIGHT[n.type] } : { width: n.width, height: n.height };
|
|
@@ -19501,7 +21011,7 @@ function resizeParentsBottomUp(nodes, input) {
|
|
|
19501
21011
|
parentIds.sort((a, b) => depth2(b) - depth2(a));
|
|
19502
21012
|
for (const id of parentIds) {
|
|
19503
21013
|
const parent = nodes[id];
|
|
19504
|
-
if (!parent || !isContainerType(parent.type) || isEffectivelyCollapsed(parent, viewCollapsedSet, expandedSet)) continue;
|
|
21014
|
+
if (!parent || keep?.has(id) || !isContainerType(parent.type) || isEffectivelyCollapsed(parent, viewCollapsedSet, expandedSet)) continue;
|
|
19505
21015
|
const children2 = Object.values(nodes).filter((c) => c.parentId === id && inView(c));
|
|
19506
21016
|
if (!children2.length) continue;
|
|
19507
21017
|
const fitted = fittedParentSize(parent, children2.map((c) => ({ x: c.x, y: c.y, ...size(c) })));
|
|
@@ -21073,7 +22583,7 @@ function unchangedResult(nodes, relations, style = "curved") {
|
|
|
21073
22583
|
}
|
|
21074
22584
|
async function runSmartLayoutELKPhase(inputNodes, inputRelations, metamodel, onProgress) {
|
|
21075
22585
|
const { nodes, relations } = projectToVisibleGraph(inputNodes, inputRelations);
|
|
21076
|
-
const { applyElkLayout } = await import("./elkLayout-
|
|
22586
|
+
const { applyElkLayout } = await import("./elkLayout-YXJWF5QP.js");
|
|
21077
22587
|
const depth2 = maxContainmentDepth(metamodel);
|
|
21078
22588
|
const mmDirection = depth2 >= 2 ? "RIGHT" : "DOWN";
|
|
21079
22589
|
const engines = [
|
|
@@ -21282,6 +22792,11 @@ var Layout2 = class {
|
|
|
21282
22792
|
this.edgeStyle = "curved";
|
|
21283
22793
|
/** Containers the canvas draws only to hold what a view shows: tight round it, no padding, no header, no size of their own. */
|
|
21284
22794
|
this.tight = /* @__PURE__ */ new Set();
|
|
22795
|
+
/** The frames the canvas drew otherwise than fitted round what the view
|
|
22796
|
+
* shows (the tight ones aside: they are drawn invisible). A view showing
|
|
22797
|
+
* part of what a frame holds opens on All elements' places: the frame as
|
|
22798
|
+
* wide as all it holds there, the part shown wherever it stood in it. */
|
|
22799
|
+
this.refitted = [];
|
|
21285
22800
|
this.peerLists = /* @__PURE__ */ new Map();
|
|
21286
22801
|
for (const id of frames) this.tight.add(id);
|
|
21287
22802
|
const abs = /* @__PURE__ */ new Map();
|
|
@@ -21321,7 +22836,41 @@ var Layout2 = class {
|
|
|
21321
22836
|
for (const d of this.descendants(id)) this.fixedIds.add(d);
|
|
21322
22837
|
for (const a of this.ancestorSets.get(id)) this.holdsFixed.add(a);
|
|
21323
22838
|
}
|
|
22839
|
+
const drawn = this.drawn = new Map(this.boxes);
|
|
21324
22840
|
this.fitAll();
|
|
22841
|
+
for (const [id, b] of this.boxes) {
|
|
22842
|
+
const was = drawn.get(id);
|
|
22843
|
+
if (!this.tight.has(id) && (Math.abs(b.x - was.x) > 1 || Math.abs(b.y - was.y) > 1 || Math.abs(b.w - was.w) > 1 || Math.abs(b.h - was.h) > 1)) this.refitted.push(id);
|
|
22844
|
+
}
|
|
22845
|
+
}
|
|
22846
|
+
/** The frames `which` names given back as drawn where nothing they hold
|
|
22847
|
+
* moved (a frame holding a pin, a frame round a selection: fitted only
|
|
22848
|
+
* round a child that moved), and the frames round them fitted again. One
|
|
22849
|
+
* that would now lie on a sibling stays fitted. Returns the frames given back. */
|
|
22850
|
+
keepUnmoved(which) {
|
|
22851
|
+
const back = [];
|
|
22852
|
+
const movedIn = /* @__PURE__ */ new Set();
|
|
22853
|
+
for (const id of this.allIds) {
|
|
22854
|
+
if (this.children.has(id)) continue;
|
|
22855
|
+
const b = this.boxes.get(id), was = this.drawn.get(id);
|
|
22856
|
+
if (Math.abs(b.x - was.x) > 0.01 || Math.abs(b.y - was.y) > 0.01) for (const a of this.ancestorSets.get(id)) movedIn.add(a);
|
|
22857
|
+
}
|
|
22858
|
+
const depth2 = (id) => this.ancestorSets.get(id).size;
|
|
22859
|
+
for (const id of [...this.children.keys()].sort((a, b) => depth2(a) - depth2(b))) {
|
|
22860
|
+
if (movedIn.has(id) || this.fixedIds.has(id) || !which(id)) continue;
|
|
22861
|
+
const p = this.parentOf(id);
|
|
22862
|
+
if (p && !movedIn.has(p) && !this.fixedIds.has(p) && which(p)) continue;
|
|
22863
|
+
const frames = [id, ...this.descendants(id)].filter((x) => this.children.has(x));
|
|
22864
|
+
const fitted = this.snapshot(frames);
|
|
22865
|
+
for (const f of frames) this.set(f, { ...this.drawn.get(f) });
|
|
22866
|
+
if (this.overlaps(id)) {
|
|
22867
|
+
this.restore(fitted);
|
|
22868
|
+
continue;
|
|
22869
|
+
}
|
|
22870
|
+
back.push(...frames);
|
|
22871
|
+
for (let a = p; a; a = this.parentOf(a)) this.fit(a);
|
|
22872
|
+
}
|
|
22873
|
+
return back;
|
|
21325
22874
|
}
|
|
21326
22875
|
/** Whether no move may take the element: it is pinned, held by one, or holds one. */
|
|
21327
22876
|
fixed(id) {
|
|
@@ -21460,7 +23009,7 @@ var Layout2 = class {
|
|
|
21460
23009
|
if (was.x === x0 && was.y === y0 && was.w === w && was.h === h) return;
|
|
21461
23010
|
this.set(id, { x: x0, y: y0, w, h, cx: x0 + w / 2, cy: y0 + h / 2 });
|
|
21462
23011
|
}
|
|
21463
|
-
/** Every frame fitted round its children again (after positions were set from outside). */
|
|
23012
|
+
/** Every frame fitted round its children again (after positions were set from outside); a pinned one, or one inside it, stays as drawn. */
|
|
21464
23013
|
refit() {
|
|
21465
23014
|
this.fitAll();
|
|
21466
23015
|
}
|
|
@@ -21470,7 +23019,7 @@ var Layout2 = class {
|
|
|
21470
23019
|
for (let p = this.parentOf(id); p; p = this.parentOf(p)) d++;
|
|
21471
23020
|
return d;
|
|
21472
23021
|
};
|
|
21473
|
-
for (const id of [...this.children.keys()].sort((a, b) => depth2(b) - depth2(a))) this.fit(id);
|
|
23022
|
+
for (const id of [...this.children.keys()].sort((a, b) => depth2(b) - depth2(a))) if (!this.fixedIds.has(id)) this.fit(id);
|
|
21474
23023
|
}
|
|
21475
23024
|
/** Whether `id` lies clear of its siblings (by its container's gap) and inside its container. */
|
|
21476
23025
|
clear(id) {
|
|
@@ -22083,13 +23632,13 @@ function portsOf(l, all) {
|
|
|
22083
23632
|
return { ports, geom };
|
|
22084
23633
|
}
|
|
22085
23634
|
function imbalance(l, id, lines) {
|
|
22086
|
-
const
|
|
22087
|
-
if (
|
|
23635
|
+
const others2 = lines.map((x) => x.a === id ? x.b : x.a);
|
|
23636
|
+
if (others2.length < 2) return 0;
|
|
22088
23637
|
const b = l.box(id);
|
|
22089
|
-
const mx =
|
|
22090
|
-
const my =
|
|
22091
|
-
const spreadX = Math.max(...
|
|
22092
|
-
const spreadY = Math.max(...
|
|
23638
|
+
const mx = others2.reduce((s, o) => s + l.box(o).cx, 0) / others2.length;
|
|
23639
|
+
const my = others2.reduce((s, o) => s + l.box(o).cy, 0) / others2.length;
|
|
23640
|
+
const spreadX = Math.max(...others2.map((o) => l.box(o).cx)) - Math.min(...others2.map((o) => l.box(o).cx));
|
|
23641
|
+
const spreadY = Math.max(...others2.map((o) => l.box(o).cy)) - Math.min(...others2.map((o) => l.box(o).cy));
|
|
22093
23642
|
const off = spreadX >= spreadY ? Math.abs(b.cx - mx) : Math.abs(b.cy - my);
|
|
22094
23643
|
return Math.min(2, off / l.meanSize);
|
|
22095
23644
|
}
|
|
@@ -22146,12 +23695,12 @@ function inGrid(l, id) {
|
|
|
22146
23695
|
function nearMissesOf(l, id) {
|
|
22147
23696
|
const b = l.box(id);
|
|
22148
23697
|
const out = [];
|
|
22149
|
-
const near = NEAR * l.meanSize,
|
|
23698
|
+
const near = NEAR * l.meanSize, reach2 = 2 * l.meanSize;
|
|
22150
23699
|
for (const o of l.peersIn(l.parentOf(id))) {
|
|
22151
23700
|
if (o === id) continue;
|
|
22152
23701
|
const r = l.box(o);
|
|
22153
23702
|
const gx = Math.max(0, r.x - (b.x + b.w), b.x - (r.x + r.w)), gy = Math.max(0, r.y - (b.y + b.h), b.y - (r.y + r.h));
|
|
22154
|
-
if (gx >
|
|
23703
|
+
if (gx > reach2 || gy > reach2) continue;
|
|
22155
23704
|
for (const axis of ["x", "y"]) {
|
|
22156
23705
|
const d = offLine(l, id, o, axis);
|
|
22157
23706
|
if (d >= STRAIGHT_TOLERANCE && d < near) out.push({ o, axis });
|
|
@@ -22199,14 +23748,14 @@ function spreadOf(l, id) {
|
|
|
22199
23748
|
}
|
|
22200
23749
|
function misplaced(l, id, lines) {
|
|
22201
23750
|
const n = l.nodes[id];
|
|
22202
|
-
const
|
|
22203
|
-
if (!
|
|
23751
|
+
const others2 = lines.map((x) => x.a === id ? x.b : x.a);
|
|
23752
|
+
if (!others2.length) return 0;
|
|
22204
23753
|
const b = l.box(id);
|
|
22205
23754
|
const role = l.role(id);
|
|
22206
|
-
if (role === "actor" || role === "start") return
|
|
22207
|
-
if (role === "end") return
|
|
22208
|
-
if (role === "broker" &&
|
|
22209
|
-
const p = l.box(
|
|
23755
|
+
if (role === "actor" || role === "start") return others2.filter((o) => l.box(o).y < b.y + b.h).length;
|
|
23756
|
+
if (role === "end") return others2.filter((o) => l.box(o).y + l.box(o).h > b.y).length;
|
|
23757
|
+
if (role === "broker" && others2.length === 2) {
|
|
23758
|
+
const p = l.box(others2[0]), q = l.box(others2[1]);
|
|
22210
23759
|
const dx = q.cx - p.cx, dy = q.cy - p.cy;
|
|
22211
23760
|
const len = Math.hypot(dx, dy) || 1;
|
|
22212
23761
|
const t = Math.max(0, Math.min(1, ((b.cx - p.cx) * dx + (b.cy - p.cy) * dy) / (len * len)));
|
|
@@ -22214,8 +23763,8 @@ function misplaced(l, id, lines) {
|
|
|
22214
23763
|
return off > l.meanSize / 2 ? 1 : 0;
|
|
22215
23764
|
}
|
|
22216
23765
|
if (n.external && !l.parentOf(id)) {
|
|
22217
|
-
const below =
|
|
22218
|
-
const right =
|
|
23766
|
+
const below = others2.every((o) => l.box(o).y + l.box(o).h <= b.y);
|
|
23767
|
+
const right = others2.every((o) => l.box(o).x + l.box(o).w <= b.x);
|
|
22219
23768
|
return below || right ? 0 : 1;
|
|
22220
23769
|
}
|
|
22221
23770
|
return 0;
|
|
@@ -22360,10 +23909,10 @@ function localCostParts(l, lines, moved, index, roomy, extra, boxes) {
|
|
|
22360
23909
|
return costOf(l, lines, mine, [...ids], moved, idx, roomy, boxes);
|
|
22361
23910
|
}
|
|
22362
23911
|
function siblingsNear(l, parent, b, out) {
|
|
22363
|
-
const
|
|
23912
|
+
const reach2 = 3 * l.meanSize;
|
|
22364
23913
|
for (const s of l.peersIn(parent)) {
|
|
22365
23914
|
const r = l.box(s);
|
|
22366
|
-
if (r.x < b.x + b.w +
|
|
23915
|
+
if (r.x < b.x + b.w + reach2 && b.x < r.x + r.w + reach2 && r.y < b.y + b.h + reach2 && b.y < r.y + r.h + reach2) out.add(s);
|
|
22367
23916
|
}
|
|
22368
23917
|
}
|
|
22369
23918
|
var Grid = class {
|
|
@@ -22541,8 +24090,8 @@ function placeNear(l, id, cx, cy) {
|
|
|
22541
24090
|
const b = l.box(id);
|
|
22542
24091
|
const parent = l.parentOf(id);
|
|
22543
24092
|
const gap = l.gapOf(parent);
|
|
22544
|
-
const
|
|
22545
|
-
const fits = (x, y) =>
|
|
24093
|
+
const others2 = l.childrenOf(parent).filter((o) => o !== id).map((o) => l.box(o));
|
|
24094
|
+
const fits = (x, y) => others2.every((r) => x + b.w + gap <= r.x || r.x + r.w + gap <= x || y + b.h + gap <= r.y || r.y + r.h + gap <= y);
|
|
22546
24095
|
const step = Math.max(40, Math.round(gap + b.h / 2));
|
|
22547
24096
|
for (let ring = 0; ring <= 10; ring++) {
|
|
22548
24097
|
const spots = [];
|
|
@@ -23248,12 +24797,12 @@ function runTidyLayout(inputNodes, inputRelations, options = {}) {
|
|
|
23248
24797
|
}
|
|
23249
24798
|
positions = { ...positions };
|
|
23250
24799
|
const roots = Object.keys(positions).filter((id) => !nodes[id].parentId || !nodes[nodes[id].parentId]);
|
|
23251
|
-
if (!first.pinned) {
|
|
24800
|
+
if (!first.pinned.length) {
|
|
23252
24801
|
const minX = Math.min(...roots.map((id) => positions[id].x)), minY = Math.min(...roots.map((id) => positions[id].y));
|
|
23253
24802
|
for (const id of roots) positions[id] = { ...positions[id], x: positions[id].x - minX, y: positions[id].y - minY };
|
|
23254
24803
|
}
|
|
23255
24804
|
const projected = projectPositions(nodes, positions);
|
|
23256
|
-
const afterLayout = new Layout2(projected, options.metamodel,
|
|
24805
|
+
const afterLayout = new Layout2(projected, options.metamodel, first.pinned, options.frames);
|
|
23257
24806
|
afterLayout.edgeStyle = style;
|
|
23258
24807
|
const after = totalCost(afterLayout, lines);
|
|
23259
24808
|
const score = computeCompositeScore(projected, relations, style);
|
|
@@ -23300,6 +24849,17 @@ function tidyOnce(inputNodes, inputRelations, options, spent) {
|
|
|
23300
24849
|
l.setPositions(enforceAlignments(nodes, l.positions(), alignments, new Set(l.ids().filter((id) => l.fixed(id)))));
|
|
23301
24850
|
l.refit();
|
|
23302
24851
|
};
|
|
24852
|
+
if (l.refitted.length) {
|
|
24853
|
+
const now4 = l.positions();
|
|
24854
|
+
const moved = {};
|
|
24855
|
+
for (const id of l.refitted) {
|
|
24856
|
+
moved[id] = now4[id];
|
|
24857
|
+
for (const c of l.childrenOf(id)) moved[c] = now4[c];
|
|
24858
|
+
}
|
|
24859
|
+
const description = l.refitted.length === 1 ? `${nodes[l.refitted[0]].label ?? l.refitted[0]} fitted round what the view shows` : `${l.refitted.length} frames fitted round what the view shows`;
|
|
24860
|
+
steps.push({ kind: "fit", description, gain: 0, moved });
|
|
24861
|
+
options.onProgress?.(steps.length, description);
|
|
24862
|
+
}
|
|
23303
24863
|
{
|
|
23304
24864
|
const wasPositions = l.positions();
|
|
23305
24865
|
lineUp();
|
|
@@ -23360,7 +24920,8 @@ function tidyOnce(inputNodes, inputRelations, options, spent) {
|
|
|
23360
24920
|
if (level(ds)) continue;
|
|
23361
24921
|
off = true;
|
|
23362
24922
|
const moved2 = ds.filter((m) => Math.abs(m.d) >= 0.01);
|
|
23363
|
-
|
|
24923
|
+
const follows = moved2.length > 0 && ds.every((m) => Math.abs(m.d) >= 0.01 || !l.fixed(m.id));
|
|
24924
|
+
if (follow && follows && level(moved2)) {
|
|
23364
24925
|
for (const m of ds) if (Math.abs(m.d) < 0.01) shift(a, m.id, moved2[0].d);
|
|
23365
24926
|
} else for (const m of moved2) shift(a, m.id, -m.d);
|
|
23366
24927
|
}
|
|
@@ -23520,7 +25081,7 @@ function tidyOnce(inputNodes, inputRelations, options, spent) {
|
|
|
23520
25081
|
if (steps.length % CHECKPOINT_EVERY === 0) checkpoint();
|
|
23521
25082
|
const touched = stale ?? /* @__PURE__ */ new Set();
|
|
23522
25083
|
stale = touched;
|
|
23523
|
-
const
|
|
25084
|
+
const reach2 = 3 * l.meanSize;
|
|
23524
25085
|
for (const id of Object.keys(moved)) {
|
|
23525
25086
|
touched.add(id);
|
|
23526
25087
|
for (const x of index.linesOf.get(id) ?? []) {
|
|
@@ -23534,7 +25095,7 @@ function tidyOnce(inputNodes, inputRelations, options, spent) {
|
|
|
23534
25095
|
const wasBox = before2 ? { x: pb.x + before2.x, y: pb.y + before2.y, w: before2.width ?? nowBox.w, h: before2.height ?? nowBox.h } : nowBox;
|
|
23535
25096
|
for (const s of l.childrenOf(parent)) {
|
|
23536
25097
|
const r = l.box(s);
|
|
23537
|
-
const near = (b) => r.x < b.x + b.w +
|
|
25098
|
+
const near = (b) => r.x < b.x + b.w + reach2 && b.x < r.x + r.w + reach2 && r.y < b.y + b.h + reach2 && b.y < r.y + r.h + reach2;
|
|
23538
25099
|
if (near(nowBox) || near(wasBox)) touched.add(s);
|
|
23539
25100
|
}
|
|
23540
25101
|
}
|
|
@@ -23682,7 +25243,20 @@ function tidyOnce(inputNodes, inputRelations, options, spent) {
|
|
|
23682
25243
|
steps.length = best.steps;
|
|
23683
25244
|
}
|
|
23684
25245
|
lineUp();
|
|
23685
|
-
|
|
25246
|
+
if (options.around?.length || pinned.length) {
|
|
25247
|
+
const back = new Set(l.keepUnmoved((id) => !!options.around?.length || l.fixed(id)));
|
|
25248
|
+
const fit = steps[0]?.kind === "fit" ? steps[0] : null;
|
|
25249
|
+
if (fit && back.size) {
|
|
25250
|
+
const kept2 = l.refitted.filter((id) => !back.has(id));
|
|
25251
|
+
if (!kept2.length) steps.shift();
|
|
25252
|
+
else {
|
|
25253
|
+
const moved = {};
|
|
25254
|
+
for (const id of kept2) for (const x of [id, ...l.childrenOf(id)]) moved[x] = fit.moved[x];
|
|
25255
|
+
steps[0] = { ...fit, moved, description: kept2.length === 1 ? `${nodes[kept2[0]].label ?? kept2[0]} fitted round what the view shows` : `${kept2.length} frames fitted round what the view shows` };
|
|
25256
|
+
}
|
|
25257
|
+
}
|
|
25258
|
+
}
|
|
25259
|
+
return { nodes, relations, baseline, lines, steps, before, work, budgetOut: outOfTime(), positions: l.positions(), pinned };
|
|
23686
25260
|
}
|
|
23687
25261
|
function tidySummary(tidy) {
|
|
23688
25262
|
const arrow = "\u2009\u2192\u2009";
|
|
@@ -24082,7 +25656,7 @@ var RADICAL_STAGE_VIEWPOINTS = {
|
|
|
24082
25656
|
c4: ["containers", "system-containers", "system-context", "components", "container-components", "responsibilities"],
|
|
24083
25657
|
review: ["requirement-gaps", "requirement-coverage", "traceability"]
|
|
24084
25658
|
};
|
|
24085
|
-
var viewsOfViewpoint = (views, viewpoint) => Object.values(views ?? {}).filter((v) => v.viewpoint === viewpoint);
|
|
25659
|
+
var viewsOfViewpoint = (views, viewpoint) => Object.values(views ?? {}).filter((v) => v.viewpoint === viewpoint && !v.origin);
|
|
24086
25660
|
var viewOfViewpoint = (views, viewpoint) => {
|
|
24087
25661
|
const all = viewsOfViewpoint(views, viewpoint);
|
|
24088
25662
|
const members = all.filter((v) => v.partOf).sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -24249,13 +25823,13 @@ function forgeArrangeGroups(facade, addedNodeIds, stage, structure = { kind: "la
|
|
|
24249
25823
|
if (structure.kind === "radical") {
|
|
24250
25824
|
const metamodel = facade.getMetamodel?.();
|
|
24251
25825
|
if (!metamodel) return [];
|
|
24252
|
-
const
|
|
25826
|
+
const added2 = new Set(addedNodeIds);
|
|
24253
25827
|
for (const viewpoint of structure.viewpoints) {
|
|
24254
25828
|
for (const view of viewsOfViewpoint(views, viewpoint)) {
|
|
24255
25829
|
if (!isCanvas(view)) continue;
|
|
24256
25830
|
if (!view.partOf && view !== viewOfViewpoint(views, viewpoint)) continue;
|
|
24257
25831
|
const shown = new Set(shownBy2(facade, view, metamodel).map((n) => n.id));
|
|
24258
|
-
const nodeIds = outermostNodes(nodes, addedNodeIds.filter((id) =>
|
|
25832
|
+
const nodeIds = outermostNodes(nodes, addedNodeIds.filter((id) => added2.has(id) && shown.has(id)));
|
|
24259
25833
|
if (nodeIds.length) groups.push({ viewId: view.id, viewName: view.name, nodeIds });
|
|
24260
25834
|
}
|
|
24261
25835
|
}
|
|
@@ -24275,16 +25849,18 @@ function forgeArrangeGroups(facade, addedNodeIds, stage, structure = { kind: "la
|
|
|
24275
25849
|
function arrangeForgeGroup(facade, group, arrangement) {
|
|
24276
25850
|
const count2 = group.nodeIds.length;
|
|
24277
25851
|
if (count2 < 2) return { ok: false, text: `${group.viewName}: only one new element, nothing to arrange.` };
|
|
25852
|
+
const shown = canvasOverflow(facade.getViews?.()[group.viewId], facade.getNodes(), facade.getRelations());
|
|
25853
|
+
if (shown !== null) return { ok: false, text: `${group.viewName}: shows ${shown.toLocaleString("en")} elements; a canvas draws up to ${CANVAS_MAX_ELEMENTS.toLocaleString("en")}.` };
|
|
24278
25854
|
if (arrangement === "grid") {
|
|
24279
25855
|
if (!facade.addGrid) return { ok: false, text: "Grids are not editable here." };
|
|
24280
25856
|
const columns = landscapeGridColumns(count2);
|
|
24281
|
-
const
|
|
24282
|
-
if ("error" in
|
|
25857
|
+
const added3 = facade.addGrid(group.viewId, group.nodeIds, columns);
|
|
25858
|
+
if ("error" in added3) return { ok: false, text: `${group.viewName}: ${added3.error}` };
|
|
24283
25859
|
return { ok: true, text: `${group.viewName}: ${count2} elements in a grid of ${columns} columns.` };
|
|
24284
25860
|
}
|
|
24285
25861
|
if (!facade.addAlignment) return { ok: false, text: "Alignments are not editable here." };
|
|
24286
|
-
const
|
|
24287
|
-
if ("error" in
|
|
25862
|
+
const added2 = facade.addAlignment(group.viewId, arrangement === "row" ? "horizontal" : "vertical", group.nodeIds, true);
|
|
25863
|
+
if ("error" in added2) return { ok: false, text: `${group.viewName}: ${added2.error}` };
|
|
24288
25864
|
return { ok: true, text: `${group.viewName}: ${count2} elements in a ${arrangement}.` };
|
|
24289
25865
|
}
|
|
24290
25866
|
|
|
@@ -24349,8 +25925,8 @@ function acceptedRefinements(refinements, accepted) {
|
|
|
24349
25925
|
const own = fields.get(r.id);
|
|
24350
25926
|
if (!own) return [];
|
|
24351
25927
|
if (r.change !== "changed") return [r];
|
|
24352
|
-
const
|
|
24353
|
-
return
|
|
25928
|
+
const kept2 = (r.fields ?? []).filter((field) => own.has(field));
|
|
25929
|
+
return kept2.length ? [{ ...r, fields: kept2 }] : [];
|
|
24354
25930
|
});
|
|
24355
25931
|
}
|
|
24356
25932
|
var isRejectable = (refinement) => refinement.change !== "removed";
|
|
@@ -24579,11 +26155,19 @@ async function applyProposal(proposal, ctx) {
|
|
|
24579
26155
|
results.push(result.resultText);
|
|
24580
26156
|
}
|
|
24581
26157
|
const after = snapshotOf(ctx.diagram);
|
|
24582
|
-
const
|
|
26158
|
+
const added2 = [
|
|
24583
26159
|
...Object.keys(after.nodes).filter((id) => !before.nodes[id]),
|
|
24584
26160
|
...Object.keys(after.relations).filter((id) => !before.relations[id])
|
|
24585
26161
|
];
|
|
24586
|
-
return { ok: true, text: results.join(" "), refinements: stageRefinements("review", before, after), added };
|
|
26162
|
+
return { ok: true, text: results.join(" "), refinements: stageRefinements("review", before, after), added: added2 };
|
|
26163
|
+
}
|
|
26164
|
+
function stageOfType(type2, stage) {
|
|
26165
|
+
const at = FORGE_STAGES.findIndex((s) => s.id === stage);
|
|
26166
|
+
const makes = (s) => PRIMARY_TYPE_IDS_FOR_STAGE[s.id].includes(type2);
|
|
26167
|
+
const earlier = FORGE_STAGES.slice(0, at).filter(makes).pop();
|
|
26168
|
+
if (earlier) return { title: earlier.title, earlier: true };
|
|
26169
|
+
const later = FORGE_STAGES.slice(at + 1).find(makes);
|
|
26170
|
+
return later ? { title: later.title, earlier: false } : void 0;
|
|
24587
26171
|
}
|
|
24588
26172
|
function refinementGuard(state, name, rawInput, resolveId, proposeTool = PROPOSE_REFINEMENT) {
|
|
24589
26173
|
const input = rawInput ?? {};
|
|
@@ -24600,7 +26184,11 @@ function refinementGuard(state, name, rawInput, resolveId, proposeTool = PROPOSE
|
|
|
24600
26184
|
case "add_node": {
|
|
24601
26185
|
const own = PRIMARY_TYPE_IDS_FOR_STAGE[state.stage];
|
|
24602
26186
|
if (typeof input.type === "string" && !own.includes(input.type)) {
|
|
24603
|
-
|
|
26187
|
+
const article = /^[aeiou]/i.test(input.type) ? "an" : "a";
|
|
26188
|
+
const owner2 = stageOfType(input.type, state.stage);
|
|
26189
|
+
const here = `not to this one (${own.join(", ") || "none of its own"})`;
|
|
26190
|
+
if (!owner2) return `add_node: ${article} ${input.type} is made by no Forge stage, ${here}. ${ask}`;
|
|
26191
|
+
return owner2.earlier ? `add_node: ${article} ${input.type} belongs to an earlier stage (${owner2.title}), ${here}. ${ask}` : `add_node: ${article} ${input.type} belongs to a later stage (${owner2.title}), ${here}: add it in that stage.`;
|
|
24604
26192
|
}
|
|
24605
26193
|
return null;
|
|
24606
26194
|
}
|
|
@@ -24760,7 +26348,7 @@ function buildIndex2(entries) {
|
|
|
24760
26348
|
}
|
|
24761
26349
|
|
|
24762
26350
|
// src/forge.ts
|
|
24763
|
-
var
|
|
26351
|
+
var STAGE_IDS3 = FORGE_STAGES.map((stage) => stage.id);
|
|
24764
26352
|
var FORGE_PROCEDURE = [
|
|
24765
26353
|
"Radical Forge turns a free-text description into EARS requirements, a domain model, fitness functions,",
|
|
24766
26354
|
"Gherkin scenarios, state machines, processes, UI mockups and a C4 model, one reviewed stage at a time, and",
|
|
@@ -24799,7 +26387,7 @@ var FORGE_PROCEDURE = [
|
|
|
24799
26387
|
" concern packs' decisions to the elements they are about; forge_complete_stage binds any it left unbound.",
|
|
24800
26388
|
"3. forge_finish: what each stage added, and the Gherkin .feature files of the scenarios."
|
|
24801
26389
|
].join("\n");
|
|
24802
|
-
var stageEnum = { type: "string", enum:
|
|
26390
|
+
var stageEnum = { type: "string", enum: STAGE_IDS3 };
|
|
24803
26391
|
var FORGE_TOOL_DEFS = [
|
|
24804
26392
|
{
|
|
24805
26393
|
name: "forge_start",
|
|
@@ -24954,9 +26542,22 @@ var FORGE_TOOL_DEFS = [
|
|
|
24954
26542
|
additionalProperties: false
|
|
24955
26543
|
}
|
|
24956
26544
|
},
|
|
26545
|
+
{
|
|
26546
|
+
name: "forge_skip_stage",
|
|
26547
|
+
description: "Leave stages of the Forge run out, with why: a system of this size does not need them (a back end without screens needs no mockups; one whose entities have no real lifecycle no state machines). Any stages not begun, in one call; the later stages then run without them, and forge_finish and Studio's view of the run name them with the reason. Clarifying or generating a skipped stage later runs it after all.",
|
|
26548
|
+
inputSchema: {
|
|
26549
|
+
type: "object",
|
|
26550
|
+
properties: {
|
|
26551
|
+
stages: { type: "array", items: { type: "string", enum: STAGE_IDS3 }, description: "The stages to leave out." },
|
|
26552
|
+
reason: { type: "string", description: "Why, in one sentence the user reads." }
|
|
26553
|
+
},
|
|
26554
|
+
required: ["stages", "reason"],
|
|
26555
|
+
additionalProperties: false
|
|
26556
|
+
}
|
|
26557
|
+
},
|
|
24957
26558
|
{
|
|
24958
26559
|
name: "forge_finish",
|
|
24959
|
-
description: "End the Forge run: what each stage added
|
|
26560
|
+
description: "End the Forge run: what each stage added, which were skipped (with forge_skip_stage) and which not run, and the Gherkin .feature files built from the scenarios in the model. Refused while a stage is open (complete it with forge_complete_stage first) or a proposed refinement waits for the user's answer.",
|
|
24960
26561
|
inputSchema: {
|
|
24961
26562
|
type: "object",
|
|
24962
26563
|
properties: {
|
|
@@ -25084,6 +26685,8 @@ var Forge = class {
|
|
|
25084
26685
|
return this.wireframe(args, ctx, facade);
|
|
25085
26686
|
case "forge_import_hub_concept":
|
|
25086
26687
|
return this.importConcept(args, facade);
|
|
26688
|
+
case "forge_skip_stage":
|
|
26689
|
+
return this.skip(args);
|
|
25087
26690
|
case "forge_finish":
|
|
25088
26691
|
return this.finish(args, facade);
|
|
25089
26692
|
default:
|
|
@@ -25092,17 +26695,17 @@ var Forge = class {
|
|
|
25092
26695
|
}
|
|
25093
26696
|
stageArg(args, tool) {
|
|
25094
26697
|
const stage = args.stage;
|
|
25095
|
-
if (typeof stage !== "string" || !
|
|
25096
|
-
return `${tool}: stage must be one of ${
|
|
26698
|
+
if (typeof stage !== "string" || !STAGE_IDS3.includes(stage)) {
|
|
26699
|
+
return `${tool}: stage must be one of ${STAGE_IDS3.join(", ")}`;
|
|
25097
26700
|
}
|
|
25098
26701
|
return stage;
|
|
25099
26702
|
}
|
|
25100
26703
|
/** Why `stage` cannot be clarified or generated now, or null. */
|
|
25101
26704
|
blocked(run, stage) {
|
|
25102
|
-
const generating =
|
|
26705
|
+
const generating = STAGE_IDS3.find((id) => run.stages[id]?.status === "generating" && id !== stage);
|
|
25103
26706
|
if (generating) return `The ${stageTitle(generating)} stage is still open; finish it with forge_complete_stage first.`;
|
|
25104
|
-
const missing =
|
|
25105
|
-
if (missing) return `Stages run in order: generate ${stageTitle(missing)} (${missing}) first.`;
|
|
26707
|
+
const missing = STAGE_IDS3.slice(0, STAGE_IDS3.indexOf(stage)).find((id) => run.stages[id]?.status !== "done" && !run.skipped.has(id));
|
|
26708
|
+
if (missing) return `Stages run in order: generate ${stageTitle(missing)} (${missing}) first, or leave it out with forge_skip_stage.`;
|
|
25106
26709
|
return null;
|
|
25107
26710
|
}
|
|
25108
26711
|
start(args, ctx, facade) {
|
|
@@ -25163,6 +26766,7 @@ var Forge = class {
|
|
|
25163
26766
|
structure,
|
|
25164
26767
|
languages,
|
|
25165
26768
|
clarified: /* @__PURE__ */ new Set(),
|
|
26769
|
+
skipped: /* @__PURE__ */ new Map(),
|
|
25166
26770
|
stages: {}
|
|
25167
26771
|
};
|
|
25168
26772
|
const lines = [
|
|
@@ -25176,33 +26780,58 @@ var Forge = class {
|
|
|
25176
26780
|
"Stages:",
|
|
25177
26781
|
...FORGE_STAGES.map((stage, i) => `${i + 1}. ${stage.title} (${stage.id}): ${stage.blurb}`),
|
|
25178
26782
|
"",
|
|
25179
|
-
`Next: forge_clarify with stage "${
|
|
26783
|
+
`Next: forge_clarify with stage "${STAGE_IDS3[0]}".`
|
|
25180
26784
|
];
|
|
25181
26785
|
return ok(lines.join("\n"), { readOnly, data, commit: () => {
|
|
25182
26786
|
this.run = run;
|
|
25183
26787
|
} });
|
|
25184
26788
|
}
|
|
26789
|
+
/** Leaves the stages named out of the run, with why (ADR Agents model as
|
|
26790
|
+
* they work; Forge on request). */
|
|
26791
|
+
skip(args) {
|
|
26792
|
+
const run = this.run;
|
|
26793
|
+
if (!run) return fail2("forge_skip_stage: no Forge run; call forge_start first");
|
|
26794
|
+
const reason = typeof args.reason === "string" ? args.reason.trim() : "";
|
|
26795
|
+
if (!reason) return fail2("forge_skip_stage: say why in reason");
|
|
26796
|
+
if (!Array.isArray(args.stages) || !args.stages.length) return fail2("forge_skip_stage: stages must name at least one stage");
|
|
26797
|
+
const unknown = args.stages.filter((s) => typeof s !== "string" || !STAGE_IDS3.includes(s));
|
|
26798
|
+
if (unknown.length) return fail2(`forge_skip_stage: stages must be among ${STAGE_IDS3.join(", ")}; not ${unknown.join(", ")}`);
|
|
26799
|
+
const ids = [...new Set(args.stages)];
|
|
26800
|
+
const begun = ids.filter((id) => run.stages[id]);
|
|
26801
|
+
if (begun.length) return fail2(`forge_skip_stage: ${begun.map((id) => `${stageTitle(id)} (${id}) is ${run.stages[id].status === "done" ? "done" : "open"}`).join(", ")}; only stages not begun can be left out`);
|
|
26802
|
+
const next = STAGE_IDS3.find((id) => run.stages[id]?.status !== "done" && !run.skipped.has(id) && !ids.includes(id));
|
|
26803
|
+
return ok([
|
|
26804
|
+
`Skipped ${ids.map((id) => `${stageTitle(id)} (${id})`).join(", ")}: ${reason}`,
|
|
26805
|
+
next ? `Next: forge_clarify with stage "${next}", or forge_skip_stage for it too.` : "No stage is left: call forge_finish."
|
|
26806
|
+
].join("\n"), { readOnly: true, commit: () => {
|
|
26807
|
+
for (const id of ids) {
|
|
26808
|
+
run.skipped.set(id, reason);
|
|
26809
|
+
run.clarified.delete(id);
|
|
26810
|
+
}
|
|
26811
|
+
} });
|
|
26812
|
+
}
|
|
25185
26813
|
clarify(args) {
|
|
25186
26814
|
const run = this.run;
|
|
25187
26815
|
if (!run) return fail2("forge_clarify: no Forge run; call forge_start first");
|
|
25188
26816
|
const stage = this.stageArg(args, "forge_clarify");
|
|
25189
|
-
if (!
|
|
26817
|
+
if (!STAGE_IDS3.includes(stage)) return fail2(stage);
|
|
25190
26818
|
const id = stage;
|
|
25191
26819
|
const blocked = this.blocked(run, id);
|
|
25192
26820
|
if (blocked) return fail2(`forge_clarify: ${blocked}`);
|
|
25193
26821
|
const packs = id === "requirements" ? this.concernPacks() : [];
|
|
25194
|
-
const priorQA =
|
|
26822
|
+
const priorQA = STAGE_IDS3.slice(0, STAGE_IDS3.indexOf(id)).map((prior) => run.stages[prior]?.clarifications ?? "").filter(Boolean).join("\n\n");
|
|
25195
26823
|
const lines = [buildClarifyPrompt(stageTitle(id), run.description, packs, priorQA, "ask"), "", ...forgeLanguageRules(run.languages)];
|
|
25196
26824
|
lines.push("", `Then call forge_generate with stage "${id}"${packs.length ? ", the answers and the concerns" : " and the answers"}.`);
|
|
25197
26825
|
return ok(lines.join("\n"), { readOnly: true, commit: () => {
|
|
25198
26826
|
run.clarified.add(id);
|
|
26827
|
+
run.skipped.delete(id);
|
|
25199
26828
|
} });
|
|
25200
26829
|
}
|
|
25201
26830
|
generate(args, facade) {
|
|
25202
26831
|
const run = this.run;
|
|
25203
26832
|
if (!run) return fail2("forge_generate: no Forge run; call forge_start first");
|
|
25204
26833
|
const stage = this.stageArg(args, "forge_generate");
|
|
25205
|
-
if (!
|
|
26834
|
+
if (!STAGE_IDS3.includes(stage)) return fail2(stage);
|
|
25206
26835
|
const id = stage;
|
|
25207
26836
|
const blocked = this.blocked(run, id);
|
|
25208
26837
|
if (blocked) return fail2(`forge_generate: ${blocked}`);
|
|
@@ -25244,16 +26873,16 @@ var Forge = class {
|
|
|
25244
26873
|
if (previous) {
|
|
25245
26874
|
const refinements = previous.refinements ?? acceptedRefinements(stageRefinements(id, previous.snapshot, snapshotOf(facade)), previous.accepted);
|
|
25246
26875
|
if (rejectRefinements(facade, refinements).length) readOnly = false;
|
|
25247
|
-
const
|
|
25248
|
-
for (const viewId of
|
|
26876
|
+
const added2 = previous.added ?? idsAddedSince(previous.before, this.ids(facade));
|
|
26877
|
+
for (const viewId of added2.views) if (facade.getViews?.()[viewId]) {
|
|
25249
26878
|
facade.removeView?.(viewId);
|
|
25250
26879
|
readOnly = false;
|
|
25251
26880
|
}
|
|
25252
|
-
for (const relId of
|
|
26881
|
+
for (const relId of added2.relations) if (facade.getRelations()[relId]) {
|
|
25253
26882
|
facade.removeRelation(relId);
|
|
25254
26883
|
readOnly = false;
|
|
25255
26884
|
}
|
|
25256
|
-
for (const nodeId of
|
|
26885
|
+
for (const nodeId of added2.nodes) if (facade.getNodes()[nodeId]) {
|
|
25257
26886
|
facade.removeNode(nodeId);
|
|
25258
26887
|
readOnly = false;
|
|
25259
26888
|
}
|
|
@@ -25296,12 +26925,12 @@ var Forge = class {
|
|
|
25296
26925
|
}
|
|
25297
26926
|
const nodes = data ? Object.fromEntries(data.nodes.map((n) => [n.id, n])) : facade.getNodes();
|
|
25298
26927
|
const relations = data ? Object.fromEntries(data.relations.map((r) => [r.id, r])) : facade.getRelations();
|
|
25299
|
-
const stageIdx =
|
|
26928
|
+
const stageIdx = STAGE_IDS3.indexOf(id);
|
|
25300
26929
|
const priorSummaries = buildPriorStagesBlock(
|
|
25301
26930
|
FORGE_STAGES.slice(0, stageIdx).map((s) => ({ title: s.title, summary: run.stages[s.id]?.summary ?? "" }))
|
|
25302
26931
|
);
|
|
25303
26932
|
const needNode = run.needId ? nodes[run.needId] : void 0;
|
|
25304
|
-
const gaps = forgeGaps(
|
|
26933
|
+
const gaps = forgeGaps(STAGE_IDS3.slice(0, stageIdx), nodes, relations, facade.getMetamodel?.());
|
|
25305
26934
|
const prompt = buildForgeStagePrompt(
|
|
25306
26935
|
id,
|
|
25307
26936
|
run.description,
|
|
@@ -25318,7 +26947,7 @@ var Forge = class {
|
|
|
25318
26947
|
context = `The model has ${Object.keys(nodes).length} nodes and ${Object.keys(relations).length} relations, too many to list here. Look up what this stage needs with search_model, e.g. LIST NODES WHERE type = "requirement".`;
|
|
25319
26948
|
}
|
|
25320
26949
|
const brief = [
|
|
25321
|
-
`Radical Forge \u2014 stage ${stageIdx + 1} of ${
|
|
26950
|
+
`Radical Forge \u2014 stage ${stageIdx + 1} of ${STAGE_IDS3.length}: ${stageTitle(id)}${previous ? " (regenerating; what it added before has been removed)" : ""}`,
|
|
25322
26951
|
FORGE_STAGES[stageIdx].blurb,
|
|
25323
26952
|
...openedNames.length ? [`Made the stage's views before it begins: ${openedNames.join(", ")}. What you add shows up in them as you add it.`] : [],
|
|
25324
26953
|
...id === "requirements" && decided.length ? [`Imported the concern packs the user confirmed, whole and unbound: ${decided.map((d) => d.name).join(", ")}. The C4 stage links them.`] : [],
|
|
@@ -25352,13 +26981,14 @@ var Forge = class {
|
|
|
25352
26981
|
return ok(brief, { readOnly, ...data ? { data } : {}, commit: () => {
|
|
25353
26982
|
run.stages[id] = state;
|
|
25354
26983
|
run.concerns = decided;
|
|
26984
|
+
run.finished = false;
|
|
25355
26985
|
} });
|
|
25356
26986
|
}
|
|
25357
26987
|
complete(args, facade) {
|
|
25358
26988
|
const run = this.run;
|
|
25359
26989
|
if (!run) return fail2("forge_complete_stage: no Forge run; call forge_start first");
|
|
25360
26990
|
const stage = this.stageArg(args, "forge_complete_stage");
|
|
25361
|
-
if (!
|
|
26991
|
+
if (!STAGE_IDS3.includes(stage)) return fail2(stage);
|
|
25362
26992
|
const id = stage;
|
|
25363
26993
|
const state = run.stages[id];
|
|
25364
26994
|
if (state?.status !== "generating") return fail2(`forge_complete_stage: the ${stageTitle(id)} stage is not open; begin it with forge_generate`);
|
|
@@ -25367,10 +26997,10 @@ var Forge = class {
|
|
|
25367
26997
|
const all = idsAddedSince(state.before, this.ids(facade));
|
|
25368
26998
|
const refinements = acceptedRefinements(stageRefinements(id, state.snapshot, snapshotOf(facade)), state.accepted);
|
|
25369
26999
|
const refined = new Set(refinements.filter((r) => r.change === "added").map((r) => r.id));
|
|
25370
|
-
const
|
|
27000
|
+
const added2 = { ...all, nodes: all.nodes.filter((n) => !refined.has(n)), relations: all.relations.filter((r) => !refined.has(r)) };
|
|
25371
27001
|
const filed = fileIntoForgeViews(facade, all.nodes, id, run.structure);
|
|
25372
27002
|
const dropped = dropEmptyForgeViews(facade, state.opened);
|
|
25373
|
-
|
|
27003
|
+
added2.views = added2.views.filter((v) => !dropped.includes(v));
|
|
25374
27004
|
let bound = [];
|
|
25375
27005
|
if (id === "c4" && run.concerns.length) {
|
|
25376
27006
|
const binding = bindUnboundConcerns(run.concerns, this.concernPacks(), facade.getNodes(), facade.getRelations(), facade.getMetamodel?.());
|
|
@@ -25378,9 +27008,9 @@ var Forge = class {
|
|
|
25378
27008
|
bound = binding.lines;
|
|
25379
27009
|
}
|
|
25380
27010
|
const nodes = facade.getNodes();
|
|
25381
|
-
const byType = countByType(nodes,
|
|
27011
|
+
const byType = countByType(nodes, added2.nodes);
|
|
25382
27012
|
const lines = [
|
|
25383
|
-
`${stageTitle(id)} done: +${
|
|
27013
|
+
`${stageTitle(id)} done: +${added2.nodes.length} nodes${byType ? ` (${byType})` : ""}, +${added2.relations.length} relations, +${added2.views.length} views.`
|
|
25384
27014
|
];
|
|
25385
27015
|
lines.push(...viewLines(filed));
|
|
25386
27016
|
if (bound.length) lines.push("Concern packs:", ...bound.map((l) => `- ${l}`));
|
|
@@ -25388,7 +27018,7 @@ var Forge = class {
|
|
|
25388
27018
|
lines.push(`It refined earlier stages as the user accepted (${refinements.length}):`, ...refinements.map((r) => `- ${describeRefinement(r)}`));
|
|
25389
27019
|
}
|
|
25390
27020
|
if (state.declined) lines.push(`The user declined ${state.declined} of its ${state.proposals} proposals.`);
|
|
25391
|
-
const gaps = forgeGaps(
|
|
27021
|
+
const gaps = forgeGaps(STAGE_IDS3.slice(0, STAGE_IDS3.indexOf(id) + 1), nodes, facade.getRelations(), facade.getMetamodel?.());
|
|
25392
27022
|
if (gaps.length) {
|
|
25393
27023
|
lines.push(`Gaps the model has now (${gaps.length}), by the rules of the stages done; ${id === "review" ? "tell the user which stay open" : "the next stage gets them"}:`, ...formatForgeGaps(gaps));
|
|
25394
27024
|
}
|
|
@@ -25402,7 +27032,7 @@ var Forge = class {
|
|
|
25402
27032
|
);
|
|
25403
27033
|
}
|
|
25404
27034
|
}
|
|
25405
|
-
const groups = forgeArrangeGroups(facade,
|
|
27035
|
+
const groups = forgeArrangeGroups(facade, added2.nodes, id, run.structure);
|
|
25406
27036
|
const alignable = groups.filter((g) => g.nodeIds.length >= 2);
|
|
25407
27037
|
const viewNames = groups.map((g) => g.viewName).join(" and ");
|
|
25408
27038
|
if (groups.length) {
|
|
@@ -25411,14 +27041,14 @@ var Forge = class {
|
|
|
25411
27041
|
- Run Smart Layout on ${viewNames}?`);
|
|
25412
27042
|
lines.push(`Do what they choose with forge_arrange (stage "${id}"${alignable.length ? ", align and/or smartLayout: true" : ", smartLayout: true"}).`);
|
|
25413
27043
|
}
|
|
25414
|
-
const next =
|
|
27044
|
+
const next = STAGE_IDS3[STAGE_IDS3.indexOf(id) + 1];
|
|
25415
27045
|
lines.push(next ? `${groups.length ? "Then" : "Next: show the user what this stage added and"} ask whether to continue with ${stageTitle(next)} (forge_clarify with stage "${next}"), regenerate this stage (forge_generate with regenerate: true) or finish here (forge_finish).` : `This was the last stage. ${groups.length ? "Then" : "Show the user what it added and"} ask whether to regenerate it (forge_generate with regenerate: true) or finish (forge_finish).`);
|
|
25416
27046
|
const changed = dropped.length > 0 || filed.some((f) => f.canvas && f.nodeIds.length || f.made) || bound.some((l) => l.includes("was bound"));
|
|
25417
27047
|
return ok(lines.join("\n"), {
|
|
25418
27048
|
readOnly: !changed,
|
|
25419
27049
|
data: changed ? placeInViews(facade.toDiagramData(), filed, facade.getMetamodel?.()) : void 0,
|
|
25420
27050
|
commit: () => {
|
|
25421
|
-
run.stages[id] = { ...state, status: "done", added, refinements, summary };
|
|
27051
|
+
run.stages[id] = { ...state, status: "done", added: added2, refinements, summary };
|
|
25422
27052
|
}
|
|
25423
27053
|
});
|
|
25424
27054
|
}
|
|
@@ -25427,7 +27057,7 @@ var Forge = class {
|
|
|
25427
27057
|
const run = this.run;
|
|
25428
27058
|
if (!run) return `${tool}: no Forge run; call forge_start first`;
|
|
25429
27059
|
const stage = this.stageArg(args, tool);
|
|
25430
|
-
if (!
|
|
27060
|
+
if (!STAGE_IDS3.includes(stage)) return stage;
|
|
25431
27061
|
const id = stage;
|
|
25432
27062
|
const state = run.stages[id];
|
|
25433
27063
|
if (state?.status !== "generating") return `${tool}: the ${stageTitle(id)} stage is not open; a stage proposes refinements while it runs`;
|
|
@@ -25486,7 +27116,7 @@ var Forge = class {
|
|
|
25486
27116
|
return ok(`Added ${pending.id}. ${outcome.text}${reply}`, {
|
|
25487
27117
|
commit: () => {
|
|
25488
27118
|
state.pending = void 0;
|
|
25489
|
-
for (const
|
|
27119
|
+
for (const added2 of outcome.added) state.proposed.add(added2);
|
|
25490
27120
|
state.accepted.push(...outcome.refinements);
|
|
25491
27121
|
}
|
|
25492
27122
|
});
|
|
@@ -25497,7 +27127,7 @@ var Forge = class {
|
|
|
25497
27127
|
guard(name, input, ctx) {
|
|
25498
27128
|
const run = this.run;
|
|
25499
27129
|
if (!run) return null;
|
|
25500
|
-
const id =
|
|
27130
|
+
const id = STAGE_IDS3.find((stage) => run.stages[stage]?.status === "generating");
|
|
25501
27131
|
const state = id ? run.stages[id] : void 0;
|
|
25502
27132
|
if (!id || !state) return null;
|
|
25503
27133
|
if (state.pending) return `${name}: proposal ${state.pending.id} waits for the user's answer; ask them and call forge_answer_refinement first.`;
|
|
@@ -25507,7 +27137,7 @@ var Forge = class {
|
|
|
25507
27137
|
const run = this.run;
|
|
25508
27138
|
if (!run) return fail2("forge_arrange: no Forge run; call forge_start first");
|
|
25509
27139
|
const stage = this.stageArg(args, "forge_arrange");
|
|
25510
|
-
if (!
|
|
27140
|
+
if (!STAGE_IDS3.includes(stage)) return fail2(stage);
|
|
25511
27141
|
const id = stage;
|
|
25512
27142
|
const state = run.stages[id];
|
|
25513
27143
|
if (state?.status !== "done" || !state.added) return fail2(`forge_arrange: complete the ${stageTitle(id)} stage first (forge_complete_stage)`);
|
|
@@ -25599,20 +27229,24 @@ Then call forge_wireframe again with mockupId "${id}" and the svg.`, { readOnly:
|
|
|
25599
27229
|
data.nodes.push(...Object.values(insert.nodes));
|
|
25600
27230
|
data.relations.push(...Object.values(insert.relations));
|
|
25601
27231
|
data.views = [...data.views ?? [], ...insert.views];
|
|
25602
|
-
const
|
|
27232
|
+
const added2 = Object.values(insert.nodes).map((n) => `- ${n.id} ${n.type} "${n.label}"`);
|
|
25603
27233
|
return ok([
|
|
25604
|
-
`Imported ${concept.name}: +${
|
|
27234
|
+
`Imported ${concept.name}: +${added2.length} nodes, +${Object.keys(insert.relations).length} relations, and its view ${insert.views.map((v) => `"${v.name}" (${v.id})`).join(", ")} in the folder Concerns.`,
|
|
25605
27235
|
bound,
|
|
25606
|
-
...
|
|
27236
|
+
...added2
|
|
25607
27237
|
].join("\n"), { data });
|
|
25608
27238
|
}
|
|
25609
27239
|
async finish(args, facade) {
|
|
25610
27240
|
const run = this.run;
|
|
25611
27241
|
if (!run) return fail2("forge_finish: no Forge run; call forge_start first");
|
|
27242
|
+
const open = STAGE_IDS3.find((stage) => run.stages[stage]?.status === "generating");
|
|
27243
|
+
const pending = open && run.stages[open].pending;
|
|
27244
|
+
if (pending) return fail2(`forge_finish: proposal ${pending.id} waits for the user's answer; ask them and call forge_answer_refinement first`);
|
|
27245
|
+
if (open) return fail2(`forge_finish: the ${stageTitle(open)} stage is open; complete it with forge_complete_stage first`);
|
|
25612
27246
|
const lines = FORGE_STAGES.map((stage) => {
|
|
25613
27247
|
const state = run.stages[stage.id];
|
|
25614
|
-
|
|
25615
|
-
if (state
|
|
27248
|
+
const why = run.skipped.get(stage.id);
|
|
27249
|
+
if (!state) return `- ${stage.title}: ${why !== void 0 ? `skipped (${why})` : "not run"}`;
|
|
25616
27250
|
const refined = state.refinements?.length ? ` \xB7 ${state.refinements.length} refinements of earlier stages accepted` : "";
|
|
25617
27251
|
return `- ${stage.title}: +${state.added.nodes.length} nodes \xB7 +${state.added.relations.length} relations${refined}`;
|
|
25618
27252
|
});
|
|
@@ -25655,7 +27289,9 @@ Then call forge_wireframe again with mockupId "${id}" and the svg.`, { readOnly:
|
|
|
25655
27289
|
};
|
|
25656
27290
|
}
|
|
25657
27291
|
if (state?.status === "generating") return { id: stage.id, status: "generating", ...state.pending ? { asking: true } : {} };
|
|
25658
|
-
|
|
27292
|
+
const why = run.skipped.get(stage.id);
|
|
27293
|
+
if (why !== void 0) return { id: stage.id, status: "skipped", reason: why };
|
|
27294
|
+
return { id: stage.id, status: run.clarified.has(stage.id) && !run.finished ? "clarifying" : "pending" };
|
|
25659
27295
|
})
|
|
25660
27296
|
};
|
|
25661
27297
|
}
|
|
@@ -25835,8 +27471,8 @@ var RepoFiles = class {
|
|
|
25835
27471
|
const builds = new Set(listing.files.filter((f) => /(^|\/)build\/[^/]+\.(cs|fs)proj$/i.test(f)).map((f) => f.slice(0, f.lastIndexOf("/"))));
|
|
25836
27472
|
const deployment = (f) => /(^|\/)build\//.test(f) && /(^|\/)((docker-)?compose[^/]*\.ya?ml|Dockerfile)$/i.test(f);
|
|
25837
27473
|
const report = (f) => /\.(html?|css|js|json|xml|info|lcov|png|svg|gif|txt|gz)$/i.test(f);
|
|
25838
|
-
const
|
|
25839
|
-
const skipped = (f) => VENDORED.test(f) || !deployment(f) && f.split("/").slice(0, -1).some((seg, i, segs) => SKIPPED.has(seg) && !
|
|
27474
|
+
const kept2 = (seg, f, at) => seg === "build" && (listing.git || builds.has(at)) || seg === "coverage" && !!listing.git && !report(f);
|
|
27475
|
+
const skipped = (f) => VENDORED.test(f) || !deployment(f) && f.split("/").slice(0, -1).some((seg, i, segs) => SKIPPED.has(seg) && !kept2(seg, f, segs.slice(0, i + 1).join("/")));
|
|
25840
27476
|
const frameworks = listing.files.map((f) => /^(.+\/)(?:source\/core\/ut_utils\.pks|pgtap\.control)$/i.exec(f)?.[1]).filter((d) => !!d);
|
|
25841
27477
|
this.list = listing.files.filter((f) => !skipped(f) && !frameworks.some((d) => f.startsWith(d))).sort();
|
|
25842
27478
|
this.set = new Set(this.list);
|
|
@@ -28877,7 +30513,7 @@ function htmlToMarkdown(html) {
|
|
|
28877
30513
|
`;
|
|
28878
30514
|
}
|
|
28879
30515
|
async function pdfText(bytes) {
|
|
28880
|
-
const { extractText, getDocumentProxy } = await import("./dist-
|
|
30516
|
+
const { extractText, getDocumentProxy } = await import("./dist-4NNGZXOU.js");
|
|
28881
30517
|
let timer2;
|
|
28882
30518
|
const late = new Promise((_, fail3) => {
|
|
28883
30519
|
timer2 = setTimeout(() => fail3(new Error(`not read within ${PDF_TIMEOUT / 1e3} s`)), PDF_TIMEOUT);
|
|
@@ -33029,8 +34665,8 @@ function conventionPlugins(files) {
|
|
|
33029
34665
|
const source = files.list.find((f) => f.startsWith(within2) && name.test(f));
|
|
33030
34666
|
if (!source) continue;
|
|
33031
34667
|
const code = files.read(source);
|
|
33032
|
-
const
|
|
33033
|
-
if (
|
|
34668
|
+
const added2 = [...code.matchAll(/project\(\s*["']:?([\w:.-]+)["']\s*\)/g)].map((p) => ({ project: p[1], file: source, line: lineAt2(code, p.index) }));
|
|
34669
|
+
if (added2.length) out.set(id[1] ?? `libs.plugins.${id[2]}`, added2);
|
|
33034
34670
|
}
|
|
33035
34671
|
}
|
|
33036
34672
|
return out;
|
|
@@ -33056,9 +34692,9 @@ function gradle(files) {
|
|
|
33056
34692
|
}
|
|
33057
34693
|
const plugins = /\bplugins\s*\{([\s\S]*?)\n\s*\}/.exec(text3);
|
|
33058
34694
|
for (const m of plugins ? plugins[1].matchAll(/\b(?:alias\(\s*(libs\.plugins\.[\w.]+)\s*\)|id\(\s*["']([\w.-]+)["']\s*\))/g) : []) {
|
|
33059
|
-
for (const
|
|
33060
|
-
const target = base +
|
|
33061
|
-
if (target !== path) d.refs.push({ name: `:${
|
|
34695
|
+
for (const added2 of conventions.get(m[1] ?? m[2]) ?? []) {
|
|
34696
|
+
const target = base + added2.project.replace(/:/g, "/");
|
|
34697
|
+
if (target !== path) d.refs.push({ name: `:${added2.project}`, path: target, line: added2.line, file: added2.file });
|
|
33062
34698
|
}
|
|
33063
34699
|
}
|
|
33064
34700
|
for (const m of text3.matchAll(/\b(?:implementation|api|compile|runtimeOnly)\s*\(?\s*['"]([\w.-]+):([\w.-]+)(?::[^'"]*)?['"]/g)) {
|
|
@@ -33358,10 +34994,10 @@ function sqlFolders(files, claimed) {
|
|
|
33358
34994
|
return dir === "." ? "." : /^(db|database|databases|sql|schemas?|scripts)$/i.test(segs[0]) && segs.length > 1 ? segs.slice(0, 2).join("/") : segs[0];
|
|
33359
34995
|
};
|
|
33360
34996
|
const dirs = [...new Set(scripts.map((f) => top(dirOf(f))))].sort((a, b) => a.length - b.length);
|
|
33361
|
-
const
|
|
33362
|
-
for (const d of dirs) if (!
|
|
34997
|
+
const kept2 = [];
|
|
34998
|
+
for (const d of dirs) if (!kept2.some((k) => k === "." || d.startsWith(`${k}/`))) kept2.push(d);
|
|
33363
34999
|
const under = (dir) => scripts.filter((f) => dir === "." || f.startsWith(`${dir}/`));
|
|
33364
|
-
return [...projects, ...
|
|
35000
|
+
return [...projects, ...kept2.map((path) => {
|
|
33365
35001
|
const d = draft("sql", path, under(path)[0], void 0, 1);
|
|
33366
35002
|
d.aliases.push(basename4(path === "." ? files.root : path));
|
|
33367
35003
|
return d;
|
|
@@ -34167,7 +35803,7 @@ function readCode(files, repo, units) {
|
|
|
34167
35803
|
const accessNamed = /* @__PURE__ */ new Map();
|
|
34168
35804
|
const accessUsers = /* @__PURE__ */ new Set();
|
|
34169
35805
|
const valuesByUnit = /* @__PURE__ */ new Map();
|
|
34170
|
-
const
|
|
35806
|
+
const valuesOf2 = (unit) => {
|
|
34171
35807
|
const known = valuesByUnit.get(unit.id);
|
|
34172
35808
|
if (known) return known;
|
|
34173
35809
|
const mine = files.list.filter((f) => owner(units, f)?.id === unit.id);
|
|
@@ -34197,7 +35833,7 @@ function readCode(files, repo, units) {
|
|
|
34197
35833
|
let text3 = configures.has(file) ? settingsFor(files, file, unit) : files.read(file);
|
|
34198
35834
|
if (!text3) continue;
|
|
34199
35835
|
const vb = VB_CODE.test(file);
|
|
34200
|
-
if (vb) text3 = inlineValues(joinContinuations(withoutVbComments(text3)),
|
|
35836
|
+
if (vb) text3 = inlineValues(joinContinuations(withoutVbComments(text3)), valuesOf2(unit));
|
|
34201
35837
|
if (config && /\.(ya?ml|properties|env|toml|conf|ini)$|(^|\/)\.env(\.[\w-]+)?$/i.test(file)) text3 = text3.replace(/^[ \t]*#.*$/gm, "").replace(/\.ini$/i.test(file) ? /^[ \t]*;.*$/gm : /$^/, "");
|
|
34202
35838
|
const unresolved = text3;
|
|
34203
35839
|
text3 = text3.replace(/\$\{([\w.-]+):([^${}\n]*)\}/g, (_, key, value) => value.startsWith("?") ? `\${${key}}` : value.replace(/^-/, ""));
|
|
@@ -34262,7 +35898,7 @@ function readCode(files, repo, units) {
|
|
|
34262
35898
|
accessNamed.set(unit.id, [...accessNamed.get(unit.id) ?? [], { name: m[2], evidence: at(m.index) }]);
|
|
34263
35899
|
}
|
|
34264
35900
|
if (/\.(frm|dob|pag|ctl)$/i.test(file)) formAddress(text3, file, unit, repo, out, once);
|
|
34265
|
-
const values =
|
|
35901
|
+
const values = valuesOf2(unit);
|
|
34266
35902
|
const hostOf = (expr) => (values.resolve(expr) ?? /^"([^"]+)"$/.exec(expr.trim())?.[1] ?? expr.trim()).toLowerCase();
|
|
34267
35903
|
const remoteHost = /\.RemoteHost\s*=\s*([^\n]+)/i.exec(text3)?.[1];
|
|
34268
35904
|
const connects = [
|
|
@@ -34460,9 +36096,9 @@ function blueprint(body, at, text3, t) {
|
|
|
34460
36096
|
for (const m of body.matchAll(/\$\w+->(\w+)\(\s*(?:'([^']+)'|"([^"]+)"|\[([^\]]*)\])?([^;]*);/g)) {
|
|
34461
36097
|
const [method, name, list, rest] = [m[1], m[2] ?? m[3], m[4], m[5]];
|
|
34462
36098
|
const line = lineAt2(text3, at + m.index);
|
|
34463
|
-
const
|
|
36099
|
+
const has2 = (column) => t.columns.some((c) => c.name === column);
|
|
34464
36100
|
const add = (column, type2) => {
|
|
34465
|
-
if (!
|
|
36101
|
+
if (!has2(column)) t.columns.push({ name: column, ...type2 ? { type: type2 } : {}, .../->nullable\(/.test(rest) ? {} : { notNull: true }, line });
|
|
34466
36102
|
};
|
|
34467
36103
|
if (method === "dropColumn" || method === "dropColumns") {
|
|
34468
36104
|
const gone = name ? [name] : [...(list ?? "").matchAll(/'([^']+)'|"([^"]+)"/g)].map((x) => x[1] ?? x[2]);
|
|
@@ -36624,17 +38260,17 @@ function linkRepositories(repositories) {
|
|
|
36624
38260
|
}
|
|
36625
38261
|
for (const r of repositories) {
|
|
36626
38262
|
const deps = r.dependencies.filter((d) => !d.target);
|
|
36627
|
-
const
|
|
38263
|
+
const has2 = (u, re) => deps.some((d) => d.unit === u.id && re.test(d.package));
|
|
36628
38264
|
for (const c of CONVENTIONS) {
|
|
36629
38265
|
const servers = [
|
|
36630
|
-
...r.units.filter((u) => c.server &&
|
|
38266
|
+
...r.units.filter((u) => c.server && has2(u, c.server)).map((u) => u.id),
|
|
36631
38267
|
...c.image ? services.filter((s) => repoOf(s.id) === r.repository && c.image.test(`${s.image ?? ""} ${s.name}`) && !s.unit).map((s) => s.id) : [],
|
|
36632
38268
|
...c.image ? r.units.filter((u) => u.stack === "docker" && c.image.test(u.name)).map((u) => u.id) : []
|
|
36633
38269
|
];
|
|
36634
38270
|
const named = [...new Set(servers)].filter((id) => /^(kafka|rabbitmq|rabbit|nats|eureka|config)(-?server)?$/i.test(services.find((x) => x.id === id)?.name ?? r.units.find((u) => u.id === id)?.name ?? ""));
|
|
36635
38271
|
if (new Set(servers).size !== 1 && named.length !== 1) continue;
|
|
36636
38272
|
if (new Set(servers).size !== 1) servers.splice(0, servers.length, named[0]);
|
|
36637
|
-
for (const u of r.units.filter((x) => x.kind === "app" && x.id !== servers[0] && !(c.server &&
|
|
38273
|
+
for (const u of r.units.filter((x) => x.kind === "app" && x.id !== servers[0] && !(c.server && has2(x, c.server)))) {
|
|
36638
38274
|
const dep = deps.find((d) => d.unit === u.id && c.client.test(d.package));
|
|
36639
38275
|
if (!dep || [...links.values()].some((l) => l.from === u.id && l.to === servers[0])) continue;
|
|
36640
38276
|
add("address", u.id, servers[0], "inferred", [dep.id, servers[0]], `${c.name} client (${dep.package}): the repository's only ${c.name}`);
|
|
@@ -38882,6 +40518,18 @@ function unitOfWritten(run, w) {
|
|
|
38882
40518
|
}
|
|
38883
40519
|
var keyOf = (p) => p.kind === "requirement" ? p.requirement.key : p.kind === "need" ? p.need.key : p.decision.key;
|
|
38884
40520
|
var labelOf = (p) => p.kind === "requirement" ? p.requirement.label : p.kind === "need" ? p.need.label : p.decision.label;
|
|
40521
|
+
function planStage(plan) {
|
|
40522
|
+
const p = plan && typeof plan === "object" ? plan : {};
|
|
40523
|
+
const has2 = (key) => Array.isArray(p[key]) && p[key].length > 0;
|
|
40524
|
+
if (has2("requirements")) return "scenarios";
|
|
40525
|
+
if (has2("stateMachines")) return "states";
|
|
40526
|
+
if (has2("processes")) return "processes";
|
|
40527
|
+
if (has2("entities") || Array.isArray(p.elements) && p.elements.some((e) => e?.type === "domain")) return "domain";
|
|
40528
|
+
if (has2("needs") || has2("decisions")) return "documents";
|
|
40529
|
+
if (has2("mockups")) return "explore";
|
|
40530
|
+
return "c4";
|
|
40531
|
+
}
|
|
40532
|
+
var GOES_ON = /* @__PURE__ */ new Set(["assay_add_sources", "assay_explore", "assay_explore_act", "assay_apply", "assay_answer"]);
|
|
38885
40533
|
var PLAYWRIGHT_CONFIG = `// Written by Radical Assay beside the tests of the paths it explored.
|
|
38886
40534
|
// Run: npx playwright test -c e2e/assay (E2E_BASE_URL: where the application runs).
|
|
38887
40535
|
import { defineConfig } from '@playwright/test'
|
|
@@ -38901,6 +40549,32 @@ async function attempt(tool, args, ctx, facade) {
|
|
|
38901
40549
|
const said = facade.refusals !== before ? facade.lastError : null;
|
|
38902
40550
|
return result.ok ? said : said ?? result.resultText;
|
|
38903
40551
|
}
|
|
40552
|
+
function newProgress() {
|
|
40553
|
+
return {
|
|
40554
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
40555
|
+
state: "active",
|
|
40556
|
+
stages: ASSAY_STAGES.map((s, i) => ({ id: s.id, status: i === 0 ? "working" : "pending" })),
|
|
40557
|
+
proposalStage: /* @__PURE__ */ new Map()
|
|
40558
|
+
};
|
|
40559
|
+
}
|
|
40560
|
+
function reach(progress, stage) {
|
|
40561
|
+
const { stages } = progress;
|
|
40562
|
+
const working = stages.findIndex((s) => s.status === "working");
|
|
40563
|
+
const at = working >= 0 ? working : stages.map((s) => s.status !== "pending").lastIndexOf(true);
|
|
40564
|
+
const to = stages.findIndex((s) => s.id === stage);
|
|
40565
|
+
if (to <= at) return;
|
|
40566
|
+
for (const s of stages.slice(0, to)) if (s.status === "working" || s.status === "pending") s.status = s.plans ? "done" : "skipped";
|
|
40567
|
+
stages[to].status = "working";
|
|
40568
|
+
}
|
|
40569
|
+
function finish(progress) {
|
|
40570
|
+
progress.state = "finished";
|
|
40571
|
+
for (const s of progress.stages) if (s.status === "working" || s.status === "pending") s.status = s.plans ? "done" : "skipped";
|
|
40572
|
+
}
|
|
40573
|
+
function added(info, written) {
|
|
40574
|
+
if (!written.length) return;
|
|
40575
|
+
const relations = written.filter((w) => w.kind === "relation").length;
|
|
40576
|
+
info.added = { nodes: (info.added?.nodes ?? 0) + written.length - relations, relations: (info.added?.relations ?? 0) + relations };
|
|
40577
|
+
}
|
|
38904
40578
|
var Assay = class _Assay {
|
|
38905
40579
|
/** `folder`: the bound model folder; `root`: its repository's root. */
|
|
38906
40580
|
constructor(folder, root2) {
|
|
@@ -38911,6 +40585,79 @@ var Assay = class _Assay {
|
|
|
38911
40585
|
this.unrealised = [];
|
|
38912
40586
|
}
|
|
38913
40587
|
async call(name, input, ctx, facade) {
|
|
40588
|
+
const result = await this.callTool(name, input, ctx, facade);
|
|
40589
|
+
const run = this.run;
|
|
40590
|
+
if (!run || name === "assay_start") return result;
|
|
40591
|
+
return this.track(run, name, input, result);
|
|
40592
|
+
}
|
|
40593
|
+
/** Where the run stands after a call: the stage it reached, a plan written or refused, a proposal answered, the run
|
|
40594
|
+
* finished. What a call writes counts once it is on disk (its commit); a refusal counts at once. */
|
|
40595
|
+
track(run, name, input, result) {
|
|
40596
|
+
const progress = run.progress;
|
|
40597
|
+
if (GOES_ON.has(name) && progress.state === "finished") progress.state = "active";
|
|
40598
|
+
if (name === "assay_explore" || name === "assay_explore_act") reach(progress, "explore");
|
|
40599
|
+
if (name === "assay_finish") finish(progress);
|
|
40600
|
+
if (name === "assay_apply") {
|
|
40601
|
+
const stage = planStage(input?.plan);
|
|
40602
|
+
reach(progress, stage);
|
|
40603
|
+
const info = progress.stages.find((s) => s.id === stage);
|
|
40604
|
+
if (!result.ok) {
|
|
40605
|
+
info.refused = (info.refused ?? 0) + 1;
|
|
40606
|
+
return result;
|
|
40607
|
+
}
|
|
40608
|
+
const commit = result.commit;
|
|
40609
|
+
return {
|
|
40610
|
+
...result,
|
|
40611
|
+
commit: () => {
|
|
40612
|
+
const written = run.written.length;
|
|
40613
|
+
const proposals = run.proposals.length;
|
|
40614
|
+
commit?.();
|
|
40615
|
+
info.plans = (info.plans ?? 0) + 1;
|
|
40616
|
+
if (info.status === "skipped") info.status = "done";
|
|
40617
|
+
added(info, run.written.slice(written));
|
|
40618
|
+
for (const p of run.proposals.slice(proposals)) progress.proposalStage.set(p.id, stage);
|
|
40619
|
+
}
|
|
40620
|
+
};
|
|
40621
|
+
}
|
|
40622
|
+
if (name === "assay_answer" && result.ok) {
|
|
40623
|
+
const id = input?.proposal;
|
|
40624
|
+
const stage = (typeof id === "string" ? progress.proposalStage.get(id) : void 0) ?? "scenarios";
|
|
40625
|
+
const commit = result.commit;
|
|
40626
|
+
return {
|
|
40627
|
+
...result,
|
|
40628
|
+
commit: () => {
|
|
40629
|
+
const written = run.written.length;
|
|
40630
|
+
commit?.();
|
|
40631
|
+
added(progress.stages.find((s) => s.id === stage), run.written.slice(written));
|
|
40632
|
+
}
|
|
40633
|
+
};
|
|
40634
|
+
}
|
|
40635
|
+
return result;
|
|
40636
|
+
}
|
|
40637
|
+
/** Where the run stands, for Studio (see assayRunStatus); null without a run. `closing`: the server shuts down, so an
|
|
40638
|
+
* unfinished run is closed. */
|
|
40639
|
+
status(closing = false) {
|
|
40640
|
+
const run = this.run;
|
|
40641
|
+
if (!run) return null;
|
|
40642
|
+
const { progress } = run;
|
|
40643
|
+
return {
|
|
40644
|
+
repositories: run.repositories.map((r) => ({
|
|
40645
|
+
name: r.repository,
|
|
40646
|
+
units: r.units.length,
|
|
40647
|
+
facts: FACT_LISTS.reduce((n, list) => n + (r[list]?.length ?? 0), 0)
|
|
40648
|
+
})),
|
|
40649
|
+
sources: run.sources.length,
|
|
40650
|
+
startedAt: progress.startedAt,
|
|
40651
|
+
state: closing && progress.state === "active" ? "closed" : progress.state,
|
|
40652
|
+
stages: progress.stages.map((s) => ({ ...s, ...s.added ? { added: { ...s.added } } : {} })),
|
|
40653
|
+
proposals: {
|
|
40654
|
+
waiting: run.proposals.filter((p) => p.status === "waiting").length,
|
|
40655
|
+
accepted: run.proposals.filter((p) => p.status === "accepted").length,
|
|
40656
|
+
rejected: run.proposals.filter((p) => p.status === "rejected").length
|
|
40657
|
+
}
|
|
40658
|
+
};
|
|
40659
|
+
}
|
|
40660
|
+
async callTool(name, input, ctx, facade) {
|
|
38914
40661
|
if (name === "assay_start") return this.start(input);
|
|
38915
40662
|
if (name === "assay_procedure") return ok2(ASSAY_PROCEDURE, { readOnly: true });
|
|
38916
40663
|
const run = this.run;
|
|
@@ -38994,7 +40741,7 @@ var Assay = class _Assay {
|
|
|
38994
40741
|
}
|
|
38995
40742
|
const links = linkRepositories(repositories);
|
|
38996
40743
|
const taken = await takeSources(sources ?? [], root2, new Set(repositories.map((r) => r.repository)), SOURCE_OPTIONS);
|
|
38997
|
-
this.run = { root: root2, modelPath: posix2(relative6(root2, this.folder)) || ".", repositories, sources: taken.sources, links, facts: factIndex([...repositories, ...taken.sources], links), written: [], proposals: [], mockupOf: /* @__PURE__ */ new Map(), navigated: /* @__PURE__ */ new Set(), testsWritten: [], skeletons: [] };
|
|
40744
|
+
this.run = { root: root2, modelPath: posix2(relative6(root2, this.folder)) || ".", repositories, sources: taken.sources, links, facts: factIndex([...repositories, ...taken.sources], links), written: [], proposals: [], mockupOf: /* @__PURE__ */ new Map(), navigated: /* @__PURE__ */ new Set(), testsWritten: [], skeletons: [], progress: newProgress() };
|
|
38998
40745
|
const lines = [
|
|
38999
40746
|
`Assay run on ${repositories.length} repositor${repositories.length === 1 ? "y" : "ies"}${taken.sources.length ? ` and ${taken.sources.length} source${taken.sources.length === 1 ? "" : "s"} of documents` : ""}; the central model is ${this.run.modelPath} in ${root2}.`,
|
|
39000
40747
|
...found.empty.length ? [`Nothing in: ${found.empty.join(", ")}.`] : [],
|
|
@@ -39006,9 +40753,9 @@ var Assay = class _Assay {
|
|
|
39006
40753
|
...taken.sources.length ? ["", "Sources:", ...describeSources(taken.sources, root2)] : []
|
|
39007
40754
|
];
|
|
39008
40755
|
const text3 = lines.join("\n");
|
|
39009
|
-
const
|
|
40756
|
+
const cut2 = text3.length > START_MAX ? `${text3.slice(0, text3.lastIndexOf("\n", START_MAX))}
|
|
39010
40757
|
\u2026 (the rest: assay_facts per repository)` : text3;
|
|
39011
|
-
return ok2(`${
|
|
40758
|
+
return ok2(`${cut2}
|
|
39012
40759
|
|
|
39013
40760
|
Next: assay_procedure gives the steps, stage by stage.`, { readOnly: true });
|
|
39014
40761
|
}
|
|
@@ -39793,13 +41540,13 @@ Files not written: ${error.message}. The model has what the call wrote.`;
|
|
|
39793
41540
|
const at = repository.implements.findIndex((m) => m.element === element);
|
|
39794
41541
|
const next = { element, name: nodes[element]?.label, paths: at < 0 ? paths : [.../* @__PURE__ */ new Set([...repository.implements[at].paths, ...paths])] };
|
|
39795
41542
|
if (at < 0) repository.implements.push(next);
|
|
39796
|
-
else repository.implements[at] = next;
|
|
41543
|
+
else repository.implements[at] = { ...repository.implements[at], ...next };
|
|
39797
41544
|
}
|
|
39798
41545
|
for (const [element, tests] of changes.verifies) {
|
|
39799
41546
|
const at = repository.verifies.findIndex((v) => v.element === element);
|
|
39800
41547
|
const next = { element, name: nodes[element]?.label, tests: at < 0 ? tests : [.../* @__PURE__ */ new Set([...repository.verifies[at].tests, ...tests])] };
|
|
39801
41548
|
if (at < 0) repository.verifies.push(next);
|
|
39802
|
-
else repository.verifies[at] = next;
|
|
41549
|
+
else repository.verifies[at] = { ...repository.verifies[at], ...next };
|
|
39803
41550
|
}
|
|
39804
41551
|
if (dir !== run.root) repository.model = { ...repository.model, repo: centralAddress(run.root) ?? (posix2(relative6(dir, run.root)) || ".") };
|
|
39805
41552
|
await mkdir4(dirname8(file), { recursive: true });
|
|
@@ -39866,12 +41613,18 @@ Files: ${notes.join("; ")}.` : "";
|
|
|
39866
41613
|
|
|
39867
41614
|
// src/folderModel.ts
|
|
39868
41615
|
var EXCLUDED_TOOLS = /* @__PURE__ */ new Set(["set_active_view", "focus_node", "reset_diagram"]);
|
|
39869
|
-
var READ_ONLY2 = /* @__PURE__ */ new Set(["get_model_summary", "get_selection", "get_issues", "get_changes", "get_implementation", "get_verification", "search_model", "list_milestones", "compare_milestones"]);
|
|
41616
|
+
var READ_ONLY2 = /* @__PURE__ */ new Set(["get_model_summary", "get_selection", "get_issues", "get_changes", "review_requirements", "get_implementation", "get_verification", "get_trace", "search_model", "list_milestones", "compare_milestones"]);
|
|
39870
41617
|
var SERVER_TOOL_DEFS = [
|
|
39871
41618
|
{
|
|
39872
41619
|
name: "get_model_summary",
|
|
39873
|
-
description: "Call this first. Shows the product version of this radical-mcp server (radicalVersion) and the model folder format it reads and writes (modelFormat), counts, the views, sequences, milestones and presentations in the bound Radical model folder, the modelling rules (how to build requirements, needs, state machines, \u2026), plus the metamodel context message: each type
|
|
39874
|
-
inputSchema: {
|
|
41620
|
+
description: "Call this first. Shows the product version of this radical-mcp server (radicalVersion) and the model folder format it reads and writes (modelFormat), counts, the views, sequences, milestones and presentations in the bound Radical model folder, the modelling rules (how to build requirements, needs, state machines, \u2026), plus the metamodel in brief (the metamodel context message the other tools refer to): each node type in one line with where it may go and its properties keys (enum options when short, \u2192 the type a reference points at), each relation type with its allowed pairs, the viewpoints by name. With types, it returns only the whole definition of those node types, relation types and viewpoints: labels, every enum option, visibility, cardinality, layout, a viewpoint's chain.",
|
|
41621
|
+
inputSchema: {
|
|
41622
|
+
type: "object",
|
|
41623
|
+
properties: {
|
|
41624
|
+
types: { type: "array", items: { type: "string" }, description: "Node type, relation type or viewpoint ids (or names) to get in full instead of the summary." }
|
|
41625
|
+
},
|
|
41626
|
+
additionalProperties: false
|
|
41627
|
+
}
|
|
39875
41628
|
},
|
|
39876
41629
|
{
|
|
39877
41630
|
name: "get_issues",
|
|
@@ -39901,6 +41654,18 @@ var SERVER_TOOL_DEFS = [
|
|
|
39901
41654
|
additionalProperties: false
|
|
39902
41655
|
}
|
|
39903
41656
|
},
|
|
41657
|
+
{
|
|
41658
|
+
name: "review_requirements",
|
|
41659
|
+
description: "Check requirements against the words of the needs they derive from (ADR Agents check requirements against the person's words). Lists each requirement added or changed since the model's version in git (a derives relation of it added, removed or quoting other words too), and each one a need changed since then leads to, with its sentence next to the whole text of every need it derives from, directly or through other requirements; names those that derive from no need, and the needs that hold no question asked of a person. Call it after you change requirements and before you write their code; confirm each, or correct it with update_node where it adds, drops or changes a value, a number, a range, a state or who may do what, and where the need does not settle a point, ask the person and add the question and answer to the need word for word. It writes nothing.",
|
|
41660
|
+
inputSchema: {
|
|
41661
|
+
type: "object",
|
|
41662
|
+
properties: {
|
|
41663
|
+
ids: { type: "array", items: { type: "string" }, description: "Review these requirements (ids or tempIds) instead of those changed on the branch." },
|
|
41664
|
+
since: { type: "string", description: "As in get_changes: the git branch, tag or commit to compare with. Default: where the branch left the default branch." }
|
|
41665
|
+
},
|
|
41666
|
+
additionalProperties: false
|
|
41667
|
+
}
|
|
41668
|
+
},
|
|
39904
41669
|
{
|
|
39905
41670
|
name: "get_implementation",
|
|
39906
41671
|
description: "Where the repository builds the model's elements, from its .radical/radical.json (folders from the repository's root). With id: the element's folders, its own or those of its nearest ancestor with an entry, named. Without: every entry, and the C4 elements of this model (systems, containers, components, databases, web apps, queues; not external ones) built nowhere the file says. Call it to find the code of an element before you change it, and before you map the repository with set_implementation.",
|
|
@@ -39912,7 +41677,7 @@ var SERVER_TOOL_DEFS = [
|
|
|
39912
41677
|
},
|
|
39913
41678
|
{
|
|
39914
41679
|
name: "set_implementation",
|
|
39915
|
-
description: "Says where the repository builds an element of the model, in its .radical/radical.json, which the repository's sensors, radical check and Studio's element card read: paths, folders from the repository's root, replace its entry; remove: true takes the entry out. Map the containers, and the components that have folders of their own: one without an entry is built where its parent is. Look at the repository's folders first; radical check warns about an entry that drifts from the model or the repository. It changes no model file.",
|
|
41680
|
+
description: "Says where the repository builds an element of the model, in its .radical/radical.json, which the repository's sensors, radical check and Studio's element card read: paths, folders from the repository's root, replace its entry; remove: true takes the entry out, also one whose element the model no longer has (delete_node takes out the entries of what it deletes). Map the containers, and the components that have folders of their own: one without an entry is built where its parent is. Look at the repository's folders first; radical check warns about an entry that drifts from the model or the repository. It changes no model file.",
|
|
39916
41681
|
inputSchema: {
|
|
39917
41682
|
type: "object",
|
|
39918
41683
|
properties: {
|
|
@@ -39933,14 +41698,25 @@ var SERVER_TOOL_DEFS = [
|
|
|
39933
41698
|
additionalProperties: false
|
|
39934
41699
|
}
|
|
39935
41700
|
},
|
|
41701
|
+
{
|
|
41702
|
+
name: "get_trace",
|
|
41703
|
+
description: "The verification path of one element (a need, requirement, scenario, ADR or fitness function), as the Inspector's Verification path panel draws it: every path through it from its need or ADR down to the tests and metric conditions that check it, failing branches first, each element with its status and each test with its outcome and, when it failed, the message the test report holds; a fitness function measured for each element its ADR constrains lists each such element. It reads the test results and measurements the last radical check kept beside the model (.state/), and says how old they are. Call it to find why a requirement or ADR is not verified, or what a failing test takes down. It changes nothing.",
|
|
41704
|
+
inputSchema: {
|
|
41705
|
+
type: "object",
|
|
41706
|
+
properties: { id: { type: "string", description: "The element (an id or a tempId)." } },
|
|
41707
|
+
required: ["id"],
|
|
41708
|
+
additionalProperties: false
|
|
41709
|
+
}
|
|
41710
|
+
},
|
|
39936
41711
|
{
|
|
39937
41712
|
name: "set_verification",
|
|
39938
|
-
description: `Binds tests of the repository to a scenario or fitness function of the model, in its .radical/radical.json, which radical check, the Inspector and Studio read: it passes when every test bound to it passed and its metric conditions hold. tests (ids as "<file> \u203A <describe> \u203A <title>", or "<file>" for every test in it, from the repository's root)
|
|
41713
|
+
description: `Binds tests of the repository to a scenario or fitness function of the model, in its .radical/radical.json, which radical check, the Inspector and Studio read: it passes when every test bound to it passed and its metric conditions hold. tests (ids as "<file> \u203A <describe> \u203A <title>" (Vitest's "<file> > <describe> > <title>" is kept with \u203A), or "<file>" for every test in it, from the repository's root) are bound beside those it has, as radical verify --test does; drop unbinds tests (with tests, it replaces one test by another); remove: true takes the entry out, also one whose element the model no longer has. Call it for each test you write for a scenario. It changes no model file.`,
|
|
39939
41714
|
inputSchema: {
|
|
39940
41715
|
type: "object",
|
|
39941
41716
|
properties: {
|
|
39942
41717
|
id: { type: "string", description: "The scenario or fitness function (an id or a tempId)." },
|
|
39943
|
-
tests: { type: "array", items: { type: "string" }, description: "
|
|
41718
|
+
tests: { type: "array", items: { type: "string" }, description: "Tests that check it, bound beside those it has." },
|
|
41719
|
+
drop: { type: "array", items: { type: "string" }, description: "Tests to unbind." },
|
|
39944
41720
|
remove: { type: "boolean", description: "Take its entry out instead." }
|
|
39945
41721
|
},
|
|
39946
41722
|
required: ["id"],
|
|
@@ -40045,6 +41821,10 @@ function settleGeometry(before, after) {
|
|
|
40045
41821
|
after.defaultPositions[node.id] = { x: node.x, y: node.y, width: node.width, height: node.height };
|
|
40046
41822
|
}
|
|
40047
41823
|
}
|
|
41824
|
+
function freshLayoutNote(arranged, notLaidOut) {
|
|
41825
|
+
const done = arranged.length ? ` Smart Layout arranged ${arranged.length === 1 ? `the new view ${arranged[0].name}` : `the ${arranged.length} new views per element`}.` : "";
|
|
41826
|
+
return done + notLaidOut.map((why) => ` Not laid out: ${why}`).join("");
|
|
41827
|
+
}
|
|
40048
41828
|
var foldedOn = (view, node) => isContainerType(node.type) && (node.collapsed && !view.expandedNodeIds?.includes(node.id) || !!view.collapsedNodeIds?.includes(node.id));
|
|
40049
41829
|
function settleViewFolds(before, after) {
|
|
40050
41830
|
const old = byId3(before.nodes);
|
|
@@ -40180,6 +41960,16 @@ var FolderModel = class _FolderModel {
|
|
|
40180
41960
|
} catch {
|
|
40181
41961
|
}
|
|
40182
41962
|
}
|
|
41963
|
+
/** Writes where the agent's Assay run stands for Studio to show (ADR Agent
|
|
41964
|
+
* Assay runs show in Studio). A failed write never fails the call. */
|
|
41965
|
+
async writeAssayStatus(closing = false) {
|
|
41966
|
+
const status = this.assay.status(closing);
|
|
41967
|
+
if (!status) return;
|
|
41968
|
+
try {
|
|
41969
|
+
await writeAssayRunFile(this.folder, serializeAssayRun({ ...status, ...this.clientName() ? { client: this.clientName() } : {} }));
|
|
41970
|
+
} catch {
|
|
41971
|
+
}
|
|
41972
|
+
}
|
|
40183
41973
|
/** Saves `content` (the model before a Forge run) as the folder's base
|
|
40184
41974
|
* unless git saved one; a line for the answer when it did. A failed write
|
|
40185
41975
|
* never fails the call. */
|
|
@@ -40198,6 +41988,7 @@ var FolderModel = class _FolderModel {
|
|
|
40198
41988
|
await this.idle();
|
|
40199
41989
|
const status = this.forge.status();
|
|
40200
41990
|
if (status?.state === "active") await this.writeForgeStatus(true);
|
|
41991
|
+
if (this.assay.status()?.state === "active") await this.writeAssayStatus(true);
|
|
40201
41992
|
}
|
|
40202
41993
|
/** Resolves once every queued call has finished. */
|
|
40203
41994
|
idle() {
|
|
@@ -40240,13 +42031,40 @@ var FolderModel = class _FolderModel {
|
|
|
40240
42031
|
}
|
|
40241
42032
|
/** The canvas selection Studio wrote into the folder, resolved against
|
|
40242
42033
|
* the model as it is now. */
|
|
42034
|
+
/** get_trace: every verification path through one element, from the
|
|
42035
|
+
* test results and measurements kept beside the model. */
|
|
42036
|
+
async trace(input, data) {
|
|
42037
|
+
const { id } = input ?? {};
|
|
42038
|
+
if (typeof id !== "string" || !id.trim()) return { ok: false, text: "get_trace: id must be an element's id" };
|
|
42039
|
+
const nodeId = this.tempIds.get(id) ?? id;
|
|
42040
|
+
if (!data.nodes.some((n) => n.id === nodeId)) return { ok: false, text: `get_trace: no element ${id} in the model` };
|
|
42041
|
+
let verifies = [];
|
|
42042
|
+
try {
|
|
42043
|
+
const text3 = await readFile6((await repositoryFileOf(this.folder)).file, "utf8").catch((error) => {
|
|
42044
|
+
if (error.code === "ENOENT") return null;
|
|
42045
|
+
throw error;
|
|
42046
|
+
});
|
|
42047
|
+
if (text3 !== null) verifies = parseRepositoryFile(text3).verifies;
|
|
42048
|
+
} catch (error) {
|
|
42049
|
+
return { ok: false, text: `get_trace: ${error.message}` };
|
|
42050
|
+
}
|
|
42051
|
+
const results = parseTestResults(await readEditorStateFile(this.folder, TEST_RESULTS_FILE) ?? "");
|
|
42052
|
+
const measurementsText = await readEditorStateFile(this.folder, MEASUREMENTS_FILE);
|
|
42053
|
+
const measurements = measurementsText ? parseMeasurementStore(measurementsText) : void 0;
|
|
42054
|
+
const nodes = Object.fromEntries(withBoundTests(data.nodes, verifies).map((n) => [n.id, n]));
|
|
42055
|
+
const relations = Object.fromEntries(data.relations.map((r) => [r.id, r]));
|
|
42056
|
+
const evidence = results || measurements ? computeEvidence({ nodes, relations, metamodel: documentMetamodel(data.metamodel, data.nodes), ...results ? { tests: results.cases } : {}, ...measurements ? { measurements } : {} }) : null;
|
|
42057
|
+
const head = results ? `Test results read ${formatAge(Math.max(0, Date.now() - Date.parse(testsRanAt(results))))} ago (${results.cases.length} test cases)${measurements ? `, ${measurements.length} measurements` : ""}.` : "No test results beside the model: run radical check <folder> --report <reports> (or --from-ci) for the outcomes.";
|
|
42058
|
+
return { ok: true, text: `${head}
|
|
42059
|
+
${formatTrace(traceOf({ nodes, relations, evidence, cases: results?.cases }, nodeId), nodes)}` };
|
|
42060
|
+
}
|
|
40243
42061
|
/** get_verification and set_verification: the tests the repository's
|
|
40244
42062
|
* .radical/radical.json binds (ADR Tests are bound outside the model). */
|
|
40245
42063
|
async verification(name, input, data) {
|
|
40246
|
-
const { id, tests, remove: remove2 } = input ?? {};
|
|
42064
|
+
const { id, tests, drop, remove: remove2 } = input ?? {};
|
|
40247
42065
|
const nodes = new Map(data.nodes.map((n) => [n.id, n]));
|
|
40248
42066
|
const named = (n) => `${n.type} "${n.label}" (${n.id})`;
|
|
40249
|
-
const file =
|
|
42067
|
+
const { file } = await repositoryFileOf(this.folder);
|
|
40250
42068
|
let repository;
|
|
40251
42069
|
try {
|
|
40252
42070
|
repository = await readFile6(file, "utf8").then((text3) => parseRepositoryFile(text3), (error) => {
|
|
@@ -40258,6 +42076,7 @@ var FolderModel = class _FolderModel {
|
|
|
40258
42076
|
}
|
|
40259
42077
|
if (id !== void 0 && typeof id !== "string") return { ok: false, text: `${name}: id must be a scenario's or fitness function's id` };
|
|
40260
42078
|
const node = typeof id === "string" ? nodes.get(this.tempIds.get(id) ?? id) : void 0;
|
|
42079
|
+
if (name === "set_verification" && typeof id === "string" && !node && remove2 === true) return await this.removeOrphan(name, file, repository, repository.verifies, this.tempIds.get(id) ?? id);
|
|
40261
42080
|
if (id !== void 0 && !node) return { ok: false, text: `${name}: no element ${id} in the model` };
|
|
40262
42081
|
if (node && node.type !== "scenario" && node.type !== "fitness-fn") return { ok: false, text: `${name}: ${named(node)} is no scenario or fitness function; only those are checked by tests` };
|
|
40263
42082
|
if (name === "get_verification") {
|
|
@@ -40282,19 +42101,26 @@ ${bound.map((t) => `- ${t}`).join("\n")}` : `${REPOSITORY_FILE} binds no test to
|
|
|
40282
42101
|
if (!node) return { ok: false, text: "set_verification: id is required" };
|
|
40283
42102
|
const at = repository.verifies.findIndex((v) => v.element === node.id);
|
|
40284
42103
|
if (remove2 === true) {
|
|
42104
|
+
if (tests !== void 0 || drop !== void 0) return { ok: false, text: "set_verification: remove: true takes the whole entry out; give it without tests or drop" };
|
|
40285
42105
|
if (at < 0) return { ok: true, text: `${REPOSITORY_FILE} has no entry for ${named(node)}.` };
|
|
40286
42106
|
repository.verifies.splice(at, 1);
|
|
40287
42107
|
} else {
|
|
40288
|
-
|
|
40289
|
-
|
|
40290
|
-
|
|
40291
|
-
|
|
40292
|
-
|
|
40293
|
-
|
|
42108
|
+
const testIds = (v) => v === void 0 ? [] : Array.isArray(v) && v.length && v.every((t) => typeof t === "string" && t.trim()) ? v.map((t) => t.trim()) : null;
|
|
42109
|
+
const adds = testIds(tests);
|
|
42110
|
+
const drops = testIds(drop);
|
|
42111
|
+
if (!adds || !drops || !adds.length && !drops.length) {
|
|
42112
|
+
return { ok: false, text: 'set_verification: tests and drop must be lists of test ids ("<file> \u203A <title>"), one of them given, or remove: true alone' };
|
|
42113
|
+
}
|
|
42114
|
+
const entry = { element: node.id, name: node.label, tests: rebindTests(testsBoundTo(repository.verifies, node.id), adds, drops) };
|
|
42115
|
+
if (!entry.tests.length) {
|
|
42116
|
+
if (at >= 0) repository.verifies.splice(at, 1);
|
|
42117
|
+
} else if (at < 0) repository.verifies.push(entry);
|
|
42118
|
+
else repository.verifies[at] = { ...repository.verifies[at], ...entry };
|
|
40294
42119
|
}
|
|
40295
42120
|
await mkdir5(dirname9(file), { recursive: true });
|
|
40296
42121
|
await writeFile5(file, serializeRepositoryFile(repository));
|
|
40297
|
-
|
|
42122
|
+
const count2 = testsBoundTo(repository.verifies, node.id).length;
|
|
42123
|
+
return { ok: true, text: remove2 === true ? `Took ${named(node)} out of ${REPOSITORY_FILE}.` : `${named(node)} is checked by ${count2 ? `${count2} test(s)` : "no test"} (${REPOSITORY_FILE}).` };
|
|
40298
42124
|
}
|
|
40299
42125
|
/** get_implementation and set_implementation: the repository's
|
|
40300
42126
|
* .radical/radical.json (ADR The repository maps the model to its code). */
|
|
@@ -40303,8 +42129,7 @@ ${bound.map((t) => `- ${t}`).join("\n")}` : `${REPOSITORY_FILE} binds no test to
|
|
|
40303
42129
|
const nodes = new Map(data.nodes.map((n) => [n.id, n]));
|
|
40304
42130
|
const parentOf = (at2) => nodes.get(at2)?.parentId;
|
|
40305
42131
|
const named = (n) => `${n.type} "${n.label}" (${n.id})`;
|
|
40306
|
-
const root2 = await
|
|
40307
|
-
const file = join17(root2, REPOSITORY_FILE);
|
|
42132
|
+
const { file, root: root2 } = await repositoryFileOf(this.folder);
|
|
40308
42133
|
let repository;
|
|
40309
42134
|
try {
|
|
40310
42135
|
repository = await readFile6(file, "utf8").then((text3) => parseRepositoryFile(text3), (error) => {
|
|
@@ -40317,6 +42142,7 @@ ${bound.map((t) => `- ${t}`).join("\n")}` : `${REPOSITORY_FILE} binds no test to
|
|
|
40317
42142
|
const mapped = repository.implements;
|
|
40318
42143
|
if (id !== void 0 && typeof id !== "string") return { ok: false, text: `${name}: id must be an element's id` };
|
|
40319
42144
|
const node = typeof id === "string" ? nodes.get(this.tempIds.get(id) ?? id) : void 0;
|
|
42145
|
+
if (name === "set_implementation" && typeof id === "string" && !node && remove2 === true) return await this.removeOrphan(name, file, repository, mapped, this.tempIds.get(id) ?? id);
|
|
40320
42146
|
if (id !== void 0 && !node) return { ok: false, text: `${name}: no element ${id} in the model` };
|
|
40321
42147
|
if (name === "get_implementation") {
|
|
40322
42148
|
if (node) {
|
|
@@ -40346,12 +42172,42 @@ ${bound.map((t) => `- ${t}`).join("\n")}` : `${REPOSITORY_FILE} binds no test to
|
|
|
40346
42172
|
if (outside.length) return { ok: false, text: `set_implementation: ${outside.join(", ")} ${outside.length === 1 ? "is" : "are"} outside the repository` };
|
|
40347
42173
|
const entry = { element: node.id, name: node.label, paths: clean };
|
|
40348
42174
|
if (at < 0) mapped.push(entry);
|
|
40349
|
-
else mapped[at] = entry;
|
|
42175
|
+
else mapped[at] = { ...mapped[at], ...entry };
|
|
40350
42176
|
await mkdir5(dirname9(file), { recursive: true });
|
|
40351
42177
|
await writeFile5(file, serializeRepositoryFile(repository));
|
|
40352
42178
|
const missing = (await Promise.all(clean.map(async (p) => await stat4(join17(root2, p)).then(() => true, () => false) ? null : p))).filter((p) => p !== null);
|
|
40353
42179
|
return { ok: true, text: `${named(node)} is built in ${clean.join(", ")} (${REPOSITORY_FILE}).${missing.length ? ` Not in the repository yet: ${missing.join(", ")}; radical check warns until they are.` : ""}` };
|
|
40354
42180
|
}
|
|
42181
|
+
/** set_implementation and set_verification with remove: true on an id the
|
|
42182
|
+
* model no longer has: its entry of `entries`, if the file has one. */
|
|
42183
|
+
async removeOrphan(name, file, repository, entries, id) {
|
|
42184
|
+
const at = entries.findIndex((e) => e.element === id);
|
|
42185
|
+
if (at < 0) return { ok: false, text: `${name}: no element ${id} in the model` };
|
|
42186
|
+
const [entry] = entries.splice(at, 1);
|
|
42187
|
+
await writeFile5(file, serializeRepositoryFile(repository));
|
|
42188
|
+
return { ok: true, text: `Took ${entry.name !== void 0 ? `"${entry.name}" (${entry.element})` : entry.element}, no element of the model, out of ${REPOSITORY_FILE}.` };
|
|
42189
|
+
}
|
|
42190
|
+
/** After a write that deleted elements: their entries taken out of the
|
|
42191
|
+
* repository's .radical/radical.json, said in a sentence ('' for none). */
|
|
42192
|
+
async removeMappingsOf(deleted) {
|
|
42193
|
+
if (!deleted.length) return "";
|
|
42194
|
+
try {
|
|
42195
|
+
const { file } = await repositoryFileOf(this.folder);
|
|
42196
|
+
const text3 = await readFile6(file, "utf8").catch(() => null);
|
|
42197
|
+
if (text3 === null) return "";
|
|
42198
|
+
const repository = parseRepositoryFile(text3);
|
|
42199
|
+
const gone = new Set(deleted.map((n) => n.id));
|
|
42200
|
+
const taken = new Set([...repository.implements, ...repository.verifies].filter((e) => gone.has(e.element)).map((e) => e.element));
|
|
42201
|
+
if (!taken.size) return "";
|
|
42202
|
+
repository.implements = repository.implements.filter((e) => !taken.has(e.element));
|
|
42203
|
+
repository.verifies = repository.verifies.filter((e) => !taken.has(e.element));
|
|
42204
|
+
await writeFile5(file, serializeRepositoryFile(repository));
|
|
42205
|
+
const named = deleted.filter((n) => taken.has(n.id)).map((n) => `${n.type} "${n.label}" (${n.id})`);
|
|
42206
|
+
return ` Took the ${named.length === 1 ? "entry" : "entries"} of ${named.join(", ")} out of ${REPOSITORY_FILE}.`;
|
|
42207
|
+
} catch (error) {
|
|
42208
|
+
return ` ${REPOSITORY_FILE} still names what was deleted: ${error.message}.`;
|
|
42209
|
+
}
|
|
42210
|
+
}
|
|
40355
42211
|
async selection(facade) {
|
|
40356
42212
|
const text3 = await readEditorStateFile(this.folder, SELECTION_FILE);
|
|
40357
42213
|
if (text3 === null) {
|
|
@@ -40395,11 +42251,102 @@ ${bound.map((t) => `- ${t}`).join("\n")}` : `${REPOSITORY_FILE} binds no test to
|
|
|
40395
42251
|
const empty2 = result.nodes.length === 0 && result.relations.length === 0;
|
|
40396
42252
|
return empty2 ? `Nothing is selected in Studio. ${JSON.stringify(result)}` : JSON.stringify(result);
|
|
40397
42253
|
}
|
|
42254
|
+
/** Each requirement to review next to the words of the needs it derives
|
|
42255
|
+
* from (ADR Agents check requirements against the person's words). */
|
|
42256
|
+
async reviewRequirements(input, data) {
|
|
42257
|
+
const { ids, since } = input ?? {};
|
|
42258
|
+
if (ids !== void 0 && (!Array.isArray(ids) || ids.some((id) => typeof id !== "string"))) return { ok: false, text: "review_requirements: ids must be an array of requirement ids" };
|
|
42259
|
+
if (since !== void 0 && typeof since !== "string") return { ok: false, text: "review_requirements: since must be a git branch, tag or commit" };
|
|
42260
|
+
const own = ownModel(data);
|
|
42261
|
+
const nodes = new Map(own.nodes.map((n) => [n.id, n]));
|
|
42262
|
+
const relations = Object.fromEntries(own.relations.map((r) => [r.id, r]));
|
|
42263
|
+
const derivesFrom = (id) => own.relations.filter((r) => r.relationType === "derives" && r.sourceId === id).map((r) => nodes.get(r.targetId)).filter((n) => !!n);
|
|
42264
|
+
const quoted2 = (reqId, needId) => {
|
|
42265
|
+
const r = own.relations.find((rel) => rel.relationType === "derives" && rel.sourceId === reqId && rel.targetId === needId);
|
|
42266
|
+
const q = r?.quote;
|
|
42267
|
+
return typeof q === "string" ? q.trim() : "";
|
|
42268
|
+
};
|
|
42269
|
+
const needsOf = (id) => {
|
|
42270
|
+
const seen = /* @__PURE__ */ new Set([id]);
|
|
42271
|
+
const needs = [];
|
|
42272
|
+
const queue = [id];
|
|
42273
|
+
while (queue.length) {
|
|
42274
|
+
for (const next of derivesFrom(queue.shift())) {
|
|
42275
|
+
if (seen.has(next.id)) continue;
|
|
42276
|
+
seen.add(next.id);
|
|
42277
|
+
if (next.type === "need") needs.push(next);
|
|
42278
|
+
else if (next.type === "requirement") queue.push(next.id);
|
|
42279
|
+
}
|
|
42280
|
+
}
|
|
42281
|
+
return needs;
|
|
42282
|
+
};
|
|
42283
|
+
let chosen;
|
|
42284
|
+
let scope;
|
|
42285
|
+
if (ids) {
|
|
42286
|
+
const wanted = ids.map((id) => this.tempIds.get(id) ?? id);
|
|
42287
|
+
const unknown = wanted.filter((id) => nodes.get(id)?.type !== "requirement");
|
|
42288
|
+
if (unknown.length) return { ok: false, text: `review_requirements: not requirements of this model: ${unknown.join(", ")}` };
|
|
42289
|
+
chosen = wanted.map((id) => nodes.get(id));
|
|
42290
|
+
scope = "the requirements named";
|
|
42291
|
+
} else {
|
|
42292
|
+
let changes;
|
|
42293
|
+
try {
|
|
42294
|
+
changes = await modelChangesSince(this.folder, own, since);
|
|
42295
|
+
} catch (err2) {
|
|
42296
|
+
return { ok: false, text: `review_requirements: ${err2.message}; name the requirements with ids instead` };
|
|
42297
|
+
}
|
|
42298
|
+
const changed = new Set([...changes.report.elements.added, ...changes.report.elements.changed].map((c) => c.id));
|
|
42299
|
+
const { relations: rels } = changes.report;
|
|
42300
|
+
for (const r of [...rels.added, ...rels.changed, ...rels.removed]) if (r.relationType === "derives" && r.source.type === "requirement") changed.add(r.source.id);
|
|
42301
|
+
chosen = own.nodes.filter((n) => n.type === "requirement" && (changed.has(n.id) || needsOf(n.id).some((need) => changed.has(need.id))));
|
|
42302
|
+
scope = `the requirements added or changed since ${changes.base.described}, with their derives relations, and those a need changed since then leads to`;
|
|
42303
|
+
}
|
|
42304
|
+
if (!chosen.length) return { ok: true, text: `Nothing to review: no requirement among ${scope}.` };
|
|
42305
|
+
const props = (n) => n;
|
|
42306
|
+
const lines = [
|
|
42307
|
+
`Review ${chosen.length} requirement${chosen.length === 1 ? "" : "s"} (${scope}) against the words of the needs they derive from.`,
|
|
42308
|
+
"For each requirement, go through every value it states (a number, null or zero, a range, a time, a state, who may do what) and find the words of its needs that say it; write each value down with the quoted words. Where the words say something else, the requirement is wrong: correct it with update_node to what the person said. Where no words say it, it is your assumption: ask the person and add the question and the answer to the need word for word, or say so in its rationale. Confirm a requirement only when every value it states has its words."
|
|
42309
|
+
];
|
|
42310
|
+
const without3 = [];
|
|
42311
|
+
const shown = /* @__PURE__ */ new Set();
|
|
42312
|
+
for (const req of chosen.sort((a, b) => a.label.localeCompare(b.label))) {
|
|
42313
|
+
const needs = needsOf(req.id);
|
|
42314
|
+
if (!needs.length) without3.push(req);
|
|
42315
|
+
const sentence2 = composeEarsSentence(props(req), void 0, requirementStatePhrase(req, Object.fromEntries(nodes), relations)).sentence;
|
|
42316
|
+
lines.push("", `## Requirement "${req.label}" (${req.id})`, sentence2 || "(no sentence: it misses its action)");
|
|
42317
|
+
if (typeof props(req).rationale === "string" && props(req).rationale) lines.push(`Rationale: ${props(req).rationale}`);
|
|
42318
|
+
const gaps = quoteValueGaps({ nodes: Object.fromEntries(nodes), relations }, req);
|
|
42319
|
+
if (gaps.missing.length) lines.push(`Values its quotes say and it does not: ${[...new Set(gaps.missing.map((g) => g.value))].map((v) => `"${v}"`).join(", ")}.`);
|
|
42320
|
+
if (gaps.unsupported.length) lines.push(`Values it says and no quote says: ${gaps.unsupported.map((v) => `"${v}"`).join(", ")}.`);
|
|
42321
|
+
for (const need of needs) {
|
|
42322
|
+
const words2 = quoted2(req.id, need.id);
|
|
42323
|
+
if (words2) {
|
|
42324
|
+
lines.push(`### Rests on need "${need.label}" (${need.id}), quoting:`, words2);
|
|
42325
|
+
continue;
|
|
42326
|
+
}
|
|
42327
|
+
if (shown.has(need.id)) {
|
|
42328
|
+
lines.push(`Derives from need "${need.label}" (${need.id}), shown above; its derives relation quotes nothing: set quote to the words it rests on.`);
|
|
42329
|
+
continue;
|
|
42330
|
+
}
|
|
42331
|
+
shown.add(need.id);
|
|
42332
|
+
const text3 = (need.description ?? "").trim();
|
|
42333
|
+
lines.push(`### Need "${need.label}" (${need.id}), quoted by no word: set quote on the derives relation to the words it rests on${text3.includes("?") ? "" : "; it holds no question asked of a person: if you asked anything about it, add the questions and answers word for word"}`, text3 || "(empty)");
|
|
42334
|
+
}
|
|
42335
|
+
}
|
|
42336
|
+
if (without3.length) lines.push("", `Derive from no need: ${without3.map((r) => `"${r.label}" (${r.id})`).join(", ")}. Derive each from the need that holds the person's words, or say why it has none.`);
|
|
42337
|
+
return { ok: true, text: lines.join("\n") };
|
|
42338
|
+
}
|
|
40398
42339
|
async dispatch(name, input, session, before, data, facade) {
|
|
40399
42340
|
let priorTempIds;
|
|
40400
42341
|
try {
|
|
40401
42342
|
if (name === "get_model_summary") {
|
|
40402
42343
|
const metamodel2 = facade.getMetamodel?.();
|
|
42344
|
+
const { types: types2 } = input ?? {};
|
|
42345
|
+
if (types2 !== void 0) {
|
|
42346
|
+
if (!Array.isArray(types2) || types2.some((t) => typeof t !== "string")) return { ok: false, text: "get_model_summary: types must be an array of type or viewpoint ids" };
|
|
42347
|
+
const detail = metamodelDetail(metamodel2, types2);
|
|
42348
|
+
return { ok: !!detail.text, text: detail.text || "get_model_summary: types names nothing" };
|
|
42349
|
+
}
|
|
40403
42350
|
const summary = JSON.stringify({
|
|
40404
42351
|
radicalVersion: displayVersion(),
|
|
40405
42352
|
modelFormat: MD_FOLDER_FORMAT_VERSION,
|
|
@@ -40414,7 +42361,8 @@ ${bound.map((t) => `- ${t}`).join("\n")}` : `${REPOSITORY_FILE} binds no test to
|
|
|
40414
42361
|
...view.kind === "explore" && view.explore?.start ? { start: view.explore.start } : {},
|
|
40415
42362
|
...view.folder ? { folder: view.folder } : {},
|
|
40416
42363
|
...view.edgeStyle ? { edgeStyle: view.edgeStyle } : {},
|
|
40417
|
-
|
|
42364
|
+
// Keep smart saved with the view; absent, each Studio's default.
|
|
42365
|
+
...typeof view.continuousLayout === "boolean" ? { continuousLayout: view.continuousLayout } : {},
|
|
40418
42366
|
...view.sequenceId ? { sequenceId: view.sequenceId } : {},
|
|
40419
42367
|
...view.layoutConstraints?.length ? { alignments: view.layoutConstraints } : {}
|
|
40420
42368
|
})),
|
|
@@ -40442,7 +42390,7 @@ ${AI_MODELLING_RULES.map((rule) => `- ${rule}`).join("\n")}`;
|
|
|
40442
42390
|
|
|
40443
42391
|
${rules}
|
|
40444
42392
|
|
|
40445
|
-
${
|
|
42393
|
+
${buildMetamodelBrief(metamodel2)}` };
|
|
40446
42394
|
}
|
|
40447
42395
|
if (name === "get_issues") {
|
|
40448
42396
|
const mm = facade.getMetamodel?.();
|
|
@@ -40456,6 +42404,8 @@ ${buildMetamodelMessage(metamodel2)}` };
|
|
|
40456
42404
|
if (name === "get_selection") return { ok: true, text: await this.selection(facade) };
|
|
40457
42405
|
if (name === "get_implementation" || name === "set_implementation") return await this.implementation(name, input, data);
|
|
40458
42406
|
if (name === "get_verification" || name === "set_verification") return await this.verification(name, input, data);
|
|
42407
|
+
if (name === "get_trace") return await this.trace(input, data);
|
|
42408
|
+
if (name === "review_requirements") return await this.reviewRequirements(input, data);
|
|
40459
42409
|
if (name === "get_changes") {
|
|
40460
42410
|
const { since } = input ?? {};
|
|
40461
42411
|
if (since !== void 0 && typeof since !== "string") return { ok: false, text: "get_changes: since must be a git branch, tag or commit" };
|
|
@@ -40480,12 +42430,14 @@ ${buildMetamodelMessage(metamodel2)}` };
|
|
|
40480
42430
|
const result = FORGE_TOOLS.has(name) ? await this.forge.call(name, input, ctx, facade) : ASSAY_TOOLS.has(name) ? await this.assay.call(name, input, ctx, facade) : await runTool(name, input, ctx);
|
|
40481
42431
|
if (ASSAY_TOOLS.has(name) ? !result.ok : !result.ok || facade.lastError) {
|
|
40482
42432
|
this.restoreTempIds(priorTempIds);
|
|
42433
|
+
if (ASSAY_TOOLS.has(name)) await this.writeAssayStatus();
|
|
40483
42434
|
return { ok: false, text: ASSAY_TOOLS.has(name) ? result.resultText : facade.lastError ?? result.resultText };
|
|
40484
42435
|
}
|
|
40485
42436
|
const forgeBase = name === "forge_start" ? forgeModelBase(ownModel(data).nodes, ownModel(data).relations) : null;
|
|
40486
42437
|
if (READ_ONLY2.has(name) || result.readOnly) {
|
|
40487
42438
|
result.commit?.();
|
|
40488
42439
|
if (FORGE_TOOLS.has(name)) await this.writeForgeStatus();
|
|
42440
|
+
if (ASSAY_TOOLS.has(name)) await this.writeAssayStatus();
|
|
40489
42441
|
return { ok: true, text: result.resultText + (forgeBase ? await this.saveForgeBase(forgeBase) : "") + (result.afterWrite ? await result.afterWrite() : "") };
|
|
40490
42442
|
}
|
|
40491
42443
|
let changed = result.data ?? facade.toDiagramData();
|
|
@@ -40494,19 +42446,26 @@ ${buildMetamodelMessage(metamodel2)}` };
|
|
|
40494
42446
|
const metamodel = facade.getMetamodel?.();
|
|
40495
42447
|
const known = new Set((data.views ?? []).map((v) => v.id));
|
|
40496
42448
|
const fresh = (changed.views ?? []).filter((v) => v.partOf && !known.has(v.id) && (v.kind ?? "static") === "static" && !Object.keys(v.positions ?? {}).length);
|
|
42449
|
+
const arranged = [];
|
|
42450
|
+
const notLaidOut = [];
|
|
40497
42451
|
for (const view of fresh) {
|
|
40498
42452
|
const laidOut = await this.smartLayout(changed, metamodel, view.id);
|
|
40499
42453
|
if (laidOut.changed) changed = laidOut.changed;
|
|
42454
|
+
if (laidOut.ok) arranged.push(view);
|
|
42455
|
+
else notLaidOut.push(laidOut.text.replace(/^smart_layout: /, ""));
|
|
40500
42456
|
}
|
|
40501
|
-
const note =
|
|
42457
|
+
const note = freshLayoutNote(arranged, notLaidOut);
|
|
40502
42458
|
const outcome = await this.commit(session, before, data, changed, metamodel, result.resultText + note, metamodelBefore);
|
|
40503
42459
|
if (!outcome.ok) {
|
|
40504
42460
|
this.restoreTempIds(priorTempIds);
|
|
40505
42461
|
return outcome;
|
|
40506
42462
|
}
|
|
40507
42463
|
result.commit?.();
|
|
42464
|
+
const kept2 = new Set(changed.nodes.map((n) => n.id));
|
|
42465
|
+
outcome.text += await this.removeMappingsOf(data.nodes.filter((n) => !kept2.has(n.id) && !originOf(n)));
|
|
40508
42466
|
if (result.afterWrite) outcome.text += await result.afterWrite();
|
|
40509
42467
|
if (FORGE_TOOLS.has(name)) await this.writeForgeStatus();
|
|
42468
|
+
if (ASSAY_TOOLS.has(name)) await this.writeAssayStatus();
|
|
40510
42469
|
if (forgeBase) outcome.text += await this.saveForgeBase(forgeBase);
|
|
40511
42470
|
if (this.refreshTools(metamodel)) return { ...outcome, toolsChanged: true };
|
|
40512
42471
|
return outcome;
|
|
@@ -40523,14 +42482,16 @@ ${buildMetamodelMessage(metamodel2)}` };
|
|
|
40523
42482
|
const changed = JSON.parse(JSON.stringify(data));
|
|
40524
42483
|
const view = viewId === void 0 ? void 0 : changed.views?.find((v) => v.id === viewId);
|
|
40525
42484
|
if (viewId !== void 0 && !view) return { ok: false, text: `smart_layout: unknown view id "${viewId}"` };
|
|
40526
|
-
const refused2 = view ? noCanvasLayout("smart_layout", view) : null;
|
|
42485
|
+
const refused2 = view ? noCanvasLayout("smart_layout", view, byId3(changed.nodes), byId3(changed.relations)) : null;
|
|
40527
42486
|
if (refused2) return { ok: false, text: `${refused2}.` };
|
|
40528
42487
|
const nodes = byId3(view ? JSON.parse(JSON.stringify(changed.nodes)) : changed.nodes);
|
|
40529
42488
|
for (const [id, pos] of Object.entries(view?.positions ?? {})) {
|
|
40530
42489
|
const node = nodes[id];
|
|
40531
42490
|
if (node) Object.assign(node, { x: pos.x, y: pos.y, width: pos.width, height: pos.height });
|
|
40532
42491
|
}
|
|
42492
|
+
if (view && (view.kind ?? "static") === "static" && !Object.keys(view.positions ?? {}).length) placeOnViewCanvas(nodes, positionsOf2(nodes), view, byId3(changed.relations));
|
|
40533
42493
|
const constraints = view ? view.layoutConstraints : changed.defaultLayoutConstraints;
|
|
42494
|
+
applyAlignments(nodes, viewLayoutInput(view, nodes, byId3(changed.relations), constraints));
|
|
40534
42495
|
const input = viewLayoutInput(view, nodes, byId3(changed.relations), constraints);
|
|
40535
42496
|
if (!Object.keys(input.nodes).length) return { ok: true, text: "Smart Layout: there are no nodes to lay out." };
|
|
40536
42497
|
if (view?.layoutMode === "tree") return this.treeLayout(changed, nodes, view, input, constraints);
|
|
@@ -40557,14 +42518,14 @@ ${buildMetamodelMessage(metamodel2)}` };
|
|
|
40557
42518
|
return { ok: true, text: ensemble ? `Smart Layout${where}: the current layout already scores best; nothing changed.` : `Smart Layout${where}: nothing left to tidy.` };
|
|
40558
42519
|
}
|
|
40559
42520
|
applyLayoutPositions(nodes, result.winner.positions, input);
|
|
40560
|
-
resizeParentsBottomUp(nodes, input);
|
|
42521
|
+
resizeParentsBottomUp(nodes, input, !ensemble && options.around?.length ? keptFrames(input.nodes, result.winner.positions, input.frames) : void 0);
|
|
40561
42522
|
const unpins = ensemble || !options.around?.length;
|
|
40562
42523
|
const unpinned = unpins ? pinnedNodeIds(constraints).length : 0;
|
|
40563
42524
|
if (unpins) {
|
|
40564
42525
|
if (view) view.layoutConstraints = view.layoutConstraints?.filter((c) => c.type !== "pin");
|
|
40565
42526
|
else changed.defaultLayoutConstraints = changed.defaultLayoutConstraints?.filter((c) => c.type !== "pin");
|
|
40566
42527
|
}
|
|
40567
|
-
applyAlignments(nodes, viewLayoutInput(view, nodes, byId3(changed.relations),
|
|
42528
|
+
applyAlignments(nodes, viewLayoutInput(view, nodes, byId3(changed.relations), view ? view.layoutConstraints : changed.defaultLayoutConstraints));
|
|
40568
42529
|
if (view) view.positions = viewCanvasPositions(view, nodes, positionsOf2(nodes), viewDrawnIds(view, nodes, byId3(changed.relations)));
|
|
40569
42530
|
const before = result.baseline;
|
|
40570
42531
|
const after = result.winner.metrics;
|
|
@@ -40584,7 +42545,7 @@ ${buildMetamodelMessage(metamodel2)}` };
|
|
|
40584
42545
|
fitAndSeparateBottomUp(nodes, input);
|
|
40585
42546
|
const unpinned = pinnedNodeIds(constraints).length;
|
|
40586
42547
|
view.layoutConstraints = view.layoutConstraints?.filter((c) => c.type !== "pin");
|
|
40587
|
-
applyAlignments(nodes, viewLayoutInput(view, nodes, byId3(changed.relations),
|
|
42548
|
+
applyAlignments(nodes, viewLayoutInput(view, nodes, byId3(changed.relations), view.layoutConstraints));
|
|
40588
42549
|
view.positions = viewCanvasPositions(view, nodes, positionsOf2(nodes), viewDrawnIds(view, nodes, byId3(changed.relations)));
|
|
40589
42550
|
return {
|
|
40590
42551
|
ok: true,
|
|
@@ -40610,10 +42571,15 @@ ${buildMetamodelMessage(metamodel2)}` };
|
|
|
40610
42571
|
- ${issue.message}`).join("")}${warnings.length > MAX_WARNINGS ? `
|
|
40611
42572
|
- \u2026and ${warnings.length - MAX_WARNINGS} more` : ""}`;
|
|
40612
42573
|
const warned = !warnings.length ? "" : retyped ? ` Warning: the metamodel change brings in ${warnings.length} ${warnings.length === 1 ? "issue" : "issues"} (fix them or change the metamodel back, see get_issues):${list}` : ` New warnings (fine while you are still building; fix them before you finish, see get_issues):${list}`;
|
|
42574
|
+
const words2 = await this.wordsBroughtIn(data, changed, metamodel);
|
|
42575
|
+
const wordList = `${words2.slice(0, MAX_WARNINGS).map((f) => `
|
|
42576
|
+
- ${f.message}${f.severity === "error" ? " (an error in radical check)" : ""}`).join("")}${words2.length > MAX_WARNINGS ? `
|
|
42577
|
+
- \u2026and ${words2.length - MAX_WARNINGS} more` : ""}`;
|
|
42578
|
+
const wordsText = words2.length ? ` The person's words, as radical check reads them, after this change (correct the requirement, its quote or its scenario; review_requirements shows them side by side):${wordList}` : "";
|
|
40613
42579
|
const next = keepMdFolderPaths(before, serializeToMdFolderWithPaths(changed).files);
|
|
40614
42580
|
next["radical.md"] = before["radical.md"];
|
|
40615
42581
|
const paths = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(next)])].filter((path) => before[path] !== next[path] && (path in next || isOwnedMdFolderFile(path, before[path]))).sort();
|
|
40616
|
-
if (!paths.length) return { ok: true, text: `${resultText} No files changed.${warned}` };
|
|
42582
|
+
if (!paths.length) return { ok: true, text: `${resultText} No files changed.${warned}${wordsText}` };
|
|
40617
42583
|
const write = await session.write(next, mergeMdFolderFiles);
|
|
40618
42584
|
await session.cacheWritten();
|
|
40619
42585
|
if (!write.ok) return { ok: false, text: `The folder changed while this call ran and does not read as a model (${write.conflict.join(", ")}); no files written. Fix the file, then try again.` };
|
|
@@ -40623,7 +42589,25 @@ ${buildMetamodelMessage(metamodel2)}` };
|
|
|
40623
42589
|
const revision = createHash("sha256").update(paths.map((path) => `${path}\0${next[path] ?? ""}`).join("\0")).digest("hex").slice(0, 12);
|
|
40624
42590
|
const created = changed.relations.filter((relation) => !data.relations.some((old) => old.id === relation.id));
|
|
40625
42591
|
const madeText = created.length === 1 ? ` Relation ID: ${created[0].id}.` : created.length > 1 ? ` ${created.length} relations created.` : "";
|
|
40626
|
-
return { ok: true, text: `${resultText}${madeText} Changed: ${paths.join(", ")}. Revision: ${revision}.${merged}${warned}` };
|
|
42592
|
+
return { ok: true, text: `${resultText}${madeText} Changed: ${paths.join(", ")}. Revision: ${revision}.${merged}${warned}${wordsText}` };
|
|
42593
|
+
}
|
|
42594
|
+
/** What a change brings in of the rules about the person's words (a quote
|
|
42595
|
+
* the need does not hold, a value lost on the way to the requirement or
|
|
42596
|
+
* its scenario, an example no scenario holds): the findings it has that
|
|
42597
|
+
* the model before it had not, without the rules check.json turns off. */
|
|
42598
|
+
async wordsBroughtIn(data, changed, metamodel) {
|
|
42599
|
+
if (!metamodel.nodeTypes.need || !metamodel.nodeTypes.requirement) return [];
|
|
42600
|
+
let off = /* @__PURE__ */ new Set();
|
|
42601
|
+
try {
|
|
42602
|
+
const config = parseCheckConfig(await readFile6(join17(this.folder, CHECK_CONFIG_FILE), "utf8"));
|
|
42603
|
+
off = new Set(Object.entries(config.rules ?? {}).filter(([id, setting2]) => WORD_RULES.has(id) && (setting2 === "off" || typeof setting2 === "object" && setting2 !== null && setting2.severity === "off")).map(([id]) => id));
|
|
42604
|
+
} catch {
|
|
42605
|
+
}
|
|
42606
|
+
const findings = (d) => wordFindings({ nodes: byId3(d.nodes), relations: byId3(d.relations), metamodel }, off);
|
|
42607
|
+
const place = (f) => `${f.rule}\0${f.nodeId ?? ""}\0${f.relationId ?? ""}`;
|
|
42608
|
+
const keys = (f) => f.about?.length ? f.about.map((a) => `${place(f)}\0${a}`) : [`${place(f)}\0${f.message}`];
|
|
42609
|
+
const before = new Set(findings(withLabelsOf(data, changed)).flatMap(keys));
|
|
42610
|
+
return findings(changed).filter((f) => keys(f).some((k) => !before.has(k)));
|
|
40627
42611
|
}
|
|
40628
42612
|
/** Tell Studio, open on the folder, that an agent is writing it: it holds
|
|
40629
42613
|
* its own saves until the agent pauses (agentActivity). */
|
|
@@ -40641,6 +42625,10 @@ ${buildMetamodelMessage(metamodel2)}` };
|
|
|
40641
42625
|
function positionsOf2(nodes) {
|
|
40642
42626
|
return Object.fromEntries(Object.values(nodes).map((node) => [node.id, { x: node.x, y: node.y, width: node.width, height: node.height }]));
|
|
40643
42627
|
}
|
|
42628
|
+
function withLabelsOf(data, named) {
|
|
42629
|
+
const labels = new Map(named.nodes.map((n) => [n.id, n.label]));
|
|
42630
|
+
return { ...data, nodes: data.nodes.map((n) => labels.has(n.id) && labels.get(n.id) !== n.label ? { ...n, label: labels.get(n.id) } : n) };
|
|
42631
|
+
}
|
|
40644
42632
|
|
|
40645
42633
|
// src/index.ts
|
|
40646
42634
|
var USAGE = `Usage: radical-mcp [--folder <model-folder>] [--metamodel ${Object.keys(PRESETS).join("|")}]
|
|
@@ -40664,9 +42652,10 @@ function parseArgs(args) {
|
|
|
40664
42652
|
}
|
|
40665
42653
|
var INSTRUCTIONS = [
|
|
40666
42654
|
"Reads and edits one Radical Markdown model folder (C4 architecture plus governance records such as ADRs and requirements).",
|
|
40667
|
-
"Call get_model_summary first: besides counts it returns the metamodel context message the other tools refer to
|
|
40668
|
-
"
|
|
40669
|
-
"
|
|
42655
|
+
"Call get_model_summary first: besides counts it returns the metamodel in brief, the context message the other tools refer to:",
|
|
42656
|
+
"each type with where it may go and its valid `properties` keys, and the node-type pairs each relation type allows;",
|
|
42657
|
+
"get_model_summary with types gives a type in full (every enum option, visibility, layout). Use search_model for exact model data",
|
|
42658
|
+
"before changing it: lists and traversals answer in brief (one sentence an element); GET NODE <id> gives an element whole, FULL at the end of a query every field.",
|
|
40670
42659
|
`When the user refers to "the selected" element, mockup or view (or "this one") without naming it, call get_selection: it returns what is selected on Studio's canvas for this folder.`,
|
|
40671
42660
|
"New nodes appear only in Studio's All elements view until you list them in a view (create_view, set_view_nodes).",
|
|
40672
42661
|
"move_node changes a node's parent. New and moved nodes get a simple placement; call smart_layout afterwards to arrange the model or one view.",
|
|
@@ -40677,7 +42666,8 @@ var INSTRUCTIONS = [
|
|
|
40677
42666
|
"Sequences (create_sequence) are ordered relation flows that dynamic views play; presentations are slides over views.",
|
|
40678
42667
|
'Milestones are named copies of the model at phases of the system (e.g. "As-is", "Target 2027"): create_milestone saves the current model as the latest one, compare_milestones says what changed, and a slide can show a milestone.',
|
|
40679
42668
|
"Metamodel tools (upsert_node_type, upsert_relation_type, \u2026) change the types; the tool schemas refresh after them.",
|
|
40680
|
-
"
|
|
42669
|
+
"Keep the model current as you work: write into it what you learn and decide when you learn and decide it, a few elements at a time (a need for what a person asks for, the requirements you derive from it, the elements that satisfy them, an ADR for each decision, a scenario for a requirement you test), and the model before the code. Add each question you ask a person and their answer to the need word for word; after you change requirements and before you write their code, call review_requirements and correct each requirement that does not say what the person said.",
|
|
42670
|
+
"Run Radical Forge only when the user asks for it: it turns a free-text description into requirements, a domain model, fitness functions, scenarios, state machines, processes, mockups and a C4 model, each stage filling gaps in the ones before and a review of the whole model at the end, the way Studio's Radical Forge does. Start with forge_start and follow the steps it returns, and leave out with forge_skip_stage the stages a system of its size does not need.",
|
|
40681
42671
|
"To find the model in existing code (Radical Assay: one or several local repositories, this folder being their central model), start with assay_start and follow the steps it returns: every element cites the facts it rests on, and requirements are written only when the user accepts them."
|
|
40682
42672
|
].join(" ");
|
|
40683
42673
|
var FORGE_ARGS = fromJsonSchema({
|