@rqml/cli 0.4.1 → 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 +6 -1
- package/dist/index.js +972 -204
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { __commonJS, __toESM } from './chunk-5WRI5ZAA.js';
|
|
3
3
|
import { createRequire } from 'module';
|
|
4
|
-
import { createHash } from 'crypto';
|
|
5
4
|
import { writeFileSync, existsSync, readFileSync, mkdirSync, statSync, readdirSync } from 'fs';
|
|
5
|
+
import { createHash } from 'crypto';
|
|
6
6
|
import { resolve, join, dirname, isAbsolute } from 'path';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
|
|
@@ -3453,6 +3453,18 @@ function updateTraceEdge(xml, request) {
|
|
|
3453
3453
|
previousUri: external.uri
|
|
3454
3454
|
};
|
|
3455
3455
|
}
|
|
3456
|
+
function fields(...pairs) {
|
|
3457
|
+
const out = [];
|
|
3458
|
+
for (const [label, value] of pairs) {
|
|
3459
|
+
if (value !== void 0 && value !== "") out.push({ label, value });
|
|
3460
|
+
}
|
|
3461
|
+
return out;
|
|
3462
|
+
}
|
|
3463
|
+
function locatorLabel(loc) {
|
|
3464
|
+
if (loc.kind === "local") return loc.id;
|
|
3465
|
+
if (loc.kind === "doc") return `${loc.uri}#${loc.id}`;
|
|
3466
|
+
return loc.uri;
|
|
3467
|
+
}
|
|
3456
3468
|
function collectTitles(doc) {
|
|
3457
3469
|
const m = /* @__PURE__ */ new Map();
|
|
3458
3470
|
const set = (id, title) => {
|
|
@@ -3524,206 +3536,632 @@ function collectTitles(doc) {
|
|
|
3524
3536
|
}
|
|
3525
3537
|
return m;
|
|
3526
3538
|
}
|
|
3527
|
-
function
|
|
3528
|
-
|
|
3539
|
+
function endpointTitle(ep, titleById) {
|
|
3540
|
+
if (ep.requirement !== void 0) return ep.requirement.title;
|
|
3541
|
+
if (ep.locator.title !== void 0) return ep.locator.title;
|
|
3542
|
+
if (ep.locator.kind === "local") return titleById.get(ep.locator.id);
|
|
3543
|
+
return void 0;
|
|
3529
3544
|
}
|
|
3530
|
-
function
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
statement: g.statement,
|
|
3537
|
-
status: g.status,
|
|
3538
|
-
priority: g.priority,
|
|
3539
|
-
rationale: g.rationale
|
|
3540
|
-
} : {};
|
|
3541
|
-
}
|
|
3542
|
-
case "qgoal": {
|
|
3543
|
-
const g = doc.goals?.qualityGoals?.find((x) => x.id === id);
|
|
3544
|
-
return g ? {
|
|
3545
|
-
title: g.title,
|
|
3546
|
-
statement: g.statement,
|
|
3547
|
-
status: g.status,
|
|
3548
|
-
priority: g.priority,
|
|
3549
|
-
notes: g.metric
|
|
3550
|
-
} : {};
|
|
3551
|
-
}
|
|
3552
|
-
case "obstacle": {
|
|
3553
|
-
const o = doc.goals?.obstacles?.find((x) => x.id === id);
|
|
3554
|
-
return o ? { title: o.title, statement: o.statement, notes: o.mitigation } : {};
|
|
3555
|
-
}
|
|
3556
|
-
case "scenario":
|
|
3557
|
-
case "misuseCase":
|
|
3558
|
-
case "edgeCase": {
|
|
3559
|
-
const all = [
|
|
3560
|
-
...doc.scenarios?.scenarios ?? [],
|
|
3561
|
-
...doc.scenarios?.misuseCases ?? [],
|
|
3562
|
-
...doc.scenarios?.edgeCases ?? []
|
|
3563
|
-
];
|
|
3564
|
-
const s = all.find((x) => x.id === id);
|
|
3565
|
-
return s ? { title: s.title, statement: s.narrative } : {};
|
|
3566
|
-
}
|
|
3567
|
-
case "testCase": {
|
|
3568
|
-
const t = doc.verification?.testCases?.find((x) => x.id === id);
|
|
3569
|
-
return t ? { title: t.title, statement: t.purpose, notes: t.expected } : {};
|
|
3570
|
-
}
|
|
3571
|
-
case "testSuite": {
|
|
3572
|
-
const t = doc.verification?.testSuites?.find((x) => x.id === id);
|
|
3573
|
-
return t ? { title: t.title, statement: t.description } : {};
|
|
3574
|
-
}
|
|
3575
|
-
case "risk": {
|
|
3576
|
-
const r = doc.catalogs?.risks?.find((x) => x.id === id);
|
|
3577
|
-
return r ? { statement: r.statement, notes: r.mitigation } : {};
|
|
3578
|
-
}
|
|
3579
|
-
case "constraint": {
|
|
3580
|
-
const c = doc.catalogs?.constraints?.find((x) => x.id === id);
|
|
3581
|
-
return c ? { statement: c.statement } : {};
|
|
3582
|
-
}
|
|
3583
|
-
case "decision": {
|
|
3584
|
-
const d = doc.catalogs?.decisions?.find((x) => x.id === id);
|
|
3585
|
-
return d ? { statement: d.decision, rationale: d.context, status: d.status } : {};
|
|
3586
|
-
}
|
|
3587
|
-
case "term": {
|
|
3588
|
-
const t = doc.catalogs?.glossary?.find((x) => x.id === id);
|
|
3589
|
-
return t ? { title: t.name, statement: t.definition } : {};
|
|
3590
|
-
}
|
|
3591
|
-
case "rule": {
|
|
3592
|
-
const r = doc.domain?.businessRules?.find((x) => x.id === id);
|
|
3593
|
-
return r ? { statement: r.statement, notes: r.examples } : {};
|
|
3594
|
-
}
|
|
3595
|
-
case "entity": {
|
|
3596
|
-
const e = doc.domain?.entities?.find((x) => x.id === id);
|
|
3597
|
-
return e ? { title: e.name, statement: e.description } : {};
|
|
3598
|
-
}
|
|
3599
|
-
case "stateMachine": {
|
|
3600
|
-
const sm = doc.behavior?.stateMachines?.find((x) => x.id === id);
|
|
3601
|
-
return sm ? { title: sm.name, statement: sm.description } : {};
|
|
3602
|
-
}
|
|
3603
|
-
default:
|
|
3604
|
-
return {};
|
|
3605
|
-
}
|
|
3545
|
+
function endpointLabel(ep, titleById) {
|
|
3546
|
+
let s = locatorLabel(ep.locator);
|
|
3547
|
+
const hint = endpointTitle(ep, titleById);
|
|
3548
|
+
if (hint !== void 0) s += ` (${hint})`;
|
|
3549
|
+
if (ep.locator.kind === "local" && ep.target === void 0) s += " [unresolved]";
|
|
3550
|
+
return s;
|
|
3606
3551
|
}
|
|
3607
|
-
function
|
|
3608
|
-
const
|
|
3609
|
-
const
|
|
3610
|
-
|
|
3611
|
-
const
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
if (
|
|
3619
|
-
|
|
3620
|
-
if (
|
|
3621
|
-
|
|
3622
|
-
}
|
|
3623
|
-
|
|
3624
|
-
|
|
3552
|
+
function buildOutline(doc) {
|
|
3553
|
+
const res = resolveTrace(doc);
|
|
3554
|
+
const titleById = collectTitles(doc);
|
|
3555
|
+
const refsBySource = /* @__PURE__ */ new Map();
|
|
3556
|
+
for (const re of res.edges) {
|
|
3557
|
+
if (re.from.locator.kind !== "local") continue;
|
|
3558
|
+
const toLoc = re.to.locator;
|
|
3559
|
+
const targetId = toLoc.kind === "local" ? toLoc.id : toLoc.uri;
|
|
3560
|
+
const resolved = toLoc.kind === "local" ? re.to.target !== void 0 : true;
|
|
3561
|
+
const ref = { relation: re.edge.type, targetId, resolved };
|
|
3562
|
+
const tt = endpointTitle(re.to, titleById);
|
|
3563
|
+
if (tt !== void 0) ref.targetTitle = tt;
|
|
3564
|
+
const arr = refsBySource.get(re.from.locator.id);
|
|
3565
|
+
if (arr) arr.push(ref);
|
|
3566
|
+
else refsBySource.set(re.from.locator.id, [ref]);
|
|
3567
|
+
}
|
|
3568
|
+
const node = (kind, id, title, flds, children) => {
|
|
3569
|
+
const n = { kind, title, fields: flds };
|
|
3570
|
+
if (id !== void 0) n.id = id;
|
|
3571
|
+
const refs = id !== void 0 ? refsBySource.get(id) : void 0;
|
|
3572
|
+
if (refs && refs.length > 0) n.refs = refs;
|
|
3573
|
+
if (children && children.length > 0) n.children = children;
|
|
3574
|
+
return n;
|
|
3575
|
+
};
|
|
3576
|
+
const sections = [];
|
|
3577
|
+
const pushSection = (title, flds, nodes) => {
|
|
3578
|
+
if (flds.length === 0 && nodes.length === 0) return;
|
|
3579
|
+
const s = { kind: "section", title, fields: flds };
|
|
3580
|
+
if (nodes.length > 0) s.children = nodes;
|
|
3581
|
+
sections.push(s);
|
|
3582
|
+
};
|
|
3583
|
+
const meta = doc.meta;
|
|
3584
|
+
pushSection(
|
|
3585
|
+
"Meta",
|
|
3586
|
+
fields(
|
|
3587
|
+
["Created", meta.dates?.created],
|
|
3588
|
+
["Updated", meta.dates?.updated],
|
|
3589
|
+
["Target release", meta.dates?.targetRelease],
|
|
3590
|
+
["Normative keywords", meta.conventions?.normativeKeywords],
|
|
3591
|
+
["ID conventions", meta.conventions?.idConventions]
|
|
3592
|
+
),
|
|
3593
|
+
(meta.profiles ?? []).map(
|
|
3594
|
+
(p) => node("profile", p.id, p.type, fields(["Description", p.description]))
|
|
3595
|
+
)
|
|
3596
|
+
);
|
|
3597
|
+
const cat = doc.catalogs;
|
|
3598
|
+
if (cat) {
|
|
3599
|
+
pushSection(
|
|
3600
|
+
"Glossary",
|
|
3601
|
+
[],
|
|
3602
|
+
(cat.glossary ?? []).map(
|
|
3603
|
+
(t) => node(
|
|
3604
|
+
"term",
|
|
3605
|
+
t.id,
|
|
3606
|
+
t.name,
|
|
3607
|
+
fields(["Definition", t.definition], ["Synonyms", t.synonyms?.join(", ")])
|
|
3608
|
+
)
|
|
3609
|
+
)
|
|
3610
|
+
);
|
|
3611
|
+
pushSection(
|
|
3612
|
+
"Actors",
|
|
3613
|
+
[],
|
|
3614
|
+
(cat.actors ?? []).map(
|
|
3615
|
+
(a) => node(
|
|
3616
|
+
"actor",
|
|
3617
|
+
a.id,
|
|
3618
|
+
a.name,
|
|
3619
|
+
fields(
|
|
3620
|
+
["Type", a.type],
|
|
3621
|
+
["Description", a.description],
|
|
3622
|
+
["Goal refs", a.goalRefs?.join(", ")]
|
|
3623
|
+
)
|
|
3624
|
+
)
|
|
3625
|
+
)
|
|
3626
|
+
);
|
|
3627
|
+
pushSection(
|
|
3628
|
+
"Stakeholders",
|
|
3629
|
+
[],
|
|
3630
|
+
(cat.stakeholders ?? []).map(
|
|
3631
|
+
(s) => node(
|
|
3632
|
+
"stakeholder",
|
|
3633
|
+
s.id,
|
|
3634
|
+
s.name,
|
|
3635
|
+
fields(["Org", s.org], ["Concerns", s.concerns])
|
|
3636
|
+
)
|
|
3637
|
+
)
|
|
3638
|
+
);
|
|
3639
|
+
pushSection(
|
|
3640
|
+
"Constraints",
|
|
3641
|
+
[],
|
|
3642
|
+
(cat.constraints ?? []).map(
|
|
3643
|
+
(c) => node(
|
|
3644
|
+
"constraint",
|
|
3645
|
+
c.id,
|
|
3646
|
+
c.statement,
|
|
3647
|
+
fields(["Severity", c.severity], ["Source", c.source])
|
|
3648
|
+
)
|
|
3649
|
+
)
|
|
3650
|
+
);
|
|
3651
|
+
pushSection(
|
|
3652
|
+
"Policies",
|
|
3653
|
+
[],
|
|
3654
|
+
(cat.policies ?? []).map(
|
|
3655
|
+
(p) => node(
|
|
3656
|
+
"policy",
|
|
3657
|
+
p.id,
|
|
3658
|
+
p.obligation,
|
|
3659
|
+
fields(["Source", p.source], ["Evidence", p.evidence])
|
|
3660
|
+
)
|
|
3661
|
+
)
|
|
3662
|
+
);
|
|
3663
|
+
pushSection(
|
|
3664
|
+
"Decisions",
|
|
3665
|
+
[],
|
|
3666
|
+
(cat.decisions ?? []).map(
|
|
3667
|
+
(d) => node(
|
|
3668
|
+
"decision",
|
|
3669
|
+
d.id,
|
|
3670
|
+
d.decision,
|
|
3671
|
+
fields(
|
|
3672
|
+
["Status", d.status],
|
|
3673
|
+
["Context", d.context],
|
|
3674
|
+
["Alternatives", d.alternatives],
|
|
3675
|
+
["Consequences", d.consequences]
|
|
3676
|
+
)
|
|
3677
|
+
)
|
|
3678
|
+
)
|
|
3679
|
+
);
|
|
3680
|
+
pushSection(
|
|
3681
|
+
"Risks",
|
|
3682
|
+
[],
|
|
3683
|
+
(cat.risks ?? []).map(
|
|
3684
|
+
(r) => node(
|
|
3685
|
+
"risk",
|
|
3686
|
+
r.id,
|
|
3687
|
+
r.statement,
|
|
3688
|
+
fields(["Severity", r.severity], ["Mitigation", r.mitigation])
|
|
3689
|
+
)
|
|
3690
|
+
)
|
|
3625
3691
|
);
|
|
3626
|
-
Object.assign(slice, extra);
|
|
3627
3692
|
}
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
const
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3693
|
+
const dom = doc.domain;
|
|
3694
|
+
if (dom) {
|
|
3695
|
+
const entityNodes = (dom.entities ?? []).map(
|
|
3696
|
+
(e) => node(
|
|
3697
|
+
"entity",
|
|
3698
|
+
e.id,
|
|
3699
|
+
e.name,
|
|
3700
|
+
fields(["Description", e.description]),
|
|
3701
|
+
(e.attrs ?? []).map(
|
|
3702
|
+
(a) => node(
|
|
3703
|
+
"attr",
|
|
3704
|
+
a.id,
|
|
3705
|
+
a.name,
|
|
3706
|
+
fields(
|
|
3707
|
+
["Type", a.type],
|
|
3708
|
+
["Required", a.required === void 0 ? void 0 : String(a.required)],
|
|
3709
|
+
["Description", a.description],
|
|
3710
|
+
["Constraints", a.constraints]
|
|
3711
|
+
)
|
|
3712
|
+
)
|
|
3713
|
+
)
|
|
3714
|
+
)
|
|
3715
|
+
);
|
|
3716
|
+
const ruleNodes = (dom.businessRules ?? []).map(
|
|
3717
|
+
(r) => node("rule", r.id, r.statement, fields(["Examples", r.examples]))
|
|
3718
|
+
);
|
|
3719
|
+
pushSection("Domain", fields(["Overview", dom.overview]), [
|
|
3720
|
+
...entityNodes,
|
|
3721
|
+
...ruleNodes
|
|
3722
|
+
]);
|
|
3723
|
+
}
|
|
3724
|
+
const goals = doc.goals;
|
|
3725
|
+
if (goals) {
|
|
3726
|
+
pushSection(
|
|
3727
|
+
"Goals",
|
|
3728
|
+
[],
|
|
3729
|
+
(goals.goals ?? []).map(
|
|
3730
|
+
(g) => node(
|
|
3731
|
+
"goal",
|
|
3732
|
+
g.id,
|
|
3733
|
+
g.title,
|
|
3734
|
+
fields(
|
|
3735
|
+
["Priority", g.priority],
|
|
3736
|
+
["Status", g.status],
|
|
3737
|
+
["Owner", g.ownerRef],
|
|
3738
|
+
["Statement", g.statement],
|
|
3739
|
+
["Rationale", g.rationale]
|
|
3740
|
+
)
|
|
3741
|
+
)
|
|
3742
|
+
)
|
|
3743
|
+
);
|
|
3744
|
+
pushSection(
|
|
3745
|
+
"Quality goals",
|
|
3746
|
+
[],
|
|
3747
|
+
(goals.qualityGoals ?? []).map(
|
|
3748
|
+
(g) => node(
|
|
3749
|
+
"qgoal",
|
|
3750
|
+
g.id,
|
|
3751
|
+
g.title,
|
|
3752
|
+
fields(
|
|
3753
|
+
["Priority", g.priority],
|
|
3754
|
+
["Status", g.status],
|
|
3755
|
+
["Statement", g.statement],
|
|
3756
|
+
["Metric", g.metric]
|
|
3757
|
+
)
|
|
3758
|
+
)
|
|
3759
|
+
)
|
|
3760
|
+
);
|
|
3761
|
+
pushSection(
|
|
3762
|
+
"Obstacles",
|
|
3763
|
+
[],
|
|
3764
|
+
(goals.obstacles ?? []).map(
|
|
3765
|
+
(o) => node(
|
|
3766
|
+
"obstacle",
|
|
3767
|
+
o.id,
|
|
3768
|
+
o.title,
|
|
3769
|
+
fields(
|
|
3770
|
+
["Likelihood", o.likelihood],
|
|
3771
|
+
["Severity", o.severity],
|
|
3772
|
+
["Statement", o.statement],
|
|
3773
|
+
["Mitigation", o.mitigation]
|
|
3774
|
+
)
|
|
3775
|
+
)
|
|
3776
|
+
)
|
|
3777
|
+
);
|
|
3778
|
+
pushSection(
|
|
3779
|
+
"Goal links",
|
|
3780
|
+
[],
|
|
3781
|
+
(goals.goalLinks ?? []).map(
|
|
3782
|
+
(l) => node(
|
|
3783
|
+
"goalLink",
|
|
3784
|
+
l.id,
|
|
3785
|
+
l.id,
|
|
3786
|
+
fields(
|
|
3787
|
+
["From", l.from],
|
|
3788
|
+
["To", l.to],
|
|
3789
|
+
["Type", l.type],
|
|
3790
|
+
["Confidence", l.confidence?.toString()]
|
|
3791
|
+
)
|
|
3792
|
+
)
|
|
3793
|
+
)
|
|
3794
|
+
);
|
|
3645
3795
|
}
|
|
3646
|
-
|
|
3796
|
+
const sc = doc.scenarios;
|
|
3797
|
+
if (sc) {
|
|
3798
|
+
const scNode = (kind) => (s) => node(
|
|
3799
|
+
kind,
|
|
3800
|
+
s.id,
|
|
3801
|
+
s.title,
|
|
3802
|
+
fields(["Actor", s.actorRef], ["Narrative", s.narrative])
|
|
3803
|
+
);
|
|
3804
|
+
pushSection("Scenarios", [], (sc.scenarios ?? []).map(scNode("scenario")));
|
|
3805
|
+
pushSection("Misuse cases", [], (sc.misuseCases ?? []).map(scNode("misuseCase")));
|
|
3806
|
+
pushSection("Edge cases", [], (sc.edgeCases ?? []).map(scNode("edgeCase")));
|
|
3807
|
+
}
|
|
3808
|
+
const criterionNode = (c) => node(
|
|
3809
|
+
"criterion",
|
|
3810
|
+
c.id,
|
|
3811
|
+
c.id ?? "Acceptance criterion",
|
|
3812
|
+
fields(["Given", c.given], ["When", c.when], ["Then", c.then])
|
|
3813
|
+
);
|
|
3814
|
+
const reqNode = (r) => node(
|
|
3815
|
+
"req",
|
|
3816
|
+
r.id,
|
|
3817
|
+
r.title,
|
|
3818
|
+
fields(
|
|
3819
|
+
["Type", r.type],
|
|
3820
|
+
["Status", r.status],
|
|
3821
|
+
["Priority", r.priority],
|
|
3822
|
+
["Owner", r.ownerRef],
|
|
3823
|
+
["Applies to", r.appliesTo],
|
|
3824
|
+
["Statement", r.statement],
|
|
3825
|
+
["Rationale", r.rationale],
|
|
3826
|
+
["Notes", r.notes]
|
|
3827
|
+
),
|
|
3828
|
+
r.acceptance.map(criterionNode)
|
|
3829
|
+
);
|
|
3830
|
+
const reqNodes = [
|
|
3831
|
+
...doc.packages.map(
|
|
3832
|
+
(p) => node(
|
|
3833
|
+
"reqPackage",
|
|
3834
|
+
p.id,
|
|
3835
|
+
p.title,
|
|
3836
|
+
fields(["Owner", p.ownerRef], ["Description", p.description]),
|
|
3837
|
+
p.requirements.map(reqNode)
|
|
3838
|
+
)
|
|
3839
|
+
),
|
|
3840
|
+
...doc.looseRequirements.map(reqNode)
|
|
3841
|
+
];
|
|
3842
|
+
pushSection("Requirements", [], reqNodes);
|
|
3843
|
+
const beh = doc.behavior;
|
|
3844
|
+
if (beh) {
|
|
3845
|
+
pushSection(
|
|
3846
|
+
"Behavior",
|
|
3847
|
+
[],
|
|
3848
|
+
(beh.stateMachines ?? []).map(
|
|
3849
|
+
(sm) => node(
|
|
3850
|
+
"stateMachine",
|
|
3851
|
+
sm.id,
|
|
3852
|
+
sm.name,
|
|
3853
|
+
fields(
|
|
3854
|
+
["Initial", sm.initial],
|
|
3855
|
+
["Entity", sm.entityRef],
|
|
3856
|
+
["Description", sm.description]
|
|
3857
|
+
),
|
|
3858
|
+
[
|
|
3859
|
+
...sm.states.map(
|
|
3860
|
+
(st) => node(
|
|
3861
|
+
"state",
|
|
3862
|
+
st.id,
|
|
3863
|
+
st.name,
|
|
3864
|
+
fields(
|
|
3865
|
+
["Type", st.type],
|
|
3866
|
+
["Description", st.description],
|
|
3867
|
+
["On entry", st.onEntry],
|
|
3868
|
+
["On exit", st.onExit],
|
|
3869
|
+
["Invariant", st.invariant]
|
|
3870
|
+
)
|
|
3871
|
+
)
|
|
3872
|
+
),
|
|
3873
|
+
...(sm.transitions ?? []).map(
|
|
3874
|
+
(tr) => node(
|
|
3875
|
+
"transition",
|
|
3876
|
+
tr.id,
|
|
3877
|
+
`${tr.from} \u2192 ${tr.to}`,
|
|
3878
|
+
fields(
|
|
3879
|
+
["From", tr.from],
|
|
3880
|
+
["To", tr.to],
|
|
3881
|
+
["Event", tr.event],
|
|
3882
|
+
["Trigger", tr.trigger],
|
|
3883
|
+
["Guard", tr.guard],
|
|
3884
|
+
["Action", tr.action],
|
|
3885
|
+
["Description", tr.description]
|
|
3886
|
+
)
|
|
3887
|
+
)
|
|
3888
|
+
)
|
|
3889
|
+
]
|
|
3890
|
+
)
|
|
3891
|
+
)
|
|
3892
|
+
);
|
|
3893
|
+
}
|
|
3894
|
+
const ifaces = doc.interfaces;
|
|
3895
|
+
if (ifaces) {
|
|
3896
|
+
const apiNodes = (ifaces.apis ?? []).map(
|
|
3897
|
+
(api) => node(
|
|
3898
|
+
"api",
|
|
3899
|
+
api.id,
|
|
3900
|
+
api.name,
|
|
3901
|
+
fields(
|
|
3902
|
+
["Protocol", api.protocol],
|
|
3903
|
+
["Auth", api.auth],
|
|
3904
|
+
["Description", api.description]
|
|
3905
|
+
),
|
|
3906
|
+
(api.endpoints ?? []).map(
|
|
3907
|
+
(ep) => node(
|
|
3908
|
+
"endpoint",
|
|
3909
|
+
ep.id,
|
|
3910
|
+
`${ep.method} ${ep.path}`,
|
|
3911
|
+
fields(
|
|
3912
|
+
["Summary", ep.summary],
|
|
3913
|
+
["Request", ep.request],
|
|
3914
|
+
["Response", ep.response],
|
|
3915
|
+
["Errors", ep.errors]
|
|
3916
|
+
)
|
|
3917
|
+
)
|
|
3918
|
+
)
|
|
3919
|
+
)
|
|
3920
|
+
);
|
|
3921
|
+
const eventNodes = (ifaces.events ?? []).map(
|
|
3922
|
+
(ev) => node(
|
|
3923
|
+
"event",
|
|
3924
|
+
ev.id,
|
|
3925
|
+
ev.name,
|
|
3926
|
+
fields(["Description", ev.description], ["Payload", ev.payload])
|
|
3927
|
+
)
|
|
3928
|
+
);
|
|
3929
|
+
pushSection("Interfaces", [], [...apiNodes, ...eventNodes]);
|
|
3930
|
+
}
|
|
3931
|
+
const ver = doc.verification;
|
|
3932
|
+
if (ver) {
|
|
3933
|
+
const suiteNodes = (ver.testSuites ?? []).map(
|
|
3934
|
+
(ts) => node("testSuite", ts.id, ts.title, fields(["Description", ts.description]))
|
|
3935
|
+
);
|
|
3936
|
+
const caseNodes = (ver.testCases ?? []).map(
|
|
3937
|
+
(tc) => node(
|
|
3938
|
+
"testCase",
|
|
3939
|
+
tc.id,
|
|
3940
|
+
tc.title,
|
|
3941
|
+
fields(
|
|
3942
|
+
["Type", tc.type],
|
|
3943
|
+
["Purpose", tc.purpose],
|
|
3944
|
+
["Steps", tc.steps],
|
|
3945
|
+
["Expected", tc.expected]
|
|
3946
|
+
)
|
|
3947
|
+
)
|
|
3948
|
+
);
|
|
3949
|
+
pushSection("Verification", [], [...suiteNodes, ...caseNodes]);
|
|
3950
|
+
}
|
|
3951
|
+
const edgeNodes = res.edges.map((re) => {
|
|
3952
|
+
const e = re.edge;
|
|
3953
|
+
return node(
|
|
3954
|
+
"edge",
|
|
3955
|
+
e.id,
|
|
3956
|
+
e.id,
|
|
3957
|
+
fields(
|
|
3958
|
+
["Type", e.type],
|
|
3959
|
+
["From", endpointLabel(re.from, titleById)],
|
|
3960
|
+
["To", endpointLabel(re.to, titleById)],
|
|
3961
|
+
["Confidence", e.confidence?.toString()],
|
|
3962
|
+
["Status", e.status],
|
|
3963
|
+
["Created by", e.createdBy],
|
|
3964
|
+
["Created at", e.createdAt],
|
|
3965
|
+
["Tags", e.tags?.join(" ")],
|
|
3966
|
+
["Notes", e.notes]
|
|
3967
|
+
)
|
|
3968
|
+
);
|
|
3969
|
+
});
|
|
3970
|
+
pushSection("Trace", [], edgeNodes);
|
|
3971
|
+
const gov = doc.governance;
|
|
3972
|
+
if (gov) {
|
|
3973
|
+
const issueNodes = (gov.issues ?? []).map(
|
|
3974
|
+
(i) => node(
|
|
3975
|
+
"issue",
|
|
3976
|
+
i.id,
|
|
3977
|
+
i.statement,
|
|
3978
|
+
fields(["Status", i.status], ["Owner", i.owner], ["Notes", i.notes])
|
|
3979
|
+
)
|
|
3980
|
+
);
|
|
3981
|
+
const approvalNodes = (gov.approvals ?? []).map(
|
|
3982
|
+
(a) => node(
|
|
3983
|
+
"approval",
|
|
3984
|
+
a.id,
|
|
3985
|
+
a.role,
|
|
3986
|
+
fields(["Status", a.status], ["Description", a.description])
|
|
3987
|
+
)
|
|
3988
|
+
);
|
|
3989
|
+
pushSection("Governance", [], [...issueNodes, ...approvalNodes]);
|
|
3990
|
+
}
|
|
3991
|
+
const outline = {
|
|
3992
|
+
docId: doc.docId,
|
|
3993
|
+
version: doc.version,
|
|
3994
|
+
status: doc.status,
|
|
3995
|
+
title: meta.title,
|
|
3996
|
+
system: meta.system,
|
|
3997
|
+
sections
|
|
3998
|
+
};
|
|
3999
|
+
if (meta.summary !== void 0) outline.summary = meta.summary;
|
|
4000
|
+
return outline;
|
|
3647
4001
|
}
|
|
3648
|
-
function
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
4002
|
+
function escapeCell(value) {
|
|
4003
|
+
return value.replace(/\|/g, "\\|").replace(/\n/g, " ");
|
|
4004
|
+
}
|
|
4005
|
+
function fieldValue(fields2, label) {
|
|
4006
|
+
return fields2.find((f) => f.label === label)?.value ?? "";
|
|
4007
|
+
}
|
|
4008
|
+
function renderTraceTable(nodes) {
|
|
4009
|
+
const lines = [
|
|
4010
|
+
"| ID | Type | From | To | Status | Confidence |",
|
|
4011
|
+
"| --- | --- | --- | --- | --- | --- |"
|
|
3654
4012
|
];
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
4013
|
+
for (const n of nodes) {
|
|
4014
|
+
const cells = [
|
|
4015
|
+
n.id ?? "",
|
|
4016
|
+
fieldValue(n.fields, "Type"),
|
|
4017
|
+
fieldValue(n.fields, "From"),
|
|
4018
|
+
fieldValue(n.fields, "To"),
|
|
4019
|
+
fieldValue(n.fields, "Status"),
|
|
4020
|
+
fieldValue(n.fields, "Confidence")
|
|
4021
|
+
].map(escapeCell);
|
|
4022
|
+
lines.push(`| ${cells.join(" | ")} |`);
|
|
3661
4023
|
}
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
4024
|
+
return lines;
|
|
4025
|
+
}
|
|
4026
|
+
function renderNode(node, depth, lines) {
|
|
4027
|
+
const heading = "#".repeat(Math.min(depth, 6));
|
|
4028
|
+
const idSuffix = node.id !== void 0 ? ` \`${node.id}\`` : "";
|
|
4029
|
+
lines.push(`${heading} ${node.title}${idSuffix}`);
|
|
4030
|
+
lines.push("");
|
|
4031
|
+
for (const f of node.fields) {
|
|
4032
|
+
lines.push(`- **${f.label}:** ${f.value}`);
|
|
4033
|
+
}
|
|
4034
|
+
if (node.refs && node.refs.length > 0) {
|
|
4035
|
+
for (const r of node.refs) {
|
|
4036
|
+
const title = r.targetTitle !== void 0 ? ` (${r.targetTitle})` : "";
|
|
4037
|
+
const flag = r.resolved ? "" : " [unresolved]";
|
|
4038
|
+
lines.push(`- _${r.relation}_ \u2192 \`${r.targetId}\`${title}${flag}`);
|
|
3671
4039
|
}
|
|
4040
|
+
}
|
|
4041
|
+
if (node.fields.length > 0 || node.refs && node.refs.length > 0) {
|
|
3672
4042
|
lines.push("");
|
|
3673
4043
|
}
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
4044
|
+
for (const child2 of node.children ?? []) {
|
|
4045
|
+
renderNode(child2, depth + 1, lines);
|
|
4046
|
+
}
|
|
4047
|
+
}
|
|
4048
|
+
function outlineToMarkdown(outline, opts = {}) {
|
|
4049
|
+
const includeMetadata = opts.includeMetadata ?? true;
|
|
4050
|
+
const traceAsTable = opts.traceAsTable ?? true;
|
|
4051
|
+
const lines = [];
|
|
4052
|
+
lines.push(`# ${outline.title}`);
|
|
4053
|
+
lines.push("");
|
|
4054
|
+
if (includeMetadata) {
|
|
4055
|
+
lines.push(
|
|
4056
|
+
`- **System:** ${outline.system}`,
|
|
4057
|
+
`- **Document:** ${outline.docId} (v${outline.version}, ${outline.status})`
|
|
4058
|
+
);
|
|
3680
4059
|
lines.push("");
|
|
3681
4060
|
}
|
|
3682
|
-
|
|
4061
|
+
if (outline.summary !== void 0) {
|
|
4062
|
+
lines.push(outline.summary, "");
|
|
4063
|
+
}
|
|
4064
|
+
for (const section of outline.sections) {
|
|
4065
|
+
lines.push(`## ${section.title}`);
|
|
4066
|
+
lines.push("");
|
|
4067
|
+
for (const f of section.fields) {
|
|
4068
|
+
lines.push(`- **${f.label}:** ${f.value}`);
|
|
4069
|
+
}
|
|
4070
|
+
if (section.fields.length > 0) lines.push("");
|
|
4071
|
+
const children = section.children ?? [];
|
|
4072
|
+
const isTrace = traceAsTable && children.length > 0 && children.every((c) => c.kind === "edge");
|
|
4073
|
+
if (isTrace) {
|
|
4074
|
+
lines.push(...renderTraceTable(children));
|
|
4075
|
+
lines.push("");
|
|
4076
|
+
} else {
|
|
4077
|
+
for (const child2 of children) renderNode(child2, 3, lines);
|
|
4078
|
+
}
|
|
4079
|
+
}
|
|
4080
|
+
while (lines.length > 0 && lines[lines.length - 1] === "") lines.pop();
|
|
4081
|
+
return `${lines.join("\n")}
|
|
3683
4082
|
`;
|
|
3684
4083
|
}
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
4084
|
+
function pruneById(node, ids) {
|
|
4085
|
+
if (node.id !== void 0 && ids.has(node.id)) return node;
|
|
4086
|
+
if (node.children) {
|
|
4087
|
+
const kept = node.children.map((c) => pruneById(c, ids)).filter((c) => c !== void 0);
|
|
4088
|
+
if (kept.length > 0) return { ...node, children: kept };
|
|
4089
|
+
}
|
|
4090
|
+
return void 0;
|
|
4091
|
+
}
|
|
4092
|
+
function projectOutline(outline, filter = {}) {
|
|
4093
|
+
let sections = outline.sections;
|
|
4094
|
+
if (filter.sections && filter.sections.length > 0) {
|
|
4095
|
+
const want = new Set(filter.sections.map((s) => s.toLowerCase()));
|
|
4096
|
+
sections = sections.filter((s) => want.has(s.title.toLowerCase()));
|
|
4097
|
+
}
|
|
4098
|
+
if (filter.ids && filter.ids.length > 0) {
|
|
4099
|
+
const ids = new Set(filter.ids);
|
|
4100
|
+
sections = sections.map((s) => pruneById(s, ids)).filter((s) => s !== void 0);
|
|
4101
|
+
}
|
|
4102
|
+
return { ...outline, sections };
|
|
4103
|
+
}
|
|
4104
|
+
var STATUS_VALUES = ["draft", "review", "approved", "deprecated"];
|
|
4105
|
+
function escapeRegExp3(value) {
|
|
4106
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4107
|
+
}
|
|
4108
|
+
function setStatus(xml, request) {
|
|
4109
|
+
if (!STATUS_VALUES.includes(request.status)) {
|
|
4110
|
+
return {
|
|
4111
|
+
ok: false,
|
|
4112
|
+
error: `invalid status "${request.status}" (${STATUS_VALUES.join(" | ")})`
|
|
4113
|
+
};
|
|
4114
|
+
}
|
|
4115
|
+
const parsed = parse(xml);
|
|
4116
|
+
if (!parsed.ok) {
|
|
4117
|
+
return { ok: false, error: `document does not parse: ${parsed.error.message}` };
|
|
4118
|
+
}
|
|
4119
|
+
const ref = declaredIdIndex(parsed.document).get(request.artifactId);
|
|
4120
|
+
if (ref === void 0) {
|
|
4121
|
+
return {
|
|
4122
|
+
ok: false,
|
|
4123
|
+
error: `artifact "${request.artifactId}" is not declared in the document`
|
|
4124
|
+
};
|
|
4125
|
+
}
|
|
4126
|
+
const openTag = new RegExp(
|
|
4127
|
+
`<${escapeRegExp3(ref.kind)}\\b[^>]*\\bid="${escapeRegExp3(request.artifactId)}"[^>]*>`
|
|
4128
|
+
);
|
|
4129
|
+
const match = openTag.exec(xml);
|
|
4130
|
+
if (match === null) {
|
|
4131
|
+
return {
|
|
4132
|
+
ok: false,
|
|
4133
|
+
error: `could not locate the <${ref.kind}> element for "${request.artifactId}" in the document text`
|
|
4134
|
+
};
|
|
4135
|
+
}
|
|
4136
|
+
const tag = match[0];
|
|
4137
|
+
const statusAttr = /\sstatus="([^"]*)"/;
|
|
4138
|
+
const existing = statusAttr.exec(tag);
|
|
4139
|
+
let newTag;
|
|
4140
|
+
let previousStatus;
|
|
4141
|
+
if (existing) {
|
|
4142
|
+
previousStatus = existing[1];
|
|
4143
|
+
if (previousStatus === request.status) return { ok: true, xml, previousStatus };
|
|
4144
|
+
newTag = tag.replace(statusAttr, () => ` status="${request.status}"`);
|
|
4145
|
+
} else {
|
|
4146
|
+
const idAttr = `id="${request.artifactId}"`;
|
|
4147
|
+
newTag = tag.replace(idAttr, () => `${idAttr} status="${request.status}"`);
|
|
4148
|
+
}
|
|
4149
|
+
const updated = xml.slice(0, match.index) + newTag + xml.slice(match.index + tag.length);
|
|
4150
|
+
const before = checkIntegrity(xml).length;
|
|
4151
|
+
const reparsed = parse(updated);
|
|
4152
|
+
if (!reparsed.ok) {
|
|
4153
|
+
return {
|
|
4154
|
+
ok: false,
|
|
4155
|
+
error: `edit produced an unparseable document: ${reparsed.error.message}`
|
|
4156
|
+
};
|
|
4157
|
+
}
|
|
4158
|
+
if (checkIntegrity(updated).length > before) {
|
|
4159
|
+
return {
|
|
4160
|
+
ok: false,
|
|
4161
|
+
error: "edit introduced an integrity violation; document left unchanged"
|
|
4162
|
+
};
|
|
4163
|
+
}
|
|
4164
|
+
return previousStatus !== void 0 ? { ok: true, xml: updated, previousStatus } : { ok: true, xml: updated };
|
|
3727
4165
|
}
|
|
3728
4166
|
var UPWARD_TARGET_KINDS = /* @__PURE__ */ new Set([
|
|
3729
4167
|
"goal",
|
|
@@ -3865,6 +4303,235 @@ function computeCoverage(doc) {
|
|
|
3865
4303
|
function finding(source, rule, message) {
|
|
3866
4304
|
return { source, severity: "warning", rule, message };
|
|
3867
4305
|
}
|
|
4306
|
+
function pathOf(uri) {
|
|
4307
|
+
const hash = uri.indexOf("#");
|
|
4308
|
+
return hash >= 0 ? uri.slice(0, hash) : uri;
|
|
4309
|
+
}
|
|
4310
|
+
function approvalGate(doc, opts = {}) {
|
|
4311
|
+
const cov = computeCoverage(doc);
|
|
4312
|
+
const changed = opts.changedPaths?.filter((p) => p.length > 0);
|
|
4313
|
+
const findings = [];
|
|
4314
|
+
for (const premature of cov.prematureImplementations) {
|
|
4315
|
+
const edge = doc.trace.find((e) => e.id === premature.edgeId);
|
|
4316
|
+
let uri;
|
|
4317
|
+
if (edge) {
|
|
4318
|
+
const external = edge.from.kind !== "local" ? edge.from : edge.to.kind !== "local" ? edge.to : void 0;
|
|
4319
|
+
uri = external?.uri;
|
|
4320
|
+
}
|
|
4321
|
+
if (changed && changed.length > 0) {
|
|
4322
|
+
if (uri === void 0) continue;
|
|
4323
|
+
const p = pathOf(uri);
|
|
4324
|
+
const hit = changed.some((c) => p === c || p.endsWith(c) || c.endsWith(p));
|
|
4325
|
+
if (!hit) continue;
|
|
4326
|
+
}
|
|
4327
|
+
findings.push(
|
|
4328
|
+
uri !== void 0 ? { edgeId: premature.edgeId, requirementId: premature.requirementId, uri } : { edgeId: premature.edgeId, requirementId: premature.requirementId }
|
|
4329
|
+
);
|
|
4330
|
+
}
|
|
4331
|
+
findings.sort((a, b) => a.edgeId.localeCompare(b.edgeId));
|
|
4332
|
+
return { blocked: findings.length > 0, findings };
|
|
4333
|
+
}
|
|
4334
|
+
function endpointKey2(locator) {
|
|
4335
|
+
return locator.kind === "local" ? locator.id : locator.uri;
|
|
4336
|
+
}
|
|
4337
|
+
function details(doc, id, kind) {
|
|
4338
|
+
switch (kind) {
|
|
4339
|
+
case "goal": {
|
|
4340
|
+
const g = doc.goals?.goals?.find((x) => x.id === id);
|
|
4341
|
+
return g ? {
|
|
4342
|
+
title: g.title,
|
|
4343
|
+
statement: g.statement,
|
|
4344
|
+
status: g.status,
|
|
4345
|
+
priority: g.priority,
|
|
4346
|
+
rationale: g.rationale
|
|
4347
|
+
} : {};
|
|
4348
|
+
}
|
|
4349
|
+
case "qgoal": {
|
|
4350
|
+
const g = doc.goals?.qualityGoals?.find((x) => x.id === id);
|
|
4351
|
+
return g ? {
|
|
4352
|
+
title: g.title,
|
|
4353
|
+
statement: g.statement,
|
|
4354
|
+
status: g.status,
|
|
4355
|
+
priority: g.priority,
|
|
4356
|
+
notes: g.metric
|
|
4357
|
+
} : {};
|
|
4358
|
+
}
|
|
4359
|
+
case "obstacle": {
|
|
4360
|
+
const o = doc.goals?.obstacles?.find((x) => x.id === id);
|
|
4361
|
+
return o ? { title: o.title, statement: o.statement, notes: o.mitigation } : {};
|
|
4362
|
+
}
|
|
4363
|
+
case "scenario":
|
|
4364
|
+
case "misuseCase":
|
|
4365
|
+
case "edgeCase": {
|
|
4366
|
+
const all = [
|
|
4367
|
+
...doc.scenarios?.scenarios ?? [],
|
|
4368
|
+
...doc.scenarios?.misuseCases ?? [],
|
|
4369
|
+
...doc.scenarios?.edgeCases ?? []
|
|
4370
|
+
];
|
|
4371
|
+
const s = all.find((x) => x.id === id);
|
|
4372
|
+
return s ? { title: s.title, statement: s.narrative } : {};
|
|
4373
|
+
}
|
|
4374
|
+
case "testCase": {
|
|
4375
|
+
const t = doc.verification?.testCases?.find((x) => x.id === id);
|
|
4376
|
+
return t ? { title: t.title, statement: t.purpose, notes: t.expected } : {};
|
|
4377
|
+
}
|
|
4378
|
+
case "testSuite": {
|
|
4379
|
+
const t = doc.verification?.testSuites?.find((x) => x.id === id);
|
|
4380
|
+
return t ? { title: t.title, statement: t.description } : {};
|
|
4381
|
+
}
|
|
4382
|
+
case "risk": {
|
|
4383
|
+
const r = doc.catalogs?.risks?.find((x) => x.id === id);
|
|
4384
|
+
return r ? { statement: r.statement, notes: r.mitigation } : {};
|
|
4385
|
+
}
|
|
4386
|
+
case "constraint": {
|
|
4387
|
+
const c = doc.catalogs?.constraints?.find((x) => x.id === id);
|
|
4388
|
+
return c ? { statement: c.statement } : {};
|
|
4389
|
+
}
|
|
4390
|
+
case "decision": {
|
|
4391
|
+
const d = doc.catalogs?.decisions?.find((x) => x.id === id);
|
|
4392
|
+
return d ? { statement: d.decision, rationale: d.context, status: d.status } : {};
|
|
4393
|
+
}
|
|
4394
|
+
case "term": {
|
|
4395
|
+
const t = doc.catalogs?.glossary?.find((x) => x.id === id);
|
|
4396
|
+
return t ? { title: t.name, statement: t.definition } : {};
|
|
4397
|
+
}
|
|
4398
|
+
case "rule": {
|
|
4399
|
+
const r = doc.domain?.businessRules?.find((x) => x.id === id);
|
|
4400
|
+
return r ? { statement: r.statement, notes: r.examples } : {};
|
|
4401
|
+
}
|
|
4402
|
+
case "entity": {
|
|
4403
|
+
const e = doc.domain?.entities?.find((x) => x.id === id);
|
|
4404
|
+
return e ? { title: e.name, statement: e.description } : {};
|
|
4405
|
+
}
|
|
4406
|
+
case "stateMachine": {
|
|
4407
|
+
const sm = doc.behavior?.stateMachines?.find((x) => x.id === id);
|
|
4408
|
+
return sm ? { title: sm.name, statement: sm.description } : {};
|
|
4409
|
+
}
|
|
4410
|
+
default:
|
|
4411
|
+
return {};
|
|
4412
|
+
}
|
|
4413
|
+
}
|
|
4414
|
+
function extractArtifact(doc, id) {
|
|
4415
|
+
const idIndex = declaredIdIndex(doc);
|
|
4416
|
+
const ref = idIndex.get(id);
|
|
4417
|
+
if (ref === void 0) return void 0;
|
|
4418
|
+
const slice = { id, kind: ref.kind, edges: [] };
|
|
4419
|
+
const req = requirementIndex(doc).get(id);
|
|
4420
|
+
if (req !== void 0) {
|
|
4421
|
+
slice.title = req.title;
|
|
4422
|
+
slice.statement = req.statement;
|
|
4423
|
+
slice.reqType = req.type;
|
|
4424
|
+
if (req.status !== void 0) slice.status = req.status;
|
|
4425
|
+
if (req.priority !== void 0) slice.priority = req.priority;
|
|
4426
|
+
if (req.rationale !== void 0) slice.rationale = req.rationale;
|
|
4427
|
+
if (req.notes !== void 0) slice.notes = req.notes;
|
|
4428
|
+
if (req.acceptance.length > 0) slice.acceptance = req.acceptance;
|
|
4429
|
+
} else {
|
|
4430
|
+
const extra = Object.fromEntries(
|
|
4431
|
+
Object.entries(details(doc, id, ref.kind)).filter(([, v]) => v !== void 0)
|
|
4432
|
+
);
|
|
4433
|
+
Object.assign(slice, extra);
|
|
4434
|
+
}
|
|
4435
|
+
for (const edge of doc.trace) {
|
|
4436
|
+
const fromKey = endpointKey2(edge.from);
|
|
4437
|
+
const toKey = endpointKey2(edge.to);
|
|
4438
|
+
if (fromKey !== id && toKey !== id) continue;
|
|
4439
|
+
const direction = fromKey === id ? "outgoing" : "incoming";
|
|
4440
|
+
const far = direction === "outgoing" ? edge.to : edge.from;
|
|
4441
|
+
const target = endpointKey2(far);
|
|
4442
|
+
const targetKind = far.kind === "local" ? idIndex.get(target)?.kind ?? "unknown" : far.kind;
|
|
4443
|
+
const sliceEdge = {
|
|
4444
|
+
edgeId: edge.id,
|
|
4445
|
+
type: edge.type,
|
|
4446
|
+
direction,
|
|
4447
|
+
target,
|
|
4448
|
+
targetKind
|
|
4449
|
+
};
|
|
4450
|
+
if (far.kind !== "local" && far.title !== void 0) sliceEdge.title = far.title;
|
|
4451
|
+
slice.edges.push(sliceEdge);
|
|
4452
|
+
}
|
|
4453
|
+
return slice;
|
|
4454
|
+
}
|
|
4455
|
+
function sliceToMarkdown(slice) {
|
|
4456
|
+
const lines = [];
|
|
4457
|
+
const heading = slice.title !== void 0 ? `${slice.id} \u2014 ${slice.title}` : slice.id;
|
|
4458
|
+
lines.push(`## ${heading}`);
|
|
4459
|
+
const facts = [
|
|
4460
|
+
`kind: ${slice.kind}${slice.reqType !== void 0 ? ` (${slice.reqType})` : ""}`
|
|
4461
|
+
];
|
|
4462
|
+
if (slice.status !== void 0) facts.push(`status: ${slice.status}`);
|
|
4463
|
+
if (slice.priority !== void 0) facts.push(`priority: ${slice.priority}`);
|
|
4464
|
+
lines.push(facts.join(" \xB7 "), "");
|
|
4465
|
+
if (slice.statement !== void 0) lines.push(slice.statement.trim(), "");
|
|
4466
|
+
if (slice.rationale !== void 0) {
|
|
4467
|
+
lines.push(`**Rationale:** ${slice.rationale.trim()}`, "");
|
|
4468
|
+
}
|
|
4469
|
+
if (slice.notes !== void 0) lines.push(`**Notes:** ${slice.notes.trim()}`, "");
|
|
4470
|
+
if (slice.acceptance !== void 0 && slice.acceptance.length > 0) {
|
|
4471
|
+
lines.push("### Acceptance");
|
|
4472
|
+
for (const c of slice.acceptance) {
|
|
4473
|
+
const parts = [];
|
|
4474
|
+
if (c.given !== void 0) parts.push(`GIVEN ${c.given.trim()}`);
|
|
4475
|
+
if (c.when !== void 0) parts.push(`WHEN ${c.when.trim()}`);
|
|
4476
|
+
parts.push(`THEN ${c.then.trim()}`);
|
|
4477
|
+
lines.push(`- ${c.id !== void 0 ? `\`${c.id}\` ` : ""}${parts.join(" ")}`);
|
|
4478
|
+
}
|
|
4479
|
+
lines.push("");
|
|
4480
|
+
}
|
|
4481
|
+
if (slice.edges.length > 0) {
|
|
4482
|
+
lines.push("### Trace");
|
|
4483
|
+
for (const e of slice.edges) {
|
|
4484
|
+
const arrow = e.direction === "outgoing" ? "\u2192" : "\u2190";
|
|
4485
|
+
lines.push(`- ${arrow} ${e.type} ${e.target} (${e.targetKind}, \`${e.edgeId}\`)`);
|
|
4486
|
+
}
|
|
4487
|
+
lines.push("");
|
|
4488
|
+
}
|
|
4489
|
+
return `${lines.join("\n").trimEnd()}
|
|
4490
|
+
`;
|
|
4491
|
+
}
|
|
4492
|
+
var SKELETON_KINDS = [
|
|
4493
|
+
"req",
|
|
4494
|
+
"edge",
|
|
4495
|
+
"testCase",
|
|
4496
|
+
"stateMachine"
|
|
4497
|
+
];
|
|
4498
|
+
var TEMPLATES = {
|
|
4499
|
+
req: (id) => `<req id="${id}" type="FR" title="Title" status="draft" priority="must">
|
|
4500
|
+
<statement>The system SHALL ...</statement>
|
|
4501
|
+
<acceptance>
|
|
4502
|
+
<criterion id="${id}-CRIT-1">
|
|
4503
|
+
<given>...</given>
|
|
4504
|
+
<when>...</when>
|
|
4505
|
+
<then>...</then>
|
|
4506
|
+
</criterion>
|
|
4507
|
+
</acceptance>
|
|
4508
|
+
</req>`,
|
|
4509
|
+
edge: (id) => `<edge id="${id}" type="satisfies">
|
|
4510
|
+
<from><locator><local id="REQ-AREA-001"/></locator></from>
|
|
4511
|
+
<to><locator><local id="GOAL-NAME"/></locator></to>
|
|
4512
|
+
</edge>`,
|
|
4513
|
+
testCase: (id) => `<testCase id="${id}" type="unit" title="Title">
|
|
4514
|
+
<purpose>...</purpose>
|
|
4515
|
+
<steps>...</steps>
|
|
4516
|
+
<expected>...</expected>
|
|
4517
|
+
</testCase>`,
|
|
4518
|
+
stateMachine: (id) => `<stateMachine id="${id}" name="Name" initial="ST-START">
|
|
4519
|
+
<state id="ST-START" name="Start" type="initial"/>
|
|
4520
|
+
<state id="ST-DONE" name="Done" type="final"/>
|
|
4521
|
+
<transition id="TR-FINISH" from="ST-START" to="ST-DONE" event="finish"/>
|
|
4522
|
+
</stateMachine>`
|
|
4523
|
+
};
|
|
4524
|
+
var DEFAULT_IDS = {
|
|
4525
|
+
req: "REQ-AREA-001",
|
|
4526
|
+
edge: "E-AREA-001",
|
|
4527
|
+
testCase: "TC-NAME",
|
|
4528
|
+
stateMachine: "SM-NAME"
|
|
4529
|
+
};
|
|
4530
|
+
function skeleton(kind, options = {}) {
|
|
4531
|
+
const template = TEMPLATES[kind];
|
|
4532
|
+
return `${template(options.id ?? DEFAULT_IDS[kind])}
|
|
4533
|
+
`;
|
|
4534
|
+
}
|
|
3868
4535
|
function refFromEndpoint(ep, titleById) {
|
|
3869
4536
|
const loc = ep.locator;
|
|
3870
4537
|
if (loc.kind === "local") {
|
|
@@ -4092,17 +4759,6 @@ function detectDrift(doc, options = {}) {
|
|
|
4092
4759
|
}
|
|
4093
4760
|
return { links, drifted, diagnostics };
|
|
4094
4761
|
}
|
|
4095
|
-
|
|
4096
|
-
// src/report.ts
|
|
4097
|
-
function formatDiagnostic(d) {
|
|
4098
|
-
const loc = d.line !== void 0 ? `:${d.line}${d.column !== void 0 ? `:${d.column}` : ""}` : "";
|
|
4099
|
-
const rule = d.rule !== void 0 ? ` [${d.rule}]` : "";
|
|
4100
|
-
return ` ${d.severity}${loc} (${d.source})${rule}: ${d.message}`;
|
|
4101
|
-
}
|
|
4102
|
-
function printDiagnostics(diags) {
|
|
4103
|
-
for (const d of diags) process.stdout.write(`${formatDiagnostic(d)}
|
|
4104
|
-
`);
|
|
4105
|
-
}
|
|
4106
4762
|
var EXIT = {
|
|
4107
4763
|
OK: 0,
|
|
4108
4764
|
/** The document is not well-formed, schema-invalid, or fails integrity. */
|
|
@@ -4181,6 +4837,46 @@ function readSpec(args) {
|
|
|
4181
4837
|
return { path, xml: readFileSync(path, "utf8") };
|
|
4182
4838
|
}
|
|
4183
4839
|
|
|
4840
|
+
// src/commands/approve.ts
|
|
4841
|
+
async function runApprove(rest) {
|
|
4842
|
+
const args = parseArgs(rest);
|
|
4843
|
+
const id = args.positionals[0];
|
|
4844
|
+
if (id === void 0) {
|
|
4845
|
+
throw new UsageError("usage: rqml approve <id> [--status approved] [--spec <path>]");
|
|
4846
|
+
}
|
|
4847
|
+
const { path, xml } = readSpec(specArgs(args));
|
|
4848
|
+
const status = flagString(args, "status") ?? "approved";
|
|
4849
|
+
const result = setStatus(xml, { artifactId: id, status });
|
|
4850
|
+
if (!result.ok) {
|
|
4851
|
+
process.stderr.write(`\u2717 ${result.error}
|
|
4852
|
+
`);
|
|
4853
|
+
return EXIT.VALIDATION;
|
|
4854
|
+
}
|
|
4855
|
+
writeFileSync(path, result.xml);
|
|
4856
|
+
if (args.json) {
|
|
4857
|
+
const out = { ok: true, id, status, previousStatus: result.previousStatus ?? null };
|
|
4858
|
+
process.stdout.write(`${JSON.stringify(out, null, 2)}
|
|
4859
|
+
`);
|
|
4860
|
+
} else {
|
|
4861
|
+
process.stdout.write(
|
|
4862
|
+
`\u2713 ${id}: ${result.previousStatus ?? "(unset)"} \u2192 ${status} in ${path}
|
|
4863
|
+
`
|
|
4864
|
+
);
|
|
4865
|
+
}
|
|
4866
|
+
return EXIT.OK;
|
|
4867
|
+
}
|
|
4868
|
+
|
|
4869
|
+
// src/report.ts
|
|
4870
|
+
function formatDiagnostic(d) {
|
|
4871
|
+
const loc = d.line !== void 0 ? `:${d.line}${d.column !== void 0 ? `:${d.column}` : ""}` : "";
|
|
4872
|
+
const rule = d.rule !== void 0 ? ` [${d.rule}]` : "";
|
|
4873
|
+
return ` ${d.severity}${loc} (${d.source})${rule}: ${d.message}`;
|
|
4874
|
+
}
|
|
4875
|
+
function printDiagnostics(diags) {
|
|
4876
|
+
for (const d of diags) process.stdout.write(`${formatDiagnostic(d)}
|
|
4877
|
+
`);
|
|
4878
|
+
}
|
|
4879
|
+
|
|
4184
4880
|
// src/commands/check.ts
|
|
4185
4881
|
function coverageBlocks(strictness) {
|
|
4186
4882
|
return strictness === "strict" || strictness === "certified";
|
|
@@ -4240,6 +4936,39 @@ async function runCheck(rest) {
|
|
|
4240
4936
|
return EXIT.OK;
|
|
4241
4937
|
}
|
|
4242
4938
|
|
|
4939
|
+
// src/commands/gate.ts
|
|
4940
|
+
function list(value) {
|
|
4941
|
+
if (value === void 0) return void 0;
|
|
4942
|
+
const items = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
4943
|
+
return items.length > 0 ? items : void 0;
|
|
4944
|
+
}
|
|
4945
|
+
async function runGate(rest) {
|
|
4946
|
+
const args = parseArgs(rest);
|
|
4947
|
+
const { path, xml } = readSpec(specArgs(args));
|
|
4948
|
+
const parsed = parse(xml);
|
|
4949
|
+
if (!parsed.ok) {
|
|
4950
|
+
process.stderr.write(`\u2717 ${path}: ${parsed.error.message}
|
|
4951
|
+
`);
|
|
4952
|
+
return EXIT.VALIDATION;
|
|
4953
|
+
}
|
|
4954
|
+
const changed = list(flagString(args, "changed")) ?? (args.positionals.length > 0 ? args.positionals : void 0);
|
|
4955
|
+
const verdict = approvalGate(parsed.document, changed ? { changedPaths: changed } : {});
|
|
4956
|
+
if (args.json) {
|
|
4957
|
+
process.stdout.write(`${JSON.stringify(verdict, null, 2)}
|
|
4958
|
+
`);
|
|
4959
|
+
} else if (verdict.findings.length === 0) {
|
|
4960
|
+
process.stdout.write("\u2713 no implementation linked to a non-approved requirement\n");
|
|
4961
|
+
} else {
|
|
4962
|
+
for (const f of verdict.findings) {
|
|
4963
|
+
process.stdout.write(
|
|
4964
|
+
`\u2717 ${f.uri ?? f.edgeId} implements ${f.requirementId}, which is not approved
|
|
4965
|
+
`
|
|
4966
|
+
);
|
|
4967
|
+
}
|
|
4968
|
+
}
|
|
4969
|
+
return verdict.blocked ? EXIT.CHECK : EXIT.OK;
|
|
4970
|
+
}
|
|
4971
|
+
|
|
4243
4972
|
// src/commands/impact.ts
|
|
4244
4973
|
async function runImpact(rest) {
|
|
4245
4974
|
const args = parseArgs(rest);
|
|
@@ -4287,7 +5016,7 @@ async function runImpact(rest) {
|
|
|
4287
5016
|
}
|
|
4288
5017
|
|
|
4289
5018
|
// ../schema/dist/index.js
|
|
4290
|
-
var AGENTS_default = '# RQML Agent Guidelines\n\n## Strictness: `standard`\n\n| Level | Description |\n|-------|-------------|\n| `relaxed` | Prototyping. Spec is advisory. Quick iteration allowed. |\n| `standard` | Production default. Spec-first for features. Core traces. |\n| `strict` | Full traceability. All behavior specified. No ghost features. |\n| `certified` | Regulated/safety-critical. Audit-grade traces with metadata. |\n\n---\n\nThis project uses **RQML** as the single source of truth for system intent. Familiarize yourself with the documentation at https://rqml.org/docs/user-guide/ and the development process at https://rqml.org/docs/development-process/\n\n**Specification file:** Specification lives in a single .rqml file in the root of the project - convention is `requirements.rqml`. Multiple .rqml files may be employed in multirepo projects, in such cases a .rqml spec applies to everything that is higher in the project tree, unless overridden by another .rqml file.\n\n**Schema file:**\nThe RQML XSD schema is at https://rqml.org/schema/rqml-2.1.0.xsd (insert correct version number). Make sure to adhere to the schema at all times and follow guidelines in schema comments. Use as much of the RQML tagset as is necessary to capture and describe high quality requirements.\n\n---\n\n## Toolchain\n\nThe spec-first loop is enforced by the `rqml` CLI (npm: `@rqml/cli`; the `@rqml/mcp` server exposes the same engine as agent tools):\n\n```bash\nrqml check # deterministic gate: validation + coverage + drift (exit 0 = pass)\nrqml status # re-anchor: spec, coverage, and drift state\nrqml show <REQ-ID> # one requirement: statement, acceptance criteria, trace neighborhood\nrqml impact <ID> # what is affected, transitively, if this artifact changes\nrqml matrix # traceability matrix: status, goals, code, tests, coverage gaps\nrqml link <REQ-ID> <path> # record an implements edge + drift baseline (--type verifiedBy for tests)\nrqml skeleton <kind> # schema-valid snippet: req | edge | testCase | stateMachine\n```\n\nRun `rqml status` when you start a session to re-anchor on the spec. Run `rqml check` before finishing any task \u2014 it must exit 0.\n\n---\n\n## Core Principle: Spec-First Development\n\nCode follows specification, not the reverse. If code and spec diverge, the spec is authoritative\u2014update the code or negotiate a spec change with the developer.\n\nRQML organizes work into a **five-stage process** (https://rqml.org/docs/development-process/). Each stage produces a durable artifact in version control; verification feeds back to the spec, so it is a loop:\n\n| Stage | Task | Output |\n|-------|------|--------|\n| **Spec** | Capture intent as requirements | `requirements.rqml` |\n| **Design** | Decide architecture, record decisions | ADRs in `.rqml/adr/` |\n| **Plan** | Break work into agent-sized stages | `.rqml/plan.md` |\n| **Code** | Implement specified behavior, keep traces current | code + tests |\n| **Verify** | Prove coverage and catch drift | trace graph + `rqml check` |\n\nNever skip ahead: do not implement behavior that is not specified, and do not make a significant architectural choice without recording it as an ADR.\n\n---\n\n## Workflow\n\n### 1. Spec\nAsk clarifying questions until you understand the goal, scope, acceptance criteria, and constraints. Don\'t assume\u2014capture assumptions as `<notes>` or `<issue>` elements. **Never implement unspecified behavior.** Update the `.rqml` file before coding:\n- Add a `<req>` with statement and acceptance criteria\n- Set appropriate `type`, `priority`, and `status="draft"`\n- Get developer confirmation; only `status="approved"` requirements drive implementation\n\n### 2. Design\nBefore building, decide *how*. Record each significant architectural decision as an **Architecture Decision Record (ADR)** in `.rqml/adr/`, following the canonical format (https://rqml.org/docs/development-process/design): `NNNN-kebab-case-slug.md`, with Status, Classification, Context, Options considered, Decision, and Consequences. A decision is ADR-worthy when there are real alternatives or the choice constrains future work; skip ADRs for low-level implementation details. ADRs are immutable once accepted\u2014supersede, don\'t edit.\n\n### 3. Plan\nBreak approved requirements into a staged implementation plan at `.rqml/plan.md`, framed for coding agents: each stage names its goal, the requirement IDs it addresses, the files it touches, and how to verify it.\n\n### 4. Code (Implement)\nRead the requirement first: `rqml show REQ-XXX`. Check blast radius before changing existing artifacts: `rqml impact REQ-XXX`. Honor the ADRs. If you discover missing requirements, stop and add them to the spec first. After implementing, record the trace link:\n\n```bash\nrqml link REQ-XXX src/path/to/implementation.ts\n```\n\n### 5. Verify\nAdd tests that reference requirement IDs, then record verification and run the gate:\n\n```bash\nrqml link REQ-XXX test/path/to/test.ts --type verifiedBy\nrqml check # must exit 0 before you are done\n```\n\n---\n\n## When Code and Spec Diverge\n\n1. **Spec gap** (code has behavior not in spec): Propose adding the requirement, mark as `status="review"`\n2. **Code bug** (code doesn\'t match spec): Fix the code\n3. **Spec bug** (spec is wrong): Propose correction, wait for developer confirmation\n\n**Never silently change the spec to match code.**\n\n---\n\n## Strictness Reference\n\n| Aspect | relaxed | standard | strict | certified |\n|--------|---------|----------|--------|-----------|\n| Spec (elicitation) | Major features | Testable reqs | Edge cases | Formal |\n| Spec-first | Recommended | Required | Required | Approved first |\n| Design (ADRs) | Optional | Significant choices | All architectural choices | With approval |\n| Plan | Optional | For multi-stage work | Required | Required |\n| Code traces | Optional | New features | All changes | With metadata |\n| Verify (test traces) | Optional | New reqs | All reqs | Full matrix |\n| Ghost features | Allowed | Blocked | Blocked | Blocked |\n\n---\n\n## Change Summary Template\n\nFor PRs and commits:\n\n```\n## RQML Trace Summary\n\n**Requirements:** REQ-xxx (added/modified/implemented)\n**Design:** ADR-xxxx \u2014 decision recorded (if any)\n**Implementation:** `path/to/file` \u2014 what changed\n**Verification:** `path/to/test` \u2014 what it verifies\n**Open items:** gaps, assumptions, follow-ups\n```\n\n---\n\n## Schema Validation\n\nThe `.rqml` file must remain valid XML conforming to the version of RQML referenced in the version attribute in the spec document.\n\n**To validate:** Use the toolchain \u2014 it validates offline against the bundled schema and also checks referential integrity the XSD alone cannot enforce:\n```bash\nrqml validate\n```\n\nIf the `rqml` CLI is not installed, `npx @rqml/cli validate` works without installation. As a last resort, xmllint (pre-installed on macOS/Linux) checks XSD validity only:\n```bash\nxmllint --schema https://rqml.org/schema/rqml-2.1.0.xsd <rqml-file-name> --noout\n```\n\n**IDE validation:** If the `.rqml` file includes `xsi:schemaLocation`, XML-aware editors (VS Code with XML extension, IntelliJ) validate automatically.\n\nThe schema comments contain detailed guidance on document structure, ID conventions, and requirement quality criteria.\n\n**If unsure:** Ask the developer before making structural changes to the spec.\n';
|
|
5019
|
+
var AGENTS_default = '# RQML Agent Guidelines\n\n## Strictness: `standard`\n\n| Level | Description |\n|-------|-------------|\n| `relaxed` | Prototyping. Spec is advisory. Quick iteration allowed. |\n| `standard` | Production default. Spec-first for features. Core traces. |\n| `strict` | Full traceability. All behavior specified. No ghost features. |\n| `certified` | Regulated/safety-critical. Audit-grade traces with metadata. |\n\n---\n\nThis project uses **RQML** as the single source of truth for system intent. Familiarize yourself with the documentation at https://rqml.org/docs/user-guide/ and the development process at https://rqml.org/docs/development-process/\n\n**Specification file:** Specification lives in a single .rqml file in the root of the project - convention is `requirements.rqml`. Multiple .rqml files may be employed in multirepo projects, in such cases a .rqml spec applies to everything that is higher in the project tree, unless overridden by another .rqml file.\n\n**Schema file:**\nThe RQML XSD schema is at https://rqml.org/schema/rqml-2.1.0.xsd (insert correct version number). Make sure to adhere to the schema at all times and follow guidelines in schema comments. Use as much of the RQML tagset as is necessary to capture and describe high quality requirements.\n\n---\n\n## Toolchain\n\nThe spec-first loop is enforced by the `rqml` CLI (npm: `@rqml/cli`; the `@rqml/mcp` server exposes the same engine as agent tools):\n\n```bash\nrqml check # deterministic gate: validation + coverage + drift (exit 0 = pass)\nrqml status # re-anchor: spec, coverage, and drift state\nrqml show <REQ-ID> # one requirement: statement, acceptance criteria, trace neighborhood\nrqml impact <ID> # what is affected, transitively, if this artifact changes\nrqml overview # readable projection of the spec (--section/--id to scope)\nrqml matrix # traceability matrix: status, goals, code, tests, coverage gaps\nrqml link <REQ-ID> <path> # record an implements edge + drift baseline (--type verifiedBy for tests)\nrqml approve <REQ-ID> # transition a requirement\'s status (default approved)\nrqml gate # block implementation of non-approved requirements\nrqml skeleton <kind> # schema-valid snippet: req | edge | testCase | stateMachine\n```\n\nRun `rqml status` when you start a session to re-anchor on the spec. Run `rqml check` before finishing any task \u2014 it must exit 0.\n\n---\n\n## Core Principle: Spec-First Development\n\nCode follows specification, not the reverse. If code and spec diverge, the spec is authoritative\u2014update the code or negotiate a spec change with the developer.\n\nRQML organizes work into a **five-stage process** (https://rqml.org/docs/development-process/). Each stage produces a durable artifact in version control; verification feeds back to the spec, so it is a loop:\n\n| Stage | Task | Output |\n|-------|------|--------|\n| **Spec** | Capture intent as requirements | `requirements.rqml` |\n| **Design** | Decide architecture, record decisions | ADRs in `.rqml/adr/` |\n| **Plan** | Break work into agent-sized stages | `.rqml/plan.md` |\n| **Code** | Implement specified behavior, keep traces current | code + tests |\n| **Verify** | Prove coverage and catch drift | trace graph + `rqml check` |\n\nNever skip ahead: do not implement behavior that is not specified, and do not make a significant architectural choice without recording it as an ADR.\n\n---\n\n## Workflow\n\n### 1. Spec\nAsk clarifying questions until you understand the goal, scope, acceptance criteria, and constraints. Don\'t assume\u2014capture assumptions as `<notes>` or `<issue>` elements. **Never implement unspecified behavior.** Update the `.rqml` file before coding:\n- Add a `<req>` with statement and acceptance criteria\n- Set appropriate `type`, `priority`, and `status="draft"`\n- Get developer confirmation; only `status="approved"` requirements drive implementation\n\n### 2. Design\nBefore building, decide *how*. Record each significant architectural decision as an **Architecture Decision Record (ADR)** in `.rqml/adr/`, following the canonical format (https://rqml.org/docs/development-process/design): `NNNN-kebab-case-slug.md`, with Status, Classification, Context, Options considered, Decision, and Consequences. A decision is ADR-worthy when there are real alternatives or the choice constrains future work; skip ADRs for low-level implementation details. ADRs are immutable once accepted\u2014supersede, don\'t edit.\n\n### 3. Plan\nBreak approved requirements into a staged implementation plan at `.rqml/plan.md`, framed for coding agents: each stage names its goal, the requirement IDs it addresses, the files it touches, and how to verify it.\n\n### 4. Code (Implement)\nRead the requirement first: `rqml show REQ-XXX`. Check blast radius before changing existing artifacts: `rqml impact REQ-XXX`. Honor the ADRs. If you discover missing requirements, stop and add them to the spec first. After implementing, record the trace link:\n\n```bash\nrqml link REQ-XXX src/path/to/implementation.ts\n```\n\n### 5. Verify\nAdd tests that reference requirement IDs, then record verification and run the gate:\n\n```bash\nrqml link REQ-XXX test/path/to/test.ts --type verifiedBy\nrqml check # must exit 0 before you are done\n```\n\n---\n\n## When Code and Spec Diverge\n\n1. **Spec gap** (code has behavior not in spec): Propose adding the requirement, mark as `status="review"`\n2. **Code bug** (code doesn\'t match spec): Fix the code\n3. **Spec bug** (spec is wrong): Propose correction, wait for developer confirmation\n\n**Never silently change the spec to match code.**\n\n---\n\n## Strictness Reference\n\n| Aspect | relaxed | standard | strict | certified |\n|--------|---------|----------|--------|-----------|\n| Spec (elicitation) | Major features | Testable reqs | Edge cases | Formal |\n| Spec-first | Recommended | Required | Required | Approved first |\n| Design (ADRs) | Optional | Significant choices | All architectural choices | With approval |\n| Plan | Optional | For multi-stage work | Required | Required |\n| Code traces | Optional | New features | All changes | With metadata |\n| Verify (test traces) | Optional | New reqs | All reqs | Full matrix |\n| Ghost features | Allowed | Blocked | Blocked | Blocked |\n\n---\n\n## Change Summary Template\n\nFor PRs and commits:\n\n```\n## RQML Trace Summary\n\n**Requirements:** REQ-xxx (added/modified/implemented)\n**Design:** ADR-xxxx \u2014 decision recorded (if any)\n**Implementation:** `path/to/file` \u2014 what changed\n**Verification:** `path/to/test` \u2014 what it verifies\n**Open items:** gaps, assumptions, follow-ups\n```\n\n---\n\n## Schema Validation\n\nThe `.rqml` file must remain valid XML conforming to the version of RQML referenced in the version attribute in the spec document.\n\n**To validate:** Use the toolchain \u2014 it validates offline against the bundled schema and also checks referential integrity the XSD alone cannot enforce:\n```bash\nrqml validate\n```\n\nIf the `rqml` CLI is not installed, `npx @rqml/cli validate` works without installation. As a last resort, xmllint (pre-installed on macOS/Linux) checks XSD validity only:\n```bash\nxmllint --schema https://rqml.org/schema/rqml-2.1.0.xsd <rqml-file-name> --noout\n```\n\n**IDE validation:** If the `.rqml` file includes `xsi:schemaLocation`, XML-aware editors (VS Code with XML extension, IntelliJ) validate automatically.\n\nThe schema comments contain detailed guidance on document structure, ID conventions, and requirement quality criteria.\n\n**If unsure:** Ask the developer before making structural changes to the spec.\n';
|
|
4291
5020
|
var AGENTS_TEMPLATE = AGENTS_default;
|
|
4292
5021
|
|
|
4293
5022
|
// src/commands/init.ts
|
|
@@ -4441,7 +5170,7 @@ function runRefresh(args, edgeId) {
|
|
|
4441
5170
|
}
|
|
4442
5171
|
|
|
4443
5172
|
// src/commands/matrix.ts
|
|
4444
|
-
function
|
|
5173
|
+
function list2(value) {
|
|
4445
5174
|
if (value === void 0) return void 0;
|
|
4446
5175
|
const items = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
4447
5176
|
return items.length > 0 ? items : void 0;
|
|
@@ -4455,9 +5184,9 @@ async function runMatrix(rest) {
|
|
|
4455
5184
|
`);
|
|
4456
5185
|
return EXIT.VALIDATION;
|
|
4457
5186
|
}
|
|
4458
|
-
const status =
|
|
4459
|
-
const type =
|
|
4460
|
-
const warning =
|
|
5187
|
+
const status = list2(flagString(args, "status"));
|
|
5188
|
+
const type = list2(flagString(args, "type"));
|
|
5189
|
+
const warning = list2(flagString(args, "warning"));
|
|
4461
5190
|
const filter = {};
|
|
4462
5191
|
if (status) filter.status = status;
|
|
4463
5192
|
if (type) filter.type = type;
|
|
@@ -4471,6 +5200,34 @@ async function runMatrix(rest) {
|
|
|
4471
5200
|
return EXIT.OK;
|
|
4472
5201
|
}
|
|
4473
5202
|
|
|
5203
|
+
// src/commands/overview.ts
|
|
5204
|
+
function list3(value) {
|
|
5205
|
+
if (value === void 0) return void 0;
|
|
5206
|
+
const items = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
5207
|
+
return items.length > 0 ? items : void 0;
|
|
5208
|
+
}
|
|
5209
|
+
async function runOverview(rest) {
|
|
5210
|
+
const args = parseArgs(rest);
|
|
5211
|
+
const { path, xml } = readSpec(args);
|
|
5212
|
+
const parsed = parse(xml);
|
|
5213
|
+
if (!parsed.ok) {
|
|
5214
|
+
process.stderr.write(`\u2717 ${path}: ${parsed.error.message}
|
|
5215
|
+
`);
|
|
5216
|
+
return EXIT.VALIDATION;
|
|
5217
|
+
}
|
|
5218
|
+
const filter = {};
|
|
5219
|
+
const sections = list3(flagString(args, "section"));
|
|
5220
|
+
const ids = list3(flagString(args, "id"));
|
|
5221
|
+
if (sections) filter.sections = sections;
|
|
5222
|
+
if (ids) filter.ids = ids;
|
|
5223
|
+
const outline = projectOutline(buildOutline(parsed.document), filter);
|
|
5224
|
+
process.stdout.write(
|
|
5225
|
+
args.json ? `${JSON.stringify(outline, null, 2)}
|
|
5226
|
+
` : outlineToMarkdown(outline)
|
|
5227
|
+
);
|
|
5228
|
+
return EXIT.OK;
|
|
5229
|
+
}
|
|
5230
|
+
|
|
4474
5231
|
// src/commands/show.ts
|
|
4475
5232
|
async function runShow(rest) {
|
|
4476
5233
|
const args = parseArgs(rest);
|
|
@@ -4602,13 +5359,18 @@ Commands:
|
|
|
4602
5359
|
(--update repoints an existing edge; --refresh <edge-id>
|
|
4603
5360
|
re-records only the baseline for an intentional change)
|
|
4604
5361
|
show <id> Extract one artifact with its trace neighborhood
|
|
5362
|
+
overview [path] Readable spec projection (whole, or --section/--id scoped)
|
|
4605
5363
|
impact <id> What is affected, transitively, if this artifact changes
|
|
4606
5364
|
matrix [path] Traceability matrix: status, goals, code, tests, warnings
|
|
5365
|
+
approve <id> Transition a requirement's status (--status, default approved)
|
|
5366
|
+
gate [paths...] Block implementation of non-approved requirements (exit 2)
|
|
4607
5367
|
skeleton <kind> Print a schema-valid snippet (req|edge|testCase|stateMachine)
|
|
4608
5368
|
|
|
4609
5369
|
Options:
|
|
4610
|
-
--json Emit machine-readable JSON (
|
|
4611
|
-
--
|
|
5370
|
+
--json Emit machine-readable JSON (reporting commands)
|
|
5371
|
+
--section, --id Scope overview (comma-separated section titles or element ids)
|
|
5372
|
+
--status, --type, --warning Filter matrix rows; for approve, --status sets the target (default approved)
|
|
5373
|
+
--changed <paths> Scope gate to changed paths (or pass paths as positionals)
|
|
4612
5374
|
--strictness <level> relaxed | standard | strict | certified (default: standard)
|
|
4613
5375
|
--base-dir <dir> Directory to resolve the spec and code links against
|
|
4614
5376
|
--spec <path> Explicit spec file (link, show, impact)
|
|
@@ -4642,6 +5404,12 @@ async function main(argv) {
|
|
|
4642
5404
|
return runImpact(rest);
|
|
4643
5405
|
case "matrix":
|
|
4644
5406
|
return runMatrix(rest);
|
|
5407
|
+
case "overview":
|
|
5408
|
+
return runOverview(rest);
|
|
5409
|
+
case "approve":
|
|
5410
|
+
return runApprove(rest);
|
|
5411
|
+
case "gate":
|
|
5412
|
+
return runGate(rest);
|
|
4645
5413
|
case "skeleton":
|
|
4646
5414
|
return runSkeleton(rest);
|
|
4647
5415
|
case "-v":
|