jioogen 0.2.11 → 0.2.12
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 +7 -5
- 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/knowledge/catalog.generated.json +165 -7
- package/authoring-pack/knowledge/library/qa/gate-reference.md +10 -2
- package/authoring-pack/knowledge/library/ui/K-UIX-003-adaptive-ui-authoring.md +13 -1
- package/authoring-pack/manifest.json +15 -15
- package/authoring-pack/skills/business-discovery/SKILL.md +7 -9
- package/authoring-pack/skills/creative-discovery/SKILL.md +6 -7
- package/authoring-pack/skills/karpathy-guidelines/SKILL.md +7 -0
- package/authoring-pack/skills/prd-authoring/SKILL.md +4 -3
- package/authoring-pack/skills/specs-authoring/SKILL.md +3 -2
- package/authoring-pack/skills/tasks-authoring/SKILL.md +13 -3
- package/dist/index.js +2381 -985
- package/dist/index.js.map +3 -3
- package/package.json +9 -9
- package/skills-pack/baseline/karpathy-guidelines/SKILL.md +7 -0
- package/skills-pack/ui-quality/impeccable/scripts/impeccable +0 -0
package/dist/index.js
CHANGED
|
@@ -363,9 +363,9 @@ var require_utils = __commonJS({
|
|
|
363
363
|
fpath.split(self.sep).forEach(function(name) {
|
|
364
364
|
if (!name || name.substr(-1, 1) === ":") return;
|
|
365
365
|
resolvedPath += self.sep + name;
|
|
366
|
-
var
|
|
366
|
+
var stat8;
|
|
367
367
|
try {
|
|
368
|
-
|
|
368
|
+
stat8 = self.fs.statSync(resolvedPath);
|
|
369
369
|
} catch (e) {
|
|
370
370
|
if (e.message && e.message.startsWith("ENOENT")) {
|
|
371
371
|
self.fs.mkdirSync(resolvedPath);
|
|
@@ -373,7 +373,7 @@ var require_utils = __commonJS({
|
|
|
373
373
|
throw e;
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
|
-
if (
|
|
376
|
+
if (stat8 && stat8.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
379
|
mkdirSync(folder);
|
|
@@ -382,8 +382,8 @@ var require_utils = __commonJS({
|
|
|
382
382
|
const self = this;
|
|
383
383
|
if (self.fs.existsSync(path)) {
|
|
384
384
|
if (!overwrite) return false;
|
|
385
|
-
var
|
|
386
|
-
if (
|
|
385
|
+
var stat8 = self.fs.statSync(path);
|
|
386
|
+
if (stat8.isDirectory()) {
|
|
387
387
|
return false;
|
|
388
388
|
}
|
|
389
389
|
}
|
|
@@ -416,8 +416,8 @@ var require_utils = __commonJS({
|
|
|
416
416
|
const self = this;
|
|
417
417
|
self.fs.exists(path, function(exist) {
|
|
418
418
|
if (exist && !overwrite) return callback(false);
|
|
419
|
-
self.fs.stat(path, function(err,
|
|
420
|
-
if (exist &&
|
|
419
|
+
self.fs.stat(path, function(err, stat8) {
|
|
420
|
+
if (exist && stat8 && stat8.isDirectory()) {
|
|
421
421
|
return callback(false);
|
|
422
422
|
}
|
|
423
423
|
var folder = pth.dirname(path);
|
|
@@ -469,13 +469,13 @@ var require_utils = __commonJS({
|
|
|
469
469
|
for (const part of rel.split(pth.sep)) {
|
|
470
470
|
if (!part || part === ".") continue;
|
|
471
471
|
cur = pth.join(cur, part);
|
|
472
|
-
let
|
|
472
|
+
let stat8;
|
|
473
473
|
try {
|
|
474
|
-
|
|
474
|
+
stat8 = self.fs.lstatSync(cur);
|
|
475
475
|
} catch (e) {
|
|
476
476
|
break;
|
|
477
477
|
}
|
|
478
|
-
if (
|
|
478
|
+
if (stat8.isSymbolicLink()) throw Errors.FILE_IN_THE_WAY(`"${cur}"`);
|
|
479
479
|
}
|
|
480
480
|
};
|
|
481
481
|
Utils.prototype.findFiles = function(path) {
|
|
@@ -502,11 +502,11 @@ var require_utils = __commonJS({
|
|
|
502
502
|
self.fs.readdirSync(dir).forEach(function(file) {
|
|
503
503
|
const path2 = pth.join(dir, file);
|
|
504
504
|
if (escapesRoot(path2)) return;
|
|
505
|
-
const
|
|
505
|
+
const stat8 = self.fs.statSync(path2);
|
|
506
506
|
if (!pattern || pattern.test(path2)) {
|
|
507
|
-
files.push(pth.normalize(path2) + (
|
|
507
|
+
files.push(pth.normalize(path2) + (stat8.isDirectory() ? self.sep : ""));
|
|
508
508
|
}
|
|
509
|
-
if (
|
|
509
|
+
if (stat8.isDirectory() && recursive) {
|
|
510
510
|
const realDir = self.fs.realpathSync(path2);
|
|
511
511
|
if (!visited.has(realDir)) {
|
|
512
512
|
visited.add(realDir);
|
|
@@ -553,14 +553,14 @@ var require_utils = __commonJS({
|
|
|
553
553
|
if (!--pending) done();
|
|
554
554
|
return;
|
|
555
555
|
}
|
|
556
|
-
self.fs.stat(file, function(err3,
|
|
556
|
+
self.fs.stat(file, function(err3, stat8) {
|
|
557
557
|
if (err3) return done(err3);
|
|
558
|
-
if (!
|
|
558
|
+
if (!stat8) {
|
|
559
559
|
if (!--pending) done();
|
|
560
560
|
return;
|
|
561
561
|
}
|
|
562
|
-
results.push(pth.normalize(file) + (
|
|
563
|
-
if (!
|
|
562
|
+
results.push(pth.normalize(file) + (stat8.isDirectory() ? self.sep : ""));
|
|
563
|
+
if (!stat8.isDirectory()) {
|
|
564
564
|
if (!--pending) done();
|
|
565
565
|
return;
|
|
566
566
|
}
|
|
@@ -9426,6 +9426,193 @@ ${specText}`, id.toLowerCase(), [], LEDGER_ESCAPE);
|
|
|
9426
9426
|
);
|
|
9427
9427
|
}
|
|
9428
9428
|
}
|
|
9429
|
+
const functionalSpec = specs.find((file) => /functional/i.test(file.path));
|
|
9430
|
+
const functionalText = functionalSpec?.content ?? "";
|
|
9431
|
+
const permTableMatch = functionalText.match(
|
|
9432
|
+
/\|[^\n]*Resource[^\n]*\|[^\n]*Action[^\n]*\|[^\n]*Role[^\n]*\|[\s\S]*?(?=\n\n|\n#{1,3}\s|$)/i
|
|
9433
|
+
);
|
|
9434
|
+
const permRows = [];
|
|
9435
|
+
if (permTableMatch) {
|
|
9436
|
+
const lines = permTableMatch[0].split(/\r?\n/).map((l) => l.trim()).filter((l) => l.startsWith("|"));
|
|
9437
|
+
lines.shift();
|
|
9438
|
+
for (const line of lines) {
|
|
9439
|
+
if (/^\|:?-{2,}/.test(line)) continue;
|
|
9440
|
+
const cells = line.replace(/^\|/, "").replace(/\|$/, "").split("|").map((c) => c.trim());
|
|
9441
|
+
if (cells.every((c) => c.length === 0)) continue;
|
|
9442
|
+
permRows.push(cells);
|
|
9443
|
+
}
|
|
9444
|
+
}
|
|
9445
|
+
if (privilegedActors.length > 0 && permRows.length === 0) {
|
|
9446
|
+
issues.push(
|
|
9447
|
+
issue(
|
|
9448
|
+
"PRIVILEGED_ACTOR_WITHOUT_PERMISSION",
|
|
9449
|
+
"conformance",
|
|
9450
|
+
"specs/functional.md",
|
|
9451
|
+
`Aktor pengelola terdeteksi (${privilegedActors.slice(0, 3).join(", ")}) tetapi tidak ada permission matrix (Resource/Action/Role/Scope/Workflow/AC).`,
|
|
9452
|
+
"specs"
|
|
9453
|
+
)
|
|
9454
|
+
);
|
|
9455
|
+
}
|
|
9456
|
+
let incompleteRows = 0;
|
|
9457
|
+
for (const row of permRows) {
|
|
9458
|
+
const filled = row.filter((c) => c.length > 0 && !/^:?-{2,}:?$/.test(c));
|
|
9459
|
+
if (filled.length < 6) incompleteRows += 1;
|
|
9460
|
+
}
|
|
9461
|
+
if (incompleteRows > 0) {
|
|
9462
|
+
issues.push(
|
|
9463
|
+
issue(
|
|
9464
|
+
"PERMISSION_ROW_INCOMPLETE",
|
|
9465
|
+
"conformance",
|
|
9466
|
+
"specs/functional.md",
|
|
9467
|
+
`${incompleteRows} baris permission matrix tidak lengkap (butuh Resource/Action/Role/Scope/Workflow/AC).`,
|
|
9468
|
+
"specs"
|
|
9469
|
+
)
|
|
9470
|
+
);
|
|
9471
|
+
}
|
|
9472
|
+
if (permRows.length > 0 && privilegedActors.length > 0) {
|
|
9473
|
+
const roleCells = permRows.map((r) => (r[2] ?? "").toLowerCase()).join(" ");
|
|
9474
|
+
const missingActor = privilegedActors.filter(
|
|
9475
|
+
(actor) => !roleCells.includes(actor.toLowerCase().split(" ")[0] ?? "")
|
|
9476
|
+
);
|
|
9477
|
+
if (missingActor.length > 0) {
|
|
9478
|
+
issues.push(
|
|
9479
|
+
issue(
|
|
9480
|
+
"PRIVILEGED_ACTOR_WITHOUT_PERMISSION",
|
|
9481
|
+
"conformance",
|
|
9482
|
+
"specs/functional.md",
|
|
9483
|
+
`Aktor pengelola tidak muncul di kolom Role permission matrix: ${missingActor.slice(0, 5).join(", ")}.`,
|
|
9484
|
+
"specs"
|
|
9485
|
+
)
|
|
9486
|
+
);
|
|
9487
|
+
}
|
|
9488
|
+
}
|
|
9489
|
+
const taskAcceptanceText = tasks.map((t) => `${t.content}
|
|
9490
|
+
${taskTargets(t)}`).join("\n");
|
|
9491
|
+
const taskFlowRefs = `${tasks.map((t) => taskLayer(t)).join(" ")} ${taskAcceptanceText}`;
|
|
9492
|
+
let permWithoutTask = 0;
|
|
9493
|
+
let permWithoutWorkflow = 0;
|
|
9494
|
+
for (const row of permRows) {
|
|
9495
|
+
const ac = row[5] ?? "";
|
|
9496
|
+
const acIds = ac.match(/AC-?\d+/gi) ?? [];
|
|
9497
|
+
if (acIds.length > 0) {
|
|
9498
|
+
const covered = acIds.some((id) => taskAcceptanceText.includes(id));
|
|
9499
|
+
if (!covered) permWithoutTask += 1;
|
|
9500
|
+
}
|
|
9501
|
+
const workflow = row[4] ?? "";
|
|
9502
|
+
const flowIds = workflow.match(/FLOW-?\d+/gi) ?? [];
|
|
9503
|
+
if (flowIds.length > 0) {
|
|
9504
|
+
const covered = flowIds.some((id) => taskFlowRefs.includes(id));
|
|
9505
|
+
if (!covered) permWithoutWorkflow += 1;
|
|
9506
|
+
}
|
|
9507
|
+
}
|
|
9508
|
+
if (permWithoutTask > 0) {
|
|
9509
|
+
issues.push(
|
|
9510
|
+
issue(
|
|
9511
|
+
"PERMISSION_WITHOUT_TASK",
|
|
9512
|
+
"conformance",
|
|
9513
|
+
"tasks/",
|
|
9514
|
+
`${permWithoutTask} permission row tidak ditelusuri ke task (AC tidak muncul di tasks).`,
|
|
9515
|
+
"tasks"
|
|
9516
|
+
)
|
|
9517
|
+
);
|
|
9518
|
+
}
|
|
9519
|
+
if (permWithoutWorkflow > 0) {
|
|
9520
|
+
issues.push(
|
|
9521
|
+
issue(
|
|
9522
|
+
"PERMISSION_WITHOUT_WORKFLOW",
|
|
9523
|
+
"conformance",
|
|
9524
|
+
"specs/functional.md",
|
|
9525
|
+
`${permWithoutWorkflow} permission row tidak ditelusuri ke workflow (FLOW ID tidak muncul di tasks/specs).`,
|
|
9526
|
+
"specs"
|
|
9527
|
+
)
|
|
9528
|
+
);
|
|
9529
|
+
}
|
|
9530
|
+
if (permRows.length > 0) {
|
|
9531
|
+
const hasAuthzTest = tasks.some(
|
|
9532
|
+
(t) => /authz|authorization|izin|permission test|akses ditolak|403|forbidden/i.test(
|
|
9533
|
+
`${t.content}
|
|
9534
|
+
${taskTargets(t)}`
|
|
9535
|
+
)
|
|
9536
|
+
);
|
|
9537
|
+
if (!hasAuthzTest) {
|
|
9538
|
+
issues.push(
|
|
9539
|
+
issue(
|
|
9540
|
+
"AUTHZ_TEST_COVERAGE_MISSING",
|
|
9541
|
+
"advisory",
|
|
9542
|
+
"tasks/",
|
|
9543
|
+
"Permission matrix ada, tetapi tidak ada task yang merujuk pengujian authorization (403/izin).",
|
|
9544
|
+
"tasks"
|
|
9545
|
+
)
|
|
9546
|
+
);
|
|
9547
|
+
}
|
|
9548
|
+
}
|
|
9549
|
+
const prdText = prd ?? "";
|
|
9550
|
+
const subfeatureIds = [...new Set(prdText.match(/SUBFEATURE-\d+/gi) ?? [])].map(
|
|
9551
|
+
(s) => s.toUpperCase()
|
|
9552
|
+
);
|
|
9553
|
+
const taskSubfeatures = (task) => {
|
|
9554
|
+
const ctx = parseTaskContext(task.content, task.path);
|
|
9555
|
+
const declared = ctx.subfeatureIds ?? ctx.subfeatures;
|
|
9556
|
+
if (Array.isArray(declared) && declared.length > 0) {
|
|
9557
|
+
return declared.map((s) => s.toUpperCase());
|
|
9558
|
+
}
|
|
9559
|
+
return subfeatureIds.filter((sf) => new RegExp(sf.replace("-", "\\-"), "i").test(task.content));
|
|
9560
|
+
};
|
|
9561
|
+
const backendImplies = /payment|pembayaran|stock|stok|order|pesanan|auth|login|database|data|mutasi|transaksi/i;
|
|
9562
|
+
for (const sf of subfeatureIds) {
|
|
9563
|
+
const owners = tasks.filter((t) => taskSubfeatures(t).includes(sf));
|
|
9564
|
+
if (owners.length === 0) {
|
|
9565
|
+
issues.push(
|
|
9566
|
+
issue(
|
|
9567
|
+
"FEATURE_TASK_MISSING",
|
|
9568
|
+
"blocker",
|
|
9569
|
+
"tasks/",
|
|
9570
|
+
`Subfeature ${sf} tidak memiliki task yang menelusurinya (subfeatureIds atau content match).`,
|
|
9571
|
+
"tasks"
|
|
9572
|
+
)
|
|
9573
|
+
);
|
|
9574
|
+
continue;
|
|
9575
|
+
}
|
|
9576
|
+
const allMock = owners.every((t) => taskLayer(t) === "frontend_mock");
|
|
9577
|
+
const sfDescMatch = prdText.match(new RegExp(`${sf}[sS]{0,200}`, "i"));
|
|
9578
|
+
const sfDesc = sfDescMatch ? sfDescMatch[0] : sf;
|
|
9579
|
+
if (allMock && backendImplies.test(sfDesc)) {
|
|
9580
|
+
issues.push(
|
|
9581
|
+
issue(
|
|
9582
|
+
"FEATURE_MOCK_ONLY",
|
|
9583
|
+
"advisory",
|
|
9584
|
+
"tasks/",
|
|
9585
|
+
`Subfeature ${sf} hanya memiliki task layer frontend_mock, padahal implikasi backend terdeteksi.`,
|
|
9586
|
+
"tasks"
|
|
9587
|
+
)
|
|
9588
|
+
);
|
|
9589
|
+
}
|
|
9590
|
+
}
|
|
9591
|
+
if (input.runtime !== "client-only") {
|
|
9592
|
+
const dataSpec = specs.find((file) => /data/i.test(file.path));
|
|
9593
|
+
const dataText = dataSpec?.content ?? "";
|
|
9594
|
+
const entityNames = [
|
|
9595
|
+
...new Set(
|
|
9596
|
+
(dataText.match(/^###\s+(.+)$/gm) ?? []).map((l) => l.replace(/^###\s+/, "").trim())
|
|
9597
|
+
)
|
|
9598
|
+
];
|
|
9599
|
+
if (entityNames.length > 0) {
|
|
9600
|
+
const hasDbTask = tasks.some(
|
|
9601
|
+
(t) => taskLayer(t) === "database" || taskLayer(t) === "backend_api"
|
|
9602
|
+
);
|
|
9603
|
+
if (!hasDbTask) {
|
|
9604
|
+
issues.push(
|
|
9605
|
+
issue(
|
|
9606
|
+
"DB_REQUIREMENT_COVERAGE_MISSING",
|
|
9607
|
+
"advisory",
|
|
9608
|
+
"tasks/",
|
|
9609
|
+
"specs/data.md mendefinisikan entitas, tetapi tidak ada task dengan layer database.",
|
|
9610
|
+
"tasks"
|
|
9611
|
+
)
|
|
9612
|
+
);
|
|
9613
|
+
}
|
|
9614
|
+
}
|
|
9615
|
+
}
|
|
9429
9616
|
return {
|
|
9430
9617
|
ok: issues.every((finding) => finding.severity !== "blocker"),
|
|
9431
9618
|
issues
|
|
@@ -9579,7 +9766,7 @@ Urutan otoritas: keamanan/a11y inti > PRD/specs > file di sini > default generik
|
|
|
9579
9766
|
var EXECUTION_SIDECAR_PATH = "tasks/.execution/state.json";
|
|
9580
9767
|
var EXECUTION_SIDECAR_VERSION = 1;
|
|
9581
9768
|
var EXECUTION_SIDECAR_VERSION_V2 = 2;
|
|
9582
|
-
var HANDOFF_PROMPT_VERSION =
|
|
9769
|
+
var HANDOFF_PROMPT_VERSION = 27;
|
|
9583
9770
|
var HANDOFF_AGENT_TOKEN_TTL_SECONDS = 30 * 24 * 3600;
|
|
9584
9771
|
var HandoffPayloadSchema = external_exports.object({
|
|
9585
9772
|
promptVersion: external_exports.literal(HANDOFF_PROMPT_VERSION),
|
|
@@ -9655,7 +9842,12 @@ var ExecutionTaskStateSchema = external_exports.object({
|
|
|
9655
9842
|
blockedReason: external_exports.string().optional(),
|
|
9656
9843
|
reqRefs: external_exports.array(external_exports.string()).optional(),
|
|
9657
9844
|
acRefs: external_exports.array(external_exports.string()).optional(),
|
|
9658
|
-
verification: external_exports.object({ command: external_exports.string().optional(), exitCode: external_exports.number().int().optional() }).optional()
|
|
9845
|
+
verification: external_exports.object({ command: external_exports.string().optional(), exitCode: external_exports.number().int().optional() }).optional(),
|
|
9846
|
+
/** v2 feature-scope roots for the completion rollup (all optional, v1-compat). */
|
|
9847
|
+
featureId: external_exports.string().optional(),
|
|
9848
|
+
subfeatures: external_exports.array(external_exports.string()).optional(),
|
|
9849
|
+
moduleId: external_exports.string().optional(),
|
|
9850
|
+
cap: external_exports.string().optional()
|
|
9659
9851
|
}).passthrough();
|
|
9660
9852
|
var TASK_MODES = ["authoring", "seed", "executor"];
|
|
9661
9853
|
var TaskModeSchema = external_exports.enum(TASK_MODES);
|
|
@@ -9696,6 +9888,66 @@ function summarizeExecutionCounts(tasks) {
|
|
|
9696
9888
|
}
|
|
9697
9889
|
return base;
|
|
9698
9890
|
}
|
|
9891
|
+
function computeCompletion(tasks, definitions) {
|
|
9892
|
+
const defById = new Map(
|
|
9893
|
+
(definitions ?? []).map((definition) => [definition.id.toUpperCase(), definition])
|
|
9894
|
+
);
|
|
9895
|
+
const units = /* @__PURE__ */ new Map();
|
|
9896
|
+
const tally = (key, done) => {
|
|
9897
|
+
if (key === void 0) return;
|
|
9898
|
+
const cleaned = key.trim();
|
|
9899
|
+
if (cleaned.length === 0 || /^N\/A\b/i.test(cleaned)) return;
|
|
9900
|
+
const entry = units.get(cleaned) ?? { done: 0, total: 0 };
|
|
9901
|
+
entry.total += 1;
|
|
9902
|
+
if (done) entry.done += 1;
|
|
9903
|
+
units.set(cleaned, entry);
|
|
9904
|
+
};
|
|
9905
|
+
const tallyDefinition = (definition, done) => {
|
|
9906
|
+
tally(definition.featureId, done);
|
|
9907
|
+
tally(definition.moduleId, done);
|
|
9908
|
+
for (const subfeature of definition.subfeatures ?? []) tally(subfeature, done);
|
|
9909
|
+
};
|
|
9910
|
+
let tasksDone = 0;
|
|
9911
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
9912
|
+
const doneRefs = /* @__PURE__ */ new Set();
|
|
9913
|
+
for (const task of tasks) {
|
|
9914
|
+
const done = task.status === "done";
|
|
9915
|
+
if (done) {
|
|
9916
|
+
tasksDone += 1;
|
|
9917
|
+
doneRefs.add(task.ref.toUpperCase());
|
|
9918
|
+
}
|
|
9919
|
+
seenIds.add(task.ref.toUpperCase());
|
|
9920
|
+
const definition = defById.get(task.ref.toUpperCase());
|
|
9921
|
+
tally(definition?.featureId ?? task.featureId, done);
|
|
9922
|
+
tally(definition?.moduleId ?? task.moduleId, done);
|
|
9923
|
+
const subfeatures = definition?.subfeatures ?? task.subfeatures ?? [];
|
|
9924
|
+
for (const subfeature of subfeatures) tally(subfeature, done);
|
|
9925
|
+
}
|
|
9926
|
+
for (const definition of definitions ?? []) {
|
|
9927
|
+
if (definition !== void 0 && !seenIds.has(definition.id.toUpperCase())) {
|
|
9928
|
+
tallyDefinition(definition, false);
|
|
9929
|
+
}
|
|
9930
|
+
}
|
|
9931
|
+
const features = {};
|
|
9932
|
+
for (const [id, entry] of units) {
|
|
9933
|
+
const status = entry.done === 0 ? "missing" : entry.done < entry.total ? "incomplete" : "complete";
|
|
9934
|
+
features[id] = { status, doneTasks: entry.done, totalTasks: entry.total };
|
|
9935
|
+
}
|
|
9936
|
+
const allTasksDone = tasks.every((task) => task.status === "done");
|
|
9937
|
+
const unitIds = Object.keys(features);
|
|
9938
|
+
const allUnitsComplete = unitIds.length > 0 && unitIds.every((id) => features[id]?.status === "complete");
|
|
9939
|
+
let allIntegrationDone = true;
|
|
9940
|
+
for (const task of tasks) {
|
|
9941
|
+
if (task.layer === "integration" && task.status !== "done") allIntegrationDone = false;
|
|
9942
|
+
}
|
|
9943
|
+
for (const definition of definitions ?? []) {
|
|
9944
|
+
if (definition.layer === "integration" && !doneRefs.has(definition.id.toUpperCase())) {
|
|
9945
|
+
allIntegrationDone = false;
|
|
9946
|
+
}
|
|
9947
|
+
}
|
|
9948
|
+
const projectComplete = allTasksDone && allUnitsComplete && allIntegrationDone;
|
|
9949
|
+
return { tasksDone, totalTasks: tasks.length, features, projectComplete };
|
|
9950
|
+
}
|
|
9699
9951
|
|
|
9700
9952
|
// src/api.ts
|
|
9701
9953
|
var DEFAULT_API_URL = "https://gen.jioo.site";
|
|
@@ -9763,6 +10015,8 @@ async function apiLogin(apiUrl, email, password) {
|
|
|
9763
10015
|
var ApiClient = class {
|
|
9764
10016
|
baseUrl;
|
|
9765
10017
|
cookie;
|
|
10018
|
+
/** Set when the server re-signed a rotated token during a request. */
|
|
10019
|
+
renewedCookie = null;
|
|
9766
10020
|
constructor(apiUrl, cookie) {
|
|
9767
10021
|
this.baseUrl = normalizeBaseUrl(apiUrl);
|
|
9768
10022
|
this.cookie = cookie;
|
|
@@ -9793,13 +10047,15 @@ var ApiClient = class {
|
|
|
9793
10047
|
}
|
|
9794
10048
|
const response = await fetch(`${this.baseUrl}${path}`, requestInit);
|
|
9795
10049
|
if (!response.ok) throw await apiError(response);
|
|
10050
|
+
const renewed = sessionCookieFrom(response);
|
|
10051
|
+
if (renewed !== null) this.renewedCookie = renewed;
|
|
9796
10052
|
return response;
|
|
9797
10053
|
}
|
|
9798
10054
|
};
|
|
9799
10055
|
|
|
9800
10056
|
// src/commands.ts
|
|
9801
10057
|
import { spawn } from "node:child_process";
|
|
9802
|
-
import { mkdir as mkdir8, readdir as readdir7, readFile as readFile10, writeFile as writeFile8 } from "node:fs/promises";
|
|
10058
|
+
import { mkdir as mkdir8, readdir as readdir7, readFile as readFile10, stat as stat7, writeFile as writeFile8 } from "node:fs/promises";
|
|
9803
10059
|
import { join as join10, resolve as resolve6 } from "node:path";
|
|
9804
10060
|
|
|
9805
10061
|
// src/authoring.ts
|
|
@@ -10223,7 +10479,8 @@ function parseProjectLink(value, bundleDir) {
|
|
|
10223
10479
|
taskMode: parseTaskMode(value.taskMode),
|
|
10224
10480
|
execution: {
|
|
10225
10481
|
// Legacy links may store the flag at the top level; prefer the nested form.
|
|
10226
|
-
uiQuality: parseUiQuality(execution.uiQuality ?? value.uiQuality)
|
|
10482
|
+
uiQuality: parseUiQuality(execution.uiQuality ?? value.uiQuality),
|
|
10483
|
+
autoMode: parseAutoMode(execution.autoMode ?? value.autoMode)
|
|
10227
10484
|
}
|
|
10228
10485
|
};
|
|
10229
10486
|
}
|
|
@@ -10234,6 +10491,27 @@ function parseUiQuality(value) {
|
|
|
10234
10491
|
}
|
|
10235
10492
|
throw new Error(`Project link execution.uiQuality tidak valid: ${String(value)}`);
|
|
10236
10493
|
}
|
|
10494
|
+
function parseAutoMode(value) {
|
|
10495
|
+
if (value === void 0 || value === null) return false;
|
|
10496
|
+
if (typeof value === "boolean") return value;
|
|
10497
|
+
if (value === "true" || value === "1" || value === "yes") return true;
|
|
10498
|
+
if (value === "false" || value === "0" || value === "no") return false;
|
|
10499
|
+
throw new Error(`Project link execution.autoMode tidak valid: ${String(value)}`);
|
|
10500
|
+
}
|
|
10501
|
+
async function readAutoMode(bundleDir) {
|
|
10502
|
+
const link = await readProjectLink(resolve2(bundleDir));
|
|
10503
|
+
return link?.execution.autoMode ?? false;
|
|
10504
|
+
}
|
|
10505
|
+
async function writeAutoMode(bundleDir, enabled) {
|
|
10506
|
+
const link = await readProjectLink(resolve2(bundleDir));
|
|
10507
|
+
if (link === null) throw new Error("Belum ada project link. Jalankan `jioogen link` dulu.");
|
|
10508
|
+
await writeProjectLink(resolve2(bundleDir), {
|
|
10509
|
+
projectId: link.projectId,
|
|
10510
|
+
apiUrl: link.apiUrl,
|
|
10511
|
+
taskMode: link.taskMode,
|
|
10512
|
+
execution: { uiQuality: link.execution.uiQuality, autoMode: enabled }
|
|
10513
|
+
});
|
|
10514
|
+
}
|
|
10237
10515
|
function parseTaskMode(value) {
|
|
10238
10516
|
if (value === void 0) return DEFAULT_TASK_MODE;
|
|
10239
10517
|
const parsed = TaskModeSchema.safeParse(value);
|
|
@@ -10284,7 +10562,10 @@ async function writeProjectLink(bundleDir, link) {
|
|
|
10284
10562
|
projectId: link.projectId,
|
|
10285
10563
|
apiUrl: link.apiUrl,
|
|
10286
10564
|
taskMode: link.taskMode ?? DEFAULT_TASK_MODE,
|
|
10287
|
-
execution: {
|
|
10565
|
+
execution: {
|
|
10566
|
+
uiQuality: link.execution?.uiQuality ?? DEFAULT_UI_QUALITY,
|
|
10567
|
+
autoMode: link.execution?.autoMode ?? false
|
|
10568
|
+
}
|
|
10288
10569
|
},
|
|
10289
10570
|
null,
|
|
10290
10571
|
2
|
|
@@ -10293,6 +10574,19 @@ async function writeProjectLink(bundleDir, link) {
|
|
|
10293
10574
|
"utf8"
|
|
10294
10575
|
);
|
|
10295
10576
|
}
|
|
10577
|
+
async function removeProjectLink(bundleDir) {
|
|
10578
|
+
let removedKey = false;
|
|
10579
|
+
for (const directoryName of [PROJECT_DIR, LEGACY_PROJECT_DIR]) {
|
|
10580
|
+
const candidate = join3(resolve2(bundleDir), directoryName, PROJECT_FILE);
|
|
10581
|
+
try {
|
|
10582
|
+
await rm2(candidate);
|
|
10583
|
+
removedKey = true;
|
|
10584
|
+
} catch (error) {
|
|
10585
|
+
if (!isMissingFile(error)) throw error;
|
|
10586
|
+
}
|
|
10587
|
+
}
|
|
10588
|
+
return removedKey;
|
|
10589
|
+
}
|
|
10296
10590
|
async function readUiQuality(bundleDir) {
|
|
10297
10591
|
const link = await readProjectLink(resolve2(bundleDir));
|
|
10298
10592
|
return link?.execution.uiQuality ?? DEFAULT_UI_QUALITY;
|
|
@@ -10306,992 +10600,1230 @@ function isMissingFile(error) {
|
|
|
10306
10600
|
}
|
|
10307
10601
|
|
|
10308
10602
|
// src/doctor.ts
|
|
10309
|
-
import { readdir as readdir6, readFile as readFile8, rm as rm6, stat as
|
|
10603
|
+
import { readdir as readdir6, readFile as readFile8, rm as rm6, stat as stat5 } from "node:fs/promises";
|
|
10310
10604
|
import { join as join8 } from "node:path";
|
|
10311
10605
|
|
|
10312
10606
|
// src/drift.ts
|
|
10313
10607
|
import { createHash } from "node:crypto";
|
|
10314
|
-
import { mkdir as
|
|
10315
|
-
import { dirname as
|
|
10608
|
+
import { mkdir as mkdir4, readdir as readdir4, readFile as readFile6, rm as rm4, stat as stat3, writeFile as writeFile4 } from "node:fs/promises";
|
|
10609
|
+
import { dirname as dirname4, isAbsolute as isAbsolute2, join as join6 } from "node:path";
|
|
10316
10610
|
|
|
10317
10611
|
// src/tasks.ts
|
|
10318
|
-
import {
|
|
10319
|
-
import {
|
|
10320
|
-
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
|
|
10324
|
-
|
|
10325
|
-
|
|
10326
|
-
|
|
10327
|
-
|
|
10328
|
-
|
|
10329
|
-
|
|
10330
|
-
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10334
|
-
|
|
10335
|
-
|
|
10336
|
-
|
|
10337
|
-
|
|
10338
|
-
|
|
10339
|
-
|
|
10340
|
-
|
|
10341
|
-
|
|
10342
|
-
"- Tangani semua state UI: loading, empty, error, success.",
|
|
10343
|
-
"- Responsive untuk mobile dan desktop.",
|
|
10344
|
-
"- Aksesibilitas dasar: label, aria, focus, keyboard.",
|
|
10345
|
-
"- Microcopy jelas dan konsisten dengan konteks.",
|
|
10346
|
-
"- Tanpa komponen/abstraksi baru untuk satu pemakaian; reuse yang ada."
|
|
10347
|
-
],
|
|
10348
|
-
database: [
|
|
10349
|
-
"- Migrasi eksplisit dan aman (reversible, tanpa mengubah migrasi lama).",
|
|
10350
|
-
"- Constraint dan index sesuai pola query.",
|
|
10351
|
-
"- Relasi dan isolation sesuai specs (tenant/owner).",
|
|
10352
|
-
"- Seed idempotent (bisa dijalankan ulang tanpa duplikasi).",
|
|
10353
|
-
"- Tanpa query lintas pemilik.",
|
|
10354
|
-
"- Tanpa tabel/kolom spekulatif; hanya yang dipakai requirement."
|
|
10355
|
-
],
|
|
10356
|
-
backend_api: [
|
|
10357
|
-
"- Validasi input di boundary.",
|
|
10358
|
-
"- Error contract konsisten (status + bentuk response).",
|
|
10359
|
-
"- Auth/permission dicek sebelum mutasi.",
|
|
10360
|
-
"- Idempotensi untuk operasi tulis/retry.",
|
|
10361
|
-
"- Logging tanpa secret/PII.",
|
|
10362
|
-
"- Tanpa helper/duplikasi untuk satu pemakaian; ekstrak hanya bila berulang."
|
|
10363
|
-
],
|
|
10364
|
-
integration: [
|
|
10365
|
-
"- Mock dihapus dari jalur utama.",
|
|
10366
|
-
"- Kontrak CONTRACT-XXX sama dengan implementasi.",
|
|
10367
|
-
"- E2E memakai data nyata.",
|
|
10368
|
-
"- Error path diuji.",
|
|
10369
|
-
"- Tanpa layer/abstraksi tambahan; hubungkan langsung ke kontrak."
|
|
10370
|
-
],
|
|
10371
|
-
verification: [
|
|
10372
|
-
"- Jalankan semua verificationCommand sampai exit 0.",
|
|
10373
|
-
"- Smoke route/navigasi utama.",
|
|
10374
|
-
"- UI states dan responsive dicek.",
|
|
10375
|
-
"- Bukti Acceptance Criteria \xA711.",
|
|
10376
|
-
"- Jangan menambah kode produksi baru hanya untuk verifikasi."
|
|
10377
|
-
]
|
|
10378
|
-
};
|
|
10379
|
-
async function loadTasks(bundleDir) {
|
|
10380
|
-
const tasksDir = join4(bundleDir, "tasks");
|
|
10381
|
-
let entries;
|
|
10382
|
-
try {
|
|
10383
|
-
entries = await readdir3(tasksDir, { withFileTypes: true });
|
|
10384
|
-
} catch (error) {
|
|
10385
|
-
if (isMissingFile2(error)) throw new Error(`Direktori tasks/ tidak ditemukan di ${bundleDir}`);
|
|
10386
|
-
throw error;
|
|
10387
|
-
}
|
|
10388
|
-
const names = entries.filter(
|
|
10389
|
-
(entry) => entry.isFile() && entry.name.toLowerCase().endsWith(".md") && entry.name.toUpperCase() !== "TASKS.MD"
|
|
10390
|
-
).map((entry) => entry.name).sort();
|
|
10391
|
-
const tasks = [];
|
|
10392
|
-
if (names.length > 0) {
|
|
10393
|
-
for (const name of names) {
|
|
10394
|
-
const content = await readFile4(join4(tasksDir, name), "utf8");
|
|
10395
|
-
tasks.push(parseSingleTask(name, content));
|
|
10396
|
-
}
|
|
10397
|
-
} else {
|
|
10398
|
-
const singlePath = join4(tasksDir, "TASKS.md");
|
|
10399
|
-
let content;
|
|
10612
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
10613
|
+
import { readdir as readdir3, readFile as readFile5, stat as stat2 } from "node:fs/promises";
|
|
10614
|
+
import { isAbsolute, join as join5 } from "node:path";
|
|
10615
|
+
|
|
10616
|
+
// src/sidecar.ts
|
|
10617
|
+
import { randomUUID } from "node:crypto";
|
|
10618
|
+
import { mkdir as mkdir3, open, readFile as readFile4, rename, rm as rm3, stat, writeFile as writeFile3 } from "node:fs/promises";
|
|
10619
|
+
import { dirname as dirname3, join as join4 } from "node:path";
|
|
10620
|
+
var LOCK_RETRY_MS = 25;
|
|
10621
|
+
var LOCK_TIMEOUT_MS = 3e3;
|
|
10622
|
+
var LOCK_STALE_MS = 1e4;
|
|
10623
|
+
function sidecarPath(bundleDir) {
|
|
10624
|
+
return join4(bundleDir, EXECUTION_SIDECAR_PATH);
|
|
10625
|
+
}
|
|
10626
|
+
function lockPath(bundleDir) {
|
|
10627
|
+
return `${sidecarPath(bundleDir)}.lock`;
|
|
10628
|
+
}
|
|
10629
|
+
async function withStateLock(bundleDir, fn) {
|
|
10630
|
+
const target = lockPath(bundleDir);
|
|
10631
|
+
await mkdir3(dirname3(target), { recursive: true });
|
|
10632
|
+
const deadline = Date.now() + LOCK_TIMEOUT_MS;
|
|
10633
|
+
let handle = null;
|
|
10634
|
+
let staleRemoved = false;
|
|
10635
|
+
while (handle === null) {
|
|
10400
10636
|
try {
|
|
10401
|
-
|
|
10637
|
+
handle = await open(target, "wx");
|
|
10402
10638
|
} catch (error) {
|
|
10403
|
-
if (
|
|
10404
|
-
|
|
10639
|
+
if (!isLockBusy(error)) throw error;
|
|
10640
|
+
if (!staleRemoved && await removeStaleLock(target)) {
|
|
10641
|
+
staleRemoved = true;
|
|
10642
|
+
continue;
|
|
10643
|
+
}
|
|
10644
|
+
if (Date.now() >= deadline) {
|
|
10645
|
+
throw new Error(
|
|
10646
|
+
`Gagal mengambil lock sidecar setelah ${LOCK_TIMEOUT_MS / 1e3} detik: ${target}. Kemungkinan proses lain masih menulis; hapus file lock itu bila proses tersebut sudah mati.`
|
|
10647
|
+
);
|
|
10648
|
+
}
|
|
10649
|
+
await delay(LOCK_RETRY_MS);
|
|
10405
10650
|
}
|
|
10406
|
-
tasks.push(...parseSingleFile(content));
|
|
10407
|
-
}
|
|
10408
|
-
if (tasks.length === 0) throw new Error(`Tidak ada task yang bisa dibaca di ${tasksDir}`);
|
|
10409
|
-
assertUniqueIds(tasks);
|
|
10410
|
-
return tasks;
|
|
10411
|
-
}
|
|
10412
|
-
function parseSingleTask(file, content) {
|
|
10413
|
-
const heading = firstHeading(content);
|
|
10414
|
-
const explicit = TASK_ID_RE2.exec(file)?.[0] ?? explicitIdFromContent(content);
|
|
10415
|
-
const id = explicit ?? file.replace(/\.md$/i, "");
|
|
10416
|
-
if (id.length === 0) {
|
|
10417
|
-
throw new Error(`Berkas task tanpa ID: ${file}`);
|
|
10418
10651
|
}
|
|
10419
|
-
|
|
10420
|
-
}
|
|
10421
|
-
|
|
10422
|
-
|
|
10423
|
-
|
|
10424
|
-
|
|
10425
|
-
|
|
10426
|
-
}
|
|
10427
|
-
|
|
10428
|
-
const blocks = content.split(/\n(?=#{1,4}\s+(?:TASK|T)-\d{3,}\b)/i);
|
|
10429
|
-
const tasks = [];
|
|
10430
|
-
for (const block of blocks) {
|
|
10431
|
-
const heading = firstHeading(block);
|
|
10432
|
-
const id = heading !== null ? TASK_ID_RE2.exec(heading)?.[0] : void 0;
|
|
10433
|
-
if (id === void 0) continue;
|
|
10434
|
-
tasks.push(buildTask(id, heading, "TASKS.md", block));
|
|
10652
|
+
try {
|
|
10653
|
+
await handle.writeFile(`${process.pid}
|
|
10654
|
+
`, "utf8");
|
|
10655
|
+
return await fn();
|
|
10656
|
+
} finally {
|
|
10657
|
+
await handle.close().catch(() => {
|
|
10658
|
+
});
|
|
10659
|
+
await rm3(target, { force: true }).catch(() => {
|
|
10660
|
+
});
|
|
10435
10661
|
}
|
|
10436
|
-
return tasks;
|
|
10437
10662
|
}
|
|
10438
|
-
function
|
|
10439
|
-
|
|
10440
|
-
|
|
10441
|
-
|
|
10442
|
-
|
|
10663
|
+
async function readState(bundleDir) {
|
|
10664
|
+
let raw;
|
|
10665
|
+
try {
|
|
10666
|
+
raw = await readFile4(sidecarPath(bundleDir), "utf8");
|
|
10667
|
+
} catch (error) {
|
|
10668
|
+
if (isMissingFile2(error)) return null;
|
|
10669
|
+
throw error;
|
|
10443
10670
|
}
|
|
10444
|
-
|
|
10445
|
-
|
|
10446
|
-
|
|
10447
|
-
|
|
10448
|
-
|
|
10449
|
-
content: content.trim(),
|
|
10450
|
-
layer,
|
|
10451
|
-
phase: context.phase ?? 1,
|
|
10452
|
-
checkpoint: context.checkpoint === true,
|
|
10453
|
-
dependsOn: context.dependsOn
|
|
10454
|
-
};
|
|
10455
|
-
}
|
|
10456
|
-
function renderActiveTask(task, context) {
|
|
10457
|
-
const lines = [
|
|
10458
|
-
"## TASK AKTIF \u2014 PRIORITASKAN INI (satu task per giliran)",
|
|
10459
|
-
`ref: ${task.id}`,
|
|
10460
|
-
`title: ${task.title}`,
|
|
10461
|
-
`layer: ${task.layer ?? "-"} | phase: ${task.phase} | checkpoint: ${task.checkpoint}`,
|
|
10462
|
-
`file: tasks/${task.file}`
|
|
10463
|
-
];
|
|
10464
|
-
if (task.dependsOn.length > 0) lines.push(`dependsOn: ${task.dependsOn.join(", ")}`);
|
|
10465
|
-
lines.push(
|
|
10466
|
-
"",
|
|
10467
|
-
"Aturan mengikat:",
|
|
10468
|
-
"- Kerjakan HANYA task ini sampai semua Acceptance Criteria terpenuhi dan verificationCommand exit 0.",
|
|
10469
|
-
"- Jangan pindah task, jangan mengerjakan task lain, jangan melebar ke file di luar targetFiles (file/direktori/glob).",
|
|
10470
|
-
"- Jangan mengarang fitur/endpoint/kolom di luar PRD.md/specs/.",
|
|
10471
|
-
"- Detail implementasi (pola, struktur file dalam scope, library yang sudah ada) milikmu; ikuti konvensi proyek.",
|
|
10472
|
-
"- Jangan mengubah PRD.md/specs/kontrak. Butuh perubahan kontrak? STOP dan laporkan.",
|
|
10473
|
-
"- Selesai: `npx jioogen task complete <ref>`, lalu `npx jioogen sync`."
|
|
10474
|
-
);
|
|
10475
|
-
const checklist = renderQualityChecklist(task.layer, context);
|
|
10476
|
-
if (checklist.length > 0) lines.push("", ...checklist);
|
|
10477
|
-
const breakdown = buildTaskBreakdown(task);
|
|
10478
|
-
const breakdownLines = [...breakdown.authored, ...breakdown.derived];
|
|
10479
|
-
if (breakdownLines.length > 0) {
|
|
10480
|
-
lines.push("", BREAKDOWN_HEADING, ...BREAKDOWN_RULES);
|
|
10481
|
-
for (const item of breakdownLines) lines.push(`- [ ] ${item}`);
|
|
10482
|
-
}
|
|
10483
|
-
lines.push("", "--- ISI TASK (otoritas scope) ---", task.content, "--- AKHIR ISI TASK ---");
|
|
10484
|
-
return lines.join("\n");
|
|
10485
|
-
}
|
|
10486
|
-
function buildTaskBreakdown(task) {
|
|
10487
|
-
const context = parseTaskContext(task.content, task.id);
|
|
10488
|
-
const authored = (context.subtasks ?? []).filter((item) => !/^N\/A\b/i.test(item));
|
|
10489
|
-
const derived = [];
|
|
10490
|
-
const seen = /* @__PURE__ */ new Set();
|
|
10491
|
-
const push = (item) => {
|
|
10492
|
-
const key = item.trim().toLowerCase();
|
|
10493
|
-
if (key.length === 0 || seen.has(key)) return;
|
|
10494
|
-
seen.add(key);
|
|
10495
|
-
derived.push(item);
|
|
10496
|
-
};
|
|
10497
|
-
for (const subfeature of context.subfeatures ?? []) {
|
|
10498
|
-
push(`${subfeature} \u2014 petakan ke AC, flow/state, dan targetFiles`);
|
|
10499
|
-
}
|
|
10500
|
-
for (const acceptance of context.acceptance ?? []) {
|
|
10501
|
-
if (/^N\/A\b/i.test(acceptance)) continue;
|
|
10502
|
-
push(`${acceptance} \u2014 penuhi + catat bukti`);
|
|
10503
|
-
}
|
|
10504
|
-
for (const flow of context.flowRef ?? []) {
|
|
10505
|
-
push(`${flow} \u2014 implement alur sampai outcome`);
|
|
10506
|
-
}
|
|
10507
|
-
for (const lifecycle of context.lifecycleRefs ?? []) {
|
|
10508
|
-
push(`Lifecycle ${lifecycle} \u2014 state/transition yang relevan`);
|
|
10509
|
-
}
|
|
10510
|
-
for (const engine of context.engineRef ?? []) {
|
|
10511
|
-
push(`Engine ${engine} \u2014 invariant/keputusan yang dijaga`);
|
|
10512
|
-
}
|
|
10513
|
-
for (const state of context.uiStates ?? []) {
|
|
10514
|
-
push(`UI state ${state} \u2014 render + verifikasi`);
|
|
10515
|
-
}
|
|
10516
|
-
for (const isolation of context.isolationRefs ?? []) {
|
|
10517
|
-
push(`${isolation} \u2014 tegakkan boundary + AC penolakan akses`);
|
|
10518
|
-
}
|
|
10519
|
-
for (const file of context.targetFiles ?? []) {
|
|
10520
|
-
push(`File ${file} \u2014 buat/edit + test terkait`);
|
|
10521
|
-
}
|
|
10522
|
-
if (context.verificationCommand !== null && context.verificationCommand !== void 0) {
|
|
10523
|
-
push(`Verifikasi: \`${context.verificationCommand}\` (wajib exit 0)`);
|
|
10524
|
-
}
|
|
10525
|
-
if (authored.length === 0 && derived.length === 0) {
|
|
10526
|
-
push("Baca task + PRD/specs, lalu tulis langkah kerja eksplisit sebelum edit");
|
|
10671
|
+
let payload;
|
|
10672
|
+
try {
|
|
10673
|
+
payload = JSON.parse(raw);
|
|
10674
|
+
} catch {
|
|
10675
|
+
throw new Error(`Sidecar bukan JSON yang valid: ${sidecarPath(bundleDir)}`);
|
|
10527
10676
|
}
|
|
10528
|
-
|
|
10529
|
-
|
|
10530
|
-
|
|
10531
|
-
|
|
10532
|
-
|
|
10533
|
-
if (layer === "frontend_mock") {
|
|
10534
|
-
const references = UI_SKILLS.filter((skill) => context.skills?.includes(skill) === true);
|
|
10535
|
-
if (references.length > 0) items.push(`- Referensi skill: ${references.join(", ")}`);
|
|
10677
|
+
const parsed = ExecutionStateSchema.safeParse(payload);
|
|
10678
|
+
if (!parsed.success) {
|
|
10679
|
+
throw new Error(
|
|
10680
|
+
`Sidecar tidak cocok dengan schema v${EXECUTION_SIDECAR_VERSION}: ${sidecarPath(bundleDir)}`
|
|
10681
|
+
);
|
|
10536
10682
|
}
|
|
10537
|
-
|
|
10538
|
-
return [QUALITY_HEADING, ...items.slice(0, MAX_CHECKLIST_LINES)];
|
|
10539
|
-
}
|
|
10540
|
-
function resolveLayer(value) {
|
|
10541
|
-
if (value === void 0) return void 0;
|
|
10542
|
-
const token = value.trim().replace(/[`*]/g, "").split(/[\s,(]/)[0];
|
|
10543
|
-
if (token === void 0) return void 0;
|
|
10544
|
-
return TASK_LAYERS.includes(token) ? token : void 0;
|
|
10545
|
-
}
|
|
10546
|
-
function titleFromGoal(content) {
|
|
10547
|
-
const match = /goal\s*\*{0,2}\s*[:=]\s*\*{0,2}\s*([^\n]+)/i.exec(content);
|
|
10548
|
-
if (match?.[1] === void 0) return null;
|
|
10549
|
-
return stripMarkup(match[1]);
|
|
10683
|
+
return parsed.data;
|
|
10550
10684
|
}
|
|
10551
|
-
function
|
|
10552
|
-
|
|
10685
|
+
function createState(projectId, definitions, now = /* @__PURE__ */ new Date(), mode = DEFAULT_TASK_MODE) {
|
|
10686
|
+
const tasks = definitions.map(toTaskState);
|
|
10687
|
+
return {
|
|
10688
|
+
schemaVersion: EXECUTION_SIDECAR_VERSION,
|
|
10689
|
+
projectId,
|
|
10690
|
+
updatedAt: now.toISOString(),
|
|
10691
|
+
executor: { engine: "jioogen" },
|
|
10692
|
+
mode,
|
|
10693
|
+
counts: summarizeExecutionCounts(tasks),
|
|
10694
|
+
tasks
|
|
10695
|
+
};
|
|
10553
10696
|
}
|
|
10554
|
-
function
|
|
10555
|
-
if (
|
|
10556
|
-
|
|
10557
|
-
return withoutId.length > 0 ? withoutId : heading;
|
|
10697
|
+
function withMode(state, mode) {
|
|
10698
|
+
if (state.mode === mode) return state;
|
|
10699
|
+
return { ...state, mode };
|
|
10558
10700
|
}
|
|
10559
|
-
function
|
|
10560
|
-
|
|
10701
|
+
function assertModeAllowsNewTasks(mode, state, definitions) {
|
|
10702
|
+
if (mode !== "executor") return;
|
|
10703
|
+
const known = new Set(state.tasks.map((task) => task.ref.toUpperCase()));
|
|
10704
|
+
const unknown = definitions.filter((definition) => !known.has(definition.id.toUpperCase())).map((definition) => definition.id);
|
|
10705
|
+
if (unknown.length === 0) return;
|
|
10706
|
+
throw new Error(
|
|
10707
|
+
`Mode executor hanya menjalankan task yang sudah ada; task baru (${unknown.join(", ")}) harus lewat authoring JiooGen atau mode seed.`
|
|
10708
|
+
);
|
|
10561
10709
|
}
|
|
10562
|
-
function
|
|
10563
|
-
const
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10710
|
+
function mergeTasks(state, definitions) {
|
|
10711
|
+
const byId = new Map(definitions.map((task) => [task.id.toUpperCase(), task]));
|
|
10712
|
+
const known = new Set(state.tasks.map((task) => task.ref.toUpperCase()));
|
|
10713
|
+
let changed = false;
|
|
10714
|
+
const existing = state.tasks.map((task) => {
|
|
10715
|
+
const definition = byId.get(task.ref.toUpperCase());
|
|
10716
|
+
if (definition === void 0) return task;
|
|
10717
|
+
if (sameMetadata(task, definition)) return task;
|
|
10718
|
+
changed = true;
|
|
10719
|
+
const updated = {
|
|
10720
|
+
...task,
|
|
10721
|
+
phase: definition.phase,
|
|
10722
|
+
checkpoint: definition.checkpoint
|
|
10723
|
+
};
|
|
10724
|
+
if (definition.layer !== void 0) updated.layer = definition.layer;
|
|
10725
|
+
else delete updated.layer;
|
|
10726
|
+
applyScopedMetadata(updated, taskScopedMetadata(definition));
|
|
10727
|
+
return updated;
|
|
10728
|
+
});
|
|
10729
|
+
const additions = definitions.filter((task) => !known.has(task.id.toUpperCase())).map(toTaskState);
|
|
10730
|
+
if (!changed && additions.length === 0) return state;
|
|
10731
|
+
return rebuild(state, [...existing, ...additions], state.current);
|
|
10569
10732
|
}
|
|
10570
|
-
function
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
);
|
|
10733
|
+
function applyScopedMetadata(task, scope) {
|
|
10734
|
+
if (scope.featureId !== void 0) task.featureId = scope.featureId;
|
|
10735
|
+
else delete task.featureId;
|
|
10736
|
+
if (scope.subfeatures !== void 0) task.subfeatures = scope.subfeatures;
|
|
10737
|
+
else delete task.subfeatures;
|
|
10738
|
+
if (scope.moduleId !== void 0) task.moduleId = scope.moduleId;
|
|
10739
|
+
else delete task.moduleId;
|
|
10740
|
+
if (scope.cap !== void 0) task.cap = scope.cap;
|
|
10741
|
+
else delete task.cap;
|
|
10574
10742
|
}
|
|
10575
|
-
function
|
|
10576
|
-
|
|
10743
|
+
function sameMetadata(task, definition) {
|
|
10744
|
+
const scope = taskScopedMetadata(definition);
|
|
10745
|
+
return task.layer === definition.layer && task.phase === definition.phase && task.checkpoint === definition.checkpoint && task.featureId === scope.featureId && sameStringList(task.subfeatures, scope.subfeatures) && task.moduleId === scope.moduleId && task.cap === scope.cap;
|
|
10577
10746
|
}
|
|
10578
|
-
function
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
const trailing = /(?:^|[-\s])(\d{3,})$/.exec(id);
|
|
10582
|
-
return trailing?.[1] !== void 0 ? Number.parseInt(trailing[1], 10) : Number.MAX_SAFE_INTEGER;
|
|
10747
|
+
function sameStringList(left, right) {
|
|
10748
|
+
if (left === void 0 || right === void 0) return left === right;
|
|
10749
|
+
return left.length === right.length && left.every((entry, index) => entry === right[index]);
|
|
10583
10750
|
}
|
|
10584
|
-
function
|
|
10585
|
-
const
|
|
10586
|
-
const
|
|
10587
|
-
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
return { task, state, reason: "in_progress" };
|
|
10591
|
-
}
|
|
10751
|
+
function withStatus(state, ref, status, options = {}) {
|
|
10752
|
+
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
10753
|
+
const index = state.tasks.findIndex((task) => task.ref.toUpperCase() === ref.toUpperCase());
|
|
10754
|
+
const previous = index === -1 ? void 0 : state.tasks[index];
|
|
10755
|
+
if (previous === void 0) {
|
|
10756
|
+
throw new Error(`Task ${ref} tidak ada di sidecar. Jalankan \`jioogen task next\` lebih dulu.`);
|
|
10592
10757
|
}
|
|
10593
|
-
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10758
|
+
const attempt = status === "in_progress" ? (previous.attempt ?? 0) + 1 : previous.attempt;
|
|
10759
|
+
const historyEntry = { status, at: now.toISOString() };
|
|
10760
|
+
if (options.note !== void 0 && options.note.length > 0) historyEntry.note = options.note;
|
|
10761
|
+
const updated = {
|
|
10762
|
+
...previous,
|
|
10763
|
+
status,
|
|
10764
|
+
updatedAt: now.toISOString(),
|
|
10765
|
+
history: [...previous.history ?? [], historyEntry]
|
|
10766
|
+
};
|
|
10767
|
+
if (attempt !== void 0) updated.attempt = attempt;
|
|
10768
|
+
if (options.note !== void 0) {
|
|
10769
|
+
if (options.note.length > 0) updated.note = options.note;
|
|
10770
|
+
else delete updated.note;
|
|
10599
10771
|
}
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
10608
|
-
)
|
|
10609
|
-
})).filter((entry) => entry.missing.length > 0);
|
|
10772
|
+
const tasks = state.tasks.map((task, taskIndex) => taskIndex === index ? updated : task);
|
|
10773
|
+
const current = status === "in_progress" || status === "verifying" ? {
|
|
10774
|
+
ref: updated.ref,
|
|
10775
|
+
...updated.layer !== void 0 ? { layer: updated.layer } : {},
|
|
10776
|
+
...updated.phase !== void 0 ? { phase: updated.phase } : {},
|
|
10777
|
+
awaitingCheckpoint: options.awaitingCheckpoint === true
|
|
10778
|
+
} : void 0;
|
|
10779
|
+
return rebuild(state, tasks, current, now);
|
|
10610
10780
|
}
|
|
10611
|
-
function
|
|
10612
|
-
return
|
|
10613
|
-
(dependency) => byRef.get(dependency.toUpperCase())?.status !== "done"
|
|
10614
|
-
);
|
|
10781
|
+
function setCurrent(state, current) {
|
|
10782
|
+
return rebuild(state, state.tasks, current ?? void 0);
|
|
10615
10783
|
}
|
|
10616
|
-
function
|
|
10617
|
-
|
|
10618
|
-
if (
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
|
|
10784
|
+
function appendTaskEvidence(state, ref, evidence) {
|
|
10785
|
+
const index = state.tasks.findIndex((task2) => task2.ref.toUpperCase() === ref.toUpperCase());
|
|
10786
|
+
if (index === -1) return state;
|
|
10787
|
+
const previous = state.tasks[index];
|
|
10788
|
+
if (previous === void 0) return state;
|
|
10789
|
+
const task = {
|
|
10790
|
+
...previous,
|
|
10791
|
+
evidence: [...previous.evidence ?? [], evidence]
|
|
10792
|
+
};
|
|
10793
|
+
const tasks = state.tasks.map((entry, i) => i === index ? task : entry);
|
|
10794
|
+
return rebuild(state, tasks, state.current);
|
|
10622
10795
|
}
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
const
|
|
10627
|
-
|
|
10796
|
+
function setTaskSource(state, ref, source) {
|
|
10797
|
+
const index = state.tasks.findIndex((task2) => task2.ref.toUpperCase() === ref.toUpperCase());
|
|
10798
|
+
if (index === -1) return state;
|
|
10799
|
+
const previous = state.tasks[index];
|
|
10800
|
+
if (previous === void 0) return state;
|
|
10801
|
+
const task = { ...previous, source };
|
|
10802
|
+
const tasks = state.tasks.map((entry, i) => i === index ? task : entry);
|
|
10803
|
+
return rebuild(state, tasks, state.current);
|
|
10628
10804
|
}
|
|
10629
|
-
function
|
|
10630
|
-
const
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
|
|
10639
|
-
|
|
10640
|
-
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
|
|
10644
|
-
|
|
10805
|
+
function setDesignReview(state, ref, review) {
|
|
10806
|
+
const index = state.tasks.findIndex((task2) => task2.ref.toUpperCase() === ref.toUpperCase());
|
|
10807
|
+
if (index === -1) return state;
|
|
10808
|
+
const previous = state.tasks[index];
|
|
10809
|
+
if (previous === void 0) return state;
|
|
10810
|
+
const task = {
|
|
10811
|
+
...previous,
|
|
10812
|
+
designReview: {
|
|
10813
|
+
passed: review.passed,
|
|
10814
|
+
findings: [...review.findings ?? []],
|
|
10815
|
+
summary: review.summary,
|
|
10816
|
+
at: review.at ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
10817
|
+
},
|
|
10818
|
+
evidence: [
|
|
10819
|
+
...previous.evidence ?? [],
|
|
10820
|
+
{
|
|
10821
|
+
type: "design_review",
|
|
10822
|
+
summary: `${review.passed ? "PASS" : "FAIL"}${review.summary ? ` \u2014 ${review.summary}` : ""}`,
|
|
10823
|
+
at: review.at ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
10824
|
+
}
|
|
10825
|
+
]
|
|
10826
|
+
};
|
|
10827
|
+
const tasks = state.tasks.map((entry, i) => i === index ? task : entry);
|
|
10828
|
+
return rebuild(state, tasks, state.current);
|
|
10645
10829
|
}
|
|
10646
|
-
function
|
|
10647
|
-
|
|
10830
|
+
async function writeState(bundleDir, state) {
|
|
10831
|
+
const normalized = rebuild(state, state.tasks, state.current);
|
|
10832
|
+
const target = sidecarPath(bundleDir);
|
|
10833
|
+
await mkdir3(dirname3(target), { recursive: true });
|
|
10834
|
+
const temp = `${target}.${process.pid}.${randomUUID()}.tmp`;
|
|
10835
|
+
try {
|
|
10836
|
+
await writeFile3(temp, `${JSON.stringify(normalized, null, 2)}
|
|
10837
|
+
`, "utf8");
|
|
10838
|
+
await rename(temp, target);
|
|
10839
|
+
} catch (error) {
|
|
10840
|
+
await rm3(temp, { force: true }).catch(() => {
|
|
10841
|
+
});
|
|
10842
|
+
throw error;
|
|
10843
|
+
}
|
|
10844
|
+
return normalized;
|
|
10648
10845
|
}
|
|
10649
|
-
function
|
|
10650
|
-
|
|
10846
|
+
async function backupExecutionState(bundleDir) {
|
|
10847
|
+
const current = await readState(bundleDir);
|
|
10848
|
+
if (current === null) return null;
|
|
10849
|
+
const backupDir = join4(bundleDir, ".jioogen");
|
|
10850
|
+
await mkdir3(backupDir, { recursive: true });
|
|
10851
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
10852
|
+
const backupFile = join4(backupDir, `state.backup-${timestamp}.json`);
|
|
10853
|
+
await writeFile3(backupFile, `${JSON.stringify(current, null, 2)}
|
|
10854
|
+
`, "utf8");
|
|
10855
|
+
return backupFile;
|
|
10651
10856
|
}
|
|
10652
|
-
function
|
|
10653
|
-
const
|
|
10654
|
-
|
|
10655
|
-
|
|
10656
|
-
|
|
10657
|
-
|
|
10658
|
-
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
|
|
10662
|
-
|
|
10663
|
-
|
|
10664
|
-
|
|
10665
|
-
|
|
10666
|
-
const next = (lines[j] ?? "").trim();
|
|
10667
|
-
if (next.length === 0) continue;
|
|
10668
|
-
if (/^#{1,6}\s/.test(next)) break;
|
|
10669
|
-
const value = stripVerificationBackticks(next);
|
|
10670
|
-
if (isVerificationPlaceholder(value)) return null;
|
|
10671
|
-
return value.length > 0 ? value : null;
|
|
10672
|
-
}
|
|
10673
|
-
}
|
|
10674
|
-
return null;
|
|
10857
|
+
function rebuild(state, tasks, current, now = /* @__PURE__ */ new Date()) {
|
|
10858
|
+
const next = {
|
|
10859
|
+
schemaVersion: state.schemaVersion,
|
|
10860
|
+
updatedAt: now.toISOString(),
|
|
10861
|
+
counts: summarizeExecutionCounts(tasks),
|
|
10862
|
+
tasks
|
|
10863
|
+
};
|
|
10864
|
+
if (state.projectId !== void 0) next.projectId = state.projectId;
|
|
10865
|
+
if (state.executor !== void 0) next.executor = state.executor;
|
|
10866
|
+
if (state.mode !== void 0) next.mode = state.mode;
|
|
10867
|
+
if (state.plan !== void 0) next.plan = state.plan;
|
|
10868
|
+
if (state.events !== void 0) next.events = state.events;
|
|
10869
|
+
if (current !== void 0) next.current = current;
|
|
10870
|
+
return next;
|
|
10675
10871
|
}
|
|
10676
|
-
function
|
|
10677
|
-
|
|
10872
|
+
function toTaskState(task) {
|
|
10873
|
+
const state = {
|
|
10874
|
+
ref: task.id,
|
|
10875
|
+
status: "todo",
|
|
10876
|
+
...task.layer !== void 0 ? { layer: task.layer } : {},
|
|
10877
|
+
phase: task.phase,
|
|
10878
|
+
checkpoint: task.checkpoint
|
|
10879
|
+
};
|
|
10880
|
+
applyScopedMetadata(state, taskScopedMetadata(task));
|
|
10881
|
+
return state;
|
|
10678
10882
|
}
|
|
10679
|
-
function
|
|
10680
|
-
const
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
}
|
|
10688
|
-
return trimmed;
|
|
10883
|
+
function taskScopedMetadata(task) {
|
|
10884
|
+
const context = parseTaskContext(task.content, task.id);
|
|
10885
|
+
return {
|
|
10886
|
+
...context.featureId !== void 0 ? { featureId: context.featureId } : {},
|
|
10887
|
+
...context.subfeatures !== void 0 && context.subfeatures.length > 0 ? { subfeatures: context.subfeatures } : {},
|
|
10888
|
+
...context.moduleId !== void 0 ? { moduleId: context.moduleId } : {},
|
|
10889
|
+
...context.cap !== void 0 ? { cap: context.cap } : {}
|
|
10890
|
+
};
|
|
10689
10891
|
}
|
|
10690
|
-
function
|
|
10691
|
-
return
|
|
10892
|
+
function completionDefinitions(definitions) {
|
|
10893
|
+
return definitions.map((definition) => ({
|
|
10894
|
+
id: definition.id,
|
|
10895
|
+
...taskScopedMetadata(definition),
|
|
10896
|
+
...definition.layer !== void 0 ? { layer: definition.layer } : {}
|
|
10897
|
+
}));
|
|
10692
10898
|
}
|
|
10693
10899
|
function isMissingFile2(error) {
|
|
10694
10900
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
10695
10901
|
}
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
var DRIFT_BASELINE_PATH = join5("tasks", ".execution", "baseline.json");
|
|
10699
|
-
var BASELINE_VERSION = 1;
|
|
10700
|
-
var MAX_TARGET_FILES = 2e3;
|
|
10701
|
-
var MAX_BUNDLE_FILE_BYTES = 1048576;
|
|
10702
|
-
var IGNORED_DIRS = /* @__PURE__ */ new Set([
|
|
10703
|
-
".git",
|
|
10704
|
-
"node_modules",
|
|
10705
|
-
".next",
|
|
10706
|
-
"dist",
|
|
10707
|
-
"build",
|
|
10708
|
-
"coverage",
|
|
10709
|
-
".turbo",
|
|
10710
|
-
".cache",
|
|
10711
|
-
".vercel",
|
|
10712
|
-
".output",
|
|
10713
|
-
"out",
|
|
10714
|
-
".expo",
|
|
10715
|
-
".jioogen",
|
|
10716
|
-
".claude",
|
|
10717
|
-
".opencode",
|
|
10718
|
-
".agent",
|
|
10719
|
-
".codex",
|
|
10720
|
-
".cursor"
|
|
10721
|
-
]);
|
|
10722
|
-
var IGNORED_TOP_FILES = /* @__PURE__ */ new Set(["AGENTS.md"]);
|
|
10723
|
-
function baselinePath(bundleDir) {
|
|
10724
|
-
return join5(bundleDir, DRIFT_BASELINE_PATH);
|
|
10902
|
+
function isLockBusy(error) {
|
|
10903
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "EEXIST";
|
|
10725
10904
|
}
|
|
10726
|
-
async function
|
|
10727
|
-
let raw;
|
|
10728
|
-
try {
|
|
10729
|
-
raw = await readFile5(baselinePath(bundleDir), "utf8");
|
|
10730
|
-
} catch {
|
|
10731
|
-
return null;
|
|
10732
|
-
}
|
|
10733
|
-
let parsed;
|
|
10905
|
+
async function removeStaleLock(target) {
|
|
10734
10906
|
try {
|
|
10735
|
-
|
|
10736
|
-
|
|
10737
|
-
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
|
|
10741
|
-
|
|
10742
|
-
if (tasks === void 0 || typeof tasks !== "object" || tasks === null) return null;
|
|
10743
|
-
const entries = {};
|
|
10744
|
-
for (const [ref, value] of Object.entries(tasks)) {
|
|
10745
|
-
if (typeof value !== "object" || value === null) continue;
|
|
10746
|
-
const entry = value;
|
|
10747
|
-
if (typeof entry.target !== "object" || entry.target === null) continue;
|
|
10748
|
-
entries[ref] = {
|
|
10749
|
-
at: typeof entry.at === "string" ? entry.at : "",
|
|
10750
|
-
target: entry.target
|
|
10751
|
-
};
|
|
10907
|
+
const info = await stat(target);
|
|
10908
|
+
if (Date.now() - info.mtimeMs < LOCK_STALE_MS) return false;
|
|
10909
|
+
await rm3(target, { force: true });
|
|
10910
|
+
return true;
|
|
10911
|
+
} catch (error) {
|
|
10912
|
+
if (isMissingFile2(error)) return true;
|
|
10913
|
+
throw error;
|
|
10752
10914
|
}
|
|
10753
|
-
return {
|
|
10754
|
-
version: typeof record.version === "number" ? record.version : BASELINE_VERSION,
|
|
10755
|
-
bundle: typeof record.bundle === "string" ? record.bundle : "",
|
|
10756
|
-
tasks: entries
|
|
10757
|
-
};
|
|
10758
|
-
}
|
|
10759
|
-
async function writeBaseline(bundleDir, baseline) {
|
|
10760
|
-
const target = baselinePath(bundleDir);
|
|
10761
|
-
await mkdir3(dirname3(target), { recursive: true });
|
|
10762
|
-
await writeFile3(target, `${JSON.stringify(baseline, null, 2)}
|
|
10763
|
-
`, "utf8");
|
|
10764
|
-
}
|
|
10765
|
-
async function clearBaseline(bundleDir) {
|
|
10766
|
-
await rm3(baselinePath(bundleDir), { force: true });
|
|
10767
10915
|
}
|
|
10768
|
-
|
|
10769
|
-
|
|
10770
|
-
version: BASELINE_VERSION,
|
|
10771
|
-
bundle: await bundleHashOf(bundleDir),
|
|
10772
|
-
tasks: {}
|
|
10773
|
-
};
|
|
10774
|
-
if (baseline.bundle.length === 0) baseline.bundle = await bundleHashOf(bundleDir);
|
|
10775
|
-
const target = await targetHashes(bundleDir, targetFilesFromContent(definition.content));
|
|
10776
|
-
baseline.tasks[definition.id.toUpperCase()] = {
|
|
10777
|
-
at: now.toISOString(),
|
|
10778
|
-
target: target.hashes
|
|
10779
|
-
};
|
|
10780
|
-
await writeBaseline(bundleDir, baseline);
|
|
10916
|
+
function delay(ms) {
|
|
10917
|
+
return new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
10781
10918
|
}
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
10790
|
-
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10919
|
+
|
|
10920
|
+
// src/tasks.ts
|
|
10921
|
+
var TASK_ID_RE2 = /\b(?:TASK|T)-\d{3,}\b/i;
|
|
10922
|
+
var HEADING_RE = /^#{1,4}\s+(.+)$/m;
|
|
10923
|
+
var LAYER_RANK = {
|
|
10924
|
+
frontend_mock: 0,
|
|
10925
|
+
database: 1,
|
|
10926
|
+
backend_api: 2,
|
|
10927
|
+
integration: 3,
|
|
10928
|
+
verification: 4
|
|
10929
|
+
};
|
|
10930
|
+
var IN_PROGRESS = ["in_progress", "verifying"];
|
|
10931
|
+
var QUALITY_HEADING = "## KUALITAS WAJIB (ringkas; detail di skill bila tersedia)";
|
|
10932
|
+
var BREAKDOWN_HEADING = "## BREAKDOWN WAJIB \u2014 SEBELUM CODING";
|
|
10933
|
+
var MAX_CHECKLIST_LINES = 12;
|
|
10934
|
+
var MAX_CUSTOM_KNOWLEDGE_FILES = 10;
|
|
10935
|
+
var CUSTOM_KNOWLEDGE_HEADER = "## KNOWLEDGE CUSTOM (user-owned, additive)";
|
|
10936
|
+
var BREAKDOWN_RULES = [
|
|
10937
|
+
"Breakdown ini mengikat: tulis/centang setiap item sebelum mulai edit, dan jangan `task complete` selama ada item tanpa bukti.",
|
|
10938
|
+
"Ini checklist kerja, bukan task baru; task baru hanya diizinkan pada `--mode seed`.",
|
|
10939
|
+
"Pratinjau ulang: `npx jioogen task expand <ref>`."
|
|
10940
|
+
];
|
|
10941
|
+
var UI_SKILLS = ["ui-ux-pro-max", "impeccable"];
|
|
10942
|
+
var LAYER_CHECKLISTS = {
|
|
10943
|
+
frontend_mock: [
|
|
10944
|
+
"- Reuse token desain yang ada; jangan hardcode warna/spacing bila token tersedia.",
|
|
10945
|
+
"- Tangani semua state UI: loading, empty, error, success.",
|
|
10946
|
+
"- Responsive untuk mobile dan desktop.",
|
|
10947
|
+
"- Aksesibilitas dasar: label, aria, focus, keyboard.",
|
|
10948
|
+
"- Microcopy jelas dan konsisten dengan konteks.",
|
|
10949
|
+
"- Tanpa komponen/abstraksi baru untuk satu pemakaian; reuse yang ada."
|
|
10950
|
+
],
|
|
10951
|
+
database: [
|
|
10952
|
+
"- Migrasi eksplisit dan aman (reversible, tanpa mengubah migrasi lama).",
|
|
10953
|
+
"- Constraint dan index sesuai pola query.",
|
|
10954
|
+
"- Relasi dan isolation sesuai specs (tenant/owner).",
|
|
10955
|
+
"- Seed idempotent (bisa dijalankan ulang tanpa duplikasi).",
|
|
10956
|
+
"- Tanpa query lintas pemilik.",
|
|
10957
|
+
"- Tanpa tabel/kolom spekulatif; hanya yang dipakai requirement."
|
|
10958
|
+
],
|
|
10959
|
+
backend_api: [
|
|
10960
|
+
"- Validasi input di boundary.",
|
|
10961
|
+
"- Error contract konsisten (status + bentuk response).",
|
|
10962
|
+
"- Auth/permission dicek sebelum mutasi.",
|
|
10963
|
+
"- Idempotensi untuk operasi tulis/retry.",
|
|
10964
|
+
"- Logging tanpa secret/PII.",
|
|
10965
|
+
"- Tanpa helper/duplikasi untuk satu pemakaian; ekstrak hanya bila berulang."
|
|
10966
|
+
],
|
|
10967
|
+
integration: [
|
|
10968
|
+
"- Mock dihapus dari jalur utama.",
|
|
10969
|
+
"- Kontrak CONTRACT-XXX sama dengan implementasi.",
|
|
10970
|
+
"- E2E memakai data nyata.",
|
|
10971
|
+
"- Error path diuji.",
|
|
10972
|
+
"- Tanpa layer/abstraksi tambahan; hubungkan langsung ke kontrak."
|
|
10973
|
+
],
|
|
10974
|
+
verification: [
|
|
10975
|
+
"- Jalankan semua verificationCommand sampai exit 0.",
|
|
10976
|
+
"- Smoke route/navigasi utama.",
|
|
10977
|
+
"- UI states dan responsive dicek.",
|
|
10978
|
+
"- Bukti Acceptance Criteria \xA711.",
|
|
10979
|
+
"- Jangan menambah kode produksi baru hanya untuk verifikasi."
|
|
10980
|
+
]
|
|
10981
|
+
};
|
|
10982
|
+
async function loadTasks(bundleDir) {
|
|
10983
|
+
const tasksDir = join5(bundleDir, "tasks");
|
|
10984
|
+
let entries;
|
|
10985
|
+
try {
|
|
10986
|
+
entries = await readdir3(tasksDir, { withFileTypes: true });
|
|
10987
|
+
} catch (error) {
|
|
10988
|
+
if (isMissingFile3(error)) throw new Error(`Direktori tasks/ tidak ditemukan di ${bundleDir}`);
|
|
10989
|
+
throw error;
|
|
10990
|
+
}
|
|
10991
|
+
const names = entries.filter(
|
|
10992
|
+
(entry) => entry.isFile() && entry.name.toLowerCase().endsWith(".md") && entry.name.toUpperCase() !== "TASKS.MD"
|
|
10993
|
+
).map((entry) => entry.name).sort();
|
|
10994
|
+
const tasks = [];
|
|
10995
|
+
if (names.length > 0) {
|
|
10996
|
+
for (const name of names) {
|
|
10997
|
+
const content = await readFile5(join5(tasksDir, name), "utf8");
|
|
10998
|
+
tasks.push(parseSingleTask(name, content));
|
|
10999
|
+
}
|
|
11000
|
+
} else {
|
|
11001
|
+
const singlePath = join5(tasksDir, "TASKS.md");
|
|
11002
|
+
let content;
|
|
11003
|
+
try {
|
|
11004
|
+
content = await readFile5(singlePath, "utf8");
|
|
11005
|
+
} catch (error) {
|
|
11006
|
+
if (isMissingFile3(error)) throw new Error(`Tidak ada berkas task di ${tasksDir}`);
|
|
11007
|
+
throw error;
|
|
10823
11008
|
}
|
|
11009
|
+
tasks.push(...parseSingleFile(content));
|
|
10824
11010
|
}
|
|
10825
|
-
if (
|
|
10826
|
-
|
|
11011
|
+
if (tasks.length === 0) throw new Error(`Tidak ada task yang bisa dibaca di ${tasksDir}`);
|
|
11012
|
+
assertUniqueIds(tasks);
|
|
11013
|
+
return tasks;
|
|
11014
|
+
}
|
|
11015
|
+
function parseSingleTask(file, content) {
|
|
11016
|
+
const heading = firstHeading(content);
|
|
11017
|
+
const explicit = TASK_ID_RE2.exec(file)?.[0] ?? explicitIdFromContent(content);
|
|
11018
|
+
const id = explicit ?? file.replace(/\.md$/i, "");
|
|
11019
|
+
if (id.length === 0) {
|
|
11020
|
+
throw new Error(`Berkas task tanpa ID: ${file}`);
|
|
10827
11021
|
}
|
|
10828
|
-
return
|
|
11022
|
+
return buildTask(id, heading, file, content);
|
|
10829
11023
|
}
|
|
10830
|
-
|
|
10831
|
-
const
|
|
10832
|
-
const
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
11024
|
+
function explicitIdFromContent(content) {
|
|
11025
|
+
const heading = firstHeading(content);
|
|
11026
|
+
const fromHeading = heading !== null ? TASK_ID_RE2.exec(heading)?.[0] : void 0;
|
|
11027
|
+
if (fromHeading !== void 0) return fromHeading;
|
|
11028
|
+
return /(?:\*\*)?ID(?:\*\*)?\s*[:=]\s*`?((?:TASK|T)-\d{3,})/i.exec(content)?.[1];
|
|
11029
|
+
}
|
|
11030
|
+
function parseSingleFile(content) {
|
|
11031
|
+
const blocks = content.split(/\n(?=#{1,4}\s+(?:TASK|T)-\d{3,}\b)/i);
|
|
11032
|
+
const tasks = [];
|
|
11033
|
+
for (const block of blocks) {
|
|
11034
|
+
const heading = firstHeading(block);
|
|
11035
|
+
const id = heading !== null ? TASK_ID_RE2.exec(heading)?.[0] : void 0;
|
|
11036
|
+
if (id === void 0) continue;
|
|
11037
|
+
tasks.push(buildTask(id, heading, "TASKS.md", block));
|
|
10839
11038
|
}
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
if (definition === void 0) continue;
|
|
10848
|
-
const current = await hashesFor(definition);
|
|
10849
|
-
const preExisting = Object.keys(current.hashes).filter((path) => !done.has(path));
|
|
10850
|
-
if (preExisting.length === 0) continue;
|
|
10851
|
-
findings.push({
|
|
10852
|
-
code: "PRE_EXISTING_SCOPE",
|
|
10853
|
-
severity: "info",
|
|
10854
|
-
taskRef: task.ref,
|
|
10855
|
-
message: `Scope ${task.ref} sudah berisi file sebelum task dimulai. Bila ini hasil Figma MCP/AI Studio/editor lain, verifikasi lalu \`jioogen task adopt ${task.ref}\`; bila belum, \`jioogen task start ${task.ref}\`.`,
|
|
10856
|
-
files: preExisting.slice(0, 8)
|
|
10857
|
-
});
|
|
11039
|
+
return tasks;
|
|
11040
|
+
}
|
|
11041
|
+
function buildTask(id, heading, file, content) {
|
|
11042
|
+
const context = parseTaskContext(content, id);
|
|
11043
|
+
const layer = resolveLayer(context.layer);
|
|
11044
|
+
if (context.layer !== void 0 && layer === void 0) {
|
|
11045
|
+
throw new Error(`Task ${context.taskId} punya layer tidak dikenal: ${context.layer.trim()}`);
|
|
10858
11046
|
}
|
|
10859
|
-
return
|
|
11047
|
+
return {
|
|
11048
|
+
// Prefer the declared `id:` so `T-001-x.md` + `dependsOn: [TASK-001]` agree.
|
|
11049
|
+
id: context.taskId,
|
|
11050
|
+
title: titleFromGoal(content) ?? titleFromHeading(heading) ?? context.taskId,
|
|
11051
|
+
file,
|
|
11052
|
+
content: content.trim(),
|
|
11053
|
+
layer,
|
|
11054
|
+
phase: context.phase ?? 1,
|
|
11055
|
+
checkpoint: context.checkpoint === true,
|
|
11056
|
+
dependsOn: context.dependsOn
|
|
11057
|
+
};
|
|
10860
11058
|
}
|
|
10861
|
-
function
|
|
10862
|
-
const
|
|
10863
|
-
|
|
10864
|
-
|
|
11059
|
+
function renderActiveTask(task, context) {
|
|
11060
|
+
const lines = [
|
|
11061
|
+
"## TASK AKTIF \u2014 PRIORITASKAN INI (satu task per giliran)",
|
|
11062
|
+
`ref: ${task.id}`,
|
|
11063
|
+
`title: ${task.title}`,
|
|
11064
|
+
`layer: ${task.layer ?? "-"} | phase: ${task.phase} | checkpoint: ${task.checkpoint}`,
|
|
11065
|
+
`file: tasks/${task.file}`
|
|
11066
|
+
];
|
|
11067
|
+
if (task.dependsOn.length > 0) lines.push(`dependsOn: ${task.dependsOn.join(", ")}`);
|
|
11068
|
+
lines.push(
|
|
11069
|
+
"",
|
|
11070
|
+
"Aturan mengikat:",
|
|
11071
|
+
"- Kerjakan HANYA task ini sampai semua Acceptance Criteria terpenuhi dan verificationCommand exit 0.",
|
|
11072
|
+
"- Jangan pindah task, jangan mengerjakan task lain, jangan melebar ke file di luar targetFiles (file/direktori/glob).",
|
|
11073
|
+
"- Jangan mengarang fitur/endpoint/kolom di luar PRD.md/specs/.",
|
|
11074
|
+
"- Detail implementasi (pola, struktur file dalam scope, library yang sudah ada) milikmu; ikuti konvensi proyek.",
|
|
11075
|
+
"- Jangan mengubah PRD.md/specs/kontrak. Butuh perubahan kontrak? STOP dan laporkan.",
|
|
11076
|
+
"- Selesai: `npx jioogen task complete <ref>`, lalu `npx jioogen sync`."
|
|
11077
|
+
);
|
|
11078
|
+
const checklist = renderQualityChecklist(task.layer, context);
|
|
11079
|
+
if (checklist.length > 0) lines.push("", ...checklist);
|
|
11080
|
+
const breakdown = buildTaskBreakdown(task);
|
|
11081
|
+
const breakdownLines = [...breakdown.authored, ...breakdown.derived];
|
|
11082
|
+
if (breakdownLines.length > 0) {
|
|
11083
|
+
lines.push("", BREAKDOWN_HEADING, ...BREAKDOWN_RULES);
|
|
11084
|
+
for (const item of breakdownLines) lines.push(`- [ ] ${item}`);
|
|
11085
|
+
}
|
|
11086
|
+
lines.push("", "--- ISI TASK (otoritas scope) ---", task.content, "--- AKHIR ISI TASK ---");
|
|
11087
|
+
if (context?.bundleDir !== void 0) {
|
|
11088
|
+
const preferencesBlock = buildCustomPreferencesBlock(context.bundleDir);
|
|
11089
|
+
if (preferencesBlock.length > 0) lines.push("", preferencesBlock);
|
|
11090
|
+
const knowledgeBlock = buildCustomKnowledgeBlock(context.bundleDir);
|
|
11091
|
+
if (knowledgeBlock.length > 0) lines.push("", knowledgeBlock);
|
|
11092
|
+
}
|
|
11093
|
+
return lines.join("\n");
|
|
10865
11094
|
}
|
|
10866
|
-
|
|
10867
|
-
const
|
|
10868
|
-
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
|
|
10876
|
-
|
|
11095
|
+
function buildTaskBreakdown(task) {
|
|
11096
|
+
const context = parseTaskContext(task.content, task.id);
|
|
11097
|
+
const authored = (context.subtasks ?? []).filter((item) => !/^N\/A\b/i.test(item));
|
|
11098
|
+
const derived = [];
|
|
11099
|
+
const seen = /* @__PURE__ */ new Set();
|
|
11100
|
+
const push = (item) => {
|
|
11101
|
+
const key = item.trim().toLowerCase();
|
|
11102
|
+
if (key.length === 0 || seen.has(key)) return;
|
|
11103
|
+
seen.add(key);
|
|
11104
|
+
derived.push(item);
|
|
11105
|
+
};
|
|
11106
|
+
for (const subfeature of context.subfeatures ?? []) {
|
|
11107
|
+
push(`${subfeature} \u2014 petakan ke AC, flow/state, dan targetFiles`);
|
|
11108
|
+
}
|
|
11109
|
+
for (const acceptance of context.acceptance ?? []) {
|
|
11110
|
+
if (/^N\/A\b/i.test(acceptance)) continue;
|
|
11111
|
+
push(`${acceptance} \u2014 penuhi + catat bukti`);
|
|
11112
|
+
}
|
|
11113
|
+
for (const flow of context.flowRef ?? []) {
|
|
11114
|
+
push(`${flow} \u2014 implement alur sampai outcome`);
|
|
11115
|
+
}
|
|
11116
|
+
for (const lifecycle of context.lifecycleRefs ?? []) {
|
|
11117
|
+
push(`Lifecycle ${lifecycle} \u2014 state/transition yang relevan`);
|
|
11118
|
+
}
|
|
11119
|
+
for (const engine of context.engineRef ?? []) {
|
|
11120
|
+
push(`Engine ${engine} \u2014 invariant/keputusan yang dijaga`);
|
|
11121
|
+
}
|
|
11122
|
+
for (const state of context.uiStates ?? []) {
|
|
11123
|
+
push(`UI state ${state} \u2014 render + verifikasi`);
|
|
11124
|
+
}
|
|
11125
|
+
for (const isolation of context.isolationRefs ?? []) {
|
|
11126
|
+
push(`${isolation} \u2014 tegakkan boundary + AC penolakan akses`);
|
|
11127
|
+
}
|
|
11128
|
+
for (const file of context.targetFiles ?? []) {
|
|
11129
|
+
push(`File ${file} \u2014 buat/edit + test terkait`);
|
|
11130
|
+
}
|
|
11131
|
+
if (context.verificationCommand !== null && context.verificationCommand !== void 0) {
|
|
11132
|
+
push(`Verifikasi: \`${context.verificationCommand}\` (wajib exit 0)`);
|
|
11133
|
+
}
|
|
11134
|
+
if (authored.length === 0 && derived.length === 0) {
|
|
11135
|
+
push("Baca task + PRD/specs, lalu tulis langkah kerja eksplisit sebelum edit");
|
|
11136
|
+
}
|
|
11137
|
+
return { authored, derived };
|
|
11138
|
+
}
|
|
11139
|
+
function renderQualityChecklist(layer, context) {
|
|
11140
|
+
if (context === void 0 || layer === void 0) return [];
|
|
11141
|
+
const items = [...LAYER_CHECKLISTS[layer] ?? []];
|
|
11142
|
+
if (layer === "frontend_mock") {
|
|
11143
|
+
const references = UI_SKILLS.filter((skill) => context.skills?.includes(skill) === true);
|
|
11144
|
+
if (references.length > 0) items.push(`- Referensi skill: ${references.join(", ")}`);
|
|
11145
|
+
}
|
|
11146
|
+
if (items.length === 0) return [];
|
|
11147
|
+
return [QUALITY_HEADING, ...items.slice(0, MAX_CHECKLIST_LINES)];
|
|
11148
|
+
}
|
|
11149
|
+
function resolveLayer(value) {
|
|
11150
|
+
if (value === void 0) return void 0;
|
|
11151
|
+
const token = value.trim().replace(/[`*]/g, "").split(/[\s,(]/)[0];
|
|
11152
|
+
if (token === void 0) return void 0;
|
|
11153
|
+
return TASK_LAYERS.includes(token) ? token : void 0;
|
|
11154
|
+
}
|
|
11155
|
+
function titleFromGoal(content) {
|
|
11156
|
+
const match = /goal\s*\*{0,2}\s*[:=]\s*\*{0,2}\s*([^\n]+)/i.exec(content);
|
|
11157
|
+
if (match?.[1] === void 0) return null;
|
|
11158
|
+
return stripMarkup(match[1]);
|
|
11159
|
+
}
|
|
11160
|
+
function firstHeading(content) {
|
|
11161
|
+
return HEADING_RE.exec(content)?.[1]?.trim() ?? null;
|
|
11162
|
+
}
|
|
11163
|
+
function titleFromHeading(heading) {
|
|
11164
|
+
if (heading === null) return null;
|
|
11165
|
+
const withoutId = heading.replace(/^(?:TASK|T)-\d{3,}\s*[—–:-]?\s*/i, "").trim();
|
|
11166
|
+
return withoutId.length > 0 ? withoutId : heading;
|
|
11167
|
+
}
|
|
11168
|
+
function stripMarkup(text2) {
|
|
11169
|
+
return text2.replace(/[`*_]/g, "").replace(/^["'\s]+|["'\s]+$/g, "").trim();
|
|
11170
|
+
}
|
|
11171
|
+
function assertUniqueIds(tasks) {
|
|
11172
|
+
const seen = /* @__PURE__ */ new Set();
|
|
11173
|
+
for (const task of tasks) {
|
|
11174
|
+
const base = task.id.toUpperCase();
|
|
11175
|
+
if (!seen.has(base)) {
|
|
11176
|
+
seen.add(base);
|
|
11177
|
+
continue;
|
|
10877
11178
|
}
|
|
10878
|
-
|
|
11179
|
+
let suffix = 2;
|
|
11180
|
+
let key = `${base}-DUP-${suffix}`;
|
|
11181
|
+
while (seen.has(key)) {
|
|
11182
|
+
suffix += 1;
|
|
11183
|
+
key = `${base}-DUP-${suffix}`;
|
|
11184
|
+
}
|
|
11185
|
+
seen.add(key);
|
|
11186
|
+
task.id = `${task.id}-DUP-${suffix}`;
|
|
11187
|
+
console.warn(
|
|
11188
|
+
`[jioogen] WARNING: ID task duplikat di tasks/${task.file}: "${base}" sudah dipakai \u2014 dilanjutkan sebagai "${task.id}". Rename file dan id-nya ke TASK unik agar warning hilang.`
|
|
11189
|
+
);
|
|
10879
11190
|
}
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
11191
|
+
}
|
|
11192
|
+
function orderTasks(tasks) {
|
|
11193
|
+
return [...tasks].sort(
|
|
11194
|
+
(left, right) => left.phase - right.phase || layerRank(left.layer) - layerRank(right.layer) || numericId(left.id) - numericId(right.id) || left.id.localeCompare(right.id)
|
|
11195
|
+
);
|
|
11196
|
+
}
|
|
11197
|
+
function layerRank(layer) {
|
|
11198
|
+
return layer === void 0 ? 0 : LAYER_RANK[layer] ?? 0;
|
|
11199
|
+
}
|
|
11200
|
+
function numericId(id) {
|
|
11201
|
+
const leading = /^(\d+)/.exec(id);
|
|
11202
|
+
if (leading?.[1] !== void 0) return Number.parseInt(leading[1], 10);
|
|
11203
|
+
const trailing = /(?:^|[-\s])(\d{3,})$/.exec(id);
|
|
11204
|
+
return trailing?.[1] !== void 0 ? Number.parseInt(trailing[1], 10) : Number.MAX_SAFE_INTEGER;
|
|
11205
|
+
}
|
|
11206
|
+
function selectNext(tasks, states, options) {
|
|
11207
|
+
const byRef = new Map(states.map((state) => [state.ref.toUpperCase(), state]));
|
|
11208
|
+
const ordered = orderTasks(tasks);
|
|
11209
|
+
for (const task of ordered) {
|
|
11210
|
+
const state = byRef.get(task.id.toUpperCase());
|
|
11211
|
+
if (state !== void 0 && IN_PROGRESS.includes(state.status)) {
|
|
11212
|
+
return { task, state, reason: "in_progress" };
|
|
11213
|
+
}
|
|
10884
11214
|
}
|
|
10885
|
-
|
|
11215
|
+
for (const task of ordered) {
|
|
11216
|
+
const state = byRef.get(task.id.toUpperCase());
|
|
11217
|
+
if (state?.status === "done") continue;
|
|
11218
|
+
if (hasUnfinishedDependency(task, byRef) && options?.lenient !== true) continue;
|
|
11219
|
+
const effective = state ?? { ref: task.id, status: "todo" };
|
|
11220
|
+
return { task, state: effective, reason: effective.status === "todo" ? "todo" : "retry" };
|
|
11221
|
+
}
|
|
11222
|
+
return null;
|
|
10886
11223
|
}
|
|
10887
|
-
async function
|
|
10888
|
-
const
|
|
10889
|
-
if (
|
|
10890
|
-
|
|
10891
|
-
const
|
|
10892
|
-
if (
|
|
10893
|
-
|
|
10894
|
-
|
|
11224
|
+
async function taskTargetFilesExist(bundleDir, task) {
|
|
11225
|
+
const targets = task.targetFiles ?? targetFilesFromContent(task.content);
|
|
11226
|
+
if (targets.length === 0) return false;
|
|
11227
|
+
for (const raw of targets) {
|
|
11228
|
+
const cleaned = raw.trim().replace(/^`+|`+$/g, "").replace(/^\.\//, "");
|
|
11229
|
+
if (cleaned.length === 0) continue;
|
|
11230
|
+
const staticPart = cleaned.replace(/[*?[][\s\S]*$/, "").replace(/\/+$/, "");
|
|
11231
|
+
const testPath = staticPart.length > 0 ? staticPart : cleaned;
|
|
11232
|
+
const fullPath = isAbsolute(testPath) ? testPath : join5(bundleDir, testPath);
|
|
11233
|
+
try {
|
|
11234
|
+
await stat2(fullPath);
|
|
11235
|
+
return true;
|
|
11236
|
+
} catch {
|
|
11237
|
+
}
|
|
11238
|
+
}
|
|
11239
|
+
return false;
|
|
11240
|
+
}
|
|
11241
|
+
async function reconcileCodebase(bundleDir, definitions, state) {
|
|
11242
|
+
let currentState = state;
|
|
11243
|
+
const adopted = [];
|
|
11244
|
+
const remaining = [];
|
|
11245
|
+
for (const task of definitions) {
|
|
11246
|
+
const existingTask = currentState.tasks.find(
|
|
11247
|
+
(t) => t.ref.toUpperCase() === task.id.toUpperCase()
|
|
11248
|
+
);
|
|
11249
|
+
if (existingTask?.status === "done") {
|
|
11250
|
+
continue;
|
|
11251
|
+
}
|
|
11252
|
+
const filesExist = await taskTargetFilesExist(bundleDir, task);
|
|
11253
|
+
if (filesExist) {
|
|
11254
|
+
currentState = withStatus(currentState, task.id, "done", {
|
|
11255
|
+
note: "reconciled: target files exist on disk",
|
|
11256
|
+
awaitingCheckpoint: false
|
|
11257
|
+
});
|
|
11258
|
+
currentState = setTaskSource(currentState, task.id, "user");
|
|
11259
|
+
currentState = appendTaskEvidence(currentState, task.id, {
|
|
11260
|
+
type: "text",
|
|
11261
|
+
summary: "reconciled from codebase: target files found on disk",
|
|
11262
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
11263
|
+
});
|
|
11264
|
+
adopted.push(task.id);
|
|
11265
|
+
} else {
|
|
11266
|
+
remaining.push(task.id);
|
|
11267
|
+
}
|
|
11268
|
+
}
|
|
11269
|
+
return {
|
|
11270
|
+
state: currentState,
|
|
11271
|
+
result: {
|
|
11272
|
+
adopted,
|
|
11273
|
+
remaining,
|
|
11274
|
+
total: definitions.length
|
|
11275
|
+
}
|
|
11276
|
+
};
|
|
11277
|
+
}
|
|
11278
|
+
function blockedTasks(tasks, states) {
|
|
11279
|
+
const byRef = new Map(states.map((state) => [state.ref.toUpperCase(), state]));
|
|
11280
|
+
return orderTasks(tasks).filter((task) => byRef.get(task.id.toUpperCase())?.status !== "done").map((task) => ({
|
|
11281
|
+
task,
|
|
11282
|
+
missing: task.dependsOn.filter(
|
|
11283
|
+
(dependency) => byRef.get(dependency.toUpperCase())?.status !== "done"
|
|
11284
|
+
)
|
|
11285
|
+
})).filter((entry) => entry.missing.length > 0);
|
|
11286
|
+
}
|
|
11287
|
+
function hasUnfinishedDependency(task, byRef) {
|
|
11288
|
+
return task.dependsOn.some(
|
|
11289
|
+
(dependency) => byRef.get(dependency.toUpperCase())?.status !== "done"
|
|
11290
|
+
);
|
|
11291
|
+
}
|
|
11292
|
+
function isBoundary(previous, next) {
|
|
11293
|
+
if (next.checkpoint) return true;
|
|
11294
|
+
if (previous.layer !== void 0 && next.layer !== void 0 && previous.layer !== next.layer) {
|
|
11295
|
+
return true;
|
|
11296
|
+
}
|
|
11297
|
+
return previous.phase !== void 0 && next.phase !== previous.phase;
|
|
11298
|
+
}
|
|
11299
|
+
var RISKY_TASK_RE = /\b(migrat(?:e|ion|ions)?|migrasi|prisma|schema|rls|auth|permission|payment|checkout|webhook|secret|deploy|drop)\b/i;
|
|
11300
|
+
var TARGET_FILES_LABEL_RE2 = /^\s*(?:[-*]\s*)?\*{0,2}targetFiles\*{0,2}\s*:\s*(.*)$/i;
|
|
11301
|
+
function isRiskyTask(task) {
|
|
11302
|
+
const targetFiles = task.targetFiles ?? targetFilesFromContent(task.content);
|
|
11303
|
+
return RISKY_TASK_RE.test([task.id, task.title, ...targetFiles].join("\n"));
|
|
11304
|
+
}
|
|
11305
|
+
function targetFilesFromContent(content) {
|
|
11306
|
+
const lines = content.split(/\r?\n/);
|
|
11307
|
+
const index = lines.findIndex((line) => TARGET_FILES_LABEL_RE2.test(line));
|
|
11308
|
+
if (index === -1) return [];
|
|
11309
|
+
const inline = (lines[index]?.match(TARGET_FILES_LABEL_RE2)?.[1] ?? "").trim();
|
|
11310
|
+
if (inline.length > 0) return splitTargetFiles(inline);
|
|
11311
|
+
const items = [];
|
|
11312
|
+
for (let cursor = index + 1; cursor < lines.length; cursor += 1) {
|
|
11313
|
+
const line = lines[cursor] ?? "";
|
|
11314
|
+
if (line.trim().length === 0) continue;
|
|
11315
|
+
const item = /^\s*-\s+(.+?)\s*$/.exec(line);
|
|
11316
|
+
if (item === null) break;
|
|
11317
|
+
const cleaned = cleanTargetFile(item[1] ?? "");
|
|
11318
|
+
if (cleaned.length > 0) items.push(cleaned);
|
|
11319
|
+
}
|
|
11320
|
+
return items;
|
|
11321
|
+
}
|
|
11322
|
+
function splitTargetFiles(value) {
|
|
11323
|
+
return value.replace(/[[\]`]/g, "").split(",").map(cleanTargetFile).filter((part) => part.length > 0 && !/^(?:\(?none\)?|n\/a|-+)$/i.test(part));
|
|
11324
|
+
}
|
|
11325
|
+
function cleanTargetFile(value) {
|
|
11326
|
+
return value.replace(/^[-*\s]+/, "").trim();
|
|
11327
|
+
}
|
|
11328
|
+
function verificationCommandFromContent(content) {
|
|
11329
|
+
const inline = content.match(
|
|
11330
|
+
/^\s*(?:[-*]\s*)?\*{0,2}verificationCommand\*{0,2}\s*:\s*(.+?)\s*$/im
|
|
11331
|
+
);
|
|
11332
|
+
if (inline?.[1] !== void 0) {
|
|
11333
|
+
const value = stripVerificationBackticks(inline[1].trim());
|
|
11334
|
+
if (isVerificationPlaceholder(value)) return null;
|
|
11335
|
+
if (value.length > 0) return value;
|
|
11336
|
+
}
|
|
11337
|
+
const lines = content.split(/\r?\n/);
|
|
11338
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
11339
|
+
const heading = lines[i]?.trim() ?? "";
|
|
11340
|
+
if (!/^#{1,6}\s+Verification(?:\s+Command)?\s*$/i.test(heading)) continue;
|
|
11341
|
+
for (let j = i + 1; j < lines.length; j += 1) {
|
|
11342
|
+
const next = (lines[j] ?? "").trim();
|
|
11343
|
+
if (next.length === 0) continue;
|
|
11344
|
+
if (/^#{1,6}\s/.test(next)) break;
|
|
11345
|
+
const value = stripVerificationBackticks(next);
|
|
11346
|
+
if (isVerificationPlaceholder(value)) return null;
|
|
11347
|
+
return value.length > 0 ? value : null;
|
|
10895
11348
|
}
|
|
10896
|
-
return info.isFile() ? [pattern] : [];
|
|
10897
11349
|
}
|
|
10898
|
-
|
|
10899
|
-
const start = staticPrefix(pattern);
|
|
10900
|
-
const walked = await walk(bundleDir, start, MAX_TARGET_FILES);
|
|
10901
|
-
return walked.files.filter((file) => matcher.test(file));
|
|
10902
|
-
}
|
|
10903
|
-
function normalizePattern(raw) {
|
|
10904
|
-
let value = raw.trim().replace(/^`+|`+$/g, "").replace(/\\/g, "/");
|
|
10905
|
-
value = value.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
10906
|
-
if (value.length === 0 || isAbsolute(value)) return null;
|
|
10907
|
-
if (value.split("/").includes("..")) return null;
|
|
10908
|
-
return value;
|
|
11350
|
+
return null;
|
|
10909
11351
|
}
|
|
10910
|
-
function
|
|
10911
|
-
const
|
|
10912
|
-
|
|
10913
|
-
const trimmed = head.replace(/\/+$/, "");
|
|
10914
|
-
if (trimmed.length === 0) return "";
|
|
10915
|
-
if (head.endsWith("/")) return trimmed;
|
|
10916
|
-
const slash = trimmed.lastIndexOf("/");
|
|
10917
|
-
return slash === -1 ? "" : trimmed.slice(0, slash);
|
|
11352
|
+
function normalizeVerificationCommand(value) {
|
|
11353
|
+
const stripped = stripVerificationBackticks(value.trim());
|
|
11354
|
+
return stripped.replace(/\b(?:pnpm|yarn|bun|npm)\s+(?:run\s+)?/g, "npm run ").replace(/\bnpx\s+/g, "npm exec ").replace(/\s+--(?:run|silent)\b/g, "").replace(/\s+-s\b/g, "").replace(/\s+--reporter(?:=\S+|\s+\S+)/g, "").replace(/\s+/g, " ").trim();
|
|
10918
11355
|
}
|
|
10919
|
-
function
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
const
|
|
10923
|
-
|
|
10924
|
-
|
|
10925
|
-
|
|
10926
|
-
source += "(?:.*/)?";
|
|
10927
|
-
index += 2;
|
|
10928
|
-
} else {
|
|
10929
|
-
source += ".*";
|
|
10930
|
-
index += 1;
|
|
10931
|
-
}
|
|
10932
|
-
} else {
|
|
10933
|
-
source += "[^/]*";
|
|
10934
|
-
}
|
|
10935
|
-
} else if (char === "?") {
|
|
10936
|
-
source += "[^/]";
|
|
10937
|
-
} else if ("\\^$+.()|{}[]".includes(char)) {
|
|
10938
|
-
source += `\\${char}`;
|
|
10939
|
-
} else {
|
|
10940
|
-
source += char;
|
|
11356
|
+
function stripVerificationBackticks(value) {
|
|
11357
|
+
const trimmed = value.replace(/^`+/, "").replace(/`+$/, "").trim();
|
|
11358
|
+
if (trimmed.length >= 2) {
|
|
11359
|
+
const first = trimmed[0];
|
|
11360
|
+
const last = trimmed[trimmed.length - 1];
|
|
11361
|
+
if (first === '"' && last === '"' || first === "'" && last === "'") {
|
|
11362
|
+
return trimmed.slice(1, -1).trim();
|
|
10941
11363
|
}
|
|
10942
11364
|
}
|
|
10943
|
-
return
|
|
10944
|
-
}
|
|
10945
|
-
async function walk(bundleDir, start, limit) {
|
|
10946
|
-
const files = [];
|
|
10947
|
-
let truncated = false;
|
|
10948
|
-
const visit = async (relative2) => {
|
|
10949
|
-
if (truncated) return;
|
|
10950
|
-
let entries;
|
|
10951
|
-
try {
|
|
10952
|
-
entries = await readdir4(relative2.length === 0 ? bundleDir : join5(bundleDir, relative2), {
|
|
10953
|
-
withFileTypes: true
|
|
10954
|
-
});
|
|
10955
|
-
} catch {
|
|
10956
|
-
return;
|
|
10957
|
-
}
|
|
10958
|
-
entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
10959
|
-
for (const entry of entries) {
|
|
10960
|
-
const child = relative2.length === 0 ? entry.name : `${relative2}/${entry.name}`;
|
|
10961
|
-
if (entry.isDirectory()) {
|
|
10962
|
-
if (IGNORED_DIRS.has(entry.name)) continue;
|
|
10963
|
-
if (child === "tasks/.execution") continue;
|
|
10964
|
-
await visit(child);
|
|
10965
|
-
} else if (entry.isFile()) {
|
|
10966
|
-
if (files.length >= limit) {
|
|
10967
|
-
truncated = true;
|
|
10968
|
-
return;
|
|
10969
|
-
}
|
|
10970
|
-
files.push(child);
|
|
10971
|
-
}
|
|
10972
|
-
}
|
|
10973
|
-
};
|
|
10974
|
-
await visit(start);
|
|
10975
|
-
return { files, truncated };
|
|
11365
|
+
return trimmed;
|
|
10976
11366
|
}
|
|
10977
|
-
|
|
10978
|
-
|
|
10979
|
-
if (info === null || !info.isFile()) return null;
|
|
10980
|
-
return `${info.size}:${Math.trunc(info.mtimeMs)}`;
|
|
11367
|
+
function isVerificationPlaceholder(value) {
|
|
11368
|
+
return /^(?:n\/a|—+|-+|none)$/i.test(value.trim());
|
|
10981
11369
|
}
|
|
10982
|
-
|
|
10983
|
-
|
|
10984
|
-
|
|
10985
|
-
|
|
11370
|
+
var CUSTOM_PREFERENCES_HEADER = "## USER CUSTOM PREFERENCES & STACK (.jioogen/custom/)";
|
|
11371
|
+
function buildCustomPreferencesBlock(bundleDir) {
|
|
11372
|
+
const parts = [];
|
|
11373
|
+
const stackFile = join5(bundleDir, ".jioogen", "custom", "stack", "STACK.md");
|
|
10986
11374
|
try {
|
|
10987
|
-
const
|
|
10988
|
-
|
|
11375
|
+
const stackContent = readFileSync(stackFile, "utf8").trim();
|
|
11376
|
+
if (stackContent.length > 0) {
|
|
11377
|
+
parts.push(`### User Custom Stack (.jioogen/custom/stack/STACK.md)
|
|
11378
|
+
${stackContent}`);
|
|
11379
|
+
}
|
|
10989
11380
|
} catch {
|
|
10990
|
-
return null;
|
|
10991
11381
|
}
|
|
10992
|
-
|
|
10993
|
-
async function statMaybe(path) {
|
|
11382
|
+
const designFile = join5(bundleDir, ".jioogen", "custom", "design", "DESIGN.md");
|
|
10994
11383
|
try {
|
|
10995
|
-
|
|
11384
|
+
const designContent = readFileSync(designFile, "utf8").trim();
|
|
11385
|
+
if (designContent.length > 0) {
|
|
11386
|
+
parts.push(`### User Custom Design (.jioogen/custom/design/DESIGN.md)
|
|
11387
|
+
${designContent}`);
|
|
11388
|
+
}
|
|
10996
11389
|
} catch {
|
|
10997
|
-
return null;
|
|
10998
|
-
}
|
|
10999
|
-
}
|
|
11000
|
-
function diffHashes(before, after) {
|
|
11001
|
-
const changed = /* @__PURE__ */ new Set();
|
|
11002
|
-
for (const [path, hash] of Object.entries(before)) {
|
|
11003
|
-
if (after[path] !== hash) changed.add(path);
|
|
11004
|
-
}
|
|
11005
|
-
for (const path of Object.keys(after)) {
|
|
11006
|
-
if (!(path in before)) changed.add(path);
|
|
11007
11390
|
}
|
|
11008
|
-
|
|
11391
|
+
if (parts.length === 0) return "";
|
|
11392
|
+
return [
|
|
11393
|
+
CUSTOM_PREFERENCES_HEADER,
|
|
11394
|
+
"Perhatikan preferensi teknologi dan arsitektur custom user di bawah ini saat mengeksekusi task:",
|
|
11395
|
+
...parts
|
|
11396
|
+
].join("\n\n");
|
|
11009
11397
|
}
|
|
11010
|
-
|
|
11011
|
-
const
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11398
|
+
function listCustomKnowledgeFiles(bundleDir) {
|
|
11399
|
+
const dir = join5(bundleDir, ".jioogen", "custom", "knowledge");
|
|
11400
|
+
let entries;
|
|
11401
|
+
try {
|
|
11402
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
11403
|
+
} catch {
|
|
11404
|
+
return [];
|
|
11015
11405
|
}
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
|
|
11022
|
-
|
|
11406
|
+
const names = entries.filter((entry) => entry.isFile() && entry.name.toLowerCase().endsWith(".md")).map((entry) => entry.name).sort();
|
|
11407
|
+
const result = [];
|
|
11408
|
+
for (const name of names) {
|
|
11409
|
+
if (result.length >= MAX_CUSTOM_KNOWLEDGE_FILES) break;
|
|
11410
|
+
const full = join5(dir, name);
|
|
11411
|
+
try {
|
|
11412
|
+
const content = readFileSync(full, "utf8");
|
|
11413
|
+
if (content.trim().length === 0) continue;
|
|
11414
|
+
} catch {
|
|
11415
|
+
continue;
|
|
11023
11416
|
}
|
|
11417
|
+
result.push(`.jioogen/custom/knowledge/${name}`);
|
|
11024
11418
|
}
|
|
11025
|
-
|
|
11026
|
-
for (const file of files.sort()) {
|
|
11027
|
-
const hash = await hashRelative(bundleDir, file);
|
|
11028
|
-
if (hash !== null) lines.push(`${file}\0${hash}`);
|
|
11029
|
-
}
|
|
11030
|
-
return createHash("sha256").update(lines.join("\n")).digest("hex");
|
|
11419
|
+
return result.slice(0, MAX_CUSTOM_KNOWLEDGE_FILES);
|
|
11031
11420
|
}
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
|
|
11035
|
-
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
|
|
11040
|
-
|
|
11041
|
-
return join6(bundleDir, EXECUTION_SIDECAR_PATH);
|
|
11421
|
+
function buildCustomKnowledgeBlock(bundleDir) {
|
|
11422
|
+
const files = listCustomKnowledgeFiles(bundleDir);
|
|
11423
|
+
if (files.length === 0) return "";
|
|
11424
|
+
const lines = [
|
|
11425
|
+
CUSTOM_KNOWLEDGE_HEADER,
|
|
11426
|
+
...files.map((file) => `- ${file}`),
|
|
11427
|
+
"Baca file-file di atas sebagai konteks tambahan user sebelum coding."
|
|
11428
|
+
];
|
|
11429
|
+
return lines.join("\n");
|
|
11042
11430
|
}
|
|
11043
|
-
function
|
|
11044
|
-
return
|
|
11431
|
+
function isMissingFile3(error) {
|
|
11432
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
11045
11433
|
}
|
|
11046
|
-
|
|
11047
|
-
|
|
11048
|
-
|
|
11049
|
-
|
|
11050
|
-
|
|
11051
|
-
|
|
11052
|
-
|
|
11053
|
-
|
|
11054
|
-
|
|
11055
|
-
|
|
11056
|
-
|
|
11057
|
-
|
|
11058
|
-
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11062
|
-
|
|
11063
|
-
|
|
11064
|
-
|
|
11065
|
-
|
|
11066
|
-
|
|
11067
|
-
|
|
11434
|
+
|
|
11435
|
+
// src/drift.ts
|
|
11436
|
+
var DRIFT_BASELINE_PATH = join6("tasks", ".execution", "baseline.json");
|
|
11437
|
+
var BASELINE_VERSION = 1;
|
|
11438
|
+
var MAX_TARGET_FILES = 2e3;
|
|
11439
|
+
var MAX_BUNDLE_FILE_BYTES = 1048576;
|
|
11440
|
+
var IGNORED_DIRS = /* @__PURE__ */ new Set([
|
|
11441
|
+
".git",
|
|
11442
|
+
"node_modules",
|
|
11443
|
+
".next",
|
|
11444
|
+
"dist",
|
|
11445
|
+
"build",
|
|
11446
|
+
"coverage",
|
|
11447
|
+
".turbo",
|
|
11448
|
+
".cache",
|
|
11449
|
+
".vercel",
|
|
11450
|
+
".output",
|
|
11451
|
+
"out",
|
|
11452
|
+
".expo",
|
|
11453
|
+
".jioogen",
|
|
11454
|
+
".claude",
|
|
11455
|
+
".opencode",
|
|
11456
|
+
".agent",
|
|
11457
|
+
".codex",
|
|
11458
|
+
".cursor"
|
|
11459
|
+
]);
|
|
11460
|
+
var IGNORED_TOP_FILES = /* @__PURE__ */ new Set(["AGENTS.md"]);
|
|
11461
|
+
async function readAcknowledged(bundleDir) {
|
|
11462
|
+
let raw;
|
|
11463
|
+
try {
|
|
11464
|
+
raw = await readFile6(join6(bundleDir, "tasks", ".execution", "acknowledged.json"), "utf8");
|
|
11465
|
+
} catch {
|
|
11466
|
+
return null;
|
|
11068
11467
|
}
|
|
11468
|
+
let parsed;
|
|
11069
11469
|
try {
|
|
11070
|
-
|
|
11071
|
-
|
|
11072
|
-
return
|
|
11073
|
-
} finally {
|
|
11074
|
-
await handle.close().catch(() => {
|
|
11075
|
-
});
|
|
11076
|
-
await rm4(target, { force: true }).catch(() => {
|
|
11077
|
-
});
|
|
11470
|
+
parsed = JSON.parse(raw);
|
|
11471
|
+
} catch {
|
|
11472
|
+
return null;
|
|
11078
11473
|
}
|
|
11474
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
11475
|
+
const record = parsed;
|
|
11476
|
+
const marker = { at: typeof record.at === "string" ? record.at : "" };
|
|
11477
|
+
if (typeof record.pruned === "boolean") marker.pruned = record.pruned;
|
|
11478
|
+
if (typeof record.prd === "boolean") marker.prd = record.prd;
|
|
11479
|
+
if (typeof record.specs === "boolean") marker.specs = record.specs;
|
|
11480
|
+
if (typeof record.tasks === "boolean") marker.tasks = record.tasks;
|
|
11481
|
+
if (typeof record.note === "string") marker.note = record.note;
|
|
11482
|
+
return marker;
|
|
11483
|
+
}
|
|
11484
|
+
async function acknowledgeDrift(bundleDir, flags = {}, note, now = /* @__PURE__ */ new Date()) {
|
|
11485
|
+
const existing = await readAcknowledged(bundleDir);
|
|
11486
|
+
const merged = {
|
|
11487
|
+
pruned: flags.pruned === true || existing?.pruned === true,
|
|
11488
|
+
prd: flags.prd === true || existing?.prd === true,
|
|
11489
|
+
specs: flags.specs === true || existing?.specs === true,
|
|
11490
|
+
tasks: flags.tasks === true || existing?.tasks === true,
|
|
11491
|
+
at: now.toISOString()
|
|
11492
|
+
};
|
|
11493
|
+
const mergedNote = note ?? existing?.note;
|
|
11494
|
+
if (mergedNote !== void 0) merged.note = mergedNote;
|
|
11495
|
+
const target = join6(bundleDir, "tasks", ".execution", "acknowledged.json");
|
|
11496
|
+
await mkdir4(dirname4(target), { recursive: true });
|
|
11497
|
+
await writeFile4(target, `${JSON.stringify(merged, null, 2)}
|
|
11498
|
+
`, "utf8");
|
|
11499
|
+
return merged;
|
|
11079
11500
|
}
|
|
11080
|
-
|
|
11501
|
+
function baselinePath(bundleDir) {
|
|
11502
|
+
return join6(bundleDir, DRIFT_BASELINE_PATH);
|
|
11503
|
+
}
|
|
11504
|
+
async function readBaseline(bundleDir) {
|
|
11081
11505
|
let raw;
|
|
11082
11506
|
try {
|
|
11083
|
-
raw = await readFile6(
|
|
11084
|
-
} catch
|
|
11085
|
-
|
|
11086
|
-
throw error;
|
|
11507
|
+
raw = await readFile6(baselinePath(bundleDir), "utf8");
|
|
11508
|
+
} catch {
|
|
11509
|
+
return null;
|
|
11087
11510
|
}
|
|
11088
|
-
let
|
|
11511
|
+
let parsed;
|
|
11089
11512
|
try {
|
|
11090
|
-
|
|
11513
|
+
parsed = JSON.parse(raw);
|
|
11091
11514
|
} catch {
|
|
11092
|
-
|
|
11515
|
+
return null;
|
|
11093
11516
|
}
|
|
11094
|
-
|
|
11095
|
-
|
|
11096
|
-
|
|
11097
|
-
|
|
11098
|
-
|
|
11517
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
11518
|
+
const record = parsed;
|
|
11519
|
+
const tasks = record.tasks;
|
|
11520
|
+
if (tasks === void 0 || typeof tasks !== "object" || tasks === null) return null;
|
|
11521
|
+
const entries = {};
|
|
11522
|
+
for (const [ref, value] of Object.entries(tasks)) {
|
|
11523
|
+
if (typeof value !== "object" || value === null) continue;
|
|
11524
|
+
const entry = value;
|
|
11525
|
+
if (typeof entry.target !== "object" || entry.target === null) continue;
|
|
11526
|
+
entries[ref] = {
|
|
11527
|
+
at: typeof entry.at === "string" ? entry.at : "",
|
|
11528
|
+
target: entry.target
|
|
11529
|
+
};
|
|
11099
11530
|
}
|
|
11100
|
-
return
|
|
11531
|
+
return {
|
|
11532
|
+
version: typeof record.version === "number" ? record.version : BASELINE_VERSION,
|
|
11533
|
+
bundle: typeof record.bundle === "string" ? record.bundle : "",
|
|
11534
|
+
tasks: entries
|
|
11535
|
+
};
|
|
11536
|
+
}
|
|
11537
|
+
async function writeBaseline(bundleDir, baseline) {
|
|
11538
|
+
const target = baselinePath(bundleDir);
|
|
11539
|
+
await mkdir4(dirname4(target), { recursive: true });
|
|
11540
|
+
await writeFile4(target, `${JSON.stringify(baseline, null, 2)}
|
|
11541
|
+
`, "utf8");
|
|
11101
11542
|
}
|
|
11102
|
-
function
|
|
11103
|
-
|
|
11104
|
-
|
|
11105
|
-
|
|
11106
|
-
|
|
11107
|
-
|
|
11108
|
-
|
|
11109
|
-
|
|
11110
|
-
|
|
11111
|
-
|
|
11543
|
+
async function clearBaseline(bundleDir) {
|
|
11544
|
+
await rm4(baselinePath(bundleDir), { force: true });
|
|
11545
|
+
}
|
|
11546
|
+
async function captureTaskBaseline(bundleDir, definition, now = /* @__PURE__ */ new Date()) {
|
|
11547
|
+
const baseline = await readBaseline(bundleDir) ?? {
|
|
11548
|
+
version: BASELINE_VERSION,
|
|
11549
|
+
bundle: await bundleHashOf(bundleDir),
|
|
11550
|
+
tasks: {}
|
|
11551
|
+
};
|
|
11552
|
+
if (baseline.bundle.length === 0) baseline.bundle = await bundleHashOf(bundleDir);
|
|
11553
|
+
const target = await targetHashes(bundleDir, targetFilesFromContent(definition.content));
|
|
11554
|
+
baseline.tasks[definition.id.toUpperCase()] = {
|
|
11555
|
+
at: now.toISOString(),
|
|
11556
|
+
target: target.hashes
|
|
11112
11557
|
};
|
|
11558
|
+
await writeBaseline(bundleDir, baseline);
|
|
11113
11559
|
}
|
|
11114
|
-
function
|
|
11115
|
-
|
|
11116
|
-
|
|
11560
|
+
async function updateContractBaseline(bundleDir) {
|
|
11561
|
+
const newBundleHash = await bundleHashOf(bundleDir);
|
|
11562
|
+
const baseline = await readBaseline(bundleDir) ?? {
|
|
11563
|
+
version: BASELINE_VERSION,
|
|
11564
|
+
bundle: newBundleHash,
|
|
11565
|
+
tasks: {}
|
|
11566
|
+
};
|
|
11567
|
+
baseline.bundle = newBundleHash;
|
|
11568
|
+
await writeBaseline(bundleDir, baseline);
|
|
11569
|
+
return newBundleHash;
|
|
11117
11570
|
}
|
|
11118
|
-
function
|
|
11119
|
-
|
|
11120
|
-
const
|
|
11121
|
-
const
|
|
11122
|
-
|
|
11123
|
-
|
|
11124
|
-
|
|
11125
|
-
);
|
|
11571
|
+
async function detectDrift(bundleDir, definitions, state, options = {}) {
|
|
11572
|
+
const baseline = await readBaseline(bundleDir);
|
|
11573
|
+
const acknowledged = await readAcknowledged(bundleDir);
|
|
11574
|
+
const bundleDriftAcknowledged = acknowledged !== null && (acknowledged.prd === true || acknowledged.specs === true || acknowledged.tasks === true);
|
|
11575
|
+
const findings = [];
|
|
11576
|
+
const focus = options.focusRef?.toUpperCase();
|
|
11577
|
+
const byId = new Map(definitions.map((entry) => [entry.id.toUpperCase(), entry]));
|
|
11578
|
+
const targetCache = /* @__PURE__ */ new Map();
|
|
11579
|
+
const hashesFor = (definition) => {
|
|
11580
|
+
const key = targetFilesFromContent(definition.content).join("\0");
|
|
11581
|
+
let cached = targetCache.get(key);
|
|
11582
|
+
if (cached === void 0) {
|
|
11583
|
+
cached = targetHashes(bundleDir, targetFilesFromContent(definition.content));
|
|
11584
|
+
targetCache.set(key, cached);
|
|
11585
|
+
}
|
|
11586
|
+
return cached;
|
|
11587
|
+
};
|
|
11588
|
+
if (baseline !== null) {
|
|
11589
|
+
const currentBundle = await bundleHashOf(bundleDir);
|
|
11590
|
+
if (baseline.bundle.length > 0 && currentBundle !== baseline.bundle) {
|
|
11591
|
+
findings.push({
|
|
11592
|
+
code: "BUNDLE_DRIFT",
|
|
11593
|
+
severity: bundleDriftAcknowledged ? "info" : "warn",
|
|
11594
|
+
message: "PRD.md/specs/tasks berubah di disk setelah baseline dibuat. Revisi resmi lewat workspace web (agar specs/tasks ditandai stale), atau kembalikan file itu; jangan diedit lokal diam-diam.",
|
|
11595
|
+
files: []
|
|
11596
|
+
});
|
|
11597
|
+
}
|
|
11598
|
+
for (const task of state.tasks) {
|
|
11599
|
+
const definition = byId.get(task.ref.toUpperCase());
|
|
11600
|
+
if (definition === void 0) continue;
|
|
11601
|
+
const entry = baseline.tasks[task.ref.toUpperCase()];
|
|
11602
|
+
if (entry === void 0) continue;
|
|
11603
|
+
if (task.status !== "todo" && task.status !== "done") continue;
|
|
11604
|
+
const current = await hashesFor(definition);
|
|
11605
|
+
const changed = diffHashes(entry.target, current.hashes);
|
|
11606
|
+
if (changed.length === 0) continue;
|
|
11607
|
+
findings.push({
|
|
11608
|
+
code: task.status === "todo" ? "OUT_OF_BAND_CHANGES" : "MODIFIED_AFTER_DONE",
|
|
11609
|
+
severity: "warn",
|
|
11610
|
+
taskRef: task.ref,
|
|
11611
|
+
message: task.status === "todo" ? `File di scope ${task.ref} berubah padahal task belum dijalankan. Kalau ini hasil alat lain (Figma MCP/AI Studio/editor luar), jalankan \`jioogen task adopt ${task.ref}\` setelah verifikasi; kalau belum selesai, \`jioogen task start ${task.ref}\` dulu.` : `File milik ${task.ref} berubah setelah task selesai. Tinjau diff; bila perubahan disengaja, reset lalu adopsi ulang (\`jioogen task reset ${task.ref}\` \u2192 \`jioogen task adopt ${task.ref}\`).`,
|
|
11612
|
+
files: changed
|
|
11613
|
+
});
|
|
11614
|
+
}
|
|
11615
|
+
}
|
|
11616
|
+
if (options.includeInfo !== false) {
|
|
11617
|
+
findings.push(...await detectPreExisting(definitions, state, baseline, focus, hashesFor));
|
|
11618
|
+
}
|
|
11619
|
+
return findings;
|
|
11126
11620
|
}
|
|
11127
|
-
function
|
|
11128
|
-
const byId = new Map(definitions.map((
|
|
11129
|
-
const
|
|
11130
|
-
|
|
11131
|
-
|
|
11621
|
+
async function detectPreExisting(definitions, state, baseline, focus, hashesFor) {
|
|
11622
|
+
const byId = new Map(definitions.map((entry) => [entry.id.toUpperCase(), entry]));
|
|
11623
|
+
const done = /* @__PURE__ */ new Set();
|
|
11624
|
+
for (const task of state.tasks) {
|
|
11625
|
+
if (task.status !== "done") continue;
|
|
11132
11626
|
const definition = byId.get(task.ref.toUpperCase());
|
|
11133
|
-
if (definition === void 0)
|
|
11134
|
-
|
|
11135
|
-
|
|
11136
|
-
|
|
11137
|
-
|
|
11138
|
-
|
|
11139
|
-
|
|
11140
|
-
|
|
11141
|
-
if (
|
|
11142
|
-
|
|
11143
|
-
|
|
11144
|
-
|
|
11145
|
-
|
|
11146
|
-
|
|
11147
|
-
|
|
11627
|
+
if (definition === void 0) continue;
|
|
11628
|
+
const current = await hashesFor(definition);
|
|
11629
|
+
for (const path of Object.keys(current.hashes)) done.add(path);
|
|
11630
|
+
}
|
|
11631
|
+
const findings = [];
|
|
11632
|
+
for (const task of state.tasks) {
|
|
11633
|
+
if (task.status !== "todo") continue;
|
|
11634
|
+
const key = task.ref.toUpperCase();
|
|
11635
|
+
if (focus !== void 0 && key !== focus) continue;
|
|
11636
|
+
if (baseline?.tasks[key] !== void 0) continue;
|
|
11637
|
+
const definition = byId.get(key);
|
|
11638
|
+
if (definition === void 0) continue;
|
|
11639
|
+
const current = await hashesFor(definition);
|
|
11640
|
+
const preExisting = Object.keys(current.hashes).filter((path) => !done.has(path));
|
|
11641
|
+
if (preExisting.length === 0) continue;
|
|
11642
|
+
findings.push({
|
|
11643
|
+
code: "PRE_EXISTING_SCOPE",
|
|
11644
|
+
severity: "info",
|
|
11645
|
+
taskRef: task.ref,
|
|
11646
|
+
message: `Scope ${task.ref} sudah berisi file sebelum task dimulai. Bila ini hasil alat luar (Stitch/v0/Lovable/Figma/AI Studio/editor lain) atau tulisan tangan, verifikasi lalu \`jioogen task adopt ${task.ref}\`; bila belum, \`jioogen task start ${task.ref}\`.`,
|
|
11647
|
+
files: preExisting.slice(0, 8)
|
|
11648
|
+
});
|
|
11649
|
+
}
|
|
11650
|
+
return findings;
|
|
11148
11651
|
}
|
|
11149
|
-
function
|
|
11150
|
-
|
|
11652
|
+
function formatDrift(finding) {
|
|
11653
|
+
const label = finding.taskRef === void 0 ? finding.code : `${finding.code} ${finding.taskRef}`;
|
|
11654
|
+
const files = finding.files.length === 0 ? "" : ` (${finding.files.slice(0, 4).join(", ")}${finding.files.length > 4 ? ", \u2026" : ""})`;
|
|
11655
|
+
return `${finding.severity === "warn" ? "\u26A0" : "\u2139"} ${label}: ${finding.message}${files}`;
|
|
11151
11656
|
}
|
|
11152
|
-
function
|
|
11153
|
-
const
|
|
11154
|
-
|
|
11155
|
-
const
|
|
11156
|
-
|
|
11157
|
-
|
|
11657
|
+
async function targetHashes(bundleDir, patterns) {
|
|
11658
|
+
const files = /* @__PURE__ */ new Set();
|
|
11659
|
+
let truncated = false;
|
|
11660
|
+
for (const pattern of patterns) {
|
|
11661
|
+
const resolved = await expandPattern(bundleDir, pattern);
|
|
11662
|
+
for (const file of resolved) {
|
|
11663
|
+
if (files.size >= MAX_TARGET_FILES) {
|
|
11664
|
+
truncated = true;
|
|
11665
|
+
break;
|
|
11666
|
+
}
|
|
11667
|
+
files.add(file);
|
|
11668
|
+
}
|
|
11669
|
+
if (truncated) break;
|
|
11158
11670
|
}
|
|
11159
|
-
const
|
|
11160
|
-
const
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
...previous,
|
|
11164
|
-
status,
|
|
11165
|
-
updatedAt: now.toISOString(),
|
|
11166
|
-
history: [...previous.history ?? [], historyEntry]
|
|
11167
|
-
};
|
|
11168
|
-
if (attempt !== void 0) updated.attempt = attempt;
|
|
11169
|
-
if (options.note !== void 0) {
|
|
11170
|
-
if (options.note.length > 0) updated.note = options.note;
|
|
11171
|
-
else delete updated.note;
|
|
11671
|
+
const hashes = {};
|
|
11672
|
+
for (const file of [...files].sort()) {
|
|
11673
|
+
const fingerprint = await fingerprintRelative(bundleDir, file);
|
|
11674
|
+
if (fingerprint !== null) hashes[file] = fingerprint;
|
|
11172
11675
|
}
|
|
11173
|
-
|
|
11174
|
-
const current = status === "in_progress" || status === "verifying" ? {
|
|
11175
|
-
ref: updated.ref,
|
|
11176
|
-
...updated.layer !== void 0 ? { layer: updated.layer } : {},
|
|
11177
|
-
...updated.phase !== void 0 ? { phase: updated.phase } : {},
|
|
11178
|
-
awaitingCheckpoint: options.awaitingCheckpoint === true
|
|
11179
|
-
} : void 0;
|
|
11180
|
-
return rebuild(state, tasks, current, now);
|
|
11181
|
-
}
|
|
11182
|
-
function setCurrent(state, current) {
|
|
11183
|
-
return rebuild(state, state.tasks, current ?? void 0);
|
|
11676
|
+
return { hashes, truncated };
|
|
11184
11677
|
}
|
|
11185
|
-
function
|
|
11186
|
-
const
|
|
11187
|
-
if (
|
|
11188
|
-
|
|
11189
|
-
|
|
11190
|
-
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11195
|
-
|
|
11678
|
+
async function expandPattern(bundleDir, raw) {
|
|
11679
|
+
const pattern = normalizePattern(raw);
|
|
11680
|
+
if (pattern === null) return [];
|
|
11681
|
+
if (!/[*?[]/.test(pattern)) {
|
|
11682
|
+
const info = await statMaybe(join6(bundleDir, pattern));
|
|
11683
|
+
if (info === null) return [];
|
|
11684
|
+
if (info.isDirectory()) {
|
|
11685
|
+
return (await walk(bundleDir, pattern, MAX_TARGET_FILES)).files;
|
|
11686
|
+
}
|
|
11687
|
+
return info.isFile() ? [pattern] : [];
|
|
11688
|
+
}
|
|
11689
|
+
const matcher = globToRegExp(pattern);
|
|
11690
|
+
const start = staticPrefix(pattern);
|
|
11691
|
+
const walked = await walk(bundleDir, start, MAX_TARGET_FILES);
|
|
11692
|
+
return walked.files.filter((file) => matcher.test(file));
|
|
11196
11693
|
}
|
|
11197
|
-
function
|
|
11198
|
-
|
|
11199
|
-
|
|
11200
|
-
|
|
11201
|
-
if (
|
|
11202
|
-
|
|
11203
|
-
const tasks = state.tasks.map((entry, i) => i === index ? task : entry);
|
|
11204
|
-
return rebuild(state, tasks, state.current);
|
|
11694
|
+
function normalizePattern(raw) {
|
|
11695
|
+
let value = raw.trim().replace(/^`+|`+$/g, "").replace(/\\/g, "/");
|
|
11696
|
+
value = value.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
11697
|
+
if (value.length === 0 || isAbsolute2(value)) return null;
|
|
11698
|
+
if (value.split("/").includes("..")) return null;
|
|
11699
|
+
return value;
|
|
11205
11700
|
}
|
|
11206
|
-
function
|
|
11207
|
-
const index =
|
|
11208
|
-
|
|
11209
|
-
const
|
|
11210
|
-
if (
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11214
|
-
passed: review.passed,
|
|
11215
|
-
findings: [...review.findings ?? []],
|
|
11216
|
-
summary: review.summary,
|
|
11217
|
-
at: review.at ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
11218
|
-
},
|
|
11219
|
-
evidence: [
|
|
11220
|
-
...previous.evidence ?? [],
|
|
11221
|
-
{
|
|
11222
|
-
type: "design_review",
|
|
11223
|
-
summary: `${review.passed ? "PASS" : "FAIL"}${review.summary ? ` \u2014 ${review.summary}` : ""}`,
|
|
11224
|
-
at: review.at ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
11225
|
-
}
|
|
11226
|
-
]
|
|
11227
|
-
};
|
|
11228
|
-
const tasks = state.tasks.map((entry, i) => i === index ? task : entry);
|
|
11229
|
-
return rebuild(state, tasks, state.current);
|
|
11701
|
+
function staticPrefix(pattern) {
|
|
11702
|
+
const index = pattern.search(/[*?[]/);
|
|
11703
|
+
const head = index === -1 ? pattern : pattern.slice(0, index);
|
|
11704
|
+
const trimmed = head.replace(/\/+$/, "");
|
|
11705
|
+
if (trimmed.length === 0) return "";
|
|
11706
|
+
if (head.endsWith("/")) return trimmed;
|
|
11707
|
+
const slash = trimmed.lastIndexOf("/");
|
|
11708
|
+
return slash === -1 ? "" : trimmed.slice(0, slash);
|
|
11230
11709
|
}
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
|
|
11242
|
-
|
|
11243
|
-
|
|
11710
|
+
function globToRegExp(pattern) {
|
|
11711
|
+
let source = "^";
|
|
11712
|
+
for (let index = 0; index < pattern.length; index += 1) {
|
|
11713
|
+
const char = pattern[index] ?? "";
|
|
11714
|
+
if (char === "*") {
|
|
11715
|
+
if (pattern[index + 1] === "*") {
|
|
11716
|
+
if (pattern[index + 2] === "/") {
|
|
11717
|
+
source += "(?:.*/)?";
|
|
11718
|
+
index += 2;
|
|
11719
|
+
} else {
|
|
11720
|
+
source += ".*";
|
|
11721
|
+
index += 1;
|
|
11722
|
+
}
|
|
11723
|
+
} else {
|
|
11724
|
+
source += "[^/]*";
|
|
11725
|
+
}
|
|
11726
|
+
} else if (char === "?") {
|
|
11727
|
+
source += "[^/]";
|
|
11728
|
+
} else if ("\\^$+.()|{}[]".includes(char)) {
|
|
11729
|
+
source += `\\${char}`;
|
|
11730
|
+
} else {
|
|
11731
|
+
source += char;
|
|
11732
|
+
}
|
|
11244
11733
|
}
|
|
11245
|
-
return
|
|
11246
|
-
}
|
|
11247
|
-
function rebuild(state, tasks, current, now = /* @__PURE__ */ new Date()) {
|
|
11248
|
-
const next = {
|
|
11249
|
-
schemaVersion: state.schemaVersion,
|
|
11250
|
-
updatedAt: now.toISOString(),
|
|
11251
|
-
counts: summarizeExecutionCounts(tasks),
|
|
11252
|
-
tasks
|
|
11253
|
-
};
|
|
11254
|
-
if (state.projectId !== void 0) next.projectId = state.projectId;
|
|
11255
|
-
if (state.executor !== void 0) next.executor = state.executor;
|
|
11256
|
-
if (state.mode !== void 0) next.mode = state.mode;
|
|
11257
|
-
if (state.plan !== void 0) next.plan = state.plan;
|
|
11258
|
-
if (state.events !== void 0) next.events = state.events;
|
|
11259
|
-
if (current !== void 0) next.current = current;
|
|
11260
|
-
return next;
|
|
11734
|
+
return new RegExp(`${source}$`);
|
|
11261
11735
|
}
|
|
11262
|
-
function
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11736
|
+
async function walk(bundleDir, start, limit) {
|
|
11737
|
+
const files = [];
|
|
11738
|
+
let truncated = false;
|
|
11739
|
+
const visit = async (relative2) => {
|
|
11740
|
+
if (truncated) return;
|
|
11741
|
+
let entries;
|
|
11742
|
+
try {
|
|
11743
|
+
entries = await readdir4(relative2.length === 0 ? bundleDir : join6(bundleDir, relative2), {
|
|
11744
|
+
withFileTypes: true
|
|
11745
|
+
});
|
|
11746
|
+
} catch {
|
|
11747
|
+
return;
|
|
11748
|
+
}
|
|
11749
|
+
entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
11750
|
+
for (const entry of entries) {
|
|
11751
|
+
const child = relative2.length === 0 ? entry.name : `${relative2}/${entry.name}`;
|
|
11752
|
+
if (entry.isDirectory()) {
|
|
11753
|
+
if (IGNORED_DIRS.has(entry.name)) continue;
|
|
11754
|
+
if (child === "tasks/.execution") continue;
|
|
11755
|
+
await visit(child);
|
|
11756
|
+
} else if (entry.isFile()) {
|
|
11757
|
+
if (files.length >= limit) {
|
|
11758
|
+
truncated = true;
|
|
11759
|
+
return;
|
|
11760
|
+
}
|
|
11761
|
+
files.push(child);
|
|
11762
|
+
}
|
|
11763
|
+
}
|
|
11269
11764
|
};
|
|
11765
|
+
await visit(start);
|
|
11766
|
+
return { files, truncated };
|
|
11270
11767
|
}
|
|
11271
|
-
function
|
|
11272
|
-
|
|
11768
|
+
async function fingerprintRelative(bundleDir, relative2) {
|
|
11769
|
+
const info = await statMaybe(join6(bundleDir, relative2));
|
|
11770
|
+
if (info === null || !info.isFile()) return null;
|
|
11771
|
+
return `${info.size}:${Math.trunc(info.mtimeMs)}`;
|
|
11273
11772
|
}
|
|
11274
|
-
function
|
|
11275
|
-
|
|
11773
|
+
async function hashRelative(bundleDir, relative2) {
|
|
11774
|
+
const info = await statMaybe(join6(bundleDir, relative2));
|
|
11775
|
+
if (info === null || !info.isFile()) return null;
|
|
11776
|
+
if (info.size > MAX_BUNDLE_FILE_BYTES) return `size:${info.size}`;
|
|
11777
|
+
try {
|
|
11778
|
+
const bytes = await readFile6(join6(bundleDir, relative2));
|
|
11779
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
11780
|
+
} catch {
|
|
11781
|
+
return null;
|
|
11782
|
+
}
|
|
11276
11783
|
}
|
|
11277
|
-
async function
|
|
11784
|
+
async function statMaybe(path) {
|
|
11278
11785
|
try {
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
return true;
|
|
11283
|
-
} catch (error) {
|
|
11284
|
-
if (isMissingFile3(error)) return true;
|
|
11285
|
-
throw error;
|
|
11786
|
+
return await stat3(path);
|
|
11787
|
+
} catch {
|
|
11788
|
+
return null;
|
|
11286
11789
|
}
|
|
11287
11790
|
}
|
|
11288
|
-
function
|
|
11289
|
-
|
|
11791
|
+
function diffHashes(before, after) {
|
|
11792
|
+
const changed = /* @__PURE__ */ new Set();
|
|
11793
|
+
for (const [path, hash] of Object.entries(before)) {
|
|
11794
|
+
if (after[path] !== hash) changed.add(path);
|
|
11795
|
+
}
|
|
11796
|
+
for (const path of Object.keys(after)) {
|
|
11797
|
+
if (!(path in before)) changed.add(path);
|
|
11798
|
+
}
|
|
11799
|
+
return [...changed].sort();
|
|
11800
|
+
}
|
|
11801
|
+
async function bundleHashOf(bundleDir) {
|
|
11802
|
+
const files = [];
|
|
11803
|
+
for (const name of ["PRD.md", "traceability.md"]) {
|
|
11804
|
+
const info = await statMaybe(join6(bundleDir, name));
|
|
11805
|
+
if (info?.isFile()) files.push(name);
|
|
11806
|
+
}
|
|
11807
|
+
for (const directory of ["specs", "tasks"]) {
|
|
11808
|
+
const walked = await walk(bundleDir, directory, MAX_TARGET_FILES);
|
|
11809
|
+
for (const file of walked.files) {
|
|
11810
|
+
if (file.startsWith("tasks/.execution/")) continue;
|
|
11811
|
+
if (IGNORED_TOP_FILES.has(file)) continue;
|
|
11812
|
+
if (!file.toLowerCase().endsWith(".md")) continue;
|
|
11813
|
+
files.push(file);
|
|
11814
|
+
}
|
|
11815
|
+
}
|
|
11816
|
+
const lines = [];
|
|
11817
|
+
for (const file of files.sort()) {
|
|
11818
|
+
const hash = await hashRelative(bundleDir, file);
|
|
11819
|
+
if (hash !== null) lines.push(`${file}\0${hash}`);
|
|
11820
|
+
}
|
|
11821
|
+
return createHash("sha256").update(lines.join("\n")).digest("hex");
|
|
11290
11822
|
}
|
|
11291
11823
|
|
|
11292
11824
|
// src/skills.ts
|
|
11293
11825
|
import { createHash as createHash2 } from "node:crypto";
|
|
11294
|
-
import { cp as cp2, mkdir as mkdir5, readdir as readdir5, readFile as readFile7, rm as rm5, stat as
|
|
11826
|
+
import { cp as cp2, mkdir as mkdir5, readdir as readdir5, readFile as readFile7, rename as rename2, rm as rm5, stat as stat4, writeFile as writeFile5 } from "node:fs/promises";
|
|
11295
11827
|
import { homedir as homedir2 } from "node:os";
|
|
11296
11828
|
import { dirname as dirname5, join as join7, resolve as resolve3 } from "node:path";
|
|
11297
11829
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -11373,6 +11905,17 @@ var JIOOGEN_AGENTS_MD = `${MARKER}
|
|
|
11373
11905
|
- Dilarang pindah task sebelum task aktif \`done\` atau \`failed\`.
|
|
11374
11906
|
- Jangan mengarang fitur/endpoint/kolom yang tidak ada di \`PRD.md\`/\`specs/\`.
|
|
11375
11907
|
- Jangan mengubah \`PRD.md\` atau \`specs/\`; itu kontrak, bukan hasil eksekusi.
|
|
11908
|
+
- **Warning CLI \u2260 BLOCKER, jangan loop.** Warning seperti ID task duplikat atau
|
|
11909
|
+
drift bukan alasan menghentikan atau mengulang-ulang eksekusi: baca pesannya,
|
|
11910
|
+
tandai kondisi di note (\`task start/complete --note "...id duplikat, default pakai
|
|
11911
|
+
yang pertama..."\`), lalu lanjutkan task. Berhenti HANYA pada hal yang benar-benar
|
|
11912
|
+
menghentikan Acceptance Criteria atau melanggar kontrak. Satu error CLI yang sama
|
|
11913
|
+
tidak boleh dijalankan ulang lebih dari sekali.
|
|
11914
|
+
- **Project dihapus = dead end, jangan usahakan lagi.** Bila CLI melaporkan project
|
|
11915
|
+
tidak ditemukan/dihapus dan link lokal sudah dilepas otomatis, direktori ini tidak
|
|
11916
|
+
terikat project apa pun: BERHENTI (tandai \`fail\`/catat di note), jangan ulangi
|
|
11917
|
+
perintah, jangan coba bind-paksa, jangan buat file baru. Laporkan ke user bahwa
|
|
11918
|
+
bundle sudah dilepas dan bisa di-pull ulang secara manual bila memang ingin lanjut.
|
|
11376
11919
|
|
|
11377
11920
|
## 2. Alur per giliran
|
|
11378
11921
|
1. \`npx jioogen task next\` \u2014 baca blok **TASK AKTIF**, **BREAKDOWN WAJIB**, + isi file task.
|
|
@@ -11385,16 +11928,21 @@ var JIOOGEN_AGENTS_MD = `${MARKER}
|
|
|
11385
11928
|
|
|
11386
11929
|
## 2b. Pekerjaan yang dibangun di luar harness
|
|
11387
11930
|
|
|
11388
|
-
Kalau sebuah layar/komponen sudah dibuat di
|
|
11389
|
-
|
|
11931
|
+
Kalau sebuah layar/komponen sudah dibuat di luar harness (alat UI generator seperti
|
|
11932
|
+
Stitch/v0/Lovable/Bolt/screenshot-to-code, AI studio, plugin desain, atau tulisan
|
|
11933
|
+
tangan) sebelum task dijalankan, jangan pura-pura mengerjakannya:
|
|
11390
11934
|
- \`npx jioogen task next\`/\`npx jioogen doctor\` menandai \`PRE_EXISTING_SCOPE\` atau
|
|
11391
11935
|
\`OUT_OF_BAND_CHANGES\`.
|
|
11936
|
+
- Petakan hasilnya ke \`targetFiles\` task aktif (framework apa pun). File baru hanya
|
|
11937
|
+
di dalam area itu.
|
|
11392
11938
|
- Verifikasi hasilnya lalu \`npx jioogen task adopt <ref> --note "<alat>"\` (task UI:
|
|
11393
11939
|
tambahkan \`--visual "<catatan>"\`). Command itu menjalankan \`verificationCommand\`
|
|
11394
11940
|
dan mencatat \`source: user\` + bukti adopsi di sidecar.
|
|
11395
11941
|
- Kalau hasil alat itu menyimpang dari \`specs/\`/\`CONTRACT-XXX\`, STOP: revisi
|
|
11396
11942
|
kontrak lewat workspace web, jangan mengadopsi diam-diam.
|
|
11397
11943
|
- Jangan edit \`PRD.md\`/\`specs/\` lokal; \`BUNDLE_DRIFT\` akan muncul.
|
|
11944
|
+
- Port dev server jangan ditebak: JiooGen/app lain bisa sudah memakainya. Pakai port
|
|
11945
|
+
bebas (mis. \`PORT=3001\`), catat di note; jangan ubah kontrak/spec demi port.
|
|
11398
11946
|
|
|
11399
11947
|
## 3. Batas scope
|
|
11400
11948
|
- Edit **hanya** file/direktori/glob di \`targetFiles\` task aktif. Jangan melebar.
|
|
@@ -11528,16 +12076,22 @@ atas ide, refactor, perbaikan, atau fitur lain.
|
|
|
11528
12076
|
|
|
11529
12077
|
## 2b. Pekerjaan yang dibangun di luar harness
|
|
11530
12078
|
|
|
11531
|
-
Kalau sebuah layar/komponen sudah dibuat di
|
|
11532
|
-
|
|
12079
|
+
Kalau sebuah layar/komponen sudah dibuat di luar harness \u2014 alat UI generator
|
|
12080
|
+
(Stitch, v0, Lovable, Bolt, screenshot-to-code, dsb.), AI studio, plugin desain,
|
|
12081
|
+
atau ditulis tangan \u2014 sebelum task dijalankan, jangan pura-pura mengerjakannya:
|
|
11533
12082
|
- \`npx jioogen task next\`/\`npx jioogen doctor\` menandai \`PRE_EXISTING_SCOPE\` atau
|
|
11534
12083
|
\`OUT_OF_BAND_CHANGES\`.
|
|
12084
|
+
- Petakan hasilnya ke \`targetFiles\` task aktif, framework apa pun (HTML/CSS, React,
|
|
12085
|
+
Vue, Svelte, dsb.). File baru hanya di dalam area itu.
|
|
11535
12086
|
- Verifikasi hasilnya lalu \`npx jioogen task adopt <ref> --note "<alat>"\` (task UI:
|
|
11536
12087
|
tambahkan \`--visual "<catatan>"\`). Command itu menjalankan \`verificationCommand\`
|
|
11537
12088
|
dan mencatat \`source: user\` + bukti adopsi di sidecar.
|
|
11538
12089
|
- Kalau hasil alat itu menyimpang dari \`specs/\`/\`CONTRACT-XXX\`, STOP: revisi
|
|
11539
12090
|
kontrak lewat workspace web, jangan mengadopsi diam-diam.
|
|
11540
12091
|
- Jangan edit \`PRD.md\`/\`specs/\` lokal; \`BUNDLE_DRIFT\` akan muncul.
|
|
12092
|
+
- **Port dev server jangan ditebak.** JiooGen/monitor atau app lain bisa sudah
|
|
12093
|
+
memakai port default; pakai port bebas (mis. \`PORT=3001\`), catat di note, dan
|
|
12094
|
+
jangan mengubah kontrak/spec demi port.
|
|
11541
12095
|
|
|
11542
12096
|
## 3. Batas scope
|
|
11543
12097
|
|
|
@@ -11607,6 +12161,24 @@ Tulis kode **minimum** yang menyelesaikan task. Gemuk = gagal review.
|
|
|
11607
12161
|
|
|
11608
12162
|
Tanya: "Apakah senior engineer bilang ini overcomplicated?" Bila ya, sederhanakan.
|
|
11609
12163
|
|
|
12164
|
+
## 3f. Design Token & design.md (kontekstual)
|
|
12165
|
+
|
|
12166
|
+
- Baca \`specs/design.md\` bila ada (design contract: token/visual). User boleh
|
|
12167
|
+
mengeditnya antar-sesi; agent **reuse/extend**, **jangan menimpa** edit user saat
|
|
12168
|
+
task berjalan. Preferensi tambahan user di \`.jioogen/custom/design/\` (additive).
|
|
12169
|
+
- Inspeksi token/theme/CSS variables/Tailwind/komponen/design reference yang sudah ada
|
|
12170
|
+
(specs/design.md, custom/design/, docs/DESIGN.md, specs, codebase). Reuse dulu;
|
|
12171
|
+
token baru hanya untuk nilai visual berulang yang nyata; jangan hardcode nilai yang
|
|
12172
|
+
sudah punya token; jangan membuat design system baru atau mengganti styling di luar
|
|
12173
|
+
scope. Produk tanpa UI: \`N/A \u2014 tidak ada surface visual\`.
|
|
12174
|
+
- Auto-generate \`specs/design.md\` bila belum ada & produk ber-surface UI (pada scaffold
|
|
12175
|
+
task phase 1 FE), dari ui-ux-pro-max + impeccable (+ gamedev skills eksternal untuk
|
|
12176
|
+
produk game). Untuk produk tanpa UI: token minimal (spacing/typography/neutral) atau
|
|
12177
|
+
N/A beralasan. Jika sudah ada (user-provided), merge: preferensi user = constraint,
|
|
12178
|
+
skill isi gap; jangan timpa.
|
|
12179
|
+
- Task UI wajib \`designTokens\` (\`reuse\`/\`extend\`/\`minimal\`/\`N/A\` beralasan) dan
|
|
12180
|
+
AC menolak hardcoded value bila token tersedia.
|
|
12181
|
+
|
|
11610
12182
|
## 4. Verifikasi jujur (jangan dipalsukan)
|
|
11611
12183
|
|
|
11612
12184
|
- Pakai test runner yang dideklarasikan di \`specs/\` atau dibuat task scaffold.
|
|
@@ -11642,6 +12214,12 @@ menampilkan perintah itu sebagai pertanyaan ke user.
|
|
|
11642
12214
|
- Jangan menunda entrypoint/scaffold ke fase backend.
|
|
11643
12215
|
- Jangan mengganti ownership/consistency boundary tanpa memperbarui spec.
|
|
11644
12216
|
- Jangan menandai \`done\` sebelum verification exit 0.
|
|
12217
|
+
- **Jangan loop pada warning CLI.** Warning (mis. ID task duplikat, drift,
|
|
12218
|
+
item breakdown belum dicentang) bukan BLOCKER: tandai di note, lanjut.
|
|
12219
|
+
Perintah CLI yang sama tidak boleh diulang demi hasil yang sama; kalau tetap
|
|
12220
|
+
gagal setelah 1 ulangan, tandai \`fail\` + alasan singkat.
|
|
12221
|
+
- **Project dihapus = dead end.** CLI sudah melepas link otomatis; jangan ulangi
|
|
12222
|
+
perintah, jangan coba re-bind paksa; berhenti dan lapor.
|
|
11645
12223
|
- Jangan diam-diam lanjut setelah gagal; tandai \`fail\` + alasan singkat.
|
|
11646
12224
|
- Jangan membuat task/laporan baru untuk micro-fix; cukup catat di note task aktif.
|
|
11647
12225
|
|
|
@@ -11677,7 +12255,7 @@ function isMissingFile4(error) {
|
|
|
11677
12255
|
}
|
|
11678
12256
|
async function isFile(path) {
|
|
11679
12257
|
try {
|
|
11680
|
-
return (await
|
|
12258
|
+
return (await stat4(path)).isFile();
|
|
11681
12259
|
} catch (error) {
|
|
11682
12260
|
if (isMissingFile4(error)) return false;
|
|
11683
12261
|
throw error;
|
|
@@ -11685,7 +12263,7 @@ async function isFile(path) {
|
|
|
11685
12263
|
}
|
|
11686
12264
|
async function isDirectory(path) {
|
|
11687
12265
|
try {
|
|
11688
|
-
return (await
|
|
12266
|
+
return (await stat4(path)).isDirectory();
|
|
11689
12267
|
} catch (error) {
|
|
11690
12268
|
if (isMissingFile4(error)) return false;
|
|
11691
12269
|
throw error;
|
|
@@ -12106,6 +12684,34 @@ async function updateSkillPacks(bundleDir) {
|
|
|
12106
12684
|
existing.productKind
|
|
12107
12685
|
);
|
|
12108
12686
|
}
|
|
12687
|
+
async function removeExecutionContract(bundleDir) {
|
|
12688
|
+
const root = resolve3(bundleDir);
|
|
12689
|
+
const removed = [];
|
|
12690
|
+
const preserved = [];
|
|
12691
|
+
const agentsPath = join7(root, "AGENTS.md");
|
|
12692
|
+
const existingAgents = await readFileSafe(agentsPath);
|
|
12693
|
+
if (existingAgents !== void 0) {
|
|
12694
|
+
if (existingAgents.includes(MARKER_PREFIX)) {
|
|
12695
|
+
await rm5(agentsPath, { force: true });
|
|
12696
|
+
removed.push("AGENTS.md");
|
|
12697
|
+
} else {
|
|
12698
|
+
preserved.push("AGENTS.md");
|
|
12699
|
+
}
|
|
12700
|
+
}
|
|
12701
|
+
for (const dir of AGENT_SKILL_DIRS) {
|
|
12702
|
+
const target = join7(root, dir, EXECUTION_SKILL_NAME);
|
|
12703
|
+
try {
|
|
12704
|
+
const info = await stat4(target);
|
|
12705
|
+
if (info.isDirectory()) {
|
|
12706
|
+
await rm5(target, { recursive: true, force: true });
|
|
12707
|
+
removed.push(`${dir}/${EXECUTION_SKILL_NAME}`);
|
|
12708
|
+
}
|
|
12709
|
+
} catch (error) {
|
|
12710
|
+
if (!isMissingFile4(error)) throw error;
|
|
12711
|
+
}
|
|
12712
|
+
}
|
|
12713
|
+
return { removed, preserved };
|
|
12714
|
+
}
|
|
12109
12715
|
async function removeSkillPack(bundleDir, pack) {
|
|
12110
12716
|
const root = resolve3(bundleDir);
|
|
12111
12717
|
const existing = await readHarnessManifest(root);
|
|
@@ -12137,6 +12743,79 @@ async function removeSkillPack(bundleDir, pack) {
|
|
|
12137
12743
|
});
|
|
12138
12744
|
return { removed, preserved, packs };
|
|
12139
12745
|
}
|
|
12746
|
+
async function restoreSkillPack(bundleDir, packArgument) {
|
|
12747
|
+
const root = resolve3(bundleDir);
|
|
12748
|
+
const packNames = parseSkillPackArgument(packArgument);
|
|
12749
|
+
if (packNames === null) {
|
|
12750
|
+
throw new Error("Pack tidak dikenal. Pilih: baseline | ui-quality | backend-rules | all.");
|
|
12751
|
+
}
|
|
12752
|
+
const existing = await readHarnessManifest(root);
|
|
12753
|
+
const productKind = existing?.productKind ?? await detectProductKind(root);
|
|
12754
|
+
const updatedPacks = existing?.packs ? [...existing.packs] : [];
|
|
12755
|
+
const restored = [];
|
|
12756
|
+
const missing = [];
|
|
12757
|
+
for (const pack of packNames) {
|
|
12758
|
+
const skills = [];
|
|
12759
|
+
const packMissing = [];
|
|
12760
|
+
for (const name of SKILL_PACKS[pack]) {
|
|
12761
|
+
const source = await resolveSkillSource(pack, name);
|
|
12762
|
+
if (source === null) {
|
|
12763
|
+
packMissing.push(name);
|
|
12764
|
+
missing.push(name);
|
|
12765
|
+
continue;
|
|
12766
|
+
}
|
|
12767
|
+
const sha256 = await hashSkillDirectory(source);
|
|
12768
|
+
for (const dir of AGENT_SKILL_DIRS) {
|
|
12769
|
+
const targetDir = join7(root, dir, name);
|
|
12770
|
+
await replaceDirectory(source, targetDir);
|
|
12771
|
+
restored.push(`${dir}/${name}`);
|
|
12772
|
+
}
|
|
12773
|
+
skills.push({ name, source: `${pack}/${name}`, sha256 });
|
|
12774
|
+
}
|
|
12775
|
+
const manifestEntry = { name: pack, skills, missing: packMissing };
|
|
12776
|
+
const index = updatedPacks.findIndex((candidate) => candidate.name === pack);
|
|
12777
|
+
if (index >= 0) updatedPacks[index] = manifestEntry;
|
|
12778
|
+
else updatedPacks.push(manifestEntry);
|
|
12779
|
+
}
|
|
12780
|
+
const orderedNames = packNamesInCanonicalOrder(updatedPacks.map((pack) => pack.name));
|
|
12781
|
+
const finalPacks = orderedNames.map((name) => updatedPacks.find((pack) => pack.name === name)).filter((pack) => pack !== void 0);
|
|
12782
|
+
await writeHarnessManifest(root, {
|
|
12783
|
+
schemaVersion: HARNESS_SCHEMA_VERSION,
|
|
12784
|
+
productKind,
|
|
12785
|
+
packs: finalPacks,
|
|
12786
|
+
custom: existing?.custom ?? [],
|
|
12787
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
12788
|
+
});
|
|
12789
|
+
return { restored, packs: finalPacks, missing };
|
|
12790
|
+
}
|
|
12791
|
+
async function disableSkill(bundleDir, name) {
|
|
12792
|
+
const root = resolve3(bundleDir);
|
|
12793
|
+
const disabled = [];
|
|
12794
|
+
for (const dir of AGENT_SKILL_DIRS) {
|
|
12795
|
+
const targetDir = join7(root, dir, name);
|
|
12796
|
+
const disabledDir = `${targetDir}.disabled`;
|
|
12797
|
+
if (!await isDirectory(targetDir)) continue;
|
|
12798
|
+
if (await isDirectory(disabledDir)) await rm5(disabledDir, { recursive: true, force: true });
|
|
12799
|
+
await rename2(targetDir, disabledDir);
|
|
12800
|
+
disabled.push(`${dir}/${name}`);
|
|
12801
|
+
}
|
|
12802
|
+
return { disabled };
|
|
12803
|
+
}
|
|
12804
|
+
async function enableSkill(bundleDir, name) {
|
|
12805
|
+
const root = resolve3(bundleDir);
|
|
12806
|
+
const enabled = [];
|
|
12807
|
+
for (const dir of AGENT_SKILL_DIRS) {
|
|
12808
|
+
const targetDir = join7(root, dir, name);
|
|
12809
|
+
const disabledDir = `${targetDir}.disabled`;
|
|
12810
|
+
if (!await isDirectory(disabledDir)) continue;
|
|
12811
|
+
if (await isDirectory(targetDir)) await rm5(disabledDir, { recursive: true, force: true });
|
|
12812
|
+
else {
|
|
12813
|
+
await rename2(disabledDir, targetDir);
|
|
12814
|
+
enabled.push(`${dir}/${name}`);
|
|
12815
|
+
}
|
|
12816
|
+
}
|
|
12817
|
+
return { enabled };
|
|
12818
|
+
}
|
|
12140
12819
|
function skillsDisabled(options) {
|
|
12141
12820
|
if (options.noSkills === true) return true;
|
|
12142
12821
|
const value = process.env.JIOOGEN_NO_SKILLS?.trim().toLowerCase();
|
|
@@ -12293,14 +12972,14 @@ async function checkProject(deps, credentials, projectId) {
|
|
|
12293
12972
|
}
|
|
12294
12973
|
async function isFile2(path) {
|
|
12295
12974
|
try {
|
|
12296
|
-
return (await
|
|
12975
|
+
return (await stat5(path)).isFile();
|
|
12297
12976
|
} catch {
|
|
12298
12977
|
return false;
|
|
12299
12978
|
}
|
|
12300
12979
|
}
|
|
12301
12980
|
async function isDirectory2(path) {
|
|
12302
12981
|
try {
|
|
12303
|
-
return (await
|
|
12982
|
+
return (await stat5(path)).isDirectory();
|
|
12304
12983
|
} catch {
|
|
12305
12984
|
return false;
|
|
12306
12985
|
}
|
|
@@ -12422,7 +13101,7 @@ async function checkLock(bundleDir) {
|
|
|
12422
13101
|
const target = lockPath(bundleDir);
|
|
12423
13102
|
let info;
|
|
12424
13103
|
try {
|
|
12425
|
-
info = await
|
|
13104
|
+
info = await stat5(target);
|
|
12426
13105
|
} catch (error) {
|
|
12427
13106
|
if (isMissingFile5(error)) {
|
|
12428
13107
|
return makeCheck("lock", "pass", "Tidak ada lock; sidecar bebas ditulis.");
|
|
@@ -12554,6 +13233,7 @@ async function checkSkillPacks(bundleDir) {
|
|
|
12554
13233
|
);
|
|
12555
13234
|
}
|
|
12556
13235
|
var CAP_ID_RE = /\bCAP-[A-Z0-9-]+\b/g;
|
|
13236
|
+
var CAP_PLACEHOLDER_RE = /^CAP-X+$/;
|
|
12557
13237
|
var TASK_CAP_RE = /^\s*cap:\s*(CAP-[A-Z0-9-]+)/im;
|
|
12558
13238
|
async function collectMarkdownFiles2(root, prefix = "") {
|
|
12559
13239
|
const dir = join8(root, prefix);
|
|
@@ -12583,7 +13263,11 @@ async function checkCapabilityCoverage(bundleDir) {
|
|
|
12583
13263
|
const specCaps = /* @__PURE__ */ new Set();
|
|
12584
13264
|
for (const relative2 of await collectMarkdownFiles2(bundleDir, "specs")) {
|
|
12585
13265
|
const content = await readFile8(join8(bundleDir, relative2), "utf8");
|
|
12586
|
-
for (const match of content.matchAll(CAP_ID_RE))
|
|
13266
|
+
for (const match of content.matchAll(CAP_ID_RE)) {
|
|
13267
|
+
const id = match[0].toUpperCase();
|
|
13268
|
+
if (CAP_PLACEHOLDER_RE.test(id)) continue;
|
|
13269
|
+
specCaps.add(id);
|
|
13270
|
+
}
|
|
12587
13271
|
}
|
|
12588
13272
|
if (taskCaps.size === 0 && specCaps.size === 0) {
|
|
12589
13273
|
return makeCheck("capability-coverage", "pass", "Tidak ada CAP-* (bundle legacy).");
|
|
@@ -12754,7 +13438,7 @@ function formatTable(headers, rows) {
|
|
|
12754
13438
|
|
|
12755
13439
|
// src/recovery.ts
|
|
12756
13440
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
12757
|
-
import { mkdir as mkdir6, readFile as readFile9, rename as
|
|
13441
|
+
import { mkdir as mkdir6, readFile as readFile9, rename as rename3, rm as rm7, writeFile as writeFile6 } from "node:fs/promises";
|
|
12758
13442
|
import { dirname as dirname6, join as join9 } from "node:path";
|
|
12759
13443
|
var RECOVERY_PATH = "tasks/.execution/recovery.json";
|
|
12760
13444
|
var RECOVERY_BUDGET = { maxAttempts: 3 };
|
|
@@ -12812,7 +13496,7 @@ async function writeRecovery(bundleDir, journal) {
|
|
|
12812
13496
|
try {
|
|
12813
13497
|
await writeFile6(temp, `${JSON.stringify(journal, null, 2)}
|
|
12814
13498
|
`, "utf8");
|
|
12815
|
-
await
|
|
13499
|
+
await rename3(temp, target);
|
|
12816
13500
|
} catch (error) {
|
|
12817
13501
|
await rm7(temp, { force: true }).catch(() => {
|
|
12818
13502
|
});
|
|
@@ -12897,7 +13581,7 @@ function describeRecovery(entry) {
|
|
|
12897
13581
|
}
|
|
12898
13582
|
|
|
12899
13583
|
// src/session.ts
|
|
12900
|
-
import { rm as rm8, stat as
|
|
13584
|
+
import { rm as rm8, stat as stat6 } from "node:fs/promises";
|
|
12901
13585
|
import { resolve as resolve4 } from "node:path";
|
|
12902
13586
|
var LOCK_STALE_MS3 = 1e4;
|
|
12903
13587
|
var CHANGE_REQUEST_PREFIX = "Perubahan diminta:";
|
|
@@ -13050,7 +13734,7 @@ async function removeStaleLock2(bundleDir) {
|
|
|
13050
13734
|
const target = lockPath(bundleDir);
|
|
13051
13735
|
let info;
|
|
13052
13736
|
try {
|
|
13053
|
-
info = await
|
|
13737
|
+
info = await stat6(target);
|
|
13054
13738
|
} catch (error) {
|
|
13055
13739
|
if (isMissingFile6(error)) return;
|
|
13056
13740
|
throw error;
|
|
@@ -13134,15 +13818,27 @@ async function loginCommand(options) {
|
|
|
13134
13818
|
options.api ?? envFirst2("JIOOGEN_API", "JIOOCODE_API") ?? DEFAULT_API_URL
|
|
13135
13819
|
);
|
|
13136
13820
|
const client = new ApiClient(apiUrl, `${SESSION_COOKIE}=${token}`);
|
|
13137
|
-
|
|
13821
|
+
let body;
|
|
13822
|
+
try {
|
|
13823
|
+
body = await client.getJson(ENDPOINTS.me);
|
|
13824
|
+
} catch (error) {
|
|
13825
|
+
if (error instanceof ApiError && error.status === 401) {
|
|
13826
|
+
throw new Error(
|
|
13827
|
+
`Token ditolak (401) oleh ${apiUrl}. Token mungkin ditandatangani secret lama sebelum migrasi VPS. Login ulang dengan --email/--password-stdin, atau set AUTH_TOKEN_SECRET_PREVIOUS di server berisi secret lama agar token diperbarui otomatis.`
|
|
13828
|
+
);
|
|
13829
|
+
}
|
|
13830
|
+
throw error;
|
|
13831
|
+
}
|
|
13832
|
+
const renewed = client.renewedCookie !== null;
|
|
13138
13833
|
await writeCredentials({
|
|
13139
13834
|
apiUrl,
|
|
13140
|
-
cookie: `${SESSION_COOKIE}=${token}`,
|
|
13835
|
+
cookie: client.renewedCookie ?? `${SESSION_COOKIE}=${token}`,
|
|
13141
13836
|
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
13142
13837
|
});
|
|
13143
13838
|
console.log(
|
|
13144
13839
|
`Login sebagai ${body.user.email} (${body.user.role}/${body.user.subscriptionPlan}) di ${apiUrl}`
|
|
13145
13840
|
);
|
|
13841
|
+
if (renewed) console.log("Token lama diperbarui otomatis ke secret aktif.");
|
|
13146
13842
|
console.log(`Credential disimpan di ${credentialsPath()} (mode 0600).`);
|
|
13147
13843
|
return;
|
|
13148
13844
|
}
|
|
@@ -13174,6 +13870,48 @@ async function logoutCommand() {
|
|
|
13174
13870
|
const removed = await clearCredentials();
|
|
13175
13871
|
console.log(removed ? "Credential lokal dihapus." : "Tidak ada credential tersimpan.");
|
|
13176
13872
|
}
|
|
13873
|
+
async function unlinkCommand(options) {
|
|
13874
|
+
const link = await findProjectLink(options.dir ?? process.cwd());
|
|
13875
|
+
const bundleDir = resolve6(link?.bundleDir ?? options.dir ?? process.cwd());
|
|
13876
|
+
const removed = await removeProjectLink(bundleDir);
|
|
13877
|
+
if (!removed) {
|
|
13878
|
+
console.log(
|
|
13879
|
+
"Tidak ada project link lokal (.jioogen/project.json) \u2014 bundle tidak terikat project."
|
|
13880
|
+
);
|
|
13881
|
+
return;
|
|
13882
|
+
}
|
|
13883
|
+
console.log(
|
|
13884
|
+
"Project link lokal dilepas (.jioogen/project.json dihapus). Isi bundle dan sidecar tetap tersimpan. Jalankan `jioogen projects` lalu `jioogen pull <id>` untuk bind project lain."
|
|
13885
|
+
);
|
|
13886
|
+
}
|
|
13887
|
+
async function executionStatusCommand(options) {
|
|
13888
|
+
const bundleDir = resolve6(options.dir ?? process.cwd());
|
|
13889
|
+
const hasMarker = await containsExecutionMarker(bundleDir);
|
|
13890
|
+
if (options.json === true) {
|
|
13891
|
+
console.log(JSON.stringify({ bundleDir, executionContract: hasMarker }, null, 2));
|
|
13892
|
+
return;
|
|
13893
|
+
}
|
|
13894
|
+
console.log(
|
|
13895
|
+
hasMarker ? "Kontrak eksekusi: TERPASANG (AGENTS.md/skill eksekusi ada)." : "Kontrak eksekusi: TIDAK terpasang \u2014 bundle bisa dijalankan manual."
|
|
13896
|
+
);
|
|
13897
|
+
}
|
|
13898
|
+
async function executionDisableCommand(options) {
|
|
13899
|
+
const bundleDir = resolve6(options.dir ?? process.cwd());
|
|
13900
|
+
const result = await removeExecutionContract(bundleDir);
|
|
13901
|
+
if (result.removed.length === 0) {
|
|
13902
|
+
console.log("Kontrak eksekusi sudah tidak terpasang (tidak ada yang dihapus).");
|
|
13903
|
+
return;
|
|
13904
|
+
}
|
|
13905
|
+
console.log("Kontrak eksekusi dilepas:");
|
|
13906
|
+
for (const entry of result.removed) console.log(`- ${entry}`);
|
|
13907
|
+
if (result.preserved.length > 0) {
|
|
13908
|
+
console.log("Dilewati (milik user, tidak diubah):");
|
|
13909
|
+
for (const entry of result.preserved) console.log(`- ${entry}`);
|
|
13910
|
+
}
|
|
13911
|
+
console.log(
|
|
13912
|
+
"Bundle sekarang bisa dijalankan manual. Untuk authoring-only: `jioogen authoring install`."
|
|
13913
|
+
);
|
|
13914
|
+
}
|
|
13177
13915
|
async function whoamiCommand(options) {
|
|
13178
13916
|
const { apiUrl, client } = await resolveApi(options);
|
|
13179
13917
|
const body = await client.getJson(ENDPOINTS.me);
|
|
@@ -13231,6 +13969,8 @@ async function pullCommand(projectId, options) {
|
|
|
13231
13969
|
taskMode: options.taskMode,
|
|
13232
13970
|
execution: { uiQuality }
|
|
13233
13971
|
});
|
|
13972
|
+
await scaffoldCustomLayer(target).catch(() => {
|
|
13973
|
+
});
|
|
13234
13974
|
if (options.json === true) {
|
|
13235
13975
|
console.log(JSON.stringify({ projectId, target, files: written, skills }, null, 2));
|
|
13236
13976
|
return;
|
|
@@ -13253,6 +13993,8 @@ async function linkCommand(projectId, options) {
|
|
|
13253
13993
|
taskMode,
|
|
13254
13994
|
execution: { uiQuality }
|
|
13255
13995
|
});
|
|
13996
|
+
await scaffoldCustomLayer(target).catch(() => {
|
|
13997
|
+
});
|
|
13256
13998
|
const skills = await installAgentSkills(target, {
|
|
13257
13999
|
noSkills: skillsDisabled(options),
|
|
13258
14000
|
uiQuality
|
|
@@ -13379,6 +14121,38 @@ async function skillsRemoveCommand(packArgument, options) {
|
|
|
13379
14121
|
console.log(`- ${file} (dilewati: milik user / sudah berubah)`);
|
|
13380
14122
|
}
|
|
13381
14123
|
}
|
|
14124
|
+
async function skillsRestoreCommand(packArgument, options) {
|
|
14125
|
+
const packNames = parseSkillPackArgument(packArgument);
|
|
14126
|
+
if (packNames === null) {
|
|
14127
|
+
throw new UsageError("Pack tidak dikenal. Pilih: baseline | ui-quality | backend-rules | all.");
|
|
14128
|
+
}
|
|
14129
|
+
const bundleDir = await resolveSkillsBundleDir(options);
|
|
14130
|
+
const result = await restoreSkillPack(bundleDir, packArgument);
|
|
14131
|
+
if (options.json === true) {
|
|
14132
|
+
console.log(JSON.stringify({ bundleDir, ...result }, null, 2));
|
|
14133
|
+
return;
|
|
14134
|
+
}
|
|
14135
|
+
console.log(`Skill pack dipulihkan di ${bundleDir}: ${result.restored.length} file.`);
|
|
14136
|
+
for (const file of result.restored) console.log(`- ${file}`);
|
|
14137
|
+
}
|
|
14138
|
+
async function skillsDisableCommand(name, options) {
|
|
14139
|
+
const bundleDir = await resolveSkillsBundleDir(options);
|
|
14140
|
+
const result = await disableSkill(bundleDir, name);
|
|
14141
|
+
if (options.json === true) {
|
|
14142
|
+
console.log(JSON.stringify({ bundleDir, name, ...result }, null, 2));
|
|
14143
|
+
return;
|
|
14144
|
+
}
|
|
14145
|
+
console.log(`Skill ${name} dinonaktifkan di ${bundleDir}: ${result.disabled.length} lokasi.`);
|
|
14146
|
+
}
|
|
14147
|
+
async function skillsEnableCommand(name, options) {
|
|
14148
|
+
const bundleDir = await resolveSkillsBundleDir(options);
|
|
14149
|
+
const result = await enableSkill(bundleDir, name);
|
|
14150
|
+
if (options.json === true) {
|
|
14151
|
+
console.log(JSON.stringify({ bundleDir, name, ...result }, null, 2));
|
|
14152
|
+
return;
|
|
14153
|
+
}
|
|
14154
|
+
console.log(`Skill ${name} diaktifkan di ${bundleDir}: ${result.enabled.length} lokasi.`);
|
|
14155
|
+
}
|
|
13382
14156
|
async function resolveSkillsBundleDir(options) {
|
|
13383
14157
|
const link = await findProjectLink(options.dir ?? process.cwd());
|
|
13384
14158
|
return resolve6(link?.bundleDir ?? options.dir ?? process.cwd());
|
|
@@ -13535,7 +14309,7 @@ async function taskNextCommand(options) {
|
|
|
13535
14309
|
bundleDir: local.bundleDir,
|
|
13536
14310
|
definitions: local.definitions,
|
|
13537
14311
|
written: written2,
|
|
13538
|
-
next: selectNext(local.definitions, written2.tasks)
|
|
14312
|
+
next: selectNext(local.definitions, written2.tasks, { lenient: options.lenient })
|
|
13539
14313
|
};
|
|
13540
14314
|
}
|
|
13541
14315
|
);
|
|
@@ -13546,12 +14320,18 @@ async function taskNextCommand(options) {
|
|
|
13546
14320
|
next === null ? {} : { focusRef: next.task.id }
|
|
13547
14321
|
).catch(() => []);
|
|
13548
14322
|
if (next === null) {
|
|
14323
|
+
const completion = computeCompletion(written.tasks, completionDefinitions(definitions));
|
|
13549
14324
|
if (options.json === true) {
|
|
13550
|
-
console.log(JSON.stringify({ done: true, projectId, drift }, null, 2));
|
|
14325
|
+
console.log(JSON.stringify({ done: true, projectId, drift, completion }, null, 2));
|
|
13551
14326
|
return;
|
|
13552
14327
|
}
|
|
13553
14328
|
for (const finding of drift) console.warn(formatDrift(finding));
|
|
13554
|
-
|
|
14329
|
+
if (completion.projectComplete) {
|
|
14330
|
+
console.log("Semua task selesai.");
|
|
14331
|
+
} else {
|
|
14332
|
+
console.log(printCompletionGaps(completion));
|
|
14333
|
+
printSeedReBreakdown();
|
|
14334
|
+
}
|
|
13555
14335
|
const blocked = blockedTasks(definitions, written.tasks);
|
|
13556
14336
|
if (blocked.length > 0) {
|
|
13557
14337
|
console.log("\nTask yang masih menunggu dependency:");
|
|
@@ -13578,9 +14358,10 @@ async function taskNextCommand(options) {
|
|
|
13578
14358
|
return;
|
|
13579
14359
|
}
|
|
13580
14360
|
const manifest = await readHarnessManifest(bundleDir);
|
|
13581
|
-
const context = manifest === null ?
|
|
14361
|
+
const context = manifest === null ? { bundleDir } : {
|
|
13582
14362
|
productKind: manifest.productKind,
|
|
13583
|
-
skills: manifest.packs.flatMap((pack) => pack.skills.map((skill) => skill.name))
|
|
14363
|
+
skills: manifest.packs.flatMap((pack) => pack.skills.map((skill) => skill.name)),
|
|
14364
|
+
bundleDir
|
|
13584
14365
|
};
|
|
13585
14366
|
const instruction = renderActiveTask(next.task, context);
|
|
13586
14367
|
if (options.json === true) {
|
|
@@ -13602,6 +14383,18 @@ async function taskNextCommand(options) {
|
|
|
13602
14383
|
);
|
|
13603
14384
|
return;
|
|
13604
14385
|
}
|
|
14386
|
+
const hasBundleDrift = drift.some((finding) => finding.code === "BUNDLE_DRIFT");
|
|
14387
|
+
if (hasBundleDrift) {
|
|
14388
|
+
console.log("");
|
|
14389
|
+
console.log("\u26A0 BUNDLE_DRIFT terdeteksi: PRD.md/specs/tasks berubah di disk.");
|
|
14390
|
+
console.log(" Contract tidak boleh diedit lokal. Pilih:");
|
|
14391
|
+
console.log(" - perubahan tidak disengaja: `git checkout -- PRD.md specs tasks`");
|
|
14392
|
+
console.log(
|
|
14393
|
+
" - perubahan disengaja: revisi via https://gen.jioo.site lalu `jioogen pull --force`"
|
|
14394
|
+
);
|
|
14395
|
+
console.log(" - audit detail: `jioogen drift`");
|
|
14396
|
+
console.log("");
|
|
14397
|
+
}
|
|
13605
14398
|
if (awaitingCheckpoint) {
|
|
13606
14399
|
console.log(
|
|
13607
14400
|
`Checkpoint aktif: ${written.current?.ref ?? "-"}. Minta konfirmasi user sebelum melanjutkan.`
|
|
@@ -13683,8 +14476,15 @@ async function taskStartCommand(ref, options) {
|
|
|
13683
14476
|
`Task ${ref} berstatus RECOVERY_EXHAUSTED. Jalankan \`jioogen resume\` lalu ulangi dengan pendekatan berbeda.`
|
|
13684
14477
|
);
|
|
13685
14478
|
}
|
|
13686
|
-
|
|
13687
|
-
|
|
14479
|
+
const resolvedState = await resolveOrAssertDependencies(
|
|
14480
|
+
ref,
|
|
14481
|
+
local.definitions,
|
|
14482
|
+
local.state,
|
|
14483
|
+
local.bundleDir,
|
|
14484
|
+
options,
|
|
14485
|
+
"start"
|
|
14486
|
+
);
|
|
14487
|
+
const updated = withStatus(resolvedState, ref, "in_progress", {
|
|
13688
14488
|
awaitingCheckpoint: false,
|
|
13689
14489
|
note: ""
|
|
13690
14490
|
});
|
|
@@ -13704,11 +14504,18 @@ async function taskStartCommand(ref, options) {
|
|
|
13704
14504
|
}
|
|
13705
14505
|
async function finishTask(ref, options, extra = {}) {
|
|
13706
14506
|
return withLocalState(options, async (local) => {
|
|
13707
|
-
|
|
14507
|
+
const resolvedState = await resolveOrAssertDependencies(
|
|
14508
|
+
ref,
|
|
14509
|
+
local.definitions,
|
|
14510
|
+
local.state,
|
|
14511
|
+
local.bundleDir,
|
|
14512
|
+
options,
|
|
14513
|
+
"complete"
|
|
14514
|
+
);
|
|
13708
14515
|
const key = ref.trim().toUpperCase();
|
|
13709
14516
|
const definition = local.definitions.find((entry) => entry.id.toUpperCase() === key);
|
|
13710
14517
|
const verificationCommand = definition === void 0 ? null : verificationCommandFromContent(definition.content);
|
|
13711
|
-
const stateTask =
|
|
14518
|
+
const stateTask = resolvedState.tasks.find((entry) => entry.ref.toUpperCase() === key);
|
|
13712
14519
|
if (options.force !== true) {
|
|
13713
14520
|
if (verificationCommand === null) {
|
|
13714
14521
|
throw new Error(
|
|
@@ -13717,7 +14524,9 @@ async function finishTask(ref, options, extra = {}) {
|
|
|
13717
14524
|
}
|
|
13718
14525
|
const proof = stateTask?.verification;
|
|
13719
14526
|
const proofCommand = proof?.command === void 0 ? void 0 : normalizeVerificationCommand(proof.command);
|
|
13720
|
-
|
|
14527
|
+
const expectedCommand = normalizeVerificationCommand(verificationCommand);
|
|
14528
|
+
const commandMatches = proofCommand !== void 0 && (proofCommand === expectedCommand || options.lenient === true);
|
|
14529
|
+
if (proof === void 0 || proof.exitCode !== 0 || !commandMatches) {
|
|
13721
14530
|
throw new Error(`Task ${ref} belum diverifikasi. Jalankan \`jioogen task verify ${ref}\`.`);
|
|
13722
14531
|
}
|
|
13723
14532
|
if (stateTask?.designReview?.passed === false) {
|
|
@@ -13729,7 +14538,8 @@ async function finishTask(ref, options, extra = {}) {
|
|
|
13729
14538
|
if (verificationCommand !== null) {
|
|
13730
14539
|
const proof = stateTask?.verification;
|
|
13731
14540
|
const proofCommand = proof?.command === void 0 ? void 0 : normalizeVerificationCommand(proof.command);
|
|
13732
|
-
|
|
14541
|
+
const expectedCommand = normalizeVerificationCommand(verificationCommand);
|
|
14542
|
+
if (proof === void 0 || proof.exitCode !== 0 || proofCommand !== expectedCommand) {
|
|
13733
14543
|
console.warn(`Warning: bypass verification requirement for ${ref}.`);
|
|
13734
14544
|
}
|
|
13735
14545
|
if (stateTask?.designReview?.passed === false) {
|
|
@@ -13739,7 +14549,7 @@ async function finishTask(ref, options, extra = {}) {
|
|
|
13739
14549
|
console.warn(`Warning: task ${ref} has no verificationCommand (legacy bypass).`);
|
|
13740
14550
|
}
|
|
13741
14551
|
}
|
|
13742
|
-
let completed = withStatus(
|
|
14552
|
+
let completed = withStatus(resolvedState, ref, "done", {
|
|
13743
14553
|
note: options.note ?? "",
|
|
13744
14554
|
awaitingCheckpoint: false
|
|
13745
14555
|
});
|
|
@@ -13752,7 +14562,7 @@ async function finishTask(ref, options, extra = {}) {
|
|
|
13752
14562
|
});
|
|
13753
14563
|
}
|
|
13754
14564
|
const completedTask = completed.tasks.find((entry) => entry.ref.toUpperCase() === key);
|
|
13755
|
-
const next = selectNext(local.definitions, completed.tasks);
|
|
14565
|
+
const next = selectNext(local.definitions, completed.tasks, { lenient: options.lenient });
|
|
13756
14566
|
const risky = definition !== void 0 && isRiskyTask(definition);
|
|
13757
14567
|
const boundary = completedTask !== void 0 && (next !== null && isBoundary(completedTask, next.task) || risky);
|
|
13758
14568
|
let finalState = completed;
|
|
@@ -13774,19 +14584,24 @@ async function finishTask(ref, options, extra = {}) {
|
|
|
13774
14584
|
completedTask: written.tasks.find((entry) => entry.ref.toUpperCase() === key),
|
|
13775
14585
|
next,
|
|
13776
14586
|
checkpoint: boundary,
|
|
14587
|
+
completion: computeCompletion(written.tasks, completionDefinitions(local.definitions)),
|
|
13777
14588
|
bundleDir: local.bundleDir,
|
|
13778
14589
|
context: local
|
|
13779
14590
|
};
|
|
13780
14591
|
});
|
|
13781
14592
|
}
|
|
13782
14593
|
async function taskCompleteCommand(ref, options) {
|
|
13783
|
-
const { completedTask, next, checkpoint, bundleDir, context } = await finishTask(
|
|
14594
|
+
const { completedTask, next, checkpoint, completion, bundleDir, context } = await finishTask(
|
|
14595
|
+
ref,
|
|
14596
|
+
options
|
|
14597
|
+
);
|
|
13784
14598
|
await recordSuccess(bundleDir, ref.trim().toUpperCase());
|
|
13785
14599
|
await pushSidecarBestEffort(options, context);
|
|
13786
14600
|
console.log(`Done ${completedTask?.ref ?? ref}.`);
|
|
13787
14601
|
if (checkpoint) {
|
|
13788
14602
|
if (next === null) {
|
|
13789
14603
|
console.log("Semua task selesai; menunggu review terakhir.");
|
|
14604
|
+
printSeedGapTrigger(completion, next);
|
|
13790
14605
|
} else {
|
|
13791
14606
|
console.log(
|
|
13792
14607
|
`Checkpoint berikutnya: ${next.task.id} (${next.task.layer ?? "-"} / phase ${next.task.phase}).`
|
|
@@ -13798,6 +14613,7 @@ async function taskCompleteCommand(ref, options) {
|
|
|
13798
14613
|
return;
|
|
13799
14614
|
}
|
|
13800
14615
|
if (next !== null) console.log(`Berikutnya: ${next.task.id} \u2014 ${next.task.title}`);
|
|
14616
|
+
printSeedGapTrigger(completion, next);
|
|
13801
14617
|
console.log(
|
|
13802
14618
|
"Monitor web: status dikirim otomatis; jalankan `jioogen sync` bila tadi ada peringatan."
|
|
13803
14619
|
);
|
|
@@ -13842,6 +14658,33 @@ async function stampVerification(context, definitions, ref, proof, visualSummary
|
|
|
13842
14658
|
await writeState(context.bundleDir, next);
|
|
13843
14659
|
});
|
|
13844
14660
|
}
|
|
14661
|
+
async function resolveFallbackVerificationCommand(bundleDir, failedCommand) {
|
|
14662
|
+
let pkgRaw;
|
|
14663
|
+
try {
|
|
14664
|
+
pkgRaw = await readFile10(join10(bundleDir, "package.json"), "utf8");
|
|
14665
|
+
} catch {
|
|
14666
|
+
return null;
|
|
14667
|
+
}
|
|
14668
|
+
let pkg;
|
|
14669
|
+
try {
|
|
14670
|
+
pkg = JSON.parse(pkgRaw);
|
|
14671
|
+
} catch {
|
|
14672
|
+
return null;
|
|
14673
|
+
}
|
|
14674
|
+
const scripts = pkg.scripts;
|
|
14675
|
+
if (!scripts || typeof scripts !== "object") return null;
|
|
14676
|
+
const candidateKeys = ["test", "test:unit", "check", "lint", "build"];
|
|
14677
|
+
const normFailed = normalizeVerificationCommand(failedCommand);
|
|
14678
|
+
for (const key of candidateKeys) {
|
|
14679
|
+
if (typeof scripts[key] === "string" && scripts[key].trim().length > 0) {
|
|
14680
|
+
const candidateCmd = key === "test" ? "npm test" : `npm run ${key}`;
|
|
14681
|
+
if (normalizeVerificationCommand(candidateCmd) !== normFailed) {
|
|
14682
|
+
return candidateCmd;
|
|
14683
|
+
}
|
|
14684
|
+
}
|
|
14685
|
+
}
|
|
14686
|
+
return null;
|
|
14687
|
+
}
|
|
13845
14688
|
async function taskVerifyCommand(ref, options) {
|
|
13846
14689
|
const context = await resolveLocalBundle(options);
|
|
13847
14690
|
const definitions = await loadTasks(context.bundleDir);
|
|
@@ -13857,20 +14700,32 @@ async function taskVerifyCommand(ref, options) {
|
|
|
13857
14700
|
}
|
|
13858
14701
|
const timeoutMs = verifyTimeoutMs();
|
|
13859
14702
|
const startedAt = Date.now();
|
|
13860
|
-
|
|
14703
|
+
let executedCommand = command;
|
|
14704
|
+
let result = await runVerification(command, context.bundleDir, timeoutMs);
|
|
14705
|
+
if (result.exitCode !== 0) {
|
|
14706
|
+
const fallback = await resolveFallbackVerificationCommand(context.bundleDir, command);
|
|
14707
|
+
if (fallback !== null) {
|
|
14708
|
+
const fallbackResult = await runVerification(fallback, context.bundleDir, timeoutMs);
|
|
14709
|
+
if (fallbackResult.exitCode === 0) {
|
|
14710
|
+
executedCommand = fallback;
|
|
14711
|
+
result = fallbackResult;
|
|
14712
|
+
console.log(`\u2139 Perintah utama gagal, tetapi fallback verifikasi berhasil: \`${fallback}\``);
|
|
14713
|
+
}
|
|
14714
|
+
}
|
|
14715
|
+
}
|
|
13861
14716
|
const durationMs = Date.now() - startedAt;
|
|
13862
14717
|
const at = (/* @__PURE__ */ new Date()).toISOString();
|
|
13863
14718
|
await stampVerification(
|
|
13864
14719
|
context,
|
|
13865
14720
|
definitions,
|
|
13866
14721
|
definition.id,
|
|
13867
|
-
{ command, exitCode: result.exitCode, durationMs, at },
|
|
14722
|
+
{ command: executedCommand, exitCode: result.exitCode, durationMs, at },
|
|
13868
14723
|
options.visual?.trim()
|
|
13869
14724
|
);
|
|
13870
14725
|
await pushSidecarBestEffort(options, context);
|
|
13871
14726
|
const payload = {
|
|
13872
14727
|
ref: definition.id,
|
|
13873
|
-
command,
|
|
14728
|
+
command: executedCommand,
|
|
13874
14729
|
exitCode: result.exitCode,
|
|
13875
14730
|
durationMs,
|
|
13876
14731
|
at,
|
|
@@ -13902,12 +14757,38 @@ async function taskAdoptCommand(ref, options) {
|
|
|
13902
14757
|
}
|
|
13903
14758
|
const existing = await readState(context.bundleDir);
|
|
13904
14759
|
const known = existing ?? createState(context.projectId, definitions);
|
|
13905
|
-
|
|
14760
|
+
const resolvedState = await resolveOrAssertDependencies(
|
|
14761
|
+
definition.id,
|
|
14762
|
+
definitions,
|
|
14763
|
+
known,
|
|
14764
|
+
context.bundleDir,
|
|
14765
|
+
options,
|
|
14766
|
+
"adopt"
|
|
14767
|
+
);
|
|
14768
|
+
await writeState(context.bundleDir, resolvedState);
|
|
13906
14769
|
const command = verificationCommandFromContent(definition.content);
|
|
13907
14770
|
let verification = null;
|
|
13908
14771
|
if (command !== null) {
|
|
13909
14772
|
const startedAt = Date.now();
|
|
13910
|
-
|
|
14773
|
+
let executedCommand = command;
|
|
14774
|
+
let result2 = await runVerification(command, context.bundleDir, verifyTimeoutMs());
|
|
14775
|
+
if (result2.exitCode !== 0) {
|
|
14776
|
+
const fallback = await resolveFallbackVerificationCommand(context.bundleDir, command);
|
|
14777
|
+
if (fallback !== null) {
|
|
14778
|
+
const fallbackResult = await runVerification(
|
|
14779
|
+
fallback,
|
|
14780
|
+
context.bundleDir,
|
|
14781
|
+
verifyTimeoutMs()
|
|
14782
|
+
);
|
|
14783
|
+
if (fallbackResult.exitCode === 0) {
|
|
14784
|
+
executedCommand = fallback;
|
|
14785
|
+
result2 = fallbackResult;
|
|
14786
|
+
console.log(
|
|
14787
|
+
`\u2139 Perintah utama gagal, tetapi fallback verifikasi berhasil: \`${fallback}\``
|
|
14788
|
+
);
|
|
14789
|
+
}
|
|
14790
|
+
}
|
|
14791
|
+
}
|
|
13911
14792
|
const durationMs = Date.now() - startedAt;
|
|
13912
14793
|
if (result2.exitCode !== 0) {
|
|
13913
14794
|
throw new Error(
|
|
@@ -13919,10 +14800,10 @@ async function taskAdoptCommand(ref, options) {
|
|
|
13919
14800
|
context,
|
|
13920
14801
|
definitions,
|
|
13921
14802
|
definition.id,
|
|
13922
|
-
{ command, exitCode: 0, durationMs, at },
|
|
14803
|
+
{ command: executedCommand, exitCode: 0, durationMs, at },
|
|
13923
14804
|
options.visual?.trim()
|
|
13924
14805
|
);
|
|
13925
|
-
verification = { command, exitCode: 0, durationMs, at };
|
|
14806
|
+
verification = { command: executedCommand, exitCode: 0, durationMs, at };
|
|
13926
14807
|
} else if (options.force !== true) {
|
|
13927
14808
|
throw new Error(
|
|
13928
14809
|
`Task ${ref} tidak punya verificationCommand. Gunakan --force hanya untuk task legacy, dan catat alasan di --note.`
|
|
@@ -13958,6 +14839,7 @@ async function taskAdoptCommand(ref, options) {
|
|
|
13958
14839
|
console.log(
|
|
13959
14840
|
result.next === null ? "Semua task selesai; menunggu review terakhir." : `Checkpoint berikutnya: ${result.next.task.id} (${result.next.task.layer ?? "-"} / phase ${result.next.task.phase}).`
|
|
13960
14841
|
);
|
|
14842
|
+
printSeedGapTrigger(result.completion, result.next);
|
|
13961
14843
|
console.log(
|
|
13962
14844
|
'Berhenti. Setelah user memutuskan: `jioogen review --approve`, `--request-changes "<teks>"`, atau `--stop`.'
|
|
13963
14845
|
);
|
|
@@ -13965,6 +14847,7 @@ async function taskAdoptCommand(ref, options) {
|
|
|
13965
14847
|
}
|
|
13966
14848
|
if (result.next !== null)
|
|
13967
14849
|
console.log(`Berikutnya: ${result.next.task.id} \u2014 ${result.next.task.title}`);
|
|
14850
|
+
printSeedGapTrigger(result.completion, result.next);
|
|
13968
14851
|
console.log(
|
|
13969
14852
|
"Monitor web: status dikirim otomatis; jalankan `jioogen sync` bila tadi ada peringatan."
|
|
13970
14853
|
);
|
|
@@ -14095,19 +14978,177 @@ async function statusCommand(options) {
|
|
|
14095
14978
|
console.log(`Project ${projectId}: belum ada sidecar. Jalankan \`jioogen task next\`.`);
|
|
14096
14979
|
return;
|
|
14097
14980
|
}
|
|
14981
|
+
let reconciled = existing;
|
|
14982
|
+
try {
|
|
14983
|
+
reconciled = mergeTasks(existing, await loadTasks(bundleDir));
|
|
14984
|
+
} catch {
|
|
14985
|
+
}
|
|
14098
14986
|
printExecution(
|
|
14099
14987
|
{
|
|
14100
|
-
tasks:
|
|
14101
|
-
counts:
|
|
14102
|
-
current:
|
|
14103
|
-
updatedAt:
|
|
14988
|
+
tasks: reconciled.tasks,
|
|
14989
|
+
counts: reconciled.counts ?? summarizeExecutionCounts(reconciled.tasks),
|
|
14990
|
+
current: reconciled.current ?? null,
|
|
14991
|
+
updatedAt: reconciled.updatedAt ?? null
|
|
14104
14992
|
},
|
|
14105
14993
|
options.json === true
|
|
14106
14994
|
);
|
|
14107
14995
|
}
|
|
14996
|
+
async function contractUpdateBaselineCommand(options) {
|
|
14997
|
+
const { bundleDir } = await resolveLocalBundle(options);
|
|
14998
|
+
const newBundleHash = await updateContractBaseline(bundleDir);
|
|
14999
|
+
console.log(`Baseline kontrak diupdate. Hash baru: ${newBundleHash}`);
|
|
15000
|
+
console.log(`File terverifikasi: PRD.md, traceability.md, specs/, tasks/`);
|
|
15001
|
+
console.log(`Perubahan lokal disetujui sebagai baseline baru.`);
|
|
15002
|
+
console.log(`Jalankan \`jioogen task next\` untuk melanjutkan.`);
|
|
15003
|
+
}
|
|
15004
|
+
async function driftCommand(options) {
|
|
15005
|
+
const { bundleDir } = await resolveLocalBundle(options);
|
|
15006
|
+
if (options.acknowledge === true) {
|
|
15007
|
+
const marker = await acknowledgeDrift(
|
|
15008
|
+
bundleDir,
|
|
15009
|
+
{
|
|
15010
|
+
pruned: options.pruned === true,
|
|
15011
|
+
prd: options.prd === true,
|
|
15012
|
+
specs: options.specs === true,
|
|
15013
|
+
tasks: options.tasks === true
|
|
15014
|
+
},
|
|
15015
|
+
options.note
|
|
15016
|
+
);
|
|
15017
|
+
if (options.json === true) {
|
|
15018
|
+
console.log(JSON.stringify({ bundleDir, acknowledged: marker }, null, 2));
|
|
15019
|
+
return;
|
|
15020
|
+
}
|
|
15021
|
+
console.log(`Drift acknowledged di ${bundleDir}: ${JSON.stringify(marker)}`);
|
|
15022
|
+
return;
|
|
15023
|
+
}
|
|
15024
|
+
const definitions = await loadTasks(bundleDir);
|
|
15025
|
+
const state = await readState(bundleDir);
|
|
15026
|
+
if (state === null) {
|
|
15027
|
+
if (options.json === true) {
|
|
15028
|
+
console.log(JSON.stringify({ bundleDir, findings: [] }, null, 2));
|
|
15029
|
+
return;
|
|
15030
|
+
}
|
|
15031
|
+
console.log(`Project bundle ${bundleDir}: belum ada sidecar; drift belum bisa dibandingkan.`);
|
|
15032
|
+
console.log("Jalankan `jioogen task next` dulu untuk membuat baseline.");
|
|
15033
|
+
return;
|
|
15034
|
+
}
|
|
15035
|
+
const findings = await detectDrift(bundleDir, definitions, state);
|
|
15036
|
+
if (options.json === true) {
|
|
15037
|
+
console.log(JSON.stringify({ bundleDir, findings }, null, 2));
|
|
15038
|
+
if (options.strict === true && findings.some((finding) => finding.severity === "warn")) {
|
|
15039
|
+
process.exitCode = 1;
|
|
15040
|
+
}
|
|
15041
|
+
return;
|
|
15042
|
+
}
|
|
15043
|
+
if (findings.length === 0) {
|
|
15044
|
+
console.log(`Drift check ${bundleDir}: tidak ada perubahan di luar harness.`);
|
|
15045
|
+
return;
|
|
15046
|
+
}
|
|
15047
|
+
for (const finding of findings) {
|
|
15048
|
+
console.log(formatDrift(finding));
|
|
15049
|
+
}
|
|
15050
|
+
const hasWarn = findings.some((finding) => finding.severity === "warn");
|
|
15051
|
+
if (hasWarn) {
|
|
15052
|
+
console.log("");
|
|
15053
|
+
console.log("Saran:");
|
|
15054
|
+
console.log(
|
|
15055
|
+
"- Perubahan tidak disengaja pada PRD.md/specs/tasks: `git checkout -- PRD.md specs tasks`"
|
|
15056
|
+
);
|
|
15057
|
+
console.log(
|
|
15058
|
+
"- Perubahan kontrak disengaja: revisi via workspace web (https://gen.jioo.site), lalu `jioogen pull --force`."
|
|
15059
|
+
);
|
|
15060
|
+
console.log(
|
|
15061
|
+
"- Perubahan di scope task: `jioogen task adopt <ref>` (setelah verifikasi) atau `jioogen task reset <ref>`."
|
|
15062
|
+
);
|
|
15063
|
+
}
|
|
15064
|
+
if (options.strict === true && hasWarn) process.exitCode = 1;
|
|
15065
|
+
}
|
|
15066
|
+
async function baselineListCommand(options) {
|
|
15067
|
+
const bundleDir = await resolveSkillsBundleDir(options);
|
|
15068
|
+
const manifest = await readHarnessManifest(bundleDir);
|
|
15069
|
+
const knowledgeDir = join10(bundleDir, ".jioogen", "custom", "knowledge");
|
|
15070
|
+
let knowledgeFiles = [];
|
|
15071
|
+
try {
|
|
15072
|
+
const entries = await readdir7(knowledgeDir, { withFileTypes: true });
|
|
15073
|
+
knowledgeFiles = entries.filter((entry) => entry.isFile()).map((entry) => entry.name).sort();
|
|
15074
|
+
} catch {
|
|
15075
|
+
knowledgeFiles = [];
|
|
15076
|
+
}
|
|
15077
|
+
const nonEmptyKnowledge = [];
|
|
15078
|
+
for (const name of knowledgeFiles) {
|
|
15079
|
+
try {
|
|
15080
|
+
const content = await readFile10(join10(knowledgeDir, name), "utf8");
|
|
15081
|
+
if (content.trim().length > 0) nonEmptyKnowledge.push(name);
|
|
15082
|
+
} catch {
|
|
15083
|
+
}
|
|
15084
|
+
}
|
|
15085
|
+
const customSkillsDir = join10(bundleDir, ".jioogen", "custom", "skills");
|
|
15086
|
+
let customSkillNames = [];
|
|
15087
|
+
try {
|
|
15088
|
+
const entries = await readdir7(customSkillsDir, { withFileTypes: true });
|
|
15089
|
+
customSkillNames = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
15090
|
+
} catch {
|
|
15091
|
+
customSkillNames = [];
|
|
15092
|
+
}
|
|
15093
|
+
const agentsPath = join10(bundleDir, "AGENTS.md");
|
|
15094
|
+
let agentsExists = false;
|
|
15095
|
+
let agentsBaseline = false;
|
|
15096
|
+
try {
|
|
15097
|
+
const content = await readFile10(agentsPath, "utf8");
|
|
15098
|
+
agentsExists = true;
|
|
15099
|
+
agentsBaseline = content.includes("jioogen-execution-skill");
|
|
15100
|
+
} catch {
|
|
15101
|
+
agentsExists = false;
|
|
15102
|
+
}
|
|
15103
|
+
const areas = [
|
|
15104
|
+
{
|
|
15105
|
+
area: "skills packs",
|
|
15106
|
+
baselineInstalled: manifest !== null && (manifest.packs?.length ?? 0) > 0,
|
|
15107
|
+
customized: (manifest?.custom?.length ?? 0) > 0,
|
|
15108
|
+
path: ".jioogen/harness.json"
|
|
15109
|
+
},
|
|
15110
|
+
{
|
|
15111
|
+
area: "custom skills",
|
|
15112
|
+
baselineInstalled: customSkillNames.length > 0,
|
|
15113
|
+
customized: customSkillNames.length > 0,
|
|
15114
|
+
path: ".jioogen/custom/skills"
|
|
15115
|
+
},
|
|
15116
|
+
{
|
|
15117
|
+
area: "knowledge",
|
|
15118
|
+
baselineInstalled: knowledgeFiles.length > 0,
|
|
15119
|
+
customized: nonEmptyKnowledge.length > 0,
|
|
15120
|
+
path: ".jioogen/custom/knowledge"
|
|
15121
|
+
},
|
|
15122
|
+
{
|
|
15123
|
+
area: "AGENTS.md/instructions",
|
|
15124
|
+
baselineInstalled: agentsBaseline,
|
|
15125
|
+
customized: agentsExists && !agentsBaseline,
|
|
15126
|
+
path: "AGENTS.md"
|
|
15127
|
+
}
|
|
15128
|
+
];
|
|
15129
|
+
if (options.json === true) {
|
|
15130
|
+
console.log(JSON.stringify({ bundleDir, areas }, null, 2));
|
|
15131
|
+
return;
|
|
15132
|
+
}
|
|
15133
|
+
console.log(`Baseline status ${bundleDir}:`);
|
|
15134
|
+
for (const area of areas) {
|
|
15135
|
+
console.log(
|
|
15136
|
+
`- ${area.area}: baseline=${area.baselineInstalled ? "yes" : "no"}, customized=${area.customized ? "yes" : "no"}, path=${area.path}`
|
|
15137
|
+
);
|
|
15138
|
+
}
|
|
15139
|
+
}
|
|
14108
15140
|
async function monitorCommand(options) {
|
|
14109
|
-
const { client, projectId } = await resolveBundle(options);
|
|
14110
|
-
|
|
15141
|
+
const { client, projectId, bundleDir } = await resolveBundle(options);
|
|
15142
|
+
let snapshot;
|
|
15143
|
+
try {
|
|
15144
|
+
snapshot = await client.getJson(projectPath(projectId, "/execution"));
|
|
15145
|
+
} catch (error) {
|
|
15146
|
+
if (error instanceof ApiError && error.status === 404) {
|
|
15147
|
+
await handleProjectGone(bundleDir);
|
|
15148
|
+
return;
|
|
15149
|
+
}
|
|
15150
|
+
throw error;
|
|
15151
|
+
}
|
|
14111
15152
|
if (options.json === true) {
|
|
14112
15153
|
console.log(JSON.stringify(snapshot, null, 2));
|
|
14113
15154
|
return;
|
|
@@ -14146,21 +15187,102 @@ async function syncCommand(options) {
|
|
|
14146
15187
|
});
|
|
14147
15188
|
}
|
|
14148
15189
|
}
|
|
14149
|
-
|
|
14150
|
-
|
|
14151
|
-
|
|
15190
|
+
let result;
|
|
15191
|
+
try {
|
|
15192
|
+
result = await client.postJson(projectPath(projectId, "/artifacts"), {
|
|
15193
|
+
files
|
|
15194
|
+
});
|
|
15195
|
+
} catch (error) {
|
|
15196
|
+
if (error instanceof ApiError && error.status === 404) {
|
|
15197
|
+
await handleProjectGone(bundleDir);
|
|
15198
|
+
return;
|
|
15199
|
+
}
|
|
15200
|
+
throw error;
|
|
15201
|
+
}
|
|
14152
15202
|
if (options.json === true) {
|
|
14153
15203
|
console.log(JSON.stringify(result, null, 2));
|
|
14154
15204
|
return;
|
|
14155
15205
|
}
|
|
14156
15206
|
console.log(`Synced ${result.written?.length ?? 0} file.`);
|
|
15207
|
+
const sidecarSynced = result.written?.some((p) => p.startsWith("tasks/.execution/")) ?? false;
|
|
15208
|
+
if (sidecarSynced) {
|
|
15209
|
+
console.log("\u2714 Status eksekusi & kemajuan task berhasil disinkronkan ke monitor web.");
|
|
15210
|
+
}
|
|
14157
15211
|
if (result.rejected !== void 0 && result.rejected.length > 0) {
|
|
14158
15212
|
for (const rejection of result.rejected) {
|
|
14159
|
-
|
|
15213
|
+
if (rejection.code === "PRD_CONFIRMED") {
|
|
15214
|
+
console.log(
|
|
15215
|
+
`\u2139 PRD.md di server dipertahankan (karena sudah dikonfirmasi di web). Gunakan web UI bila ingin merevisi PRD.`
|
|
15216
|
+
);
|
|
15217
|
+
} else {
|
|
15218
|
+
console.log(`Ditolak: ${rejection.path} (${rejection.code}) \u2014 ${rejection.reason}`);
|
|
15219
|
+
}
|
|
14160
15220
|
}
|
|
14161
15221
|
}
|
|
14162
15222
|
if (result.warning !== void 0) console.log(`Peringatan: ${result.warning}`);
|
|
14163
15223
|
}
|
|
15224
|
+
async function reconcileCommand(options) {
|
|
15225
|
+
const result = await withLocalState(options, async (local) => {
|
|
15226
|
+
const backupFile = await backupExecutionState(local.bundleDir);
|
|
15227
|
+
const { state: reconciledState, result: recResult } = await reconcileCodebase(
|
|
15228
|
+
local.bundleDir,
|
|
15229
|
+
local.definitions,
|
|
15230
|
+
local.state
|
|
15231
|
+
);
|
|
15232
|
+
let writtenState = reconciledState;
|
|
15233
|
+
if (options.dryRun !== true) {
|
|
15234
|
+
writtenState = await writeState(local.bundleDir, reconciledState);
|
|
15235
|
+
}
|
|
15236
|
+
const next = selectNext(local.definitions, writtenState.tasks, {
|
|
15237
|
+
lenient: options.lenient
|
|
15238
|
+
});
|
|
15239
|
+
return {
|
|
15240
|
+
backupFile,
|
|
15241
|
+
recResult,
|
|
15242
|
+
next,
|
|
15243
|
+
writtenState,
|
|
15244
|
+
context: local
|
|
15245
|
+
};
|
|
15246
|
+
});
|
|
15247
|
+
if (options.dryRun !== true) {
|
|
15248
|
+
await pushSidecarBestEffort(options, result.context);
|
|
15249
|
+
}
|
|
15250
|
+
if (options.json === true) {
|
|
15251
|
+
console.log(
|
|
15252
|
+
JSON.stringify(
|
|
15253
|
+
{
|
|
15254
|
+
backupFile: result.backupFile,
|
|
15255
|
+
dryRun: options.dryRun === true,
|
|
15256
|
+
adopted: result.recResult.adopted,
|
|
15257
|
+
remaining: result.recResult.remaining,
|
|
15258
|
+
total: result.recResult.total,
|
|
15259
|
+
next: result.next?.task.id ?? null
|
|
15260
|
+
},
|
|
15261
|
+
null,
|
|
15262
|
+
2
|
|
15263
|
+
)
|
|
15264
|
+
);
|
|
15265
|
+
return;
|
|
15266
|
+
}
|
|
15267
|
+
console.log("\u2714 Rekonsiliasi codebase selesai.");
|
|
15268
|
+
if (result.backupFile !== null) {
|
|
15269
|
+
console.log(` Backup state disimpan di: ${result.backupFile}`);
|
|
15270
|
+
}
|
|
15271
|
+
if (result.recResult.adopted.length > 0) {
|
|
15272
|
+
console.log(
|
|
15273
|
+
` - ${result.recResult.adopted.length} task terdeteksi sudah memiliki berkas kode (diadopsi): ${result.recResult.adopted.join(", ")}`
|
|
15274
|
+
);
|
|
15275
|
+
} else {
|
|
15276
|
+
console.log(" - Tidak ada task baru yang berkasnya ditemukan di disk.");
|
|
15277
|
+
}
|
|
15278
|
+
console.log(` - ${result.recResult.remaining.length} task tersisa.`);
|
|
15279
|
+
if (result.next !== null) {
|
|
15280
|
+
console.log(`
|
|
15281
|
+
Task berikutnya: ${result.next.task.id} \u2014 ${result.next.task.title}`);
|
|
15282
|
+
} else {
|
|
15283
|
+
console.log("\nSemua task selesai.");
|
|
15284
|
+
}
|
|
15285
|
+
}
|
|
14164
15286
|
async function resolveApi(options) {
|
|
14165
15287
|
const stored = await readCredentials();
|
|
14166
15288
|
const apiUrl = normalizeBaseUrl(
|
|
@@ -14200,34 +15322,50 @@ async function resolveBundle(options) {
|
|
|
14200
15322
|
}
|
|
14201
15323
|
async function pushSidecarBestEffort(options, local) {
|
|
14202
15324
|
if (options.noSync === true || process.env.JIOOGEN_NO_SYNC === "1") return;
|
|
14203
|
-
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
|
|
14217
|
-
|
|
15325
|
+
const maxAttempts = 2;
|
|
15326
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
15327
|
+
try {
|
|
15328
|
+
const api = await resolveApi({ api: options.api ?? local.linkedApiUrl });
|
|
15329
|
+
const state = await readState(local.bundleDir);
|
|
15330
|
+
if (state === null) return;
|
|
15331
|
+
await api.client.postJson(
|
|
15332
|
+
projectPath(local.projectId, "/artifacts"),
|
|
15333
|
+
{
|
|
15334
|
+
files: [
|
|
15335
|
+
{
|
|
15336
|
+
path: EXECUTION_SIDECAR_PATH,
|
|
15337
|
+
content: `${JSON.stringify(
|
|
15338
|
+
{ ...state, counts: summarizeExecutionCounts(state.tasks) },
|
|
15339
|
+
null,
|
|
15340
|
+
2
|
|
15341
|
+
)}
|
|
14218
15342
|
`
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
15343
|
+
}
|
|
15344
|
+
]
|
|
15345
|
+
},
|
|
15346
|
+
{ signal: AbortSignal.timeout(STATUS_PUSH_TIMEOUT_MS) }
|
|
15347
|
+
);
|
|
15348
|
+
return;
|
|
15349
|
+
} catch (error) {
|
|
15350
|
+
if (error instanceof ApiError && error.status === 404) {
|
|
15351
|
+
await handleProjectGone(local.bundleDir);
|
|
15352
|
+
return;
|
|
15353
|
+
}
|
|
15354
|
+
if (attempt === maxAttempts) {
|
|
15355
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
15356
|
+
console.warn(
|
|
15357
|
+
`Status tersimpan lokal; belum terkirim ke monitor (${message}). Jalankan \`jioogen sync\` nanti.`
|
|
15358
|
+
);
|
|
15359
|
+
}
|
|
15360
|
+
}
|
|
14229
15361
|
}
|
|
14230
15362
|
}
|
|
15363
|
+
async function handleProjectGone(bundleDir) {
|
|
15364
|
+
const removed = await removeProjectLink(bundleDir);
|
|
15365
|
+
console.warn(
|
|
15366
|
+
removed ? "Project dihapus/tidak ditemukan di server. Link lokal dilepas (.jioogen/project.json dihapus); bundle ini tidak terikat project apa pun. Jalankan `jioogen projects` untuk memilih project lain lalu `jioogen pull <id>` untuk bind ulang." : "Project dihapus/tidak ditemukan di server. Bundle ini juga sudah tidak punya link lokal (.jioogen/project.json); ia tidak terikat project apa pun."
|
|
15367
|
+
);
|
|
15368
|
+
}
|
|
14231
15369
|
async function withLocalState(options, fn) {
|
|
14232
15370
|
const context = await resolveLocalBundle(options);
|
|
14233
15371
|
return withStateLock(context.bundleDir, async () => {
|
|
@@ -14251,20 +15389,43 @@ function unmetDependencies(ref, definitions, states) {
|
|
|
14251
15389
|
(dependency) => byRef.get(dependency.toUpperCase())?.status !== "done"
|
|
14252
15390
|
);
|
|
14253
15391
|
}
|
|
14254
|
-
function
|
|
14255
|
-
const
|
|
14256
|
-
|
|
14257
|
-
|
|
14258
|
-
|
|
14259
|
-
);
|
|
14260
|
-
|
|
14261
|
-
|
|
14262
|
-
|
|
14263
|
-
|
|
14264
|
-
|
|
14265
|
-
|
|
14266
|
-
|
|
14267
|
-
|
|
15392
|
+
async function resolveOrAssertDependencies(ref, definitions, state, bundleDir, options, action) {
|
|
15393
|
+
const key = ref.toUpperCase();
|
|
15394
|
+
const definition = definitions.find((task) => task.id.toUpperCase() === key);
|
|
15395
|
+
if (definition === void 0) return state;
|
|
15396
|
+
let currentState = state;
|
|
15397
|
+
const missing = unmetDependencies(ref, definitions, currentState.tasks);
|
|
15398
|
+
if (missing.length === 0) return currentState;
|
|
15399
|
+
const stillMissing = [];
|
|
15400
|
+
for (const depId of missing) {
|
|
15401
|
+
const depDef = definitions.find((task) => task.id.toUpperCase() === depId.toUpperCase());
|
|
15402
|
+
const filesExist = depDef !== void 0 ? await taskTargetFilesExist(bundleDir, depDef) : false;
|
|
15403
|
+
if (options.lenient === true || filesExist) {
|
|
15404
|
+
const reason = filesExist ? `target files terdeteksi di disk (diperlukan oleh ${ref})` : `auto-adopted via --lenient (diperlukan oleh ${ref})`;
|
|
15405
|
+
currentState = withStatus(currentState, depId, "done", {
|
|
15406
|
+
note: reason,
|
|
15407
|
+
awaitingCheckpoint: false
|
|
15408
|
+
});
|
|
15409
|
+
currentState = setTaskSource(currentState, depId, "user");
|
|
15410
|
+
currentState = appendTaskEvidence(currentState, depId, {
|
|
15411
|
+
type: "text",
|
|
15412
|
+
summary: `auto-adopted outside harness as dependency of ${ref}`,
|
|
15413
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
15414
|
+
});
|
|
15415
|
+
console.log(
|
|
15416
|
+
`\u2139 Auto-mengadopsi dependensi hulu ${depId} (source: user) agar ${ref} tidak terblokir.`
|
|
15417
|
+
);
|
|
15418
|
+
} else {
|
|
15419
|
+
stillMissing.push(depId);
|
|
15420
|
+
}
|
|
15421
|
+
}
|
|
15422
|
+
if (stillMissing.length > 0 && options.force !== true) {
|
|
15423
|
+
const verb = action === "start" ? "memulai" : action === "adopt" ? "mengadopsi" : "menyelesaikan";
|
|
15424
|
+
throw new Error(
|
|
15425
|
+
`Tidak bisa ${verb} ${ref}: dependency belum selesai (${stillMissing.join(", ")}). Selesaikan dependency itu lebih dulu, atau gunakan --lenient / --force bila disengaja.`
|
|
15426
|
+
);
|
|
15427
|
+
}
|
|
15428
|
+
return currentState;
|
|
14268
15429
|
}
|
|
14269
15430
|
async function assertPullDefaultDir(cwd, dirOption) {
|
|
14270
15431
|
if (dirOption) return;
|
|
@@ -14328,6 +15489,33 @@ async function hasTaskMarkdown(directory) {
|
|
|
14328
15489
|
}
|
|
14329
15490
|
return names.some((name) => name.toLowerCase().endsWith(".md"));
|
|
14330
15491
|
}
|
|
15492
|
+
async function scaffoldCustomLayer(bundleDir) {
|
|
15493
|
+
const stackDir = join10(bundleDir, ".jioogen", "custom", "stack");
|
|
15494
|
+
const knowledgeDir = join10(bundleDir, ".jioogen", "custom", "knowledge");
|
|
15495
|
+
const designDir = join10(bundleDir, ".jioogen", "custom", "design");
|
|
15496
|
+
await mkdir8(stackDir, { recursive: true });
|
|
15497
|
+
await mkdir8(knowledgeDir, { recursive: true });
|
|
15498
|
+
await mkdir8(designDir, { recursive: true });
|
|
15499
|
+
const exampleFile = join10(stackDir, "STACK.md.example");
|
|
15500
|
+
try {
|
|
15501
|
+
await stat7(exampleFile);
|
|
15502
|
+
} catch {
|
|
15503
|
+
const template = [
|
|
15504
|
+
"# Custom Stack & Architecture Preferences",
|
|
15505
|
+
"",
|
|
15506
|
+
"Tulis preferensi teknologi pilihan Anda di sini (ubah nama file menjadi STACK.md).",
|
|
15507
|
+
"Perintah `jioogen task next` akan otomatis menyuntikkan isi file ini ke AI executor.",
|
|
15508
|
+
"",
|
|
15509
|
+
"Contoh:",
|
|
15510
|
+
"- UI / Styling: Tailwind CSS, shadcn/ui",
|
|
15511
|
+
"- Database / ORM: PostgreSQL + Drizzle ORM",
|
|
15512
|
+
"- Testing Runner: Vitest (bukan Jest)",
|
|
15513
|
+
""
|
|
15514
|
+
].join("\n");
|
|
15515
|
+
await writeFile8(exampleFile, template, "utf8").catch(() => {
|
|
15516
|
+
});
|
|
15517
|
+
}
|
|
15518
|
+
}
|
|
14331
15519
|
async function verifyProjectAccess(client, projectId) {
|
|
14332
15520
|
try {
|
|
14333
15521
|
await client.getJson(projectPath(projectId, "/execution"));
|
|
@@ -14344,6 +15532,31 @@ function assertBundleRelative(path) {
|
|
|
14344
15532
|
throw new Error(`Path harus relatif terhadap bundle: ${path}`);
|
|
14345
15533
|
}
|
|
14346
15534
|
}
|
|
15535
|
+
function printCompletionGaps(completion) {
|
|
15536
|
+
const lines = ["Task DAG selesai, tetapi per-feature masih ada gap:"];
|
|
15537
|
+
const entries = Object.entries(completion.features).filter(([, unit]) => unit.status !== "complete").sort(([left], [right]) => left.localeCompare(right));
|
|
15538
|
+
if (entries.length === 0) lines.push("- (tidak ada unit feature yang dideklarasikan)");
|
|
15539
|
+
for (const [id, unit] of entries) {
|
|
15540
|
+
lines.push(`- ${id}: ${unit.status} (${unit.doneTasks}/${unit.totalTasks} task selesai)`);
|
|
15541
|
+
}
|
|
15542
|
+
return lines.join("\n");
|
|
15543
|
+
}
|
|
15544
|
+
function printSeedReBreakdown() {
|
|
15545
|
+
console.log("");
|
|
15546
|
+
console.log("Gap di atas tidak ditutup oleh DAG task yang ada \u2014 ini bukan 'selesai',");
|
|
15547
|
+
console.log("melainkan coverage feature yang belum lengkap.");
|
|
15548
|
+
console.log("Buat follow-up task untuk pekerjaan yang belum ter-cover lewat re-breakdown");
|
|
15549
|
+
console.log("dengan mode seed (mis. `jioogen link <projectId> --mode seed` atau sejenisnya),");
|
|
15550
|
+
console.log(
|
|
15551
|
+
"lalu kerjakan task baru itu untuk menutup gap. Task follow-up TIDAK dibuat otomatis."
|
|
15552
|
+
);
|
|
15553
|
+
}
|
|
15554
|
+
function printSeedGapTrigger(completion, next) {
|
|
15555
|
+
if (next !== null || completion.projectComplete) return;
|
|
15556
|
+
console.log("");
|
|
15557
|
+
console.log(printCompletionGaps(completion));
|
|
15558
|
+
printSeedReBreakdown();
|
|
15559
|
+
}
|
|
14347
15560
|
function printExecution(data, asJson) {
|
|
14348
15561
|
if (asJson) {
|
|
14349
15562
|
console.log(JSON.stringify(data, null, 2));
|
|
@@ -14422,9 +15635,86 @@ async function authoringRemoveCommand(options) {
|
|
|
14422
15635
|
}
|
|
14423
15636
|
console.log(`Authoring contract dihapus dari ${dir}.`);
|
|
14424
15637
|
}
|
|
15638
|
+
async function runCommand(options) {
|
|
15639
|
+
const { bundleDir, projectId } = await resolveLocalBundle(options);
|
|
15640
|
+
const link = await findProjectLink(bundleDir);
|
|
15641
|
+
if (link === null) throw new Error("Belum ada project link. Jalankan `jioogen link` dulu.");
|
|
15642
|
+
if (options.stop === true) {
|
|
15643
|
+
await writeAutoMode(bundleDir, false);
|
|
15644
|
+
console.log(`Auto-mode DINONAKTIFKAN untuk project ${projectId}.`);
|
|
15645
|
+
console.log("Agent akan kembali ke mode satu task per giliran (human-in-the-loop).");
|
|
15646
|
+
return;
|
|
15647
|
+
}
|
|
15648
|
+
const currentlyOn = await readAutoMode(bundleDir);
|
|
15649
|
+
if (options.auto !== true && options.dryRun !== true && options.until === void 0 && options.maxTasks === void 0) {
|
|
15650
|
+
console.log(`Project ${projectId} \u2014 auto-mode: ${currentlyOn ? "AKTIF" : "nonaktif"}.`);
|
|
15651
|
+
console.log("Aktifkan: `jioogen run --auto` (tanya konfirmasi di awal).");
|
|
15652
|
+
console.log("Matikan: `jioogen run --stop`.");
|
|
15653
|
+
console.log("Rencana saja: `jioogen run --auto --dry-run`.");
|
|
15654
|
+
return;
|
|
15655
|
+
}
|
|
15656
|
+
const maxTasks = Math.max(1, Math.min(50, options.maxTasks ?? 5));
|
|
15657
|
+
const definitions = await loadTasks(bundleDir);
|
|
15658
|
+
const existing = await readState(bundleDir);
|
|
15659
|
+
const tasks = existing?.tasks ?? [];
|
|
15660
|
+
const todo = definitions.filter((d) => {
|
|
15661
|
+
const s = tasks.find((t) => t.id === d.id)?.status;
|
|
15662
|
+
return s !== "done";
|
|
15663
|
+
});
|
|
15664
|
+
const target = options.until ?? "all";
|
|
15665
|
+
const plan = target === "all" ? todo.slice(0, maxTasks) : todo.filter((d) => d.id === target).slice(0, maxTasks);
|
|
15666
|
+
console.log(`Project ${projectId} \u2014 auto-mode`);
|
|
15667
|
+
console.log(
|
|
15668
|
+
`Mode: ${options.strictCheckpoints === true ? "strict (berhenti di setiap transisi layer)" : "normal (transisi layer = soft stop)"}`
|
|
15669
|
+
);
|
|
15670
|
+
console.log(`Batas: ${maxTasks} task per run`);
|
|
15671
|
+
console.log(`Daftar task yang akan dijalankan (${plan.length}):`);
|
|
15672
|
+
for (const t of plan) console.log(`- ${t.id} (${t.layer ?? "?"}, phase ${t.phase}) ${t.title}`);
|
|
15673
|
+
if (plan.length === 0) {
|
|
15674
|
+
console.log("Tidak ada task yang tersisa. Auto-mode tidak diperlukan.");
|
|
15675
|
+
return;
|
|
15676
|
+
}
|
|
15677
|
+
if (options.dryRun === true) {
|
|
15678
|
+
console.log("\n(dry-run: tidak ada perubahan state)");
|
|
15679
|
+
return;
|
|
15680
|
+
}
|
|
15681
|
+
process.stdout.write("\nAktifkan auto-mode? (lanjut / batal): ");
|
|
15682
|
+
const answer = await readLine();
|
|
15683
|
+
if (answer.trim().toLowerCase() !== "lanjut") {
|
|
15684
|
+
console.log("Dibatalkan. Auto-mode tidak diaktifkan.");
|
|
15685
|
+
return;
|
|
15686
|
+
}
|
|
15687
|
+
await writeAutoMode(bundleDir, true);
|
|
15688
|
+
console.log("\nAuto-mode AKTIF. Aturan yang berlaku untuk agent:");
|
|
15689
|
+
console.log("- Jalankan task berurutan via `task next` \u2192 kerjakan \u2192 `task complete` \u2192 lanjut.");
|
|
15690
|
+
console.log(
|
|
15691
|
+
"- AUTO-CONTINUE (tanpa konfirmasi) pada: transisi layer & kenaikan phase (soft stop, dicatat di sidecar)."
|
|
15692
|
+
);
|
|
15693
|
+
console.log(
|
|
15694
|
+
"- HARD STOP (wajib berhenti) pada: task fail, verifikasi gagal, task checkpoint:true, task sensitif (data/akses/integrasi/rahasia/deploy/infra), max-tasks tercapai, bundle blocked, atau user `jioogen run --stop`."
|
|
15695
|
+
);
|
|
15696
|
+
console.log("- Setiap task tetap dapat commit git kecil (rollback point).");
|
|
15697
|
+
console.log("- Jangan edit PRD.md/specs/ (hard rule tetap).");
|
|
15698
|
+
console.log("\nUntuk mematikan: `jioogen run --stop` atau Ctrl+C (graceful).");
|
|
15699
|
+
console.log("Monitoring: `jioogen status` / `jioogen monitor`.");
|
|
15700
|
+
}
|
|
15701
|
+
async function readLine() {
|
|
15702
|
+
return new Promise((resolve7) => {
|
|
15703
|
+
const chunks = [];
|
|
15704
|
+
process.stdin.resume();
|
|
15705
|
+
process.stdin.on("data", (chunk) => {
|
|
15706
|
+
chunks.push(Buffer.from(chunk));
|
|
15707
|
+
if (Buffer.concat(chunks).toString("utf8").includes("\n")) {
|
|
15708
|
+
process.stdin.pause();
|
|
15709
|
+
resolve7(Buffer.concat(chunks).toString("utf8"));
|
|
15710
|
+
}
|
|
15711
|
+
});
|
|
15712
|
+
process.stdin.on("end", () => resolve7(Buffer.concat(chunks).toString("utf8")));
|
|
15713
|
+
});
|
|
15714
|
+
}
|
|
14425
15715
|
|
|
14426
15716
|
// src/index.ts
|
|
14427
|
-
var VERSION = "0.2.
|
|
15717
|
+
var VERSION = "0.2.12";
|
|
14428
15718
|
function parseTaskModeOption(value) {
|
|
14429
15719
|
if (value === void 0) return void 0;
|
|
14430
15720
|
const parsed = TaskModeSchema.safeParse(value);
|
|
@@ -14445,6 +15735,9 @@ Usage:
|
|
|
14445
15735
|
jioogen login --email <email> (--password <pass> | --password-stdin)
|
|
14446
15736
|
jioogen logout
|
|
14447
15737
|
jioogen whoami
|
|
15738
|
+
jioogen unlink [--dir <dir>]
|
|
15739
|
+
jioogen execution status [--dir <dir>] [--json]
|
|
15740
|
+
jioogen execution disable [--dir <dir>]
|
|
14448
15741
|
jioogen projects
|
|
14449
15742
|
jioogen pull <projectId> [--dir <dir>] [--force] [--no-skills] [--mode <mode>] [--ui-quality <auto|on|off>]
|
|
14450
15743
|
jioogen link <projectId> [--dir <dir>] [--no-skills] [--mode <mode>] [--ui-quality <auto|on|off>]
|
|
@@ -14453,23 +15746,32 @@ Usage:
|
|
|
14453
15746
|
jioogen skills add <baseline|ui-quality|backend-rules|all> [--dir <dir>]
|
|
14454
15747
|
jioogen skills update [--dir <dir>]
|
|
14455
15748
|
jioogen skills remove <baseline|ui-quality|backend-rules> [--dir <dir>]
|
|
15749
|
+
jioogen skills restore <pack|all> [--dir <dir>]
|
|
15750
|
+
jioogen skills disable <name> [--dir <dir>]
|
|
15751
|
+
jioogen skills enable <name> [--dir <dir>]
|
|
14456
15752
|
jioogen authoring install [--dir <dir>]
|
|
14457
15753
|
jioogen authoring status [--dir <dir>] [--json]
|
|
14458
15754
|
jioogen authoring remove [--dir <dir>]
|
|
14459
15755
|
jioogen check [--dir <dir>] [--json]
|
|
14460
15756
|
jioogen doctor [--fix] [--dir <dir>] [--json]
|
|
15757
|
+
jioogen drift [--dir <dir>] [--json] [--strict] [--acknowledge] [--prd] [--specs] [--tasks] [--note <text>]
|
|
15758
|
+
jioogen contract update-baseline [--dir <dir>]
|
|
15759
|
+
jioogen baseline list [--dir <dir>] [--json]
|
|
14461
15760
|
jioogen resume [--dir <dir>] [--json]
|
|
15761
|
+
jioogen run [--auto] [--until <ref|all>] [--max-tasks N] [--strict-checkpoints] [--dry-run]
|
|
15762
|
+
jioogen run --stop
|
|
14462
15763
|
jioogen review (--approve | --request-changes <teks> | --stop) [--ref <TASK-XXX>] [--json]
|
|
14463
15764
|
jioogen handoff [--project <id>] [--json]
|
|
14464
|
-
jioogen task next [--json]
|
|
14465
|
-
jioogen task start <ref>
|
|
14466
|
-
jioogen task complete <ref> [--note <text>] [--force]
|
|
14467
|
-
jioogen task adopt <ref> [--note <text>] [--visual <catatan>] [--force]
|
|
15765
|
+
jioogen task next [--json] [--lenient]
|
|
15766
|
+
jioogen task start <ref> [--lenient]
|
|
15767
|
+
jioogen task complete <ref> [--note <text>] [--lenient] [--force]
|
|
15768
|
+
jioogen task adopt <ref> [--note <text>] [--visual <catatan>] [--lenient] [--force]
|
|
14468
15769
|
jioogen task verify <ref> [--dir <dir>] [--json]
|
|
14469
15770
|
jioogen task expand <ref> [--write]
|
|
14470
15771
|
jioogen task fail <ref> [reason...] [--note <text>]
|
|
14471
15772
|
jioogen task reset <ref> [reason...] [--note <text>]
|
|
14472
15773
|
jioogen status [--remote] [--json]
|
|
15774
|
+
jioogen reconcile [--dry-run] [--lenient] [--dir <dir>] [--json]
|
|
14473
15775
|
jioogen sync [--files a.md,b.md] [--json]
|
|
14474
15776
|
jioogen monitor [--json]
|
|
14475
15777
|
|
|
@@ -14503,6 +15805,7 @@ async function main() {
|
|
|
14503
15805
|
dir: { type: "string" },
|
|
14504
15806
|
remote: { type: "boolean" },
|
|
14505
15807
|
force: { type: "boolean" },
|
|
15808
|
+
lenient: { type: "boolean" },
|
|
14506
15809
|
"no-skills": { type: "boolean" },
|
|
14507
15810
|
mode: { type: "string" },
|
|
14508
15811
|
"ui-quality": { type: "string" },
|
|
@@ -14517,6 +15820,18 @@ async function main() {
|
|
|
14517
15820
|
json: { type: "boolean" },
|
|
14518
15821
|
write: { type: "boolean" },
|
|
14519
15822
|
visual: { type: "string" },
|
|
15823
|
+
auto: { type: "boolean" },
|
|
15824
|
+
"max-tasks": { type: "string" },
|
|
15825
|
+
until: { type: "string" },
|
|
15826
|
+
"strict-checkpoints": { type: "boolean" },
|
|
15827
|
+
strict: { type: "boolean" },
|
|
15828
|
+
acknowledge: { type: "boolean" },
|
|
15829
|
+
pruned: { type: "boolean" },
|
|
15830
|
+
prd: { type: "boolean" },
|
|
15831
|
+
specs: { type: "boolean" },
|
|
15832
|
+
tasks: { type: "boolean" },
|
|
15833
|
+
"dry-run": { type: "boolean" },
|
|
15834
|
+
resume: { type: "boolean" },
|
|
14520
15835
|
help: { type: "boolean", short: "h" },
|
|
14521
15836
|
version: { type: "boolean", short: "v" }
|
|
14522
15837
|
}
|
|
@@ -14542,6 +15857,7 @@ async function main() {
|
|
|
14542
15857
|
dir: text(raw.dir),
|
|
14543
15858
|
remote: flag(raw.remote),
|
|
14544
15859
|
force: flag(raw.force),
|
|
15860
|
+
lenient: flag(raw.lenient),
|
|
14545
15861
|
noSkills: flag(raw["no-skills"]),
|
|
14546
15862
|
noSync: flag(raw["no-sync"]),
|
|
14547
15863
|
files: text(raw.files),
|
|
@@ -14554,6 +15870,18 @@ async function main() {
|
|
|
14554
15870
|
json: flag(raw.json),
|
|
14555
15871
|
write: flag(raw.write),
|
|
14556
15872
|
visual: text(raw.visual),
|
|
15873
|
+
auto: flag(raw.auto),
|
|
15874
|
+
maxTasks: raw["max-tasks"] === void 0 ? void 0 : Number(raw["max-tasks"]),
|
|
15875
|
+
until: text(raw.until),
|
|
15876
|
+
strictCheckpoints: flag(raw["strict-checkpoints"]),
|
|
15877
|
+
strict: flag(raw.strict),
|
|
15878
|
+
acknowledge: flag(raw.acknowledge),
|
|
15879
|
+
pruned: flag(raw.pruned),
|
|
15880
|
+
prd: flag(raw.prd),
|
|
15881
|
+
specs: flag(raw.specs),
|
|
15882
|
+
tasks: flag(raw.tasks),
|
|
15883
|
+
dryRun: flag(raw["dry-run"]),
|
|
15884
|
+
resume: flag(raw.resume),
|
|
14557
15885
|
taskMode,
|
|
14558
15886
|
uiQuality
|
|
14559
15887
|
};
|
|
@@ -14593,6 +15921,21 @@ async function dispatch(command, rest, options) {
|
|
|
14593
15921
|
case "logout":
|
|
14594
15922
|
await logoutCommand();
|
|
14595
15923
|
return;
|
|
15924
|
+
case "unlink":
|
|
15925
|
+
await unlinkCommand(options);
|
|
15926
|
+
return;
|
|
15927
|
+
case "execution": {
|
|
15928
|
+
const sub = rest[0];
|
|
15929
|
+
if (sub === "status") {
|
|
15930
|
+
await executionStatusCommand(options);
|
|
15931
|
+
return;
|
|
15932
|
+
}
|
|
15933
|
+
if (sub === "disable") {
|
|
15934
|
+
await executionDisableCommand(options);
|
|
15935
|
+
return;
|
|
15936
|
+
}
|
|
15937
|
+
throw new UsageError("Subcommand execution: status | disable");
|
|
15938
|
+
}
|
|
14596
15939
|
case "whoami":
|
|
14597
15940
|
await whoamiCommand(options);
|
|
14598
15941
|
return;
|
|
@@ -14623,6 +15966,15 @@ async function dispatch(command, rest, options) {
|
|
|
14623
15966
|
case "doctor":
|
|
14624
15967
|
await doctorCommand(options);
|
|
14625
15968
|
return;
|
|
15969
|
+
case "drift":
|
|
15970
|
+
await driftCommand(options);
|
|
15971
|
+
return;
|
|
15972
|
+
case "baseline":
|
|
15973
|
+
await baselineListCommand(options);
|
|
15974
|
+
return;
|
|
15975
|
+
case "contract":
|
|
15976
|
+
await dispatchContract(rest, options);
|
|
15977
|
+
return;
|
|
14626
15978
|
case "resume":
|
|
14627
15979
|
await resumeCommand(options);
|
|
14628
15980
|
return;
|
|
@@ -14638,6 +15990,12 @@ async function dispatch(command, rest, options) {
|
|
|
14638
15990
|
case "status":
|
|
14639
15991
|
await statusCommand(options);
|
|
14640
15992
|
return;
|
|
15993
|
+
case "reconcile":
|
|
15994
|
+
await reconcileCommand(options);
|
|
15995
|
+
return;
|
|
15996
|
+
case "run":
|
|
15997
|
+
await runCommand(options);
|
|
15998
|
+
return;
|
|
14641
15999
|
case "sync":
|
|
14642
16000
|
await syncCommand(options);
|
|
14643
16001
|
return;
|
|
@@ -14677,8 +16035,34 @@ async function dispatchSkills(rest, options) {
|
|
|
14677
16035
|
await skillsRemoveCommand(pack, options);
|
|
14678
16036
|
return;
|
|
14679
16037
|
}
|
|
16038
|
+
case "restore": {
|
|
16039
|
+
const pack = rest[1];
|
|
16040
|
+
if (pack === void 0) {
|
|
16041
|
+
throw new UsageError("`jioogen skills restore` butuh <pack|all>.");
|
|
16042
|
+
}
|
|
16043
|
+
await skillsRestoreCommand(pack, options);
|
|
16044
|
+
return;
|
|
16045
|
+
}
|
|
16046
|
+
case "disable": {
|
|
16047
|
+
const name = rest[1];
|
|
16048
|
+
if (name === void 0) {
|
|
16049
|
+
throw new UsageError("`jioogen skills disable` butuh <name>.");
|
|
16050
|
+
}
|
|
16051
|
+
await skillsDisableCommand(name, options);
|
|
16052
|
+
return;
|
|
16053
|
+
}
|
|
16054
|
+
case "enable": {
|
|
16055
|
+
const name = rest[1];
|
|
16056
|
+
if (name === void 0) {
|
|
16057
|
+
throw new UsageError("`jioogen skills enable` butuh <name>.");
|
|
16058
|
+
}
|
|
16059
|
+
await skillsEnableCommand(name, options);
|
|
16060
|
+
return;
|
|
16061
|
+
}
|
|
14680
16062
|
default:
|
|
14681
|
-
throw new UsageError(
|
|
16063
|
+
throw new UsageError(
|
|
16064
|
+
"Subcommand skills: install | list | add | update | remove | restore | disable | enable"
|
|
16065
|
+
);
|
|
14682
16066
|
}
|
|
14683
16067
|
}
|
|
14684
16068
|
async function dispatchAuthoring(rest, options) {
|
|
@@ -14698,6 +16082,18 @@ async function dispatchAuthoring(rest, options) {
|
|
|
14698
16082
|
throw new UsageError("Subcommand authoring: install | status | remove");
|
|
14699
16083
|
}
|
|
14700
16084
|
}
|
|
16085
|
+
async function dispatchContract(rest, options) {
|
|
16086
|
+
const subcommand = rest[0];
|
|
16087
|
+
switch (subcommand) {
|
|
16088
|
+
case "update-baseline":
|
|
16089
|
+
await contractUpdateBaselineCommand(options);
|
|
16090
|
+
return;
|
|
16091
|
+
default:
|
|
16092
|
+
throw new UsageError(
|
|
16093
|
+
"Subcommand contract: update-baseline. Contoh: `jioogen contract update-baseline`"
|
|
16094
|
+
);
|
|
16095
|
+
}
|
|
16096
|
+
}
|
|
14701
16097
|
async function dispatchTask(rest, options) {
|
|
14702
16098
|
const subcommand = rest[0];
|
|
14703
16099
|
const ref = rest[1];
|