arkaik-mcp 0.2.0 → 0.2.2

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.
Files changed (2) hide show
  1. package/dist/index.js +355 -40
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14635,16 +14635,43 @@ config(en_default());
14635
14635
  var SPECIES_IDS = ["flow", "view", "data-model", "api-endpoint", "acceptance"];
14636
14636
  var STATUS_IDS = [
14637
14637
  "idea",
14638
+ "discovery",
14638
14639
  "backlog",
14639
- "prioritized",
14640
14640
  "development",
14641
14641
  "releasing",
14642
14642
  "live",
14643
- "archived",
14644
- "blocked"
14643
+ "archived"
14645
14644
  ];
14646
14645
  var PLATFORM_IDS = ["web", "ios", "android"];
14647
14646
  var EDGE_TYPE_IDS = ["composes", "calls", "displays", "queries", "covers"];
14647
+ var VALID_EDGE_SEMANTICS = {
14648
+ composes: [
14649
+ ["flow", "view"],
14650
+ ["flow", "flow"],
14651
+ ["view", "flow"],
14652
+ ["view", "view"]
14653
+ ],
14654
+ // `calls` names the initiator, which is why it runs in both directions
14655
+ // between a view and an endpoint: view → api is the outbound/write
14656
+ // affordance, api → view the inbound/read one a server opens itself (a
14657
+ // webhook, an SSE channel, a push). Both project onto the View card
14658
+ // (docs/graph-model.md § Edge Types). Consumers that walk `calls` must
14659
+ // therefore not assume it points down into the system layer — see
14660
+ // `buildProductUsageIndex` in ./products.ts, which restricts hops by
14661
+ // target species for exactly this reason.
14662
+ calls: [
14663
+ ["view", "api-endpoint"],
14664
+ ["flow", "api-endpoint"],
14665
+ ["api-endpoint", "api-endpoint"],
14666
+ ["api-endpoint", "view"]
14667
+ ],
14668
+ displays: [["view", "data-model"]],
14669
+ queries: [["api-endpoint", "data-model"]],
14670
+ covers: [
14671
+ ["acceptance", "view"],
14672
+ ["acceptance", "flow"]
14673
+ ]
14674
+ };
14648
14675
  var VALUE_TIER_IDS = ["functional", "emotional", "life-changing", "social-impact"];
14649
14676
  var VALUE_IDS = [
14650
14677
  // functional (14)
@@ -14683,6 +14710,78 @@ var VALUE_IDS = [
14683
14710
  "self-transcendence"
14684
14711
  ];
14685
14712
 
14713
+ // ../schema/src/legacy-status.ts
14714
+ var LEGACY_STATUS_IDS = ["prioritized", "blocked"];
14715
+ var LEGACY_STATUS_ALIASES = {
14716
+ prioritized: "backlog",
14717
+ blocked: "development"
14718
+ };
14719
+ var STATUS_VOCABULARY_VERSION = 3;
14720
+ var BLOCKED_BY_MIGRATION_NOTE = "migrated from legacy blocked status";
14721
+ function normalizeStatus(value) {
14722
+ if (STATUS_IDS.includes(value)) return value;
14723
+ return LEGACY_STATUS_ALIASES[value];
14724
+ }
14725
+ var LEGACY_ALIAS_REMAP = { ...LEGACY_STATUS_ALIASES };
14726
+ var LEGACY_VOCABULARY_REMAP = {
14727
+ backlog: "idea",
14728
+ ...LEGACY_STATUS_ALIASES
14729
+ };
14730
+ function migrateNode(node, remap) {
14731
+ let changed = false;
14732
+ let wasBlocked = node.status === "blocked";
14733
+ const mappedStatus = remap[node.status];
14734
+ const status = mappedStatus ?? node.status;
14735
+ if (mappedStatus !== void 0) changed = true;
14736
+ let metadata = node.metadata;
14737
+ const platformStatuses = node.metadata?.platformStatuses;
14738
+ if (platformStatuses !== void 0) {
14739
+ let anyMapped = false;
14740
+ const next = {};
14741
+ for (const [platform, value] of Object.entries(platformStatuses)) {
14742
+ if (value === "blocked") wasBlocked = true;
14743
+ const mapped = remap[value];
14744
+ next[platform] = mapped ?? value;
14745
+ if (mapped !== void 0) anyMapped = true;
14746
+ }
14747
+ if (anyMapped) {
14748
+ metadata = { ...metadata, platformStatuses: next };
14749
+ changed = true;
14750
+ }
14751
+ }
14752
+ const refs = node.metadata?.refs;
14753
+ if (Array.isArray(refs)) {
14754
+ let anyMapped = false;
14755
+ const nextRefs = refs.map((ref) => {
14756
+ if (ref.status_mapped === void 0) return ref;
14757
+ const mapped = remap[ref.status_mapped];
14758
+ if (mapped === void 0) return ref;
14759
+ anyMapped = true;
14760
+ return { ...ref, status_mapped: mapped };
14761
+ });
14762
+ if (anyMapped) {
14763
+ metadata = { ...metadata, refs: nextRefs };
14764
+ changed = true;
14765
+ }
14766
+ }
14767
+ if (wasBlocked && !metadata?.blocked_by) {
14768
+ metadata = { ...metadata, blocked_by: BLOCKED_BY_MIGRATION_NOTE };
14769
+ changed = true;
14770
+ }
14771
+ if (!changed) return node;
14772
+ return { ...node, status, ...metadata !== void 0 ? { metadata } : {} };
14773
+ }
14774
+ function migrateStatusVocabulary(bundle) {
14775
+ const current = typeof bundle.schema_version === "number" && bundle.schema_version >= STATUS_VOCABULARY_VERSION;
14776
+ const remap = current ? LEGACY_ALIAS_REMAP : LEGACY_VOCABULARY_REMAP;
14777
+ const nodes = bundle.nodes.map((node) => migrateNode(node, remap));
14778
+ if (current) {
14779
+ const untouched = nodes.every((node, i) => node === bundle.nodes[i]);
14780
+ return untouched ? bundle : { ...bundle, nodes };
14781
+ }
14782
+ return { ...bundle, schema_version: STATUS_VOCABULARY_VERSION, nodes };
14783
+ }
14784
+
14686
14785
  // ../schema/src/enums.ts
14687
14786
  var SpeciesSchema = external_exports.enum(SPECIES_IDS).meta({
14688
14787
  id: "Species",
@@ -14692,6 +14791,10 @@ var StatusSchema = external_exports.enum(STATUS_IDS).meta({
14692
14791
  id: "Status",
14693
14792
  description: "Lifecycle status of a node."
14694
14793
  });
14794
+ var AnyStatusSchema = external_exports.enum([...STATUS_IDS, ...LEGACY_STATUS_IDS]).meta({
14795
+ id: "AnyStatus",
14796
+ description: "Lifecycle status as stored: the current vocabulary, or a legacy id (prioritized, blocked) accepted from pre-v3 bundles and migrated on load."
14797
+ });
14695
14798
  var PlatformSchema = external_exports.enum(PLATFORM_IDS).meta({
14696
14799
  id: "Platform",
14697
14800
  description: "Target platform."
@@ -14864,6 +14967,12 @@ var NODE_REF_FIELDS = {
14864
14967
  "idea.proposed": ["node_id"],
14865
14968
  "request.filed": ["node_id"]
14866
14969
  };
14970
+ function statusesAgree(last, snapshot) {
14971
+ if (last === snapshot) return true;
14972
+ if (typeof snapshot !== "string") return false;
14973
+ if (last === "backlog" && snapshot === "idea") return true;
14974
+ return (normalizeStatus(last) ?? last) === (normalizeStatus(snapshot) ?? snapshot);
14975
+ }
14867
14976
  function crossCheckJournal(bundle) {
14868
14977
  const findings = [];
14869
14978
  const journalRaw = bundle.journal;
@@ -14982,7 +15091,7 @@ function crossCheckJournal(bundle) {
14982
15091
  });
14983
15092
  }
14984
15093
  const last = lastProjectStatus.get(nodeId);
14985
- if (last !== void 0 && last !== status) {
15094
+ if (last !== void 0 && !statusesAgree(last, status)) {
14986
15095
  findings.push({
14987
15096
  path: "journal",
14988
15097
  rule: "journal-status-mismatch",
@@ -15021,8 +15130,10 @@ var NodeStatusChangedEventSchema = external_exports.object({
15021
15130
  ...envelope,
15022
15131
  type: external_exports.literal("node.status_changed"),
15023
15132
  node_id: external_exports.string(),
15024
- from: StatusSchema,
15025
- to: StatusSchema,
15133
+ // History is never rewritten (docs/spec/journal.md): pre-v3 events keep
15134
+ // their legacy status ids, so strict per-type validation must accept them.
15135
+ from: AnyStatusSchema,
15136
+ to: AnyStatusSchema,
15026
15137
  platform: PlatformSchema.optional()
15027
15138
  }).catchall(external_exports.unknown());
15028
15139
  var NodeDeletedEventSchema = external_exports.object({ ...envelope, type: external_exports.literal("node.deleted"), node_id: external_exports.string() }).catchall(external_exports.unknown());
@@ -15107,7 +15218,8 @@ var KnownJournalEventSchema = external_exports.union([
15107
15218
  // ../schema/src/bundle.ts
15108
15219
  var PlatformStatusMapSchema = external_exports.partialRecord(
15109
15220
  PlatformSchema,
15110
- StatusSchema
15221
+ // legacy-tolerant: migrateStatusVocabulary normalizes on load
15222
+ AnyStatusSchema
15111
15223
  ).meta({ id: "PlatformStatusMap", description: "Per-platform status overrides for view nodes." });
15112
15224
  var PlatformNotesMapSchema = external_exports.partialRecord(
15113
15225
  PlatformSchema,
@@ -15130,7 +15242,8 @@ var RefSchema = external_exports.object({
15130
15242
  external_status: external_exports.string().optional().meta({
15131
15243
  description: 'Mirrored external state, verbatim (e.g. "open", "merged", "In Progress").'
15132
15244
  }),
15133
- status_mapped: StatusSchema.optional().meta({
15245
+ // legacy-tolerant: migrateStatusVocabulary normalizes on load
15246
+ status_mapped: AnyStatusSchema.optional().meta({
15134
15247
  description: "Optional mapping of external_status into the arkaik lifecycle. Advisory display data \u2014 never mutates node.status."
15135
15248
  }),
15136
15249
  platform: PlatformSchema.optional().meta({ description: "Optional scoping to one platform variant." }),
@@ -15138,6 +15251,9 @@ var RefSchema = external_exports.object({
15138
15251
  }).meta({ id: "Ref", description: "A typed external reference on a node (docs/spec/bundle-format.md \xA7 References)." });
15139
15252
  var NodeMetadataSchema = external_exports.object({
15140
15253
  stage: external_exports.string().optional(),
15254
+ blocked_by: external_exports.string().optional().meta({
15255
+ description: "Non-empty = blocked at the current status. A node id (rendered as a link) or free text naming the dependency."
15256
+ }),
15141
15257
  playlist: FlowPlaylistSchema.optional(),
15142
15258
  platformNotes: PlatformNotesMapSchema.optional(),
15143
15259
  platformStatuses: PlatformStatusMapSchema.optional(),
@@ -15148,6 +15264,9 @@ var NodeMetadataSchema = external_exports.object({
15148
15264
  }),
15149
15265
  values: external_exports.array(ValueSchema).optional().meta({
15150
15266
  description: "Acceptance nodes only: 1..n Bain value elements served (the Why)."
15267
+ }),
15268
+ product: external_exports.string().optional().meta({
15269
+ description: "Product membership (docs/spec/bundle-format.md \xA7 Products); flow, view, and acceptance only."
15151
15270
  })
15152
15271
  }).catchall(external_exports.unknown()).meta({ id: "NodeMetadata", description: "Optional metadata for a node." });
15153
15272
  var NodeSchema = external_exports.object({
@@ -15156,7 +15275,8 @@ var NodeSchema = external_exports.object({
15156
15275
  species: SpeciesSchema,
15157
15276
  title: external_exports.string().meta({ description: "Human-readable node title." }),
15158
15277
  description: external_exports.string().optional().meta({ description: "Optional description of the node's purpose." }),
15159
- status: StatusSchema,
15278
+ // legacy-tolerant: migrateStatusVocabulary normalizes on load
15279
+ status: AnyStatusSchema,
15160
15280
  platforms: external_exports.array(PlatformSchema).meta({ description: "One or more target platforms." }),
15161
15281
  metadata: NodeMetadataSchema.optional()
15162
15282
  }).meta({ id: "Node" });
@@ -15168,6 +15288,18 @@ var EdgeSchema = external_exports.object({
15168
15288
  edge_type: EdgeTypeSchema,
15169
15289
  metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional().meta({ description: "Optional edge metadata." })
15170
15290
  }).meta({ id: "Edge" });
15291
+ var MapDisplayOptionsSchema = external_exports.object({
15292
+ images: external_exports.boolean().optional().meta({ description: "Screenshot (or cover) art on view cards." }),
15293
+ flow_platforms: external_exports.string().optional().meta({
15294
+ description: "A flow card's platform delivery: rings (default) | bars."
15295
+ }),
15296
+ view_platforms: external_exports.string().optional().meta({
15297
+ description: "A view card's platform availability: chips (default) | rows."
15298
+ }),
15299
+ minimap_color: external_exports.string().optional().meta({
15300
+ description: "What a minimap node's fill encodes: status (default) | species."
15301
+ })
15302
+ }).catchall(external_exports.unknown()).meta({ id: "MapDisplayOptions", description: "How a map draws its cards (docs/spec/maps.md \xA7 Display Options)." });
15171
15303
  var MapDefinitionSchema = external_exports.object({
15172
15304
  id: external_exports.string().meta({
15173
15305
  description: "Kebab-case, unique within the project; built-in ids (journey, system) are reserved."
@@ -15186,13 +15318,32 @@ var MapDefinitionSchema = external_exports.object({
15186
15318
  root_node_id: external_exports.string().optional().meta({
15187
15319
  description: "Scope anchor: the subgraph is the undirected neighborhood reachable from this node."
15188
15320
  }),
15321
+ product: external_exports.string().optional().meta({ description: "Product scope; absent = every product." }),
15189
15322
  depth: external_exports.number().optional().meta({ description: "Traversal bound from the root; absent = unbounded." }),
15190
- layout: external_exports.object({ direction: external_exports.string().optional() }).catchall(external_exports.unknown()).optional().meta({ description: "Renderer layout hints (e.g. direction: DOWN | RIGHT)." })
15323
+ layout: external_exports.object({ direction: external_exports.string().optional() }).catchall(external_exports.unknown()).optional().meta({ description: "Renderer layout hints (e.g. direction: DOWN | RIGHT)." }),
15324
+ display: MapDisplayOptionsSchema.optional().meta({
15325
+ description: "Card rendering; the human twin is project.metadata.map_display[id]."
15326
+ })
15191
15327
  }).catchall(external_exports.unknown()).meta({ id: "MapDefinition", description: "A stored map definition (docs/spec/maps.md \xA7 MapDefinition)." });
15328
+ var ProductDefinitionSchema = external_exports.object({
15329
+ id: external_exports.string().meta({ description: "Kebab-case, unique within the project." }),
15330
+ title: external_exports.string().meta({ description: "Display title." }),
15331
+ description: external_exports.string().optional().meta({ description: "What this product is." }),
15332
+ platforms: external_exports.array(PlatformSchema).meta({
15333
+ description: "The platforms this product can ship on; empty means availability is not tracked."
15334
+ }),
15335
+ root_node_id: external_exports.string().optional().meta({ description: "This product's journey anchor." })
15336
+ }).catchall(external_exports.unknown()).meta({ id: "ProductDefinition", description: "A product definition (docs/spec/bundle-format.md \xA7 Products)." });
15192
15337
  var ProjectMetadataSchema = external_exports.object({
15193
15338
  view_card_variant: external_exports.enum(["compact", "large"]).optional(),
15194
15339
  maps: external_exports.array(MapDefinitionSchema).optional().meta({
15195
15340
  description: "Stored map definitions (docs/spec/maps.md \xA7 Storage) \u2014 additive; unknown fields preserved."
15341
+ }),
15342
+ map_display: external_exports.record(external_exports.string(), MapDisplayOptionsSchema).optional().meta({
15343
+ description: "Per-map display overrides keyed by map id (docs/spec/maps.md \xA7 Display Options) \u2014 the only path open to the built-in maps."
15344
+ }),
15345
+ products: external_exports.array(ProductDefinitionSchema).optional().meta({
15346
+ description: "Product definitions (docs/spec/bundle-format.md \xA7 Products) \u2014 additive; unknown fields preserved."
15196
15347
  })
15197
15348
  }).catchall(external_exports.unknown()).meta({ id: "ProjectMetadata", description: "Optional project-level UI settings." });
15198
15349
  var ProjectSchema = external_exports.object({
@@ -15229,6 +15380,9 @@ var ProjectBundleSchema = external_exports.object({
15229
15380
  });
15230
15381
 
15231
15382
  // ../schema/src/maps.ts
15383
+ var MAP_FLOW_PLATFORMS_MODES = ["rings", "bars"];
15384
+ var MAP_VIEW_PLATFORMS_MODES = ["chips", "rows"];
15385
+ var MAP_MINIMAP_COLOR_MODES = ["status", "species"];
15232
15386
  var KIND_DEFAULTS = {
15233
15387
  journey: { species: ["flow", "view"], edge_types: ["composes"] },
15234
15388
  system: { species: ["view", "api-endpoint", "data-model"], edge_types: ["calls", "displays", "queries"] }
@@ -15319,6 +15473,23 @@ function listMaps(project) {
15319
15473
  return [...BUILT_IN_MAPS, ...custom2];
15320
15474
  }
15321
15475
 
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
+
15322
15493
  // ../schema/src/validate.ts
15323
15494
  var VALID_STAGES = ["beta", "monitoring", "deprecated"];
15324
15495
  var VALID_VIEW_CARD_VARIANTS = ["compact", "large"];
@@ -15330,25 +15501,6 @@ function estimateDataUriBytes(dataUri) {
15330
15501
  const padding = payload.endsWith("==") ? 2 : payload.endsWith("=") ? 1 : 0;
15331
15502
  return Math.floor(payload.length * 3 / 4) - padding;
15332
15503
  }
15333
- var VALID_EDGE_SEMANTICS = {
15334
- composes: [
15335
- ["flow", "view"],
15336
- ["flow", "flow"],
15337
- ["view", "flow"],
15338
- ["view", "view"]
15339
- ],
15340
- calls: [
15341
- ["view", "api-endpoint"],
15342
- ["flow", "api-endpoint"],
15343
- ["api-endpoint", "api-endpoint"]
15344
- ],
15345
- displays: [["view", "data-model"]],
15346
- queries: [["api-endpoint", "data-model"]],
15347
- covers: [
15348
- ["acceptance", "view"],
15349
- ["acceptance", "flow"]
15350
- ]
15351
- };
15352
15504
  function isIsoDate(value) {
15353
15505
  return typeof value === "string" && !Number.isNaN(Date.parse(value));
15354
15506
  }
@@ -15583,6 +15735,38 @@ function validateBundle(input) {
15583
15735
  `project.root_node_id "${rootNodeId}" does not reference an existing node`
15584
15736
  );
15585
15737
  }
15738
+ const checkMapDisplay = (display, path, subject) => {
15739
+ if (typeof display !== "object" || display === null || Array.isArray(display)) return;
15740
+ const options = display;
15741
+ const modes = [
15742
+ ["flow_platforms", MAP_FLOW_PLATFORMS_MODES],
15743
+ ["view_platforms", MAP_VIEW_PLATFORMS_MODES],
15744
+ ["minimap_color", MAP_MINIMAP_COLOR_MODES]
15745
+ ];
15746
+ for (const [key, allowed] of modes) {
15747
+ const value = options[key];
15748
+ if (value !== void 0 && (typeof value !== "string" || !allowed.includes(value))) {
15749
+ warn(
15750
+ `${path}.${key}`,
15751
+ "map-unknown-display",
15752
+ `${subject} sets ${key} to "${String(value)}"; expected one of ${allowed.join(", ")} (renderers fall back to the default)`
15753
+ );
15754
+ }
15755
+ }
15756
+ if (options.images !== void 0 && typeof options.images !== "boolean") {
15757
+ warn(
15758
+ `${path}.images`,
15759
+ "map-unknown-display",
15760
+ `${subject} sets images to a non-boolean value (renderers fall back to the default)`
15761
+ );
15762
+ }
15763
+ };
15764
+ const mapDisplayOverrides = projectMetadata?.map_display;
15765
+ if (typeof mapDisplayOverrides === "object" && mapDisplayOverrides !== null && !Array.isArray(mapDisplayOverrides)) {
15766
+ for (const [mapId, display] of Object.entries(mapDisplayOverrides)) {
15767
+ checkMapDisplay(display, `project.metadata.map_display.${mapId}`, `Map "${mapId}"`);
15768
+ }
15769
+ }
15586
15770
  const storedMaps = projectMetadata?.maps;
15587
15771
  if (Array.isArray(storedMaps)) {
15588
15772
  const seenMapIds = /* @__PURE__ */ new Set();
@@ -15630,8 +15814,122 @@ function validateBundle(input) {
15630
15814
  }
15631
15815
  });
15632
15816
  }
15817
+ checkMapDisplay(map2.display, `${path}.display`, `Map "${mapId ?? index}"`);
15818
+ });
15819
+ }
15820
+ const storedProducts = projectMetadata?.products;
15821
+ const declaredProductIds = /* @__PURE__ */ new Set();
15822
+ if (Array.isArray(storedProducts)) {
15823
+ const seenProductIds = /* @__PURE__ */ new Set();
15824
+ storedProducts.forEach((definition, index) => {
15825
+ if (typeof definition !== "object" || definition === null || Array.isArray(definition)) return;
15826
+ const product = definition;
15827
+ const path = `project.metadata.products[${index}]`;
15828
+ const productId = typeof product.id === "string" ? product.id : void 0;
15829
+ if (productId === void 0) return;
15830
+ if (seenProductIds.has(productId)) {
15831
+ warn(`${path}.id`, "product-duplicate-id", `Duplicate product id "${productId}" \u2014 the first wins`);
15832
+ } else {
15833
+ seenProductIds.add(productId);
15834
+ if (productId.trim() !== "") declaredProductIds.add(productId);
15835
+ }
15836
+ if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(productId)) {
15837
+ warn(`${path}.id`, "product-invalid-id", `Product id "${productId}" is not kebab-case`);
15838
+ }
15633
15839
  });
15634
15840
  }
15841
+ const hasProducts = declaredProductIds.size > 0;
15842
+ const anchorsByAcceptance = /* @__PURE__ */ new Map();
15843
+ for (const edge of edges) {
15844
+ if (edge.edge_type !== "covers") continue;
15845
+ const source = typeof edge.source_id === "string" ? edge.source_id : void 0;
15846
+ const target = typeof edge.target_id === "string" ? edge.target_id : void 0;
15847
+ if (source === void 0 || target === void 0) continue;
15848
+ const list = anchorsByAcceptance.get(source) ?? [];
15849
+ list.push(target);
15850
+ anchorsByAcceptance.set(source, list);
15851
+ }
15852
+ const menuByProduct = /* @__PURE__ */ new Map();
15853
+ if (hasProducts) {
15854
+ for (const definition of resolveProducts({ metadata: projectMetadata })) {
15855
+ menuByProduct.set(
15856
+ definition.id,
15857
+ new Set(Array.isArray(definition.platforms) ? definition.platforms : [])
15858
+ );
15859
+ }
15860
+ }
15861
+ const productByNodeId = /* @__PURE__ */ new Map();
15862
+ const indexByNodeId = /* @__PURE__ */ new Map();
15863
+ nodes.forEach((node, index) => {
15864
+ const nodeId = typeof node.id === "string" ? node.id : `#${index}`;
15865
+ const species = node.species;
15866
+ const base = `nodes[${index}]`;
15867
+ indexByNodeId.set(nodeId, index);
15868
+ const metadata = node.metadata ?? {};
15869
+ const membership = typeof metadata.product === "string" ? metadata.product : void 0;
15870
+ const storesMembership = species !== void 0 && PRODUCT_MEMBERSHIP_SPECIES.includes(species);
15871
+ if (membership !== void 0 && !storesMembership) {
15872
+ const detail = SPECIES_IDS.includes(species) ? `${species} membership is derived from consumers and must not be stored` : "metadata.product is only meaningful on flow, view, and acceptance nodes";
15873
+ warn(`${base}.metadata.product`, "product-membership-wrong-species", `Node ${nodeId}: ${detail}`);
15874
+ return;
15875
+ }
15876
+ if (!storesMembership) return;
15877
+ if (membership === void 0) {
15878
+ if (!hasProducts) return;
15879
+ if (species === "acceptance") {
15880
+ if (!anchorsByAcceptance.has(nodeId)) {
15881
+ warn(
15882
+ `${base}.metadata.product`,
15883
+ "acceptance-product-unassigned",
15884
+ `Acceptance ${nodeId} covers nothing and names no product \u2014 it will show only under "All products"`
15885
+ );
15886
+ }
15887
+ } else {
15888
+ warn(
15889
+ `${base}.metadata.product`,
15890
+ "unassigned-membership",
15891
+ `Node ${nodeId}: no product membership \u2014 it will show only under "All products"`
15892
+ );
15893
+ }
15894
+ return;
15895
+ }
15896
+ productByNodeId.set(nodeId, membership);
15897
+ if (!declaredProductIds.has(membership)) {
15898
+ warn(
15899
+ `${base}.metadata.product`,
15900
+ "product-unknown-reference",
15901
+ `Node ${nodeId}: product "${membership}" is not declared on the project`
15902
+ );
15903
+ return;
15904
+ }
15905
+ const menu = menuByProduct.get(membership);
15906
+ const nodePlatforms = Array.isArray(node.platforms) ? node.platforms : [];
15907
+ if (menu) {
15908
+ for (const platform of nodePlatforms) {
15909
+ if (typeof platform === "string" && !menu.has(platform)) {
15910
+ warn(
15911
+ `${base}.platforms`,
15912
+ "product-platform-not-in-menu",
15913
+ `Node ${nodeId}: platform "${platform}" is not in product "${membership}"'s menu`
15914
+ );
15915
+ }
15916
+ }
15917
+ }
15918
+ });
15919
+ if (hasProducts) {
15920
+ for (const [acceptanceId, anchors] of anchorsByAcceptance) {
15921
+ const acceptanceIndex = indexByNodeId.get(acceptanceId);
15922
+ if (acceptanceIndex === void 0) continue;
15923
+ const spanned = new Set(anchors.map((id) => productByNodeId.get(id)).filter((id) => Boolean(id)));
15924
+ if (spanned.size > 1) {
15925
+ warn(
15926
+ `nodes[${acceptanceIndex}].metadata.product`,
15927
+ "acceptance-covers-span-products",
15928
+ `Acceptance ${acceptanceId} covers anchors in ${[...spanned].sort().join(" and ")} \u2014 statuses may conflate products`
15929
+ );
15930
+ }
15931
+ }
15932
+ }
15635
15933
  const edgeIds = /* @__PURE__ */ new Set();
15636
15934
  const edgeSignatures = /* @__PURE__ */ new Set();
15637
15935
  const composesSet = /* @__PURE__ */ new Set();
@@ -16408,6 +16706,13 @@ function requireString(args, key) {
16408
16706
  }
16409
16707
  return value;
16410
16708
  }
16709
+ function normalizeStatusArg(value) {
16710
+ const normalized = normalizeStatus(value);
16711
+ if (normalized === void 0) {
16712
+ throw new ToolError(`"${value}" is not a status (expected one of: ${STATUS_IDS.join(", ")}).`);
16713
+ }
16714
+ return normalized;
16715
+ }
16411
16716
  function findNode(nodes, nodeId) {
16412
16717
  const node = nodes.find((candidate) => candidate.id === nodeId);
16413
16718
  if (!node) throw new ToolError(`No node with id "${nodeId}".`);
@@ -16494,10 +16799,11 @@ function buildCatalog(ctx) {
16494
16799
  const { nodes, edges } = await load(ctx);
16495
16800
  const query = typeof args.query === "string" ? args.query.toLowerCase() : void 0;
16496
16801
  const limit = typeof args.limit === "number" && args.limit >= 1 ? Math.floor(args.limit) : 50;
16802
+ const status = typeof args.status === "string" ? normalizeStatusArg(args.status) : void 0;
16497
16803
  const anchorCoveringIds = typeof args.anchor === "string" ? new Set(acceptancesCovering(args.anchor, nodes, edges).map((node) => node.id)) : void 0;
16498
16804
  const matches = nodes.filter((node) => {
16499
16805
  if (typeof args.species === "string" && node.species !== args.species) return false;
16500
- if (typeof args.status === "string" && node.status !== args.status) return false;
16806
+ if (status !== void 0 && node.status !== status) return false;
16501
16807
  if (typeof args.platform === "string" && !node.platforms.includes(args.platform))
16502
16808
  return false;
16503
16809
  if (typeof args.value === "string" && (node.species !== "acceptance" || !(node.metadata?.values ?? []).includes(args.value))) return false;
@@ -16670,7 +16976,7 @@ ${node.description ?? ""}`.toLowerCase();
16670
16976
  project_id: graph.project.id,
16671
16977
  title,
16672
16978
  species,
16673
- status: typeof args.status === "string" ? args.status : "idea",
16979
+ status: typeof args.status === "string" ? normalizeStatusArg(args.status) : "idea",
16674
16980
  platforms,
16675
16981
  ...typeof args.description === "string" ? { description: args.description } : {},
16676
16982
  ...typeof args.metadata === "object" && args.metadata !== null ? { metadata: args.metadata } : {}
@@ -16721,6 +17027,7 @@ ${node.description ?? ""}`.toLowerCase();
16721
17027
  throw new ToolError(`Field "${key}" cannot be patched (allowed: ${[...UPDATABLE_NODE_FIELDS].join(", ")}).`);
16722
17028
  }
16723
17029
  }
17030
+ if (typeof patch.status === "string") patch.status = normalizeStatusArg(patch.status);
16724
17031
  const graph = await load(ctx);
16725
17032
  const current = findNode(graph.nodes, nodeId);
16726
17033
  const ops = [{ op: "update_node", node_id: nodeId, patch }];
@@ -16899,7 +17206,9 @@ function readBundle(filePath) {
16899
17206
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
16900
17207
  throw new Error("Bundle must be a JSON object.");
16901
17208
  }
16902
- return parsed;
17209
+ const record2 = parsed;
17210
+ if (!Array.isArray(record2.nodes)) return record2;
17211
+ return migrateStatusVocabulary(record2);
16903
17212
  }
16904
17213
 
16905
17214
  // ../cli/src/lib/journal-io.ts
@@ -17053,19 +17362,25 @@ function createRemoteStore(options) {
17053
17362
  ]);
17054
17363
  const nodes = bundle.nodes ?? [];
17055
17364
  const edges = bundle.edges ?? [];
17365
+ const folded = { ...bundle, journal };
17366
+ let validation;
17367
+ const validate = () => validation ??= validateBundle(folded);
17056
17368
  return {
17057
- // `loaded` mirrors the file store's BundleValidation shape closely
17058
- // enough for the read tools, which only ever touch bundle/nodes/edges/
17059
- // journal. The server has already validated everything it stores, so
17060
- // there are no findings to carry here.
17061
17369
  loaded: {
17062
- bundle: { ...bundle, journal },
17370
+ bundle: folded,
17063
17371
  nodes,
17064
17372
  edges,
17065
17373
  journal,
17066
17374
  sidecarLoaded: false,
17067
- errors: [],
17068
- warnings: []
17375
+ // Nothing was folded in from a JSONL sidecar, so there are no line
17376
+ // findings — hosted journals arrive already parsed.
17377
+ sidecarFindings: [],
17378
+ get result() {
17379
+ return validate();
17380
+ },
17381
+ get valid() {
17382
+ return validate().errors.length === 0;
17383
+ }
17069
17384
  },
17070
17385
  nodes,
17071
17386
  edges,
@@ -17171,7 +17486,7 @@ function resolveRemoteConfig(argv2, env, cwd) {
17171
17486
  }
17172
17487
 
17173
17488
  // src/index.ts
17174
- var VERSION = "0.1.0";
17489
+ var VERSION = "0.2.2";
17175
17490
  var argv = process.argv.slice(2);
17176
17491
  if (argv.includes("--help") || argv.includes("-h")) {
17177
17492
  process.stdout.write(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkaik-mcp",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
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",