jioogen 0.2.16 → 0.2.18
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/authoring-pack/agent/core.md +3 -1
- package/authoring-pack/agent/discovery.md +1 -1
- package/authoring-pack/agent/prd.md +1 -1
- package/authoring-pack/agent/specs.md +1 -1
- package/authoring-pack/agent/tasks.md +1 -1
- package/authoring-pack/manifest.json +6 -6
- package/dist/index.js +472 -124
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
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 =
|
|
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({});
|
|
@@ -9896,6 +9898,12 @@ function summarizeExecutionCounts(tasks) {
|
|
|
9896
9898
|
}
|
|
9897
9899
|
return base;
|
|
9898
9900
|
}
|
|
9901
|
+
function isAdoptedTask(task) {
|
|
9902
|
+
if (task.source === "user") return true;
|
|
9903
|
+
return (task.evidence ?? []).some(
|
|
9904
|
+
(entry) => entry.type === "text" && entry.summary !== void 0 && entry.summary.startsWith("adopted outside harness")
|
|
9905
|
+
);
|
|
9906
|
+
}
|
|
9899
9907
|
function computeCompletion(tasks, definitions) {
|
|
9900
9908
|
const defById = new Map(
|
|
9901
9909
|
(definitions ?? []).map((definition) => [definition.id.toUpperCase(), definition])
|
|
@@ -9916,20 +9924,26 @@ function computeCompletion(tasks, definitions) {
|
|
|
9916
9924
|
for (const subfeature of definition.subfeatures ?? []) tally(subfeature, done);
|
|
9917
9925
|
};
|
|
9918
9926
|
let tasksDone = 0;
|
|
9927
|
+
let tasksVerified = 0;
|
|
9928
|
+
const adoptedTaskRefs = [];
|
|
9919
9929
|
const seenIds = /* @__PURE__ */ new Set();
|
|
9920
9930
|
const doneRefs = /* @__PURE__ */ new Set();
|
|
9921
9931
|
for (const task of tasks) {
|
|
9922
9932
|
const done = task.status === "done";
|
|
9933
|
+
const adopted = isAdoptedTask(task);
|
|
9934
|
+
const verifiedDone = done && !adopted;
|
|
9923
9935
|
if (done) {
|
|
9924
9936
|
tasksDone += 1;
|
|
9925
9937
|
doneRefs.add(task.ref.toUpperCase());
|
|
9926
9938
|
}
|
|
9939
|
+
if (verifiedDone) tasksVerified += 1;
|
|
9940
|
+
if (adopted) adoptedTaskRefs.push(task.ref);
|
|
9927
9941
|
seenIds.add(task.ref.toUpperCase());
|
|
9928
9942
|
const definition = defById.get(task.ref.toUpperCase());
|
|
9929
|
-
tally(definition?.featureId ?? task.featureId,
|
|
9930
|
-
tally(definition?.moduleId ?? task.moduleId,
|
|
9943
|
+
tally(definition?.featureId ?? task.featureId, verifiedDone);
|
|
9944
|
+
tally(definition?.moduleId ?? task.moduleId, verifiedDone);
|
|
9931
9945
|
const subfeatures = definition?.subfeatures ?? task.subfeatures ?? [];
|
|
9932
|
-
for (const subfeature of subfeatures) tally(subfeature,
|
|
9946
|
+
for (const subfeature of subfeatures) tally(subfeature, verifiedDone);
|
|
9933
9947
|
}
|
|
9934
9948
|
for (const definition of definitions ?? []) {
|
|
9935
9949
|
if (definition !== void 0 && !seenIds.has(definition.id.toUpperCase())) {
|
|
@@ -9941,20 +9955,29 @@ function computeCompletion(tasks, definitions) {
|
|
|
9941
9955
|
const status = entry.done === 0 ? "missing" : entry.done < entry.total ? "incomplete" : "complete";
|
|
9942
9956
|
features[id] = { status, doneTasks: entry.done, totalTasks: entry.total };
|
|
9943
9957
|
}
|
|
9944
|
-
const
|
|
9958
|
+
const allTasksVerified = tasks.every((task) => task.status === "done" && !isAdoptedTask(task));
|
|
9945
9959
|
const unitIds = Object.keys(features);
|
|
9946
9960
|
const allUnitsComplete = unitIds.length > 0 && unitIds.every((id) => features[id]?.status === "complete");
|
|
9947
9961
|
let allIntegrationDone = true;
|
|
9948
9962
|
for (const task of tasks) {
|
|
9949
|
-
if (task.layer === "integration" && task.status !== "done"
|
|
9963
|
+
if (task.layer === "integration" && (task.status !== "done" || isAdoptedTask(task))) {
|
|
9964
|
+
allIntegrationDone = false;
|
|
9965
|
+
}
|
|
9950
9966
|
}
|
|
9951
9967
|
for (const definition of definitions ?? []) {
|
|
9952
9968
|
if (definition.layer === "integration" && !doneRefs.has(definition.id.toUpperCase())) {
|
|
9953
9969
|
allIntegrationDone = false;
|
|
9954
9970
|
}
|
|
9955
9971
|
}
|
|
9956
|
-
const projectComplete =
|
|
9957
|
-
return {
|
|
9972
|
+
const projectComplete = allTasksVerified && allUnitsComplete && allIntegrationDone;
|
|
9973
|
+
return {
|
|
9974
|
+
tasksDone,
|
|
9975
|
+
tasksVerified,
|
|
9976
|
+
totalTasks: tasks.length,
|
|
9977
|
+
features,
|
|
9978
|
+
adoptedTaskRefs,
|
|
9979
|
+
projectComplete
|
|
9980
|
+
};
|
|
9958
9981
|
}
|
|
9959
9982
|
|
|
9960
9983
|
// ../contracts/src/layout.ts
|
|
@@ -9963,6 +9986,9 @@ var CONTRACT_ROOT_REL = "docs/00-contract";
|
|
|
9963
9986
|
function isContractArtifactPath(relative3) {
|
|
9964
9987
|
return relative3 === "PRD.md" || relative3 === "traceability.md" || relative3.startsWith("specs/") || relative3.startsWith("tasks/");
|
|
9965
9988
|
}
|
|
9989
|
+
function isDocsArtifactPath(relative3) {
|
|
9990
|
+
return relative3.startsWith("docs/") && relative3.endsWith(".md") && !relative3.startsWith(`${CONTRACT_ROOT_REL}/`);
|
|
9991
|
+
}
|
|
9966
9992
|
function normalizeContractRoot(value) {
|
|
9967
9993
|
if (typeof value !== "string") return null;
|
|
9968
9994
|
const normalized = value.replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
|
|
@@ -10824,7 +10850,7 @@ async function snapshotContract(bundleDir) {
|
|
|
10824
10850
|
const files = {};
|
|
10825
10851
|
for (const path of [...paths].sort()) {
|
|
10826
10852
|
try {
|
|
10827
|
-
files[path] = sha256(await readFile3(
|
|
10853
|
+
files[path] = sha256(await readFile3(resolveProjectPath(bundleDir, path)));
|
|
10828
10854
|
} catch {
|
|
10829
10855
|
}
|
|
10830
10856
|
}
|
|
@@ -10866,6 +10892,20 @@ function changedSince(current, previous) {
|
|
|
10866
10892
|
const docs = previous === null ? current.docs !== null : current.docs !== previous.docs;
|
|
10867
10893
|
return { prd, specs, tasks, docs, any: prd || specs || tasks || docs };
|
|
10868
10894
|
}
|
|
10895
|
+
function serverOnlyStages(local, server) {
|
|
10896
|
+
const extra = Object.keys(server.files ?? {}).filter((path) => !(path in local.files));
|
|
10897
|
+
const specs = local.specs !== null && extra.some((path) => path.startsWith("specs/"));
|
|
10898
|
+
const tasks = local.tasks !== null && extra.some((path) => path.startsWith("tasks/") || path === "traceability.md");
|
|
10899
|
+
const docs = local.docs !== null && extra.some((path) => path.startsWith("docs/"));
|
|
10900
|
+
return { prd: false, specs, tasks, docs, any: specs || tasks || docs };
|
|
10901
|
+
}
|
|
10902
|
+
function mergeChanges(left, right) {
|
|
10903
|
+
const prd = left.prd || right.prd;
|
|
10904
|
+
const specs = left.specs || right.specs;
|
|
10905
|
+
const tasks = left.tasks || right.tasks;
|
|
10906
|
+
const docs = left.docs || right.docs;
|
|
10907
|
+
return { prd, specs, tasks, docs, any: prd || specs || tasks || docs };
|
|
10908
|
+
}
|
|
10869
10909
|
function serverAsSnapshot(server) {
|
|
10870
10910
|
return {
|
|
10871
10911
|
prd: server.prd,
|
|
@@ -10875,6 +10915,20 @@ function serverAsSnapshot(server) {
|
|
|
10875
10915
|
files: {}
|
|
10876
10916
|
};
|
|
10877
10917
|
}
|
|
10918
|
+
function serverViewForLocal(local, server) {
|
|
10919
|
+
const files = {};
|
|
10920
|
+
for (const path of Object.keys(local.files)) {
|
|
10921
|
+
const hash = server.files?.[path];
|
|
10922
|
+
if (hash !== void 0) files[path] = hash;
|
|
10923
|
+
}
|
|
10924
|
+
return {
|
|
10925
|
+
prd: files["PRD.md"] ?? null,
|
|
10926
|
+
specs: fingerprint(files, (path) => path.startsWith("specs/")),
|
|
10927
|
+
tasks: fingerprint(files, (path) => path.startsWith("tasks/") || path === "traceability.md"),
|
|
10928
|
+
docs: fingerprint(files, (path) => path.startsWith("docs/")),
|
|
10929
|
+
files
|
|
10930
|
+
};
|
|
10931
|
+
}
|
|
10878
10932
|
function objectValue(value) {
|
|
10879
10933
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
10880
10934
|
}
|
|
@@ -11349,6 +11403,7 @@ var LAYER_CHECKLISTS = {
|
|
|
11349
11403
|
"- Responsive untuk mobile dan desktop.",
|
|
11350
11404
|
"- Aksesibilitas dasar: label, aria, focus, keyboard.",
|
|
11351
11405
|
"- Microcopy jelas dan konsisten dengan konteks.",
|
|
11406
|
+
"- Multi-surface: kerjakan FE design terpisah per komponen UI; jangan pakai desain web untuk app native.",
|
|
11352
11407
|
"- Tanpa komponen/abstraksi baru untuk satu pemakaian; reuse yang ada."
|
|
11353
11408
|
],
|
|
11354
11409
|
database: [
|
|
@@ -11475,7 +11530,7 @@ function renderActiveTask(task, context) {
|
|
|
11475
11530
|
"- Jangan pindah task, jangan mengerjakan task lain, jangan melebar ke file di luar targetFiles (file/direktori/glob).",
|
|
11476
11531
|
"- Jangan mengarang fitur/endpoint/kolom di luar PRD.md/specs/.",
|
|
11477
11532
|
"- 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
|
|
11533
|
+
"- 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
11534
|
"- Selesai: `npx jioogen task complete <ref>`, lalu `npx jioogen sync`."
|
|
11480
11535
|
);
|
|
11481
11536
|
const checklist = renderQualityChecklist(task.layer, context);
|
|
@@ -11882,7 +11937,7 @@ function buildCustomKnowledgeBlock(bundleDir) {
|
|
|
11882
11937
|
...files.map((file) => `- ${file}`),
|
|
11883
11938
|
"Baca file-file di atas sebagai konteks tambahan user sebelum coding.",
|
|
11884
11939
|
"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,
|
|
11940
|
+
"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
11941
|
];
|
|
11887
11942
|
return lines.join("\n");
|
|
11888
11943
|
}
|
|
@@ -12292,6 +12347,9 @@ function serverStateFromWorkspace(state) {
|
|
|
12292
12347
|
specs: fingerprint(files, (path) => path.startsWith("specs/")),
|
|
12293
12348
|
tasks: fingerprint(files, (path) => path.startsWith("tasks/") || path === "traceability.md"),
|
|
12294
12349
|
docs: fingerprint(files, (path) => path.startsWith("docs/")),
|
|
12350
|
+
files,
|
|
12351
|
+
revision: state.revision ?? null,
|
|
12352
|
+
commit: state.commit ?? null,
|
|
12295
12353
|
derivation: parseDerivation(state.derivation)
|
|
12296
12354
|
};
|
|
12297
12355
|
}
|
|
@@ -12392,7 +12450,10 @@ function planAlignment(local, ledger, server, check) {
|
|
|
12392
12450
|
}
|
|
12393
12451
|
return { kind: "gate", check };
|
|
12394
12452
|
}
|
|
12395
|
-
const pushChanges = server === null ? localChanges :
|
|
12453
|
+
const pushChanges = server === null ? localChanges : mergeChanges(
|
|
12454
|
+
changedSince(local, serverViewForLocal(local, server)),
|
|
12455
|
+
serverOnlyStages(local, server)
|
|
12456
|
+
);
|
|
12396
12457
|
if (pushChanges.any) {
|
|
12397
12458
|
return {
|
|
12398
12459
|
kind: "push",
|
|
@@ -12422,21 +12483,38 @@ async function readContractFiles(bundleDir, snapshot, stages) {
|
|
|
12422
12483
|
}
|
|
12423
12484
|
return files;
|
|
12424
12485
|
}
|
|
12486
|
+
async function approveLocalRevision(bundleDir, prdHash) {
|
|
12487
|
+
const existing = await readApproval(bundleDir);
|
|
12488
|
+
if (existing?.prd?.hash === prdHash) return;
|
|
12489
|
+
await writeApproval(bundleDir, {
|
|
12490
|
+
schemaVersion: 1,
|
|
12491
|
+
prd: {
|
|
12492
|
+
hash: prdHash,
|
|
12493
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12494
|
+
note: "auto: revisi PRD lokal diselaraskan"
|
|
12495
|
+
}
|
|
12496
|
+
});
|
|
12497
|
+
}
|
|
12498
|
+
function serverLeftovers(local, server) {
|
|
12499
|
+
if (server === null) return [];
|
|
12500
|
+
const extra = Object.keys(server.files ?? {}).filter(
|
|
12501
|
+
(path) => !(path in local.files) && (isContractArtifactPath(path) || isDocsArtifactPath(path))
|
|
12502
|
+
);
|
|
12503
|
+
if (extra.length === 0) return [];
|
|
12504
|
+
const sample = extra.slice(0, 3).join(", ");
|
|
12505
|
+
return [
|
|
12506
|
+
`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.`
|
|
12507
|
+
];
|
|
12508
|
+
}
|
|
12425
12509
|
async function pushContract(deps, bundleDir, snapshot, stages, server) {
|
|
12426
12510
|
if (deps.client === void 0 || deps.projectId === void 0) {
|
|
12427
12511
|
return { ok: false, error: "Project belum terhubung ke API; sinkronisasi web dilewati." };
|
|
12428
12512
|
}
|
|
12429
12513
|
const approval = await readApproval(bundleDir);
|
|
12430
|
-
if (stages.prd && server !== null && server.prd !== snapshot.prd) {
|
|
12514
|
+
if (stages.prd && server !== null && server.prd !== snapshot.prd && snapshot.prd !== null) {
|
|
12431
12515
|
const confirmation = await deps.client.getPrdConfirmation(deps.projectId).catch(() => null);
|
|
12432
12516
|
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
|
-
}
|
|
12517
|
+
if (approval?.prd?.hash !== snapshot.prd) await approveLocalRevision(bundleDir, snapshot.prd);
|
|
12440
12518
|
await deps.client.revokePrdConfirmation(
|
|
12441
12519
|
deps.projectId,
|
|
12442
12520
|
"PRD lokal disetujui user untuk diselaraskan."
|
|
@@ -12445,10 +12523,14 @@ async function pushContract(deps, bundleDir, snapshot, stages, server) {
|
|
|
12445
12523
|
}
|
|
12446
12524
|
await deps.client.ensureProjectLayout(deps.projectId).catch(() => null);
|
|
12447
12525
|
const files = await readContractFiles(bundleDir, snapshot, stages);
|
|
12526
|
+
const pruneStages = pruneStagesFor(stages);
|
|
12448
12527
|
let result;
|
|
12449
12528
|
try {
|
|
12450
12529
|
result = await deps.client.postJson(projectPath(deps.projectId, "/artifacts"), {
|
|
12451
|
-
files
|
|
12530
|
+
files,
|
|
12531
|
+
...pruneStages.length > 0 ? { pruneStages } : {},
|
|
12532
|
+
publish: true,
|
|
12533
|
+
...server?.revision === void 0 || server.revision === null ? {} : { baseRevision: server.revision }
|
|
12452
12534
|
});
|
|
12453
12535
|
} catch (error) {
|
|
12454
12536
|
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -12456,11 +12538,7 @@ async function pushContract(deps, bundleDir, snapshot, stages, server) {
|
|
|
12456
12538
|
const rejected = result.rejected ?? [];
|
|
12457
12539
|
const prdRejected = rejected.find((entry) => entry.path === "PRD.md");
|
|
12458
12540
|
if (prdRejected !== void 0) {
|
|
12459
|
-
return {
|
|
12460
|
-
ok: false,
|
|
12461
|
-
needsApproval: prdRejected.code === "PRD_CONFIRMED",
|
|
12462
|
-
error: prdRejected.reason
|
|
12463
|
-
};
|
|
12541
|
+
return { ok: false, error: prdRejected.reason };
|
|
12464
12542
|
}
|
|
12465
12543
|
const blocked = rejected.filter((entry) => entry.code !== "PRD_CONFIRMED");
|
|
12466
12544
|
if (blocked.length > 0) {
|
|
@@ -12469,7 +12547,18 @@ async function pushContract(deps, bundleDir, snapshot, stages, server) {
|
|
|
12469
12547
|
error: blocked.map((entry) => `${entry.path}: ${entry.reason}`).join(" | ")
|
|
12470
12548
|
};
|
|
12471
12549
|
}
|
|
12472
|
-
return {
|
|
12550
|
+
return {
|
|
12551
|
+
ok: true,
|
|
12552
|
+
revision: result.revision ?? null,
|
|
12553
|
+
commit: result.commit ?? null
|
|
12554
|
+
};
|
|
12555
|
+
}
|
|
12556
|
+
function pruneStagesFor(stages) {
|
|
12557
|
+
return [
|
|
12558
|
+
...stages.specs ? ["specs"] : [],
|
|
12559
|
+
...stages.tasks ? ["tasks"] : [],
|
|
12560
|
+
...stages.docs ? ["docs"] : []
|
|
12561
|
+
];
|
|
12473
12562
|
}
|
|
12474
12563
|
async function pullContract(deps, bundleDir) {
|
|
12475
12564
|
if (deps.client === void 0 || deps.projectId === void 0) {
|
|
@@ -12528,24 +12617,37 @@ function authoringTimeoutMs() {
|
|
|
12528
12617
|
const value = raw === void 0 ? Number.NaN : Number(raw);
|
|
12529
12618
|
return Number.isFinite(value) && value > 0 ? value : 30 * 60 * 1e3;
|
|
12530
12619
|
}
|
|
12531
|
-
|
|
12532
|
-
const
|
|
12533
|
-
const
|
|
12534
|
-
|
|
12535
|
-
|
|
12536
|
-
|
|
12537
|
-
|
|
12538
|
-
|
|
12539
|
-
|
|
12540
|
-
|
|
12541
|
-
|
|
12542
|
-
|
|
12543
|
-
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
|
|
12547
|
-
|
|
12548
|
-
|
|
12620
|
+
function authoringAttemptTimeoutMs() {
|
|
12621
|
+
const raw = process.env.JIOOGEN_ALIGN_ATTEMPT_TIMEOUT_MS;
|
|
12622
|
+
const value = raw === void 0 ? Number.NaN : Number(raw);
|
|
12623
|
+
return Number.isFinite(value) && value > 0 ? value : 12 * 60 * 1e3;
|
|
12624
|
+
}
|
|
12625
|
+
function authoringModelChain() {
|
|
12626
|
+
const explicit = process.env.JIOOGEN_AUTHORING_MODEL_CHAIN?.trim();
|
|
12627
|
+
if (explicit !== void 0 && explicit.length > 0) {
|
|
12628
|
+
const parsed = explicit.split(",").map((value) => value.trim()).filter((value) => value.length > 0);
|
|
12629
|
+
if (parsed.length > 0) return parsed;
|
|
12630
|
+
}
|
|
12631
|
+
const single = process.env.JIOOGEN_AUTHORING_MODEL?.trim();
|
|
12632
|
+
return single !== void 0 && single.length > 0 ? [single] : [void 0];
|
|
12633
|
+
}
|
|
12634
|
+
function extractAuthoringError(stdout) {
|
|
12635
|
+
for (const line of stdout.split("\n").reverse()) {
|
|
12636
|
+
const trimmed = line.trim();
|
|
12637
|
+
if (trimmed.length === 0 || !trimmed.startsWith("{")) continue;
|
|
12638
|
+
try {
|
|
12639
|
+
const event = JSON.parse(trimmed);
|
|
12640
|
+
if (event.type !== "error" || event.error === void 0) continue;
|
|
12641
|
+
const message = event.error.data?.message;
|
|
12642
|
+
const name = typeof event.error.name === "string" ? event.error.name : "Error";
|
|
12643
|
+
const ref = typeof event.error.data?.ref === "string" ? ` (ref ${event.error.data.ref})` : "";
|
|
12644
|
+
return typeof message === "string" && message.length > 0 ? `${name}: ${message}${ref}` : name;
|
|
12645
|
+
} catch {
|
|
12646
|
+
}
|
|
12647
|
+
}
|
|
12648
|
+
return void 0;
|
|
12649
|
+
}
|
|
12650
|
+
function runAuthoringAttempt(bin, args, configPath, bundleDir, label, stage, timeoutMs) {
|
|
12549
12651
|
return new Promise((resolve7) => {
|
|
12550
12652
|
const child = spawn(bin, args, {
|
|
12551
12653
|
cwd: bundleDir,
|
|
@@ -12554,9 +12656,10 @@ async function runLocalAuthoring(stage, bundleDir, issues) {
|
|
|
12554
12656
|
OPENCODE_CONFIG: configPath,
|
|
12555
12657
|
OPENCODE_DISABLE_CLAUDE_CODE: "1"
|
|
12556
12658
|
},
|
|
12557
|
-
stdio: ["ignore", "
|
|
12659
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
12558
12660
|
});
|
|
12559
12661
|
let stderr = "";
|
|
12662
|
+
let stdout = "";
|
|
12560
12663
|
let settled = false;
|
|
12561
12664
|
const finish = (result) => {
|
|
12562
12665
|
if (settled) return;
|
|
@@ -12567,23 +12670,89 @@ async function runLocalAuthoring(stage, bundleDir, issues) {
|
|
|
12567
12670
|
const timer = setTimeout(() => {
|
|
12568
12671
|
child.kill("SIGTERM");
|
|
12569
12672
|
setTimeout(() => child.kill("SIGKILL"), 5e3).unref();
|
|
12570
|
-
finish({ ok: false, error: `Authoring ${stage} melewati batas waktu.` });
|
|
12571
|
-
},
|
|
12673
|
+
finish({ ok: false, error: `Authoring ${stage} via ${label} melewati batas waktu.` });
|
|
12674
|
+
}, timeoutMs);
|
|
12572
12675
|
timer.unref();
|
|
12573
12676
|
child.stderr.on("data", (chunk) => {
|
|
12574
12677
|
stderr = `${stderr}${chunk.toString()}`.slice(-4e3);
|
|
12575
12678
|
});
|
|
12679
|
+
child.stdout?.on("data", (chunk) => {
|
|
12680
|
+
stdout = `${stdout}${chunk.toString()}`.slice(-8e3);
|
|
12681
|
+
});
|
|
12576
12682
|
child.on("error", (error) => finish({ ok: false, error: error.message }));
|
|
12577
12683
|
child.on("close", (code) => {
|
|
12578
|
-
|
|
12579
|
-
|
|
12580
|
-
|
|
12581
|
-
|
|
12582
|
-
|
|
12583
|
-
|
|
12684
|
+
if (code === 0) {
|
|
12685
|
+
finish({ ok: true });
|
|
12686
|
+
return;
|
|
12687
|
+
}
|
|
12688
|
+
const detail = extractAuthoringError(stdout) ?? stderr.trim();
|
|
12689
|
+
finish({
|
|
12690
|
+
ok: false,
|
|
12691
|
+
error: `Authoring ${stage} via ${label} gagal (exit ${code ?? "?"}).${detail ? ` ${detail}` : " Tidak ada error dari child process."}`
|
|
12692
|
+
});
|
|
12584
12693
|
});
|
|
12585
12694
|
});
|
|
12586
12695
|
}
|
|
12696
|
+
async function runLocalAuthoring(stage, bundleDir, issues) {
|
|
12697
|
+
const configDir2 = join8(bundleDir, ".jioogen", "align");
|
|
12698
|
+
const configPath = join8(configDir2, "generated.json");
|
|
12699
|
+
await mkdir5(configDir2, { recursive: true });
|
|
12700
|
+
const config = await buildAuthoringOpencodeConfig(bundledAuthoringPackDir());
|
|
12701
|
+
await writeFile5(configPath, `${JSON.stringify(config, null, 2)}
|
|
12702
|
+
`, "utf8");
|
|
12703
|
+
const bin = process.env.OPENCODE_BIN?.trim() || "opencode";
|
|
12704
|
+
const chain = authoringModelChain();
|
|
12705
|
+
const deadline = Date.now() + authoringTimeoutMs();
|
|
12706
|
+
const failures = [];
|
|
12707
|
+
let pending = [...issues];
|
|
12708
|
+
for (const [index, model] of chain.entries()) {
|
|
12709
|
+
const remaining = deadline - Date.now();
|
|
12710
|
+
if (remaining <= 0) {
|
|
12711
|
+
failures.push("batas waktu total habis");
|
|
12712
|
+
break;
|
|
12713
|
+
}
|
|
12714
|
+
if (index > 0) pending = issuesForStage(await inspectBundle(bundleDir), stage);
|
|
12715
|
+
const label = model ?? "default";
|
|
12716
|
+
process.stderr.write(`[align] authoring ${stage} via ${label}
|
|
12717
|
+
`);
|
|
12718
|
+
const before = await snapshotContract(bundleDir);
|
|
12719
|
+
const args = [
|
|
12720
|
+
"run",
|
|
12721
|
+
...model === void 0 ? [] : ["--model", model],
|
|
12722
|
+
"--agent",
|
|
12723
|
+
"build",
|
|
12724
|
+
"--format",
|
|
12725
|
+
"json",
|
|
12726
|
+
"--dir",
|
|
12727
|
+
bundleDir,
|
|
12728
|
+
authoringPrompt(stage, pending)
|
|
12729
|
+
];
|
|
12730
|
+
const result = await runAuthoringAttempt(
|
|
12731
|
+
bin,
|
|
12732
|
+
args,
|
|
12733
|
+
configPath,
|
|
12734
|
+
bundleDir,
|
|
12735
|
+
label,
|
|
12736
|
+
stage,
|
|
12737
|
+
// The per-attempt cap only bounds failover iterations; a single-model
|
|
12738
|
+
// run gets the whole remaining budget (a full rewrite legitimately
|
|
12739
|
+
// takes longer than one hop of a chain).
|
|
12740
|
+
chain.length > 1 ? Math.min(authoringAttemptTimeoutMs(), remaining) : remaining
|
|
12741
|
+
);
|
|
12742
|
+
const after = await snapshotContract(bundleDir);
|
|
12743
|
+
const changed = stage === "specs" ? after.specs !== before.specs : after.tasks !== before.tasks;
|
|
12744
|
+
if (result.ok && (changed || pending.length === 0)) return result;
|
|
12745
|
+
const reason = result.ok ? `tidak menulis ${stage}/` : result.error ?? "gagal";
|
|
12746
|
+
failures.push(`${label}: ${reason}`);
|
|
12747
|
+
process.stderr.write(`[align] ${label} gagal: ${reason}
|
|
12748
|
+
`);
|
|
12749
|
+
}
|
|
12750
|
+
const names = chain.map((model) => model ?? "default").join(", ");
|
|
12751
|
+
return {
|
|
12752
|
+
ok: false,
|
|
12753
|
+
error: chain.length === 1 ? `Authoring ${stage} gagal (${names}): ${failures.join(" | ")}` : `Authoring ${stage} gagal pada semua model (${names}). ${failures.join(" | ")}`
|
|
12754
|
+
};
|
|
12755
|
+
}
|
|
12587
12756
|
async function alignBundle(bundleDir, deps = {}) {
|
|
12588
12757
|
if (deps.client !== void 0 && deps.projectId !== void 0) {
|
|
12589
12758
|
await deps.client.ensureProjectLayout(deps.projectId).catch(() => null);
|
|
@@ -12592,9 +12761,15 @@ async function alignBundle(bundleDir, deps = {}) {
|
|
|
12592
12761
|
let local = await snapshotContract(bundleDir);
|
|
12593
12762
|
let server = await fetchServerState(deps);
|
|
12594
12763
|
let ledger = await loadLedger(bundleDir, local, server);
|
|
12595
|
-
|
|
12764
|
+
const gate = deps.inspectBundle ?? inspectBundle;
|
|
12765
|
+
let check = await gate(bundleDir);
|
|
12596
12766
|
const runAuthoring = deps.runAuthoring ?? runLocalAuthoring;
|
|
12597
|
-
const
|
|
12767
|
+
const attempts = /* @__PURE__ */ new Map();
|
|
12768
|
+
const pushedSignatures = /* @__PURE__ */ new Set();
|
|
12769
|
+
const finish = (result) => {
|
|
12770
|
+
const leftovers = serverLeftovers(local, server);
|
|
12771
|
+
return leftovers.length > 0 ? { ...result, warnings: leftovers } : result;
|
|
12772
|
+
};
|
|
12598
12773
|
for (let step = 0; step < 6; step += 1) {
|
|
12599
12774
|
const plan = planAlignment(local, ledger, server, check);
|
|
12600
12775
|
if (plan.kind === "clean") {
|
|
@@ -12604,37 +12779,46 @@ async function alignBundle(bundleDir, deps = {}) {
|
|
|
12604
12779
|
server,
|
|
12605
12780
|
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
12606
12781
|
});
|
|
12607
|
-
return { ok: true, applied, check, ledger };
|
|
12782
|
+
return finish({ ok: true, applied, check, ledger });
|
|
12608
12783
|
}
|
|
12609
12784
|
if (plan.kind === "gate") {
|
|
12610
|
-
|
|
12785
|
+
const summary = check.issues.slice(0, 5).map((issue2) => `${issue2.code} @ ${issue2.where}`).join("; ");
|
|
12786
|
+
return finish({
|
|
12787
|
+
ok: false,
|
|
12788
|
+
applied,
|
|
12789
|
+
blocked: `Bundle belum lolos gate (isu milik PRD/user, bukan artefak yang bisa diturunkan). ${summary}`,
|
|
12790
|
+
check,
|
|
12791
|
+
ledger
|
|
12792
|
+
});
|
|
12611
12793
|
}
|
|
12612
12794
|
if (plan.kind === "conflict") {
|
|
12613
|
-
return { ok: false, applied, blocked: plan.message, check, ledger };
|
|
12795
|
+
return finish({ ok: false, applied, blocked: plan.message, check, ledger });
|
|
12614
12796
|
}
|
|
12615
12797
|
if (plan.kind === "approve") {
|
|
12616
|
-
return { ok: false, applied, blocked: plan.reason, check, ledger };
|
|
12798
|
+
return finish({ ok: false, applied, blocked: plan.reason, check, ledger });
|
|
12617
12799
|
}
|
|
12618
12800
|
if (plan.kind === "author") {
|
|
12619
|
-
|
|
12620
|
-
|
|
12801
|
+
const used = attempts.get(plan.stage) ?? 0;
|
|
12802
|
+
if (used >= 2) {
|
|
12803
|
+
const summary = issuesForStage(check, plan.stage).slice(0, 5).join("; ");
|
|
12804
|
+
return finish({
|
|
12621
12805
|
ok: false,
|
|
12622
12806
|
applied,
|
|
12623
|
-
blocked: `Gate masih gagal setelah authoring ${
|
|
12807
|
+
blocked: `Gate ${plan.stage} masih gagal setelah 2x authoring. ${summary}`,
|
|
12624
12808
|
check,
|
|
12625
12809
|
ledger
|
|
12626
|
-
};
|
|
12810
|
+
});
|
|
12627
12811
|
}
|
|
12628
|
-
|
|
12812
|
+
attempts.set(plan.stage, used + 1);
|
|
12629
12813
|
const result = await runAuthoring(plan.stage, bundleDir, issuesForStage(check, plan.stage));
|
|
12630
12814
|
if (!result.ok) {
|
|
12631
|
-
return {
|
|
12815
|
+
return finish({
|
|
12632
12816
|
ok: false,
|
|
12633
12817
|
applied,
|
|
12634
12818
|
blocked: result.error ?? `Authoring ${plan.stage} gagal.`,
|
|
12635
12819
|
check,
|
|
12636
12820
|
ledger
|
|
12637
|
-
};
|
|
12821
|
+
});
|
|
12638
12822
|
}
|
|
12639
12823
|
applied.push(`author:${plan.stage}`);
|
|
12640
12824
|
local = await snapshotContract(bundleDir);
|
|
@@ -12655,54 +12839,112 @@ async function alignBundle(bundleDir, deps = {}) {
|
|
|
12655
12839
|
}
|
|
12656
12840
|
};
|
|
12657
12841
|
await writeContractLedger(bundleDir, ledger);
|
|
12658
|
-
check = await
|
|
12842
|
+
check = await gate(bundleDir);
|
|
12659
12843
|
continue;
|
|
12660
12844
|
}
|
|
12661
12845
|
if (plan.kind === "pull") {
|
|
12662
12846
|
const error = await pullContract(deps, bundleDir);
|
|
12663
12847
|
if (error !== null) {
|
|
12664
|
-
return { ok: false, applied, blocked: error, check, ledger };
|
|
12848
|
+
return finish({ ok: false, applied, blocked: error, check, ledger });
|
|
12665
12849
|
}
|
|
12666
12850
|
applied.push("pull");
|
|
12667
12851
|
local = await snapshotContract(bundleDir);
|
|
12668
12852
|
server = await fetchServerState(deps);
|
|
12669
|
-
ledger =
|
|
12853
|
+
ledger = { ...ledger, local, server, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
12670
12854
|
await writeContractLedger(bundleDir, ledger);
|
|
12671
|
-
check = await
|
|
12855
|
+
check = await gate(bundleDir);
|
|
12672
12856
|
continue;
|
|
12673
12857
|
}
|
|
12674
12858
|
if (plan.kind === "push") {
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12859
|
+
if (plan.stages.prd && server !== null && server.prd !== local.prd && local.prd !== null) {
|
|
12860
|
+
await approveLocalRevision(bundleDir, local.prd);
|
|
12861
|
+
}
|
|
12862
|
+
const signature = `${plan.stages.prd}|${plan.stages.specs}|${plan.stages.tasks}|${plan.stages.docs}`;
|
|
12863
|
+
if (pushedSignatures.has(signature)) {
|
|
12864
|
+
return finish({
|
|
12678
12865
|
ok: false,
|
|
12679
12866
|
applied,
|
|
12680
|
-
blocked: "
|
|
12867
|
+
blocked: "Web belum konvergen setelah push yang sama; server mungkin belum mendukung pembersihan stage.",
|
|
12681
12868
|
check,
|
|
12682
12869
|
ledger
|
|
12683
|
-
};
|
|
12870
|
+
});
|
|
12684
12871
|
}
|
|
12872
|
+
pushedSignatures.add(signature);
|
|
12685
12873
|
const result = await pushContract(deps, bundleDir, local, plan.stages, server);
|
|
12686
12874
|
if (!result.ok) {
|
|
12687
|
-
return {
|
|
12875
|
+
return finish({
|
|
12688
12876
|
ok: false,
|
|
12689
12877
|
applied,
|
|
12690
|
-
blocked: result.
|
|
12878
|
+
blocked: result.error ?? "Sinkronisasi web gagal.",
|
|
12691
12879
|
check,
|
|
12692
12880
|
ledger
|
|
12693
|
-
};
|
|
12881
|
+
});
|
|
12694
12882
|
}
|
|
12695
12883
|
applied.push("push");
|
|
12696
12884
|
server = await fetchServerState(deps);
|
|
12697
12885
|
ledger = { ...ledger, local, server, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
12698
12886
|
}
|
|
12699
12887
|
}
|
|
12700
|
-
return {
|
|
12888
|
+
return finish({
|
|
12701
12889
|
ok: false,
|
|
12702
12890
|
applied,
|
|
12703
12891
|
blocked: "Penyelarasan tidak selesai dalam batas langkah.",
|
|
12704
12892
|
check,
|
|
12705
12893
|
ledger
|
|
12894
|
+
});
|
|
12895
|
+
}
|
|
12896
|
+
async function reportBundle(bundleDir, deps = {}) {
|
|
12897
|
+
const local = await snapshotContract(bundleDir);
|
|
12898
|
+
const gate = await (deps.inspectBundle ?? inspectBundle)(bundleDir);
|
|
12899
|
+
const missing = [
|
|
12900
|
+
...local.prd === null ? ["PRD.md"] : [],
|
|
12901
|
+
...local.specs === null ? ["specs/"] : [],
|
|
12902
|
+
...local.tasks === null ? ["tasks/"] : []
|
|
12903
|
+
];
|
|
12904
|
+
if (missing.length > 0) {
|
|
12905
|
+
return {
|
|
12906
|
+
ok: false,
|
|
12907
|
+
gate,
|
|
12908
|
+
error: `Bundle tidak lengkap: ${missing.join(", ")}. Tidak ada revisi yang dibuat.`
|
|
12909
|
+
};
|
|
12910
|
+
}
|
|
12911
|
+
const ledger = {
|
|
12912
|
+
...buildContractLedger(local, null, freshDerivation(local)),
|
|
12913
|
+
server: await fetchServerState(deps)
|
|
12914
|
+
};
|
|
12915
|
+
await writeContractLedger(bundleDir, ledger);
|
|
12916
|
+
const server = ledger.server;
|
|
12917
|
+
if (server !== null) {
|
|
12918
|
+
const drift = mergeChanges(
|
|
12919
|
+
changedSince(local, serverViewForLocal(local, server)),
|
|
12920
|
+
serverOnlyStages(local, server)
|
|
12921
|
+
);
|
|
12922
|
+
if (!drift.any && deps.force !== true) {
|
|
12923
|
+
if (deps.client !== void 0 && deps.projectId !== void 0) {
|
|
12924
|
+
await deps.client.postJson(projectPath(deps.projectId, "/prd-confirmation"), { action: "confirm" }).catch(() => null);
|
|
12925
|
+
}
|
|
12926
|
+
return {
|
|
12927
|
+
ok: true,
|
|
12928
|
+
revision: server.revision ?? null,
|
|
12929
|
+
commit: server.commit ?? null,
|
|
12930
|
+
gate
|
|
12931
|
+
};
|
|
12932
|
+
}
|
|
12933
|
+
}
|
|
12934
|
+
const stages = {
|
|
12935
|
+
prd: true,
|
|
12936
|
+
specs: true,
|
|
12937
|
+
tasks: true,
|
|
12938
|
+
docs: true,
|
|
12939
|
+
any: true
|
|
12940
|
+
};
|
|
12941
|
+
const result = await pushContract(deps, bundleDir, local, stages, ledger.server);
|
|
12942
|
+
if (!result.ok) return { ok: false, gate, error: result.error ?? "Gagal menerbitkan revisi." };
|
|
12943
|
+
return {
|
|
12944
|
+
ok: true,
|
|
12945
|
+
revision: result.revision ?? null,
|
|
12946
|
+
commit: result.commit ?? null,
|
|
12947
|
+
gate
|
|
12706
12948
|
};
|
|
12707
12949
|
}
|
|
12708
12950
|
function formatAlign(result) {
|
|
@@ -12713,6 +12955,7 @@ function formatAlign(result) {
|
|
|
12713
12955
|
lines.push(`\u2716 Kontrak belum selaras: ${result.blocked ?? "tidak diketahui"}`);
|
|
12714
12956
|
}
|
|
12715
12957
|
if (result.applied.length > 0) lines.push(` Tindakan: ${result.applied.join(", ")}`);
|
|
12958
|
+
for (const warning of result.warnings ?? []) lines.push(` \u26A0 ${warning}`);
|
|
12716
12959
|
if (result.check.issueCount > 0) {
|
|
12717
12960
|
lines.push(` Gate: ${result.check.issueCount} isu.`);
|
|
12718
12961
|
for (const issue2 of result.check.issues.slice(0, 8)) {
|
|
@@ -13028,6 +13271,11 @@ var JIOOGEN_AGENTS_MD = `${MARKER}
|
|
|
13028
13271
|
karangan; preferensi user tidak boleh melemahkan keamanan/a11y inti.
|
|
13029
13272
|
- \`.jioogen/custom/**\` hanya menambah atau mengetatkan; jangan menimpa atau
|
|
13030
13273
|
menghapus isinya.
|
|
13274
|
+
- **Multi-surface:** bila profil produk punya \u22652 komponen UI (mis. web + Android/
|
|
13275
|
+
iOS native), kerjakan **FE design terpisah per komponen**: ikuti \`Profil produk\`
|
|
13276
|
+
+ \`specs/design.md\` komponen itu, jangan pakai desain web untuk app native, dan
|
|
13277
|
+
verifikasi di target masing-masing (browser / emulator / build desktop). Produk
|
|
13278
|
+
responsif satu permukaan = satu desain lintas layar.
|
|
13031
13279
|
- **Mode task** tercatat di \`.jioogen/project.json\` (\`taskMode\`, di-set saat
|
|
13032
13280
|
\`pull\`/\`link --mode\`): \`authoring\` (default) memakai task dari JiooGen, \`seed\`
|
|
13033
13281
|
mengizinkanmu menambah task, \`executor\` hanya menjalankan task yang sudah ada \u2014
|
|
@@ -13043,16 +13291,18 @@ var JIOOGEN_AGENTS_MD = `${MARKER}
|
|
|
13043
13291
|
## 0d. Otonomi penyelarasan kontrak (wajib)
|
|
13044
13292
|
|
|
13045
13293
|
- **Jangan menyuruh user mengetik perintah \`jioogen\`.** Kamu yang menjalankan
|
|
13046
|
-
\`jioogen
|
|
13294
|
+
\`jioogen align\` (atau \`jioogen report\`), \`jioogen check\`, dan \`jioogen docs\`.
|
|
13047
13295
|
- Kontrak ada di \`docs/00-contract/\` (\`PRD.md\`, \`specs/\`, \`tasks/\`); dokumen lain
|
|
13048
13296
|
ada di \`docs/01-product\`, \`02-design\`, \`03-architecture\`, \`04-domain\`,
|
|
13049
13297
|
\`05-operations\`, \`06-quality\`. Baca \`docs/README.md\` lebih dulu.
|
|
13050
|
-
- Bila user bilang PRD berubah
|
|
13051
|
-
|
|
13052
|
-
dan
|
|
13053
|
-
|
|
13298
|
+
- Bila user bilang PRD/specs/tasks berubah: jalankan sendiri \`jioogen align\`
|
|
13299
|
+
untuk menerbitkan revisi kontrak lokal ke web. \`align\` TIDAK menulis ulang
|
|
13300
|
+
specs/tasks dan tidak memanggil model; PRD otomatis dikonfirmasi saat publish.
|
|
13301
|
+
Hanya jika user eksplisit minta turunkan ulang specs/tasks, jalankan dengan
|
|
13302
|
+
\`JIOOGEN_ALIGN_AUTHOR=1\`.
|
|
13054
13303
|
- Bila output CLI menyebut \`ALIGN_NEXT\` atau "kontrak belum selaras": jalankan
|
|
13055
|
-
|
|
13304
|
+
\`jioogen align\`. \`ALIGN_NEXT: approve\` tidak lagi wajib \u2014 publish
|
|
13305
|
+
mengonfirmasi PRD otomatis.
|
|
13056
13306
|
- **Batch vs Manual:** tanyakan "Batch (sekaligus) atau Manual (satu per satu)?
|
|
13057
13307
|
(batch/manual)". Pilihan disimpan; ganti hanya bila user memintanya eksplisit.
|
|
13058
13308
|
- Dokumen = niat, kode = kenyataan. Bila berbeda, jangan menebak; tanyakan
|
|
@@ -13097,13 +13347,12 @@ tangan) sebelum task dijalankan, jangan pura-pura mengerjakannya:
|
|
|
13097
13347
|
- Verifikasi hasilnya lalu \`npx jioogen task adopt <ref> --note "<alat>"\` (task UI:
|
|
13098
13348
|
tambahkan \`--visual "<catatan>"\`). Command itu menjalankan \`verificationCommand\`
|
|
13099
13349
|
dan mencatat \`source: user\` + bukti adopsi di sidecar.
|
|
13100
|
-
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
Jangan menyuruh user balik ke web dan jangan edit \`specs/\`/\`tasks/\` manual.
|
|
13350
|
+
- Revisi kontrak lokal: bila user menyetujui patch, ubah \`PRD.md\` (dan
|
|
13351
|
+
specs/tasks bila perlu), lalu jalankan \`npx jioogen align\`: kontrak lokal
|
|
13352
|
+
dikirim sebagai revisi baru ke web, PRD otomatis dikonfirmasi, tanpa authoring.
|
|
13353
|
+
\`align\` tidak menulis ulang specs/tasks. \`npx jioogen task next\` melakukan
|
|
13354
|
+
publish yang sama sebelum memilih task. Hanya jika user minta turunkan ulang
|
|
13355
|
+
specs/tasks, jalankan dengan \`JIOOGEN_ALIGN_AUTHOR=1\`.
|
|
13107
13356
|
- Sebelum mode authoring lokal, agent WAJIB bertanya dengan bahasa manusia:
|
|
13108
13357
|
"Saya mau mengubah PRD, lalu specs, lalu tasks di lokal. Boleh? (ya/tidak)".
|
|
13109
13358
|
Lanjut HANYA bila user menjawab "ya". Tanpa "ya", jangan ubah apa pun.
|
|
@@ -13217,6 +13466,11 @@ atas ide, refactor, perbaikan, atau fitur lain.
|
|
|
13217
13466
|
user tidak boleh melemahkan keamanan/a11y inti.
|
|
13218
13467
|
- \`.jioogen/custom/**\` hanya menambah atau mengetatkan; jangan menimpa atau
|
|
13219
13468
|
menghapus isinya.
|
|
13469
|
+
- **Multi-surface:** bila profil produk punya \u22652 komponen UI (mis. web + Android/
|
|
13470
|
+
iOS native), kerjakan **FE design terpisah per komponen**: ikuti \`Profil produk\`
|
|
13471
|
+
+ \`specs/design.md\` komponen itu, jangan pakai desain web untuk app native, dan
|
|
13472
|
+
verifikasi di target masing-masing (browser / emulator / build desktop). Produk
|
|
13473
|
+
responsif satu permukaan = satu desain lintas layar.
|
|
13220
13474
|
- **Mode task** tercatat di \`.jioogen/project.json\` (\`taskMode\`, di-set saat
|
|
13221
13475
|
\`pull\`/\`link --mode\`): \`authoring\` (default) memakai task dari JiooGen, \`seed\`
|
|
13222
13476
|
mengizinkanmu menambah task, \`executor\` hanya menjalankan task yang sudah ada \u2014
|
|
@@ -13227,16 +13481,18 @@ atas ide, refactor, perbaikan, atau fitur lain.
|
|
|
13227
13481
|
## 0d. Otonomi penyelarasan kontrak (wajib)
|
|
13228
13482
|
|
|
13229
13483
|
- **Jangan menyuruh user mengetik perintah \`jioogen\`.** Kamu yang menjalankan
|
|
13230
|
-
\`jioogen
|
|
13484
|
+
\`jioogen align\` (atau \`jioogen report\`), \`jioogen check\`, dan \`jioogen docs\`.
|
|
13231
13485
|
- Kontrak ada di \`docs/00-contract/\` (\`PRD.md\`, \`specs/\`, \`tasks/\`); dokumen lain
|
|
13232
13486
|
ada di \`docs/01-product\`, \`02-design\`, \`03-architecture\`, \`04-domain\`,
|
|
13233
13487
|
\`05-operations\`, \`06-quality\`. Baca \`docs/README.md\` lebih dulu.
|
|
13234
|
-
- Bila user bilang PRD berubah
|
|
13235
|
-
|
|
13236
|
-
dan
|
|
13237
|
-
|
|
13488
|
+
- Bila user bilang PRD/specs/tasks berubah: jalankan sendiri \`jioogen align\`
|
|
13489
|
+
untuk menerbitkan revisi kontrak lokal ke web. \`align\` TIDAK menulis ulang
|
|
13490
|
+
specs/tasks dan tidak memanggil model; PRD otomatis dikonfirmasi saat publish.
|
|
13491
|
+
Hanya jika user eksplisit minta turunkan ulang specs/tasks, jalankan dengan
|
|
13492
|
+
\`JIOOGEN_ALIGN_AUTHOR=1\`.
|
|
13238
13493
|
- Bila output CLI menyebut \`ALIGN_NEXT\` atau "kontrak belum selaras": jalankan
|
|
13239
|
-
|
|
13494
|
+
\`jioogen align\`. \`ALIGN_NEXT: approve\` tidak lagi wajib \u2014 publish
|
|
13495
|
+
mengonfirmasi PRD otomatis.
|
|
13240
13496
|
- **Batch vs Manual:** tanyakan "Batch (sekaligus) atau Manual (satu per satu)?
|
|
13241
13497
|
(batch/manual)". Pilihan disimpan; ganti hanya bila user memintanya eksplisit.
|
|
13242
13498
|
- Dokumen = niat, kode = kenyataan. Bila berbeda, jangan menebak; tanyakan
|
|
@@ -13274,13 +13530,12 @@ atau ditulis tangan \u2014 sebelum task dijalankan, jangan pura-pura mengerjakan
|
|
|
13274
13530
|
- Verifikasi hasilnya lalu \`npx jioogen task adopt <ref> --note "<alat>"\` (task UI:
|
|
13275
13531
|
tambahkan \`--visual "<catatan>"\`). Command itu menjalankan \`verificationCommand\`
|
|
13276
13532
|
dan mencatat \`source: user\` + bukti adopsi di sidecar.
|
|
13277
|
-
-
|
|
13278
|
-
|
|
13279
|
-
|
|
13280
|
-
|
|
13281
|
-
|
|
13282
|
-
|
|
13283
|
-
Jangan menyuruh user balik ke web dan jangan edit \`specs/\`/\`tasks/\` manual.
|
|
13533
|
+
- Revisi kontrak lokal: bila user menyetujui patch, ubah \`PRD.md\` (dan
|
|
13534
|
+
specs/tasks bila perlu), lalu jalankan \`npx jioogen align\`: kontrak lokal
|
|
13535
|
+
dikirim sebagai revisi baru ke web, PRD otomatis dikonfirmasi, tanpa authoring.
|
|
13536
|
+
\`align\` tidak menulis ulang specs/tasks. \`npx jioogen task next\` melakukan
|
|
13537
|
+
publish yang sama sebelum memilih task. Hanya jika user minta turunkan ulang
|
|
13538
|
+
specs/tasks, jalankan dengan \`JIOOGEN_ALIGN_AUTHOR=1\`.
|
|
13284
13539
|
- Sebelum mode authoring lokal, agent WAJIB bertanya dengan bahasa manusia:
|
|
13285
13540
|
"Saya mau mengubah PRD, lalu specs, lalu tasks di lokal. Boleh? (ya/tidak)".
|
|
13286
13541
|
Lanjut HANYA bila user menjawab "ya". Tanpa "ya", jangan ubah apa pun.
|
|
@@ -15476,6 +15731,10 @@ async function alignCommand(options) {
|
|
|
15476
15731
|
client = void 0;
|
|
15477
15732
|
}
|
|
15478
15733
|
}
|
|
15734
|
+
if (process.env.JIOOGEN_ALIGN_AUTHOR !== "1") {
|
|
15735
|
+
await reportCommand(options);
|
|
15736
|
+
return;
|
|
15737
|
+
}
|
|
15479
15738
|
const autoDisabled = process.env.JIOOGEN_AUTO_ALIGN === "0";
|
|
15480
15739
|
const result = await alignBundle(local.bundleDir, {
|
|
15481
15740
|
...client === void 0 ? {} : { client },
|
|
@@ -15494,6 +15753,61 @@ async function alignCommand(options) {
|
|
|
15494
15753
|
}
|
|
15495
15754
|
if (!result.ok) process.exitCode = 1;
|
|
15496
15755
|
}
|
|
15756
|
+
async function reportCommand(options) {
|
|
15757
|
+
const local = await resolveLocalBundle(options);
|
|
15758
|
+
let client;
|
|
15759
|
+
const noSync = options.noSync === true || process.env.JIOOGEN_NO_SYNC === "1";
|
|
15760
|
+
if (!noSync) {
|
|
15761
|
+
try {
|
|
15762
|
+
const api = await resolveApi({ api: options.api ?? local.linkedApiUrl });
|
|
15763
|
+
client = api.client;
|
|
15764
|
+
} catch {
|
|
15765
|
+
client = void 0;
|
|
15766
|
+
}
|
|
15767
|
+
}
|
|
15768
|
+
const result = await reportBundle(local.bundleDir, {
|
|
15769
|
+
...client === void 0 ? {} : { client },
|
|
15770
|
+
projectId: local.projectId,
|
|
15771
|
+
...options.force === true ? { force: true } : {}
|
|
15772
|
+
});
|
|
15773
|
+
if (options.json === true) {
|
|
15774
|
+
console.log(
|
|
15775
|
+
JSON.stringify(
|
|
15776
|
+
{
|
|
15777
|
+
ok: result.ok,
|
|
15778
|
+
revision: result.revision ?? null,
|
|
15779
|
+
commit: result.commit ?? null,
|
|
15780
|
+
gate: {
|
|
15781
|
+
ok: result.gate.ok,
|
|
15782
|
+
issueCount: result.gate.issueCount,
|
|
15783
|
+
issues: result.gate.issues.slice(0, 12).map((issue2) => ({
|
|
15784
|
+
code: issue2.code,
|
|
15785
|
+
where: issue2.where,
|
|
15786
|
+
message: issue2.message
|
|
15787
|
+
}))
|
|
15788
|
+
},
|
|
15789
|
+
...result.error === void 0 ? {} : { error: result.error }
|
|
15790
|
+
},
|
|
15791
|
+
null,
|
|
15792
|
+
2
|
|
15793
|
+
)
|
|
15794
|
+
);
|
|
15795
|
+
} else {
|
|
15796
|
+
console.log(
|
|
15797
|
+
result.ok ? "\u2714 Revisi diterbitkan." : `\u2716 ${result.error ?? "Gagal menerbitkan revisi."}`
|
|
15798
|
+
);
|
|
15799
|
+
if (result.revision !== void 0 && result.revision !== null) {
|
|
15800
|
+
console.log(` Revisi: ${result.revision} (${result.commit ?? "-"})`);
|
|
15801
|
+
}
|
|
15802
|
+
if (result.gate.issueCount > 0) {
|
|
15803
|
+
console.log(` Gate: ${result.gate.issueCount} isu (laporan, tidak memblokir).`);
|
|
15804
|
+
for (const issue2 of result.gate.issues.slice(0, 8)) {
|
|
15805
|
+
console.log(` - ${issue2.code} ${issue2.where}: ${issue2.message}`);
|
|
15806
|
+
}
|
|
15807
|
+
}
|
|
15808
|
+
}
|
|
15809
|
+
if (!result.ok) process.exitCode = 1;
|
|
15810
|
+
}
|
|
15497
15811
|
async function docsCommand(options, subcommand) {
|
|
15498
15812
|
const link = await findProjectLink(options.dir ?? process.cwd());
|
|
15499
15813
|
const bundleDir = resolve6(link?.bundleDir ?? options.dir ?? process.cwd());
|
|
@@ -15726,11 +16040,7 @@ async function alignBeforeTask(options) {
|
|
|
15726
16040
|
await installAgentSkills(local.bundleDir, { noSkills: true }).catch(() => null);
|
|
15727
16041
|
const contract = await snapshotContract(local.bundleDir);
|
|
15728
16042
|
if (!hasContractArtifacts(contract)) return true;
|
|
15729
|
-
|
|
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...");
|
|
16043
|
+
if (options.json !== true) console.log("Menyelaraskan revisi kontrak ke web...");
|
|
15734
16044
|
let client;
|
|
15735
16045
|
const noSync = options.noSync === true || process.env.JIOOGEN_NO_SYNC === "1";
|
|
15736
16046
|
if (!noSync) {
|
|
@@ -15741,25 +16051,36 @@ async function alignBeforeTask(options) {
|
|
|
15741
16051
|
client = void 0;
|
|
15742
16052
|
}
|
|
15743
16053
|
}
|
|
15744
|
-
const result = await
|
|
16054
|
+
const result = await reportBundle(local.bundleDir, {
|
|
15745
16055
|
...client === void 0 ? {} : { client },
|
|
15746
16056
|
projectId: local.projectId
|
|
15747
16057
|
});
|
|
15748
16058
|
if (options.json === true) {
|
|
15749
16059
|
console.log(
|
|
15750
16060
|
JSON.stringify(
|
|
15751
|
-
{
|
|
16061
|
+
{
|
|
16062
|
+
aligned: result.ok,
|
|
16063
|
+
revision: result.revision ?? null,
|
|
16064
|
+
gate: result.gate.issueCount,
|
|
16065
|
+
error: result.error ?? null
|
|
16066
|
+
},
|
|
15752
16067
|
null,
|
|
15753
16068
|
2
|
|
15754
16069
|
)
|
|
15755
16070
|
);
|
|
16071
|
+
} else if (result.ok) {
|
|
16072
|
+
console.log(
|
|
16073
|
+
`Revisi kontrak aktif${result.revision === void 0 || result.revision === null ? "" : `: ${result.revision}`}.`
|
|
16074
|
+
);
|
|
15756
16075
|
} else {
|
|
15757
|
-
console.log(
|
|
15758
|
-
if (!result.ok) console.log("Task tidak dipilih sampai kontrak selaras.");
|
|
16076
|
+
console.log(`Peringatan: revisi belum terkirim ke web (${result.error ?? "tidak diketahui"}).`);
|
|
15759
16077
|
}
|
|
15760
|
-
if (result.ok)
|
|
15761
|
-
|
|
15762
|
-
|
|
16078
|
+
if (!result.gate.ok) {
|
|
16079
|
+
console.log("Task tidak dipilih sampai kontrak selaras.");
|
|
16080
|
+
process.exitCode = 1;
|
|
16081
|
+
return false;
|
|
16082
|
+
}
|
|
16083
|
+
return true;
|
|
15763
16084
|
}
|
|
15764
16085
|
async function taskNextCommand(options) {
|
|
15765
16086
|
if (!await alignBeforeTask(options)) return;
|
|
@@ -15951,6 +16272,9 @@ async function taskStartCommand(ref, options) {
|
|
|
15951
16272
|
awaitingCheckpoint: false,
|
|
15952
16273
|
note: ""
|
|
15953
16274
|
});
|
|
16275
|
+
const ledger = await readContractLedger(local.bundleDir);
|
|
16276
|
+
const pinned = ledger?.server?.revision;
|
|
16277
|
+
if (pinned !== void 0 && pinned !== null) updated.revision = pinned;
|
|
15954
16278
|
await writeState(local.bundleDir, updated);
|
|
15955
16279
|
const definition = local.definitions.find((entry) => entry.id.toUpperCase() === key);
|
|
15956
16280
|
if (definition !== void 0) {
|
|
@@ -16063,7 +16387,7 @@ async function taskCompleteCommand(ref, options) {
|
|
|
16063
16387
|
console.log(`Done ${completedTask?.ref ?? ref}.`);
|
|
16064
16388
|
if (checkpoint) {
|
|
16065
16389
|
if (next === null) {
|
|
16066
|
-
console.log(
|
|
16390
|
+
console.log(printCompletionHeadline(completion));
|
|
16067
16391
|
printSeedGapTrigger(completion, next);
|
|
16068
16392
|
} else {
|
|
16069
16393
|
console.log(
|
|
@@ -16300,7 +16624,7 @@ async function taskAdoptCommand(ref, options) {
|
|
|
16300
16624
|
);
|
|
16301
16625
|
if (result.checkpoint) {
|
|
16302
16626
|
console.log(
|
|
16303
|
-
result.next === null ?
|
|
16627
|
+
result.next === null ? printCompletionHeadline(result.completion) : `Checkpoint berikutnya: ${result.next.task.id} (${result.next.task.layer ?? "-"} / phase ${result.next.task.phase}).`
|
|
16304
16628
|
);
|
|
16305
16629
|
printSeedGapTrigger(result.completion, result.next);
|
|
16306
16630
|
console.log(
|
|
@@ -16795,7 +17119,7 @@ async function resolveLocalBundle(options) {
|
|
|
16795
17119
|
const projectId = options.project ?? envFirst2("JIOOGEN_PROJECT", "JIOOCODE_PROJECT") ?? link?.projectId;
|
|
16796
17120
|
if (projectId === void 0 || projectId.length === 0) {
|
|
16797
17121
|
throw new Error(
|
|
16798
|
-
"Project belum di-bind. Jalankan `jioogen
|
|
17122
|
+
"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
17123
|
);
|
|
16800
17124
|
}
|
|
16801
17125
|
return {
|
|
@@ -17026,10 +17350,30 @@ function printCompletionGaps(completion) {
|
|
|
17026
17350
|
const entries = Object.entries(completion.features).filter(([, unit]) => unit.status !== "complete").sort(([left], [right]) => left.localeCompare(right));
|
|
17027
17351
|
if (entries.length === 0) lines.push("- (tidak ada unit feature yang dideklarasikan)");
|
|
17028
17352
|
for (const [id, unit] of entries) {
|
|
17029
|
-
lines.push(`- ${id}: ${unit.status} (${unit.doneTasks}/${unit.totalTasks} task
|
|
17353
|
+
lines.push(`- ${id}: ${unit.status} (${unit.doneTasks}/${unit.totalTasks} task terverifikasi)`);
|
|
17354
|
+
}
|
|
17355
|
+
if (completion.adoptedTaskRefs.length > 0) {
|
|
17356
|
+
const shown = completion.adoptedTaskRefs.slice(0, 8).join(", ");
|
|
17357
|
+
const extra = completion.adoptedTaskRefs.length > 8 ? ` +${completion.adoptedTaskRefs.length - 8} lagi` : "";
|
|
17358
|
+
lines.push(
|
|
17359
|
+
`- Diadopsi di luar harness (bookkeeping, tidak dihitung complete): ${shown}${extra}`
|
|
17360
|
+
);
|
|
17030
17361
|
}
|
|
17031
17362
|
return lines.join("\n");
|
|
17032
17363
|
}
|
|
17364
|
+
function printCompletionHeadline(completion) {
|
|
17365
|
+
if (completion.projectComplete) {
|
|
17366
|
+
return "Project complete: seluruh unit fitur & layer integration terverifikasi.";
|
|
17367
|
+
}
|
|
17368
|
+
const unverified = completion.tasksDone - completion.tasksVerified;
|
|
17369
|
+
const parts = [];
|
|
17370
|
+
if (completion.adoptedTaskRefs.length > 0) {
|
|
17371
|
+
parts.push(`${completion.adoptedTaskRefs.length} task diadopsi di luar harness`);
|
|
17372
|
+
}
|
|
17373
|
+
if (unverified > 0) parts.push(`${unverified} done belum terverifikasi`);
|
|
17374
|
+
const detail = parts.length > 0 ? ` \u2014 ${parts.join(", ")}` : "";
|
|
17375
|
+
return `Semua task dieksekusi, tetapi project BELUM complete${detail}.`;
|
|
17376
|
+
}
|
|
17033
17377
|
function printSeedReBreakdown() {
|
|
17034
17378
|
console.log("");
|
|
17035
17379
|
console.log("Gap di atas tidak ditutup oleh DAG task yang ada \u2014 ini bukan 'selesai',");
|
|
@@ -17203,7 +17547,7 @@ async function readLine() {
|
|
|
17203
17547
|
}
|
|
17204
17548
|
|
|
17205
17549
|
// src/index.ts
|
|
17206
|
-
var VERSION = "0.2.
|
|
17550
|
+
var VERSION = "0.2.18";
|
|
17207
17551
|
function parseTaskModeOption(value) {
|
|
17208
17552
|
if (value === void 0) return void 0;
|
|
17209
17553
|
const parsed = TaskModeSchema.safeParse(value);
|
|
@@ -17242,6 +17586,7 @@ Usage:
|
|
|
17242
17586
|
jioogen authoring status [--dir <dir>] [--json]
|
|
17243
17587
|
jioogen authoring remove [--dir <dir>]
|
|
17244
17588
|
jioogen align [--dir <dir>] [--json]
|
|
17589
|
+
jioogen report [--dir <dir>] [--json] [--force]
|
|
17245
17590
|
jioogen approve [--dir <dir>] [--note <text>] [--json]
|
|
17246
17591
|
jioogen docs (scan|migrate|index|check) [--dir <dir>] [--dry-run] [--json]
|
|
17247
17592
|
jioogen check [--dir <dir>] [--json]
|
|
@@ -17455,6 +17800,9 @@ async function dispatch(command, rest, options) {
|
|
|
17455
17800
|
case "align":
|
|
17456
17801
|
await alignCommand(options);
|
|
17457
17802
|
return;
|
|
17803
|
+
case "report":
|
|
17804
|
+
await reportCommand(options);
|
|
17805
|
+
return;
|
|
17458
17806
|
case "docs":
|
|
17459
17807
|
await docsCommand(options, rest[0] ?? "scan");
|
|
17460
17808
|
return;
|