jioogen 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +291 -64
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2124,8 +2124,8 @@ var require_adm_zip = __commonJS({
|
|
|
2124
2124
|
return null;
|
|
2125
2125
|
}
|
|
2126
2126
|
function fixPath(zipPath) {
|
|
2127
|
-
const { join:
|
|
2128
|
-
return
|
|
2127
|
+
const { join: join9, normalize, sep: sep2 } = pth.posix;
|
|
2128
|
+
return join9(pth.isAbsolute(zipPath) ? "/" : ".", normalize(sep2 + zipPath.split("\\").join(sep2) + sep2));
|
|
2129
2129
|
}
|
|
2130
2130
|
function filenameFilter(filterfn) {
|
|
2131
2131
|
if (filterfn instanceof RegExp) {
|
|
@@ -2978,8 +2978,8 @@ var ApiClient = class {
|
|
|
2978
2978
|
};
|
|
2979
2979
|
|
|
2980
2980
|
// src/commands.ts
|
|
2981
|
-
import { readdir as readdir5, readFile as
|
|
2982
|
-
import { join as
|
|
2981
|
+
import { readdir as readdir5, readFile as readFile8 } from "node:fs/promises";
|
|
2982
|
+
import { join as join8, resolve as resolve5 } from "node:path";
|
|
2983
2983
|
|
|
2984
2984
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
|
|
2985
2985
|
var external_exports = {};
|
|
@@ -9502,6 +9502,37 @@ async function checkSidecar(bundleDir) {
|
|
|
9502
9502
|
);
|
|
9503
9503
|
}
|
|
9504
9504
|
}
|
|
9505
|
+
async function checkRecovery(bundleDir) {
|
|
9506
|
+
const path = join5(bundleDir, "tasks/.execution/recovery.json");
|
|
9507
|
+
let raw;
|
|
9508
|
+
try {
|
|
9509
|
+
raw = await readFile5(path, "utf8");
|
|
9510
|
+
} catch (error) {
|
|
9511
|
+
if (isMissingFile4(error)) {
|
|
9512
|
+
return makeCheck("recovery", "pass", "Belum ada recovery journal.");
|
|
9513
|
+
}
|
|
9514
|
+
return makeCheck("recovery", "warn", "Recovery journal tidak bisa dibaca.");
|
|
9515
|
+
}
|
|
9516
|
+
let payload;
|
|
9517
|
+
try {
|
|
9518
|
+
payload = JSON.parse(raw);
|
|
9519
|
+
} catch {
|
|
9520
|
+
return makeCheck("recovery", "warn", "Recovery journal bukan JSON valid.");
|
|
9521
|
+
}
|
|
9522
|
+
const tasks = typeof payload === "object" && payload !== null ? payload.tasks : void 0;
|
|
9523
|
+
if (tasks === void 0 || typeof tasks !== "object" || tasks === null) {
|
|
9524
|
+
return makeCheck("recovery", "warn", "Recovery journal tidak memuat tasks.");
|
|
9525
|
+
}
|
|
9526
|
+
const exhausted = Object.entries(tasks).filter(([, entry]) => entry?.exhausted === true).map(([ref]) => ref);
|
|
9527
|
+
if (exhausted.length > 0) {
|
|
9528
|
+
return makeCheck(
|
|
9529
|
+
"recovery",
|
|
9530
|
+
"warn",
|
|
9531
|
+
`Task RECOVERY_EXHAUSTED: ${exhausted.join(", ")}. Jalankan \`jioogen resume\`.`
|
|
9532
|
+
);
|
|
9533
|
+
}
|
|
9534
|
+
return makeCheck("recovery", "pass", "Recovery journal valid; tidak ada task exhausted.");
|
|
9535
|
+
}
|
|
9505
9536
|
async function checkLock(bundleDir) {
|
|
9506
9537
|
const target = lockPath(bundleDir);
|
|
9507
9538
|
let info;
|
|
@@ -9720,6 +9751,7 @@ async function runChecks(options, deps) {
|
|
|
9720
9751
|
checks.push(await checkBundle(options.bundleDir));
|
|
9721
9752
|
checks.push(await checkSidecar(options.bundleDir));
|
|
9722
9753
|
checks.push(await checkLock(options.bundleDir));
|
|
9754
|
+
checks.push(await checkRecovery(options.bundleDir));
|
|
9723
9755
|
checks.push(await checkAgents(options.bundleDir));
|
|
9724
9756
|
checks.push(await checkExecutionSkill(options.bundleDir));
|
|
9725
9757
|
checks.push(await checkSkillPacks(options.bundleDir));
|
|
@@ -9772,13 +9804,144 @@ function formatTable(headers, rows) {
|
|
|
9772
9804
|
return [render(headers), divider, ...rows.map(render)].join("\n");
|
|
9773
9805
|
}
|
|
9774
9806
|
|
|
9807
|
+
// src/recovery.ts
|
|
9808
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
9809
|
+
import { mkdir as mkdir4, readFile as readFile6, rename as rename2, rm as rm5, writeFile as writeFile4 } from "node:fs/promises";
|
|
9810
|
+
import { dirname as dirname4, join as join6 } from "node:path";
|
|
9811
|
+
var RECOVERY_PATH = "tasks/.execution/recovery.json";
|
|
9812
|
+
var RECOVERY_BUDGET = { maxAttempts: 3 };
|
|
9813
|
+
function recoveryPath(bundleDir) {
|
|
9814
|
+
return join6(bundleDir, RECOVERY_PATH);
|
|
9815
|
+
}
|
|
9816
|
+
function emptyJournal() {
|
|
9817
|
+
return { schemaVersion: 1, tasks: {} };
|
|
9818
|
+
}
|
|
9819
|
+
function isJournal(value) {
|
|
9820
|
+
if (typeof value !== "object" || value === null) return false;
|
|
9821
|
+
const obj = value;
|
|
9822
|
+
if (obj.schemaVersion !== 1) return false;
|
|
9823
|
+
if (typeof obj.tasks !== "object" || obj.tasks === null) return false;
|
|
9824
|
+
return true;
|
|
9825
|
+
}
|
|
9826
|
+
async function readRecovery(bundleDir) {
|
|
9827
|
+
let raw;
|
|
9828
|
+
try {
|
|
9829
|
+
raw = await readFile6(recoveryPath(bundleDir), "utf8");
|
|
9830
|
+
} catch {
|
|
9831
|
+
return emptyJournal();
|
|
9832
|
+
}
|
|
9833
|
+
let payload;
|
|
9834
|
+
try {
|
|
9835
|
+
payload = JSON.parse(raw);
|
|
9836
|
+
} catch {
|
|
9837
|
+
return emptyJournal();
|
|
9838
|
+
}
|
|
9839
|
+
if (!isJournal(payload)) return emptyJournal();
|
|
9840
|
+
return payload;
|
|
9841
|
+
}
|
|
9842
|
+
function classifyFailure(input) {
|
|
9843
|
+
if (input.stalled === true || input.timedOut === true) return "transient";
|
|
9844
|
+
if (input.verificationFailed === true) return "semantic";
|
|
9845
|
+
const note = input.note ?? "";
|
|
9846
|
+
if (/^AUTHORIZATION:/i.test(note.trim())) return "authorization";
|
|
9847
|
+
if (/timeout|stall|econn|rate limit|\b429\b|\b5\d\d\b/i.test(note)) return "transient";
|
|
9848
|
+
const prior = input.prior ?? null;
|
|
9849
|
+
if (prior !== null && prior.attempts >= 1 && note === prior.lastNote) return "no_progress";
|
|
9850
|
+
return "semantic";
|
|
9851
|
+
}
|
|
9852
|
+
async function writeRecovery(bundleDir, journal) {
|
|
9853
|
+
const target = recoveryPath(bundleDir);
|
|
9854
|
+
await mkdir4(dirname4(target), { recursive: true });
|
|
9855
|
+
const temp = `${target}.${process.pid}.${randomUUID2()}.tmp`;
|
|
9856
|
+
try {
|
|
9857
|
+
await writeFile4(temp, `${JSON.stringify(journal, null, 2)}
|
|
9858
|
+
`, "utf8");
|
|
9859
|
+
await rename2(temp, target);
|
|
9860
|
+
} catch (error) {
|
|
9861
|
+
await rm5(temp, { force: true }).catch(() => {
|
|
9862
|
+
});
|
|
9863
|
+
throw error;
|
|
9864
|
+
}
|
|
9865
|
+
}
|
|
9866
|
+
async function recordFailure(bundleDir, ref, args) {
|
|
9867
|
+
return withStateLock(bundleDir, async () => {
|
|
9868
|
+
const journal = await readRecovery(bundleDir);
|
|
9869
|
+
const prior = journal.tasks[ref] ?? null;
|
|
9870
|
+
const klass = classifyFailure({ ...args, prior });
|
|
9871
|
+
const attempt = (prior?.attempts ?? 0) + 1;
|
|
9872
|
+
const exhausted = attempt >= RECOVERY_BUDGET.maxAttempts;
|
|
9873
|
+
const resumable = exhausted;
|
|
9874
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
9875
|
+
const note = args.note ?? "";
|
|
9876
|
+
const history = [...prior?.history ?? []];
|
|
9877
|
+
history.push({ attempt, class: klass, note, at: now });
|
|
9878
|
+
const capped = history.length > 20 ? history.slice(history.length - 20) : history;
|
|
9879
|
+
const entry = {
|
|
9880
|
+
ref,
|
|
9881
|
+
attempts: attempt,
|
|
9882
|
+
exhausted,
|
|
9883
|
+
resumable,
|
|
9884
|
+
lastClass: klass,
|
|
9885
|
+
lastNote: note === "" ? prior?.lastNote ?? "" : note,
|
|
9886
|
+
history: capped,
|
|
9887
|
+
updatedAt: now
|
|
9888
|
+
};
|
|
9889
|
+
journal.tasks[ref] = entry;
|
|
9890
|
+
await writeRecovery(bundleDir, journal);
|
|
9891
|
+
return { entry, exhausted, class: klass, attempt };
|
|
9892
|
+
});
|
|
9893
|
+
}
|
|
9894
|
+
async function recordSuccess(bundleDir, ref) {
|
|
9895
|
+
await withStateLock(bundleDir, async () => {
|
|
9896
|
+
const journal = await readRecovery(bundleDir);
|
|
9897
|
+
if (journal.tasks[ref] !== void 0) {
|
|
9898
|
+
delete journal.tasks[ref];
|
|
9899
|
+
await writeRecovery(bundleDir, journal);
|
|
9900
|
+
}
|
|
9901
|
+
});
|
|
9902
|
+
}
|
|
9903
|
+
async function rearmTask(bundleDir, ref) {
|
|
9904
|
+
await withStateLock(bundleDir, async () => {
|
|
9905
|
+
const journal = await readRecovery(bundleDir);
|
|
9906
|
+
const prior = journal.tasks[ref];
|
|
9907
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
9908
|
+
const entry = {
|
|
9909
|
+
ref,
|
|
9910
|
+
attempts: 0,
|
|
9911
|
+
exhausted: false,
|
|
9912
|
+
resumable: true,
|
|
9913
|
+
lastClass: prior?.lastClass ?? null,
|
|
9914
|
+
lastNote: prior?.lastNote ?? "",
|
|
9915
|
+
history: prior?.history ?? [],
|
|
9916
|
+
updatedAt: now
|
|
9917
|
+
};
|
|
9918
|
+
journal.tasks[ref] = entry;
|
|
9919
|
+
await writeRecovery(bundleDir, journal);
|
|
9920
|
+
});
|
|
9921
|
+
}
|
|
9922
|
+
function isExhausted(journal, ref) {
|
|
9923
|
+
return journal.tasks[ref]?.exhausted === true;
|
|
9924
|
+
}
|
|
9925
|
+
function describeRecovery(entry) {
|
|
9926
|
+
if (entry === void 0) {
|
|
9927
|
+
return "No recovery record. Run `jioogen resume`, then retry with a different approach.";
|
|
9928
|
+
}
|
|
9929
|
+
const lines = [];
|
|
9930
|
+
lines.push(
|
|
9931
|
+
`Task ${entry.ref}: ${entry.attempts}/${RECOVERY_BUDGET.maxAttempts} attempts, last=${entry.lastClass ?? "none"}.`
|
|
9932
|
+
);
|
|
9933
|
+
if (entry.lastNote.length > 0) lines.push(`Last note: ${entry.lastNote}`);
|
|
9934
|
+
lines.push("Run `jioogen resume`, then retry with a different approach.");
|
|
9935
|
+
return lines.join("\n");
|
|
9936
|
+
}
|
|
9937
|
+
|
|
9775
9938
|
// src/session.ts
|
|
9776
|
-
import { rm as
|
|
9939
|
+
import { rm as rm6, stat as stat4 } from "node:fs/promises";
|
|
9777
9940
|
import { resolve as resolve3 } from "node:path";
|
|
9778
9941
|
|
|
9779
9942
|
// src/tasks.ts
|
|
9780
|
-
import { readdir as readdir4, readFile as
|
|
9781
|
-
import { join as
|
|
9943
|
+
import { readdir as readdir4, readFile as readFile7 } from "node:fs/promises";
|
|
9944
|
+
import { join as join7 } from "node:path";
|
|
9782
9945
|
var TASK_ID_RE2 = /\b(?:TASK|T)-\d{3,}\b/i;
|
|
9783
9946
|
var HEADING_RE = /^#{1,4}\s+(.+)$/m;
|
|
9784
9947
|
var LAYER_RANK = {
|
|
@@ -9828,7 +9991,7 @@ var LAYER_CHECKLISTS = {
|
|
|
9828
9991
|
]
|
|
9829
9992
|
};
|
|
9830
9993
|
async function loadTasks(bundleDir) {
|
|
9831
|
-
const tasksDir =
|
|
9994
|
+
const tasksDir = join7(bundleDir, "tasks");
|
|
9832
9995
|
let entries;
|
|
9833
9996
|
try {
|
|
9834
9997
|
entries = await readdir4(tasksDir, { withFileTypes: true });
|
|
@@ -9842,14 +10005,14 @@ async function loadTasks(bundleDir) {
|
|
|
9842
10005
|
const tasks = [];
|
|
9843
10006
|
if (names.length > 0) {
|
|
9844
10007
|
for (const name of names) {
|
|
9845
|
-
const content = await
|
|
10008
|
+
const content = await readFile7(join7(tasksDir, name), "utf8");
|
|
9846
10009
|
tasks.push(parseSingleTask(name, content));
|
|
9847
10010
|
}
|
|
9848
10011
|
} else {
|
|
9849
|
-
const singlePath =
|
|
10012
|
+
const singlePath = join7(tasksDir, "TASKS.md");
|
|
9850
10013
|
let content;
|
|
9851
10014
|
try {
|
|
9852
|
-
content = await
|
|
10015
|
+
content = await readFile7(singlePath, "utf8");
|
|
9853
10016
|
} catch (error) {
|
|
9854
10017
|
if (isMissingFile5(error)) throw new Error(`Tidak ada berkas task di ${tasksDir}`);
|
|
9855
10018
|
throw error;
|
|
@@ -10071,22 +10234,38 @@ async function resumeSession(options) {
|
|
|
10071
10234
|
awaitingCheckpoint: false
|
|
10072
10235
|
};
|
|
10073
10236
|
}
|
|
10074
|
-
|
|
10237
|
+
const definitions = await loadTasks(context.bundleDir);
|
|
10238
|
+
const written = await withStateLock(context.bundleDir, async () => {
|
|
10075
10239
|
const state = await readState(context.bundleDir) ?? initial;
|
|
10076
|
-
const definitions = await loadTasks(context.bundleDir);
|
|
10077
10240
|
const merged = mergeTasks(state, definitions);
|
|
10078
|
-
|
|
10079
|
-
const current = written.current ?? null;
|
|
10080
|
-
const next = selectNext(definitions, written.tasks);
|
|
10081
|
-
return {
|
|
10082
|
-
projectId: written.projectId ?? context.projectId ?? "",
|
|
10083
|
-
bundleDir: context.bundleDir,
|
|
10084
|
-
hasState: true,
|
|
10085
|
-
current,
|
|
10086
|
-
nextRef: next?.task.id ?? null,
|
|
10087
|
-
awaitingCheckpoint: current?.awaitingCheckpoint === true
|
|
10088
|
-
};
|
|
10241
|
+
return writeState(context.bundleDir, merged);
|
|
10089
10242
|
});
|
|
10243
|
+
const journal = await readRecovery(context.bundleDir);
|
|
10244
|
+
const exhausted = written.tasks.filter(
|
|
10245
|
+
(task) => isExhausted(journal, task.ref.toUpperCase()) || isExhausted(journal, task.ref)
|
|
10246
|
+
);
|
|
10247
|
+
if (exhausted.length > 0) {
|
|
10248
|
+
await withStateLock(context.bundleDir, async () => {
|
|
10249
|
+
const state = await readState(context.bundleDir) ?? written;
|
|
10250
|
+
let next2 = state;
|
|
10251
|
+
for (const task of exhausted) {
|
|
10252
|
+
next2 = withStatus(next2, task.ref, "todo", { awaitingCheckpoint: false });
|
|
10253
|
+
}
|
|
10254
|
+
await writeState(context.bundleDir, next2);
|
|
10255
|
+
});
|
|
10256
|
+
for (const task of exhausted) await rearmTask(context.bundleDir, task.ref.toUpperCase());
|
|
10257
|
+
}
|
|
10258
|
+
const finalState = await readState(context.bundleDir) ?? written;
|
|
10259
|
+
const current = finalState.current ?? null;
|
|
10260
|
+
const next = selectNext(definitions, finalState.tasks);
|
|
10261
|
+
return {
|
|
10262
|
+
projectId: finalState.projectId ?? context.projectId ?? "",
|
|
10263
|
+
bundleDir: context.bundleDir,
|
|
10264
|
+
hasState: true,
|
|
10265
|
+
current,
|
|
10266
|
+
nextRef: next?.task.id ?? null,
|
|
10267
|
+
awaitingCheckpoint: current?.awaitingCheckpoint === true
|
|
10268
|
+
};
|
|
10090
10269
|
}
|
|
10091
10270
|
async function reviewSession(options, review) {
|
|
10092
10271
|
const context = await resolveBundleContext(options);
|
|
@@ -10122,7 +10301,10 @@ async function reviewSession(options, review) {
|
|
|
10122
10301
|
);
|
|
10123
10302
|
}
|
|
10124
10303
|
const note = `${CHANGE_REQUEST_PREFIX} ${review.note ?? ""}`.trim();
|
|
10125
|
-
const reopened = withStatus(state, target.ref, "in_progress", {
|
|
10304
|
+
const reopened = withStatus(state, target.ref, "in_progress", {
|
|
10305
|
+
note,
|
|
10306
|
+
awaitingCheckpoint: false
|
|
10307
|
+
});
|
|
10126
10308
|
const reopenedTarget = findTask(reopened, target.ref);
|
|
10127
10309
|
const nextCurrent = {
|
|
10128
10310
|
ref: reopenedTarget?.ref ?? target.ref,
|
|
@@ -10191,7 +10373,7 @@ async function removeStaleLock2(bundleDir) {
|
|
|
10191
10373
|
throw error;
|
|
10192
10374
|
}
|
|
10193
10375
|
if (Date.now() - info.mtimeMs <= LOCK_STALE_MS3) return;
|
|
10194
|
-
await
|
|
10376
|
+
await rm6(target, { force: true });
|
|
10195
10377
|
}
|
|
10196
10378
|
function envFirst(primary, legacy) {
|
|
10197
10379
|
const value = process.env[primary]?.trim();
|
|
@@ -10205,8 +10387,8 @@ function isMissingFile6(error) {
|
|
|
10205
10387
|
|
|
10206
10388
|
// src/zip.ts
|
|
10207
10389
|
var import_adm_zip = __toESM(require_adm_zip(), 1);
|
|
10208
|
-
import { mkdir as
|
|
10209
|
-
import { dirname as
|
|
10390
|
+
import { mkdir as mkdir5, writeFile as writeFile5 } from "node:fs/promises";
|
|
10391
|
+
import { dirname as dirname5, resolve as resolve4, sep } from "node:path";
|
|
10210
10392
|
async function extractBundle(bytes, targetDir) {
|
|
10211
10393
|
const root = resolve4(targetDir);
|
|
10212
10394
|
const zip = new import_adm_zip.default(Buffer.from(bytes));
|
|
@@ -10222,8 +10404,8 @@ async function extractBundle(bytes, targetDir) {
|
|
|
10222
10404
|
if (!destination.startsWith(`${root}${sep}`)) {
|
|
10223
10405
|
throw new Error(`Path bundle keluar dari direktori target: ${entry.entryName}`);
|
|
10224
10406
|
}
|
|
10225
|
-
await
|
|
10226
|
-
await
|
|
10407
|
+
await mkdir5(dirname5(destination), { recursive: true });
|
|
10408
|
+
await writeFile5(destination, entry.getData());
|
|
10227
10409
|
written.push(relative2);
|
|
10228
10410
|
}
|
|
10229
10411
|
return written;
|
|
@@ -10343,7 +10525,7 @@ async function linkCommand(projectId, options) {
|
|
|
10343
10525
|
await verifyProjectAccess(client, projectId);
|
|
10344
10526
|
await writeProjectLink(target, { projectId, apiUrl });
|
|
10345
10527
|
const skills = await installAgentSkills(target, { noSkills: skillsDisabled(options) });
|
|
10346
|
-
const linkedFile =
|
|
10528
|
+
const linkedFile = join8(target, ".jioogen", "project.json");
|
|
10347
10529
|
if (options.json === true) {
|
|
10348
10530
|
console.log(JSON.stringify({ projectId, target, apiUrl, linkedFile, skills }, null, 2));
|
|
10349
10531
|
return;
|
|
@@ -10478,7 +10660,7 @@ async function doctorCommand(options) {
|
|
|
10478
10660
|
const warns = report.checks.filter((check) => check.status === "warn").length;
|
|
10479
10661
|
console.log(
|
|
10480
10662
|
`
|
|
10481
|
-
${report.ok ? "Doctor OK" : "Doctor GAGAL"} (${fails} fail, ${warns} warn).` + (options.fix === true ? "" : " Jalankan `jioogen doctor --fix` untuk perbaikan wiring.")
|
|
10663
|
+
${report.ok ? "Doctor OK" : "Doctor GAGAL"} (${fails} fail, ${warns} warn).` + (report.ok || options.fix === true ? "" : " Jalankan `jioogen doctor --fix` untuk perbaikan wiring.")
|
|
10482
10664
|
);
|
|
10483
10665
|
}
|
|
10484
10666
|
if (!report.ok) process.exitCode = 1;
|
|
@@ -10588,6 +10770,21 @@ async function taskNextCommand(options) {
|
|
|
10588
10770
|
return;
|
|
10589
10771
|
}
|
|
10590
10772
|
const awaitingCheckpoint = written.current?.awaitingCheckpoint === true;
|
|
10773
|
+
const journal = await readRecovery(bundleDir);
|
|
10774
|
+
if (isExhausted(journal, next.task.id)) {
|
|
10775
|
+
const entry = journal.tasks[next.task.id];
|
|
10776
|
+
const diagnosis = describeRecovery(entry);
|
|
10777
|
+
if (options.json === true) {
|
|
10778
|
+
console.log(
|
|
10779
|
+
JSON.stringify({ done: false, projectId, recoveryExhausted: true, diagnosis }, null, 2)
|
|
10780
|
+
);
|
|
10781
|
+
return;
|
|
10782
|
+
}
|
|
10783
|
+
console.log("## RECOVERY_EXHAUSTED \u2014 task ini butuh keputusan");
|
|
10784
|
+
console.log(diagnosis);
|
|
10785
|
+
console.log("\nLanjutkan dengan `npx jioogen resume`, lalu ulangi dengan pendekatan berbeda.");
|
|
10786
|
+
return;
|
|
10787
|
+
}
|
|
10591
10788
|
const manifest = await readHarnessManifest(bundleDir);
|
|
10592
10789
|
const context = manifest === null ? void 0 : {
|
|
10593
10790
|
productKind: manifest.productKind,
|
|
@@ -10625,7 +10822,14 @@ Status: ${next.state.status} \u2014 silakan ulangi.`);
|
|
|
10625
10822
|
Progress: ${written.counts?.done ?? 0}/${definitions.length} task selesai.`);
|
|
10626
10823
|
}
|
|
10627
10824
|
async function taskStartCommand(ref, options) {
|
|
10825
|
+
const key = ref.trim().toUpperCase();
|
|
10628
10826
|
const task = await withLocalState(options, async (local) => {
|
|
10827
|
+
const journal = await readRecovery(local.bundleDir);
|
|
10828
|
+
if (isExhausted(journal, key) || isExhausted(journal, ref)) {
|
|
10829
|
+
throw new Error(
|
|
10830
|
+
`Task ${ref} berstatus RECOVERY_EXHAUSTED. Jalankan \`jioogen resume\` lalu ulangi dengan pendekatan berbeda.`
|
|
10831
|
+
);
|
|
10832
|
+
}
|
|
10629
10833
|
assertStartDependencies(ref, local.definitions, local.state.tasks);
|
|
10630
10834
|
const updated = withStatus(local.state, ref, "in_progress", {
|
|
10631
10835
|
awaitingCheckpoint: false,
|
|
@@ -10637,35 +10841,39 @@ async function taskStartCommand(ref, options) {
|
|
|
10637
10841
|
console.log(`Started ${task?.ref ?? ref} (attempt ${task?.attempt ?? 1}).`);
|
|
10638
10842
|
}
|
|
10639
10843
|
async function taskCompleteCommand(ref, options) {
|
|
10640
|
-
const { completedTask, next, checkpoint } = await withLocalState(
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
(entry) => entry.ref.toUpperCase() === ref.toUpperCase()
|
|
10648
|
-
);
|
|
10649
|
-
const next2 = selectNext(local.definitions, completed.tasks);
|
|
10650
|
-
const definition = local.definitions.find(
|
|
10651
|
-
(entry) => entry.id.toUpperCase() === ref.toUpperCase()
|
|
10652
|
-
);
|
|
10653
|
-
const risky = definition !== void 0 && isRiskyTask(definition);
|
|
10654
|
-
const boundary = completedTask2 !== void 0 && (next2 !== null && isBoundary(completedTask2, next2.task) || risky);
|
|
10655
|
-
if (boundary && completedTask2 !== void 0) {
|
|
10656
|
-
const target = next2?.task;
|
|
10657
|
-
const withCheckpoint = setCurrent(completed, {
|
|
10658
|
-
ref: target?.id ?? completedTask2.ref,
|
|
10659
|
-
layer: target?.layer ?? completedTask2.layer,
|
|
10660
|
-
phase: target?.phase ?? completedTask2.phase ?? 1,
|
|
10661
|
-
awaitingCheckpoint: true
|
|
10844
|
+
const { completedTask, next, checkpoint, bundleDir } = await withLocalState(
|
|
10845
|
+
options,
|
|
10846
|
+
async (local) => {
|
|
10847
|
+
assertCompleteDependencies(ref, local.definitions, local.state.tasks, options.force === true);
|
|
10848
|
+
const completed = withStatus(local.state, ref, "done", {
|
|
10849
|
+
note: options.note ?? "",
|
|
10850
|
+
awaitingCheckpoint: false
|
|
10662
10851
|
});
|
|
10663
|
-
|
|
10664
|
-
|
|
10852
|
+
const completedTask2 = completed.tasks.find(
|
|
10853
|
+
(entry) => entry.ref.toUpperCase() === ref.toUpperCase()
|
|
10854
|
+
);
|
|
10855
|
+
const next2 = selectNext(local.definitions, completed.tasks);
|
|
10856
|
+
const definition = local.definitions.find(
|
|
10857
|
+
(entry) => entry.id.toUpperCase() === ref.toUpperCase()
|
|
10858
|
+
);
|
|
10859
|
+
const risky = definition !== void 0 && isRiskyTask(definition);
|
|
10860
|
+
const boundary = completedTask2 !== void 0 && (next2 !== null && isBoundary(completedTask2, next2.task) || risky);
|
|
10861
|
+
if (boundary && completedTask2 !== void 0) {
|
|
10862
|
+
const target = next2?.task;
|
|
10863
|
+
const withCheckpoint = setCurrent(completed, {
|
|
10864
|
+
ref: target?.id ?? completedTask2.ref,
|
|
10865
|
+
layer: target?.layer ?? completedTask2.layer,
|
|
10866
|
+
phase: target?.phase ?? completedTask2.phase ?? 1,
|
|
10867
|
+
awaitingCheckpoint: true
|
|
10868
|
+
});
|
|
10869
|
+
await writeState(local.bundleDir, withCheckpoint);
|
|
10870
|
+
return { completedTask: completedTask2, next: next2, checkpoint: true, bundleDir: local.bundleDir };
|
|
10871
|
+
}
|
|
10872
|
+
await writeState(local.bundleDir, completed);
|
|
10873
|
+
return { completedTask: completedTask2, next: next2, checkpoint: false, bundleDir: local.bundleDir };
|
|
10665
10874
|
}
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
});
|
|
10875
|
+
);
|
|
10876
|
+
await recordSuccess(bundleDir, ref.trim().toUpperCase());
|
|
10669
10877
|
console.log(`Done ${completedTask?.ref ?? ref}.`);
|
|
10670
10878
|
if (checkpoint) {
|
|
10671
10879
|
if (next === null) {
|
|
@@ -10684,14 +10892,33 @@ async function taskCompleteCommand(ref, options) {
|
|
|
10684
10892
|
}
|
|
10685
10893
|
async function taskFailCommand(ref, reasonParts, options) {
|
|
10686
10894
|
const reason = reasonParts.join(" ").trim() || options.note || "";
|
|
10687
|
-
|
|
10895
|
+
const key = ref.trim().toUpperCase();
|
|
10896
|
+
const bundleDir = await withLocalState(options, async (local) => {
|
|
10688
10897
|
const updated = withStatus(local.state, ref, "failed", {
|
|
10689
10898
|
note: reason,
|
|
10690
10899
|
awaitingCheckpoint: false
|
|
10691
10900
|
});
|
|
10692
10901
|
await writeState(local.bundleDir, updated);
|
|
10902
|
+
return local.bundleDir;
|
|
10693
10903
|
});
|
|
10904
|
+
const recovery = await recordFailure(bundleDir, key, { note: reason });
|
|
10905
|
+
if (recovery.exhausted) {
|
|
10906
|
+
await withLocalState(options, async (local) => {
|
|
10907
|
+
const blocked = withStatus(local.state, ref, "blocked", {
|
|
10908
|
+
note: `RECOVERY_EXHAUSTED: ${describeRecovery(recovery.entry)}`,
|
|
10909
|
+
awaitingCheckpoint: false
|
|
10910
|
+
});
|
|
10911
|
+
await writeState(local.bundleDir, blocked);
|
|
10912
|
+
});
|
|
10913
|
+
}
|
|
10694
10914
|
console.log(`Failed ${ref}${reason.length > 0 ? `: ${reason}` : "."}`);
|
|
10915
|
+
console.log(
|
|
10916
|
+
`Recovery: attempt ${recovery.attempt}/${RECOVERY_BUDGET.maxAttempts}, kelas ${recovery.class}.`
|
|
10917
|
+
);
|
|
10918
|
+
if (recovery.exhausted) {
|
|
10919
|
+
console.log("Status: RECOVERY_EXHAUSTED (blocked). State tersimpan dan bisa dilanjutkan.");
|
|
10920
|
+
console.log(describeRecovery(recovery.entry));
|
|
10921
|
+
}
|
|
10695
10922
|
}
|
|
10696
10923
|
async function taskResetCommand(ref, reasonParts, options) {
|
|
10697
10924
|
const reason = reasonParts.join(" ").trim() || options.note || "";
|
|
@@ -10779,7 +11006,7 @@ async function syncCommand(options) {
|
|
|
10779
11006
|
assertBundleRelative(relative2);
|
|
10780
11007
|
files.push({
|
|
10781
11008
|
path: relative2,
|
|
10782
|
-
content: await
|
|
11009
|
+
content: await readFile8(join8(bundleDir, relative2), "utf8")
|
|
10783
11010
|
});
|
|
10784
11011
|
}
|
|
10785
11012
|
}
|
|
@@ -10913,12 +11140,12 @@ async function assertLinkTarget(target, projectId) {
|
|
|
10913
11140
|
}
|
|
10914
11141
|
async function hasBundleMarkers(target) {
|
|
10915
11142
|
try {
|
|
10916
|
-
await
|
|
11143
|
+
await readFile8(join8(target, "PRD.md"));
|
|
10917
11144
|
return true;
|
|
10918
11145
|
} catch (error) {
|
|
10919
11146
|
if (!isMissingFile7(error)) throw error;
|
|
10920
11147
|
}
|
|
10921
|
-
return hasTaskMarkdown(
|
|
11148
|
+
return hasTaskMarkdown(join8(target, "tasks"));
|
|
10922
11149
|
}
|
|
10923
11150
|
async function hasTaskMarkdown(directory) {
|
|
10924
11151
|
let names;
|
|
@@ -10992,7 +11219,7 @@ function isMissingFile7(error) {
|
|
|
10992
11219
|
}
|
|
10993
11220
|
|
|
10994
11221
|
// src/index.ts
|
|
10995
|
-
var VERSION = "0.2.
|
|
11222
|
+
var VERSION = "0.2.6";
|
|
10996
11223
|
var USAGE = `jioogen \u2014 CLI JiooGen (task selection lokal, server read-only)
|
|
10997
11224
|
|
|
10998
11225
|
Usage:
|