jioogen 0.2.17 → 0.2.19
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 +503 -252
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9898,6 +9898,59 @@ function summarizeExecutionCounts(tasks) {
|
|
|
9898
9898
|
}
|
|
9899
9899
|
return base;
|
|
9900
9900
|
}
|
|
9901
|
+
var SUPERSESSION_SUMMARY_PREFIX = "stale adoption superseded";
|
|
9902
|
+
function isSupersessionEvidence(entry) {
|
|
9903
|
+
return entry.type === "text" && (entry.summary ?? "").startsWith(SUPERSESSION_SUMMARY_PREFIX);
|
|
9904
|
+
}
|
|
9905
|
+
var ADOPTION_MARKER_PREFIX = "adopted outside harness";
|
|
9906
|
+
function isAdoptionMarker(entry) {
|
|
9907
|
+
return entry.type === "text" && entry.summary !== void 0 && entry.summary.startsWith(ADOPTION_MARKER_PREFIX);
|
|
9908
|
+
}
|
|
9909
|
+
function validAt(entry) {
|
|
9910
|
+
if (entry.at === void 0) return void 0;
|
|
9911
|
+
const parsed = Date.parse(entry.at);
|
|
9912
|
+
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
9913
|
+
}
|
|
9914
|
+
function adoptionMarkers(task) {
|
|
9915
|
+
return (task.evidence ?? []).filter(isAdoptionMarker);
|
|
9916
|
+
}
|
|
9917
|
+
function maxAdoptionAt(task) {
|
|
9918
|
+
const values = adoptionMarkers(task).map(validAt).filter((value) => value !== void 0);
|
|
9919
|
+
if (values.length === 0) return void 0;
|
|
9920
|
+
return Math.max(...values);
|
|
9921
|
+
}
|
|
9922
|
+
function maxSupersededAt(task) {
|
|
9923
|
+
const values = (task.evidence ?? []).filter(isSupersessionEvidence).map(validAt).filter((value) => value !== void 0);
|
|
9924
|
+
if (values.length === 0) return void 0;
|
|
9925
|
+
return Math.max(...values);
|
|
9926
|
+
}
|
|
9927
|
+
function isAdoptedTask(task) {
|
|
9928
|
+
const baseAdopted = task.source === "user" || (task.evidence ?? []).some(
|
|
9929
|
+
(entry) => entry.type === "text" && entry.summary !== void 0 && entry.summary.startsWith(ADOPTION_MARKER_PREFIX)
|
|
9930
|
+
);
|
|
9931
|
+
if (!baseAdopted) return false;
|
|
9932
|
+
const adoptionAt = maxAdoptionAt(task);
|
|
9933
|
+
if (adoptionAt === void 0) return true;
|
|
9934
|
+
const supersededAt = maxSupersededAt(task);
|
|
9935
|
+
if (supersededAt !== void 0 && supersededAt > adoptionAt) return false;
|
|
9936
|
+
return true;
|
|
9937
|
+
}
|
|
9938
|
+
function isStaleAdoption(task) {
|
|
9939
|
+
if (task.status !== "done") return false;
|
|
9940
|
+
if (!isAdoptedTask(task)) return false;
|
|
9941
|
+
const adoptionAt = maxAdoptionAt(task);
|
|
9942
|
+
if (adoptionAt === void 0) return false;
|
|
9943
|
+
const verificationEntries = (task.evidence ?? []).filter(
|
|
9944
|
+
(entry) => entry.type === "verification" && typeof entry.exitCode === "number"
|
|
9945
|
+
);
|
|
9946
|
+
const withAt = verificationEntries.map((entry) => ({ entry, at: validAt(entry) })).filter((item) => item.at !== void 0);
|
|
9947
|
+
if (withAt.length === 0) return false;
|
|
9948
|
+
const maxAt = Math.max(...withAt.map((item) => item.at));
|
|
9949
|
+
if (withAt.some((item) => item.at === maxAt && item.entry.exitCode !== 0)) return false;
|
|
9950
|
+
const latest = withAt.find((item) => item.at === maxAt && item.entry.exitCode === 0);
|
|
9951
|
+
if (latest === void 0) return false;
|
|
9952
|
+
return latest.at > adoptionAt;
|
|
9953
|
+
}
|
|
9901
9954
|
function computeCompletion(tasks, definitions) {
|
|
9902
9955
|
const defById = new Map(
|
|
9903
9956
|
(definitions ?? []).map((definition) => [definition.id.toUpperCase(), definition])
|
|
@@ -9918,20 +9971,26 @@ function computeCompletion(tasks, definitions) {
|
|
|
9918
9971
|
for (const subfeature of definition.subfeatures ?? []) tally(subfeature, done);
|
|
9919
9972
|
};
|
|
9920
9973
|
let tasksDone = 0;
|
|
9974
|
+
let tasksVerified = 0;
|
|
9975
|
+
const adoptedTaskRefs = [];
|
|
9921
9976
|
const seenIds = /* @__PURE__ */ new Set();
|
|
9922
9977
|
const doneRefs = /* @__PURE__ */ new Set();
|
|
9923
9978
|
for (const task of tasks) {
|
|
9924
9979
|
const done = task.status === "done";
|
|
9980
|
+
const adopted = isAdoptedTask(task);
|
|
9981
|
+
const verifiedDone = done && !adopted;
|
|
9925
9982
|
if (done) {
|
|
9926
9983
|
tasksDone += 1;
|
|
9927
9984
|
doneRefs.add(task.ref.toUpperCase());
|
|
9928
9985
|
}
|
|
9986
|
+
if (verifiedDone) tasksVerified += 1;
|
|
9987
|
+
if (adopted) adoptedTaskRefs.push(task.ref);
|
|
9929
9988
|
seenIds.add(task.ref.toUpperCase());
|
|
9930
9989
|
const definition = defById.get(task.ref.toUpperCase());
|
|
9931
|
-
tally(definition?.featureId ?? task.featureId,
|
|
9932
|
-
tally(definition?.moduleId ?? task.moduleId,
|
|
9990
|
+
tally(definition?.featureId ?? task.featureId, verifiedDone);
|
|
9991
|
+
tally(definition?.moduleId ?? task.moduleId, verifiedDone);
|
|
9933
9992
|
const subfeatures = definition?.subfeatures ?? task.subfeatures ?? [];
|
|
9934
|
-
for (const subfeature of subfeatures) tally(subfeature,
|
|
9993
|
+
for (const subfeature of subfeatures) tally(subfeature, verifiedDone);
|
|
9935
9994
|
}
|
|
9936
9995
|
for (const definition of definitions ?? []) {
|
|
9937
9996
|
if (definition !== void 0 && !seenIds.has(definition.id.toUpperCase())) {
|
|
@@ -9943,20 +10002,29 @@ function computeCompletion(tasks, definitions) {
|
|
|
9943
10002
|
const status = entry.done === 0 ? "missing" : entry.done < entry.total ? "incomplete" : "complete";
|
|
9944
10003
|
features[id] = { status, doneTasks: entry.done, totalTasks: entry.total };
|
|
9945
10004
|
}
|
|
9946
|
-
const
|
|
10005
|
+
const allTasksVerified = tasks.every((task) => task.status === "done" && !isAdoptedTask(task));
|
|
9947
10006
|
const unitIds = Object.keys(features);
|
|
9948
10007
|
const allUnitsComplete = unitIds.length > 0 && unitIds.every((id) => features[id]?.status === "complete");
|
|
9949
10008
|
let allIntegrationDone = true;
|
|
9950
10009
|
for (const task of tasks) {
|
|
9951
|
-
if (task.layer === "integration" && task.status !== "done"
|
|
10010
|
+
if (task.layer === "integration" && (task.status !== "done" || isAdoptedTask(task))) {
|
|
10011
|
+
allIntegrationDone = false;
|
|
10012
|
+
}
|
|
9952
10013
|
}
|
|
9953
10014
|
for (const definition of definitions ?? []) {
|
|
9954
10015
|
if (definition.layer === "integration" && !doneRefs.has(definition.id.toUpperCase())) {
|
|
9955
10016
|
allIntegrationDone = false;
|
|
9956
10017
|
}
|
|
9957
10018
|
}
|
|
9958
|
-
const projectComplete =
|
|
9959
|
-
return {
|
|
10019
|
+
const projectComplete = allTasksVerified && allUnitsComplete && allIntegrationDone;
|
|
10020
|
+
return {
|
|
10021
|
+
tasksDone,
|
|
10022
|
+
tasksVerified,
|
|
10023
|
+
totalTasks: tasks.length,
|
|
10024
|
+
features,
|
|
10025
|
+
adoptedTaskRefs,
|
|
10026
|
+
projectComplete
|
|
10027
|
+
};
|
|
9960
10028
|
}
|
|
9961
10029
|
|
|
9962
10030
|
// ../contracts/src/layout.ts
|
|
@@ -11229,6 +11297,34 @@ function appendTaskEvidence(state, ref, evidence) {
|
|
|
11229
11297
|
const tasks = state.tasks.map((entry, i) => i === index ? task : entry);
|
|
11230
11298
|
return rebuild(state, tasks, state.current);
|
|
11231
11299
|
}
|
|
11300
|
+
function supersedeStaleAdoption(state, ref, now = /* @__PURE__ */ new Date()) {
|
|
11301
|
+
const index = state.tasks.findIndex((task) => task.ref.toUpperCase() === ref.toUpperCase());
|
|
11302
|
+
if (index === -1) return state;
|
|
11303
|
+
const previous = state.tasks[index];
|
|
11304
|
+
if (previous === void 0) return state;
|
|
11305
|
+
const adoptionMarkers2 = (previous.evidence ?? []).filter(
|
|
11306
|
+
(entry) => entry.type === "text" && entry.summary !== void 0 && entry.summary.startsWith("adopted outside harness")
|
|
11307
|
+
);
|
|
11308
|
+
if (adoptionMarkers2.length === 0) return state;
|
|
11309
|
+
if (!isAdoptedTask(previous)) return state;
|
|
11310
|
+
const adoptionAtValues = adoptionMarkers2.map((entry) => entry.at === void 0 ? NaN : Date.parse(entry.at)).filter((value) => !Number.isNaN(value));
|
|
11311
|
+
if (adoptionAtValues.length === 0) return state;
|
|
11312
|
+
const latestAdoptionAt = Math.max(...adoptionAtValues);
|
|
11313
|
+
const effectiveMs = Math.max(now.getTime(), latestAdoptionAt + 1);
|
|
11314
|
+
const effective = new Date(effectiveMs).toISOString();
|
|
11315
|
+
const summary = `${SUPERSESSION_SUMMARY_PREFIX}: ${adoptionMarkers2.length} marker(s), verified exit 0`;
|
|
11316
|
+
const updated = {
|
|
11317
|
+
...previous,
|
|
11318
|
+
updatedAt: effective,
|
|
11319
|
+
evidence: [...previous.evidence ?? [], { type: "text", summary, at: effective }],
|
|
11320
|
+
history: [
|
|
11321
|
+
...previous.history ?? [],
|
|
11322
|
+
{ status: previous.status, at: effective, note: SUPERSESSION_SUMMARY_PREFIX }
|
|
11323
|
+
]
|
|
11324
|
+
};
|
|
11325
|
+
const tasks = state.tasks.map((entry, i) => i === index ? updated : entry);
|
|
11326
|
+
return rebuild(state, tasks, state.current, new Date(effectiveMs));
|
|
11327
|
+
}
|
|
11232
11328
|
function setTaskSource(state, ref, source) {
|
|
11233
11329
|
const index = state.tasks.findIndex((task2) => task2.ref.toUpperCase() === ref.toUpperCase());
|
|
11234
11330
|
if (index === -1) return state;
|
|
@@ -13174,14 +13270,166 @@ function isMissingFile3(error) {
|
|
|
13174
13270
|
}
|
|
13175
13271
|
|
|
13176
13272
|
// src/doctor.ts
|
|
13177
|
-
import { readdir as readdir7, readFile as
|
|
13178
|
-
import { join as
|
|
13273
|
+
import { readdir as readdir7, readFile as readFile11, rm as rm8, stat as stat6 } from "node:fs/promises";
|
|
13274
|
+
import { join as join12 } from "node:path";
|
|
13275
|
+
|
|
13276
|
+
// src/recovery.ts
|
|
13277
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
13278
|
+
import { mkdir as mkdir7, readFile as readFile9, rename as rename2, rm as rm6, writeFile as writeFile7 } from "node:fs/promises";
|
|
13279
|
+
import { dirname as dirname6, join as join10 } from "node:path";
|
|
13280
|
+
var RECOVERY_PATH = "tasks/.execution/recovery.json";
|
|
13281
|
+
var RECOVERY_BUDGET = { maxAttempts: 3 };
|
|
13282
|
+
var RECOVERY_BASE_ATTEMPTS = 3;
|
|
13283
|
+
var RECOVERY_MAX_ATTEMPTS = 6;
|
|
13284
|
+
function recoveryBudget(input) {
|
|
13285
|
+
let budget = RECOVERY_BASE_ATTEMPTS;
|
|
13286
|
+
if (input.failureClass === "transient") budget += 1;
|
|
13287
|
+
if (input.failureClass === "semantic") budget += 1;
|
|
13288
|
+
return Math.min(budget, RECOVERY_MAX_ATTEMPTS);
|
|
13289
|
+
}
|
|
13290
|
+
function recoveryPath(bundleDir) {
|
|
13291
|
+
return join10(bundleDir, RECOVERY_PATH);
|
|
13292
|
+
}
|
|
13293
|
+
function isMissingFile4(error) {
|
|
13294
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
13295
|
+
}
|
|
13296
|
+
function emptyJournal() {
|
|
13297
|
+
return { schemaVersion: 1, tasks: {} };
|
|
13298
|
+
}
|
|
13299
|
+
function isJournal(value) {
|
|
13300
|
+
if (typeof value !== "object" || value === null) return false;
|
|
13301
|
+
const obj = value;
|
|
13302
|
+
if (obj.schemaVersion !== 1) return false;
|
|
13303
|
+
if (typeof obj.tasks !== "object" || obj.tasks === null) return false;
|
|
13304
|
+
return true;
|
|
13305
|
+
}
|
|
13306
|
+
async function readRecoveryStrict(bundleDir) {
|
|
13307
|
+
let raw;
|
|
13308
|
+
try {
|
|
13309
|
+
raw = await readFile9(recoveryPath(bundleDir), "utf8");
|
|
13310
|
+
} catch (error) {
|
|
13311
|
+
if (isMissingFile4(error)) return emptyJournal();
|
|
13312
|
+
return null;
|
|
13313
|
+
}
|
|
13314
|
+
let payload;
|
|
13315
|
+
try {
|
|
13316
|
+
payload = JSON.parse(raw);
|
|
13317
|
+
} catch {
|
|
13318
|
+
return null;
|
|
13319
|
+
}
|
|
13320
|
+
if (!isJournal(payload)) return null;
|
|
13321
|
+
return payload;
|
|
13322
|
+
}
|
|
13323
|
+
async function readRecovery(bundleDir) {
|
|
13324
|
+
const strict = await readRecoveryStrict(bundleDir);
|
|
13325
|
+
return strict ?? emptyJournal();
|
|
13326
|
+
}
|
|
13327
|
+
function classifyFailure(input) {
|
|
13328
|
+
if (input.stalled === true || input.timedOut === true) return "transient";
|
|
13329
|
+
if (input.verificationFailed === true) return "semantic";
|
|
13330
|
+
const note = input.note ?? "";
|
|
13331
|
+
if (/^AUTHORIZATION:/i.test(note.trim())) return "authorization";
|
|
13332
|
+
if (/timeout|stall|econn|rate limit|\b429\b|\b5\d\d\b/i.test(note)) return "transient";
|
|
13333
|
+
const prior = input.prior ?? null;
|
|
13334
|
+
if (prior !== null && prior.attempts >= 1 && note === prior.lastNote) return "no_progress";
|
|
13335
|
+
return "semantic";
|
|
13336
|
+
}
|
|
13337
|
+
async function writeRecovery(bundleDir, journal) {
|
|
13338
|
+
const target = recoveryPath(bundleDir);
|
|
13339
|
+
await mkdir7(dirname6(target), { recursive: true });
|
|
13340
|
+
const temp = `${target}.${process.pid}.${randomUUID2()}.tmp`;
|
|
13341
|
+
try {
|
|
13342
|
+
await writeFile7(temp, `${JSON.stringify(journal, null, 2)}
|
|
13343
|
+
`, "utf8");
|
|
13344
|
+
await rename2(temp, target);
|
|
13345
|
+
} catch (error) {
|
|
13346
|
+
await rm6(temp, { force: true }).catch(() => {
|
|
13347
|
+
});
|
|
13348
|
+
throw error;
|
|
13349
|
+
}
|
|
13350
|
+
}
|
|
13351
|
+
async function recordFailure(bundleDir, ref, args) {
|
|
13352
|
+
return withStateLock(bundleDir, async () => {
|
|
13353
|
+
const journal = await readRecovery(bundleDir);
|
|
13354
|
+
const prior = journal.tasks[ref] ?? null;
|
|
13355
|
+
const klass = classifyFailure({ ...args, prior });
|
|
13356
|
+
const attempt = (prior?.attempts ?? 0) + 1;
|
|
13357
|
+
const budget = recoveryBudget({
|
|
13358
|
+
failureClass: klass,
|
|
13359
|
+
priorAttempts: prior?.attempts ?? 0,
|
|
13360
|
+
priorClass: prior?.lastClass ?? null
|
|
13361
|
+
});
|
|
13362
|
+
const exhausted = attempt >= budget;
|
|
13363
|
+
const resumable = exhausted;
|
|
13364
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
13365
|
+
const note = args.note ?? "";
|
|
13366
|
+
const history = [...prior?.history ?? []];
|
|
13367
|
+
history.push({ attempt, class: klass, note, at: now });
|
|
13368
|
+
const capped = history.length > 20 ? history.slice(history.length - 20) : history;
|
|
13369
|
+
const entry = {
|
|
13370
|
+
ref,
|
|
13371
|
+
attempts: attempt,
|
|
13372
|
+
exhausted,
|
|
13373
|
+
resumable,
|
|
13374
|
+
lastClass: klass,
|
|
13375
|
+
lastNote: note === "" ? prior?.lastNote ?? "" : note,
|
|
13376
|
+
history: capped,
|
|
13377
|
+
updatedAt: now
|
|
13378
|
+
};
|
|
13379
|
+
journal.tasks[ref] = entry;
|
|
13380
|
+
await writeRecovery(bundleDir, journal);
|
|
13381
|
+
return { entry, exhausted, class: klass, attempt };
|
|
13382
|
+
});
|
|
13383
|
+
}
|
|
13384
|
+
async function recordSuccess(bundleDir, ref) {
|
|
13385
|
+
await withStateLock(bundleDir, async () => {
|
|
13386
|
+
const journal = await readRecovery(bundleDir);
|
|
13387
|
+
if (journal.tasks[ref] !== void 0) {
|
|
13388
|
+
delete journal.tasks[ref];
|
|
13389
|
+
await writeRecovery(bundleDir, journal);
|
|
13390
|
+
}
|
|
13391
|
+
});
|
|
13392
|
+
}
|
|
13393
|
+
async function rearmTask(bundleDir, ref) {
|
|
13394
|
+
await withStateLock(bundleDir, async () => {
|
|
13395
|
+
const journal = await readRecovery(bundleDir);
|
|
13396
|
+
const prior = journal.tasks[ref];
|
|
13397
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
13398
|
+
const entry = {
|
|
13399
|
+
ref,
|
|
13400
|
+
attempts: 0,
|
|
13401
|
+
exhausted: false,
|
|
13402
|
+
resumable: true,
|
|
13403
|
+
lastClass: prior?.lastClass ?? null,
|
|
13404
|
+
lastNote: prior?.lastNote ?? "",
|
|
13405
|
+
history: prior?.history ?? [],
|
|
13406
|
+
updatedAt: now
|
|
13407
|
+
};
|
|
13408
|
+
journal.tasks[ref] = entry;
|
|
13409
|
+
await writeRecovery(bundleDir, journal);
|
|
13410
|
+
});
|
|
13411
|
+
}
|
|
13412
|
+
function isExhausted(journal, ref) {
|
|
13413
|
+
return journal.tasks[ref]?.exhausted === true;
|
|
13414
|
+
}
|
|
13415
|
+
function describeRecovery(entry) {
|
|
13416
|
+
if (entry === void 0) {
|
|
13417
|
+
return "No recovery record. Run `jioogen resume`, then retry with a different approach.";
|
|
13418
|
+
}
|
|
13419
|
+
const lines = [];
|
|
13420
|
+
lines.push(
|
|
13421
|
+
`Task ${entry.ref}: ${entry.attempts}/${RECOVERY_BUDGET.maxAttempts} attempts, last=${entry.lastClass ?? "none"}.`
|
|
13422
|
+
);
|
|
13423
|
+
if (entry.lastNote.length > 0) lines.push(`Last note: ${entry.lastNote}`);
|
|
13424
|
+
lines.push("Run `jioogen resume`, then retry with a different approach.");
|
|
13425
|
+
return lines.join("\n");
|
|
13426
|
+
}
|
|
13179
13427
|
|
|
13180
13428
|
// src/skills.ts
|
|
13181
13429
|
import { createHash as createHash3 } from "node:crypto";
|
|
13182
|
-
import { cp as cp2, mkdir as
|
|
13430
|
+
import { cp as cp2, mkdir as mkdir8, readdir as readdir6, readFile as readFile10, rename as rename3, rm as rm7, stat as stat5, writeFile as writeFile8 } from "node:fs/promises";
|
|
13183
13431
|
import { homedir as homedir2 } from "node:os";
|
|
13184
|
-
import { dirname as
|
|
13432
|
+
import { dirname as dirname7, join as join11, resolve as resolve3 } from "node:path";
|
|
13185
13433
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
13186
13434
|
var EXECUTION_SKILL_NAME = "jioogen-execution";
|
|
13187
13435
|
var AGENT_SKILL_DIRS = [
|
|
@@ -13664,18 +13912,18 @@ Gap non-material \u2192 tafsir paling sempit + catat asumsi di note, lanjut. Gap
|
|
|
13664
13912
|
Jangan menebak scope baru.
|
|
13665
13913
|
`;
|
|
13666
13914
|
async function ensureCustomScaffold(root) {
|
|
13667
|
-
const base =
|
|
13915
|
+
const base = join11(root, ".jioogen", "custom");
|
|
13668
13916
|
for (const dir of CUSTOM_SCAFFOLD_DIRS) {
|
|
13669
|
-
await
|
|
13917
|
+
await mkdir8(join11(base, dir), { recursive: true });
|
|
13670
13918
|
}
|
|
13671
|
-
const readme =
|
|
13919
|
+
const readme = join11(root, CUSTOM_SCAFFOLD_README_PATH);
|
|
13672
13920
|
if (await readFileSafe(readme) !== void 0) return [];
|
|
13673
|
-
await
|
|
13921
|
+
await writeFile8(readme, CUSTOM_SCAFFOLD_README, "utf8");
|
|
13674
13922
|
return [CUSTOM_SCAFFOLD_README_PATH];
|
|
13675
13923
|
}
|
|
13676
13924
|
async function readFileSafe(path) {
|
|
13677
13925
|
try {
|
|
13678
|
-
return await
|
|
13926
|
+
return await readFile10(path, "utf8");
|
|
13679
13927
|
} catch {
|
|
13680
13928
|
return void 0;
|
|
13681
13929
|
}
|
|
@@ -13683,14 +13931,14 @@ async function readFileSafe(path) {
|
|
|
13683
13931
|
function isRecord2(value) {
|
|
13684
13932
|
return typeof value === "object" && value !== null;
|
|
13685
13933
|
}
|
|
13686
|
-
function
|
|
13934
|
+
function isMissingFile5(error) {
|
|
13687
13935
|
return isRecord2(error) && error.code === "ENOENT";
|
|
13688
13936
|
}
|
|
13689
13937
|
async function isFile(path) {
|
|
13690
13938
|
try {
|
|
13691
13939
|
return (await stat5(path)).isFile();
|
|
13692
13940
|
} catch (error) {
|
|
13693
|
-
if (
|
|
13941
|
+
if (isMissingFile5(error)) return false;
|
|
13694
13942
|
throw error;
|
|
13695
13943
|
}
|
|
13696
13944
|
}
|
|
@@ -13698,7 +13946,7 @@ async function isDirectory(path) {
|
|
|
13698
13946
|
try {
|
|
13699
13947
|
return (await stat5(path)).isDirectory();
|
|
13700
13948
|
} catch (error) {
|
|
13701
|
-
if (
|
|
13949
|
+
if (isMissingFile5(error)) return false;
|
|
13702
13950
|
throw error;
|
|
13703
13951
|
}
|
|
13704
13952
|
}
|
|
@@ -13764,12 +14012,12 @@ function parseHarnessManifest(value) {
|
|
|
13764
14012
|
};
|
|
13765
14013
|
}
|
|
13766
14014
|
async function readHarnessManifest(bundleDir) {
|
|
13767
|
-
const path =
|
|
14015
|
+
const path = join11(resolve3(bundleDir), HARNESS_MANIFEST_PATH);
|
|
13768
14016
|
let raw;
|
|
13769
14017
|
try {
|
|
13770
|
-
raw = await
|
|
14018
|
+
raw = await readFile10(path, "utf8");
|
|
13771
14019
|
} catch (error) {
|
|
13772
|
-
if (
|
|
14020
|
+
if (isMissingFile5(error)) return null;
|
|
13773
14021
|
throw error;
|
|
13774
14022
|
}
|
|
13775
14023
|
try {
|
|
@@ -13779,24 +14027,24 @@ async function readHarnessManifest(bundleDir) {
|
|
|
13779
14027
|
}
|
|
13780
14028
|
}
|
|
13781
14029
|
async function writeHarnessManifest(bundleDir, manifest) {
|
|
13782
|
-
const path =
|
|
13783
|
-
await
|
|
13784
|
-
await
|
|
14030
|
+
const path = join11(resolve3(bundleDir), HARNESS_MANIFEST_PATH);
|
|
14031
|
+
await mkdir8(dirname7(path), { recursive: true });
|
|
14032
|
+
await writeFile8(path, `${JSON.stringify(manifest, null, 2)}
|
|
13785
14033
|
`, "utf8");
|
|
13786
14034
|
return path;
|
|
13787
14035
|
}
|
|
13788
14036
|
async function detectProductKind(bundleDir) {
|
|
13789
|
-
const tasksDir =
|
|
14037
|
+
const tasksDir = join11(contractRoot(resolve3(bundleDir)), "tasks");
|
|
13790
14038
|
let entries;
|
|
13791
14039
|
try {
|
|
13792
14040
|
entries = await readdir6(tasksDir, { withFileTypes: true });
|
|
13793
14041
|
} catch (error) {
|
|
13794
|
-
if (
|
|
14042
|
+
if (isMissingFile5(error)) return "non-ui";
|
|
13795
14043
|
throw error;
|
|
13796
14044
|
}
|
|
13797
14045
|
for (const entry of entries) {
|
|
13798
14046
|
if (!entry.isFile() || !entry.name.toLowerCase().endsWith(".md")) continue;
|
|
13799
|
-
const content = await readFileSafe(
|
|
14047
|
+
const content = await readFileSafe(join11(tasksDir, entry.name));
|
|
13800
14048
|
if (content !== void 0 && FRONTEND_MOCK_LAYER_RE.test(content)) return "ui";
|
|
13801
14049
|
}
|
|
13802
14050
|
return "non-ui";
|
|
@@ -13812,30 +14060,30 @@ function packsForProduct(productKind, uiQuality = "auto") {
|
|
|
13812
14060
|
return packs;
|
|
13813
14061
|
}
|
|
13814
14062
|
function cliPackageRoot2() {
|
|
13815
|
-
return resolve3(
|
|
14063
|
+
return resolve3(dirname7(fileURLToPath2(import.meta.url)), "..");
|
|
13816
14064
|
}
|
|
13817
14065
|
function skillSourceCandidates(pack, name) {
|
|
13818
14066
|
const candidates = [];
|
|
13819
14067
|
const override = process.env.JIOOGEN_SKILLS_DIR?.trim();
|
|
13820
|
-
if (override !== void 0 && override.length > 0) candidates.push(
|
|
13821
|
-
candidates.push(
|
|
13822
|
-
candidates.push(
|
|
14068
|
+
if (override !== void 0 && override.length > 0) candidates.push(join11(override, name));
|
|
14069
|
+
candidates.push(join11(configDir(), "skill-cache", name));
|
|
14070
|
+
candidates.push(join11(cliPackageRoot2(), "skills-pack", pack, name));
|
|
13823
14071
|
const home = homedir2();
|
|
13824
|
-
candidates.push(
|
|
13825
|
-
candidates.push(
|
|
13826
|
-
candidates.push(
|
|
14072
|
+
candidates.push(join11(home, ".agents", "skills", name));
|
|
14073
|
+
candidates.push(join11(home, ".config", "opencode", "skills", name));
|
|
14074
|
+
candidates.push(join11(home, ".claude", "skills", name));
|
|
13827
14075
|
return candidates;
|
|
13828
14076
|
}
|
|
13829
14077
|
async function resolveSkillSource(pack, name) {
|
|
13830
14078
|
for (const candidate of skillSourceCandidates(pack, name)) {
|
|
13831
|
-
if (await isDirectory(candidate) && await isFile(
|
|
14079
|
+
if (await isDirectory(candidate) && await isFile(join11(candidate, "SKILL.md"))) {
|
|
13832
14080
|
return candidate;
|
|
13833
14081
|
}
|
|
13834
14082
|
}
|
|
13835
14083
|
return null;
|
|
13836
14084
|
}
|
|
13837
14085
|
async function collectRelativeFiles(root, prefix) {
|
|
13838
|
-
const entries = await readdir6(
|
|
14086
|
+
const entries = await readdir6(join11(root, prefix), { withFileTypes: true });
|
|
13839
14087
|
const files = [];
|
|
13840
14088
|
for (const entry of entries) {
|
|
13841
14089
|
const relative3 = prefix.length === 0 ? entry.name : `${prefix}/${entry.name}`;
|
|
@@ -13854,14 +14102,14 @@ async function hashSkillDirectory(directory) {
|
|
|
13854
14102
|
for (const relative3 of files) {
|
|
13855
14103
|
hash.update(relative3);
|
|
13856
14104
|
hash.update("\0");
|
|
13857
|
-
hash.update(await
|
|
14105
|
+
hash.update(await readFile10(join11(root, ...relative3.split("/"))));
|
|
13858
14106
|
hash.update("\0");
|
|
13859
14107
|
}
|
|
13860
14108
|
return hash.digest("hex");
|
|
13861
14109
|
}
|
|
13862
14110
|
async function replaceDirectory(source, target) {
|
|
13863
|
-
await
|
|
13864
|
-
await
|
|
14111
|
+
await rm7(target, { recursive: true, force: true });
|
|
14112
|
+
await mkdir8(dirname7(target), { recursive: true });
|
|
13865
14113
|
await cp2(source, target, { recursive: true });
|
|
13866
14114
|
}
|
|
13867
14115
|
function packNamesInCanonicalOrder(names) {
|
|
@@ -13881,8 +14129,8 @@ async function provisionPack(root, pack, prior, written, preserved) {
|
|
|
13881
14129
|
const previous = prior?.skills.find((entry) => entry.name === name);
|
|
13882
14130
|
let owned = previous !== void 0;
|
|
13883
14131
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13884
|
-
const targetDir =
|
|
13885
|
-
const skillMd =
|
|
14132
|
+
const targetDir = join11(root, dir, name);
|
|
14133
|
+
const skillMd = join11(targetDir, "SKILL.md");
|
|
13886
14134
|
if (await isFile(skillMd)) {
|
|
13887
14135
|
const targetHash = await hashSkillDirectory(targetDir);
|
|
13888
14136
|
if (previous === void 0) {
|
|
@@ -13913,18 +14161,18 @@ async function provisionCustomSkills(root, prior) {
|
|
|
13913
14161
|
const conflicts = [];
|
|
13914
14162
|
const removed = [];
|
|
13915
14163
|
const sources = /* @__PURE__ */ new Set();
|
|
13916
|
-
const base =
|
|
14164
|
+
const base = join11(root, CUSTOM_SKILLS_DIR);
|
|
13917
14165
|
const reserved = /* @__PURE__ */ new Set([EXECUTION_SKILL_NAME, ...Object.values(SKILL_PACKS).flat()]);
|
|
13918
14166
|
let entries = [];
|
|
13919
14167
|
try {
|
|
13920
14168
|
entries = await readdir6(base, { withFileTypes: true });
|
|
13921
14169
|
} catch (error) {
|
|
13922
|
-
if (!
|
|
14170
|
+
if (!isMissingFile5(error)) throw error;
|
|
13923
14171
|
}
|
|
13924
14172
|
const names = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
13925
14173
|
for (const name of names) {
|
|
13926
|
-
const source =
|
|
13927
|
-
if (!await isFile(
|
|
14174
|
+
const source = join11(base, name);
|
|
14175
|
+
if (!await isFile(join11(source, "SKILL.md"))) continue;
|
|
13928
14176
|
sources.add(name);
|
|
13929
14177
|
if (reserved.has(name)) {
|
|
13930
14178
|
conflicts.push(name);
|
|
@@ -13934,8 +14182,8 @@ async function provisionCustomSkills(root, prior) {
|
|
|
13934
14182
|
const previous = prior.find((entry) => entry.name === name);
|
|
13935
14183
|
let owned = previous !== void 0;
|
|
13936
14184
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13937
|
-
const targetDir =
|
|
13938
|
-
const skillMd =
|
|
14185
|
+
const targetDir = join11(root, dir, name);
|
|
14186
|
+
const skillMd = join11(targetDir, "SKILL.md");
|
|
13939
14187
|
if (await isFile(skillMd)) {
|
|
13940
14188
|
const targetHash = await hashSkillDirectory(targetDir);
|
|
13941
14189
|
if (previous === void 0) {
|
|
@@ -13969,15 +14217,15 @@ async function provisionCustomSkills(root, prior) {
|
|
|
13969
14217
|
if (sources.has(entry.name) && !reserved.has(entry.name)) continue;
|
|
13970
14218
|
if (reserved.has(entry.name)) continue;
|
|
13971
14219
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13972
|
-
const targetDir =
|
|
13973
|
-
const skillMd =
|
|
14220
|
+
const targetDir = join11(root, dir, entry.name);
|
|
14221
|
+
const skillMd = join11(targetDir, "SKILL.md");
|
|
13974
14222
|
if (!await isFile(skillMd)) continue;
|
|
13975
14223
|
const targetHash = await hashSkillDirectory(targetDir);
|
|
13976
14224
|
if (targetHash !== entry.sha256) {
|
|
13977
14225
|
preserved.push(`${dir}/${entry.name}/SKILL.md`);
|
|
13978
14226
|
continue;
|
|
13979
14227
|
}
|
|
13980
|
-
await
|
|
14228
|
+
await rm7(targetDir, { recursive: true, force: true });
|
|
13981
14229
|
removed.push(`${dir}/${entry.name}/SKILL.md`);
|
|
13982
14230
|
}
|
|
13983
14231
|
}
|
|
@@ -14021,10 +14269,10 @@ async function provisionSkillPacks(bundleDir, packNames, productKind) {
|
|
|
14021
14269
|
};
|
|
14022
14270
|
}
|
|
14023
14271
|
async function ensureBundleGitignore(root) {
|
|
14024
|
-
const path =
|
|
14272
|
+
const path = join11(resolve3(root), ".gitignore");
|
|
14025
14273
|
const existing = await readFileSafe(path);
|
|
14026
14274
|
if (existing === void 0) {
|
|
14027
|
-
await
|
|
14275
|
+
await writeFile8(path, GITIGNORE_BLOCK, "utf8");
|
|
14028
14276
|
return ".gitignore";
|
|
14029
14277
|
}
|
|
14030
14278
|
const start = existing.indexOf(GITIGNORE_START);
|
|
@@ -14032,7 +14280,7 @@ async function ensureBundleGitignore(root) {
|
|
|
14032
14280
|
const next = start >= 0 && end > start ? `${existing.slice(0, start)}${GITIGNORE_BLOCK}${existing.slice(end + GITIGNORE_END.length).replace(/^\n/, "")}` : `${existing.replace(/\n*$/, "\n")}
|
|
14033
14281
|
${GITIGNORE_BLOCK}`;
|
|
14034
14282
|
if (next === existing) return null;
|
|
14035
|
-
await
|
|
14283
|
+
await writeFile8(path, next, "utf8");
|
|
14036
14284
|
return ".gitignore";
|
|
14037
14285
|
}
|
|
14038
14286
|
async function installAgentSkills(bundleDir, options = {}) {
|
|
@@ -14040,20 +14288,20 @@ async function installAgentSkills(bundleDir, options = {}) {
|
|
|
14040
14288
|
const written = [];
|
|
14041
14289
|
const preserved = [];
|
|
14042
14290
|
const productKind = options.productKind ?? await detectProductKind(root);
|
|
14043
|
-
const harnessPath =
|
|
14044
|
-
const agentsPath =
|
|
14291
|
+
const harnessPath = join11(root, HARNESS_MANIFEST_PATH);
|
|
14292
|
+
const agentsPath = join11(root, "AGENTS.md");
|
|
14045
14293
|
const existing = await readFileSafe(agentsPath);
|
|
14046
14294
|
if (existing === void 0 || existing.includes(MARKER_PREFIX)) {
|
|
14047
|
-
await
|
|
14295
|
+
await writeFile8(agentsPath, JIOOGEN_AGENTS_MD, "utf8");
|
|
14048
14296
|
written.push("AGENTS.md");
|
|
14049
14297
|
} else {
|
|
14050
14298
|
preserved.push("AGENTS.md");
|
|
14051
14299
|
}
|
|
14052
14300
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14053
14301
|
const relative3 = `${dir}/${EXECUTION_SKILL_NAME}/SKILL.md`;
|
|
14054
|
-
const target =
|
|
14055
|
-
await
|
|
14056
|
-
await
|
|
14302
|
+
const target = join11(root, relative3);
|
|
14303
|
+
await mkdir8(dirname7(target), { recursive: true });
|
|
14304
|
+
await writeFile8(target, JIOOGEN_EXECUTION_SKILL, "utf8");
|
|
14057
14305
|
written.push(relative3);
|
|
14058
14306
|
}
|
|
14059
14307
|
const gitignore = await ensureBundleGitignore(root);
|
|
@@ -14121,26 +14369,26 @@ async function removeExecutionContract(bundleDir) {
|
|
|
14121
14369
|
const root = resolve3(bundleDir);
|
|
14122
14370
|
const removed = [];
|
|
14123
14371
|
const preserved = [];
|
|
14124
|
-
const agentsPath =
|
|
14372
|
+
const agentsPath = join11(root, "AGENTS.md");
|
|
14125
14373
|
const existingAgents = await readFileSafe(agentsPath);
|
|
14126
14374
|
if (existingAgents !== void 0) {
|
|
14127
14375
|
if (existingAgents.includes(MARKER_PREFIX)) {
|
|
14128
|
-
await
|
|
14376
|
+
await rm7(agentsPath, { force: true });
|
|
14129
14377
|
removed.push("AGENTS.md");
|
|
14130
14378
|
} else {
|
|
14131
14379
|
preserved.push("AGENTS.md");
|
|
14132
14380
|
}
|
|
14133
14381
|
}
|
|
14134
14382
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14135
|
-
const target =
|
|
14383
|
+
const target = join11(root, dir, EXECUTION_SKILL_NAME);
|
|
14136
14384
|
try {
|
|
14137
14385
|
const info = await stat5(target);
|
|
14138
14386
|
if (info.isDirectory()) {
|
|
14139
|
-
await
|
|
14387
|
+
await rm7(target, { recursive: true, force: true });
|
|
14140
14388
|
removed.push(`${dir}/${EXECUTION_SKILL_NAME}`);
|
|
14141
14389
|
}
|
|
14142
14390
|
} catch (error) {
|
|
14143
|
-
if (!
|
|
14391
|
+
if (!isMissingFile5(error)) throw error;
|
|
14144
14392
|
}
|
|
14145
14393
|
}
|
|
14146
14394
|
return { removed, preserved };
|
|
@@ -14155,15 +14403,15 @@ async function removeSkillPack(bundleDir, pack) {
|
|
|
14155
14403
|
if (entry !== void 0) {
|
|
14156
14404
|
for (const skill of entry.skills) {
|
|
14157
14405
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14158
|
-
const targetDir =
|
|
14159
|
-
const skillMd =
|
|
14406
|
+
const targetDir = join11(root, dir, skill.name);
|
|
14407
|
+
const skillMd = join11(targetDir, "SKILL.md");
|
|
14160
14408
|
if (!await isFile(skillMd)) continue;
|
|
14161
14409
|
const targetHash = await hashSkillDirectory(targetDir);
|
|
14162
14410
|
if (targetHash !== skill.sha256) {
|
|
14163
14411
|
preserved.push(`${dir}/${skill.name}/SKILL.md`);
|
|
14164
14412
|
continue;
|
|
14165
14413
|
}
|
|
14166
|
-
await
|
|
14414
|
+
await rm7(targetDir, { recursive: true, force: true });
|
|
14167
14415
|
removed.push(`${dir}/${skill.name}/SKILL.md`);
|
|
14168
14416
|
}
|
|
14169
14417
|
}
|
|
@@ -14199,7 +14447,7 @@ async function restoreSkillPack(bundleDir, packArgument) {
|
|
|
14199
14447
|
}
|
|
14200
14448
|
const sha2562 = await hashSkillDirectory(source);
|
|
14201
14449
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14202
|
-
const targetDir =
|
|
14450
|
+
const targetDir = join11(root, dir, name);
|
|
14203
14451
|
await replaceDirectory(source, targetDir);
|
|
14204
14452
|
restored.push(`${dir}/${name}`);
|
|
14205
14453
|
}
|
|
@@ -14225,11 +14473,11 @@ async function disableSkill(bundleDir, name) {
|
|
|
14225
14473
|
const root = resolve3(bundleDir);
|
|
14226
14474
|
const disabled = [];
|
|
14227
14475
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14228
|
-
const targetDir =
|
|
14476
|
+
const targetDir = join11(root, dir, name);
|
|
14229
14477
|
const disabledDir = `${targetDir}.disabled`;
|
|
14230
14478
|
if (!await isDirectory(targetDir)) continue;
|
|
14231
|
-
if (await isDirectory(disabledDir)) await
|
|
14232
|
-
await
|
|
14479
|
+
if (await isDirectory(disabledDir)) await rm7(disabledDir, { recursive: true, force: true });
|
|
14480
|
+
await rename3(targetDir, disabledDir);
|
|
14233
14481
|
disabled.push(`${dir}/${name}`);
|
|
14234
14482
|
}
|
|
14235
14483
|
return { disabled };
|
|
@@ -14238,12 +14486,12 @@ async function enableSkill(bundleDir, name) {
|
|
|
14238
14486
|
const root = resolve3(bundleDir);
|
|
14239
14487
|
const enabled = [];
|
|
14240
14488
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14241
|
-
const targetDir =
|
|
14489
|
+
const targetDir = join11(root, dir, name);
|
|
14242
14490
|
const disabledDir = `${targetDir}.disabled`;
|
|
14243
14491
|
if (!await isDirectory(disabledDir)) continue;
|
|
14244
|
-
if (await isDirectory(targetDir)) await
|
|
14492
|
+
if (await isDirectory(targetDir)) await rm7(disabledDir, { recursive: true, force: true });
|
|
14245
14493
|
else {
|
|
14246
|
-
await
|
|
14494
|
+
await rename3(disabledDir, targetDir);
|
|
14247
14495
|
enabled.push(`${dir}/${name}`);
|
|
14248
14496
|
}
|
|
14249
14497
|
}
|
|
@@ -14266,7 +14514,7 @@ function makeCheck(id, status, detail, fixable) {
|
|
|
14266
14514
|
function errorMessage(error) {
|
|
14267
14515
|
return error instanceof Error ? error.message : String(error);
|
|
14268
14516
|
}
|
|
14269
|
-
function
|
|
14517
|
+
function isMissingFile6(error) {
|
|
14270
14518
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
14271
14519
|
}
|
|
14272
14520
|
function resolveDeps(deps) {
|
|
@@ -14280,7 +14528,8 @@ function resolveDeps(deps) {
|
|
|
14280
14528
|
const client = new ApiClient(apiUrl, cookie);
|
|
14281
14529
|
return client.getJson(projectPath(projectId, "/execution"));
|
|
14282
14530
|
}),
|
|
14283
|
-
installSkills: deps?.installSkills ?? ((bundleDir) => installAgentSkills(bundleDir))
|
|
14531
|
+
installSkills: deps?.installSkills ?? ((bundleDir) => installAgentSkills(bundleDir)),
|
|
14532
|
+
publishSidecar: deps?.publishSidecar
|
|
14284
14533
|
};
|
|
14285
14534
|
}
|
|
14286
14535
|
function checkNode() {
|
|
@@ -14428,17 +14677,17 @@ async function listMarkdownFiles(directory) {
|
|
|
14428
14677
|
async function checkBundle(bundleDir) {
|
|
14429
14678
|
const missing = [];
|
|
14430
14679
|
const contract = contractRoot(bundleDir);
|
|
14431
|
-
if (!await isFile2(
|
|
14432
|
-
const specsDir =
|
|
14680
|
+
if (!await isFile2(join12(contract, "PRD.md"))) missing.push("PRD.md");
|
|
14681
|
+
const specsDir = join12(contract, "specs");
|
|
14433
14682
|
if (!await isDirectory2(specsDir)) {
|
|
14434
14683
|
missing.push("specs/");
|
|
14435
14684
|
} else {
|
|
14436
14685
|
const markdown = await listMarkdownFiles(specsDir);
|
|
14437
|
-
const readme = await
|
|
14686
|
+
const readme = await readFile11(join12(specsDir, "SPECS.md"), "utf8").catch(() => "");
|
|
14438
14687
|
const hasContent = markdown.some((name) => name.toLowerCase() !== "specs.md") || specReadmeIsContent(readme);
|
|
14439
14688
|
if (!hasContent) missing.push("specs/*.md (konten)");
|
|
14440
14689
|
}
|
|
14441
|
-
const tasksDir =
|
|
14690
|
+
const tasksDir = join12(contract, "tasks");
|
|
14442
14691
|
if (!await isDirectory2(tasksDir)) {
|
|
14443
14692
|
missing.push("tasks/");
|
|
14444
14693
|
} else {
|
|
@@ -14484,6 +14733,82 @@ async function checkSidecar(bundleDir) {
|
|
|
14484
14733
|
);
|
|
14485
14734
|
}
|
|
14486
14735
|
}
|
|
14736
|
+
async function checkStaleAdoption(bundleDir) {
|
|
14737
|
+
let state;
|
|
14738
|
+
try {
|
|
14739
|
+
state = await readState(bundleDir);
|
|
14740
|
+
} catch (error) {
|
|
14741
|
+
return makeCheck(
|
|
14742
|
+
"stale-adoption",
|
|
14743
|
+
"warn",
|
|
14744
|
+
`Tidak bisa memeriksa stale adoption: ${errorMessage(error)}.`
|
|
14745
|
+
);
|
|
14746
|
+
}
|
|
14747
|
+
if (state === null) {
|
|
14748
|
+
return makeCheck("stale-adoption", "pass", "Belum ada sidecar; stale adoption tidak berlaku.");
|
|
14749
|
+
}
|
|
14750
|
+
const strictJournal = await readRecoveryStrict(bundleDir);
|
|
14751
|
+
if (strictJournal === null) {
|
|
14752
|
+
return makeCheck(
|
|
14753
|
+
"stale-adoption",
|
|
14754
|
+
"warn",
|
|
14755
|
+
"Recovery journal rusak; stale adoption tidak diperbaiki otomatis."
|
|
14756
|
+
);
|
|
14757
|
+
}
|
|
14758
|
+
const journal = strictJournal;
|
|
14759
|
+
const unusableAdopted = [];
|
|
14760
|
+
for (const task of state.tasks) {
|
|
14761
|
+
const markers = (task.evidence ?? []).filter(
|
|
14762
|
+
(entry) => entry.type === "text" && entry.summary !== void 0 && entry.summary.startsWith("adopted outside harness")
|
|
14763
|
+
);
|
|
14764
|
+
if (markers.length === 0) continue;
|
|
14765
|
+
const hasValidAt = markers.some((entry) => {
|
|
14766
|
+
if (entry.at === void 0) return false;
|
|
14767
|
+
return !Number.isNaN(Date.parse(entry.at));
|
|
14768
|
+
});
|
|
14769
|
+
const baseAdopted = task.source === "user" || (task.evidence ?? []).some(
|
|
14770
|
+
(entry) => entry.type === "text" && entry.summary !== void 0 && entry.summary.startsWith("adopted outside harness")
|
|
14771
|
+
);
|
|
14772
|
+
if (baseAdopted && !hasValidAt) {
|
|
14773
|
+
unusableAdopted.push(task.ref);
|
|
14774
|
+
}
|
|
14775
|
+
}
|
|
14776
|
+
const candidates = [];
|
|
14777
|
+
const deferred = [];
|
|
14778
|
+
for (const task of state.tasks) {
|
|
14779
|
+
if (!isStaleAdoption(task)) continue;
|
|
14780
|
+
const checkpointPending = state.current?.ref === task.ref && state.current.awaitingCheckpoint === true;
|
|
14781
|
+
const exhausted = isExhausted(journal, task.ref);
|
|
14782
|
+
if (checkpointPending || exhausted) {
|
|
14783
|
+
deferred.push(task.ref);
|
|
14784
|
+
continue;
|
|
14785
|
+
}
|
|
14786
|
+
candidates.push(task.ref);
|
|
14787
|
+
}
|
|
14788
|
+
if (candidates.length > 0) {
|
|
14789
|
+
const detailParts = [
|
|
14790
|
+
`Task stale adoption (verified exit 0 lebih baru): ${candidates.join(", ")}`
|
|
14791
|
+
];
|
|
14792
|
+
if (deferred.length > 0) detailParts.push(`ditunda: ${deferred.join(", ")}`);
|
|
14793
|
+
if (unusableAdopted.length > 0)
|
|
14794
|
+
detailParts.push(`tanpa timestamp: ${unusableAdopted.join(", ")}`);
|
|
14795
|
+
return makeCheck(
|
|
14796
|
+
"stale-adoption",
|
|
14797
|
+
"warn",
|
|
14798
|
+
`${detailParts.join("; ")}. Jalankan \`jioogen doctor --fix\`.`,
|
|
14799
|
+
true
|
|
14800
|
+
);
|
|
14801
|
+
}
|
|
14802
|
+
if (deferred.length > 0 || unusableAdopted.length > 0) {
|
|
14803
|
+
const refs = [...deferred, ...unusableAdopted];
|
|
14804
|
+
return makeCheck(
|
|
14805
|
+
"stale-adoption",
|
|
14806
|
+
"warn",
|
|
14807
|
+
`Stale adoption tertunda/tidak dapat diperbaiki: ${refs.join(", ")}.`
|
|
14808
|
+
);
|
|
14809
|
+
}
|
|
14810
|
+
return makeCheck("stale-adoption", "pass", "Tidak ada stale adoption.");
|
|
14811
|
+
}
|
|
14487
14812
|
async function checkDrift(bundleDir) {
|
|
14488
14813
|
try {
|
|
14489
14814
|
const local = await snapshotContract(bundleDir);
|
|
@@ -14531,12 +14856,12 @@ async function checkDrift(bundleDir) {
|
|
|
14531
14856
|
}
|
|
14532
14857
|
}
|
|
14533
14858
|
async function checkRecovery(bundleDir) {
|
|
14534
|
-
const path =
|
|
14859
|
+
const path = join12(contractRoot(bundleDir), "tasks/.execution/recovery.json");
|
|
14535
14860
|
let raw;
|
|
14536
14861
|
try {
|
|
14537
|
-
raw = await
|
|
14862
|
+
raw = await readFile11(path, "utf8");
|
|
14538
14863
|
} catch (error) {
|
|
14539
|
-
if (
|
|
14864
|
+
if (isMissingFile6(error)) {
|
|
14540
14865
|
return makeCheck("recovery", "pass", "Belum ada recovery journal.");
|
|
14541
14866
|
}
|
|
14542
14867
|
return makeCheck("recovery", "warn", "Recovery journal tidak bisa dibaca.");
|
|
@@ -14567,7 +14892,7 @@ async function checkLock(bundleDir) {
|
|
|
14567
14892
|
try {
|
|
14568
14893
|
info = await stat6(target);
|
|
14569
14894
|
} catch (error) {
|
|
14570
|
-
if (
|
|
14895
|
+
if (isMissingFile6(error)) {
|
|
14571
14896
|
return makeCheck("lock", "pass", "Tidak ada lock; sidecar bebas ditulis.");
|
|
14572
14897
|
}
|
|
14573
14898
|
return makeCheck("lock", "warn", `Tidak bisa memeriksa lock: ${errorMessage(error)}.`);
|
|
@@ -14591,9 +14916,9 @@ async function checkLock(bundleDir) {
|
|
|
14591
14916
|
async function checkAgents(bundleDir) {
|
|
14592
14917
|
let content;
|
|
14593
14918
|
try {
|
|
14594
|
-
content = await
|
|
14919
|
+
content = await readFile11(join12(bundleDir, "AGENTS.md"), "utf8");
|
|
14595
14920
|
} catch (error) {
|
|
14596
|
-
if (
|
|
14921
|
+
if (isMissingFile6(error)) {
|
|
14597
14922
|
return makeCheck(
|
|
14598
14923
|
"agents",
|
|
14599
14924
|
"fail",
|
|
@@ -14621,7 +14946,7 @@ async function checkAgents(bundleDir) {
|
|
|
14621
14946
|
async function checkExecutionSkill(bundleDir) {
|
|
14622
14947
|
const missing = [];
|
|
14623
14948
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14624
|
-
const target =
|
|
14949
|
+
const target = join12(bundleDir, dir, EXECUTION_SKILL_NAME, "SKILL.md");
|
|
14625
14950
|
if (!await isFile2(target)) missing.push(dir);
|
|
14626
14951
|
}
|
|
14627
14952
|
if (missing.length > 0) {
|
|
@@ -14669,8 +14994,8 @@ async function checkSkillPacks(bundleDir) {
|
|
|
14669
14994
|
for (const skill of pack.skills) {
|
|
14670
14995
|
let matched = false;
|
|
14671
14996
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14672
|
-
const target =
|
|
14673
|
-
if (!await isFile2(
|
|
14997
|
+
const target = join12(bundleDir, dir, skill.name);
|
|
14998
|
+
if (!await isFile2(join12(target, "SKILL.md"))) continue;
|
|
14674
14999
|
try {
|
|
14675
15000
|
if (await hashSkillDirectory(target) === skill.sha256) {
|
|
14676
15001
|
matched = true;
|
|
@@ -14717,7 +15042,7 @@ function capabilityModelNotRequired(content) {
|
|
|
14717
15042
|
return notRequired;
|
|
14718
15043
|
}
|
|
14719
15044
|
async function collectMarkdownFiles2(root, prefix = "") {
|
|
14720
|
-
const dir =
|
|
15045
|
+
const dir = join12(root, prefix);
|
|
14721
15046
|
let entries;
|
|
14722
15047
|
try {
|
|
14723
15048
|
entries = await readdir7(dir, { withFileTypes: true });
|
|
@@ -14737,7 +15062,7 @@ async function checkCapabilityCoverage(bundleDir) {
|
|
|
14737
15062
|
const taskCaps = /* @__PURE__ */ new Map();
|
|
14738
15063
|
for (const relative3 of await collectMarkdownFiles2(contract, "tasks")) {
|
|
14739
15064
|
if (relative3 === BUNDLE_PATHS.TASKS_INDEX) continue;
|
|
14740
|
-
const content = await
|
|
15065
|
+
const content = await readFile11(join12(contract, relative3), "utf8");
|
|
14741
15066
|
const cap = TASK_CAP_RE.exec(content)?.[1]?.toUpperCase();
|
|
14742
15067
|
if (cap === void 0) continue;
|
|
14743
15068
|
taskCaps.set(cap, relative3);
|
|
@@ -14745,7 +15070,7 @@ async function checkCapabilityCoverage(bundleDir) {
|
|
|
14745
15070
|
const specCaps = /* @__PURE__ */ new Set();
|
|
14746
15071
|
const notRequiredCaps = /* @__PURE__ */ new Set();
|
|
14747
15072
|
for (const relative3 of await collectMarkdownFiles2(contract, "specs")) {
|
|
14748
|
-
const content = await
|
|
15073
|
+
const content = await readFile11(join12(contract, relative3), "utf8");
|
|
14749
15074
|
for (const match of content.matchAll(CAP_ID_RE)) {
|
|
14750
15075
|
const id = match[0].toUpperCase();
|
|
14751
15076
|
if (CAP_PLACEHOLDER_RE.test(id)) continue;
|
|
@@ -14796,7 +15121,7 @@ async function checkDuplicates(bundleDir) {
|
|
|
14796
15121
|
}
|
|
14797
15122
|
const dirsByName = /* @__PURE__ */ new Map();
|
|
14798
15123
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14799
|
-
const root =
|
|
15124
|
+
const root = join12(bundleDir, dir);
|
|
14800
15125
|
if (!await isDirectory2(root)) continue;
|
|
14801
15126
|
let entries;
|
|
14802
15127
|
try {
|
|
@@ -14807,7 +15132,7 @@ async function checkDuplicates(bundleDir) {
|
|
|
14807
15132
|
for (const entry of entries) {
|
|
14808
15133
|
if (!entry.isDirectory()) continue;
|
|
14809
15134
|
if (managed.has(entry.name)) continue;
|
|
14810
|
-
if (!await isFile2(
|
|
15135
|
+
if (!await isFile2(join12(root, entry.name, "SKILL.md"))) continue;
|
|
14811
15136
|
const owners = dirsByName.get(entry.name) ?? [];
|
|
14812
15137
|
owners.push(dir);
|
|
14813
15138
|
dirsByName.set(entry.name, owners);
|
|
@@ -14827,7 +15152,7 @@ async function checkDuplicates(bundleDir) {
|
|
|
14827
15152
|
async function checkHarness(bundleDir) {
|
|
14828
15153
|
const detected = [];
|
|
14829
15154
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14830
|
-
if (await isDirectory2(
|
|
15155
|
+
if (await isDirectory2(join12(bundleDir, dir))) detected.push(dir);
|
|
14831
15156
|
}
|
|
14832
15157
|
if (detected.length === 0) {
|
|
14833
15158
|
return makeCheck("harness", "pass", "Tidak ada direktori harness terdeteksi.");
|
|
@@ -14866,6 +15191,7 @@ async function runChecks(options, deps) {
|
|
|
14866
15191
|
checks.push(await checkProject(deps, credentials, effectiveProjectId));
|
|
14867
15192
|
checks.push(await checkBundle(options.bundleDir));
|
|
14868
15193
|
checks.push(await checkSidecar(options.bundleDir));
|
|
15194
|
+
checks.push(await checkStaleAdoption(options.bundleDir));
|
|
14869
15195
|
checks.push(await checkDrift(options.bundleDir));
|
|
14870
15196
|
checks.push(await checkLock(options.bundleDir));
|
|
14871
15197
|
checks.push(await checkRecovery(options.bundleDir));
|
|
@@ -14881,7 +15207,7 @@ async function applyFixes(options, deps, checks) {
|
|
|
14881
15207
|
let changed = false;
|
|
14882
15208
|
if (checks.some((check) => check.id === "lock" && check.fixable === true)) {
|
|
14883
15209
|
try {
|
|
14884
|
-
await
|
|
15210
|
+
await rm8(lockPath(options.bundleDir), { force: true });
|
|
14885
15211
|
changed = true;
|
|
14886
15212
|
} catch {
|
|
14887
15213
|
}
|
|
@@ -14896,6 +15222,44 @@ async function applyFixes(options, deps, checks) {
|
|
|
14896
15222
|
} catch {
|
|
14897
15223
|
}
|
|
14898
15224
|
}
|
|
15225
|
+
if (checks.some((check) => check.id === "stale-adoption" && check.fixable === true)) {
|
|
15226
|
+
try {
|
|
15227
|
+
let sidecarRepaired = false;
|
|
15228
|
+
await withStateLock(options.bundleDir, async () => {
|
|
15229
|
+
const state = await readState(options.bundleDir);
|
|
15230
|
+
if (state === null) return;
|
|
15231
|
+
const strictJournal = await readRecoveryStrict(options.bundleDir);
|
|
15232
|
+
if (strictJournal === null) return;
|
|
15233
|
+
const journal = strictJournal;
|
|
15234
|
+
let working = state;
|
|
15235
|
+
let localChanged = false;
|
|
15236
|
+
for (const task of state.tasks) {
|
|
15237
|
+
const checkpointPending = state.current?.ref === task.ref && state.current.awaitingCheckpoint === true;
|
|
15238
|
+
if (!isStaleAdoption(task)) continue;
|
|
15239
|
+
if (checkpointPending) continue;
|
|
15240
|
+
if (isExhausted(journal, task.ref)) continue;
|
|
15241
|
+
const next = supersedeStaleAdoption(working, task.ref, /* @__PURE__ */ new Date());
|
|
15242
|
+
if (next !== working) {
|
|
15243
|
+
working = next;
|
|
15244
|
+
localChanged = true;
|
|
15245
|
+
}
|
|
15246
|
+
}
|
|
15247
|
+
if (localChanged) {
|
|
15248
|
+
await writeState(options.bundleDir, working);
|
|
15249
|
+
changed = true;
|
|
15250
|
+
sidecarRepaired = true;
|
|
15251
|
+
}
|
|
15252
|
+
});
|
|
15253
|
+
if (sidecarRepaired) {
|
|
15254
|
+
try {
|
|
15255
|
+
await deps.publishSidecar?.(options.bundleDir);
|
|
15256
|
+
} catch {
|
|
15257
|
+
console.warn("Status tersimpan lokal; jalankan `jioogen sync`");
|
|
15258
|
+
}
|
|
15259
|
+
}
|
|
15260
|
+
} catch {
|
|
15261
|
+
}
|
|
15262
|
+
}
|
|
14899
15263
|
return changed;
|
|
14900
15264
|
}
|
|
14901
15265
|
async function runDoctor(options) {
|
|
@@ -14922,150 +15286,6 @@ function formatTable(headers, rows) {
|
|
|
14922
15286
|
return [render(headers), divider, ...rows.map(render)].join("\n");
|
|
14923
15287
|
}
|
|
14924
15288
|
|
|
14925
|
-
// src/recovery.ts
|
|
14926
|
-
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
14927
|
-
import { mkdir as mkdir8, readFile as readFile11, rename as rename3, rm as rm8, writeFile as writeFile8 } from "node:fs/promises";
|
|
14928
|
-
import { dirname as dirname7, join as join12 } from "node:path";
|
|
14929
|
-
var RECOVERY_PATH = "tasks/.execution/recovery.json";
|
|
14930
|
-
var RECOVERY_BUDGET = { maxAttempts: 3 };
|
|
14931
|
-
var RECOVERY_BASE_ATTEMPTS = 3;
|
|
14932
|
-
var RECOVERY_MAX_ATTEMPTS = 6;
|
|
14933
|
-
function recoveryBudget(input) {
|
|
14934
|
-
let budget = RECOVERY_BASE_ATTEMPTS;
|
|
14935
|
-
if (input.failureClass === "transient") budget += 1;
|
|
14936
|
-
if (input.failureClass === "semantic") budget += 1;
|
|
14937
|
-
return Math.min(budget, RECOVERY_MAX_ATTEMPTS);
|
|
14938
|
-
}
|
|
14939
|
-
function recoveryPath(bundleDir) {
|
|
14940
|
-
return join12(bundleDir, RECOVERY_PATH);
|
|
14941
|
-
}
|
|
14942
|
-
function emptyJournal() {
|
|
14943
|
-
return { schemaVersion: 1, tasks: {} };
|
|
14944
|
-
}
|
|
14945
|
-
function isJournal(value) {
|
|
14946
|
-
if (typeof value !== "object" || value === null) return false;
|
|
14947
|
-
const obj = value;
|
|
14948
|
-
if (obj.schemaVersion !== 1) return false;
|
|
14949
|
-
if (typeof obj.tasks !== "object" || obj.tasks === null) return false;
|
|
14950
|
-
return true;
|
|
14951
|
-
}
|
|
14952
|
-
async function readRecovery(bundleDir) {
|
|
14953
|
-
let raw;
|
|
14954
|
-
try {
|
|
14955
|
-
raw = await readFile11(recoveryPath(bundleDir), "utf8");
|
|
14956
|
-
} catch {
|
|
14957
|
-
return emptyJournal();
|
|
14958
|
-
}
|
|
14959
|
-
let payload;
|
|
14960
|
-
try {
|
|
14961
|
-
payload = JSON.parse(raw);
|
|
14962
|
-
} catch {
|
|
14963
|
-
return emptyJournal();
|
|
14964
|
-
}
|
|
14965
|
-
if (!isJournal(payload)) return emptyJournal();
|
|
14966
|
-
return payload;
|
|
14967
|
-
}
|
|
14968
|
-
function classifyFailure(input) {
|
|
14969
|
-
if (input.stalled === true || input.timedOut === true) return "transient";
|
|
14970
|
-
if (input.verificationFailed === true) return "semantic";
|
|
14971
|
-
const note = input.note ?? "";
|
|
14972
|
-
if (/^AUTHORIZATION:/i.test(note.trim())) return "authorization";
|
|
14973
|
-
if (/timeout|stall|econn|rate limit|\b429\b|\b5\d\d\b/i.test(note)) return "transient";
|
|
14974
|
-
const prior = input.prior ?? null;
|
|
14975
|
-
if (prior !== null && prior.attempts >= 1 && note === prior.lastNote) return "no_progress";
|
|
14976
|
-
return "semantic";
|
|
14977
|
-
}
|
|
14978
|
-
async function writeRecovery(bundleDir, journal) {
|
|
14979
|
-
const target = recoveryPath(bundleDir);
|
|
14980
|
-
await mkdir8(dirname7(target), { recursive: true });
|
|
14981
|
-
const temp = `${target}.${process.pid}.${randomUUID2()}.tmp`;
|
|
14982
|
-
try {
|
|
14983
|
-
await writeFile8(temp, `${JSON.stringify(journal, null, 2)}
|
|
14984
|
-
`, "utf8");
|
|
14985
|
-
await rename3(temp, target);
|
|
14986
|
-
} catch (error) {
|
|
14987
|
-
await rm8(temp, { force: true }).catch(() => {
|
|
14988
|
-
});
|
|
14989
|
-
throw error;
|
|
14990
|
-
}
|
|
14991
|
-
}
|
|
14992
|
-
async function recordFailure(bundleDir, ref, args) {
|
|
14993
|
-
return withStateLock(bundleDir, async () => {
|
|
14994
|
-
const journal = await readRecovery(bundleDir);
|
|
14995
|
-
const prior = journal.tasks[ref] ?? null;
|
|
14996
|
-
const klass = classifyFailure({ ...args, prior });
|
|
14997
|
-
const attempt = (prior?.attempts ?? 0) + 1;
|
|
14998
|
-
const budget = recoveryBudget({
|
|
14999
|
-
failureClass: klass,
|
|
15000
|
-
priorAttempts: prior?.attempts ?? 0,
|
|
15001
|
-
priorClass: prior?.lastClass ?? null
|
|
15002
|
-
});
|
|
15003
|
-
const exhausted = attempt >= budget;
|
|
15004
|
-
const resumable = exhausted;
|
|
15005
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
15006
|
-
const note = args.note ?? "";
|
|
15007
|
-
const history = [...prior?.history ?? []];
|
|
15008
|
-
history.push({ attempt, class: klass, note, at: now });
|
|
15009
|
-
const capped = history.length > 20 ? history.slice(history.length - 20) : history;
|
|
15010
|
-
const entry = {
|
|
15011
|
-
ref,
|
|
15012
|
-
attempts: attempt,
|
|
15013
|
-
exhausted,
|
|
15014
|
-
resumable,
|
|
15015
|
-
lastClass: klass,
|
|
15016
|
-
lastNote: note === "" ? prior?.lastNote ?? "" : note,
|
|
15017
|
-
history: capped,
|
|
15018
|
-
updatedAt: now
|
|
15019
|
-
};
|
|
15020
|
-
journal.tasks[ref] = entry;
|
|
15021
|
-
await writeRecovery(bundleDir, journal);
|
|
15022
|
-
return { entry, exhausted, class: klass, attempt };
|
|
15023
|
-
});
|
|
15024
|
-
}
|
|
15025
|
-
async function recordSuccess(bundleDir, ref) {
|
|
15026
|
-
await withStateLock(bundleDir, async () => {
|
|
15027
|
-
const journal = await readRecovery(bundleDir);
|
|
15028
|
-
if (journal.tasks[ref] !== void 0) {
|
|
15029
|
-
delete journal.tasks[ref];
|
|
15030
|
-
await writeRecovery(bundleDir, journal);
|
|
15031
|
-
}
|
|
15032
|
-
});
|
|
15033
|
-
}
|
|
15034
|
-
async function rearmTask(bundleDir, ref) {
|
|
15035
|
-
await withStateLock(bundleDir, async () => {
|
|
15036
|
-
const journal = await readRecovery(bundleDir);
|
|
15037
|
-
const prior = journal.tasks[ref];
|
|
15038
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
15039
|
-
const entry = {
|
|
15040
|
-
ref,
|
|
15041
|
-
attempts: 0,
|
|
15042
|
-
exhausted: false,
|
|
15043
|
-
resumable: true,
|
|
15044
|
-
lastClass: prior?.lastClass ?? null,
|
|
15045
|
-
lastNote: prior?.lastNote ?? "",
|
|
15046
|
-
history: prior?.history ?? [],
|
|
15047
|
-
updatedAt: now
|
|
15048
|
-
};
|
|
15049
|
-
journal.tasks[ref] = entry;
|
|
15050
|
-
await writeRecovery(bundleDir, journal);
|
|
15051
|
-
});
|
|
15052
|
-
}
|
|
15053
|
-
function isExhausted(journal, ref) {
|
|
15054
|
-
return journal.tasks[ref]?.exhausted === true;
|
|
15055
|
-
}
|
|
15056
|
-
function describeRecovery(entry) {
|
|
15057
|
-
if (entry === void 0) {
|
|
15058
|
-
return "No recovery record. Run `jioogen resume`, then retry with a different approach.";
|
|
15059
|
-
}
|
|
15060
|
-
const lines = [];
|
|
15061
|
-
lines.push(
|
|
15062
|
-
`Task ${entry.ref}: ${entry.attempts}/${RECOVERY_BUDGET.maxAttempts} attempts, last=${entry.lastClass ?? "none"}.`
|
|
15063
|
-
);
|
|
15064
|
-
if (entry.lastNote.length > 0) lines.push(`Last note: ${entry.lastNote}`);
|
|
15065
|
-
lines.push("Run `jioogen resume`, then retry with a different approach.");
|
|
15066
|
-
return lines.join("\n");
|
|
15067
|
-
}
|
|
15068
|
-
|
|
15069
15289
|
// src/session.ts
|
|
15070
15290
|
import { rm as rm9, stat as stat7 } from "node:fs/promises";
|
|
15071
15291
|
import { resolve as resolve4 } from "node:path";
|
|
@@ -15222,7 +15442,7 @@ async function removeStaleLock2(bundleDir) {
|
|
|
15222
15442
|
try {
|
|
15223
15443
|
info = await stat7(target);
|
|
15224
15444
|
} catch (error) {
|
|
15225
|
-
if (
|
|
15445
|
+
if (isMissingFile7(error)) return;
|
|
15226
15446
|
throw error;
|
|
15227
15447
|
}
|
|
15228
15448
|
if (Date.now() - info.mtimeMs <= LOCK_STALE_MS3) return;
|
|
@@ -15234,7 +15454,7 @@ function envFirst(primary, legacy) {
|
|
|
15234
15454
|
const fallback = process.env[legacy]?.trim();
|
|
15235
15455
|
return fallback !== void 0 && fallback.length > 0 ? fallback : void 0;
|
|
15236
15456
|
}
|
|
15237
|
-
function
|
|
15457
|
+
function isMissingFile7(error) {
|
|
15238
15458
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
15239
15459
|
}
|
|
15240
15460
|
|
|
@@ -15902,7 +16122,18 @@ async function doctorCommand(options) {
|
|
|
15902
16122
|
const report = await runDoctor({
|
|
15903
16123
|
bundleDir,
|
|
15904
16124
|
...projectId === void 0 ? {} : { projectId },
|
|
15905
|
-
fix: options.fix === true
|
|
16125
|
+
fix: options.fix === true,
|
|
16126
|
+
deps: {
|
|
16127
|
+
publishSidecar: async (bd) => {
|
|
16128
|
+
const pid = projectId ?? link?.projectId;
|
|
16129
|
+
if (pid === void 0) return;
|
|
16130
|
+
await pushSidecarBestEffort(options, {
|
|
16131
|
+
projectId: pid,
|
|
16132
|
+
bundleDir: bd,
|
|
16133
|
+
linkedApiUrl: link?.apiUrl
|
|
16134
|
+
});
|
|
16135
|
+
}
|
|
16136
|
+
}
|
|
15906
16137
|
});
|
|
15907
16138
|
if (options.json === true) {
|
|
15908
16139
|
console.log(JSON.stringify(report, null, 2));
|
|
@@ -16366,7 +16597,7 @@ async function taskCompleteCommand(ref, options) {
|
|
|
16366
16597
|
console.log(`Done ${completedTask?.ref ?? ref}.`);
|
|
16367
16598
|
if (checkpoint) {
|
|
16368
16599
|
if (next === null) {
|
|
16369
|
-
console.log(
|
|
16600
|
+
console.log(printCompletionHeadline(completion));
|
|
16370
16601
|
printSeedGapTrigger(completion, next);
|
|
16371
16602
|
} else {
|
|
16372
16603
|
console.log(
|
|
@@ -16603,7 +16834,7 @@ async function taskAdoptCommand(ref, options) {
|
|
|
16603
16834
|
);
|
|
16604
16835
|
if (result.checkpoint) {
|
|
16605
16836
|
console.log(
|
|
16606
|
-
result.next === null ?
|
|
16837
|
+
result.next === null ? printCompletionHeadline(result.completion) : `Checkpoint berikutnya: ${result.next.task.id} (${result.next.task.layer ?? "-"} / phase ${result.next.task.phase}).`
|
|
16607
16838
|
);
|
|
16608
16839
|
printSeedGapTrigger(result.completion, result.next);
|
|
16609
16840
|
console.log(
|
|
@@ -17232,7 +17463,7 @@ async function assertPullTarget(target, projectId, force = false) {
|
|
|
17232
17463
|
try {
|
|
17233
17464
|
entries = await readdir8(target);
|
|
17234
17465
|
} catch (error) {
|
|
17235
|
-
if (
|
|
17466
|
+
if (isMissingFile8(error)) return;
|
|
17236
17467
|
throw error;
|
|
17237
17468
|
}
|
|
17238
17469
|
if (entries.length === 0) return;
|
|
@@ -17267,7 +17498,7 @@ async function hasBundleMarkers(target) {
|
|
|
17267
17498
|
await readFile12(join13(contractRoot(target), "PRD.md"));
|
|
17268
17499
|
return true;
|
|
17269
17500
|
} catch (error) {
|
|
17270
|
-
if (!
|
|
17501
|
+
if (!isMissingFile8(error)) throw error;
|
|
17271
17502
|
}
|
|
17272
17503
|
return hasTaskMarkdown(join13(contractRoot(target), "tasks"));
|
|
17273
17504
|
}
|
|
@@ -17276,7 +17507,7 @@ async function hasTaskMarkdown(directory) {
|
|
|
17276
17507
|
try {
|
|
17277
17508
|
names = await readdir8(directory);
|
|
17278
17509
|
} catch (error) {
|
|
17279
|
-
if (
|
|
17510
|
+
if (isMissingFile8(error)) return false;
|
|
17280
17511
|
throw error;
|
|
17281
17512
|
}
|
|
17282
17513
|
return names.some((name) => name.toLowerCase().endsWith(".md"));
|
|
@@ -17329,10 +17560,30 @@ function printCompletionGaps(completion) {
|
|
|
17329
17560
|
const entries = Object.entries(completion.features).filter(([, unit]) => unit.status !== "complete").sort(([left], [right]) => left.localeCompare(right));
|
|
17330
17561
|
if (entries.length === 0) lines.push("- (tidak ada unit feature yang dideklarasikan)");
|
|
17331
17562
|
for (const [id, unit] of entries) {
|
|
17332
|
-
lines.push(`- ${id}: ${unit.status} (${unit.doneTasks}/${unit.totalTasks} task
|
|
17563
|
+
lines.push(`- ${id}: ${unit.status} (${unit.doneTasks}/${unit.totalTasks} task terverifikasi)`);
|
|
17564
|
+
}
|
|
17565
|
+
if (completion.adoptedTaskRefs.length > 0) {
|
|
17566
|
+
const shown = completion.adoptedTaskRefs.slice(0, 8).join(", ");
|
|
17567
|
+
const extra = completion.adoptedTaskRefs.length > 8 ? ` +${completion.adoptedTaskRefs.length - 8} lagi` : "";
|
|
17568
|
+
lines.push(
|
|
17569
|
+
`- Diadopsi di luar harness (bookkeeping, tidak dihitung complete): ${shown}${extra}`
|
|
17570
|
+
);
|
|
17333
17571
|
}
|
|
17334
17572
|
return lines.join("\n");
|
|
17335
17573
|
}
|
|
17574
|
+
function printCompletionHeadline(completion) {
|
|
17575
|
+
if (completion.projectComplete) {
|
|
17576
|
+
return "Project complete: seluruh unit fitur & layer integration terverifikasi.";
|
|
17577
|
+
}
|
|
17578
|
+
const unverified = completion.tasksDone - completion.tasksVerified;
|
|
17579
|
+
const parts = [];
|
|
17580
|
+
if (completion.adoptedTaskRefs.length > 0) {
|
|
17581
|
+
parts.push(`${completion.adoptedTaskRefs.length} task diadopsi di luar harness`);
|
|
17582
|
+
}
|
|
17583
|
+
if (unverified > 0) parts.push(`${unverified} done belum terverifikasi`);
|
|
17584
|
+
const detail = parts.length > 0 ? ` \u2014 ${parts.join(", ")}` : "";
|
|
17585
|
+
return `Semua task dieksekusi, tetapi project BELUM complete${detail}.`;
|
|
17586
|
+
}
|
|
17336
17587
|
function printSeedReBreakdown() {
|
|
17337
17588
|
console.log("");
|
|
17338
17589
|
console.log("Gap di atas tidak ditutup oleh DAG task yang ada \u2014 ini bukan 'selesai',");
|
|
@@ -17390,7 +17641,7 @@ function envFirst2(primary, legacy) {
|
|
|
17390
17641
|
const fallback = process.env[legacy]?.trim();
|
|
17391
17642
|
return fallback !== void 0 && fallback.length > 0 ? fallback : void 0;
|
|
17392
17643
|
}
|
|
17393
|
-
function
|
|
17644
|
+
function isMissingFile8(error) {
|
|
17394
17645
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
17395
17646
|
}
|
|
17396
17647
|
async function authoringInstallCommand(options) {
|
|
@@ -17506,7 +17757,7 @@ async function readLine() {
|
|
|
17506
17757
|
}
|
|
17507
17758
|
|
|
17508
17759
|
// src/index.ts
|
|
17509
|
-
var VERSION = "0.2.
|
|
17760
|
+
var VERSION = "0.2.19";
|
|
17510
17761
|
function parseTaskModeOption(value) {
|
|
17511
17762
|
if (value === void 0) return void 0;
|
|
17512
17763
|
const parsed = TaskModeSchema.safeParse(value);
|