arkaik 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/io.js CHANGED
@@ -14787,7 +14787,25 @@ var FlowPlaylistSchema = external_exports.object({
14787
14787
  entries: external_exports.array(PlaylistEntrySchema)
14788
14788
  }).meta({ id: "FlowPlaylist" });
14789
14789
 
14790
+ // ../schema/src/screenshots.ts
14791
+ function reduceScreenshotSlots(ordered) {
14792
+ const slots = /* @__PURE__ */ new Map();
14793
+ for (const ev of ordered) {
14794
+ if (ev.type !== "screenshot.recorded" && ev.type !== "screenshot.removed") continue;
14795
+ if (typeof ev.node_id !== "string" || typeof ev.platform !== "string") continue;
14796
+ let byPlatform = slots.get(ev.node_id);
14797
+ if (!byPlatform) {
14798
+ byPlatform = /* @__PURE__ */ new Map();
14799
+ slots.set(ev.node_id, byPlatform);
14800
+ }
14801
+ byPlatform.set(ev.platform, ev.type === "screenshot.removed" ? null : ev);
14802
+ }
14803
+ return slots;
14804
+ }
14805
+
14790
14806
  // ../schema/src/journal.ts
14807
+ var SCREENSHOT_SOURCES = ["ci", "manual"];
14808
+ var SCREENSHOT_FORMS = ["url", "path", "data"];
14791
14809
  function orderEvents(events) {
14792
14810
  const key = (v) => typeof v === "string" ? v : "";
14793
14811
  return [...events].sort((a, b) => {
@@ -14857,9 +14875,14 @@ var NODE_REF_FIELDS = {
14857
14875
  "ref.added": ["node_id"],
14858
14876
  "ref.removed": ["node_id"],
14859
14877
  "ref.status_changed": ["node_id"],
14878
+ "screenshot.recorded": ["node_id"],
14879
+ "screenshot.removed": ["node_id"],
14860
14880
  "idea.proposed": ["node_id"],
14861
14881
  "request.filed": ["node_id"]
14862
14882
  };
14883
+ function isRecord(value) {
14884
+ return typeof value === "object" && value !== null && !Array.isArray(value);
14885
+ }
14863
14886
  function statusesAgree(last, snapshot) {
14864
14887
  if (last === snapshot) return true;
14865
14888
  if (typeof snapshot !== "string") return false;
@@ -15040,6 +15063,41 @@ function crossCheckJournal(bundle) {
15040
15063
  });
15041
15064
  }
15042
15065
  }
15066
+ const slots = reduceScreenshotSlots(ordered);
15067
+ nodesRaw.forEach((n, index) => {
15068
+ const nodeId = str(n?.id);
15069
+ if (nodeId === void 0) return;
15070
+ const metadata = isRecord(n.metadata) ? n.metadata : {};
15071
+ const shots = isRecord(metadata.platformScreenshots) ? metadata.platformScreenshots : {};
15072
+ const eventSlots = slots.get(nodeId);
15073
+ const platforms = /* @__PURE__ */ new Set([...Object.keys(shots), ...eventSlots ? eventSlots.keys() : []]);
15074
+ for (const platform of platforms) {
15075
+ const last = eventSlots?.get(platform);
15076
+ if (last === void 0) continue;
15077
+ const slot = typeof shots[platform] === "string" ? shots[platform] : void 0;
15078
+ let says;
15079
+ let agrees;
15080
+ if (last === null) {
15081
+ agrees = slot === void 0;
15082
+ says = "it was removed";
15083
+ } else if (last.form === "data") {
15084
+ agrees = slot !== void 0;
15085
+ says = "a data URI was recorded";
15086
+ } else {
15087
+ const url2 = str(last.url);
15088
+ agrees = slot === url2;
15089
+ says = url2 === void 0 ? "an unknown value was recorded" : `"${url2}" was recorded`;
15090
+ }
15091
+ if (!agrees) {
15092
+ findings.push({
15093
+ path: `nodes[${index}].metadata.platformScreenshots.${platform}`,
15094
+ rule: "screenshot-untracked",
15095
+ message: `Node "${nodeId}": platformScreenshots.${platform} is ${slot === void 0 ? "empty" : `"${slot}"`} but the journal's last screenshot event says ${says} \u2014 write screenshots through record_screenshot, not update_node.`,
15096
+ severity: "warning"
15097
+ });
15098
+ }
15099
+ }
15100
+ });
15043
15101
  return findings;
15044
15102
  }
15045
15103
  function missingProvenanceNodeIds(snapshotNodeIds, events) {
@@ -15169,6 +15227,19 @@ var RefStatusChangedEventSchema = external_exports.object({
15169
15227
  to: external_exports.string(),
15170
15228
  synced_at: external_exports.string()
15171
15229
  }).catchall(external_exports.unknown());
15230
+ var ScreenshotRecordedEventSchema = external_exports.object({
15231
+ ...envelope,
15232
+ type: external_exports.literal("screenshot.recorded"),
15233
+ node_id: external_exports.string(),
15234
+ platform: PlatformSchema,
15235
+ source: external_exports.enum(SCREENSHOT_SOURCES),
15236
+ form: external_exports.enum(SCREENSHOT_FORMS),
15237
+ url: external_exports.string().optional(),
15238
+ commit: external_exports.string().optional(),
15239
+ order: external_exports.number().int().nonnegative().optional(),
15240
+ detail: external_exports.string().optional()
15241
+ }).catchall(external_exports.unknown());
15242
+ var ScreenshotRemovedEventSchema = external_exports.object({ ...envelope, type: external_exports.literal("screenshot.removed"), node_id: external_exports.string(), platform: PlatformSchema }).catchall(external_exports.unknown());
15172
15243
  var JournalBaselineEventSchema = external_exports.object({ ...envelope, type: external_exports.literal("journal.baseline"), node_ids: external_exports.array(external_exports.string()) }).catchall(external_exports.unknown());
15173
15244
  var QualityAuditCompletedEventSchema = external_exports.object({
15174
15245
  ...envelope,
@@ -15255,6 +15326,8 @@ var JOURNAL_EVENT_SCHEMAS = {
15255
15326
  "ref.added": RefAddedEventSchema,
15256
15327
  "ref.removed": RefRemovedEventSchema,
15257
15328
  "ref.status_changed": RefStatusChangedEventSchema,
15329
+ "screenshot.recorded": ScreenshotRecordedEventSchema,
15330
+ "screenshot.removed": ScreenshotRemovedEventSchema,
15258
15331
  "journal.baseline": JournalBaselineEventSchema,
15259
15332
  "quality.audit.completed": QualityAuditCompletedEventSchema,
15260
15333
  "quality.assessment.scored": QualityAssessmentScoredEventSchema,
@@ -15278,6 +15351,8 @@ var KnownJournalEventSchema = external_exports.union([
15278
15351
  RefAddedEventSchema,
15279
15352
  RefRemovedEventSchema,
15280
15353
  RefStatusChangedEventSchema,
15354
+ ScreenshotRecordedEventSchema,
15355
+ ScreenshotRemovedEventSchema,
15281
15356
  JournalBaselineEventSchema,
15282
15357
  QualityAuditCompletedEventSchema,
15283
15358
  QualityAssessmentScoredEventSchema,
@@ -15287,6 +15362,49 @@ var KnownJournalEventSchema = external_exports.union([
15287
15362
  QualitySignalTrippedEventSchema
15288
15363
  ]);
15289
15364
 
15365
+ // ../schema/src/quality.ts
15366
+ var asArray = (value) => Array.isArray(value) ? value : [];
15367
+ var CROSS_SURFACE_ID = "cross-surface";
15368
+ function mergeKritikLibrary(pack, overlay) {
15369
+ if (!overlay || typeof overlay !== "object") return pack;
15370
+ const domains = [...asArray(pack.domains)];
15371
+ for (const domain2 of asArray(overlay.domains)) {
15372
+ if (typeof domain2?.code !== "string" || domain2.code === "") continue;
15373
+ const at = domains.findIndex((existing) => existing?.code === domain2.code);
15374
+ if (at >= 0) domains[at] = domain2;
15375
+ else domains.push(domain2);
15376
+ }
15377
+ const criteria = [...asArray(pack.criteria)];
15378
+ for (const criterion of asArray(overlay.criteria)) {
15379
+ if (typeof criterion?.id !== "string" || criterion.id === "") continue;
15380
+ const at = criteria.findIndex((existing) => existing?.id === criterion.id);
15381
+ if (at >= 0) criteria[at] = criterion;
15382
+ else criteria.push(criterion);
15383
+ }
15384
+ const scales = pack.scales || overlay.scales ? { ...pack.scales ?? {}, ...overlay.scales ?? {} } : void 0;
15385
+ return { ...pack, domains, criteria, ...scales ? { scales } : {} };
15386
+ }
15387
+
15388
+ // ../schema/src/quality-plan.ts
15389
+ var KRITIK_PLAN_SCHEMA = "arkaik.kritik.plan/1";
15390
+ var SCOPED_AUDIT_ID = /-scoped(-\d+)?$/;
15391
+ var PLAN_ID = /^\d{4}-\d{2}-zplan-\d{4}$/;
15392
+ function isScopedAuditId(id) {
15393
+ return typeof id === "string" && SCOPED_AUDIT_ID.test(id);
15394
+ }
15395
+ function isPlanId(id) {
15396
+ return typeof id === "string" && PLAN_ID.test(id);
15397
+ }
15398
+ function planPartId(planId, domain2, surface) {
15399
+ const id = `${planId}-${domain2.toLowerCase()}-${surface.toLowerCase()}`;
15400
+ if (isScopedAuditId(id)) {
15401
+ throw new Error(
15402
+ `the part ${domain2}:${surface} would be named "${id}", which reads as a scoped re-audit. A surface named "scoped", or ending in "-scoped" or "-scoped-NN", cannot be planned.`
15403
+ );
15404
+ }
15405
+ return id;
15406
+ }
15407
+
15290
15408
  // ../schema/src/quality-schemas.ts
15291
15409
  var GradeSchema = external_exports.enum(["A", "B", "C", "D", "E"]);
15292
15410
  var KritikScalesSchema = external_exports.object({
@@ -15389,6 +15507,92 @@ var QualitySectionSchema = external_exports.object({
15389
15507
  id: "QualitySection",
15390
15508
  description: "The project's Kritik state (docs/rfcs/kritik.md \xA7 4.1) \u2014 profile, assessments, findings. Criteria are library content, not graph nodes; the matrix is a projection, never stored."
15391
15509
  });
15510
+ var KritikPlanBandSchema = external_exports.object({
15511
+ low: external_exports.number().nonnegative(),
15512
+ mid: external_exports.number().nonnegative(),
15513
+ high: external_exports.number().nonnegative()
15514
+ });
15515
+ var KritikPlanCellSchema = external_exports.object({ criterion_id: external_exports.string(), surface: external_exports.string() });
15516
+ var KritikPlanPartSchema = external_exports.object({
15517
+ domain: external_exports.string().regex(/^[A-Z0-9]{2,5}$/),
15518
+ surface: external_exports.string().min(1),
15519
+ auditId: external_exports.string(),
15520
+ cells: external_exports.array(KritikPlanCellSchema).min(1),
15521
+ steps: external_exports.number().int().nonnegative(),
15522
+ estimate: external_exports.object({
15523
+ tokens: KritikPlanBandSchema,
15524
+ usd: KritikPlanBandSchema.nullable(),
15525
+ inputs: external_exports.object({
15526
+ P: external_exports.number(),
15527
+ B: external_exports.number(),
15528
+ c: KritikPlanBandSchema,
15529
+ q: KritikPlanBandSchema,
15530
+ h: KritikPlanBandSchema,
15531
+ V: KritikPlanBandSchema
15532
+ }),
15533
+ calibrated: external_exports.boolean()
15534
+ }).nullable(),
15535
+ status: external_exports.enum(["included", "deferred"]),
15536
+ prompt: external_exports.string()
15537
+ });
15538
+ var KritikPlanSchema = external_exports.object({
15539
+ schema: external_exports.literal(KRITIK_PLAN_SCHEMA),
15540
+ planId: external_exports.string(),
15541
+ createdAt: external_exports.iso.datetime(),
15542
+ commit: external_exports.string().nullable(),
15543
+ frameworkVersion: external_exports.string(),
15544
+ tier: external_exports.string().nullable(),
15545
+ budgetTokens: external_exports.number().int().positive().nullable(),
15546
+ budgetUsd: external_exports.number().positive().nullable(),
15547
+ pricePerMTok: external_exports.number().positive().nullable(),
15548
+ parts: external_exports.array(KritikPlanPartSchema).min(1),
15549
+ totals: external_exports.object({
15550
+ cells: external_exports.number().int(),
15551
+ steps: external_exports.number().int(),
15552
+ applicableCells: external_exports.number().int(),
15553
+ tokens: KritikPlanBandSchema.nullable(),
15554
+ usd: KritikPlanBandSchema.nullable()
15555
+ }),
15556
+ prompt: external_exports.string(),
15557
+ recordCommand: external_exports.string()
15558
+ }).superRefine((plan, ctx) => {
15559
+ if (plan.budgetUsd !== null && plan.pricePerMTok === null) {
15560
+ ctx.addIssue({ code: "custom", path: ["pricePerMTok"], message: "required when budgetUsd is set" });
15561
+ }
15562
+ if (!isPlanId(plan.planId)) {
15563
+ ctx.addIssue({ code: "custom", path: ["planId"], message: "not a plan id (YYYY-MM-zplan-DDNN)" });
15564
+ return;
15565
+ }
15566
+ const seen = /* @__PURE__ */ new Map();
15567
+ plan.parts.forEach((part, index) => {
15568
+ let expected;
15569
+ try {
15570
+ expected = planPartId(plan.planId, part.domain, part.surface);
15571
+ } catch {
15572
+ expected = null;
15573
+ }
15574
+ if (part.auditId !== expected) {
15575
+ ctx.addIssue({
15576
+ code: "custom",
15577
+ path: ["parts", index, "auditId"],
15578
+ message: expected === null ? `the surface "${part.surface}" cannot be planned, so no audit id fits this part` : `not this part's audit id: expected "${expected}"`
15579
+ });
15580
+ } else if (seen.has(part.auditId)) {
15581
+ ctx.addIssue({ code: "custom", path: ["parts", index, "auditId"], message: `repeats the audit id of part ${seen.get(part.auditId)}` });
15582
+ } else {
15583
+ seen.set(part.auditId, index);
15584
+ }
15585
+ part.cells.forEach((cell, cellIndex) => {
15586
+ if (cell.surface !== part.surface) {
15587
+ ctx.addIssue({
15588
+ code: "custom",
15589
+ path: ["parts", index, "cells", cellIndex, "surface"],
15590
+ message: `not the part's surface "${part.surface}"`
15591
+ });
15592
+ }
15593
+ });
15594
+ });
15595
+ });
15392
15596
 
15393
15597
  // ../schema/src/bundle.ts
15394
15598
  var PlatformStatusMapSchema = external_exports.partialRecord(
@@ -15407,6 +15611,15 @@ var PlatformScreenshotsMapSchema = external_exports.partialRecord(
15407
15611
  id: "PlatformScreenshotsMap",
15408
15612
  description: "Per-platform screenshot: a relative path, an absolute URL, or a data URI (see docs/spec/bundle-format.md \xA7 Asset Values)."
15409
15613
  });
15614
+ var PlatformScreenshotMetaSchema = external_exports.object({
15615
+ ts: external_exports.string().optional().meta({ description: "ISO 8601 timestamp of when the current shot was recorded." }),
15616
+ source: external_exports.enum(SCREENSHOT_SOURCES).optional().meta({ description: "Who recorded the current shot: ci or manual." }),
15617
+ form: external_exports.enum(SCREENSHOT_FORMS).optional().meta({ description: "Asset form of the slot value: url, path or data (see Asset Values)." }),
15618
+ commit: external_exports.string().optional().meta({ description: "The sha a CI shot was rendered from." }),
15619
+ order: external_exports.number().int().nonnegative().optional().meta({ description: "That commit's height on the default branch." }),
15620
+ ci_order: external_exports.number().int().nonnegative().optional().meta({ description: "The highest CI order ever accepted for this slot, kept across a manual shot and a removal so a late CI re-run cannot overwrite a newer shot." })
15621
+ }).meta({ id: "PlatformScreenshotMeta", description: "Provenance of the current per-platform screenshot and the CI order watermark." });
15622
+ var PlatformScreenshotMetaMapSchema = external_exports.partialRecord(PlatformSchema, PlatformScreenshotMetaSchema).meta({ id: "PlatformScreenshotMetaMap", description: "Per-platform screenshot provenance (see PlatformScreenshotMeta)." });
15410
15623
  var RefSchema = external_exports.object({
15411
15624
  id: external_exports.string().meta({ description: 'Unique within the node, kebab-case (e.g. "gh-142").' }),
15412
15625
  type: external_exports.string().meta({
@@ -15433,6 +15646,7 @@ var NodeMetadataSchema = external_exports.object({
15433
15646
  platformNotes: PlatformNotesMapSchema.optional(),
15434
15647
  platformStatuses: PlatformStatusMapSchema.optional(),
15435
15648
  platformScreenshots: PlatformScreenshotsMapSchema.optional(),
15649
+ platformScreenshotMeta: PlatformScreenshotMetaMapSchema.optional(),
15436
15650
  refs: external_exports.array(RefSchema).optional().meta({ description: "Typed external references on the node." }),
15437
15651
  gherkin: external_exports.string().optional().meta({
15438
15652
  description: "Acceptance nodes only: exactly one Given/When/Then scenario (the How). A second scenario is a second acceptance node."
@@ -15489,18 +15703,18 @@ var MapDisplayOptionsSchema = external_exports.object({
15489
15703
  }).catchall(external_exports.unknown()).meta({ id: "MapDisplayOptions", description: "How a map draws its cards (docs/spec/maps.md \xA7 Display Options)." });
15490
15704
  var MapDefinitionSchema = external_exports.object({
15491
15705
  id: external_exports.string().meta({
15492
- description: "Kebab-case, unique within the project; built-in ids (journey, system) are reserved."
15706
+ description: "Kebab-case, unique within the project; built-in ids (journey, system, screens) are reserved."
15493
15707
  }),
15494
15708
  title: external_exports.string().meta({ description: "Display title." }),
15495
15709
  description: external_exports.string().optional().meta({ description: "What this map is for." }),
15496
15710
  kind: external_exports.string().meta({
15497
- description: "Map kind: journey | system. Selects the renderer and selection defaults; unrecognized kinds are preserved and listed as unrenderable."
15711
+ description: "Map kind: journey | system | screens. Selects the renderer and selection defaults; unrecognized kinds are preserved and listed as unrenderable."
15498
15712
  }),
15499
15713
  species: external_exports.array(external_exports.string()).optional().meta({
15500
- description: "Node filter; defaults by kind (journey: flow+view; system: view+api-endpoint+data-model)."
15714
+ description: "Node filter; defaults by kind (journey: flow+view; system: view+api-endpoint+data-model; screens: flow+view)."
15501
15715
  }),
15502
15716
  edge_types: external_exports.array(external_exports.string()).optional().meta({
15503
- description: "Edge filter; defaults by kind (journey: composes; system: calls+displays+queries)."
15717
+ description: "Edge filter; defaults by kind (journey: composes; system: calls+displays+queries; screens: none)."
15504
15718
  }),
15505
15719
  root_node_id: external_exports.string().optional().meta({
15506
15720
  description: "Scope anchor: the subgraph is the undirected neighborhood reachable from this node."
@@ -15591,34 +15805,11 @@ function resolveProducts(project) {
15591
15805
  var MAP_FLOW_PLATFORMS_MODES = ["rings", "bars"];
15592
15806
  var MAP_VIEW_PLATFORMS_MODES = ["chips", "rows"];
15593
15807
  var MAP_MINIMAP_COLOR_MODES = ["status", "species"];
15594
- var BUILT_IN_MAP_IDS = ["journey", "system"];
15808
+ var BUILT_IN_MAP_IDS = ["journey", "system", "screens"];
15595
15809
  function isBuiltInMapId(id) {
15596
15810
  return BUILT_IN_MAP_IDS.includes(id);
15597
15811
  }
15598
15812
 
15599
- // ../schema/src/quality.ts
15600
- var asArray = (value) => Array.isArray(value) ? value : [];
15601
- var CROSS_SURFACE_ID = "cross-surface";
15602
- function mergeKritikLibrary(pack, overlay) {
15603
- if (!overlay || typeof overlay !== "object") return pack;
15604
- const domains = [...asArray(pack.domains)];
15605
- for (const domain2 of asArray(overlay.domains)) {
15606
- if (typeof domain2?.code !== "string" || domain2.code === "") continue;
15607
- const at = domains.findIndex((existing) => existing?.code === domain2.code);
15608
- if (at >= 0) domains[at] = domain2;
15609
- else domains.push(domain2);
15610
- }
15611
- const criteria = [...asArray(pack.criteria)];
15612
- for (const criterion of asArray(overlay.criteria)) {
15613
- if (typeof criterion?.id !== "string" || criterion.id === "") continue;
15614
- const at = criteria.findIndex((existing) => existing?.id === criterion.id);
15615
- if (at >= 0) criteria[at] = criterion;
15616
- else criteria.push(criterion);
15617
- }
15618
- const scales = pack.scales || overlay.scales ? { ...pack.scales ?? {}, ...overlay.scales ?? {} } : void 0;
15619
- return { ...pack, domains, criteria, ...scales ? { scales } : {} };
15620
- }
15621
-
15622
15813
  // ../schema/src/validate.ts
15623
15814
  var VALID_STAGES = ["beta", "monitoring", "deprecated"];
15624
15815
  var VALID_VIEW_CARD_VARIANTS = ["compact", "large"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkaik",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "description": "Arkaik CLI — link a repository to a hosted product graph, validate and pack bundles, mirror external ref status.",
5
5
  "license": "MIT",
6
6
  "type": "module",