arkaik 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -201,7 +201,7 @@ interface JournalEvent extends Record<string, unknown> {
201
201
  id: string;
202
202
  /** ISO 8601 timestamp. */
203
203
  ts: string;
204
- /** Who/what wrote it: "alexis", "claude-code", "arkaik-sync", "ci". */
204
+ /** Who/what wrote it: "alexis", "claude-code", "arkaik-sync", "arkaik-ci". */
205
205
  actor?: string;
206
206
  /** Event type — the v1 vocabulary, or an unknown forward-compatible value. */
207
207
  type: string;
@@ -230,6 +230,12 @@ interface NodeStatusChangedEvent extends JournalEvent {
230
230
  from: StatusId;
231
231
  to: StatusId;
232
232
  platform?: PlatformId;
233
+ /**
234
+ * Free-form evidence for the move — the deployment URL, the store build
235
+ * number. Written by the hosted `release:append` door, the one writer that
236
+ * always knows it; edits through the mutations route never carry it.
237
+ */
238
+ detail?: string;
233
239
  }
234
240
 
235
241
  interface NodeDeletedEvent extends JournalEvent {
package/dist/index.js CHANGED
@@ -15080,7 +15080,7 @@ function missingProvenanceNodeIds(snapshotNodeIds, events) {
15080
15080
  var envelope = {
15081
15081
  id: external_exports.string().meta({ description: "ULID \u2014 sortable, collision-free without coordination." }),
15082
15082
  ts: external_exports.string().meta({ description: "ISO 8601 timestamp." }),
15083
- actor: external_exports.string().optional().meta({ description: 'Who/what wrote it (e.g. "claude-code", "ci").' }),
15083
+ actor: external_exports.string().optional().meta({ description: 'Who/what wrote it (e.g. "claude-code", "arkaik-ci").' }),
15084
15084
  v: external_exports.number().int().optional().meta({ description: "Reserved per-event payload version; absent today." })
15085
15085
  };
15086
15086
  var JournalEventSchema = external_exports.object({
@@ -15107,7 +15107,8 @@ var NodeStatusChangedEventSchema = external_exports.object({
15107
15107
  // their legacy status ids, so strict per-type validation must accept them.
15108
15108
  from: AnyStatusSchema,
15109
15109
  to: AnyStatusSchema,
15110
- platform: PlatformSchema.optional()
15110
+ platform: PlatformSchema.optional(),
15111
+ detail: external_exports.string().optional()
15111
15112
  }).catchall(external_exports.unknown());
15112
15113
  var DecisionStatusChangedEventSchema = external_exports.object({
15113
15114
  ...envelope,
@@ -16971,8 +16972,8 @@ function makeEvent(type, payload = {}, options = {}) {
16971
16972
 
16972
16973
  // ../schema/src/promote.ts
16973
16974
  var DEFAULT_REF_POLICY = {
16974
- "github-pr": { open: "development", merged: "live", closed: null },
16975
- "gitlab-mr": { open: "development", merged: "live", closed: null }
16975
+ "github-pr": { open: "development", merged: "releasing", closed: null },
16976
+ "gitlab-mr": { open: "development", merged: "releasing", closed: null }
16976
16977
  };
16977
16978
  function resolveRefPolicy(bundle) {
16978
16979
  const declared = bundle.project.metadata?.ref_policy;
@@ -17031,6 +17032,10 @@ function computeRefPromotions(bundle) {
17031
17032
  skipped.push({ node_id: node.id, ref_id: ref.id, reason: "already-there", detail: to });
17032
17033
  continue;
17033
17034
  }
17035
+ if (from === "live") {
17036
+ skipped.push({ node_id: node.id, ref_id: ref.id, reason: "live", detail: to });
17037
+ continue;
17038
+ }
17034
17039
  promotions.push({
17035
17040
  node_id: node.id,
17036
17041
  ref_id: ref.id,
@@ -17053,6 +17058,41 @@ function promotionPatch(node, promotion) {
17053
17058
  };
17054
17059
  }
17055
17060
 
17061
+ // ../schema/src/mentions.ts
17062
+ function isPlatformId(value) {
17063
+ return PLATFORM_IDS.includes(value);
17064
+ }
17065
+ var ACCEPTANCE_MENTION = /\b(AC-[a-z0-9][a-z0-9-]*)(?:\\?@((?:(?!\bAC-[a-z0-9])\S)+))?/gi;
17066
+ var TRAILING_PROSE = /* @__PURE__ */ new Set([".", ",", ";", ":", "!", "?", ")", "]", "}", ">", "'", '"', "`", "*", "_", "~"]);
17067
+ function trimTrailingProse(token) {
17068
+ let end = token.length;
17069
+ while (end > 0 && TRAILING_PROSE.has(token[end - 1])) end -= 1;
17070
+ return token.slice(0, end);
17071
+ }
17072
+ function mentionedAcceptances(event) {
17073
+ const mentions = /* @__PURE__ */ new Map();
17074
+ const unknown2 = /* @__PURE__ */ new Map();
17075
+ for (const text of [event.title, event.body]) {
17076
+ if (!text) continue;
17077
+ for (const match of text.matchAll(ACCEPTANCE_MENTION)) {
17078
+ const id = `AC-${match[1].slice(3)}`;
17079
+ const written = match[2];
17080
+ if (written === void 0) {
17081
+ mentions.set(`${id}@`, { id, platform: null });
17082
+ continue;
17083
+ }
17084
+ const token = trimTrailingProse(written);
17085
+ const suffix = token.toLowerCase();
17086
+ if (!isPlatformId(suffix)) {
17087
+ unknown2.set(`${id}@${suffix}`, { id, platform: token || written });
17088
+ continue;
17089
+ }
17090
+ mentions.set(`${id}@${suffix}`, { id, platform: suffix });
17091
+ }
17092
+ }
17093
+ return { mentions: [...mentions.values()], unknown: [...unknown2.values()] };
17094
+ }
17095
+
17056
17096
  // ../schema/src/quality-ops.ts
17057
17097
  var DEFAULT_TARGET_LEVEL = 3;
17058
17098
  function upsertAssessment(assessments, next) {
@@ -18457,7 +18497,8 @@ function renderEventLine(event, nodesById) {
18457
18497
  const from = str(event.from) ?? "?";
18458
18498
  const to = str(event.to) ?? "?";
18459
18499
  const platform = str(event.platform);
18460
- return `${title(event.node_id, nodesById)}: ${from} -> ${to}${platform ? ` [${platform}]` : ""}`;
18500
+ const detail = str(event.detail);
18501
+ return `${title(event.node_id, nodesById)}: ${from} -> ${to}${platform ? ` [${platform}]` : ""}${detail ? ` - ${detail}` : ""}`;
18461
18502
  }
18462
18503
  case "node.deleted":
18463
18504
  return `${title(event.node_id, nodesById)} deleted`;
@@ -20300,13 +20341,273 @@ function runLinkCli(argv) {
20300
20341
  });
20301
20342
  }
20302
20343
 
20303
- // src/commands/restore.ts
20304
- import { existsSync as existsSync9, linkSync, mkdirSync as mkdirSync6, readFileSync as readFileSync9, unlinkSync, writeFileSync as writeFileSync9 } from "node:fs";
20344
+ // src/commands/live.ts
20345
+ import { readFileSync as readFileSync9 } from "node:fs";
20305
20346
  import { join as join8, resolve as resolve9 } from "node:path";
20306
20347
  var LINK_FILE2 = "docs/arkaik/arkaik.json";
20348
+ var DEFAULT_BASE_URL2 = "https://arkaik.app";
20349
+ var MAX_ENTRIES_PER_REQUEST = 50;
20350
+ var KNOWN_FLAGS = /* @__PURE__ */ new Set(["--platform", "--detail", "--mentions", "--paths", "--remote", "--dry-run", "--help"]);
20351
+ var VALUED_FLAGS = /* @__PURE__ */ new Set(["--platform", "--detail", "--mentions", "--paths", "--remote"]);
20352
+ var DROPPABLE_REASONS = /* @__PURE__ */ new Set(["platform_not_applicable", "unknown_node"]);
20353
+ var ACCEPTANCE_ID = /^AC-[A-Za-z0-9._-]+$/;
20354
+ var USAGE11 = `arkaik live \u2014 mark the acceptances a deploy carried live on one platform
20355
+
20356
+ Usage:
20357
+ arkaik live --platform <web|ios|android> [options] [AC-id ...]
20358
+
20359
+ Options:
20360
+ --platform <id> Required. The platform that went live.
20361
+ --detail <text> Evidence to record on the status change: a deploy URL, a build number.
20362
+ --mentions <file> JSON array of merged pull requests: [{ number, title, body, files }].
20363
+ Acceptances mentioned as AC-id@<platform> count; bare AC-id mentions
20364
+ count only when the PR touched one of --paths (or --paths is absent).
20365
+ --paths <prefixes> Comma-separated path prefixes that make a bare mention count (apps/web).
20366
+ --dry-run Print the entries and send nothing.
20367
+ --remote <url> Instance origin. Default: $ARKAIK_URL, else the link file's remote, else ${DEFAULT_BASE_URL2}
20368
+ -h, --help Show this help.
20369
+
20370
+ Environment:
20371
+ ARKAIK_TOKEN Required. A release:append token from <origin>/settings/tokens.
20372
+
20373
+ Reads ${LINK_FILE2} for the project id. Exit 0 when nothing needs marking; exit 1 on a refusal or any failed request.`;
20374
+ function flagValue2(argv, flag) {
20375
+ const index = argv.indexOf(flag);
20376
+ return index !== -1 ? argv[index + 1] : void 0;
20377
+ }
20378
+ function normalisePrefix(prefix) {
20379
+ const trimmed = prefix.trim().replace(/^(\.\/)+/, "").replace(/^\/+/, "").replace(/\/+$/, "");
20380
+ return trimmed === "" ? null : `${trimmed}/`;
20381
+ }
20382
+ function touchesAny(files, prefixes) {
20383
+ return files.some((file2) => prefixes.some((prefix) => file2.startsWith(prefix)));
20384
+ }
20385
+ function deriveLiveIds(prs, platform, paths) {
20386
+ const prefixes = paths.map(normalisePrefix).filter((p) => p !== null);
20387
+ const ids = [];
20388
+ const warnings = [];
20389
+ const seen = /* @__PURE__ */ new Set();
20390
+ const explicit = /* @__PURE__ */ new Set();
20391
+ for (const pr of prs) {
20392
+ const scan = mentionedAcceptances({ title: pr.title ?? "", body: pr.body ?? "" });
20393
+ for (const unknown2 of scan.unknown) {
20394
+ warnings.push(`#${pr.number || "?"}: ${unknown2.id}@${unknown2.platform} names no platform arkaik knows \u2014 ignored`);
20395
+ }
20396
+ for (const mention of scan.mentions) {
20397
+ if (mention.platform === platform) explicit.add(mention.id);
20398
+ const counts = mention.platform === platform || mention.platform === null && (prefixes.length === 0 || touchesAny(pr.files ?? [], prefixes));
20399
+ if (!counts || seen.has(mention.id)) continue;
20400
+ seen.add(mention.id);
20401
+ ids.push(mention.id);
20402
+ }
20403
+ }
20404
+ return { ids, warnings, inferred: ids.filter((id) => !explicit.has(id)) };
20405
+ }
20406
+ function readMentions(file2) {
20407
+ let parsed;
20408
+ try {
20409
+ parsed = JSON.parse(readFileSync9(file2, "utf8"));
20410
+ } catch (e) {
20411
+ return { error: `Could not read ${file2}: ${e.message}` };
20412
+ }
20413
+ if (!Array.isArray(parsed)) return { error: `${file2} must be a JSON array of pull requests` };
20414
+ const prs = [];
20415
+ for (const [i, raw] of parsed.entries()) {
20416
+ if (typeof raw !== "object" || raw === null) return { error: `${file2}[${i}] must be an object` };
20417
+ const r = raw;
20418
+ prs.push({
20419
+ number: typeof r.number === "number" && Number.isFinite(r.number) ? r.number : 0,
20420
+ title: typeof r.title === "string" ? r.title : "",
20421
+ body: typeof r.body === "string" ? r.body : "",
20422
+ files: Array.isArray(r.files) ? r.files.filter((f) => typeof f === "string") : []
20423
+ });
20424
+ }
20425
+ return prs;
20426
+ }
20427
+ function describeFailure2(status, baseUrl, body) {
20428
+ if (status === 401) return `Unauthorized \u2014 check ARKAIK_TOKEN (create one at ${baseUrl}/settings/tokens).`;
20429
+ if (status === 403) return "Forbidden \u2014 this token lacks the release:append scope (or graph:write).";
20430
+ if (status === 404) return `No linked project in this account \u2014 check ${LINK_FILE2}.`;
20431
+ if (status === 409) return "The project changed under every retry \u2014 run again.";
20432
+ return `Request failed (${status})${body.message ? ` \u2014 ${body.message}` : body.error ? ` \u2014 ${body.error}` : ""}.`;
20433
+ }
20434
+ async function runLive(argv, options = {}) {
20435
+ const log = options.log ?? ((m) => console.log(m));
20436
+ const errorLog = options.errorLog ?? ((m) => console.error(m));
20437
+ const env = options.env ?? process.env;
20438
+ const cwd = options.cwd ?? process.cwd();
20439
+ const doFetch = options.httpClient ?? ((...args) => fetch(...args));
20440
+ if (argv.includes("--help") || argv.includes("-h")) {
20441
+ log(USAGE11);
20442
+ return { ok: true };
20443
+ }
20444
+ const positional = [];
20445
+ for (let i = 0; i < argv.length; i++) {
20446
+ const arg = argv[i];
20447
+ if (VALUED_FLAGS.has(arg)) {
20448
+ i++;
20449
+ continue;
20450
+ }
20451
+ if (arg.startsWith("--")) {
20452
+ if (KNOWN_FLAGS.has(arg)) continue;
20453
+ errorLog(`Unknown flag ${arg}. Flags take a separate value (--mentions file.json), see arkaik live --help.`);
20454
+ return { ok: false };
20455
+ }
20456
+ if (arg.includes("@")) {
20457
+ errorLog(`"${arg}": positional ids take no @platform \u2014 the platform comes from --platform.`);
20458
+ return { ok: false };
20459
+ }
20460
+ if (!ACCEPTANCE_ID.test(arg)) {
20461
+ errorLog(`"${arg}" is not an acceptance id (they start with AC-). Flags take one value each; see arkaik live --help.`);
20462
+ return { ok: false };
20463
+ }
20464
+ positional.push(arg);
20465
+ }
20466
+ const platformArg = flagValue2(argv, "--platform");
20467
+ if (!platformArg) {
20468
+ errorLog(`--platform is required: arkaik live --platform <${PLATFORM_IDS.join("|")}> \u2026`);
20469
+ return { ok: false };
20470
+ }
20471
+ if (!isPlatformId(platformArg)) {
20472
+ errorLog(`"${platformArg}" is not a platform. Expected one of: ${PLATFORM_IDS.join(", ")}.`);
20473
+ return { ok: false };
20474
+ }
20475
+ const platform = platformArg;
20476
+ const detail = flagValue2(argv, "--detail");
20477
+ const mentionsFile = flagValue2(argv, "--mentions");
20478
+ const paths = (flagValue2(argv, "--paths") ?? "").split(",").map((p) => p.trim()).filter(Boolean);
20479
+ const dryRun = argv.includes("--dry-run");
20480
+ const linkPath = join8(cwd, LINK_FILE2);
20481
+ let link;
20482
+ try {
20483
+ link = JSON.parse(readFileSync9(linkPath, "utf8"));
20484
+ } catch {
20485
+ errorLog(`No ${LINK_FILE2}. Run \`arkaik link --project <id>\` first \u2014 live only targets hosted projects.`);
20486
+ return { ok: false };
20487
+ }
20488
+ const projectId = link.project_id;
20489
+ if (!projectId) {
20490
+ errorLog(`${LINK_FILE2} has no project_id. Run \`arkaik link --project <id>\`.`);
20491
+ return { ok: false };
20492
+ }
20493
+ const baseUrl = (flagValue2(argv, "--remote") ?? env.ARKAIK_URL ?? link.remote ?? DEFAULT_BASE_URL2).replace(/\/+$/, "");
20494
+ const ids = [];
20495
+ const seen = /* @__PURE__ */ new Set();
20496
+ const add = (id) => {
20497
+ if (!seen.has(id)) {
20498
+ seen.add(id);
20499
+ ids.push(id);
20500
+ }
20501
+ };
20502
+ for (const id of positional) add(id);
20503
+ const inferred = /* @__PURE__ */ new Set();
20504
+ if (mentionsFile) {
20505
+ const prs = readMentions(resolve9(cwd, mentionsFile));
20506
+ if (!Array.isArray(prs)) {
20507
+ errorLog(prs.error);
20508
+ return { ok: false };
20509
+ }
20510
+ const derived = deriveLiveIds(prs, platform, paths);
20511
+ for (const warning of derived.warnings) errorLog(`warning: ${warning}`);
20512
+ for (const id of derived.ids) add(id);
20513
+ for (const id of derived.inferred) if (!positional.includes(id)) inferred.add(id);
20514
+ }
20515
+ if (ids.length === 0) {
20516
+ log(`Nothing to mark live on ${platform}.`);
20517
+ return { ok: true, ids };
20518
+ }
20519
+ const hasDetail = detail !== void 0 && detail !== "";
20520
+ const entries = ids.map((node_id) => ({ node_id, platform, ...hasDetail ? { detail } : {} }));
20521
+ if (dryRun) {
20522
+ log(`Would mark ${platform} live for ${ids.length} acceptance(s) on ${projectId} (${baseUrl}):`);
20523
+ for (const entry of entries) log(` ${entry.node_id}@${platform}${hasDetail ? ` \u2014 ${detail}` : ""}`);
20524
+ return { ok: true, ids };
20525
+ }
20526
+ const token = env.ARKAIK_TOKEN;
20527
+ if (!token) {
20528
+ errorLog(`ARKAIK_TOKEN is not set. Create a release:append token at ${baseUrl}/settings/tokens and export it.`);
20529
+ return { ok: false };
20530
+ }
20531
+ const post = async (chunk) => {
20532
+ let res;
20533
+ try {
20534
+ res = await doFetch(`${baseUrl}/api/graph/projects/${encodeURIComponent(projectId)}/live`, {
20535
+ method: "POST",
20536
+ headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
20537
+ body: JSON.stringify({ entries: chunk })
20538
+ });
20539
+ } catch (e) {
20540
+ errorLog(`Could not reach ${baseUrl}: ${e.message}`);
20541
+ return null;
20542
+ }
20543
+ let body = {};
20544
+ try {
20545
+ body = await res.json();
20546
+ } catch {
20547
+ }
20548
+ return { res, body };
20549
+ };
20550
+ let landed = 0;
20551
+ for (let start = 0; start < entries.length; start += MAX_ENTRIES_PER_REQUEST) {
20552
+ const end = Math.min(start + MAX_ENTRIES_PER_REQUEST, entries.length) - 1;
20553
+ let chunk = entries.slice(start, end + 1).map((entry, i) => ({ entry, at: start + i }));
20554
+ let resent = false;
20555
+ for (; ; ) {
20556
+ const sent = await post(chunk.map((c) => c.entry));
20557
+ if (!sent) return { ok: false, ids };
20558
+ const { res, body } = sent;
20559
+ if (res.status === 422 && body.refusals) {
20560
+ const refusals = body.refusals;
20561
+ const droppable = !resent && refusals.every((r) => DROPPABLE_REASONS.has(r.reason) && inferred.has(r.node_id));
20562
+ if (droppable) {
20563
+ const dropped = /* @__PURE__ */ new Set();
20564
+ for (const r of refusals) {
20565
+ errorLog(`warning: ${r.node_id}@${r.platform} was inferred from a bare mention and the project does not list it that way (${r.reason}) \u2014 dropped`);
20566
+ dropped.add(r.node_id);
20567
+ }
20568
+ chunk = chunk.filter((c) => !dropped.has(c.entry.node_id));
20569
+ resent = true;
20570
+ if (chunk.length === 0) {
20571
+ log(`Nothing left to send in entries ${start}\u2013${end} after dropping inferred ids.`);
20572
+ break;
20573
+ }
20574
+ continue;
20575
+ }
20576
+ errorLog(
20577
+ landed > 0 ? `Refused \u2014 entries ${start}\u2013${end} wrote nothing; the ${landed} before them were applied above (a re-run skips them):` : "Refused \u2014 nothing was written:"
20578
+ );
20579
+ for (const r of refusals) {
20580
+ const at2 = chunk[r.index]?.at ?? start + r.index;
20581
+ errorLog(` entries[${at2}] ${r.node_id}@${r.platform}: ${r.reason}${r.detail ? ` \u2014 ${r.detail}` : ""}`);
20582
+ }
20583
+ errorLog("Re-run with the other ids as arguments \u2014 acceptances already live are skipped, so a retry is safe.");
20584
+ return { ok: false, ids };
20585
+ }
20586
+ if (!res.ok) {
20587
+ errorLog(describeFailure2(res.status, baseUrl, body));
20588
+ return { ok: false, ids };
20589
+ }
20590
+ for (const a of body.applied ?? []) log(`${a.node_id}: ${a.from} \u2192 ${a.to} [${a.platform}]`);
20591
+ for (const sk of body.skipped ?? []) log(`${sk.node_id}: already live [${sk.platform}]`);
20592
+ landed += chunk.length;
20593
+ break;
20594
+ }
20595
+ }
20596
+ return { ok: true, ids };
20597
+ }
20598
+ function runLiveCli(argv) {
20599
+ void runLive(argv).then((result) => {
20600
+ if (!result.ok) process.exit(1);
20601
+ });
20602
+ }
20603
+
20604
+ // src/commands/restore.ts
20605
+ import { existsSync as existsSync9, linkSync, mkdirSync as mkdirSync6, readFileSync as readFileSync10, unlinkSync, writeFileSync as writeFileSync9 } from "node:fs";
20606
+ import { join as join9, resolve as resolve10 } from "node:path";
20607
+ var LINK_FILE3 = "docs/arkaik/arkaik.json";
20307
20608
  var DEFAULT_BUNDLE_PATH9 = "docs/arkaik/bundle.json";
20308
20609
  var DEFAULT_API_BASE2 = "https://arkaik.app";
20309
- var USAGE11 = `arkaik restore [options] [path]
20610
+ var USAGE12 = `arkaik restore [options] [path]
20310
20611
 
20311
20612
  Replace the linked hosted project's bundle, journal AND quality section with
20312
20613
  a local bundle \u2014
@@ -20526,7 +20827,7 @@ function describeQualityLoss(hostedQuality, qualityRoot, noQuality, foldNotice)
20526
20827
  lines.push("The outbound bundle has no section because the fold found nothing to build one from:");
20527
20828
  lines.push(` ${foldNotice}`);
20528
20829
  }
20529
- if (!existsSync9(join8(qualityRoot, QUALITY_DIR))) {
20830
+ if (!existsSync9(join9(qualityRoot, QUALITY_DIR))) {
20530
20831
  lines.push(
20531
20832
  `There is no ${QUALITY_DIR}/ under ${qualityRoot} at all. If this project's sidecars live somewhere else, point --root at that repo and the section is rebuilt rather than removed.`
20532
20833
  );
@@ -20544,27 +20845,27 @@ async function runRestore(options = {}) {
20544
20845
  const noQuality = options.noQuality ?? false;
20545
20846
  const allowQualityLoss = options.allowQualityLoss ?? false;
20546
20847
  const httpClient = options.httpClient ?? DEFAULT_HTTP_CLIENT;
20547
- const linkPath = join8(cwd, LINK_FILE2);
20848
+ const linkPath = join9(cwd, LINK_FILE3);
20548
20849
  if (!existsSync9(linkPath)) {
20549
- return fatalResult5(dryRun, `No ${LINK_FILE2}. Run \`arkaik link\` first \u2014 restore only targets hosted projects.`);
20850
+ return fatalResult5(dryRun, `No ${LINK_FILE3}. Run \`arkaik link\` first \u2014 restore only targets hosted projects.`);
20550
20851
  }
20551
20852
  let link;
20552
20853
  try {
20553
- link = JSON.parse(readFileSync9(linkPath, "utf8"));
20854
+ link = JSON.parse(readFileSync10(linkPath, "utf8"));
20554
20855
  } catch (e) {
20555
- return fatalResult5(dryRun, `Could not parse ${LINK_FILE2}: ${e.message}`);
20856
+ return fatalResult5(dryRun, `Could not parse ${LINK_FILE3}: ${e.message}`);
20556
20857
  }
20557
20858
  const projectId = link.project_id;
20558
- if (!projectId) return fatalResult5(dryRun, `${LINK_FILE2} has no project_id. Run \`arkaik link --project <id>\`.`);
20859
+ if (!projectId) return fatalResult5(dryRun, `${LINK_FILE3} has no project_id. Run \`arkaik link --project <id>\`.`);
20559
20860
  const baseUrl = (options.apiBase ?? env.ARKAIK_URL ?? link.remote ?? DEFAULT_API_BASE2).replace(/\/+$/, "");
20560
20861
  const encodedProjectId = encodeURIComponent(projectId);
20561
20862
  const token = env.ARKAIK_TOKEN;
20562
20863
  if (!token) return fatalResult5(dryRun, `ARKAIK_TOKEN is not set. Create a token at ${baseUrl}/settings/tokens and export it.`);
20563
- const bundlePath = resolve9(cwd, options.path ?? DEFAULT_BUNDLE_PATH9);
20864
+ const bundlePath = resolve10(cwd, options.path ?? DEFAULT_BUNDLE_PATH9);
20564
20865
  if (!existsSync9(bundlePath)) return fatalResult5(dryRun, `No bundle at ${bundlePath}. Run \`arkaik merge\` (or \`arkaik pack\`) first.`);
20565
20866
  let localRaw;
20566
20867
  try {
20567
- localRaw = JSON.parse(readFileSync9(bundlePath, "utf8"));
20868
+ localRaw = JSON.parse(readFileSync10(bundlePath, "utf8"));
20568
20869
  } catch (e) {
20569
20870
  return fatalResult5(dryRun, `Could not parse ${bundlePath}: ${e.message}`);
20570
20871
  }
@@ -20658,15 +20959,15 @@ async function runRestore(options = {}) {
20658
20959
  if ((removedNodes.length > 0 || removedEdges.length > 0) && !allowDeletions) {
20659
20960
  return fatalResult5(dryRun, describeDeletions(removedNodes, removedEdges, bundlePath), qualityFields);
20660
20961
  }
20661
- const backupDir = join8(cwd, "docs", "arkaik", ".backups");
20962
+ const backupDir = join9(cwd, "docs", "arkaik", ".backups");
20662
20963
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
20663
- const backupPath = join8(backupDir, `${stamp}-bundle.json`);
20964
+ const backupPath = join9(backupDir, `${stamp}-bundle.json`);
20664
20965
  const backupContent = `${JSON.stringify(exported, null, 2)}
20665
20966
  `;
20666
20967
  try {
20667
20968
  mkdirSync6(backupDir, { recursive: true });
20668
20969
  writeBackupFile(backupPath, backupContent);
20669
- JSON.parse(readFileSync9(backupPath, "utf8"));
20970
+ JSON.parse(readFileSync10(backupPath, "utf8"));
20670
20971
  } catch (e) {
20671
20972
  return fatalResult5(
20672
20973
  dryRun,
@@ -20766,7 +21067,7 @@ function runRestoreCli(argv) {
20766
21067
  for (let i = 0; i < argv.length; i++) {
20767
21068
  const arg = argv[i];
20768
21069
  if (arg === "-h" || arg === "--help") {
20769
- console.log(USAGE11);
21070
+ console.log(USAGE12);
20770
21071
  process.exitCode = 0;
20771
21072
  return;
20772
21073
  } else if (arg === "--dry-run") {
@@ -20783,35 +21084,35 @@ function runRestoreCli(argv) {
20783
21084
  const value = argv[++i];
20784
21085
  if (value === void 0) fail10(`Missing value for --audit
20785
21086
 
20786
- ${USAGE11}`);
21087
+ ${USAGE12}`);
20787
21088
  audit = value;
20788
21089
  } else if (arg === "--root") {
20789
21090
  const value = argv[++i];
20790
21091
  if (value === void 0) fail10(`Missing value for --root
20791
21092
 
20792
- ${USAGE11}`);
21093
+ ${USAGE12}`);
20793
21094
  root = value;
20794
21095
  } else if (arg === "--api") {
20795
21096
  const value = argv[++i];
20796
21097
  if (value === void 0) fail10(`Missing value for --api
20797
21098
 
20798
- ${USAGE11}`);
21099
+ ${USAGE12}`);
20799
21100
  apiBase = value;
20800
21101
  } else if (arg.startsWith("-")) {
20801
21102
  fail10(`Unknown option: ${arg}
20802
21103
 
20803
- ${USAGE11}`);
21104
+ ${USAGE12}`);
20804
21105
  } else {
20805
21106
  positionals.push(arg);
20806
21107
  }
20807
21108
  }
20808
21109
  if (positionals.length > 1) fail10(`Unexpected argument(s): ${positionals.slice(1).join(" ")}
20809
21110
 
20810
- ${USAGE11}`);
21111
+ ${USAGE12}`);
20811
21112
  if (noQuality && audit !== void 0) {
20812
21113
  fail10(`--audit and --no-quality contradict each other: one names an audit to fold, the other removes the section
20813
21114
 
20814
- ${USAGE11}`);
21115
+ ${USAGE12}`);
20815
21116
  }
20816
21117
  runRestore({ path: positionals[0], dryRun, allowHistoryLoss, allowDeletions, noQuality, allowQualityLoss, audit, root, apiBase }).then((result) => reportRestore(result)).catch((e) => fail10(`FATAL: ${e.message}`));
20817
21118
  }
@@ -20823,11 +21124,11 @@ import path5 from "node:path";
20823
21124
 
20824
21125
  // src/lib/bootstrap/corpus.ts
20825
21126
  import { spawnSync } from "node:child_process";
20826
- import { existsSync as existsSync11, readdirSync as readdirSync3, readFileSync as readFileSync11, writeFileSync as writeFileSync11 } from "node:fs";
21127
+ import { existsSync as existsSync11, readdirSync as readdirSync3, readFileSync as readFileSync12, writeFileSync as writeFileSync11 } from "node:fs";
20827
21128
  import path2 from "node:path";
20828
21129
 
20829
21130
  // src/lib/bootstrap/paths.ts
20830
- import { existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync10 } from "node:fs";
21131
+ import { existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "node:fs";
20831
21132
  import path from "node:path";
20832
21133
  var BOOTSTRAP_ROOT = ".arkaik";
20833
21134
  var CORPUS_DIR = ".arkaik/corpus";
@@ -20847,7 +21148,7 @@ function ensureDir(dirPath) {
20847
21148
  function ensureGitignored(cwd) {
20848
21149
  const file2 = path.join(cwd, ".gitignore");
20849
21150
  const line2 = `${BOOTSTRAP_ROOT}/`;
20850
- const current = existsSync10(file2) ? readFileSync10(file2, "utf8") : "";
21151
+ const current = existsSync10(file2) ? readFileSync11(file2, "utf8") : "";
20851
21152
  const ignored = current.split("\n").map((l) => l.trim()).some((l) => l === line2 || l === BOOTSTRAP_ROOT);
20852
21153
  if (ignored) return false;
20853
21154
  const prefix = current.length > 0 && !current.endsWith("\n") ? "\n" : "";
@@ -20966,7 +21267,7 @@ function listFiles(cwd) {
20966
21267
  }
20967
21268
  function buildDocsManifest(cwd, files) {
20968
21269
  return files.filter((f) => f.startsWith("docs/") && f.endsWith(".md")).map((f) => {
20969
- const text = readFileSync11(path2.join(cwd, f), "utf8");
21270
+ const text = readFileSync12(path2.join(cwd, f), "utf8");
20970
21271
  const heading = /^#\s+(.+)$/m.exec(text);
20971
21272
  return { path: f, title: heading ? heading[1].trim() : path2.basename(f, ".md") };
20972
21273
  });
@@ -20981,7 +21282,7 @@ function buildSurfaceInventory(files) {
20981
21282
  }
20982
21283
  function buildCorpus(options) {
20983
21284
  const { cwd } = options;
20984
- const raw = options.fromJson ? JSON.parse(readFileSync11(path2.resolve(cwd, options.fromJson), "utf8")) : options.fromGit ? fetchPrsViaGit(cwd) : fetchPrsViaGh(cwd, options.limit);
21285
+ const raw = options.fromJson ? JSON.parse(readFileSync12(path2.resolve(cwd, options.fromJson), "utf8")) : options.fromGit ? fetchPrsViaGit(cwd) : fetchPrsViaGh(cwd, options.limit);
20985
21286
  let prs = normalizePrs(raw);
20986
21287
  let sinceDroppedUndated = 0;
20987
21288
  if (options.since) {
@@ -21012,11 +21313,11 @@ function buildCorpus(options) {
21012
21313
  function readCorpusPrs(cwd) {
21013
21314
  const file2 = at(cwd, PRS_FILE);
21014
21315
  if (!existsSync11(file2)) return [];
21015
- return readFileSync11(file2, "utf8").split("\n").filter(Boolean).map((line2) => JSON.parse(line2));
21316
+ return readFileSync12(file2, "utf8").split("\n").filter(Boolean).map((line2) => JSON.parse(line2));
21016
21317
  }
21017
21318
 
21018
21319
  // src/lib/bootstrap/fragments.ts
21019
- import { existsSync as existsSync12, readFileSync as readFileSync12 } from "node:fs";
21320
+ import { existsSync as existsSync12, readFileSync as readFileSync13 } from "node:fs";
21020
21321
  import path3 from "node:path";
21021
21322
  function isArrayOfObjects(value) {
21022
21323
  return value === void 0 || Array.isArray(value) && value.every((v) => typeof v === "object" && v !== null && !Array.isArray(v));
@@ -21048,7 +21349,7 @@ function loadFragments(cwd, manifest) {
21048
21349
  }
21049
21350
  let parsed;
21050
21351
  try {
21051
- parsed = JSON.parse(readFileSync12(file2, "utf8"));
21352
+ parsed = JSON.parse(readFileSync13(file2, "utf8"));
21052
21353
  } catch (err) {
21053
21354
  problems.push({ unit: unit2.id, message: `not valid JSON: ${err instanceof Error ? err.message : "parse error"}` });
21054
21355
  continue;
@@ -21085,7 +21386,7 @@ function renderIndex(bundle) {
21085
21386
  }
21086
21387
 
21087
21388
  // src/lib/bootstrap/manifest.ts
21088
- import { existsSync as existsSync13, readFileSync as readFileSync13, writeFileSync as writeFileSync12 } from "node:fs";
21389
+ import { existsSync as existsSync13, readFileSync as readFileSync14, writeFileSync as writeFileSync12 } from "node:fs";
21089
21390
  import path4 from "node:path";
21090
21391
 
21091
21392
  // src/lib/bootstrap/era-window.ts
@@ -21196,7 +21497,7 @@ function readProfile(cwd) {
21196
21497
  const file2 = at(cwd, PROFILE_FILE2);
21197
21498
  if (!existsSync13(file2)) return null;
21198
21499
  try {
21199
- return JSON.parse(readFileSync13(file2, "utf8"));
21500
+ return JSON.parse(readFileSync14(file2, "utf8"));
21200
21501
  } catch (err) {
21201
21502
  throw new Error(`cannot read ${PROFILE_FILE2}: ${err instanceof Error ? err.message : String(err)}`);
21202
21503
  }
@@ -21205,7 +21506,7 @@ function readManifest(cwd) {
21205
21506
  const file2 = at(cwd, MANIFEST_FILE);
21206
21507
  if (!existsSync13(file2)) return null;
21207
21508
  try {
21208
- return JSON.parse(readFileSync13(file2, "utf8"));
21509
+ return JSON.parse(readFileSync14(file2, "utf8"));
21209
21510
  } catch (err) {
21210
21511
  throw new Error(`cannot read ${MANIFEST_FILE}: ${err instanceof Error ? err.message : String(err)}`);
21211
21512
  }
@@ -21221,7 +21522,7 @@ function detectMode(cwd, bundlePath) {
21221
21522
  if (!existsSync13(file2)) return "greenfield";
21222
21523
  let parsed;
21223
21524
  try {
21224
- parsed = JSON.parse(readFileSync13(file2, "utf8"));
21525
+ parsed = JSON.parse(readFileSync14(file2, "utf8"));
21225
21526
  } catch (err) {
21226
21527
  throw new Error(`cannot read bundle at ${bundlePath}: ${err instanceof Error ? err.message : String(err)}`);
21227
21528
  }
@@ -21674,7 +21975,7 @@ function mergeFragments(input) {
21674
21975
  }
21675
21976
 
21676
21977
  // src/lib/bootstrap/slice.ts
21677
- import { existsSync as existsSync14, readFileSync as readFileSync14 } from "node:fs";
21978
+ import { existsSync as existsSync14, readFileSync as readFileSync15 } from "node:fs";
21678
21979
 
21679
21980
  // src/lib/bootstrap/body-budget.ts
21680
21981
  var LAB_NOTE_HEADING_RE = /^##\s+Lab Note.*$/m;
@@ -21717,7 +22018,7 @@ function boundBody(body) {
21717
22018
  // src/lib/bootstrap/slice.ts
21718
22019
  function readJsonArray(file2) {
21719
22020
  if (!existsSync14(file2)) return [];
21720
- const parsed = JSON.parse(readFileSync14(file2, "utf8"));
22021
+ const parsed = JSON.parse(readFileSync15(file2, "utf8"));
21721
22022
  return Array.isArray(parsed) ? parsed : [];
21722
22023
  }
21723
22024
  function toPosix(value) {
@@ -21791,7 +22092,7 @@ function resolveSlice(cwd, unit2) {
21791
22092
  }
21792
22093
 
21793
22094
  // src/commands/bootstrap.ts
21794
- var USAGE12 = `arkaik bootstrap <subcommand> [options]
22095
+ var USAGE13 = `arkaik bootstrap <subcommand> [options]
21795
22096
 
21796
22097
  Subcommands:
21797
22098
  corpus [options] Mine merged PRs, docs and surfaces into .arkaik/corpus/.
@@ -22121,7 +22422,7 @@ ${MERGE_USAGE}`);
22121
22422
  function runBootstrap(argv) {
22122
22423
  const [sub, ...rest] = argv;
22123
22424
  if (sub === void 0 || sub === "-h" || sub === "--help" || sub === "help") {
22124
- console.log(USAGE12);
22425
+ console.log(USAGE13);
22125
22426
  process.exit(0);
22126
22427
  }
22127
22428
  switch (sub) {
@@ -22143,7 +22444,7 @@ function runBootstrap(argv) {
22143
22444
  default:
22144
22445
  console.error(`Unknown bootstrap subcommand: ${sub}
22145
22446
 
22146
- ${USAGE12}`);
22447
+ ${USAGE13}`);
22147
22448
  process.exit(1);
22148
22449
  }
22149
22450
  }
@@ -22277,8 +22578,8 @@ Pass --domain-name "<display name>" to define it, or use an existing domain code
22277
22578
  }
22278
22579
 
22279
22580
  // src/commands/kritik.ts
22280
- import { existsSync as existsSync16, readFileSync as readFileSync15 } from "node:fs";
22281
- var USAGE13 = `arkaik kritik <subcommand> [options]
22581
+ import { existsSync as existsSync16, readFileSync as readFileSync16 } from "node:fs";
22582
+ var USAGE14 = `arkaik kritik <subcommand> [options]
22282
22583
 
22283
22584
  Audit this product's quality with the Kritik framework: a maturity level per
22284
22585
  criterion per surface backed by evidence, findings carrying risk and cost, and
@@ -22520,7 +22821,7 @@ function textOrFile(value) {
22520
22821
  if (!value.startsWith("@")) return value;
22521
22822
  const path6 = value.slice(1);
22522
22823
  if (!existsSync16(path6)) fail12(`kritik: no file at ${path6}`);
22523
- return readFileSync15(path6, "utf8").trim();
22824
+ return readFileSync16(path6, "utf8").trim();
22524
22825
  }
22525
22826
  function currentAuditId() {
22526
22827
  const now = /* @__PURE__ */ new Date();
@@ -23496,7 +23797,7 @@ ${CRITERION_USAGE}`);
23496
23797
  try {
23497
23798
  if (single.from !== void 0) {
23498
23799
  if (!existsSync16(single.from)) fail12(`kritik: no file at ${single.from}`);
23499
- criterion = JSON.parse(readFileSync15(single.from, "utf8"));
23800
+ criterion = JSON.parse(readFileSync16(single.from, "utf8"));
23500
23801
  } else {
23501
23802
  const anchors = {};
23502
23803
  for (const spec of many.anchor) {
@@ -23551,7 +23852,7 @@ function runKritik(args) {
23551
23852
  const { rest, common } = takeCommon(args);
23552
23853
  const [sub, ...subArgs] = rest;
23553
23854
  if (sub === void 0 || sub === "--help" || sub === "-h" || sub === "help") {
23554
- console.log(USAGE13);
23855
+ console.log(USAGE14);
23555
23856
  process.exit(sub === void 0 ? 1 : 0);
23556
23857
  }
23557
23858
  switch (sub) {
@@ -23580,12 +23881,12 @@ function runKritik(args) {
23580
23881
  default:
23581
23882
  fail12(`kritik: unknown subcommand "${sub}"
23582
23883
 
23583
- ${USAGE13}`);
23884
+ ${USAGE14}`);
23584
23885
  }
23585
23886
  }
23586
23887
 
23587
23888
  // src/index.ts
23588
- var USAGE14 = `arkaik \u2014 CLI for Arkaik project bundles
23889
+ var USAGE15 = `arkaik \u2014 CLI for Arkaik project bundles
23589
23890
 
23590
23891
  Usage:
23591
23892
  arkaik <command> [options]
@@ -23603,6 +23904,8 @@ Commands:
23603
23904
  --delete <id> --key <owner_key> removes a snapshot.
23604
23905
  link [options] [path] Point this repo at a hosted project so an agent can edit it.
23605
23906
  --list shows the projects your token can reach.
23907
+ live --platform <p> [ids] Mark acceptances live on one platform from a deploy (release:append token).
23908
+ --mentions <file> derives them from merged pull requests.
23606
23909
  restore [options] [path] Replace the linked project's bundle, journal + quality (backs up first).
23607
23910
  bootstrap <sub> [options] One-time onboarding: mine, plan, slice, merge a map from a repo.
23608
23911
  kritik <sub> [options] Quality audits: score criteria, open findings, roll up the matrix.
@@ -23612,11 +23915,11 @@ Options:
23612
23915
  -v, --version Print the version.
23613
23916
 
23614
23917
  Run "arkaik <command> --help" for command-specific help.`;
23615
- var VERSION = "0.8.0";
23918
+ var VERSION = "0.10.0";
23616
23919
  function main(argv) {
23617
23920
  const [command, ...rest] = argv;
23618
23921
  if (command === void 0 || command === "--help" || command === "-h" || command === "help") {
23619
- console.log(USAGE14);
23922
+ console.log(USAGE15);
23620
23923
  process.exit(0);
23621
23924
  }
23622
23925
  if (command === "--version" || command === "-v" || command === "version") {
@@ -23654,6 +23957,9 @@ function main(argv) {
23654
23957
  case "link":
23655
23958
  runLinkCli(rest);
23656
23959
  return;
23960
+ case "live":
23961
+ runLiveCli(rest);
23962
+ return;
23657
23963
  case "restore":
23658
23964
  runRestoreCli(rest);
23659
23965
  return;
@@ -23666,7 +23972,7 @@ function main(argv) {
23666
23972
  default:
23667
23973
  console.error(`Unknown command: ${command}
23668
23974
  `);
23669
- console.error(USAGE14);
23975
+ console.error(USAGE15);
23670
23976
  process.exit(1);
23671
23977
  }
23672
23978
  }
package/dist/io.js CHANGED
@@ -15067,7 +15067,7 @@ function missingProvenanceNodeIds(snapshotNodeIds, events) {
15067
15067
  var envelope = {
15068
15068
  id: external_exports.string().meta({ description: "ULID \u2014 sortable, collision-free without coordination." }),
15069
15069
  ts: external_exports.string().meta({ description: "ISO 8601 timestamp." }),
15070
- actor: external_exports.string().optional().meta({ description: 'Who/what wrote it (e.g. "claude-code", "ci").' }),
15070
+ actor: external_exports.string().optional().meta({ description: 'Who/what wrote it (e.g. "claude-code", "arkaik-ci").' }),
15071
15071
  v: external_exports.number().int().optional().meta({ description: "Reserved per-event payload version; absent today." })
15072
15072
  };
15073
15073
  var JournalEventSchema = external_exports.object({
@@ -15094,7 +15094,8 @@ var NodeStatusChangedEventSchema = external_exports.object({
15094
15094
  // their legacy status ids, so strict per-type validation must accept them.
15095
15095
  from: AnyStatusSchema,
15096
15096
  to: AnyStatusSchema,
15097
- platform: PlatformSchema.optional()
15097
+ platform: PlatformSchema.optional(),
15098
+ detail: external_exports.string().optional()
15098
15099
  }).catchall(external_exports.unknown());
15099
15100
  var DecisionStatusChangedEventSchema = external_exports.object({
15100
15101
  ...envelope,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkaik",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
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",