arkaik-mcp 0.2.2 → 0.2.3
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/LICENSE +21 -0
- package/dist/index.js +507 -46
- package/package.json +3 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alexis Bohns
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -14632,7 +14632,7 @@ function date4(params) {
|
|
|
14632
14632
|
config(en_default());
|
|
14633
14633
|
|
|
14634
14634
|
// ../schema/src/ids.ts
|
|
14635
|
-
var SPECIES_IDS = ["flow", "view", "data-model", "api-endpoint", "acceptance"];
|
|
14635
|
+
var SPECIES_IDS = ["flow", "view", "data-model", "api-endpoint", "acceptance", "decision"];
|
|
14636
14636
|
var STATUS_IDS = [
|
|
14637
14637
|
"idea",
|
|
14638
14638
|
"discovery",
|
|
@@ -14643,7 +14643,7 @@ var STATUS_IDS = [
|
|
|
14643
14643
|
"archived"
|
|
14644
14644
|
];
|
|
14645
14645
|
var PLATFORM_IDS = ["web", "ios", "android"];
|
|
14646
|
-
var EDGE_TYPE_IDS = ["composes", "calls", "displays", "queries", "covers"];
|
|
14646
|
+
var EDGE_TYPE_IDS = ["composes", "calls", "displays", "queries", "covers", "supersedes", "generates", "impacts"];
|
|
14647
14647
|
var VALID_EDGE_SEMANTICS = {
|
|
14648
14648
|
composes: [
|
|
14649
14649
|
["flow", "view"],
|
|
@@ -14670,6 +14670,18 @@ var VALID_EDGE_SEMANTICS = {
|
|
|
14670
14670
|
covers: [
|
|
14671
14671
|
["acceptance", "view"],
|
|
14672
14672
|
["acceptance", "flow"]
|
|
14673
|
+
],
|
|
14674
|
+
// Decision edges (cycle 2). `generates` and `impacts` are deliberately
|
|
14675
|
+
// disjoint: an acceptance is *generated* by a decision, never merely
|
|
14676
|
+
// impacted, so `impacts` does not admit an acceptance target
|
|
14677
|
+
// (docs/superpowers/specs/2026-08-03-decisions-species-design.md §3).
|
|
14678
|
+
supersedes: [["decision", "decision"]],
|
|
14679
|
+
generates: [["decision", "acceptance"]],
|
|
14680
|
+
impacts: [
|
|
14681
|
+
["decision", "flow"],
|
|
14682
|
+
["decision", "view"],
|
|
14683
|
+
["decision", "data-model"],
|
|
14684
|
+
["decision", "api-endpoint"]
|
|
14673
14685
|
]
|
|
14674
14686
|
};
|
|
14675
14687
|
var VALUE_TIER_IDS = ["functional", "emotional", "life-changing", "social-impact"];
|
|
@@ -14782,6 +14794,34 @@ function migrateStatusVocabulary(bundle) {
|
|
|
14782
14794
|
return { ...bundle, schema_version: STATUS_VOCABULARY_VERSION, nodes };
|
|
14783
14795
|
}
|
|
14784
14796
|
|
|
14797
|
+
// ../schema/src/decision.ts
|
|
14798
|
+
var DECISION_STATUS_IDS = [
|
|
14799
|
+
"proposed",
|
|
14800
|
+
"approved",
|
|
14801
|
+
"enacted",
|
|
14802
|
+
"rejected",
|
|
14803
|
+
"deprecated",
|
|
14804
|
+
"superseded"
|
|
14805
|
+
];
|
|
14806
|
+
function lifecycleStatusForDecision(decisionStatus) {
|
|
14807
|
+
switch (decisionStatus) {
|
|
14808
|
+
case "proposed":
|
|
14809
|
+
return "discovery";
|
|
14810
|
+
case "approved":
|
|
14811
|
+
return "backlog";
|
|
14812
|
+
case "enacted":
|
|
14813
|
+
return "live";
|
|
14814
|
+
case "rejected":
|
|
14815
|
+
case "deprecated":
|
|
14816
|
+
case "superseded":
|
|
14817
|
+
return "archived";
|
|
14818
|
+
}
|
|
14819
|
+
}
|
|
14820
|
+
function decisionStatusOf(node) {
|
|
14821
|
+
const raw = node.metadata?.decision_status;
|
|
14822
|
+
return DECISION_STATUS_IDS.includes(raw) ? raw : "proposed";
|
|
14823
|
+
}
|
|
14824
|
+
|
|
14785
14825
|
// ../schema/src/enums.ts
|
|
14786
14826
|
var SpeciesSchema = external_exports.enum(SPECIES_IDS).meta({
|
|
14787
14827
|
id: "Species",
|
|
@@ -14811,6 +14851,10 @@ var ValueSchema = external_exports.enum(VALUE_IDS).meta({
|
|
|
14811
14851
|
id: "Value",
|
|
14812
14852
|
description: "A Bain B2C Elements-of-Value element served by an acceptance (spec \xA73.2)."
|
|
14813
14853
|
});
|
|
14854
|
+
var DecisionStatusSchema = external_exports.enum(DECISION_STATUS_IDS).meta({
|
|
14855
|
+
id: "DecisionStatus",
|
|
14856
|
+
description: "Decision nodes only: proposed \u2192 approved (agreed, not yet reality) \u2192 enacted (in effect); terminal: rejected, deprecated, superseded. Not a lifecycle status \u2014 the node's status field is kept in sync (proposed\u2192discovery, approved\u2192backlog, enacted\u2192live, terminals\u2192archived)."
|
|
14857
|
+
});
|
|
14814
14858
|
|
|
14815
14859
|
// ../schema/src/id-gen.ts
|
|
14816
14860
|
var SPECIES_PREFIXES = {
|
|
@@ -14818,7 +14862,8 @@ var SPECIES_PREFIXES = {
|
|
|
14818
14862
|
view: "V-",
|
|
14819
14863
|
"data-model": "DM-",
|
|
14820
14864
|
"api-endpoint": "API-",
|
|
14821
|
-
acceptance: "AC-"
|
|
14865
|
+
acceptance: "AC-",
|
|
14866
|
+
decision: "DEC-"
|
|
14822
14867
|
};
|
|
14823
14868
|
function kebabCase(input) {
|
|
14824
14869
|
return input.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -14959,6 +15004,7 @@ function parseJournalLines(text) {
|
|
|
14959
15004
|
var NODE_REF_FIELDS = {
|
|
14960
15005
|
"node.updated": ["node_id"],
|
|
14961
15006
|
"node.status_changed": ["node_id"],
|
|
15007
|
+
"decision.status_changed": ["node_id"],
|
|
14962
15008
|
"node.deleted": ["node_id"],
|
|
14963
15009
|
"edge.added": ["source_id", "target_id"],
|
|
14964
15010
|
"ref.added": ["node_id"],
|
|
@@ -14991,9 +15037,15 @@ function crossCheckJournal(bundle) {
|
|
|
14991
15037
|
const nodesRaw = Array.isArray(bundle.nodes) ? bundle.nodes : [];
|
|
14992
15038
|
const edgesRaw = Array.isArray(bundle.edges) ? bundle.edges : [];
|
|
14993
15039
|
const snapshotNodeStatus = /* @__PURE__ */ new Map();
|
|
15040
|
+
const snapshotDecisionStatus = /* @__PURE__ */ new Map();
|
|
14994
15041
|
for (const n of nodesRaw) {
|
|
14995
15042
|
const id = str(n?.id);
|
|
14996
|
-
if (id !== void 0)
|
|
15043
|
+
if (id !== void 0) {
|
|
15044
|
+
snapshotNodeStatus.set(id, n.status);
|
|
15045
|
+
const metadata = n.metadata;
|
|
15046
|
+
const decisionStatus = metadata && typeof metadata === "object" && !Array.isArray(metadata) ? metadata.decision_status : void 0;
|
|
15047
|
+
snapshotDecisionStatus.set(id, decisionStatus ?? "proposed");
|
|
15048
|
+
}
|
|
14997
15049
|
}
|
|
14998
15050
|
const snapshotEdgeIds = /* @__PURE__ */ new Set();
|
|
14999
15051
|
for (const e of edgesRaw) {
|
|
@@ -15030,6 +15082,7 @@ function crossCheckJournal(bundle) {
|
|
|
15030
15082
|
});
|
|
15031
15083
|
const everNodes = new Set(snapshotNodeStatus.keys());
|
|
15032
15084
|
const everEdges = new Set(snapshotEdgeIds);
|
|
15085
|
+
const baselined = /* @__PURE__ */ new Set();
|
|
15033
15086
|
for (const { ev } of valid) {
|
|
15034
15087
|
if (ev.type === "node.created") {
|
|
15035
15088
|
const nid = str(ev.node_id);
|
|
@@ -15037,11 +15090,20 @@ function crossCheckJournal(bundle) {
|
|
|
15037
15090
|
} else if (ev.type === "edge.added") {
|
|
15038
15091
|
const eid = str(ev.edge_id);
|
|
15039
15092
|
if (eid) everEdges.add(eid);
|
|
15093
|
+
} else if (ev.type === "journal.baseline" && Array.isArray(ev.node_ids)) {
|
|
15094
|
+
for (const raw of ev.node_ids) {
|
|
15095
|
+
const nid = str(raw);
|
|
15096
|
+
if (nid) {
|
|
15097
|
+
baselined.add(nid);
|
|
15098
|
+
everNodes.add(nid);
|
|
15099
|
+
}
|
|
15100
|
+
}
|
|
15040
15101
|
}
|
|
15041
15102
|
}
|
|
15042
15103
|
const ordered = orderEvents(valid.map((v) => v.ev));
|
|
15043
15104
|
const created = /* @__PURE__ */ new Set();
|
|
15044
15105
|
const lastProjectStatus = /* @__PURE__ */ new Map();
|
|
15106
|
+
const lastDecisionStatus = /* @__PURE__ */ new Map();
|
|
15045
15107
|
for (const ev of ordered) {
|
|
15046
15108
|
if (ev.type === "node.created") {
|
|
15047
15109
|
const nid = str(ev.node_id);
|
|
@@ -15052,6 +15114,12 @@ function crossCheckJournal(bundle) {
|
|
|
15052
15114
|
const to = str(ev.to);
|
|
15053
15115
|
if (to !== void 0) lastProjectStatus.set(nid, to);
|
|
15054
15116
|
}
|
|
15117
|
+
} else if (ev.type === "decision.status_changed") {
|
|
15118
|
+
const nid = str(ev.node_id);
|
|
15119
|
+
if (nid) {
|
|
15120
|
+
const to = str(ev.to);
|
|
15121
|
+
if (to !== void 0) lastDecisionStatus.set(nid, to);
|
|
15122
|
+
}
|
|
15055
15123
|
}
|
|
15056
15124
|
}
|
|
15057
15125
|
for (const { ev, index } of valid) {
|
|
@@ -15069,6 +15137,19 @@ function crossCheckJournal(bundle) {
|
|
|
15069
15137
|
}
|
|
15070
15138
|
}
|
|
15071
15139
|
}
|
|
15140
|
+
if (ev.type === "deliverable.shipped" && Array.isArray(ev.node_ids)) {
|
|
15141
|
+
ev.node_ids.forEach((raw, i) => {
|
|
15142
|
+
const ref = str(raw);
|
|
15143
|
+
if (ref !== void 0 && !everNodes.has(ref)) {
|
|
15144
|
+
findings.push({
|
|
15145
|
+
path: `journal[${index}].node_ids[${i}]`,
|
|
15146
|
+
rule: "journal-dangling-node-ref",
|
|
15147
|
+
message: `journal[${index}] (${ev.type}): references node "${ref}" that never existed in the snapshot or journal.`,
|
|
15148
|
+
severity: "error"
|
|
15149
|
+
});
|
|
15150
|
+
}
|
|
15151
|
+
});
|
|
15152
|
+
}
|
|
15072
15153
|
if (ev.type === "edge.removed") {
|
|
15073
15154
|
const ref = str(ev.edge_id);
|
|
15074
15155
|
if (ref !== void 0 && !everEdges.has(ref)) {
|
|
@@ -15082,7 +15163,7 @@ function crossCheckJournal(bundle) {
|
|
|
15082
15163
|
}
|
|
15083
15164
|
}
|
|
15084
15165
|
for (const [nodeId, status] of snapshotNodeStatus) {
|
|
15085
|
-
if (!created.has(nodeId)) {
|
|
15166
|
+
if (!created.has(nodeId) && !baselined.has(nodeId)) {
|
|
15086
15167
|
findings.push({
|
|
15087
15168
|
path: "journal",
|
|
15088
15169
|
rule: "journal-missing-node-created",
|
|
@@ -15100,8 +15181,40 @@ function crossCheckJournal(bundle) {
|
|
|
15100
15181
|
});
|
|
15101
15182
|
}
|
|
15102
15183
|
}
|
|
15184
|
+
for (const [nodeId, last] of lastDecisionStatus) {
|
|
15185
|
+
if (!snapshotDecisionStatus.has(nodeId)) continue;
|
|
15186
|
+
const current = snapshotDecisionStatus.get(nodeId) ?? "proposed";
|
|
15187
|
+
if (last !== current) {
|
|
15188
|
+
findings.push({
|
|
15189
|
+
path: "journal",
|
|
15190
|
+
rule: "journal-decision-status-mismatch",
|
|
15191
|
+
message: `Node "${nodeId}": journal's last decision.status_changed.to "${last}" disagrees with snapshot decision_status "${String(current)}".`,
|
|
15192
|
+
severity: "error"
|
|
15193
|
+
});
|
|
15194
|
+
}
|
|
15195
|
+
}
|
|
15103
15196
|
return findings;
|
|
15104
15197
|
}
|
|
15198
|
+
function missingProvenanceNodeIds(snapshotNodeIds, events) {
|
|
15199
|
+
const covered = /* @__PURE__ */ new Set();
|
|
15200
|
+
for (const ev of events) {
|
|
15201
|
+
if (ev.type === "node.created") {
|
|
15202
|
+
if (typeof ev.node_id === "string") covered.add(ev.node_id);
|
|
15203
|
+
} else if (ev.type === "journal.baseline" && Array.isArray(ev.node_ids)) {
|
|
15204
|
+
for (const id of ev.node_ids) {
|
|
15205
|
+
if (typeof id === "string") covered.add(id);
|
|
15206
|
+
}
|
|
15207
|
+
}
|
|
15208
|
+
}
|
|
15209
|
+
const missing = [];
|
|
15210
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15211
|
+
for (const id of snapshotNodeIds) {
|
|
15212
|
+
if (covered.has(id) || seen.has(id)) continue;
|
|
15213
|
+
seen.add(id);
|
|
15214
|
+
missing.push(id);
|
|
15215
|
+
}
|
|
15216
|
+
return missing;
|
|
15217
|
+
}
|
|
15105
15218
|
|
|
15106
15219
|
// ../schema/src/journal-events.ts
|
|
15107
15220
|
var envelope = {
|
|
@@ -15136,6 +15249,13 @@ var NodeStatusChangedEventSchema = external_exports.object({
|
|
|
15136
15249
|
to: AnyStatusSchema,
|
|
15137
15250
|
platform: PlatformSchema.optional()
|
|
15138
15251
|
}).catchall(external_exports.unknown());
|
|
15252
|
+
var DecisionStatusChangedEventSchema = external_exports.object({
|
|
15253
|
+
...envelope,
|
|
15254
|
+
type: external_exports.literal("decision.status_changed"),
|
|
15255
|
+
node_id: external_exports.string(),
|
|
15256
|
+
from: DecisionStatusSchema,
|
|
15257
|
+
to: DecisionStatusSchema
|
|
15258
|
+
}).catchall(external_exports.unknown());
|
|
15139
15259
|
var NodeDeletedEventSchema = external_exports.object({ ...envelope, type: external_exports.literal("node.deleted"), node_id: external_exports.string() }).catchall(external_exports.unknown());
|
|
15140
15260
|
var EdgeAddedEventSchema = external_exports.object({
|
|
15141
15261
|
...envelope,
|
|
@@ -15153,6 +15273,16 @@ var ReleaseTaggedEventSchema = external_exports.object({
|
|
|
15153
15273
|
notes: external_exports.string().optional(),
|
|
15154
15274
|
platform: PlatformSchema.optional()
|
|
15155
15275
|
}).catchall(external_exports.unknown());
|
|
15276
|
+
var DeliverableShippedEventSchema = external_exports.object({
|
|
15277
|
+
...envelope,
|
|
15278
|
+
type: external_exports.literal("deliverable.shipped"),
|
|
15279
|
+
deliverable_id: external_exports.string(),
|
|
15280
|
+
title: external_exports.string(),
|
|
15281
|
+
summary: external_exports.string().optional(),
|
|
15282
|
+
url: external_exports.string().optional(),
|
|
15283
|
+
node_ids: external_exports.array(external_exports.string()).optional(),
|
|
15284
|
+
platform: PlatformSchema.optional()
|
|
15285
|
+
}).catchall(external_exports.unknown());
|
|
15156
15286
|
var IdeaProposedEventSchema = external_exports.object({
|
|
15157
15287
|
...envelope,
|
|
15158
15288
|
type: external_exports.literal("idea.proposed"),
|
|
@@ -15186,33 +15316,40 @@ var RefStatusChangedEventSchema = external_exports.object({
|
|
|
15186
15316
|
to: external_exports.string(),
|
|
15187
15317
|
synced_at: external_exports.string()
|
|
15188
15318
|
}).catchall(external_exports.unknown());
|
|
15319
|
+
var JournalBaselineEventSchema = external_exports.object({ ...envelope, type: external_exports.literal("journal.baseline"), node_ids: external_exports.array(external_exports.string()) }).catchall(external_exports.unknown());
|
|
15189
15320
|
var JOURNAL_EVENT_SCHEMAS = {
|
|
15190
15321
|
"node.created": NodeCreatedEventSchema,
|
|
15191
15322
|
"node.updated": NodeUpdatedEventSchema,
|
|
15192
15323
|
"node.status_changed": NodeStatusChangedEventSchema,
|
|
15324
|
+
"decision.status_changed": DecisionStatusChangedEventSchema,
|
|
15193
15325
|
"node.deleted": NodeDeletedEventSchema,
|
|
15194
15326
|
"edge.added": EdgeAddedEventSchema,
|
|
15195
15327
|
"edge.removed": EdgeRemovedEventSchema,
|
|
15196
15328
|
"release.tagged": ReleaseTaggedEventSchema,
|
|
15329
|
+
"deliverable.shipped": DeliverableShippedEventSchema,
|
|
15197
15330
|
"idea.proposed": IdeaProposedEventSchema,
|
|
15198
15331
|
"request.filed": RequestFiledEventSchema,
|
|
15199
15332
|
"ref.added": RefAddedEventSchema,
|
|
15200
15333
|
"ref.removed": RefRemovedEventSchema,
|
|
15201
|
-
"ref.status_changed": RefStatusChangedEventSchema
|
|
15334
|
+
"ref.status_changed": RefStatusChangedEventSchema,
|
|
15335
|
+
"journal.baseline": JournalBaselineEventSchema
|
|
15202
15336
|
};
|
|
15203
15337
|
var KnownJournalEventSchema = external_exports.union([
|
|
15204
15338
|
NodeCreatedEventSchema,
|
|
15205
15339
|
NodeUpdatedEventSchema,
|
|
15206
15340
|
NodeStatusChangedEventSchema,
|
|
15341
|
+
DecisionStatusChangedEventSchema,
|
|
15207
15342
|
NodeDeletedEventSchema,
|
|
15208
15343
|
EdgeAddedEventSchema,
|
|
15209
15344
|
EdgeRemovedEventSchema,
|
|
15210
15345
|
ReleaseTaggedEventSchema,
|
|
15346
|
+
DeliverableShippedEventSchema,
|
|
15211
15347
|
IdeaProposedEventSchema,
|
|
15212
15348
|
RequestFiledEventSchema,
|
|
15213
15349
|
RefAddedEventSchema,
|
|
15214
15350
|
RefRemovedEventSchema,
|
|
15215
|
-
RefStatusChangedEventSchema
|
|
15351
|
+
RefStatusChangedEventSchema,
|
|
15352
|
+
JournalBaselineEventSchema
|
|
15216
15353
|
]);
|
|
15217
15354
|
|
|
15218
15355
|
// ../schema/src/bundle.ts
|
|
@@ -15267,6 +15404,18 @@ var NodeMetadataSchema = external_exports.object({
|
|
|
15267
15404
|
}),
|
|
15268
15405
|
product: external_exports.string().optional().meta({
|
|
15269
15406
|
description: "Product membership (docs/spec/bundle-format.md \xA7 Products); flow, view, and acceptance only."
|
|
15407
|
+
}),
|
|
15408
|
+
decision_status: DecisionStatusSchema.optional().meta({
|
|
15409
|
+
description: "Decision nodes only: proposed | approved | enacted | rejected | deprecated | superseded. The node's lifecycle status is kept in sync (spec \xA72)."
|
|
15410
|
+
}),
|
|
15411
|
+
context: external_exports.string().optional().meta({
|
|
15412
|
+
description: "Decision nodes only: Context \u2014 the Why (markdown)."
|
|
15413
|
+
}),
|
|
15414
|
+
consequences: external_exports.string().optional().meta({
|
|
15415
|
+
description: "Decision nodes only: Consequences \u2014 the How (markdown)."
|
|
15416
|
+
}),
|
|
15417
|
+
decided_at: external_exports.string().optional().meta({
|
|
15418
|
+
description: "Decision nodes only: ISO 8601 date the decision was made."
|
|
15270
15419
|
})
|
|
15271
15420
|
}).catchall(external_exports.unknown()).meta({ id: "NodeMetadata", description: "Optional metadata for a node." });
|
|
15272
15421
|
var NodeSchema = external_exports.object({
|
|
@@ -15379,6 +15528,115 @@ var ProjectBundleSchema = external_exports.object({
|
|
|
15379
15528
|
description: "The import/export format for an Arkaik product graph. Contains a project, its nodes (flows, views, data models, API endpoints), and edges (relationships between nodes)."
|
|
15380
15529
|
});
|
|
15381
15530
|
|
|
15531
|
+
// ../schema/src/products.ts
|
|
15532
|
+
var PRODUCT_MEMBERSHIP_SPECIES = ["flow", "view", "acceptance"];
|
|
15533
|
+
function resolveProducts(project) {
|
|
15534
|
+
const stored = project?.metadata?.products;
|
|
15535
|
+
if (!Array.isArray(stored)) return [];
|
|
15536
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15537
|
+
const products = [];
|
|
15538
|
+
for (const entry of stored) {
|
|
15539
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) continue;
|
|
15540
|
+
const candidate = entry;
|
|
15541
|
+
if (typeof candidate.id !== "string" || candidate.id.trim() === "" || seen.has(candidate.id)) continue;
|
|
15542
|
+
seen.add(candidate.id);
|
|
15543
|
+
products.push(candidate);
|
|
15544
|
+
}
|
|
15545
|
+
return products;
|
|
15546
|
+
}
|
|
15547
|
+
function productOf(node) {
|
|
15548
|
+
if (!PRODUCT_MEMBERSHIP_SPECIES.includes(node.species)) return null;
|
|
15549
|
+
const product = node.metadata?.product;
|
|
15550
|
+
return typeof product === "string" ? product : null;
|
|
15551
|
+
}
|
|
15552
|
+
var SYSTEM_LAYER_SPECIES = ["api-endpoint", "data-model"];
|
|
15553
|
+
var USAGE_EDGE_TYPES = /* @__PURE__ */ new Set(["calls", "displays", "queries"]);
|
|
15554
|
+
function buildProductUsageIndex(nodes, edges) {
|
|
15555
|
+
const speciesById = /* @__PURE__ */ new Map();
|
|
15556
|
+
for (const node of nodes) speciesById.set(node.id, node.species);
|
|
15557
|
+
const outgoing = /* @__PURE__ */ new Map();
|
|
15558
|
+
for (const edge of edges) {
|
|
15559
|
+
if (!USAGE_EDGE_TYPES.has(edge.edge_type)) continue;
|
|
15560
|
+
const targetSpecies = speciesById.get(edge.target_id);
|
|
15561
|
+
if (targetSpecies === void 0 || !SYSTEM_LAYER_SPECIES.includes(targetSpecies)) continue;
|
|
15562
|
+
const list = outgoing.get(edge.source_id) ?? [];
|
|
15563
|
+
list.push(edge.target_id);
|
|
15564
|
+
outgoing.set(edge.source_id, list);
|
|
15565
|
+
}
|
|
15566
|
+
const seedsByProduct = /* @__PURE__ */ new Map();
|
|
15567
|
+
for (const node of nodes) {
|
|
15568
|
+
const product = productOf(node);
|
|
15569
|
+
if (product === null) continue;
|
|
15570
|
+
const seeds = seedsByProduct.get(product) ?? /* @__PURE__ */ new Set();
|
|
15571
|
+
for (const next of outgoing.get(node.id) ?? []) seeds.add(next);
|
|
15572
|
+
seedsByProduct.set(product, seeds);
|
|
15573
|
+
}
|
|
15574
|
+
const byNode = /* @__PURE__ */ new Map();
|
|
15575
|
+
for (const [product, seeds] of seedsByProduct) {
|
|
15576
|
+
const visited = new Set(seeds);
|
|
15577
|
+
let frontier = [...seeds];
|
|
15578
|
+
while (frontier.length > 0) {
|
|
15579
|
+
const next = [];
|
|
15580
|
+
for (const current of frontier) {
|
|
15581
|
+
const products = byNode.get(current) ?? /* @__PURE__ */ new Set();
|
|
15582
|
+
products.add(product);
|
|
15583
|
+
byNode.set(current, products);
|
|
15584
|
+
for (const neighbor of outgoing.get(current) ?? []) {
|
|
15585
|
+
if (visited.has(neighbor)) continue;
|
|
15586
|
+
visited.add(neighbor);
|
|
15587
|
+
next.push(neighbor);
|
|
15588
|
+
}
|
|
15589
|
+
}
|
|
15590
|
+
frontier = next;
|
|
15591
|
+
}
|
|
15592
|
+
}
|
|
15593
|
+
const index = /* @__PURE__ */ new Map();
|
|
15594
|
+
for (const [nodeId, products] of byNode) index.set(nodeId, [...products].sort());
|
|
15595
|
+
return index;
|
|
15596
|
+
}
|
|
15597
|
+
function productsUsingNode(nodeId, index) {
|
|
15598
|
+
return index.get(nodeId) ?? [];
|
|
15599
|
+
}
|
|
15600
|
+
function buildProductGraph(nodes, edges) {
|
|
15601
|
+
return {
|
|
15602
|
+
edges,
|
|
15603
|
+
nodesById: new Map(nodes.map((node) => [node.id, node])),
|
|
15604
|
+
usageIndex: buildProductUsageIndex(nodes, edges)
|
|
15605
|
+
};
|
|
15606
|
+
}
|
|
15607
|
+
function coveredAnchorIds(acceptanceId, edges) {
|
|
15608
|
+
return edges.filter((edge) => edge.edge_type === "covers" && edge.source_id === acceptanceId).map((edge) => edge.target_id);
|
|
15609
|
+
}
|
|
15610
|
+
function productsOfAcceptance(acceptance, edges, nodesById) {
|
|
15611
|
+
const anchors = coveredAnchorIds(acceptance.id, edges).map((anchorId) => nodesById.get(anchorId)).filter((anchor) => anchor !== void 0);
|
|
15612
|
+
if (anchors.length === 0) {
|
|
15613
|
+
const stored = productOf(acceptance);
|
|
15614
|
+
return stored === null ? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set([stored]);
|
|
15615
|
+
}
|
|
15616
|
+
const products = /* @__PURE__ */ new Set();
|
|
15617
|
+
for (const anchor of anchors) {
|
|
15618
|
+
const product = productOf(anchor);
|
|
15619
|
+
if (product !== null) products.add(product);
|
|
15620
|
+
}
|
|
15621
|
+
return products;
|
|
15622
|
+
}
|
|
15623
|
+
function productsOfNode(node, graph) {
|
|
15624
|
+
if (node.species === "acceptance") {
|
|
15625
|
+
return productsOfAcceptance(node, graph.edges, graph.nodesById);
|
|
15626
|
+
}
|
|
15627
|
+
if (PRODUCT_MEMBERSHIP_SPECIES.includes(node.species)) {
|
|
15628
|
+
const stored = productOf(node);
|
|
15629
|
+
return stored === null ? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set([stored]);
|
|
15630
|
+
}
|
|
15631
|
+
return new Set(productsUsingNode(node.id, graph.usageIndex));
|
|
15632
|
+
}
|
|
15633
|
+
function nodeInProduct(node, productId, graph) {
|
|
15634
|
+
if (productId === null) return true;
|
|
15635
|
+
const products = productsOfNode(node, graph);
|
|
15636
|
+
if (products.size === 0) return !PRODUCT_MEMBERSHIP_SPECIES.includes(node.species);
|
|
15637
|
+
return products.has(productId);
|
|
15638
|
+
}
|
|
15639
|
+
|
|
15382
15640
|
// ../schema/src/maps.ts
|
|
15383
15641
|
var MAP_FLOW_PLATFORMS_MODES = ["rings", "bars"];
|
|
15384
15642
|
var MAP_VIEW_PLATFORMS_MODES = ["chips", "rows"];
|
|
@@ -15414,11 +15672,20 @@ function resolveMapDefaults(definition) {
|
|
|
15414
15672
|
edge_types: definition.edge_types ?? defaults?.edge_types ?? []
|
|
15415
15673
|
};
|
|
15416
15674
|
}
|
|
15417
|
-
function
|
|
15675
|
+
function declared(value) {
|
|
15676
|
+
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
15677
|
+
}
|
|
15678
|
+
function mapProductId(definition, defaultProductId = null) {
|
|
15679
|
+
return declared(definition?.product) ?? defaultProductId;
|
|
15680
|
+
}
|
|
15681
|
+
function computeMapSubgraph(definition, nodes, edges, options) {
|
|
15418
15682
|
const resolved = resolveMapDefaults(definition);
|
|
15419
15683
|
const speciesSet = new Set(resolved.species);
|
|
15420
15684
|
const edgeTypeSet = new Set(resolved.edge_types);
|
|
15421
|
-
const
|
|
15685
|
+
const productId = options?.product !== void 0 ? options.product : mapProductId(definition);
|
|
15686
|
+
const productGraph = productId === null ? void 0 : options?.graph ?? buildProductGraph(nodes, edges);
|
|
15687
|
+
const selectable = productGraph === void 0 ? nodes : nodes.filter((node) => nodeInProduct(node, productId, productGraph));
|
|
15688
|
+
const keptNodes = selectable.filter((node) => speciesSet.has(node.species));
|
|
15422
15689
|
const keptNodeIds = new Set(keptNodes.map((node) => node.id));
|
|
15423
15690
|
const keptEdges = edges.filter(
|
|
15424
15691
|
(edge) => edgeTypeSet.has(edge.edge_type) && keptNodeIds.has(edge.source_id) && keptNodeIds.has(edge.target_id)
|
|
@@ -15473,23 +15740,6 @@ function listMaps(project) {
|
|
|
15473
15740
|
return [...BUILT_IN_MAPS, ...custom2];
|
|
15474
15741
|
}
|
|
15475
15742
|
|
|
15476
|
-
// ../schema/src/products.ts
|
|
15477
|
-
var PRODUCT_MEMBERSHIP_SPECIES = ["flow", "view", "acceptance"];
|
|
15478
|
-
function resolveProducts(project) {
|
|
15479
|
-
const stored = project?.metadata?.products;
|
|
15480
|
-
if (!Array.isArray(stored)) return [];
|
|
15481
|
-
const seen = /* @__PURE__ */ new Set();
|
|
15482
|
-
const products = [];
|
|
15483
|
-
for (const entry of stored) {
|
|
15484
|
-
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) continue;
|
|
15485
|
-
const candidate = entry;
|
|
15486
|
-
if (typeof candidate.id !== "string" || candidate.id.trim() === "" || seen.has(candidate.id)) continue;
|
|
15487
|
-
seen.add(candidate.id);
|
|
15488
|
-
products.push(candidate);
|
|
15489
|
-
}
|
|
15490
|
-
return products;
|
|
15491
|
-
}
|
|
15492
|
-
|
|
15493
15743
|
// ../schema/src/validate.ts
|
|
15494
15744
|
var VALID_STAGES = ["beta", "monitoring", "deprecated"];
|
|
15495
15745
|
var VALID_VIEW_CARD_VARIANTS = ["compact", "large"];
|
|
@@ -15596,7 +15846,9 @@ function validateBundle(input) {
|
|
|
15596
15846
|
}
|
|
15597
15847
|
const platforms = node.platforms;
|
|
15598
15848
|
if (!platforms || platforms.length === 0) {
|
|
15599
|
-
|
|
15849
|
+
if (species !== "decision") {
|
|
15850
|
+
error51(`${base}.platforms`, "platforms-non-empty", `Node ${nodeId}: platforms array is empty or missing`);
|
|
15851
|
+
}
|
|
15600
15852
|
} else {
|
|
15601
15853
|
for (const p of platforms) {
|
|
15602
15854
|
if (!PLATFORM_IDS.includes(p)) {
|
|
@@ -15718,6 +15970,25 @@ function validateBundle(input) {
|
|
|
15718
15970
|
}
|
|
15719
15971
|
});
|
|
15720
15972
|
}
|
|
15973
|
+
const decisionStatus = md.decision_status;
|
|
15974
|
+
if (decisionStatus !== void 0 && species !== "decision") {
|
|
15975
|
+
warn(
|
|
15976
|
+
`${base}.metadata.decision_status`,
|
|
15977
|
+
"decision-status-wrong-species",
|
|
15978
|
+
`decision_status is meaningful on decision nodes only; "${nodeId}" is a ${species}.`
|
|
15979
|
+
);
|
|
15980
|
+
}
|
|
15981
|
+
if (species === "decision") {
|
|
15982
|
+
const effective = decisionStatusOf({ metadata: node.metadata });
|
|
15983
|
+
const expected = lifecycleStatusForDecision(effective);
|
|
15984
|
+
if (node.status !== expected) {
|
|
15985
|
+
warn(
|
|
15986
|
+
`${base}.status`,
|
|
15987
|
+
"decision-lifecycle-mismatch",
|
|
15988
|
+
`Decision "${nodeId}" is ${effective}, whose lifecycle status should be "${expected}", but status is "${node.status}" (spec \xA72).`
|
|
15989
|
+
);
|
|
15990
|
+
}
|
|
15991
|
+
}
|
|
15721
15992
|
if (species === "flow") {
|
|
15722
15993
|
const playlist = md.playlist;
|
|
15723
15994
|
if (!node.metadata || !playlist || !playlist.entries) {
|
|
@@ -15985,13 +16256,98 @@ function validateBundle(input) {
|
|
|
15985
16256
|
composesSet.add(`${sourceId}->${targetId}`);
|
|
15986
16257
|
}
|
|
15987
16258
|
});
|
|
16259
|
+
const PLAYLIST_ENTRY_TYPES = ["view", "flow", "condition", "junction"];
|
|
16260
|
+
const checkPlaylistShape = (entries, flowId, path, depth = 0) => {
|
|
16261
|
+
if (depth > 50) return;
|
|
16262
|
+
if (!Array.isArray(entries)) {
|
|
16263
|
+
error51(path, "playlist-entry-shape", `Flow ${flowId}: ${path} must be an array of playlist entries`);
|
|
16264
|
+
return;
|
|
16265
|
+
}
|
|
16266
|
+
entries.forEach((raw, i) => {
|
|
16267
|
+
const p = `${path}[${i}]`;
|
|
16268
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
16269
|
+
error51(p, "playlist-entry-shape", `Flow ${flowId}: ${p} must be a playlist entry object`);
|
|
16270
|
+
return;
|
|
16271
|
+
}
|
|
16272
|
+
const entry = raw;
|
|
16273
|
+
const type = entry.type;
|
|
16274
|
+
if (typeof type !== "string" || !PLAYLIST_ENTRY_TYPES.includes(type)) {
|
|
16275
|
+
error51(
|
|
16276
|
+
`${p}.type`,
|
|
16277
|
+
"playlist-entry-shape",
|
|
16278
|
+
`Flow ${flowId}: ${p}.type must be one of ${PLAYLIST_ENTRY_TYPES.join(", ")} (got ${JSON.stringify(type)})`
|
|
16279
|
+
);
|
|
16280
|
+
return;
|
|
16281
|
+
}
|
|
16282
|
+
if (type === "view") {
|
|
16283
|
+
if (typeof entry.view_id !== "string") {
|
|
16284
|
+
error51(`${p}.view_id`, "playlist-entry-shape", `Flow ${flowId}: ${p} is a view entry with no view_id string`);
|
|
16285
|
+
}
|
|
16286
|
+
} else if (type === "flow") {
|
|
16287
|
+
if (typeof entry.flow_id !== "string") {
|
|
16288
|
+
error51(`${p}.flow_id`, "playlist-entry-shape", `Flow ${flowId}: ${p} is a flow entry with no flow_id string`);
|
|
16289
|
+
}
|
|
16290
|
+
} else if (type === "condition") {
|
|
16291
|
+
if (typeof entry.label !== "string") {
|
|
16292
|
+
error51(`${p}.label`, "playlist-entry-shape", `Flow ${flowId}: ${p} is a condition with no label string`);
|
|
16293
|
+
}
|
|
16294
|
+
for (const branch of ["if_true", "if_false"]) {
|
|
16295
|
+
if (!Array.isArray(entry[branch])) {
|
|
16296
|
+
error51(
|
|
16297
|
+
`${p}.${branch}`,
|
|
16298
|
+
"playlist-entry-shape",
|
|
16299
|
+
`Flow ${flowId}: ${p}.${branch} must be an array of playlist entries (both branches are required, use [] for an empty one)`
|
|
16300
|
+
);
|
|
16301
|
+
} else {
|
|
16302
|
+
checkPlaylistShape(entry[branch], flowId, `${p}.${branch}`, depth + 1);
|
|
16303
|
+
}
|
|
16304
|
+
}
|
|
16305
|
+
} else {
|
|
16306
|
+
if (typeof entry.label !== "string") {
|
|
16307
|
+
error51(`${p}.label`, "playlist-entry-shape", `Flow ${flowId}: ${p} is a junction with no label string`);
|
|
16308
|
+
}
|
|
16309
|
+
if (!Array.isArray(entry.cases)) {
|
|
16310
|
+
error51(`${p}.cases`, "playlist-entry-shape", `Flow ${flowId}: ${p}.cases must be an array of junction cases`);
|
|
16311
|
+
return;
|
|
16312
|
+
}
|
|
16313
|
+
entry.cases.forEach((rawCase, j) => {
|
|
16314
|
+
const cp = `${p}.cases[${j}]`;
|
|
16315
|
+
if (typeof rawCase !== "object" || rawCase === null || Array.isArray(rawCase)) {
|
|
16316
|
+
error51(cp, "playlist-entry-shape", `Flow ${flowId}: ${cp} must be a junction case object`);
|
|
16317
|
+
return;
|
|
16318
|
+
}
|
|
16319
|
+
const branch = rawCase;
|
|
16320
|
+
if (typeof branch.label !== "string") {
|
|
16321
|
+
error51(`${cp}.label`, "playlist-entry-shape", `Flow ${flowId}: ${cp} has no label string`);
|
|
16322
|
+
}
|
|
16323
|
+
if (!Array.isArray(branch.entries)) {
|
|
16324
|
+
error51(
|
|
16325
|
+
`${cp}.entries`,
|
|
16326
|
+
"playlist-entry-shape",
|
|
16327
|
+
`Flow ${flowId}: ${cp}.entries must be an array of playlist entries \u2014 a junction case holds its own entries, not a bare view_id/flow_id`
|
|
16328
|
+
);
|
|
16329
|
+
} else {
|
|
16330
|
+
checkPlaylistShape(branch.entries, flowId, `${cp}.entries`, depth + 1);
|
|
16331
|
+
}
|
|
16332
|
+
});
|
|
16333
|
+
}
|
|
16334
|
+
});
|
|
16335
|
+
};
|
|
16336
|
+
nodes.forEach((node, i) => {
|
|
16337
|
+
const md = node.metadata;
|
|
16338
|
+
if (node.species === "flow" && md?.playlist?.entries) {
|
|
16339
|
+
checkPlaylistShape(md.playlist.entries, node.id, `nodes[${i}].metadata.playlist.entries`);
|
|
16340
|
+
}
|
|
16341
|
+
});
|
|
15988
16342
|
const collectPlaylistRefs = (entries, flowId, path, depth = 0) => {
|
|
15989
16343
|
if (depth > 50) {
|
|
15990
16344
|
error51(path, "playlist-depth", `Flow ${flowId}: playlist nesting too deep (possible cycle)`);
|
|
15991
16345
|
return [];
|
|
15992
16346
|
}
|
|
15993
16347
|
const refs = [];
|
|
16348
|
+
if (!Array.isArray(entries)) return refs;
|
|
15994
16349
|
for (const entry of entries) {
|
|
16350
|
+
if (typeof entry !== "object" || entry === null) continue;
|
|
15995
16351
|
if (entry.type === "view") {
|
|
15996
16352
|
if (!nodeIds.has(entry.view_id)) {
|
|
15997
16353
|
error51(path, "playlist-ref-exists", `Flow ${flowId}: playlist references non-existent view "${entry.view_id}"`);
|
|
@@ -16043,7 +16399,9 @@ function validateBundle(input) {
|
|
|
16043
16399
|
const nodeId = node.id;
|
|
16044
16400
|
const subFlows = [];
|
|
16045
16401
|
const findSubFlows = (entries) => {
|
|
16402
|
+
if (!Array.isArray(entries)) return;
|
|
16046
16403
|
for (const e of entries) {
|
|
16404
|
+
if (typeof e !== "object" || e === null) continue;
|
|
16047
16405
|
if (e.type === "flow") subFlows.push(e.flow_id);
|
|
16048
16406
|
if (e.type === "condition") {
|
|
16049
16407
|
if (e.if_true) findSubFlows(e.if_true);
|
|
@@ -16240,6 +16598,9 @@ function eventAffectsPlatform(ev, platform, nodesById) {
|
|
|
16240
16598
|
const edge = ev;
|
|
16241
16599
|
return onPlatform(edge.source_id) || onPlatform(edge.target_id);
|
|
16242
16600
|
}
|
|
16601
|
+
if (ev.type === "deliverable.shipped" && Array.isArray(ev.node_ids)) {
|
|
16602
|
+
return ev.node_ids.some(onPlatform);
|
|
16603
|
+
}
|
|
16243
16604
|
return false;
|
|
16244
16605
|
}
|
|
16245
16606
|
function computeChangelog(events, toVersion, options = {}) {
|
|
@@ -16253,7 +16614,7 @@ function computeChangelog(events, toVersion, options = {}) {
|
|
|
16253
16614
|
}
|
|
16254
16615
|
}
|
|
16255
16616
|
if (toIndex === -1) {
|
|
16256
|
-
return { fromVersion: null, toVersion, events: [] };
|
|
16617
|
+
return { fromVersion: null, toVersion, events: [], deliverables: [] };
|
|
16257
16618
|
}
|
|
16258
16619
|
const platform = asString(ordered[toIndex].platform);
|
|
16259
16620
|
let fromIndex = -1;
|
|
@@ -16282,7 +16643,8 @@ function computeChangelog(events, toVersion, options = {}) {
|
|
|
16282
16643
|
fromVersion: fromIndex >= 0 ? asString(ordered[fromIndex].version) ?? null : null,
|
|
16283
16644
|
toVersion,
|
|
16284
16645
|
...platform ? { platform } : {},
|
|
16285
|
-
events: slice
|
|
16646
|
+
events: slice,
|
|
16647
|
+
deliverables: computeDeliverables(ordered).filter((d) => d.releaseVersion === toVersion)
|
|
16286
16648
|
};
|
|
16287
16649
|
}
|
|
16288
16650
|
function deriveExistingNodeIds(orderedEvents) {
|
|
@@ -16311,6 +16673,61 @@ function computeBacklog(events, options = {}) {
|
|
|
16311
16673
|
items
|
|
16312
16674
|
};
|
|
16313
16675
|
}
|
|
16676
|
+
function computeDeliverables(events) {
|
|
16677
|
+
const ordered = orderEvents(events);
|
|
16678
|
+
const firstIndex = /* @__PURE__ */ new Map();
|
|
16679
|
+
const latest = /* @__PURE__ */ new Map();
|
|
16680
|
+
ordered.forEach((ev, i) => {
|
|
16681
|
+
if (ev.type !== "deliverable.shipped") return;
|
|
16682
|
+
const id = asString(ev.deliverable_id);
|
|
16683
|
+
if (id === void 0) return;
|
|
16684
|
+
if (!firstIndex.has(id)) firstIndex.set(id, i);
|
|
16685
|
+
latest.set(id, ev);
|
|
16686
|
+
});
|
|
16687
|
+
if (firstIndex.size === 0) return [];
|
|
16688
|
+
const markerLatest = /* @__PURE__ */ new Map();
|
|
16689
|
+
ordered.forEach((ev, i) => {
|
|
16690
|
+
if (ev.type !== "release.tagged") return;
|
|
16691
|
+
const version2 = asString(ev.version);
|
|
16692
|
+
if (version2 !== void 0) markerLatest.set(version2, i);
|
|
16693
|
+
});
|
|
16694
|
+
const windows = [];
|
|
16695
|
+
for (const [version2, toIndex] of markerLatest) {
|
|
16696
|
+
let fromIndex = -1;
|
|
16697
|
+
for (let i = toIndex - 1; i >= 0; i -= 1) {
|
|
16698
|
+
if (ordered[i].type === "release.tagged") {
|
|
16699
|
+
fromIndex = i;
|
|
16700
|
+
break;
|
|
16701
|
+
}
|
|
16702
|
+
}
|
|
16703
|
+
windows.push({ version: version2, from: fromIndex, to: toIndex });
|
|
16704
|
+
}
|
|
16705
|
+
const releaseOf = (index) => {
|
|
16706
|
+
for (const w of windows) {
|
|
16707
|
+
if (index > w.from && index < w.to) return w.version;
|
|
16708
|
+
}
|
|
16709
|
+
return null;
|
|
16710
|
+
};
|
|
16711
|
+
const out = [];
|
|
16712
|
+
for (const [id, anchorIndex] of firstIndex) {
|
|
16713
|
+
const ev = latest.get(id);
|
|
16714
|
+
if (ev === void 0) continue;
|
|
16715
|
+
const summary = asString(ev.summary);
|
|
16716
|
+
const url2 = asString(ev.url);
|
|
16717
|
+
const platform = asString(ev.platform);
|
|
16718
|
+
out.push({
|
|
16719
|
+
deliverable_id: id,
|
|
16720
|
+
title: asString(ev.title) ?? id,
|
|
16721
|
+
...summary !== void 0 ? { summary } : {},
|
|
16722
|
+
...url2 !== void 0 ? { url: url2 } : {},
|
|
16723
|
+
node_ids: Array.isArray(ev.node_ids) ? ev.node_ids.filter((n) => typeof n === "string") : [],
|
|
16724
|
+
...platform !== void 0 ? { platform } : {},
|
|
16725
|
+
ts: asString(ordered[anchorIndex].ts) ?? "",
|
|
16726
|
+
releaseVersion: releaseOf(anchorIndex)
|
|
16727
|
+
});
|
|
16728
|
+
}
|
|
16729
|
+
return out;
|
|
16730
|
+
}
|
|
16314
16731
|
|
|
16315
16732
|
// ../schema/src/emit.ts
|
|
16316
16733
|
var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
@@ -16495,6 +16912,12 @@ function diffNodeUpdate(current, patch) {
|
|
|
16495
16912
|
for (const platform of changedMapKeys(prevMeta[key], nextMeta[key])) {
|
|
16496
16913
|
changedPaths.push(`metadata.${key}.${platform}`);
|
|
16497
16914
|
}
|
|
16915
|
+
} else if (key === "decision_status") {
|
|
16916
|
+
const from = prevMeta[key] ?? "proposed";
|
|
16917
|
+
const to = nextMeta[key] ?? "proposed";
|
|
16918
|
+
if (!valueEqual(from, to)) {
|
|
16919
|
+
events.push({ type: "decision.status_changed", payload: { node_id: nodeId, from, to } });
|
|
16920
|
+
}
|
|
16498
16921
|
} else if (!valueEqual(prevMeta[key], nextMeta[key])) {
|
|
16499
16922
|
changedPaths.push(`metadata.${key}`);
|
|
16500
16923
|
}
|
|
@@ -16899,14 +17322,15 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
16899
17322
|
tool(
|
|
16900
17323
|
{
|
|
16901
17324
|
name: "list_maps",
|
|
16902
|
-
description: "Every map the project offers \u2014 built-ins plus stored definitions \u2014 with live subgraph sizes.",
|
|
17325
|
+
description: "Every map the project offers \u2014 built-ins plus stored definitions \u2014 with live subgraph sizes. A definition carrying a `product` is counted through that restriction, as the canvas draws it.",
|
|
16903
17326
|
inputSchema: { type: "object", properties: {}, additionalProperties: false }
|
|
16904
17327
|
},
|
|
16905
17328
|
async () => {
|
|
16906
17329
|
const { nodes, edges, project } = await load(ctx);
|
|
17330
|
+
const graph = buildProductGraph(nodes, edges);
|
|
16907
17331
|
return {
|
|
16908
17332
|
maps: listMaps(project).map((definition) => {
|
|
16909
|
-
const subgraph = computeMapSubgraph(definition, nodes, edges);
|
|
17333
|
+
const subgraph = computeMapSubgraph(definition, nodes, edges, { graph });
|
|
16910
17334
|
return { definition, nodeCount: subgraph.nodes.length, edgeCount: subgraph.edges.length };
|
|
16911
17335
|
})
|
|
16912
17336
|
};
|
|
@@ -16915,7 +17339,7 @@ ${node.description ?? ""}`.toLowerCase();
|
|
|
16915
17339
|
tool(
|
|
16916
17340
|
{
|
|
16917
17341
|
name: "get_map",
|
|
16918
|
-
description: "Resolve a map definition (built-in or stored) and return its computed subgraph.",
|
|
17342
|
+
description: "Resolve a map definition (built-in or stored) and return its computed subgraph. A definition carrying a `product` returns only that product's nodes \u2014 the same subgraph the canvas draws.",
|
|
16919
17343
|
inputSchema: {
|
|
16920
17344
|
type: "object",
|
|
16921
17345
|
properties: { map_id: { type: "string" } },
|
|
@@ -17212,12 +17636,17 @@ function readBundle(filePath) {
|
|
|
17212
17636
|
}
|
|
17213
17637
|
|
|
17214
17638
|
// ../cli/src/lib/journal-io.ts
|
|
17215
|
-
import { appendFileSync, existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
17639
|
+
import { appendFileSync, existsSync as existsSync2, mkdirSync, readdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
17216
17640
|
import { dirname, join } from "node:path";
|
|
17217
17641
|
var JOURNAL_SIDECAR = "journal.jsonl";
|
|
17218
17642
|
function journalPathFor(bundlePath) {
|
|
17219
17643
|
return join(dirname(bundlePath), JOURNAL_SIDECAR);
|
|
17220
17644
|
}
|
|
17645
|
+
function archivePathsFor(journalPath) {
|
|
17646
|
+
const dir = join(dirname(journalPath), "journal");
|
|
17647
|
+
if (!existsSync2(dir)) return [];
|
|
17648
|
+
return readdirSync(dir).filter((name) => name.startsWith("archive-") && name.endsWith(".jsonl")).sort().map((name) => join(dir, name));
|
|
17649
|
+
}
|
|
17221
17650
|
function toLine(event) {
|
|
17222
17651
|
return JSON.stringify(event) + "\n";
|
|
17223
17652
|
}
|
|
@@ -17235,8 +17664,7 @@ function appendJournalEvent(journalPath, event) {
|
|
|
17235
17664
|
|
|
17236
17665
|
// ../cli/src/lib/bundle-validate.ts
|
|
17237
17666
|
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "node:fs";
|
|
17238
|
-
import {
|
|
17239
|
-
var JOURNAL_SIDECAR2 = "journal.jsonl";
|
|
17667
|
+
import { basename } from "node:path";
|
|
17240
17668
|
function validateBundleAt(filePath) {
|
|
17241
17669
|
const bundle = readBundle(filePath);
|
|
17242
17670
|
const loose = bundle;
|
|
@@ -17245,21 +17673,43 @@ function validateBundleAt(filePath) {
|
|
|
17245
17673
|
}
|
|
17246
17674
|
let sidecarFindings = [];
|
|
17247
17675
|
let sidecarLoaded = false;
|
|
17676
|
+
const archiveFindings = [];
|
|
17677
|
+
const archivesLoaded = [];
|
|
17248
17678
|
if (loose.journal === void 0) {
|
|
17249
|
-
const sidecarPath =
|
|
17679
|
+
const sidecarPath = journalPathFor(filePath);
|
|
17680
|
+
const folded = [];
|
|
17250
17681
|
if (existsSync3(sidecarPath)) {
|
|
17251
17682
|
const { events, findings } = parseJournalLines(readFileSync3(sidecarPath, "utf8"));
|
|
17252
17683
|
sidecarFindings = findings;
|
|
17253
17684
|
sidecarLoaded = true;
|
|
17254
|
-
|
|
17685
|
+
folded.push(...events);
|
|
17255
17686
|
}
|
|
17687
|
+
for (const archivePath of archivePathsFor(sidecarPath)) {
|
|
17688
|
+
const { events, findings } = parseJournalLines(readFileSync3(archivePath, "utf8"));
|
|
17689
|
+
const file2 = basename(archivePath);
|
|
17690
|
+
for (const finding of findings) archiveFindings.push({ ...finding, file: file2 });
|
|
17691
|
+
archivesLoaded.push(file2);
|
|
17692
|
+
folded.push(...events);
|
|
17693
|
+
}
|
|
17694
|
+
if (sidecarLoaded || archivesLoaded.length > 0) loose.journal = folded;
|
|
17256
17695
|
}
|
|
17257
17696
|
const nodes = Array.isArray(loose.nodes) ? loose.nodes : [];
|
|
17258
17697
|
const edges = Array.isArray(loose.edges) ? loose.edges : [];
|
|
17259
17698
|
const journal = Array.isArray(loose.journal) ? loose.journal : [];
|
|
17260
17699
|
const result = validateBundle(bundle);
|
|
17261
|
-
const valid = sidecarFindings.length === 0 && result.errors.length === 0;
|
|
17262
|
-
return {
|
|
17700
|
+
const valid = sidecarFindings.length === 0 && archiveFindings.length === 0 && result.errors.length === 0;
|
|
17701
|
+
return {
|
|
17702
|
+
bundle,
|
|
17703
|
+
nodes,
|
|
17704
|
+
edges,
|
|
17705
|
+
journal,
|
|
17706
|
+
sidecarLoaded,
|
|
17707
|
+
sidecarFindings,
|
|
17708
|
+
archivesLoaded,
|
|
17709
|
+
archiveFindings,
|
|
17710
|
+
result,
|
|
17711
|
+
valid
|
|
17712
|
+
};
|
|
17263
17713
|
}
|
|
17264
17714
|
|
|
17265
17715
|
// src/store.ts
|
|
@@ -17275,8 +17725,15 @@ function resolveBundlePath(argv2, env) {
|
|
|
17275
17725
|
function loadBundle(bundlePath) {
|
|
17276
17726
|
return validateBundleAt(bundlePath);
|
|
17277
17727
|
}
|
|
17728
|
+
function nodeIdsOf(nodes) {
|
|
17729
|
+
return nodes.map((node) => node?.id).filter((id) => typeof id === "string");
|
|
17730
|
+
}
|
|
17278
17731
|
function persistMutation(bundlePath, loaded, next, inputs) {
|
|
17279
|
-
const
|
|
17732
|
+
const baselineNodeIds = inputs.length === 0 ? [] : missingProvenanceNodeIds(nodeIdsOf(loaded.nodes), loaded.journal);
|
|
17733
|
+
const events = [
|
|
17734
|
+
...baselineNodeIds.length > 0 ? [makeEvent("journal.baseline", { node_ids: baselineNodeIds }, { actor: MCP_ACTOR })] : [],
|
|
17735
|
+
...toJournalEvents(inputs, MCP_ACTOR)
|
|
17736
|
+
];
|
|
17280
17737
|
const nextNodes = next.nodes ?? loaded.nodes;
|
|
17281
17738
|
const nextEdges = next.edges ?? loaded.edges;
|
|
17282
17739
|
const candidate = {
|
|
@@ -17289,7 +17746,8 @@ function persistMutation(bundlePath, loaded, next, inputs) {
|
|
|
17289
17746
|
if (result.errors.length > 0) {
|
|
17290
17747
|
return { ok: false, errors: result.errors, warnings: result.warnings };
|
|
17291
17748
|
}
|
|
17292
|
-
const
|
|
17749
|
+
const journalOnDisk = loaded.sidecarLoaded || loaded.archivesLoaded.length > 0;
|
|
17750
|
+
const embeddedJournal = !journalOnDisk && loaded.bundle.journal !== void 0;
|
|
17293
17751
|
if (embeddedJournal) {
|
|
17294
17752
|
writeFileSync2(bundlePath, serializeBundle(candidate));
|
|
17295
17753
|
} else {
|
|
@@ -17372,9 +17830,12 @@ function createRemoteStore(options) {
|
|
|
17372
17830
|
edges,
|
|
17373
17831
|
journal,
|
|
17374
17832
|
sidecarLoaded: false,
|
|
17375
|
-
// Nothing was folded in from a JSONL sidecar
|
|
17376
|
-
// findings — hosted journals arrive already
|
|
17833
|
+
// Nothing was folded in from a JSONL sidecar or a compaction archive,
|
|
17834
|
+
// so there are no line findings — hosted journals arrive already
|
|
17835
|
+
// parsed, and compaction is a repo-mode concern.
|
|
17377
17836
|
sidecarFindings: [],
|
|
17837
|
+
archivesLoaded: [],
|
|
17838
|
+
archiveFindings: [],
|
|
17378
17839
|
get result() {
|
|
17379
17840
|
return validate();
|
|
17380
17841
|
},
|
|
@@ -17440,12 +17901,12 @@ function describeFailure(status, body) {
|
|
|
17440
17901
|
|
|
17441
17902
|
// src/config.ts
|
|
17442
17903
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
17443
|
-
import { join as
|
|
17904
|
+
import { join as join2 } from "node:path";
|
|
17444
17905
|
var LINK_FILE = "docs/arkaik/arkaik.json";
|
|
17445
17906
|
var DEFAULT_BASE_URL = "https://arkaik.app";
|
|
17446
17907
|
function readLinkFile(cwd) {
|
|
17447
17908
|
try {
|
|
17448
|
-
const parsed = JSON.parse(readFileSync4(
|
|
17909
|
+
const parsed = JSON.parse(readFileSync4(join2(cwd, LINK_FILE), "utf8"));
|
|
17449
17910
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
17450
17911
|
return parsed;
|
|
17451
17912
|
} catch {
|
|
@@ -17486,7 +17947,7 @@ function resolveRemoteConfig(argv2, env, cwd) {
|
|
|
17486
17947
|
}
|
|
17487
17948
|
|
|
17488
17949
|
// src/index.ts
|
|
17489
|
-
var VERSION = "0.2.
|
|
17950
|
+
var VERSION = "0.2.3";
|
|
17490
17951
|
var argv = process.argv.slice(2);
|
|
17491
17952
|
if (argv.includes("--help") || argv.includes("-h")) {
|
|
17492
17953
|
process.stdout.write(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkaik-mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Arkaik MCP server — stdio tools over an Arkaik product-graph bundle: read projections plus validator-gated dual-write mutations.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"arkaik-mcp": "dist/index.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
|
-
"dist"
|
|
11
|
+
"dist",
|
|
12
|
+
"LICENSE"
|
|
12
13
|
],
|
|
13
14
|
"repository": {
|
|
14
15
|
"type": "git",
|