jioogen 0.2.16 → 0.2.17

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/index.js CHANGED
@@ -9774,7 +9774,7 @@ Urutan otoritas: keamanan/a11y inti > PRD/specs > file di sini > default generik
9774
9774
  var EXECUTION_SIDECAR_PATH = "tasks/.execution/state.json";
9775
9775
  var EXECUTION_SIDECAR_VERSION = 1;
9776
9776
  var EXECUTION_SIDECAR_VERSION_V2 = 2;
9777
- var HANDOFF_PROMPT_VERSION = 27;
9777
+ var HANDOFF_PROMPT_VERSION = 28;
9778
9778
  var HANDOFF_AGENT_TOKEN_TTL_SECONDS = 30 * 24 * 3600;
9779
9779
  var HandoffPayloadSchema = external_exports.object({
9780
9780
  promptVersion: external_exports.literal(HANDOFF_PROMPT_VERSION),
@@ -9871,7 +9871,9 @@ var ExecutionStateSchema = external_exports.object({
9871
9871
  /** Task-breakdown ownership; absent means legacy `authoring`. */
9872
9872
  mode: TaskModeSchema.optional(),
9873
9873
  plan: external_exports.string().optional(),
9874
- events: external_exports.array(ExecutionHistoryEntrySchema).optional()
9874
+ events: external_exports.array(ExecutionHistoryEntrySchema).optional(),
9875
+ /** Published bundle revision this execution was started from. */
9876
+ revision: external_exports.number().int().nonnegative().optional()
9875
9877
  }).passthrough();
9876
9878
  function summarizeExecutionCounts(tasks) {
9877
9879
  const base = ExecutionCountsSchema.parse({});
@@ -9963,6 +9965,9 @@ var CONTRACT_ROOT_REL = "docs/00-contract";
9963
9965
  function isContractArtifactPath(relative3) {
9964
9966
  return relative3 === "PRD.md" || relative3 === "traceability.md" || relative3.startsWith("specs/") || relative3.startsWith("tasks/");
9965
9967
  }
9968
+ function isDocsArtifactPath(relative3) {
9969
+ return relative3.startsWith("docs/") && relative3.endsWith(".md") && !relative3.startsWith(`${CONTRACT_ROOT_REL}/`);
9970
+ }
9966
9971
  function normalizeContractRoot(value) {
9967
9972
  if (typeof value !== "string") return null;
9968
9973
  const normalized = value.replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
@@ -10824,7 +10829,7 @@ async function snapshotContract(bundleDir) {
10824
10829
  const files = {};
10825
10830
  for (const path of [...paths].sort()) {
10826
10831
  try {
10827
- files[path] = sha256(await readFile3(join4(root, path)));
10832
+ files[path] = sha256(await readFile3(resolveProjectPath(bundleDir, path)));
10828
10833
  } catch {
10829
10834
  }
10830
10835
  }
@@ -10866,6 +10871,20 @@ function changedSince(current, previous) {
10866
10871
  const docs = previous === null ? current.docs !== null : current.docs !== previous.docs;
10867
10872
  return { prd, specs, tasks, docs, any: prd || specs || tasks || docs };
10868
10873
  }
10874
+ function serverOnlyStages(local, server) {
10875
+ const extra = Object.keys(server.files ?? {}).filter((path) => !(path in local.files));
10876
+ const specs = local.specs !== null && extra.some((path) => path.startsWith("specs/"));
10877
+ const tasks = local.tasks !== null && extra.some((path) => path.startsWith("tasks/") || path === "traceability.md");
10878
+ const docs = local.docs !== null && extra.some((path) => path.startsWith("docs/"));
10879
+ return { prd: false, specs, tasks, docs, any: specs || tasks || docs };
10880
+ }
10881
+ function mergeChanges(left, right) {
10882
+ const prd = left.prd || right.prd;
10883
+ const specs = left.specs || right.specs;
10884
+ const tasks = left.tasks || right.tasks;
10885
+ const docs = left.docs || right.docs;
10886
+ return { prd, specs, tasks, docs, any: prd || specs || tasks || docs };
10887
+ }
10869
10888
  function serverAsSnapshot(server) {
10870
10889
  return {
10871
10890
  prd: server.prd,
@@ -10875,6 +10894,20 @@ function serverAsSnapshot(server) {
10875
10894
  files: {}
10876
10895
  };
10877
10896
  }
10897
+ function serverViewForLocal(local, server) {
10898
+ const files = {};
10899
+ for (const path of Object.keys(local.files)) {
10900
+ const hash = server.files?.[path];
10901
+ if (hash !== void 0) files[path] = hash;
10902
+ }
10903
+ return {
10904
+ prd: files["PRD.md"] ?? null,
10905
+ specs: fingerprint(files, (path) => path.startsWith("specs/")),
10906
+ tasks: fingerprint(files, (path) => path.startsWith("tasks/") || path === "traceability.md"),
10907
+ docs: fingerprint(files, (path) => path.startsWith("docs/")),
10908
+ files
10909
+ };
10910
+ }
10878
10911
  function objectValue(value) {
10879
10912
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
10880
10913
  }
@@ -11349,6 +11382,7 @@ var LAYER_CHECKLISTS = {
11349
11382
  "- Responsive untuk mobile dan desktop.",
11350
11383
  "- Aksesibilitas dasar: label, aria, focus, keyboard.",
11351
11384
  "- Microcopy jelas dan konsisten dengan konteks.",
11385
+ "- Multi-surface: kerjakan FE design terpisah per komponen UI; jangan pakai desain web untuk app native.",
11352
11386
  "- Tanpa komponen/abstraksi baru untuk satu pemakaian; reuse yang ada."
11353
11387
  ],
11354
11388
  database: [
@@ -11475,7 +11509,7 @@ function renderActiveTask(task, context) {
11475
11509
  "- Jangan pindah task, jangan mengerjakan task lain, jangan melebar ke file di luar targetFiles (file/direktori/glob).",
11476
11510
  "- Jangan mengarang fitur/endpoint/kolom di luar PRD.md/specs/.",
11477
11511
  "- Detail implementasi (pola, struktur file dalam scope, library yang sudah ada) milikmu; ikuti konvensi proyek.",
11478
- "- Jangan mengubah PRD.md/specs/kontrak saat task berjalan. Butuh perubahan? Hentikan task, minta izin sekali, jalankan `npx jioogen approve` + `npx jioogen align`, lalu lanjut.",
11512
+ "- Jangan mengubah PRD.md/specs/kontrak saat task berjalan. Butuh perubahan? Hentikan task, minta izin sekali, jalankan `npx jioogen align` (menerbitkan revisi tanpa authoring), lalu lanjut.",
11479
11513
  "- Selesai: `npx jioogen task complete <ref>`, lalu `npx jioogen sync`."
11480
11514
  );
11481
11515
  const checklist = renderQualityChecklist(task.layer, context);
@@ -11882,7 +11916,7 @@ function buildCustomKnowledgeBlock(bundleDir) {
11882
11916
  ...files.map((file) => `- ${file}`),
11883
11917
  "Baca file-file di atas sebagai konteks tambahan user sebelum coding.",
11884
11918
  "Setiap pertanyaan ke user pakai bahasa manusia yang mudah: kalimat pendek, ya/tidak atau pilihan A/B, tanpa jargon teknis.",
11885
- "Bila user menyetujui patch kontrak, jalankan `jioogen approve --note <alasan>` lalu ubah PRD.md; setelah itu `jioogen align` otomatis menurunkan specs dan tasks, memvalidasi, dan menyelaraskan web. Jangan edit specs/tasks manual dan jangan `jioogen pull --force`."
11919
+ "Bila user menyetujui patch kontrak, ubah PRD.md/specs/tasks sesuai kesepakatan lalu jalankan `jioogen align`: kontrak lokal diterbitkan sebagai revisi baru (PRD otomatis dikonfirmasi) tanpa authoring. Jangan `jioogen pull --force`."
11886
11920
  ];
11887
11921
  return lines.join("\n");
11888
11922
  }
@@ -12292,6 +12326,9 @@ function serverStateFromWorkspace(state) {
12292
12326
  specs: fingerprint(files, (path) => path.startsWith("specs/")),
12293
12327
  tasks: fingerprint(files, (path) => path.startsWith("tasks/") || path === "traceability.md"),
12294
12328
  docs: fingerprint(files, (path) => path.startsWith("docs/")),
12329
+ files,
12330
+ revision: state.revision ?? null,
12331
+ commit: state.commit ?? null,
12295
12332
  derivation: parseDerivation(state.derivation)
12296
12333
  };
12297
12334
  }
@@ -12392,7 +12429,10 @@ function planAlignment(local, ledger, server, check) {
12392
12429
  }
12393
12430
  return { kind: "gate", check };
12394
12431
  }
12395
- const pushChanges = server === null ? localChanges : changedSince(local, serverAsSnapshot(server));
12432
+ const pushChanges = server === null ? localChanges : mergeChanges(
12433
+ changedSince(local, serverViewForLocal(local, server)),
12434
+ serverOnlyStages(local, server)
12435
+ );
12396
12436
  if (pushChanges.any) {
12397
12437
  return {
12398
12438
  kind: "push",
@@ -12422,21 +12462,38 @@ async function readContractFiles(bundleDir, snapshot, stages) {
12422
12462
  }
12423
12463
  return files;
12424
12464
  }
12465
+ async function approveLocalRevision(bundleDir, prdHash) {
12466
+ const existing = await readApproval(bundleDir);
12467
+ if (existing?.prd?.hash === prdHash) return;
12468
+ await writeApproval(bundleDir, {
12469
+ schemaVersion: 1,
12470
+ prd: {
12471
+ hash: prdHash,
12472
+ at: (/* @__PURE__ */ new Date()).toISOString(),
12473
+ note: "auto: revisi PRD lokal diselaraskan"
12474
+ }
12475
+ });
12476
+ }
12477
+ function serverLeftovers(local, server) {
12478
+ if (server === null) return [];
12479
+ const extra = Object.keys(server.files ?? {}).filter(
12480
+ (path) => !(path in local.files) && (isContractArtifactPath(path) || isDocsArtifactPath(path))
12481
+ );
12482
+ if (extra.length === 0) return [];
12483
+ const sample = extra.slice(0, 3).join(", ");
12484
+ return [
12485
+ `Web masih menyimpan ${extra.length} file bundle yang tidak ada di lokal (${sample}${extra.length > 3 ? ", \u2026" : ""}). Push tidak menghapusnya \u2014 perlu pembersihan di sisi web.`
12486
+ ];
12487
+ }
12425
12488
  async function pushContract(deps, bundleDir, snapshot, stages, server) {
12426
12489
  if (deps.client === void 0 || deps.projectId === void 0) {
12427
12490
  return { ok: false, error: "Project belum terhubung ke API; sinkronisasi web dilewati." };
12428
12491
  }
12429
12492
  const approval = await readApproval(bundleDir);
12430
- if (stages.prd && server !== null && server.prd !== snapshot.prd) {
12493
+ if (stages.prd && server !== null && server.prd !== snapshot.prd && snapshot.prd !== null) {
12431
12494
  const confirmation = await deps.client.getPrdConfirmation(deps.projectId).catch(() => null);
12432
12495
  if (confirmation?.confirmation.confirmed === true) {
12433
- if (approval?.prd?.hash !== snapshot.prd) {
12434
- return {
12435
- ok: false,
12436
- needsApproval: true,
12437
- error: "PRD lokal berbeda dari PRD yang dikonfirmasi di web."
12438
- };
12439
- }
12496
+ if (approval?.prd?.hash !== snapshot.prd) await approveLocalRevision(bundleDir, snapshot.prd);
12440
12497
  await deps.client.revokePrdConfirmation(
12441
12498
  deps.projectId,
12442
12499
  "PRD lokal disetujui user untuk diselaraskan."
@@ -12445,10 +12502,14 @@ async function pushContract(deps, bundleDir, snapshot, stages, server) {
12445
12502
  }
12446
12503
  await deps.client.ensureProjectLayout(deps.projectId).catch(() => null);
12447
12504
  const files = await readContractFiles(bundleDir, snapshot, stages);
12505
+ const pruneStages = pruneStagesFor(stages);
12448
12506
  let result;
12449
12507
  try {
12450
12508
  result = await deps.client.postJson(projectPath(deps.projectId, "/artifacts"), {
12451
- files
12509
+ files,
12510
+ ...pruneStages.length > 0 ? { pruneStages } : {},
12511
+ publish: true,
12512
+ ...server?.revision === void 0 || server.revision === null ? {} : { baseRevision: server.revision }
12452
12513
  });
12453
12514
  } catch (error) {
12454
12515
  return { ok: false, error: error instanceof Error ? error.message : String(error) };
@@ -12456,11 +12517,7 @@ async function pushContract(deps, bundleDir, snapshot, stages, server) {
12456
12517
  const rejected = result.rejected ?? [];
12457
12518
  const prdRejected = rejected.find((entry) => entry.path === "PRD.md");
12458
12519
  if (prdRejected !== void 0) {
12459
- return {
12460
- ok: false,
12461
- needsApproval: prdRejected.code === "PRD_CONFIRMED",
12462
- error: prdRejected.reason
12463
- };
12520
+ return { ok: false, error: prdRejected.reason };
12464
12521
  }
12465
12522
  const blocked = rejected.filter((entry) => entry.code !== "PRD_CONFIRMED");
12466
12523
  if (blocked.length > 0) {
@@ -12469,7 +12526,18 @@ async function pushContract(deps, bundleDir, snapshot, stages, server) {
12469
12526
  error: blocked.map((entry) => `${entry.path}: ${entry.reason}`).join(" | ")
12470
12527
  };
12471
12528
  }
12472
- return { ok: true };
12529
+ return {
12530
+ ok: true,
12531
+ revision: result.revision ?? null,
12532
+ commit: result.commit ?? null
12533
+ };
12534
+ }
12535
+ function pruneStagesFor(stages) {
12536
+ return [
12537
+ ...stages.specs ? ["specs"] : [],
12538
+ ...stages.tasks ? ["tasks"] : [],
12539
+ ...stages.docs ? ["docs"] : []
12540
+ ];
12473
12541
  }
12474
12542
  async function pullContract(deps, bundleDir) {
12475
12543
  if (deps.client === void 0 || deps.projectId === void 0) {
@@ -12528,24 +12596,37 @@ function authoringTimeoutMs() {
12528
12596
  const value = raw === void 0 ? Number.NaN : Number(raw);
12529
12597
  return Number.isFinite(value) && value > 0 ? value : 30 * 60 * 1e3;
12530
12598
  }
12531
- async function runLocalAuthoring(stage, bundleDir, issues) {
12532
- const configDir2 = join8(bundleDir, ".jioogen", "align");
12533
- const configPath = join8(configDir2, "opencode.json");
12534
- await mkdir5(configDir2, { recursive: true });
12535
- const config = await buildAuthoringOpencodeConfig(bundledAuthoringPackDir());
12536
- await writeFile5(configPath, `${JSON.stringify(config, null, 2)}
12537
- `, "utf8");
12538
- const bin = process.env.OPENCODE_BIN?.trim() || "opencode";
12539
- const args = [
12540
- "run",
12541
- "--agent",
12542
- "build",
12543
- "--format",
12544
- "json",
12545
- "--dir",
12546
- bundleDir,
12547
- authoringPrompt(stage, issues)
12548
- ];
12599
+ function authoringAttemptTimeoutMs() {
12600
+ const raw = process.env.JIOOGEN_ALIGN_ATTEMPT_TIMEOUT_MS;
12601
+ const value = raw === void 0 ? Number.NaN : Number(raw);
12602
+ return Number.isFinite(value) && value > 0 ? value : 12 * 60 * 1e3;
12603
+ }
12604
+ function authoringModelChain() {
12605
+ const explicit = process.env.JIOOGEN_AUTHORING_MODEL_CHAIN?.trim();
12606
+ if (explicit !== void 0 && explicit.length > 0) {
12607
+ const parsed = explicit.split(",").map((value) => value.trim()).filter((value) => value.length > 0);
12608
+ if (parsed.length > 0) return parsed;
12609
+ }
12610
+ const single = process.env.JIOOGEN_AUTHORING_MODEL?.trim();
12611
+ return single !== void 0 && single.length > 0 ? [single] : [void 0];
12612
+ }
12613
+ function extractAuthoringError(stdout) {
12614
+ for (const line of stdout.split("\n").reverse()) {
12615
+ const trimmed = line.trim();
12616
+ if (trimmed.length === 0 || !trimmed.startsWith("{")) continue;
12617
+ try {
12618
+ const event = JSON.parse(trimmed);
12619
+ if (event.type !== "error" || event.error === void 0) continue;
12620
+ const message = event.error.data?.message;
12621
+ const name = typeof event.error.name === "string" ? event.error.name : "Error";
12622
+ const ref = typeof event.error.data?.ref === "string" ? ` (ref ${event.error.data.ref})` : "";
12623
+ return typeof message === "string" && message.length > 0 ? `${name}: ${message}${ref}` : name;
12624
+ } catch {
12625
+ }
12626
+ }
12627
+ return void 0;
12628
+ }
12629
+ function runAuthoringAttempt(bin, args, configPath, bundleDir, label, stage, timeoutMs) {
12549
12630
  return new Promise((resolve7) => {
12550
12631
  const child = spawn(bin, args, {
12551
12632
  cwd: bundleDir,
@@ -12554,9 +12635,10 @@ async function runLocalAuthoring(stage, bundleDir, issues) {
12554
12635
  OPENCODE_CONFIG: configPath,
12555
12636
  OPENCODE_DISABLE_CLAUDE_CODE: "1"
12556
12637
  },
12557
- stdio: ["ignore", "ignore", "pipe"]
12638
+ stdio: ["ignore", "pipe", "pipe"]
12558
12639
  });
12559
12640
  let stderr = "";
12641
+ let stdout = "";
12560
12642
  let settled = false;
12561
12643
  const finish = (result) => {
12562
12644
  if (settled) return;
@@ -12567,23 +12649,89 @@ async function runLocalAuthoring(stage, bundleDir, issues) {
12567
12649
  const timer = setTimeout(() => {
12568
12650
  child.kill("SIGTERM");
12569
12651
  setTimeout(() => child.kill("SIGKILL"), 5e3).unref();
12570
- finish({ ok: false, error: `Authoring ${stage} melewati batas waktu.` });
12571
- }, authoringTimeoutMs());
12652
+ finish({ ok: false, error: `Authoring ${stage} via ${label} melewati batas waktu.` });
12653
+ }, timeoutMs);
12572
12654
  timer.unref();
12573
12655
  child.stderr.on("data", (chunk) => {
12574
12656
  stderr = `${stderr}${chunk.toString()}`.slice(-4e3);
12575
12657
  });
12658
+ child.stdout?.on("data", (chunk) => {
12659
+ stdout = `${stdout}${chunk.toString()}`.slice(-8e3);
12660
+ });
12576
12661
  child.on("error", (error) => finish({ ok: false, error: error.message }));
12577
12662
  child.on("close", (code) => {
12578
- finish(
12579
- code === 0 ? { ok: true } : {
12580
- ok: false,
12581
- error: `Authoring ${stage} gagal (exit ${code ?? "?"}). ${stderr.trim()}`
12582
- }
12583
- );
12663
+ if (code === 0) {
12664
+ finish({ ok: true });
12665
+ return;
12666
+ }
12667
+ const detail = extractAuthoringError(stdout) ?? stderr.trim();
12668
+ finish({
12669
+ ok: false,
12670
+ error: `Authoring ${stage} via ${label} gagal (exit ${code ?? "?"}).${detail ? ` ${detail}` : " Tidak ada error dari child process."}`
12671
+ });
12584
12672
  });
12585
12673
  });
12586
12674
  }
12675
+ async function runLocalAuthoring(stage, bundleDir, issues) {
12676
+ const configDir2 = join8(bundleDir, ".jioogen", "align");
12677
+ const configPath = join8(configDir2, "generated.json");
12678
+ await mkdir5(configDir2, { recursive: true });
12679
+ const config = await buildAuthoringOpencodeConfig(bundledAuthoringPackDir());
12680
+ await writeFile5(configPath, `${JSON.stringify(config, null, 2)}
12681
+ `, "utf8");
12682
+ const bin = process.env.OPENCODE_BIN?.trim() || "opencode";
12683
+ const chain = authoringModelChain();
12684
+ const deadline = Date.now() + authoringTimeoutMs();
12685
+ const failures = [];
12686
+ let pending = [...issues];
12687
+ for (const [index, model] of chain.entries()) {
12688
+ const remaining = deadline - Date.now();
12689
+ if (remaining <= 0) {
12690
+ failures.push("batas waktu total habis");
12691
+ break;
12692
+ }
12693
+ if (index > 0) pending = issuesForStage(await inspectBundle(bundleDir), stage);
12694
+ const label = model ?? "default";
12695
+ process.stderr.write(`[align] authoring ${stage} via ${label}
12696
+ `);
12697
+ const before = await snapshotContract(bundleDir);
12698
+ const args = [
12699
+ "run",
12700
+ ...model === void 0 ? [] : ["--model", model],
12701
+ "--agent",
12702
+ "build",
12703
+ "--format",
12704
+ "json",
12705
+ "--dir",
12706
+ bundleDir,
12707
+ authoringPrompt(stage, pending)
12708
+ ];
12709
+ const result = await runAuthoringAttempt(
12710
+ bin,
12711
+ args,
12712
+ configPath,
12713
+ bundleDir,
12714
+ label,
12715
+ stage,
12716
+ // The per-attempt cap only bounds failover iterations; a single-model
12717
+ // run gets the whole remaining budget (a full rewrite legitimately
12718
+ // takes longer than one hop of a chain).
12719
+ chain.length > 1 ? Math.min(authoringAttemptTimeoutMs(), remaining) : remaining
12720
+ );
12721
+ const after = await snapshotContract(bundleDir);
12722
+ const changed = stage === "specs" ? after.specs !== before.specs : after.tasks !== before.tasks;
12723
+ if (result.ok && (changed || pending.length === 0)) return result;
12724
+ const reason = result.ok ? `tidak menulis ${stage}/` : result.error ?? "gagal";
12725
+ failures.push(`${label}: ${reason}`);
12726
+ process.stderr.write(`[align] ${label} gagal: ${reason}
12727
+ `);
12728
+ }
12729
+ const names = chain.map((model) => model ?? "default").join(", ");
12730
+ return {
12731
+ ok: false,
12732
+ error: chain.length === 1 ? `Authoring ${stage} gagal (${names}): ${failures.join(" | ")}` : `Authoring ${stage} gagal pada semua model (${names}). ${failures.join(" | ")}`
12733
+ };
12734
+ }
12587
12735
  async function alignBundle(bundleDir, deps = {}) {
12588
12736
  if (deps.client !== void 0 && deps.projectId !== void 0) {
12589
12737
  await deps.client.ensureProjectLayout(deps.projectId).catch(() => null);
@@ -12592,9 +12740,15 @@ async function alignBundle(bundleDir, deps = {}) {
12592
12740
  let local = await snapshotContract(bundleDir);
12593
12741
  let server = await fetchServerState(deps);
12594
12742
  let ledger = await loadLedger(bundleDir, local, server);
12595
- let check = await inspectBundle(bundleDir);
12743
+ const gate = deps.inspectBundle ?? inspectBundle;
12744
+ let check = await gate(bundleDir);
12596
12745
  const runAuthoring = deps.runAuthoring ?? runLocalAuthoring;
12597
- const attempted = /* @__PURE__ */ new Set();
12746
+ const attempts = /* @__PURE__ */ new Map();
12747
+ const pushedSignatures = /* @__PURE__ */ new Set();
12748
+ const finish = (result) => {
12749
+ const leftovers = serverLeftovers(local, server);
12750
+ return leftovers.length > 0 ? { ...result, warnings: leftovers } : result;
12751
+ };
12598
12752
  for (let step = 0; step < 6; step += 1) {
12599
12753
  const plan = planAlignment(local, ledger, server, check);
12600
12754
  if (plan.kind === "clean") {
@@ -12604,37 +12758,46 @@ async function alignBundle(bundleDir, deps = {}) {
12604
12758
  server,
12605
12759
  at: (/* @__PURE__ */ new Date()).toISOString()
12606
12760
  });
12607
- return { ok: true, applied, check, ledger };
12761
+ return finish({ ok: true, applied, check, ledger });
12608
12762
  }
12609
12763
  if (plan.kind === "gate") {
12610
- return { ok: false, applied, blocked: "Bundle belum lolos gate.", check, ledger };
12764
+ const summary = check.issues.slice(0, 5).map((issue2) => `${issue2.code} @ ${issue2.where}`).join("; ");
12765
+ return finish({
12766
+ ok: false,
12767
+ applied,
12768
+ blocked: `Bundle belum lolos gate (isu milik PRD/user, bukan artefak yang bisa diturunkan). ${summary}`,
12769
+ check,
12770
+ ledger
12771
+ });
12611
12772
  }
12612
12773
  if (plan.kind === "conflict") {
12613
- return { ok: false, applied, blocked: plan.message, check, ledger };
12774
+ return finish({ ok: false, applied, blocked: plan.message, check, ledger });
12614
12775
  }
12615
12776
  if (plan.kind === "approve") {
12616
- return { ok: false, applied, blocked: plan.reason, check, ledger };
12777
+ return finish({ ok: false, applied, blocked: plan.reason, check, ledger });
12617
12778
  }
12618
12779
  if (plan.kind === "author") {
12619
- if (attempted.has(plan.stage)) {
12620
- return {
12780
+ const used = attempts.get(plan.stage) ?? 0;
12781
+ if (used >= 2) {
12782
+ const summary = issuesForStage(check, plan.stage).slice(0, 5).join("; ");
12783
+ return finish({
12621
12784
  ok: false,
12622
12785
  applied,
12623
- blocked: `Gate masih gagal setelah authoring ${plan.stage}.`,
12786
+ blocked: `Gate ${plan.stage} masih gagal setelah 2x authoring. ${summary}`,
12624
12787
  check,
12625
12788
  ledger
12626
- };
12789
+ });
12627
12790
  }
12628
- attempted.add(plan.stage);
12791
+ attempts.set(plan.stage, used + 1);
12629
12792
  const result = await runAuthoring(plan.stage, bundleDir, issuesForStage(check, plan.stage));
12630
12793
  if (!result.ok) {
12631
- return {
12794
+ return finish({
12632
12795
  ok: false,
12633
12796
  applied,
12634
12797
  blocked: result.error ?? `Authoring ${plan.stage} gagal.`,
12635
12798
  check,
12636
12799
  ledger
12637
- };
12800
+ });
12638
12801
  }
12639
12802
  applied.push(`author:${plan.stage}`);
12640
12803
  local = await snapshotContract(bundleDir);
@@ -12655,54 +12818,112 @@ async function alignBundle(bundleDir, deps = {}) {
12655
12818
  }
12656
12819
  };
12657
12820
  await writeContractLedger(bundleDir, ledger);
12658
- check = await inspectBundle(bundleDir);
12821
+ check = await gate(bundleDir);
12659
12822
  continue;
12660
12823
  }
12661
12824
  if (plan.kind === "pull") {
12662
12825
  const error = await pullContract(deps, bundleDir);
12663
12826
  if (error !== null) {
12664
- return { ok: false, applied, blocked: error, check, ledger };
12827
+ return finish({ ok: false, applied, blocked: error, check, ledger });
12665
12828
  }
12666
12829
  applied.push("pull");
12667
12830
  local = await snapshotContract(bundleDir);
12668
12831
  server = await fetchServerState(deps);
12669
- ledger = await loadLedger(bundleDir, local, server);
12832
+ ledger = { ...ledger, local, server, at: (/* @__PURE__ */ new Date()).toISOString() };
12670
12833
  await writeContractLedger(bundleDir, ledger);
12671
- check = await inspectBundle(bundleDir);
12834
+ check = await gate(bundleDir);
12672
12835
  continue;
12673
12836
  }
12674
12837
  if (plan.kind === "push") {
12675
- const approval = await readApproval(bundleDir);
12676
- if (plan.stages.prd && server !== null && server.prd !== local.prd && approval?.prd?.hash !== local.prd) {
12677
- return {
12838
+ if (plan.stages.prd && server !== null && server.prd !== local.prd && local.prd !== null) {
12839
+ await approveLocalRevision(bundleDir, local.prd);
12840
+ }
12841
+ const signature = `${plan.stages.prd}|${plan.stages.specs}|${plan.stages.tasks}|${plan.stages.docs}`;
12842
+ if (pushedSignatures.has(signature)) {
12843
+ return finish({
12678
12844
  ok: false,
12679
12845
  applied,
12680
- blocked: "PRD lokal berubah. Boleh saya kirim versi lokal ke web? (ya/tidak)",
12846
+ blocked: "Web belum konvergen setelah push yang sama; server mungkin belum mendukung pembersihan stage.",
12681
12847
  check,
12682
12848
  ledger
12683
- };
12849
+ });
12684
12850
  }
12851
+ pushedSignatures.add(signature);
12685
12852
  const result = await pushContract(deps, bundleDir, local, plan.stages, server);
12686
12853
  if (!result.ok) {
12687
- return {
12854
+ return finish({
12688
12855
  ok: false,
12689
12856
  applied,
12690
- blocked: result.needsApproval === true ? "PRD lokal berubah. Boleh saya kirim versi lokal ke web? (ya/tidak)" : result.error ?? "Sinkronisasi web gagal.",
12857
+ blocked: result.error ?? "Sinkronisasi web gagal.",
12691
12858
  check,
12692
12859
  ledger
12693
- };
12860
+ });
12694
12861
  }
12695
12862
  applied.push("push");
12696
12863
  server = await fetchServerState(deps);
12697
12864
  ledger = { ...ledger, local, server, at: (/* @__PURE__ */ new Date()).toISOString() };
12698
12865
  }
12699
12866
  }
12700
- return {
12867
+ return finish({
12701
12868
  ok: false,
12702
12869
  applied,
12703
12870
  blocked: "Penyelarasan tidak selesai dalam batas langkah.",
12704
12871
  check,
12705
12872
  ledger
12873
+ });
12874
+ }
12875
+ async function reportBundle(bundleDir, deps = {}) {
12876
+ const local = await snapshotContract(bundleDir);
12877
+ const gate = await (deps.inspectBundle ?? inspectBundle)(bundleDir);
12878
+ const missing = [
12879
+ ...local.prd === null ? ["PRD.md"] : [],
12880
+ ...local.specs === null ? ["specs/"] : [],
12881
+ ...local.tasks === null ? ["tasks/"] : []
12882
+ ];
12883
+ if (missing.length > 0) {
12884
+ return {
12885
+ ok: false,
12886
+ gate,
12887
+ error: `Bundle tidak lengkap: ${missing.join(", ")}. Tidak ada revisi yang dibuat.`
12888
+ };
12889
+ }
12890
+ const ledger = {
12891
+ ...buildContractLedger(local, null, freshDerivation(local)),
12892
+ server: await fetchServerState(deps)
12893
+ };
12894
+ await writeContractLedger(bundleDir, ledger);
12895
+ const server = ledger.server;
12896
+ if (server !== null) {
12897
+ const drift = mergeChanges(
12898
+ changedSince(local, serverViewForLocal(local, server)),
12899
+ serverOnlyStages(local, server)
12900
+ );
12901
+ if (!drift.any && deps.force !== true) {
12902
+ if (deps.client !== void 0 && deps.projectId !== void 0) {
12903
+ await deps.client.postJson(projectPath(deps.projectId, "/prd-confirmation"), { action: "confirm" }).catch(() => null);
12904
+ }
12905
+ return {
12906
+ ok: true,
12907
+ revision: server.revision ?? null,
12908
+ commit: server.commit ?? null,
12909
+ gate
12910
+ };
12911
+ }
12912
+ }
12913
+ const stages = {
12914
+ prd: true,
12915
+ specs: true,
12916
+ tasks: true,
12917
+ docs: true,
12918
+ any: true
12919
+ };
12920
+ const result = await pushContract(deps, bundleDir, local, stages, ledger.server);
12921
+ if (!result.ok) return { ok: false, gate, error: result.error ?? "Gagal menerbitkan revisi." };
12922
+ return {
12923
+ ok: true,
12924
+ revision: result.revision ?? null,
12925
+ commit: result.commit ?? null,
12926
+ gate
12706
12927
  };
12707
12928
  }
12708
12929
  function formatAlign(result) {
@@ -12713,6 +12934,7 @@ function formatAlign(result) {
12713
12934
  lines.push(`\u2716 Kontrak belum selaras: ${result.blocked ?? "tidak diketahui"}`);
12714
12935
  }
12715
12936
  if (result.applied.length > 0) lines.push(` Tindakan: ${result.applied.join(", ")}`);
12937
+ for (const warning of result.warnings ?? []) lines.push(` \u26A0 ${warning}`);
12716
12938
  if (result.check.issueCount > 0) {
12717
12939
  lines.push(` Gate: ${result.check.issueCount} isu.`);
12718
12940
  for (const issue2 of result.check.issues.slice(0, 8)) {
@@ -13028,6 +13250,11 @@ var JIOOGEN_AGENTS_MD = `${MARKER}
13028
13250
  karangan; preferensi user tidak boleh melemahkan keamanan/a11y inti.
13029
13251
  - \`.jioogen/custom/**\` hanya menambah atau mengetatkan; jangan menimpa atau
13030
13252
  menghapus isinya.
13253
+ - **Multi-surface:** bila profil produk punya \u22652 komponen UI (mis. web + Android/
13254
+ iOS native), kerjakan **FE design terpisah per komponen**: ikuti \`Profil produk\`
13255
+ + \`specs/design.md\` komponen itu, jangan pakai desain web untuk app native, dan
13256
+ verifikasi di target masing-masing (browser / emulator / build desktop). Produk
13257
+ responsif satu permukaan = satu desain lintas layar.
13031
13258
  - **Mode task** tercatat di \`.jioogen/project.json\` (\`taskMode\`, di-set saat
13032
13259
  \`pull\`/\`link --mode\`): \`authoring\` (default) memakai task dari JiooGen, \`seed\`
13033
13260
  mengizinkanmu menambah task, \`executor\` hanya menjalankan task yang sudah ada \u2014
@@ -13043,16 +13270,18 @@ var JIOOGEN_AGENTS_MD = `${MARKER}
13043
13270
  ## 0d. Otonomi penyelarasan kontrak (wajib)
13044
13271
 
13045
13272
  - **Jangan menyuruh user mengetik perintah \`jioogen\`.** Kamu yang menjalankan
13046
- \`jioogen approve\`, \`jioogen align\`, dan \`jioogen docs\`.
13273
+ \`jioogen align\` (atau \`jioogen report\`), \`jioogen check\`, dan \`jioogen docs\`.
13047
13274
  - Kontrak ada di \`docs/00-contract/\` (\`PRD.md\`, \`specs/\`, \`tasks/\`); dokumen lain
13048
13275
  ada di \`docs/01-product\`, \`02-design\`, \`03-architecture\`, \`04-domain\`,
13049
13276
  \`05-operations\`, \`06-quality\`. Baca \`docs/README.md\` lebih dulu.
13050
- - Bila user bilang PRD berubah, minta ubah produk, atau specs/tasks tampak basi:
13051
- tanya **sekali** dengan bahasa manusia, mis. "Mau saya rapikan specs, tasks,
13052
- dan web sekaligus? (ya/tidak)". Setelah "ya", jalankan sendiri \`jioogen approve\`
13053
- (bila PRD lokal berbeda dari web) lalu \`jioogen align\`.
13277
+ - Bila user bilang PRD/specs/tasks berubah: jalankan sendiri \`jioogen align\`
13278
+ untuk menerbitkan revisi kontrak lokal ke web. \`align\` TIDAK menulis ulang
13279
+ specs/tasks dan tidak memanggil model; PRD otomatis dikonfirmasi saat publish.
13280
+ Hanya jika user eksplisit minta turunkan ulang specs/tasks, jalankan dengan
13281
+ \`JIOOGEN_ALIGN_AUTHOR=1\`.
13054
13282
  - Bila output CLI menyebut \`ALIGN_NEXT\` atau "kontrak belum selaras": jalankan
13055
- aksinya sendiri. \`ALIGN_NEXT: approve\` \u2192 tanya sekali, lalu \`approve\` + \`align\`.
13283
+ \`jioogen align\`. \`ALIGN_NEXT: approve\` tidak lagi wajib \u2014 publish
13284
+ mengonfirmasi PRD otomatis.
13056
13285
  - **Batch vs Manual:** tanyakan "Batch (sekaligus) atau Manual (satu per satu)?
13057
13286
  (batch/manual)". Pilihan disimpan; ganti hanya bila user memintanya eksplisit.
13058
13287
  - Dokumen = niat, kode = kenyataan. Bila berbeda, jangan menebak; tanyakan
@@ -13097,13 +13326,12 @@ tangan) sebelum task dijalankan, jangan pura-pura mengerjakannya:
13097
13326
  - Verifikasi hasilnya lalu \`npx jioogen task adopt <ref> --note "<alat>"\` (task UI:
13098
13327
  tambahkan \`--visual "<catatan>"\`). Command itu menjalankan \`verificationCommand\`
13099
13328
  dan mencatat \`source: user\` + bukti adopsi di sidecar.
13100
- - Mode authoring lokal: bila user menyetujui patch kontrak di chat lokal, catat
13101
- persetujuan dengan \`npx jioogen approve --note "<alasan>"\` (menulis
13102
- \`.jioogen/approvals.json\` + \`.jioogen/custom/knowledge/approved-patches.md\`),
13103
- lalu ubah \`PRD.md\`. Setelah itu jalankan \`npx jioogen align\`: JiooGen otomatis
13104
- menurunkan \`specs/\` \u2192 \`tasks/\`, memvalidasi gate, dan menyelaraskan ke web.
13105
- \`npx jioogen task next\` juga menyelaraskan otomatis sebelum memilih task.
13106
- Jangan menyuruh user balik ke web dan jangan edit \`specs/\`/\`tasks/\` manual.
13329
+ - Revisi kontrak lokal: bila user menyetujui patch, ubah \`PRD.md\` (dan
13330
+ specs/tasks bila perlu), lalu jalankan \`npx jioogen align\`: kontrak lokal
13331
+ dikirim sebagai revisi baru ke web, PRD otomatis dikonfirmasi, tanpa authoring.
13332
+ \`align\` tidak menulis ulang specs/tasks. \`npx jioogen task next\` melakukan
13333
+ publish yang sama sebelum memilih task. Hanya jika user minta turunkan ulang
13334
+ specs/tasks, jalankan dengan \`JIOOGEN_ALIGN_AUTHOR=1\`.
13107
13335
  - Sebelum mode authoring lokal, agent WAJIB bertanya dengan bahasa manusia:
13108
13336
  "Saya mau mengubah PRD, lalu specs, lalu tasks di lokal. Boleh? (ya/tidak)".
13109
13337
  Lanjut HANYA bila user menjawab "ya". Tanpa "ya", jangan ubah apa pun.
@@ -13217,6 +13445,11 @@ atas ide, refactor, perbaikan, atau fitur lain.
13217
13445
  user tidak boleh melemahkan keamanan/a11y inti.
13218
13446
  - \`.jioogen/custom/**\` hanya menambah atau mengetatkan; jangan menimpa atau
13219
13447
  menghapus isinya.
13448
+ - **Multi-surface:** bila profil produk punya \u22652 komponen UI (mis. web + Android/
13449
+ iOS native), kerjakan **FE design terpisah per komponen**: ikuti \`Profil produk\`
13450
+ + \`specs/design.md\` komponen itu, jangan pakai desain web untuk app native, dan
13451
+ verifikasi di target masing-masing (browser / emulator / build desktop). Produk
13452
+ responsif satu permukaan = satu desain lintas layar.
13220
13453
  - **Mode task** tercatat di \`.jioogen/project.json\` (\`taskMode\`, di-set saat
13221
13454
  \`pull\`/\`link --mode\`): \`authoring\` (default) memakai task dari JiooGen, \`seed\`
13222
13455
  mengizinkanmu menambah task, \`executor\` hanya menjalankan task yang sudah ada \u2014
@@ -13227,16 +13460,18 @@ atas ide, refactor, perbaikan, atau fitur lain.
13227
13460
  ## 0d. Otonomi penyelarasan kontrak (wajib)
13228
13461
 
13229
13462
  - **Jangan menyuruh user mengetik perintah \`jioogen\`.** Kamu yang menjalankan
13230
- \`jioogen approve\`, \`jioogen align\`, dan \`jioogen docs\`.
13463
+ \`jioogen align\` (atau \`jioogen report\`), \`jioogen check\`, dan \`jioogen docs\`.
13231
13464
  - Kontrak ada di \`docs/00-contract/\` (\`PRD.md\`, \`specs/\`, \`tasks/\`); dokumen lain
13232
13465
  ada di \`docs/01-product\`, \`02-design\`, \`03-architecture\`, \`04-domain\`,
13233
13466
  \`05-operations\`, \`06-quality\`. Baca \`docs/README.md\` lebih dulu.
13234
- - Bila user bilang PRD berubah, minta ubah produk, atau specs/tasks tampak basi:
13235
- tanya **sekali** dengan bahasa manusia, mis. "Mau saya rapikan specs, tasks,
13236
- dan web sekaligus? (ya/tidak)". Setelah "ya", jalankan sendiri \`jioogen approve\`
13237
- (bila PRD lokal berbeda dari web) lalu \`jioogen align\`.
13467
+ - Bila user bilang PRD/specs/tasks berubah: jalankan sendiri \`jioogen align\`
13468
+ untuk menerbitkan revisi kontrak lokal ke web. \`align\` TIDAK menulis ulang
13469
+ specs/tasks dan tidak memanggil model; PRD otomatis dikonfirmasi saat publish.
13470
+ Hanya jika user eksplisit minta turunkan ulang specs/tasks, jalankan dengan
13471
+ \`JIOOGEN_ALIGN_AUTHOR=1\`.
13238
13472
  - Bila output CLI menyebut \`ALIGN_NEXT\` atau "kontrak belum selaras": jalankan
13239
- aksinya sendiri. \`ALIGN_NEXT: approve\` \u2192 tanya sekali, lalu \`approve\` + \`align\`.
13473
+ \`jioogen align\`. \`ALIGN_NEXT: approve\` tidak lagi wajib \u2014 publish
13474
+ mengonfirmasi PRD otomatis.
13240
13475
  - **Batch vs Manual:** tanyakan "Batch (sekaligus) atau Manual (satu per satu)?
13241
13476
  (batch/manual)". Pilihan disimpan; ganti hanya bila user memintanya eksplisit.
13242
13477
  - Dokumen = niat, kode = kenyataan. Bila berbeda, jangan menebak; tanyakan
@@ -13274,13 +13509,12 @@ atau ditulis tangan \u2014 sebelum task dijalankan, jangan pura-pura mengerjakan
13274
13509
  - Verifikasi hasilnya lalu \`npx jioogen task adopt <ref> --note "<alat>"\` (task UI:
13275
13510
  tambahkan \`--visual "<catatan>"\`). Command itu menjalankan \`verificationCommand\`
13276
13511
  dan mencatat \`source: user\` + bukti adopsi di sidecar.
13277
- - Mode authoring lokal: bila user menyetujui patch kontrak di chat lokal, catat
13278
- persetujuan dengan \`npx jioogen approve --note "<alasan>"\` (menulis
13279
- \`.jioogen/approvals.json\` + \`.jioogen/custom/knowledge/approved-patches.md\`),
13280
- lalu ubah \`PRD.md\`. Setelah itu jalankan \`npx jioogen align\`: JiooGen otomatis
13281
- menurunkan \`specs/\` \u2192 \`tasks/\`, memvalidasi gate, dan menyelaraskan ke web.
13282
- \`npx jioogen task next\` juga menyelaraskan otomatis sebelum memilih task.
13283
- Jangan menyuruh user balik ke web dan jangan edit \`specs/\`/\`tasks/\` manual.
13512
+ - Revisi kontrak lokal: bila user menyetujui patch, ubah \`PRD.md\` (dan
13513
+ specs/tasks bila perlu), lalu jalankan \`npx jioogen align\`: kontrak lokal
13514
+ dikirim sebagai revisi baru ke web, PRD otomatis dikonfirmasi, tanpa authoring.
13515
+ \`align\` tidak menulis ulang specs/tasks. \`npx jioogen task next\` melakukan
13516
+ publish yang sama sebelum memilih task. Hanya jika user minta turunkan ulang
13517
+ specs/tasks, jalankan dengan \`JIOOGEN_ALIGN_AUTHOR=1\`.
13284
13518
  - Sebelum mode authoring lokal, agent WAJIB bertanya dengan bahasa manusia:
13285
13519
  "Saya mau mengubah PRD, lalu specs, lalu tasks di lokal. Boleh? (ya/tidak)".
13286
13520
  Lanjut HANYA bila user menjawab "ya". Tanpa "ya", jangan ubah apa pun.
@@ -15476,6 +15710,10 @@ async function alignCommand(options) {
15476
15710
  client = void 0;
15477
15711
  }
15478
15712
  }
15713
+ if (process.env.JIOOGEN_ALIGN_AUTHOR !== "1") {
15714
+ await reportCommand(options);
15715
+ return;
15716
+ }
15479
15717
  const autoDisabled = process.env.JIOOGEN_AUTO_ALIGN === "0";
15480
15718
  const result = await alignBundle(local.bundleDir, {
15481
15719
  ...client === void 0 ? {} : { client },
@@ -15494,6 +15732,61 @@ async function alignCommand(options) {
15494
15732
  }
15495
15733
  if (!result.ok) process.exitCode = 1;
15496
15734
  }
15735
+ async function reportCommand(options) {
15736
+ const local = await resolveLocalBundle(options);
15737
+ let client;
15738
+ const noSync = options.noSync === true || process.env.JIOOGEN_NO_SYNC === "1";
15739
+ if (!noSync) {
15740
+ try {
15741
+ const api = await resolveApi({ api: options.api ?? local.linkedApiUrl });
15742
+ client = api.client;
15743
+ } catch {
15744
+ client = void 0;
15745
+ }
15746
+ }
15747
+ const result = await reportBundle(local.bundleDir, {
15748
+ ...client === void 0 ? {} : { client },
15749
+ projectId: local.projectId,
15750
+ ...options.force === true ? { force: true } : {}
15751
+ });
15752
+ if (options.json === true) {
15753
+ console.log(
15754
+ JSON.stringify(
15755
+ {
15756
+ ok: result.ok,
15757
+ revision: result.revision ?? null,
15758
+ commit: result.commit ?? null,
15759
+ gate: {
15760
+ ok: result.gate.ok,
15761
+ issueCount: result.gate.issueCount,
15762
+ issues: result.gate.issues.slice(0, 12).map((issue2) => ({
15763
+ code: issue2.code,
15764
+ where: issue2.where,
15765
+ message: issue2.message
15766
+ }))
15767
+ },
15768
+ ...result.error === void 0 ? {} : { error: result.error }
15769
+ },
15770
+ null,
15771
+ 2
15772
+ )
15773
+ );
15774
+ } else {
15775
+ console.log(
15776
+ result.ok ? "\u2714 Revisi diterbitkan." : `\u2716 ${result.error ?? "Gagal menerbitkan revisi."}`
15777
+ );
15778
+ if (result.revision !== void 0 && result.revision !== null) {
15779
+ console.log(` Revisi: ${result.revision} (${result.commit ?? "-"})`);
15780
+ }
15781
+ if (result.gate.issueCount > 0) {
15782
+ console.log(` Gate: ${result.gate.issueCount} isu (laporan, tidak memblokir).`);
15783
+ for (const issue2 of result.gate.issues.slice(0, 8)) {
15784
+ console.log(` - ${issue2.code} ${issue2.where}: ${issue2.message}`);
15785
+ }
15786
+ }
15787
+ }
15788
+ if (!result.ok) process.exitCode = 1;
15789
+ }
15497
15790
  async function docsCommand(options, subcommand) {
15498
15791
  const link = await findProjectLink(options.dir ?? process.cwd());
15499
15792
  const bundleDir = resolve6(link?.bundleDir ?? options.dir ?? process.cwd());
@@ -15726,11 +16019,7 @@ async function alignBeforeTask(options) {
15726
16019
  await installAgentSkills(local.bundleDir, { noSkills: true }).catch(() => null);
15727
16020
  const contract = await snapshotContract(local.bundleDir);
15728
16021
  if (!hasContractArtifacts(contract)) return true;
15729
- const ledger = await readContractLedger(local.bundleDir);
15730
- const check = await inspectBundle(local.bundleDir);
15731
- const stale = ledger === null ? true : computeStaleness(ledger.derivation, contract).stale;
15732
- if (ledger !== null && check.ok && !stale) return true;
15733
- if (options.json !== true) console.log("Kontrak belum selaras; menyelaraskan otomatis...");
16022
+ if (options.json !== true) console.log("Menyelaraskan revisi kontrak ke web...");
15734
16023
  let client;
15735
16024
  const noSync = options.noSync === true || process.env.JIOOGEN_NO_SYNC === "1";
15736
16025
  if (!noSync) {
@@ -15741,25 +16030,36 @@ async function alignBeforeTask(options) {
15741
16030
  client = void 0;
15742
16031
  }
15743
16032
  }
15744
- const result = await alignBundle(local.bundleDir, {
16033
+ const result = await reportBundle(local.bundleDir, {
15745
16034
  ...client === void 0 ? {} : { client },
15746
16035
  projectId: local.projectId
15747
16036
  });
15748
16037
  if (options.json === true) {
15749
16038
  console.log(
15750
16039
  JSON.stringify(
15751
- { aligned: result.ok, blocked: result.blocked, applied: result.applied },
16040
+ {
16041
+ aligned: result.ok,
16042
+ revision: result.revision ?? null,
16043
+ gate: result.gate.issueCount,
16044
+ error: result.error ?? null
16045
+ },
15752
16046
  null,
15753
16047
  2
15754
16048
  )
15755
16049
  );
16050
+ } else if (result.ok) {
16051
+ console.log(
16052
+ `Revisi kontrak aktif${result.revision === void 0 || result.revision === null ? "" : `: ${result.revision}`}.`
16053
+ );
15756
16054
  } else {
15757
- console.log(formatAlign(result));
15758
- if (!result.ok) console.log("Task tidak dipilih sampai kontrak selaras.");
16055
+ console.log(`Peringatan: revisi belum terkirim ke web (${result.error ?? "tidak diketahui"}).`);
15759
16056
  }
15760
- if (result.ok) return true;
15761
- process.exitCode = 1;
15762
- return false;
16057
+ if (!result.gate.ok) {
16058
+ console.log("Task tidak dipilih sampai kontrak selaras.");
16059
+ process.exitCode = 1;
16060
+ return false;
16061
+ }
16062
+ return true;
15763
16063
  }
15764
16064
  async function taskNextCommand(options) {
15765
16065
  if (!await alignBeforeTask(options)) return;
@@ -15951,6 +16251,9 @@ async function taskStartCommand(ref, options) {
15951
16251
  awaitingCheckpoint: false,
15952
16252
  note: ""
15953
16253
  });
16254
+ const ledger = await readContractLedger(local.bundleDir);
16255
+ const pinned = ledger?.server?.revision;
16256
+ if (pinned !== void 0 && pinned !== null) updated.revision = pinned;
15954
16257
  await writeState(local.bundleDir, updated);
15955
16258
  const definition = local.definitions.find((entry) => entry.id.toUpperCase() === key);
15956
16259
  if (definition !== void 0) {
@@ -16795,7 +17098,7 @@ async function resolveLocalBundle(options) {
16795
17098
  const projectId = options.project ?? envFirst2("JIOOGEN_PROJECT", "JIOOCODE_PROJECT") ?? link?.projectId;
16796
17099
  if (projectId === void 0 || projectId.length === 0) {
16797
17100
  throw new Error(
16798
- "Project belum di-bind. Jalankan `jioogen pull <projectId>` atau pakai --project."
17101
+ "Project belum di-bind. Jalankan `jioogen link <projectId>` (atau pakai --project). `jioogen pull` akan menimpa kontrak lokal Anda \u2014 jangan dipakai hanya untuk mengikat project."
16799
17102
  );
16800
17103
  }
16801
17104
  return {
@@ -17203,7 +17506,7 @@ async function readLine() {
17203
17506
  }
17204
17507
 
17205
17508
  // src/index.ts
17206
- var VERSION = "0.2.16";
17509
+ var VERSION = "0.2.17";
17207
17510
  function parseTaskModeOption(value) {
17208
17511
  if (value === void 0) return void 0;
17209
17512
  const parsed = TaskModeSchema.safeParse(value);
@@ -17242,6 +17545,7 @@ Usage:
17242
17545
  jioogen authoring status [--dir <dir>] [--json]
17243
17546
  jioogen authoring remove [--dir <dir>]
17244
17547
  jioogen align [--dir <dir>] [--json]
17548
+ jioogen report [--dir <dir>] [--json] [--force]
17245
17549
  jioogen approve [--dir <dir>] [--note <text>] [--json]
17246
17550
  jioogen docs (scan|migrate|index|check) [--dir <dir>] [--dry-run] [--json]
17247
17551
  jioogen check [--dir <dir>] [--json]
@@ -17455,6 +17759,9 @@ async function dispatch(command, rest, options) {
17455
17759
  case "align":
17456
17760
  await alignCommand(options);
17457
17761
  return;
17762
+ case "report":
17763
+ await reportCommand(options);
17764
+ return;
17458
17765
  case "docs":
17459
17766
  await docsCommand(options, rest[0] ?? "scan");
17460
17767
  return;