jioogen 0.2.18 → 0.3.0
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 +1 -1
- package/authoring-pack/agent/discovery.md +1 -1
- package/authoring-pack/agent/prd.md +6 -1
- package/authoring-pack/agent/specs.md +1 -1
- package/authoring-pack/agent/tasks.md +1 -1
- package/authoring-pack/knowledge/catalog.generated.json +4 -1
- package/authoring-pack/knowledge/library/prd/prd-standard.md +7 -0
- package/authoring-pack/knowledge/library/prd/self-check.md +6 -0
- package/authoring-pack/manifest.json +10 -10
- package/authoring-pack/skills/prd-authoring/SKILL.md +1 -1
- package/dist/index.js +835 -382
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9774,7 +9774,7 @@ Urutan otoritas: keamanan/a11y inti > PRD/specs > file di sini > default generik
|
|
|
9774
9774
|
var EXECUTION_SIDECAR_PATH = "tasks/.execution/state.json";
|
|
9775
9775
|
var EXECUTION_SIDECAR_VERSION = 1;
|
|
9776
9776
|
var EXECUTION_SIDECAR_VERSION_V2 = 2;
|
|
9777
|
-
var HANDOFF_PROMPT_VERSION =
|
|
9777
|
+
var HANDOFF_PROMPT_VERSION = 29;
|
|
9778
9778
|
var HANDOFF_AGENT_TOKEN_TTL_SECONDS = 30 * 24 * 3600;
|
|
9779
9779
|
var HandoffPayloadSchema = external_exports.object({
|
|
9780
9780
|
promptVersion: external_exports.literal(HANDOFF_PROMPT_VERSION),
|
|
@@ -9898,11 +9898,58 @@ 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
|
+
}
|
|
9901
9927
|
function isAdoptedTask(task) {
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
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"
|
|
9905
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;
|
|
9906
9953
|
}
|
|
9907
9954
|
function computeCompletion(tasks, definitions) {
|
|
9908
9955
|
const defById = new Map(
|
|
@@ -10136,12 +10183,12 @@ var ApiClient = class {
|
|
|
10136
10183
|
// src/commands.ts
|
|
10137
10184
|
import { spawn as spawn2 } from "node:child_process";
|
|
10138
10185
|
import { existsSync as existsSync3 } from "node:fs";
|
|
10139
|
-
import { mkdir as
|
|
10186
|
+
import { mkdir as mkdir11, readdir as readdir8, readFile as readFile12, stat as stat8, writeFile as writeFile11 } from "node:fs/promises";
|
|
10140
10187
|
import { join as join13, resolve as resolve6 } from "node:path";
|
|
10141
10188
|
|
|
10142
10189
|
// src/align.ts
|
|
10143
10190
|
import { spawn } from "node:child_process";
|
|
10144
|
-
import { mkdir as
|
|
10191
|
+
import { mkdir as mkdir6, readFile as readFile7, rm as rm4, stat as stat4, writeFile as writeFile6 } from "node:fs/promises";
|
|
10145
10192
|
import { join as join8 } from "node:path";
|
|
10146
10193
|
|
|
10147
10194
|
// src/authoring.ts
|
|
@@ -11062,13 +11109,13 @@ async function appendApprovalNote(bundleDir, input) {
|
|
|
11062
11109
|
|
|
11063
11110
|
// src/drift.ts
|
|
11064
11111
|
import { createHash as createHash2 } from "node:crypto";
|
|
11065
|
-
import { mkdir as
|
|
11066
|
-
import { dirname as
|
|
11112
|
+
import { mkdir as mkdir5, readdir as readdir5, readFile as readFile6, rm as rm3, stat as stat3, writeFile as writeFile5 } from "node:fs/promises";
|
|
11113
|
+
import { dirname as dirname5, isAbsolute as isAbsolute2, join as join7 } from "node:path";
|
|
11067
11114
|
|
|
11068
11115
|
// src/tasks.ts
|
|
11069
11116
|
import { readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
11070
|
-
import { readdir as readdir4, readFile as readFile5, stat as stat2 } from "node:fs/promises";
|
|
11071
|
-
import { isAbsolute, join as join6 } from "node:path";
|
|
11117
|
+
import { mkdir as mkdir4, readdir as readdir4, readFile as readFile5, stat as stat2, writeFile as writeFile4 } from "node:fs/promises";
|
|
11118
|
+
import { dirname as dirname4, isAbsolute, join as join6 } from "node:path";
|
|
11072
11119
|
|
|
11073
11120
|
// src/sidecar.ts
|
|
11074
11121
|
import { randomUUID } from "node:crypto";
|
|
@@ -11250,6 +11297,34 @@ function appendTaskEvidence(state, ref, evidence) {
|
|
|
11250
11297
|
const tasks = state.tasks.map((entry, i) => i === index ? task : entry);
|
|
11251
11298
|
return rebuild(state, tasks, state.current);
|
|
11252
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
|
+
}
|
|
11253
11328
|
function setTaskSource(state, ref, source) {
|
|
11254
11329
|
const index = state.tasks.findIndex((task2) => task2.ref.toUpperCase() === ref.toUpperCase());
|
|
11255
11330
|
if (index === -1) return state;
|
|
@@ -11535,11 +11610,22 @@ function renderActiveTask(task, context) {
|
|
|
11535
11610
|
);
|
|
11536
11611
|
const checklist = renderQualityChecklist(task.layer, context);
|
|
11537
11612
|
if (checklist.length > 0) lines.push("", ...checklist);
|
|
11538
|
-
const
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11613
|
+
const persistedChecklist = context?.bundleDir !== void 0 ? readBreakdownChecklistLines(context.bundleDir, task.id) : [];
|
|
11614
|
+
if (persistedChecklist.length > 0) {
|
|
11615
|
+
lines.push(
|
|
11616
|
+
"",
|
|
11617
|
+
BREAKDOWN_HEADING,
|
|
11618
|
+
...BREAKDOWN_RULES,
|
|
11619
|
+
`Checklist tersimpan: .jioogen/breakdown/${task.id}.md`,
|
|
11620
|
+
...persistedChecklist
|
|
11621
|
+
);
|
|
11622
|
+
} else {
|
|
11623
|
+
const breakdown = buildTaskBreakdown(task);
|
|
11624
|
+
const breakdownLines = [...breakdown.authored, ...breakdown.derived];
|
|
11625
|
+
if (breakdownLines.length > 0) {
|
|
11626
|
+
lines.push("", BREAKDOWN_HEADING, ...BREAKDOWN_RULES);
|
|
11627
|
+
for (const item of breakdownLines) lines.push(`- [ ] ${item}`);
|
|
11628
|
+
}
|
|
11543
11629
|
}
|
|
11544
11630
|
lines.push("", "--- ISI TASK (otoritas scope) ---", task.content, "--- AKHIR ISI TASK ---");
|
|
11545
11631
|
if (context?.bundleDir !== void 0) {
|
|
@@ -11596,6 +11682,93 @@ function buildTaskBreakdown(task) {
|
|
|
11596
11682
|
}
|
|
11597
11683
|
return { authored, derived };
|
|
11598
11684
|
}
|
|
11685
|
+
var BREAKDOWN_DIR = ".jioogen/breakdown";
|
|
11686
|
+
var BREAKDOWN_CHECKBOX_RE = /^\s*-\s*\[( |x|X)\]\s*(.*)$/;
|
|
11687
|
+
var BREAKDOWN_ID_RE = /^([A-Z]+-\d+)\s*[—:-]?\s*(.*)$/;
|
|
11688
|
+
function breakdownPath(bundleDir, ref) {
|
|
11689
|
+
return join6(bundleDir, BREAKDOWN_DIR, `${ref}.md`);
|
|
11690
|
+
}
|
|
11691
|
+
function breakdownItems(task) {
|
|
11692
|
+
const breakdown = buildTaskBreakdown(task);
|
|
11693
|
+
const items = [];
|
|
11694
|
+
const seen = /* @__PURE__ */ new Set();
|
|
11695
|
+
const push = (prefix, index, text2) => {
|
|
11696
|
+
const key = text2.trim().toLowerCase();
|
|
11697
|
+
if (key.length === 0 || seen.has(key)) return;
|
|
11698
|
+
seen.add(key);
|
|
11699
|
+
items.push({ id: `${prefix}-${String(index + 1).padStart(2, "0")}`, text: text2.trim() });
|
|
11700
|
+
};
|
|
11701
|
+
breakdown.authored.forEach((text2, index) => {
|
|
11702
|
+
push("SUB", index, text2);
|
|
11703
|
+
});
|
|
11704
|
+
breakdown.derived.forEach((text2, index) => {
|
|
11705
|
+
push("BD", index, text2);
|
|
11706
|
+
});
|
|
11707
|
+
return items;
|
|
11708
|
+
}
|
|
11709
|
+
function renderBreakdownScaffold(task) {
|
|
11710
|
+
const items = breakdownItems(task);
|
|
11711
|
+
const section3 = items.map((item) => `- [ ] ${item.id} \u2014 ${item.text}`).join("\n");
|
|
11712
|
+
return `${[
|
|
11713
|
+
`# Breakdown ${task.id} \u2014 ${task.title}`,
|
|
11714
|
+
"",
|
|
11715
|
+
"## Breakdown",
|
|
11716
|
+
"",
|
|
11717
|
+
section3,
|
|
11718
|
+
"",
|
|
11719
|
+
"> Checklist ini mengikat. Kerjakan dan centang setiap item; `task complete` menolak selama masih ada `- [ ]`.",
|
|
11720
|
+
"> File ini milik eksekusi (`.jioogen/`), bukan kontrak. Jangan menyalinnya ke `tasks/`."
|
|
11721
|
+
].join("\n")}
|
|
11722
|
+
`;
|
|
11723
|
+
}
|
|
11724
|
+
async function writeBreakdownScaffold(bundleDir, task) {
|
|
11725
|
+
const path = breakdownPath(bundleDir, task.id);
|
|
11726
|
+
await mkdir4(dirname4(path), { recursive: true });
|
|
11727
|
+
await writeFile4(path, renderBreakdownScaffold(task), "utf8");
|
|
11728
|
+
return path;
|
|
11729
|
+
}
|
|
11730
|
+
async function ensureBreakdownScaffold(bundleDir, task) {
|
|
11731
|
+
const path = breakdownPath(bundleDir, task.id);
|
|
11732
|
+
try {
|
|
11733
|
+
const content = await readFile5(path, "utf8");
|
|
11734
|
+
if (content.trim().length > 0) return path;
|
|
11735
|
+
} catch {
|
|
11736
|
+
}
|
|
11737
|
+
return writeBreakdownScaffold(bundleDir, task);
|
|
11738
|
+
}
|
|
11739
|
+
async function readBreakdownChecklist(bundleDir, ref) {
|
|
11740
|
+
const path = breakdownPath(bundleDir, ref);
|
|
11741
|
+
let content;
|
|
11742
|
+
try {
|
|
11743
|
+
content = await readFile5(path, "utf8");
|
|
11744
|
+
} catch {
|
|
11745
|
+
return null;
|
|
11746
|
+
}
|
|
11747
|
+
let total = 0;
|
|
11748
|
+
const unchecked = [];
|
|
11749
|
+
for (const line of content.split(/\r?\n/)) {
|
|
11750
|
+
const match = BREAKDOWN_CHECKBOX_RE.exec(line);
|
|
11751
|
+
if (match === null) continue;
|
|
11752
|
+
total += 1;
|
|
11753
|
+
if (match[1] !== " ") continue;
|
|
11754
|
+
const body = (match[2] ?? "").trim();
|
|
11755
|
+
const withId = BREAKDOWN_ID_RE.exec(body);
|
|
11756
|
+
if (withId === null) {
|
|
11757
|
+
unchecked.push({ id: `ITEM-${String(total).padStart(2, "0")}`, text: body });
|
|
11758
|
+
continue;
|
|
11759
|
+
}
|
|
11760
|
+
unchecked.push({ id: withId[1] ?? "", text: (withId[2] ?? "").trim() });
|
|
11761
|
+
}
|
|
11762
|
+
return { path, total, unchecked };
|
|
11763
|
+
}
|
|
11764
|
+
function readBreakdownChecklistLines(bundleDir, ref) {
|
|
11765
|
+
try {
|
|
11766
|
+
const content = readFileSync2(breakdownPath(bundleDir, ref), "utf8");
|
|
11767
|
+
return content.split(/\r?\n/).filter((line) => BREAKDOWN_CHECKBOX_RE.test(line)).map((line) => line.trim());
|
|
11768
|
+
} catch {
|
|
11769
|
+
return [];
|
|
11770
|
+
}
|
|
11771
|
+
}
|
|
11599
11772
|
function renderQualityChecklist(layer, context) {
|
|
11600
11773
|
if (context === void 0 || layer === void 0) return [];
|
|
11601
11774
|
const items = [...LAYER_CHECKLISTS[layer] ?? []];
|
|
@@ -12009,8 +12182,8 @@ async function acknowledgeDrift(bundleDir, flags = {}, note, now = /* @__PURE__
|
|
|
12009
12182
|
const mergedNote = note ?? existing?.note;
|
|
12010
12183
|
if (mergedNote !== void 0) merged.note = mergedNote;
|
|
12011
12184
|
const target = join7(contractRoot(bundleDir), "tasks", ".execution", "acknowledged.json");
|
|
12012
|
-
await
|
|
12013
|
-
await
|
|
12185
|
+
await mkdir5(dirname5(target), { recursive: true });
|
|
12186
|
+
await writeFile5(target, `${JSON.stringify(merged, null, 2)}
|
|
12014
12187
|
`, "utf8");
|
|
12015
12188
|
return merged;
|
|
12016
12189
|
}
|
|
@@ -12052,8 +12225,8 @@ async function readBaseline(bundleDir) {
|
|
|
12052
12225
|
}
|
|
12053
12226
|
async function writeBaseline(bundleDir, baseline) {
|
|
12054
12227
|
const target = baselinePath(bundleDir);
|
|
12055
|
-
await
|
|
12056
|
-
await
|
|
12228
|
+
await mkdir5(dirname5(target), { recursive: true });
|
|
12229
|
+
await writeFile5(target, `${JSON.stringify(baseline, null, 2)}
|
|
12057
12230
|
`, "utf8");
|
|
12058
12231
|
}
|
|
12059
12232
|
async function clearBaseline(bundleDir) {
|
|
@@ -12170,6 +12343,18 @@ function formatDrift(finding) {
|
|
|
12170
12343
|
const files = finding.files.length === 0 ? "" : ` (${finding.files.slice(0, 4).join(", ")}${finding.files.length > 4 ? ", \u2026" : ""})`;
|
|
12171
12344
|
return `${finding.severity === "warn" ? "\u26A0" : "\u2139"} ${label}: ${finding.message}${files}`;
|
|
12172
12345
|
}
|
|
12346
|
+
async function latestTargetMtime(bundleDir, patterns) {
|
|
12347
|
+
let latest = null;
|
|
12348
|
+
for (const pattern of patterns) {
|
|
12349
|
+
const resolved = await expandPattern(bundleDir, pattern);
|
|
12350
|
+
for (const file of resolved) {
|
|
12351
|
+
const info = await statMaybe(join7(bundleDir, file));
|
|
12352
|
+
if (info === null || !info.isFile()) continue;
|
|
12353
|
+
if (latest === null || info.mtimeMs > latest) latest = info.mtimeMs;
|
|
12354
|
+
}
|
|
12355
|
+
}
|
|
12356
|
+
return latest;
|
|
12357
|
+
}
|
|
12173
12358
|
async function targetHashes(bundleDir, patterns) {
|
|
12174
12359
|
const files = /* @__PURE__ */ new Set();
|
|
12175
12360
|
let truncated = false;
|
|
@@ -12584,8 +12769,8 @@ async function pullContract(deps, bundleDir) {
|
|
|
12584
12769
|
}
|
|
12585
12770
|
for (const [path, content] of contents) {
|
|
12586
12771
|
const target = resolveProjectPath(bundleDir, path);
|
|
12587
|
-
await
|
|
12588
|
-
await
|
|
12772
|
+
await mkdir6(join8(target, ".."), { recursive: true });
|
|
12773
|
+
await writeFile6(target, content, "utf8");
|
|
12589
12774
|
}
|
|
12590
12775
|
await clearBaseline(bundleDir).catch(() => {
|
|
12591
12776
|
});
|
|
@@ -12696,9 +12881,9 @@ function runAuthoringAttempt(bin, args, configPath, bundleDir, label, stage, tim
|
|
|
12696
12881
|
async function runLocalAuthoring(stage, bundleDir, issues) {
|
|
12697
12882
|
const configDir2 = join8(bundleDir, ".jioogen", "align");
|
|
12698
12883
|
const configPath = join8(configDir2, "generated.json");
|
|
12699
|
-
await
|
|
12884
|
+
await mkdir6(configDir2, { recursive: true });
|
|
12700
12885
|
const config = await buildAuthoringOpencodeConfig(bundledAuthoringPackDir());
|
|
12701
|
-
await
|
|
12886
|
+
await writeFile6(configPath, `${JSON.stringify(config, null, 2)}
|
|
12702
12887
|
`, "utf8");
|
|
12703
12888
|
const bin = process.env.OPENCODE_BIN?.trim() || "opencode";
|
|
12704
12889
|
const chain = authoringModelChain();
|
|
@@ -12965,10 +13150,146 @@ function formatAlign(result) {
|
|
|
12965
13150
|
return lines.join("\n");
|
|
12966
13151
|
}
|
|
12967
13152
|
|
|
13153
|
+
// src/completion-gate.ts
|
|
13154
|
+
var FRESH_TOLERANCE_MS = 2e3;
|
|
13155
|
+
function parseAt(value) {
|
|
13156
|
+
if (value === void 0) return void 0;
|
|
13157
|
+
const parsed = Date.parse(value);
|
|
13158
|
+
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
13159
|
+
}
|
|
13160
|
+
function latestVerificationAt(task) {
|
|
13161
|
+
const times = (task.evidence ?? []).filter((entry) => entry.type === "verification" && entry.exitCode === 0).map((entry) => parseAt(entry.at)).filter((value) => value !== void 0);
|
|
13162
|
+
if (times.length === 0) return void 0;
|
|
13163
|
+
return Math.max(...times);
|
|
13164
|
+
}
|
|
13165
|
+
async function evaluateCompletionGate(input) {
|
|
13166
|
+
const findings = [];
|
|
13167
|
+
const { definition, stateTask } = input;
|
|
13168
|
+
const targetFiles = targetFilesFromContent(definition.content);
|
|
13169
|
+
const declared = verificationCommandFromContent(definition.content);
|
|
13170
|
+
if (declared === null) {
|
|
13171
|
+
findings.push({
|
|
13172
|
+
code: "VERIFICATION_COMMAND_MISSING",
|
|
13173
|
+
message: "Task tidak punya verificationCommand. Lengkapi kontrak task lebih dulu (align/seed); `task complete` tidak punya jalur legacy."
|
|
13174
|
+
});
|
|
13175
|
+
} else if (stateTask === void 0 || stateTask.verification === void 0) {
|
|
13176
|
+
findings.push({
|
|
13177
|
+
code: "VERIFICATION_MISSING",
|
|
13178
|
+
message: "Belum ada bukti verifikasi. Jalankan `npx jioogen task verify <ref>`."
|
|
13179
|
+
});
|
|
13180
|
+
} else if (stateTask.verification.exitCode !== 0) {
|
|
13181
|
+
findings.push({
|
|
13182
|
+
code: "VERIFICATION_FAILED",
|
|
13183
|
+
message: `Verifikasi terakhir exit ${stateTask.verification.exitCode}; perbaiki sampai exit 0.`
|
|
13184
|
+
});
|
|
13185
|
+
} else {
|
|
13186
|
+
const proofCommand = stateTask.verification.command === void 0 ? null : normalizeVerificationCommand(stateTask.verification.command);
|
|
13187
|
+
const expected = normalizeVerificationCommand(declared);
|
|
13188
|
+
if (proofCommand !== expected && input.lenient !== true) {
|
|
13189
|
+
findings.push({
|
|
13190
|
+
code: "VERIFICATION_COMMAND_MISMATCH",
|
|
13191
|
+
message: "Bukti verifikasi milik command yang berbeda dari kontrak task. Jalankan `task verify` lagi."
|
|
13192
|
+
});
|
|
13193
|
+
}
|
|
13194
|
+
const proofAt = latestVerificationAt(stateTask);
|
|
13195
|
+
const latestFileAt = await latestTargetMtime(input.bundleDir, targetFiles);
|
|
13196
|
+
if (proofAt === void 0) {
|
|
13197
|
+
findings.push({
|
|
13198
|
+
code: "VERIFICATION_STALE",
|
|
13199
|
+
message: "Bukti verifikasi tidak punya timestamp. Jalankan `task verify` lagi."
|
|
13200
|
+
});
|
|
13201
|
+
} else if (latestFileAt !== null && latestFileAt > proofAt + FRESH_TOLERANCE_MS) {
|
|
13202
|
+
findings.push({
|
|
13203
|
+
code: "VERIFICATION_STALE",
|
|
13204
|
+
message: "File target berubah setelah verifikasi terakhir. Jalankan `task verify` lagi."
|
|
13205
|
+
});
|
|
13206
|
+
}
|
|
13207
|
+
}
|
|
13208
|
+
const checklist = await readBreakdownChecklist(input.bundleDir, definition.id);
|
|
13209
|
+
if (checklist === null) {
|
|
13210
|
+
findings.push({
|
|
13211
|
+
code: "BREAKDOWN_INCOMPLETE",
|
|
13212
|
+
message: "Checklist breakdown belum ada. Jalankan `task start` (atau `task expand --write`) lalu kerjakan itemnya."
|
|
13213
|
+
});
|
|
13214
|
+
} else if (checklist.total === 0) {
|
|
13215
|
+
findings.push({
|
|
13216
|
+
code: "BREAKDOWN_INCOMPLETE",
|
|
13217
|
+
message: `Checklist ${checklist.path} tidak berisi item. Regenerate dengan \`task expand --write\`.`
|
|
13218
|
+
});
|
|
13219
|
+
} else if (checklist.unchecked.length > 0) {
|
|
13220
|
+
const refs = checklist.unchecked.map((item) => item.id);
|
|
13221
|
+
const shown = refs.slice(0, 6).join(", ");
|
|
13222
|
+
findings.push({
|
|
13223
|
+
code: "BREAKDOWN_INCOMPLETE",
|
|
13224
|
+
message: `${checklist.unchecked.length} item belum tercentang (${shown}${refs.length > 6 ? ", \u2026" : ""}). Kerjakan lalu centang di ${checklist.path}.`,
|
|
13225
|
+
refs
|
|
13226
|
+
});
|
|
13227
|
+
}
|
|
13228
|
+
if (definition.layer === "frontend_mock") {
|
|
13229
|
+
if (stateTask?.designReview === void 0) {
|
|
13230
|
+
findings.push({
|
|
13231
|
+
code: "DESIGN_REVIEW_MISSING",
|
|
13232
|
+
message: 'Task UI belum punya design review. Jalankan `task verify --visual "<catatan>"` sebelum complete.'
|
|
13233
|
+
});
|
|
13234
|
+
} else if (stateTask.designReview.passed !== true) {
|
|
13235
|
+
findings.push({
|
|
13236
|
+
code: "DESIGN_REVIEW_FAILED",
|
|
13237
|
+
message: "Design review terakhir gagal. Perbaiki lalu verifikasi visual ulang."
|
|
13238
|
+
});
|
|
13239
|
+
} else {
|
|
13240
|
+
const reviewAt = parseAt(stateTask.designReview.at);
|
|
13241
|
+
const latestFileAt = await latestTargetMtime(input.bundleDir, targetFiles);
|
|
13242
|
+
if (reviewAt !== void 0 && latestFileAt !== null && latestFileAt > reviewAt + FRESH_TOLERANCE_MS) {
|
|
13243
|
+
findings.push({
|
|
13244
|
+
code: "DESIGN_REVIEW_STALE",
|
|
13245
|
+
message: "File target berubah setelah design review. Jalankan `task verify --visual` lagi."
|
|
13246
|
+
});
|
|
13247
|
+
}
|
|
13248
|
+
}
|
|
13249
|
+
}
|
|
13250
|
+
const byRef = new Map(input.state.tasks.map((entry) => [entry.ref.toUpperCase(), entry]));
|
|
13251
|
+
const unmet = [];
|
|
13252
|
+
for (const dependency of definition.dependsOn) {
|
|
13253
|
+
const dependencyState = byRef.get(dependency.toUpperCase());
|
|
13254
|
+
const verifiedProof = dependencyState?.verification?.exitCode === 0 && latestVerificationAt(dependencyState) !== void 0;
|
|
13255
|
+
if (dependencyState === void 0 || dependencyState.status !== "done" || isAdoptedTask(dependencyState) || !verifiedProof) {
|
|
13256
|
+
unmet.push(dependency);
|
|
13257
|
+
}
|
|
13258
|
+
}
|
|
13259
|
+
if (unmet.length > 0) {
|
|
13260
|
+
findings.push({
|
|
13261
|
+
code: "DEPENDENCY_UNVERIFIED",
|
|
13262
|
+
message: `Dependency belum terverifikasi: ${unmet.join(", ")}. Selesaikan lewat harness (bukan --force/adopt) sebelum complete.`,
|
|
13263
|
+
refs: unmet
|
|
13264
|
+
});
|
|
13265
|
+
}
|
|
13266
|
+
const drift = await detectDrift(input.bundleDir, input.definitions, input.state, {
|
|
13267
|
+
focusRef: definition.id,
|
|
13268
|
+
includeInfo: false
|
|
13269
|
+
});
|
|
13270
|
+
if (drift.some((finding) => finding.code === "BUNDLE_DRIFT")) {
|
|
13271
|
+
findings.push({
|
|
13272
|
+
code: "CONTRACT_DRIFT",
|
|
13273
|
+
message: "PRD.md/specs/tasks berubah di luar alur align. Jalankan `jioogen align` (bila disengaja) atau kembalikan file kontrak."
|
|
13274
|
+
});
|
|
13275
|
+
}
|
|
13276
|
+
return { ok: findings.length === 0, findings };
|
|
13277
|
+
}
|
|
13278
|
+
function formatCompletionGateFailure(ref, result) {
|
|
13279
|
+
const lines = [`Task ${ref} belum boleh ditandai done:`];
|
|
13280
|
+
for (const finding of result.findings) {
|
|
13281
|
+
lines.push(`- ${finding.code}: ${finding.message}`);
|
|
13282
|
+
}
|
|
13283
|
+
lines.push(
|
|
13284
|
+
"Gate ini otomatis dan milik agent. Perbaiki di giliran ini, jalankan `task verify` bila perlu, lalu `task complete` lagi. `--force` tidak melewati gate ini."
|
|
13285
|
+
);
|
|
13286
|
+
return lines.join("\n");
|
|
13287
|
+
}
|
|
13288
|
+
|
|
12968
13289
|
// src/config.ts
|
|
12969
|
-
import { chmod, mkdir as
|
|
13290
|
+
import { chmod, mkdir as mkdir7, readFile as readFile8, rm as rm5, writeFile as writeFile7 } from "node:fs/promises";
|
|
12970
13291
|
import { homedir } from "node:os";
|
|
12971
|
-
import { dirname as
|
|
13292
|
+
import { dirname as dirname6, join as join9, resolve as resolve2 } from "node:path";
|
|
12972
13293
|
|
|
12973
13294
|
// src/types.ts
|
|
12974
13295
|
var UI_QUALITY_MODES = ["auto", "on", "off"];
|
|
@@ -13036,9 +13357,9 @@ async function readCredentials() {
|
|
|
13036
13357
|
}
|
|
13037
13358
|
async function writeCredentials(credentials) {
|
|
13038
13359
|
const directory = configDir();
|
|
13039
|
-
await
|
|
13360
|
+
await mkdir7(directory, { recursive: true, mode: 448 });
|
|
13040
13361
|
const target = credentialsPath();
|
|
13041
|
-
await
|
|
13362
|
+
await writeFile7(target, `${JSON.stringify(credentials, null, 2)}
|
|
13042
13363
|
`, {
|
|
13043
13364
|
encoding: "utf8",
|
|
13044
13365
|
mode: 384
|
|
@@ -13142,15 +13463,15 @@ async function findProjectLink(startDir) {
|
|
|
13142
13463
|
for (; ; ) {
|
|
13143
13464
|
const link = await readProjectLink(directory);
|
|
13144
13465
|
if (link !== null) return link;
|
|
13145
|
-
const parent =
|
|
13466
|
+
const parent = dirname6(directory);
|
|
13146
13467
|
if (parent === directory) return null;
|
|
13147
13468
|
directory = parent;
|
|
13148
13469
|
}
|
|
13149
13470
|
}
|
|
13150
13471
|
async function writeProjectLink(bundleDir, link) {
|
|
13151
13472
|
const directory = join9(resolve2(bundleDir), PROJECT_DIR);
|
|
13152
|
-
await
|
|
13153
|
-
await
|
|
13473
|
+
await mkdir7(directory, { recursive: true });
|
|
13474
|
+
await writeFile7(
|
|
13154
13475
|
join9(directory, PROJECT_FILE),
|
|
13155
13476
|
`${JSON.stringify(
|
|
13156
13477
|
{
|
|
@@ -13195,14 +13516,166 @@ function isMissingFile3(error) {
|
|
|
13195
13516
|
}
|
|
13196
13517
|
|
|
13197
13518
|
// src/doctor.ts
|
|
13198
|
-
import { readdir as readdir7, readFile as
|
|
13199
|
-
import { join as
|
|
13519
|
+
import { readdir as readdir7, readFile as readFile11, rm as rm8, stat as stat6 } from "node:fs/promises";
|
|
13520
|
+
import { join as join12 } from "node:path";
|
|
13521
|
+
|
|
13522
|
+
// src/recovery.ts
|
|
13523
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
13524
|
+
import { mkdir as mkdir8, readFile as readFile9, rename as rename2, rm as rm6, writeFile as writeFile8 } from "node:fs/promises";
|
|
13525
|
+
import { dirname as dirname7, join as join10 } from "node:path";
|
|
13526
|
+
var RECOVERY_PATH = "tasks/.execution/recovery.json";
|
|
13527
|
+
var RECOVERY_BUDGET = { maxAttempts: 3 };
|
|
13528
|
+
var RECOVERY_BASE_ATTEMPTS = 3;
|
|
13529
|
+
var RECOVERY_MAX_ATTEMPTS = 6;
|
|
13530
|
+
function recoveryBudget(input) {
|
|
13531
|
+
let budget = RECOVERY_BASE_ATTEMPTS;
|
|
13532
|
+
if (input.failureClass === "transient") budget += 1;
|
|
13533
|
+
if (input.failureClass === "semantic") budget += 1;
|
|
13534
|
+
return Math.min(budget, RECOVERY_MAX_ATTEMPTS);
|
|
13535
|
+
}
|
|
13536
|
+
function recoveryPath(bundleDir) {
|
|
13537
|
+
return join10(bundleDir, RECOVERY_PATH);
|
|
13538
|
+
}
|
|
13539
|
+
function isMissingFile4(error) {
|
|
13540
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
13541
|
+
}
|
|
13542
|
+
function emptyJournal() {
|
|
13543
|
+
return { schemaVersion: 1, tasks: {} };
|
|
13544
|
+
}
|
|
13545
|
+
function isJournal(value) {
|
|
13546
|
+
if (typeof value !== "object" || value === null) return false;
|
|
13547
|
+
const obj = value;
|
|
13548
|
+
if (obj.schemaVersion !== 1) return false;
|
|
13549
|
+
if (typeof obj.tasks !== "object" || obj.tasks === null) return false;
|
|
13550
|
+
return true;
|
|
13551
|
+
}
|
|
13552
|
+
async function readRecoveryStrict(bundleDir) {
|
|
13553
|
+
let raw;
|
|
13554
|
+
try {
|
|
13555
|
+
raw = await readFile9(recoveryPath(bundleDir), "utf8");
|
|
13556
|
+
} catch (error) {
|
|
13557
|
+
if (isMissingFile4(error)) return emptyJournal();
|
|
13558
|
+
return null;
|
|
13559
|
+
}
|
|
13560
|
+
let payload;
|
|
13561
|
+
try {
|
|
13562
|
+
payload = JSON.parse(raw);
|
|
13563
|
+
} catch {
|
|
13564
|
+
return null;
|
|
13565
|
+
}
|
|
13566
|
+
if (!isJournal(payload)) return null;
|
|
13567
|
+
return payload;
|
|
13568
|
+
}
|
|
13569
|
+
async function readRecovery(bundleDir) {
|
|
13570
|
+
const strict = await readRecoveryStrict(bundleDir);
|
|
13571
|
+
return strict ?? emptyJournal();
|
|
13572
|
+
}
|
|
13573
|
+
function classifyFailure(input) {
|
|
13574
|
+
if (input.stalled === true || input.timedOut === true) return "transient";
|
|
13575
|
+
if (input.verificationFailed === true) return "semantic";
|
|
13576
|
+
const note = input.note ?? "";
|
|
13577
|
+
if (/^AUTHORIZATION:/i.test(note.trim())) return "authorization";
|
|
13578
|
+
if (/timeout|stall|econn|rate limit|\b429\b|\b5\d\d\b/i.test(note)) return "transient";
|
|
13579
|
+
const prior = input.prior ?? null;
|
|
13580
|
+
if (prior !== null && prior.attempts >= 1 && note === prior.lastNote) return "no_progress";
|
|
13581
|
+
return "semantic";
|
|
13582
|
+
}
|
|
13583
|
+
async function writeRecovery(bundleDir, journal) {
|
|
13584
|
+
const target = recoveryPath(bundleDir);
|
|
13585
|
+
await mkdir8(dirname7(target), { recursive: true });
|
|
13586
|
+
const temp = `${target}.${process.pid}.${randomUUID2()}.tmp`;
|
|
13587
|
+
try {
|
|
13588
|
+
await writeFile8(temp, `${JSON.stringify(journal, null, 2)}
|
|
13589
|
+
`, "utf8");
|
|
13590
|
+
await rename2(temp, target);
|
|
13591
|
+
} catch (error) {
|
|
13592
|
+
await rm6(temp, { force: true }).catch(() => {
|
|
13593
|
+
});
|
|
13594
|
+
throw error;
|
|
13595
|
+
}
|
|
13596
|
+
}
|
|
13597
|
+
async function recordFailure(bundleDir, ref, args) {
|
|
13598
|
+
return withStateLock(bundleDir, async () => {
|
|
13599
|
+
const journal = await readRecovery(bundleDir);
|
|
13600
|
+
const prior = journal.tasks[ref] ?? null;
|
|
13601
|
+
const klass = classifyFailure({ ...args, prior });
|
|
13602
|
+
const attempt = (prior?.attempts ?? 0) + 1;
|
|
13603
|
+
const budget = recoveryBudget({
|
|
13604
|
+
failureClass: klass,
|
|
13605
|
+
priorAttempts: prior?.attempts ?? 0,
|
|
13606
|
+
priorClass: prior?.lastClass ?? null
|
|
13607
|
+
});
|
|
13608
|
+
const exhausted = attempt >= budget;
|
|
13609
|
+
const resumable = exhausted;
|
|
13610
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
13611
|
+
const note = args.note ?? "";
|
|
13612
|
+
const history = [...prior?.history ?? []];
|
|
13613
|
+
history.push({ attempt, class: klass, note, at: now });
|
|
13614
|
+
const capped = history.length > 20 ? history.slice(history.length - 20) : history;
|
|
13615
|
+
const entry = {
|
|
13616
|
+
ref,
|
|
13617
|
+
attempts: attempt,
|
|
13618
|
+
exhausted,
|
|
13619
|
+
resumable,
|
|
13620
|
+
lastClass: klass,
|
|
13621
|
+
lastNote: note === "" ? prior?.lastNote ?? "" : note,
|
|
13622
|
+
history: capped,
|
|
13623
|
+
updatedAt: now
|
|
13624
|
+
};
|
|
13625
|
+
journal.tasks[ref] = entry;
|
|
13626
|
+
await writeRecovery(bundleDir, journal);
|
|
13627
|
+
return { entry, exhausted, class: klass, attempt };
|
|
13628
|
+
});
|
|
13629
|
+
}
|
|
13630
|
+
async function recordSuccess(bundleDir, ref) {
|
|
13631
|
+
await withStateLock(bundleDir, async () => {
|
|
13632
|
+
const journal = await readRecovery(bundleDir);
|
|
13633
|
+
if (journal.tasks[ref] !== void 0) {
|
|
13634
|
+
delete journal.tasks[ref];
|
|
13635
|
+
await writeRecovery(bundleDir, journal);
|
|
13636
|
+
}
|
|
13637
|
+
});
|
|
13638
|
+
}
|
|
13639
|
+
async function rearmTask(bundleDir, ref) {
|
|
13640
|
+
await withStateLock(bundleDir, async () => {
|
|
13641
|
+
const journal = await readRecovery(bundleDir);
|
|
13642
|
+
const prior = journal.tasks[ref];
|
|
13643
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
13644
|
+
const entry = {
|
|
13645
|
+
ref,
|
|
13646
|
+
attempts: 0,
|
|
13647
|
+
exhausted: false,
|
|
13648
|
+
resumable: true,
|
|
13649
|
+
lastClass: prior?.lastClass ?? null,
|
|
13650
|
+
lastNote: prior?.lastNote ?? "",
|
|
13651
|
+
history: prior?.history ?? [],
|
|
13652
|
+
updatedAt: now
|
|
13653
|
+
};
|
|
13654
|
+
journal.tasks[ref] = entry;
|
|
13655
|
+
await writeRecovery(bundleDir, journal);
|
|
13656
|
+
});
|
|
13657
|
+
}
|
|
13658
|
+
function isExhausted(journal, ref) {
|
|
13659
|
+
return journal.tasks[ref]?.exhausted === true;
|
|
13660
|
+
}
|
|
13661
|
+
function describeRecovery(entry) {
|
|
13662
|
+
if (entry === void 0) {
|
|
13663
|
+
return "No recovery record. Run `jioogen resume`, then retry with a different approach.";
|
|
13664
|
+
}
|
|
13665
|
+
const lines = [];
|
|
13666
|
+
lines.push(
|
|
13667
|
+
`Task ${entry.ref}: ${entry.attempts}/${RECOVERY_BUDGET.maxAttempts} attempts, last=${entry.lastClass ?? "none"}.`
|
|
13668
|
+
);
|
|
13669
|
+
if (entry.lastNote.length > 0) lines.push(`Last note: ${entry.lastNote}`);
|
|
13670
|
+
lines.push("Run `jioogen resume`, then retry with a different approach.");
|
|
13671
|
+
return lines.join("\n");
|
|
13672
|
+
}
|
|
13200
13673
|
|
|
13201
13674
|
// src/skills.ts
|
|
13202
13675
|
import { createHash as createHash3 } from "node:crypto";
|
|
13203
|
-
import { cp as cp2, mkdir as
|
|
13676
|
+
import { cp as cp2, mkdir as mkdir9, readdir as readdir6, readFile as readFile10, rename as rename3, rm as rm7, stat as stat5, writeFile as writeFile9 } from "node:fs/promises";
|
|
13204
13677
|
import { homedir as homedir2 } from "node:os";
|
|
13205
|
-
import { dirname as
|
|
13678
|
+
import { dirname as dirname8, join as join11, resolve as resolve3 } from "node:path";
|
|
13206
13679
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
13207
13680
|
var EXECUTION_SKILL_NAME = "jioogen-execution";
|
|
13208
13681
|
var AGENT_SKILL_DIRS = [
|
|
@@ -13328,11 +13801,11 @@ var JIOOGEN_AGENTS_MD = `${MARKER}
|
|
|
13328
13801
|
|
|
13329
13802
|
## 2. Alur per giliran
|
|
13330
13803
|
1. \`npx jioogen task next\` \u2014 baca blok **TASK AKTIF**, **BREAKDOWN WAJIB**, + isi file task.
|
|
13331
|
-
2.
|
|
13332
|
-
3.
|
|
13804
|
+
2. \`npx jioogen task start <ref>\` \u2014 CLI menulis checklist ke \`.jioogen/breakdown/<ref>.md\`.
|
|
13805
|
+
3. Kerjakan dan centang setiap item checklist sebelum lanjut edit.
|
|
13333
13806
|
4. Implementasikan **hanya** task itu sampai semua Acceptance Criteria dan item breakdown terpenuhi.
|
|
13334
|
-
5. Jalankan \`npx jioogen task verify <ref>\` \u2014 CLI menjalankan \`verificationCommand\` dan mencatat bukti exit code.
|
|
13335
|
-
6. \`npx jioogen task complete <ref>\`
|
|
13807
|
+
5. Jalankan \`npx jioogen task verify <ref>\` \u2014 CLI menjalankan \`verificationCommand\` dan mencatat bukti exit code. Task UI: tambah \`--visual "<catatan>"\`.
|
|
13808
|
+
6. \`npx jioogen task complete <ref>\` \u2014 gate otomatis menolak item belum tercentang, bukti basi, dependency belum terverifikasi, atau kontrak berubah. Perbaiki di giliran itu juga, lalu ulangi. Setelah lolos, buat satu commit git kecil.
|
|
13336
13809
|
7. \`npx jioogen sync\`, lalu kembali ke langkah 1.
|
|
13337
13810
|
|
|
13338
13811
|
## 2b. Pekerjaan yang dibangun di luar harness
|
|
@@ -13400,19 +13873,25 @@ ringkasan; jangan dipecah menjadi banyak task.
|
|
|
13400
13873
|
Task parent bersifat naratif. \`task next\` menyuntik \`## BREAKDOWN WAJIB\` yang
|
|
13401
13874
|
diturunkan dari AC, subfeature, flow/step, lifecycle, engine, UI states,
|
|
13402
13875
|
\`targetFiles\`, dan \`verificationCommand\`. Wajib:
|
|
13403
|
-
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13876
|
+
- \`task start\` menulis checklist ke \`.jioogen/breakdown/<ref>.md\` (execution-owned,
|
|
13877
|
+
bukan kontrak). \`task expand <ref> --write\` membuatnya bila belum ada.
|
|
13878
|
+
- Kerjakan dan centang setiap item di file itu sebelum mulai edit; item tidak boleh dilewati.
|
|
13406
13879
|
- Breakdown bukan task baru; jangan menambah task atau mengubah
|
|
13407
|
-
\`PRD.md\`/\`specs/\`/\`tasks/\` (task baru hanya pada \`--mode seed\`).
|
|
13408
|
-
|
|
13409
|
-
|
|
13880
|
+
\`PRD.md\`/\`specs/\`/\`tasks/\` (task baru hanya pada \`--mode seed\`). Jangan menyalin
|
|
13881
|
+
checklist ke file task.
|
|
13882
|
+
- \`task complete\` menolak selama masih ada \`- [ ]\`. Selesai bila semua item,
|
|
13883
|
+
\`targetFiles\`, AC, dan \`verificationCommand\` terpenuhi.
|
|
13410
13884
|
|
|
13411
13885
|
## 4. Verifikasi jujur
|
|
13412
13886
|
- Pakai test runner yang dideklarasikan di \`specs/\` atau dibuat task scaffold.
|
|
13413
13887
|
- Dilarang \`--passWithNoTests\` atau flag yang membuat command exit 0 tanpa test nyata.
|
|
13414
13888
|
- Kalau test belum ada, task belum selesai.
|
|
13415
|
-
- Bukti verifikasi dicatat CLI lewat \`npx jioogen task verify <ref>\`; \`task complete\` menolak tanpa bukti exit 0.
|
|
13889
|
+
- Bukti verifikasi dicatat CLI lewat \`npx jioogen task verify <ref>\`; \`task complete\` menolak tanpa bukti exit 0 yang lebih baru dari perubahan terakhir.
|
|
13890
|
+
- Task UI wajib \`npx jioogen task verify <ref> --visual "<catatan>"\`; design review yang hilang/gagal/basi menolak \`task complete\`.
|
|
13891
|
+
- Gate \`task complete\` tidak punya \`--force\`: perbaiki temuan di giliran yang sama, jangan lanjutkan task berikutnya.
|
|
13892
|
+
- Bila task sudah \`done\` tetapi ternyata partial: reopen dengan \`npx jioogen task start <ref>\`
|
|
13893
|
+
(history append-only), lengkapi item yang dilewati, \`task verify\`, lalu \`task complete\`
|
|
13894
|
+
lagi. Jangan cukup mencatat "partial" di note.
|
|
13416
13895
|
|
|
13417
13896
|
## 5. Berhenti sebentar untuk konfirmasi
|
|
13418
13897
|
Berhenti setelah satu bagian besar selesai, sebelum beralih ke bagian berikutnya,
|
|
@@ -13510,12 +13989,15 @@ atas ide, refactor, perbaikan, atau fitur lain.
|
|
|
13510
13989
|
## 2. Siklus per giliran
|
|
13511
13990
|
|
|
13512
13991
|
1. \`npx jioogen task next\` \u2014 baca TASK AKTIF, BREAKDOWN WAJIB, + isi file task.
|
|
13513
|
-
2.
|
|
13514
|
-
3.
|
|
13992
|
+
2. \`npx jioogen task start <ref>\`.
|
|
13993
|
+
3. Buka \`.jioogen/breakdown/<ref>.md\`; kerjakan dan centang setiap item sebelum lanjut edit.
|
|
13515
13994
|
4. Implementasikan **hanya** task itu sampai semua Acceptance Criteria dan item breakdown terpenuhi.
|
|
13516
13995
|
5. Jalankan \`npx jioogen task verify <ref>\` sampai exit 0; CLI mencatat buktinya.
|
|
13517
|
-
|
|
13518
|
-
|
|
13996
|
+
Task UI: juga \`npx jioogen task verify <ref> --visual "<catatan>"\`.
|
|
13997
|
+
6. \`npx jioogen task complete <ref>\` \u2014 gate otomatis menolak bila ada item belum
|
|
13998
|
+
tercentang, bukti basi, dependency belum terverifikasi, atau kontrak berubah.
|
|
13999
|
+
Perbaiki di giliran itu juga, lalu ulangi. Setelah lolos, buat **satu commit git kecil**
|
|
14000
|
+
untuk task itu (lewati bila folder bukan repo git).
|
|
13519
14001
|
7. \`npx jioogen sync\`, lalu kembali ke langkah 1.
|
|
13520
14002
|
|
|
13521
14003
|
## 2b. Pekerjaan yang dibangun di luar harness
|
|
@@ -13590,13 +14072,14 @@ ringkasan; jangan dipecah menjadi banyak task.
|
|
|
13590
14072
|
Task parent bersifat naratif. \`task next\` menyuntik \`## BREAKDOWN WAJIB\` yang
|
|
13591
14073
|
diturunkan dari AC, subfeature, flow/step, lifecycle, engine, UI states,
|
|
13592
14074
|
\`targetFiles\`, dan \`verificationCommand\`. Wajib:
|
|
13593
|
-
-
|
|
13594
|
-
|
|
13595
|
-
|
|
14075
|
+
- \`task start\` menulis checklist ke \`.jioogen/breakdown/<ref>.md\` (execution-owned,
|
|
14076
|
+
bukan kontrak). \`task expand <ref> --write\` membuatnya bila belum ada.
|
|
14077
|
+
- Kerjakan dan centang setiap item di file itu sebelum mulai edit; item tidak boleh dilewati.
|
|
13596
14078
|
- Breakdown bukan task baru; jangan menambah task atau mengubah
|
|
13597
|
-
\`PRD.md\`/\`specs/\`/\`tasks/\` (task baru hanya pada \`--mode seed\`).
|
|
13598
|
-
|
|
13599
|
-
|
|
14079
|
+
\`PRD.md\`/\`specs/\`/\`tasks/\` (task baru hanya pada \`--mode seed\`). Jangan menyalin
|
|
14080
|
+
checklist ke file task.
|
|
14081
|
+
- \`task complete\` menolak selama masih ada \`- [ ]\`. Selesai bila semua item,
|
|
14082
|
+
\`targetFiles\`, AC, dan \`verificationCommand\` terpenuhi.
|
|
13600
14083
|
|
|
13601
14084
|
## 3e. Anti-Bloat & Code Health
|
|
13602
14085
|
|
|
@@ -13639,9 +14122,14 @@ Tanya: "Apakah senior engineer bilang ini overcomplicated?" Bila ya, sederhanaka
|
|
|
13639
14122
|
- **Dilarang** \`--passWithNoTests\` atau flag sejenis yang membuat command exit 0
|
|
13640
14123
|
tanpa menjalankan test nyata.
|
|
13641
14124
|
- Kalau test belum ada, task belum selesai.
|
|
13642
|
-
- Bukti verifikasi dicatat CLI lewat \`npx jioogen task verify <ref>\`; \`task complete\` menolak tanpa bukti exit 0.
|
|
14125
|
+
- Bukti verifikasi dicatat CLI lewat \`npx jioogen task verify <ref>\`; \`task complete\` menolak tanpa bukti exit 0 yang lebih baru dari perubahan terakhir.
|
|
13643
14126
|
- Task yang menyentuh UI: jalankan juga \`npx jioogen task verify <ref> --visual\`
|
|
13644
|
-
(design review); \`task complete\` menolak design review yang gagal.
|
|
14127
|
+
(design review); \`task complete\` menolak design review yang hilang, gagal, atau basi.
|
|
14128
|
+
- Gate \`task complete\` tidak punya \`--force\`: perbaiki temuan di giliran yang sama,
|
|
14129
|
+
jangan lanjutkan task berikutnya.
|
|
14130
|
+
- Bila task sudah \`done\` tetapi ternyata partial: reopen dengan \`npx jioogen task start <ref>\`
|
|
14131
|
+
(history append-only), lengkapi item yang dilewati, \`task verify\`, lalu \`task complete\`
|
|
14132
|
+
lagi. Jangan cukup mencatat "partial" di note.
|
|
13645
14133
|
- Task \`layer: verification\` menjalankan semua \`verificationCommand\`, smoke test
|
|
13646
14134
|
route/navigasi, cek UI states + responsive, dan verifikasi AC.
|
|
13647
14135
|
|
|
@@ -13668,8 +14156,12 @@ menampilkan perintah itu sebagai pertanyaan ke user.
|
|
|
13668
14156
|
- Jangan menunda entrypoint/scaffold ke fase backend.
|
|
13669
14157
|
- Jangan mengganti ownership/consistency boundary tanpa memperbarui spec.
|
|
13670
14158
|
- Jangan menandai \`done\` sebelum verification exit 0.
|
|
13671
|
-
- **
|
|
13672
|
-
|
|
14159
|
+
- **Gate \`task complete\` tidak bisa dilewati.** Item breakdown belum tercentang,
|
|
14160
|
+
bukti verifikasi hilang/basi, design review UI hilang/gagal, dependency belum
|
|
14161
|
+
terverifikasi, atau kontrak berubah = perbaiki dulu di giliran yang sama.
|
|
14162
|
+
\`--force\`/\`--lenient\` tidak membuka gate ini.
|
|
14163
|
+
- **Jangan loop pada warning CLI non-gate.** Warning seperti ID task duplikat atau
|
|
14164
|
+
drift bukan BLOCKER: baca pesannya, tandai di note, lanjut.
|
|
13673
14165
|
Perintah CLI yang sama tidak boleh diulang demi hasil yang sama; kalau tetap
|
|
13674
14166
|
gagal setelah 1 ulangan, tandai \`fail\` + alasan singkat.
|
|
13675
14167
|
- **Project dihapus = dead end.** CLI sudah melepas link otomatis; jangan ulangi
|
|
@@ -13685,18 +14177,18 @@ Gap non-material \u2192 tafsir paling sempit + catat asumsi di note, lanjut. Gap
|
|
|
13685
14177
|
Jangan menebak scope baru.
|
|
13686
14178
|
`;
|
|
13687
14179
|
async function ensureCustomScaffold(root) {
|
|
13688
|
-
const base =
|
|
14180
|
+
const base = join11(root, ".jioogen", "custom");
|
|
13689
14181
|
for (const dir of CUSTOM_SCAFFOLD_DIRS) {
|
|
13690
|
-
await
|
|
14182
|
+
await mkdir9(join11(base, dir), { recursive: true });
|
|
13691
14183
|
}
|
|
13692
|
-
const readme =
|
|
14184
|
+
const readme = join11(root, CUSTOM_SCAFFOLD_README_PATH);
|
|
13693
14185
|
if (await readFileSafe(readme) !== void 0) return [];
|
|
13694
|
-
await
|
|
14186
|
+
await writeFile9(readme, CUSTOM_SCAFFOLD_README, "utf8");
|
|
13695
14187
|
return [CUSTOM_SCAFFOLD_README_PATH];
|
|
13696
14188
|
}
|
|
13697
14189
|
async function readFileSafe(path) {
|
|
13698
14190
|
try {
|
|
13699
|
-
return await
|
|
14191
|
+
return await readFile10(path, "utf8");
|
|
13700
14192
|
} catch {
|
|
13701
14193
|
return void 0;
|
|
13702
14194
|
}
|
|
@@ -13704,14 +14196,14 @@ async function readFileSafe(path) {
|
|
|
13704
14196
|
function isRecord2(value) {
|
|
13705
14197
|
return typeof value === "object" && value !== null;
|
|
13706
14198
|
}
|
|
13707
|
-
function
|
|
14199
|
+
function isMissingFile5(error) {
|
|
13708
14200
|
return isRecord2(error) && error.code === "ENOENT";
|
|
13709
14201
|
}
|
|
13710
14202
|
async function isFile(path) {
|
|
13711
14203
|
try {
|
|
13712
14204
|
return (await stat5(path)).isFile();
|
|
13713
14205
|
} catch (error) {
|
|
13714
|
-
if (
|
|
14206
|
+
if (isMissingFile5(error)) return false;
|
|
13715
14207
|
throw error;
|
|
13716
14208
|
}
|
|
13717
14209
|
}
|
|
@@ -13719,7 +14211,7 @@ async function isDirectory(path) {
|
|
|
13719
14211
|
try {
|
|
13720
14212
|
return (await stat5(path)).isDirectory();
|
|
13721
14213
|
} catch (error) {
|
|
13722
|
-
if (
|
|
14214
|
+
if (isMissingFile5(error)) return false;
|
|
13723
14215
|
throw error;
|
|
13724
14216
|
}
|
|
13725
14217
|
}
|
|
@@ -13785,12 +14277,12 @@ function parseHarnessManifest(value) {
|
|
|
13785
14277
|
};
|
|
13786
14278
|
}
|
|
13787
14279
|
async function readHarnessManifest(bundleDir) {
|
|
13788
|
-
const path =
|
|
14280
|
+
const path = join11(resolve3(bundleDir), HARNESS_MANIFEST_PATH);
|
|
13789
14281
|
let raw;
|
|
13790
14282
|
try {
|
|
13791
|
-
raw = await
|
|
14283
|
+
raw = await readFile10(path, "utf8");
|
|
13792
14284
|
} catch (error) {
|
|
13793
|
-
if (
|
|
14285
|
+
if (isMissingFile5(error)) return null;
|
|
13794
14286
|
throw error;
|
|
13795
14287
|
}
|
|
13796
14288
|
try {
|
|
@@ -13800,24 +14292,24 @@ async function readHarnessManifest(bundleDir) {
|
|
|
13800
14292
|
}
|
|
13801
14293
|
}
|
|
13802
14294
|
async function writeHarnessManifest(bundleDir, manifest) {
|
|
13803
|
-
const path =
|
|
13804
|
-
await
|
|
13805
|
-
await
|
|
14295
|
+
const path = join11(resolve3(bundleDir), HARNESS_MANIFEST_PATH);
|
|
14296
|
+
await mkdir9(dirname8(path), { recursive: true });
|
|
14297
|
+
await writeFile9(path, `${JSON.stringify(manifest, null, 2)}
|
|
13806
14298
|
`, "utf8");
|
|
13807
14299
|
return path;
|
|
13808
14300
|
}
|
|
13809
14301
|
async function detectProductKind(bundleDir) {
|
|
13810
|
-
const tasksDir =
|
|
14302
|
+
const tasksDir = join11(contractRoot(resolve3(bundleDir)), "tasks");
|
|
13811
14303
|
let entries;
|
|
13812
14304
|
try {
|
|
13813
14305
|
entries = await readdir6(tasksDir, { withFileTypes: true });
|
|
13814
14306
|
} catch (error) {
|
|
13815
|
-
if (
|
|
14307
|
+
if (isMissingFile5(error)) return "non-ui";
|
|
13816
14308
|
throw error;
|
|
13817
14309
|
}
|
|
13818
14310
|
for (const entry of entries) {
|
|
13819
14311
|
if (!entry.isFile() || !entry.name.toLowerCase().endsWith(".md")) continue;
|
|
13820
|
-
const content = await readFileSafe(
|
|
14312
|
+
const content = await readFileSafe(join11(tasksDir, entry.name));
|
|
13821
14313
|
if (content !== void 0 && FRONTEND_MOCK_LAYER_RE.test(content)) return "ui";
|
|
13822
14314
|
}
|
|
13823
14315
|
return "non-ui";
|
|
@@ -13833,30 +14325,30 @@ function packsForProduct(productKind, uiQuality = "auto") {
|
|
|
13833
14325
|
return packs;
|
|
13834
14326
|
}
|
|
13835
14327
|
function cliPackageRoot2() {
|
|
13836
|
-
return resolve3(
|
|
14328
|
+
return resolve3(dirname8(fileURLToPath2(import.meta.url)), "..");
|
|
13837
14329
|
}
|
|
13838
14330
|
function skillSourceCandidates(pack, name) {
|
|
13839
14331
|
const candidates = [];
|
|
13840
14332
|
const override = process.env.JIOOGEN_SKILLS_DIR?.trim();
|
|
13841
|
-
if (override !== void 0 && override.length > 0) candidates.push(
|
|
13842
|
-
candidates.push(
|
|
13843
|
-
candidates.push(
|
|
14333
|
+
if (override !== void 0 && override.length > 0) candidates.push(join11(override, name));
|
|
14334
|
+
candidates.push(join11(configDir(), "skill-cache", name));
|
|
14335
|
+
candidates.push(join11(cliPackageRoot2(), "skills-pack", pack, name));
|
|
13844
14336
|
const home = homedir2();
|
|
13845
|
-
candidates.push(
|
|
13846
|
-
candidates.push(
|
|
13847
|
-
candidates.push(
|
|
14337
|
+
candidates.push(join11(home, ".agents", "skills", name));
|
|
14338
|
+
candidates.push(join11(home, ".config", "opencode", "skills", name));
|
|
14339
|
+
candidates.push(join11(home, ".claude", "skills", name));
|
|
13848
14340
|
return candidates;
|
|
13849
14341
|
}
|
|
13850
14342
|
async function resolveSkillSource(pack, name) {
|
|
13851
14343
|
for (const candidate of skillSourceCandidates(pack, name)) {
|
|
13852
|
-
if (await isDirectory(candidate) && await isFile(
|
|
14344
|
+
if (await isDirectory(candidate) && await isFile(join11(candidate, "SKILL.md"))) {
|
|
13853
14345
|
return candidate;
|
|
13854
14346
|
}
|
|
13855
14347
|
}
|
|
13856
14348
|
return null;
|
|
13857
14349
|
}
|
|
13858
14350
|
async function collectRelativeFiles(root, prefix) {
|
|
13859
|
-
const entries = await readdir6(
|
|
14351
|
+
const entries = await readdir6(join11(root, prefix), { withFileTypes: true });
|
|
13860
14352
|
const files = [];
|
|
13861
14353
|
for (const entry of entries) {
|
|
13862
14354
|
const relative3 = prefix.length === 0 ? entry.name : `${prefix}/${entry.name}`;
|
|
@@ -13875,14 +14367,14 @@ async function hashSkillDirectory(directory) {
|
|
|
13875
14367
|
for (const relative3 of files) {
|
|
13876
14368
|
hash.update(relative3);
|
|
13877
14369
|
hash.update("\0");
|
|
13878
|
-
hash.update(await
|
|
14370
|
+
hash.update(await readFile10(join11(root, ...relative3.split("/"))));
|
|
13879
14371
|
hash.update("\0");
|
|
13880
14372
|
}
|
|
13881
14373
|
return hash.digest("hex");
|
|
13882
14374
|
}
|
|
13883
14375
|
async function replaceDirectory(source, target) {
|
|
13884
|
-
await
|
|
13885
|
-
await
|
|
14376
|
+
await rm7(target, { recursive: true, force: true });
|
|
14377
|
+
await mkdir9(dirname8(target), { recursive: true });
|
|
13886
14378
|
await cp2(source, target, { recursive: true });
|
|
13887
14379
|
}
|
|
13888
14380
|
function packNamesInCanonicalOrder(names) {
|
|
@@ -13902,8 +14394,8 @@ async function provisionPack(root, pack, prior, written, preserved) {
|
|
|
13902
14394
|
const previous = prior?.skills.find((entry) => entry.name === name);
|
|
13903
14395
|
let owned = previous !== void 0;
|
|
13904
14396
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13905
|
-
const targetDir =
|
|
13906
|
-
const skillMd =
|
|
14397
|
+
const targetDir = join11(root, dir, name);
|
|
14398
|
+
const skillMd = join11(targetDir, "SKILL.md");
|
|
13907
14399
|
if (await isFile(skillMd)) {
|
|
13908
14400
|
const targetHash = await hashSkillDirectory(targetDir);
|
|
13909
14401
|
if (previous === void 0) {
|
|
@@ -13934,18 +14426,18 @@ async function provisionCustomSkills(root, prior) {
|
|
|
13934
14426
|
const conflicts = [];
|
|
13935
14427
|
const removed = [];
|
|
13936
14428
|
const sources = /* @__PURE__ */ new Set();
|
|
13937
|
-
const base =
|
|
14429
|
+
const base = join11(root, CUSTOM_SKILLS_DIR);
|
|
13938
14430
|
const reserved = /* @__PURE__ */ new Set([EXECUTION_SKILL_NAME, ...Object.values(SKILL_PACKS).flat()]);
|
|
13939
14431
|
let entries = [];
|
|
13940
14432
|
try {
|
|
13941
14433
|
entries = await readdir6(base, { withFileTypes: true });
|
|
13942
14434
|
} catch (error) {
|
|
13943
|
-
if (!
|
|
14435
|
+
if (!isMissingFile5(error)) throw error;
|
|
13944
14436
|
}
|
|
13945
14437
|
const names = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
13946
14438
|
for (const name of names) {
|
|
13947
|
-
const source =
|
|
13948
|
-
if (!await isFile(
|
|
14439
|
+
const source = join11(base, name);
|
|
14440
|
+
if (!await isFile(join11(source, "SKILL.md"))) continue;
|
|
13949
14441
|
sources.add(name);
|
|
13950
14442
|
if (reserved.has(name)) {
|
|
13951
14443
|
conflicts.push(name);
|
|
@@ -13955,8 +14447,8 @@ async function provisionCustomSkills(root, prior) {
|
|
|
13955
14447
|
const previous = prior.find((entry) => entry.name === name);
|
|
13956
14448
|
let owned = previous !== void 0;
|
|
13957
14449
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13958
|
-
const targetDir =
|
|
13959
|
-
const skillMd =
|
|
14450
|
+
const targetDir = join11(root, dir, name);
|
|
14451
|
+
const skillMd = join11(targetDir, "SKILL.md");
|
|
13960
14452
|
if (await isFile(skillMd)) {
|
|
13961
14453
|
const targetHash = await hashSkillDirectory(targetDir);
|
|
13962
14454
|
if (previous === void 0) {
|
|
@@ -13990,15 +14482,15 @@ async function provisionCustomSkills(root, prior) {
|
|
|
13990
14482
|
if (sources.has(entry.name) && !reserved.has(entry.name)) continue;
|
|
13991
14483
|
if (reserved.has(entry.name)) continue;
|
|
13992
14484
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13993
|
-
const targetDir =
|
|
13994
|
-
const skillMd =
|
|
14485
|
+
const targetDir = join11(root, dir, entry.name);
|
|
14486
|
+
const skillMd = join11(targetDir, "SKILL.md");
|
|
13995
14487
|
if (!await isFile(skillMd)) continue;
|
|
13996
14488
|
const targetHash = await hashSkillDirectory(targetDir);
|
|
13997
14489
|
if (targetHash !== entry.sha256) {
|
|
13998
14490
|
preserved.push(`${dir}/${entry.name}/SKILL.md`);
|
|
13999
14491
|
continue;
|
|
14000
14492
|
}
|
|
14001
|
-
await
|
|
14493
|
+
await rm7(targetDir, { recursive: true, force: true });
|
|
14002
14494
|
removed.push(`${dir}/${entry.name}/SKILL.md`);
|
|
14003
14495
|
}
|
|
14004
14496
|
}
|
|
@@ -14042,10 +14534,10 @@ async function provisionSkillPacks(bundleDir, packNames, productKind) {
|
|
|
14042
14534
|
};
|
|
14043
14535
|
}
|
|
14044
14536
|
async function ensureBundleGitignore(root) {
|
|
14045
|
-
const path =
|
|
14537
|
+
const path = join11(resolve3(root), ".gitignore");
|
|
14046
14538
|
const existing = await readFileSafe(path);
|
|
14047
14539
|
if (existing === void 0) {
|
|
14048
|
-
await
|
|
14540
|
+
await writeFile9(path, GITIGNORE_BLOCK, "utf8");
|
|
14049
14541
|
return ".gitignore";
|
|
14050
14542
|
}
|
|
14051
14543
|
const start = existing.indexOf(GITIGNORE_START);
|
|
@@ -14053,7 +14545,7 @@ async function ensureBundleGitignore(root) {
|
|
|
14053
14545
|
const next = start >= 0 && end > start ? `${existing.slice(0, start)}${GITIGNORE_BLOCK}${existing.slice(end + GITIGNORE_END.length).replace(/^\n/, "")}` : `${existing.replace(/\n*$/, "\n")}
|
|
14054
14546
|
${GITIGNORE_BLOCK}`;
|
|
14055
14547
|
if (next === existing) return null;
|
|
14056
|
-
await
|
|
14548
|
+
await writeFile9(path, next, "utf8");
|
|
14057
14549
|
return ".gitignore";
|
|
14058
14550
|
}
|
|
14059
14551
|
async function installAgentSkills(bundleDir, options = {}) {
|
|
@@ -14061,20 +14553,20 @@ async function installAgentSkills(bundleDir, options = {}) {
|
|
|
14061
14553
|
const written = [];
|
|
14062
14554
|
const preserved = [];
|
|
14063
14555
|
const productKind = options.productKind ?? await detectProductKind(root);
|
|
14064
|
-
const harnessPath =
|
|
14065
|
-
const agentsPath =
|
|
14556
|
+
const harnessPath = join11(root, HARNESS_MANIFEST_PATH);
|
|
14557
|
+
const agentsPath = join11(root, "AGENTS.md");
|
|
14066
14558
|
const existing = await readFileSafe(agentsPath);
|
|
14067
14559
|
if (existing === void 0 || existing.includes(MARKER_PREFIX)) {
|
|
14068
|
-
await
|
|
14560
|
+
await writeFile9(agentsPath, JIOOGEN_AGENTS_MD, "utf8");
|
|
14069
14561
|
written.push("AGENTS.md");
|
|
14070
14562
|
} else {
|
|
14071
14563
|
preserved.push("AGENTS.md");
|
|
14072
14564
|
}
|
|
14073
14565
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14074
14566
|
const relative3 = `${dir}/${EXECUTION_SKILL_NAME}/SKILL.md`;
|
|
14075
|
-
const target =
|
|
14076
|
-
await
|
|
14077
|
-
await
|
|
14567
|
+
const target = join11(root, relative3);
|
|
14568
|
+
await mkdir9(dirname8(target), { recursive: true });
|
|
14569
|
+
await writeFile9(target, JIOOGEN_EXECUTION_SKILL, "utf8");
|
|
14078
14570
|
written.push(relative3);
|
|
14079
14571
|
}
|
|
14080
14572
|
const gitignore = await ensureBundleGitignore(root);
|
|
@@ -14142,26 +14634,26 @@ async function removeExecutionContract(bundleDir) {
|
|
|
14142
14634
|
const root = resolve3(bundleDir);
|
|
14143
14635
|
const removed = [];
|
|
14144
14636
|
const preserved = [];
|
|
14145
|
-
const agentsPath =
|
|
14637
|
+
const agentsPath = join11(root, "AGENTS.md");
|
|
14146
14638
|
const existingAgents = await readFileSafe(agentsPath);
|
|
14147
14639
|
if (existingAgents !== void 0) {
|
|
14148
14640
|
if (existingAgents.includes(MARKER_PREFIX)) {
|
|
14149
|
-
await
|
|
14641
|
+
await rm7(agentsPath, { force: true });
|
|
14150
14642
|
removed.push("AGENTS.md");
|
|
14151
14643
|
} else {
|
|
14152
14644
|
preserved.push("AGENTS.md");
|
|
14153
14645
|
}
|
|
14154
14646
|
}
|
|
14155
14647
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14156
|
-
const target =
|
|
14648
|
+
const target = join11(root, dir, EXECUTION_SKILL_NAME);
|
|
14157
14649
|
try {
|
|
14158
14650
|
const info = await stat5(target);
|
|
14159
14651
|
if (info.isDirectory()) {
|
|
14160
|
-
await
|
|
14652
|
+
await rm7(target, { recursive: true, force: true });
|
|
14161
14653
|
removed.push(`${dir}/${EXECUTION_SKILL_NAME}`);
|
|
14162
14654
|
}
|
|
14163
14655
|
} catch (error) {
|
|
14164
|
-
if (!
|
|
14656
|
+
if (!isMissingFile5(error)) throw error;
|
|
14165
14657
|
}
|
|
14166
14658
|
}
|
|
14167
14659
|
return { removed, preserved };
|
|
@@ -14176,15 +14668,15 @@ async function removeSkillPack(bundleDir, pack) {
|
|
|
14176
14668
|
if (entry !== void 0) {
|
|
14177
14669
|
for (const skill of entry.skills) {
|
|
14178
14670
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14179
|
-
const targetDir =
|
|
14180
|
-
const skillMd =
|
|
14671
|
+
const targetDir = join11(root, dir, skill.name);
|
|
14672
|
+
const skillMd = join11(targetDir, "SKILL.md");
|
|
14181
14673
|
if (!await isFile(skillMd)) continue;
|
|
14182
14674
|
const targetHash = await hashSkillDirectory(targetDir);
|
|
14183
14675
|
if (targetHash !== skill.sha256) {
|
|
14184
14676
|
preserved.push(`${dir}/${skill.name}/SKILL.md`);
|
|
14185
14677
|
continue;
|
|
14186
14678
|
}
|
|
14187
|
-
await
|
|
14679
|
+
await rm7(targetDir, { recursive: true, force: true });
|
|
14188
14680
|
removed.push(`${dir}/${skill.name}/SKILL.md`);
|
|
14189
14681
|
}
|
|
14190
14682
|
}
|
|
@@ -14220,7 +14712,7 @@ async function restoreSkillPack(bundleDir, packArgument) {
|
|
|
14220
14712
|
}
|
|
14221
14713
|
const sha2562 = await hashSkillDirectory(source);
|
|
14222
14714
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14223
|
-
const targetDir =
|
|
14715
|
+
const targetDir = join11(root, dir, name);
|
|
14224
14716
|
await replaceDirectory(source, targetDir);
|
|
14225
14717
|
restored.push(`${dir}/${name}`);
|
|
14226
14718
|
}
|
|
@@ -14246,11 +14738,11 @@ async function disableSkill(bundleDir, name) {
|
|
|
14246
14738
|
const root = resolve3(bundleDir);
|
|
14247
14739
|
const disabled = [];
|
|
14248
14740
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14249
|
-
const targetDir =
|
|
14741
|
+
const targetDir = join11(root, dir, name);
|
|
14250
14742
|
const disabledDir = `${targetDir}.disabled`;
|
|
14251
14743
|
if (!await isDirectory(targetDir)) continue;
|
|
14252
|
-
if (await isDirectory(disabledDir)) await
|
|
14253
|
-
await
|
|
14744
|
+
if (await isDirectory(disabledDir)) await rm7(disabledDir, { recursive: true, force: true });
|
|
14745
|
+
await rename3(targetDir, disabledDir);
|
|
14254
14746
|
disabled.push(`${dir}/${name}`);
|
|
14255
14747
|
}
|
|
14256
14748
|
return { disabled };
|
|
@@ -14259,12 +14751,12 @@ async function enableSkill(bundleDir, name) {
|
|
|
14259
14751
|
const root = resolve3(bundleDir);
|
|
14260
14752
|
const enabled = [];
|
|
14261
14753
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14262
|
-
const targetDir =
|
|
14754
|
+
const targetDir = join11(root, dir, name);
|
|
14263
14755
|
const disabledDir = `${targetDir}.disabled`;
|
|
14264
14756
|
if (!await isDirectory(disabledDir)) continue;
|
|
14265
|
-
if (await isDirectory(targetDir)) await
|
|
14757
|
+
if (await isDirectory(targetDir)) await rm7(disabledDir, { recursive: true, force: true });
|
|
14266
14758
|
else {
|
|
14267
|
-
await
|
|
14759
|
+
await rename3(disabledDir, targetDir);
|
|
14268
14760
|
enabled.push(`${dir}/${name}`);
|
|
14269
14761
|
}
|
|
14270
14762
|
}
|
|
@@ -14287,7 +14779,7 @@ function makeCheck(id, status, detail, fixable) {
|
|
|
14287
14779
|
function errorMessage(error) {
|
|
14288
14780
|
return error instanceof Error ? error.message : String(error);
|
|
14289
14781
|
}
|
|
14290
|
-
function
|
|
14782
|
+
function isMissingFile6(error) {
|
|
14291
14783
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
14292
14784
|
}
|
|
14293
14785
|
function resolveDeps(deps) {
|
|
@@ -14301,7 +14793,8 @@ function resolveDeps(deps) {
|
|
|
14301
14793
|
const client = new ApiClient(apiUrl, cookie);
|
|
14302
14794
|
return client.getJson(projectPath(projectId, "/execution"));
|
|
14303
14795
|
}),
|
|
14304
|
-
installSkills: deps?.installSkills ?? ((bundleDir) => installAgentSkills(bundleDir))
|
|
14796
|
+
installSkills: deps?.installSkills ?? ((bundleDir) => installAgentSkills(bundleDir)),
|
|
14797
|
+
publishSidecar: deps?.publishSidecar
|
|
14305
14798
|
};
|
|
14306
14799
|
}
|
|
14307
14800
|
function checkNode() {
|
|
@@ -14449,17 +14942,17 @@ async function listMarkdownFiles(directory) {
|
|
|
14449
14942
|
async function checkBundle(bundleDir) {
|
|
14450
14943
|
const missing = [];
|
|
14451
14944
|
const contract = contractRoot(bundleDir);
|
|
14452
|
-
if (!await isFile2(
|
|
14453
|
-
const specsDir =
|
|
14945
|
+
if (!await isFile2(join12(contract, "PRD.md"))) missing.push("PRD.md");
|
|
14946
|
+
const specsDir = join12(contract, "specs");
|
|
14454
14947
|
if (!await isDirectory2(specsDir)) {
|
|
14455
14948
|
missing.push("specs/");
|
|
14456
14949
|
} else {
|
|
14457
14950
|
const markdown = await listMarkdownFiles(specsDir);
|
|
14458
|
-
const readme = await
|
|
14951
|
+
const readme = await readFile11(join12(specsDir, "SPECS.md"), "utf8").catch(() => "");
|
|
14459
14952
|
const hasContent = markdown.some((name) => name.toLowerCase() !== "specs.md") || specReadmeIsContent(readme);
|
|
14460
14953
|
if (!hasContent) missing.push("specs/*.md (konten)");
|
|
14461
14954
|
}
|
|
14462
|
-
const tasksDir =
|
|
14955
|
+
const tasksDir = join12(contract, "tasks");
|
|
14463
14956
|
if (!await isDirectory2(tasksDir)) {
|
|
14464
14957
|
missing.push("tasks/");
|
|
14465
14958
|
} else {
|
|
@@ -14505,6 +14998,82 @@ async function checkSidecar(bundleDir) {
|
|
|
14505
14998
|
);
|
|
14506
14999
|
}
|
|
14507
15000
|
}
|
|
15001
|
+
async function checkStaleAdoption(bundleDir) {
|
|
15002
|
+
let state;
|
|
15003
|
+
try {
|
|
15004
|
+
state = await readState(bundleDir);
|
|
15005
|
+
} catch (error) {
|
|
15006
|
+
return makeCheck(
|
|
15007
|
+
"stale-adoption",
|
|
15008
|
+
"warn",
|
|
15009
|
+
`Tidak bisa memeriksa stale adoption: ${errorMessage(error)}.`
|
|
15010
|
+
);
|
|
15011
|
+
}
|
|
15012
|
+
if (state === null) {
|
|
15013
|
+
return makeCheck("stale-adoption", "pass", "Belum ada sidecar; stale adoption tidak berlaku.");
|
|
15014
|
+
}
|
|
15015
|
+
const strictJournal = await readRecoveryStrict(bundleDir);
|
|
15016
|
+
if (strictJournal === null) {
|
|
15017
|
+
return makeCheck(
|
|
15018
|
+
"stale-adoption",
|
|
15019
|
+
"warn",
|
|
15020
|
+
"Recovery journal rusak; stale adoption tidak diperbaiki otomatis."
|
|
15021
|
+
);
|
|
15022
|
+
}
|
|
15023
|
+
const journal = strictJournal;
|
|
15024
|
+
const unusableAdopted = [];
|
|
15025
|
+
for (const task of state.tasks) {
|
|
15026
|
+
const markers = (task.evidence ?? []).filter(
|
|
15027
|
+
(entry) => entry.type === "text" && entry.summary !== void 0 && entry.summary.startsWith("adopted outside harness")
|
|
15028
|
+
);
|
|
15029
|
+
if (markers.length === 0) continue;
|
|
15030
|
+
const hasValidAt = markers.some((entry) => {
|
|
15031
|
+
if (entry.at === void 0) return false;
|
|
15032
|
+
return !Number.isNaN(Date.parse(entry.at));
|
|
15033
|
+
});
|
|
15034
|
+
const baseAdopted = task.source === "user" || (task.evidence ?? []).some(
|
|
15035
|
+
(entry) => entry.type === "text" && entry.summary !== void 0 && entry.summary.startsWith("adopted outside harness")
|
|
15036
|
+
);
|
|
15037
|
+
if (baseAdopted && !hasValidAt) {
|
|
15038
|
+
unusableAdopted.push(task.ref);
|
|
15039
|
+
}
|
|
15040
|
+
}
|
|
15041
|
+
const candidates = [];
|
|
15042
|
+
const deferred = [];
|
|
15043
|
+
for (const task of state.tasks) {
|
|
15044
|
+
if (!isStaleAdoption(task)) continue;
|
|
15045
|
+
const checkpointPending = state.current?.ref === task.ref && state.current.awaitingCheckpoint === true;
|
|
15046
|
+
const exhausted = isExhausted(journal, task.ref);
|
|
15047
|
+
if (checkpointPending || exhausted) {
|
|
15048
|
+
deferred.push(task.ref);
|
|
15049
|
+
continue;
|
|
15050
|
+
}
|
|
15051
|
+
candidates.push(task.ref);
|
|
15052
|
+
}
|
|
15053
|
+
if (candidates.length > 0) {
|
|
15054
|
+
const detailParts = [
|
|
15055
|
+
`Task stale adoption (verified exit 0 lebih baru): ${candidates.join(", ")}`
|
|
15056
|
+
];
|
|
15057
|
+
if (deferred.length > 0) detailParts.push(`ditunda: ${deferred.join(", ")}`);
|
|
15058
|
+
if (unusableAdopted.length > 0)
|
|
15059
|
+
detailParts.push(`tanpa timestamp: ${unusableAdopted.join(", ")}`);
|
|
15060
|
+
return makeCheck(
|
|
15061
|
+
"stale-adoption",
|
|
15062
|
+
"warn",
|
|
15063
|
+
`${detailParts.join("; ")}. Jalankan \`jioogen doctor --fix\`.`,
|
|
15064
|
+
true
|
|
15065
|
+
);
|
|
15066
|
+
}
|
|
15067
|
+
if (deferred.length > 0 || unusableAdopted.length > 0) {
|
|
15068
|
+
const refs = [...deferred, ...unusableAdopted];
|
|
15069
|
+
return makeCheck(
|
|
15070
|
+
"stale-adoption",
|
|
15071
|
+
"warn",
|
|
15072
|
+
`Stale adoption tertunda/tidak dapat diperbaiki: ${refs.join(", ")}.`
|
|
15073
|
+
);
|
|
15074
|
+
}
|
|
15075
|
+
return makeCheck("stale-adoption", "pass", "Tidak ada stale adoption.");
|
|
15076
|
+
}
|
|
14508
15077
|
async function checkDrift(bundleDir) {
|
|
14509
15078
|
try {
|
|
14510
15079
|
const local = await snapshotContract(bundleDir);
|
|
@@ -14552,12 +15121,12 @@ async function checkDrift(bundleDir) {
|
|
|
14552
15121
|
}
|
|
14553
15122
|
}
|
|
14554
15123
|
async function checkRecovery(bundleDir) {
|
|
14555
|
-
const path =
|
|
15124
|
+
const path = join12(contractRoot(bundleDir), "tasks/.execution/recovery.json");
|
|
14556
15125
|
let raw;
|
|
14557
15126
|
try {
|
|
14558
|
-
raw = await
|
|
15127
|
+
raw = await readFile11(path, "utf8");
|
|
14559
15128
|
} catch (error) {
|
|
14560
|
-
if (
|
|
15129
|
+
if (isMissingFile6(error)) {
|
|
14561
15130
|
return makeCheck("recovery", "pass", "Belum ada recovery journal.");
|
|
14562
15131
|
}
|
|
14563
15132
|
return makeCheck("recovery", "warn", "Recovery journal tidak bisa dibaca.");
|
|
@@ -14588,7 +15157,7 @@ async function checkLock(bundleDir) {
|
|
|
14588
15157
|
try {
|
|
14589
15158
|
info = await stat6(target);
|
|
14590
15159
|
} catch (error) {
|
|
14591
|
-
if (
|
|
15160
|
+
if (isMissingFile6(error)) {
|
|
14592
15161
|
return makeCheck("lock", "pass", "Tidak ada lock; sidecar bebas ditulis.");
|
|
14593
15162
|
}
|
|
14594
15163
|
return makeCheck("lock", "warn", `Tidak bisa memeriksa lock: ${errorMessage(error)}.`);
|
|
@@ -14612,9 +15181,9 @@ async function checkLock(bundleDir) {
|
|
|
14612
15181
|
async function checkAgents(bundleDir) {
|
|
14613
15182
|
let content;
|
|
14614
15183
|
try {
|
|
14615
|
-
content = await
|
|
15184
|
+
content = await readFile11(join12(bundleDir, "AGENTS.md"), "utf8");
|
|
14616
15185
|
} catch (error) {
|
|
14617
|
-
if (
|
|
15186
|
+
if (isMissingFile6(error)) {
|
|
14618
15187
|
return makeCheck(
|
|
14619
15188
|
"agents",
|
|
14620
15189
|
"fail",
|
|
@@ -14642,7 +15211,7 @@ async function checkAgents(bundleDir) {
|
|
|
14642
15211
|
async function checkExecutionSkill(bundleDir) {
|
|
14643
15212
|
const missing = [];
|
|
14644
15213
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14645
|
-
const target =
|
|
15214
|
+
const target = join12(bundleDir, dir, EXECUTION_SKILL_NAME, "SKILL.md");
|
|
14646
15215
|
if (!await isFile2(target)) missing.push(dir);
|
|
14647
15216
|
}
|
|
14648
15217
|
if (missing.length > 0) {
|
|
@@ -14690,8 +15259,8 @@ async function checkSkillPacks(bundleDir) {
|
|
|
14690
15259
|
for (const skill of pack.skills) {
|
|
14691
15260
|
let matched = false;
|
|
14692
15261
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14693
|
-
const target =
|
|
14694
|
-
if (!await isFile2(
|
|
15262
|
+
const target = join12(bundleDir, dir, skill.name);
|
|
15263
|
+
if (!await isFile2(join12(target, "SKILL.md"))) continue;
|
|
14695
15264
|
try {
|
|
14696
15265
|
if (await hashSkillDirectory(target) === skill.sha256) {
|
|
14697
15266
|
matched = true;
|
|
@@ -14738,7 +15307,7 @@ function capabilityModelNotRequired(content) {
|
|
|
14738
15307
|
return notRequired;
|
|
14739
15308
|
}
|
|
14740
15309
|
async function collectMarkdownFiles2(root, prefix = "") {
|
|
14741
|
-
const dir =
|
|
15310
|
+
const dir = join12(root, prefix);
|
|
14742
15311
|
let entries;
|
|
14743
15312
|
try {
|
|
14744
15313
|
entries = await readdir7(dir, { withFileTypes: true });
|
|
@@ -14758,7 +15327,7 @@ async function checkCapabilityCoverage(bundleDir) {
|
|
|
14758
15327
|
const taskCaps = /* @__PURE__ */ new Map();
|
|
14759
15328
|
for (const relative3 of await collectMarkdownFiles2(contract, "tasks")) {
|
|
14760
15329
|
if (relative3 === BUNDLE_PATHS.TASKS_INDEX) continue;
|
|
14761
|
-
const content = await
|
|
15330
|
+
const content = await readFile11(join12(contract, relative3), "utf8");
|
|
14762
15331
|
const cap = TASK_CAP_RE.exec(content)?.[1]?.toUpperCase();
|
|
14763
15332
|
if (cap === void 0) continue;
|
|
14764
15333
|
taskCaps.set(cap, relative3);
|
|
@@ -14766,7 +15335,7 @@ async function checkCapabilityCoverage(bundleDir) {
|
|
|
14766
15335
|
const specCaps = /* @__PURE__ */ new Set();
|
|
14767
15336
|
const notRequiredCaps = /* @__PURE__ */ new Set();
|
|
14768
15337
|
for (const relative3 of await collectMarkdownFiles2(contract, "specs")) {
|
|
14769
|
-
const content = await
|
|
15338
|
+
const content = await readFile11(join12(contract, relative3), "utf8");
|
|
14770
15339
|
for (const match of content.matchAll(CAP_ID_RE)) {
|
|
14771
15340
|
const id = match[0].toUpperCase();
|
|
14772
15341
|
if (CAP_PLACEHOLDER_RE.test(id)) continue;
|
|
@@ -14817,7 +15386,7 @@ async function checkDuplicates(bundleDir) {
|
|
|
14817
15386
|
}
|
|
14818
15387
|
const dirsByName = /* @__PURE__ */ new Map();
|
|
14819
15388
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14820
|
-
const root =
|
|
15389
|
+
const root = join12(bundleDir, dir);
|
|
14821
15390
|
if (!await isDirectory2(root)) continue;
|
|
14822
15391
|
let entries;
|
|
14823
15392
|
try {
|
|
@@ -14828,7 +15397,7 @@ async function checkDuplicates(bundleDir) {
|
|
|
14828
15397
|
for (const entry of entries) {
|
|
14829
15398
|
if (!entry.isDirectory()) continue;
|
|
14830
15399
|
if (managed.has(entry.name)) continue;
|
|
14831
|
-
if (!await isFile2(
|
|
15400
|
+
if (!await isFile2(join12(root, entry.name, "SKILL.md"))) continue;
|
|
14832
15401
|
const owners = dirsByName.get(entry.name) ?? [];
|
|
14833
15402
|
owners.push(dir);
|
|
14834
15403
|
dirsByName.set(entry.name, owners);
|
|
@@ -14848,7 +15417,7 @@ async function checkDuplicates(bundleDir) {
|
|
|
14848
15417
|
async function checkHarness(bundleDir) {
|
|
14849
15418
|
const detected = [];
|
|
14850
15419
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14851
|
-
if (await isDirectory2(
|
|
15420
|
+
if (await isDirectory2(join12(bundleDir, dir))) detected.push(dir);
|
|
14852
15421
|
}
|
|
14853
15422
|
if (detected.length === 0) {
|
|
14854
15423
|
return makeCheck("harness", "pass", "Tidak ada direktori harness terdeteksi.");
|
|
@@ -14887,6 +15456,7 @@ async function runChecks(options, deps) {
|
|
|
14887
15456
|
checks.push(await checkProject(deps, credentials, effectiveProjectId));
|
|
14888
15457
|
checks.push(await checkBundle(options.bundleDir));
|
|
14889
15458
|
checks.push(await checkSidecar(options.bundleDir));
|
|
15459
|
+
checks.push(await checkStaleAdoption(options.bundleDir));
|
|
14890
15460
|
checks.push(await checkDrift(options.bundleDir));
|
|
14891
15461
|
checks.push(await checkLock(options.bundleDir));
|
|
14892
15462
|
checks.push(await checkRecovery(options.bundleDir));
|
|
@@ -14902,7 +15472,7 @@ async function applyFixes(options, deps, checks) {
|
|
|
14902
15472
|
let changed = false;
|
|
14903
15473
|
if (checks.some((check) => check.id === "lock" && check.fixable === true)) {
|
|
14904
15474
|
try {
|
|
14905
|
-
await
|
|
15475
|
+
await rm8(lockPath(options.bundleDir), { force: true });
|
|
14906
15476
|
changed = true;
|
|
14907
15477
|
} catch {
|
|
14908
15478
|
}
|
|
@@ -14917,6 +15487,44 @@ async function applyFixes(options, deps, checks) {
|
|
|
14917
15487
|
} catch {
|
|
14918
15488
|
}
|
|
14919
15489
|
}
|
|
15490
|
+
if (checks.some((check) => check.id === "stale-adoption" && check.fixable === true)) {
|
|
15491
|
+
try {
|
|
15492
|
+
let sidecarRepaired = false;
|
|
15493
|
+
await withStateLock(options.bundleDir, async () => {
|
|
15494
|
+
const state = await readState(options.bundleDir);
|
|
15495
|
+
if (state === null) return;
|
|
15496
|
+
const strictJournal = await readRecoveryStrict(options.bundleDir);
|
|
15497
|
+
if (strictJournal === null) return;
|
|
15498
|
+
const journal = strictJournal;
|
|
15499
|
+
let working = state;
|
|
15500
|
+
let localChanged = false;
|
|
15501
|
+
for (const task of state.tasks) {
|
|
15502
|
+
const checkpointPending = state.current?.ref === task.ref && state.current.awaitingCheckpoint === true;
|
|
15503
|
+
if (!isStaleAdoption(task)) continue;
|
|
15504
|
+
if (checkpointPending) continue;
|
|
15505
|
+
if (isExhausted(journal, task.ref)) continue;
|
|
15506
|
+
const next = supersedeStaleAdoption(working, task.ref, /* @__PURE__ */ new Date());
|
|
15507
|
+
if (next !== working) {
|
|
15508
|
+
working = next;
|
|
15509
|
+
localChanged = true;
|
|
15510
|
+
}
|
|
15511
|
+
}
|
|
15512
|
+
if (localChanged) {
|
|
15513
|
+
await writeState(options.bundleDir, working);
|
|
15514
|
+
changed = true;
|
|
15515
|
+
sidecarRepaired = true;
|
|
15516
|
+
}
|
|
15517
|
+
});
|
|
15518
|
+
if (sidecarRepaired) {
|
|
15519
|
+
try {
|
|
15520
|
+
await deps.publishSidecar?.(options.bundleDir);
|
|
15521
|
+
} catch {
|
|
15522
|
+
console.warn("Status tersimpan lokal; jalankan `jioogen sync`");
|
|
15523
|
+
}
|
|
15524
|
+
}
|
|
15525
|
+
} catch {
|
|
15526
|
+
}
|
|
15527
|
+
}
|
|
14920
15528
|
return changed;
|
|
14921
15529
|
}
|
|
14922
15530
|
async function runDoctor(options) {
|
|
@@ -14943,150 +15551,6 @@ function formatTable(headers, rows) {
|
|
|
14943
15551
|
return [render(headers), divider, ...rows.map(render)].join("\n");
|
|
14944
15552
|
}
|
|
14945
15553
|
|
|
14946
|
-
// src/recovery.ts
|
|
14947
|
-
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
14948
|
-
import { mkdir as mkdir8, readFile as readFile11, rename as rename3, rm as rm8, writeFile as writeFile8 } from "node:fs/promises";
|
|
14949
|
-
import { dirname as dirname7, join as join12 } from "node:path";
|
|
14950
|
-
var RECOVERY_PATH = "tasks/.execution/recovery.json";
|
|
14951
|
-
var RECOVERY_BUDGET = { maxAttempts: 3 };
|
|
14952
|
-
var RECOVERY_BASE_ATTEMPTS = 3;
|
|
14953
|
-
var RECOVERY_MAX_ATTEMPTS = 6;
|
|
14954
|
-
function recoveryBudget(input) {
|
|
14955
|
-
let budget = RECOVERY_BASE_ATTEMPTS;
|
|
14956
|
-
if (input.failureClass === "transient") budget += 1;
|
|
14957
|
-
if (input.failureClass === "semantic") budget += 1;
|
|
14958
|
-
return Math.min(budget, RECOVERY_MAX_ATTEMPTS);
|
|
14959
|
-
}
|
|
14960
|
-
function recoveryPath(bundleDir) {
|
|
14961
|
-
return join12(bundleDir, RECOVERY_PATH);
|
|
14962
|
-
}
|
|
14963
|
-
function emptyJournal() {
|
|
14964
|
-
return { schemaVersion: 1, tasks: {} };
|
|
14965
|
-
}
|
|
14966
|
-
function isJournal(value) {
|
|
14967
|
-
if (typeof value !== "object" || value === null) return false;
|
|
14968
|
-
const obj = value;
|
|
14969
|
-
if (obj.schemaVersion !== 1) return false;
|
|
14970
|
-
if (typeof obj.tasks !== "object" || obj.tasks === null) return false;
|
|
14971
|
-
return true;
|
|
14972
|
-
}
|
|
14973
|
-
async function readRecovery(bundleDir) {
|
|
14974
|
-
let raw;
|
|
14975
|
-
try {
|
|
14976
|
-
raw = await readFile11(recoveryPath(bundleDir), "utf8");
|
|
14977
|
-
} catch {
|
|
14978
|
-
return emptyJournal();
|
|
14979
|
-
}
|
|
14980
|
-
let payload;
|
|
14981
|
-
try {
|
|
14982
|
-
payload = JSON.parse(raw);
|
|
14983
|
-
} catch {
|
|
14984
|
-
return emptyJournal();
|
|
14985
|
-
}
|
|
14986
|
-
if (!isJournal(payload)) return emptyJournal();
|
|
14987
|
-
return payload;
|
|
14988
|
-
}
|
|
14989
|
-
function classifyFailure(input) {
|
|
14990
|
-
if (input.stalled === true || input.timedOut === true) return "transient";
|
|
14991
|
-
if (input.verificationFailed === true) return "semantic";
|
|
14992
|
-
const note = input.note ?? "";
|
|
14993
|
-
if (/^AUTHORIZATION:/i.test(note.trim())) return "authorization";
|
|
14994
|
-
if (/timeout|stall|econn|rate limit|\b429\b|\b5\d\d\b/i.test(note)) return "transient";
|
|
14995
|
-
const prior = input.prior ?? null;
|
|
14996
|
-
if (prior !== null && prior.attempts >= 1 && note === prior.lastNote) return "no_progress";
|
|
14997
|
-
return "semantic";
|
|
14998
|
-
}
|
|
14999
|
-
async function writeRecovery(bundleDir, journal) {
|
|
15000
|
-
const target = recoveryPath(bundleDir);
|
|
15001
|
-
await mkdir8(dirname7(target), { recursive: true });
|
|
15002
|
-
const temp = `${target}.${process.pid}.${randomUUID2()}.tmp`;
|
|
15003
|
-
try {
|
|
15004
|
-
await writeFile8(temp, `${JSON.stringify(journal, null, 2)}
|
|
15005
|
-
`, "utf8");
|
|
15006
|
-
await rename3(temp, target);
|
|
15007
|
-
} catch (error) {
|
|
15008
|
-
await rm8(temp, { force: true }).catch(() => {
|
|
15009
|
-
});
|
|
15010
|
-
throw error;
|
|
15011
|
-
}
|
|
15012
|
-
}
|
|
15013
|
-
async function recordFailure(bundleDir, ref, args) {
|
|
15014
|
-
return withStateLock(bundleDir, async () => {
|
|
15015
|
-
const journal = await readRecovery(bundleDir);
|
|
15016
|
-
const prior = journal.tasks[ref] ?? null;
|
|
15017
|
-
const klass = classifyFailure({ ...args, prior });
|
|
15018
|
-
const attempt = (prior?.attempts ?? 0) + 1;
|
|
15019
|
-
const budget = recoveryBudget({
|
|
15020
|
-
failureClass: klass,
|
|
15021
|
-
priorAttempts: prior?.attempts ?? 0,
|
|
15022
|
-
priorClass: prior?.lastClass ?? null
|
|
15023
|
-
});
|
|
15024
|
-
const exhausted = attempt >= budget;
|
|
15025
|
-
const resumable = exhausted;
|
|
15026
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
15027
|
-
const note = args.note ?? "";
|
|
15028
|
-
const history = [...prior?.history ?? []];
|
|
15029
|
-
history.push({ attempt, class: klass, note, at: now });
|
|
15030
|
-
const capped = history.length > 20 ? history.slice(history.length - 20) : history;
|
|
15031
|
-
const entry = {
|
|
15032
|
-
ref,
|
|
15033
|
-
attempts: attempt,
|
|
15034
|
-
exhausted,
|
|
15035
|
-
resumable,
|
|
15036
|
-
lastClass: klass,
|
|
15037
|
-
lastNote: note === "" ? prior?.lastNote ?? "" : note,
|
|
15038
|
-
history: capped,
|
|
15039
|
-
updatedAt: now
|
|
15040
|
-
};
|
|
15041
|
-
journal.tasks[ref] = entry;
|
|
15042
|
-
await writeRecovery(bundleDir, journal);
|
|
15043
|
-
return { entry, exhausted, class: klass, attempt };
|
|
15044
|
-
});
|
|
15045
|
-
}
|
|
15046
|
-
async function recordSuccess(bundleDir, ref) {
|
|
15047
|
-
await withStateLock(bundleDir, async () => {
|
|
15048
|
-
const journal = await readRecovery(bundleDir);
|
|
15049
|
-
if (journal.tasks[ref] !== void 0) {
|
|
15050
|
-
delete journal.tasks[ref];
|
|
15051
|
-
await writeRecovery(bundleDir, journal);
|
|
15052
|
-
}
|
|
15053
|
-
});
|
|
15054
|
-
}
|
|
15055
|
-
async function rearmTask(bundleDir, ref) {
|
|
15056
|
-
await withStateLock(bundleDir, async () => {
|
|
15057
|
-
const journal = await readRecovery(bundleDir);
|
|
15058
|
-
const prior = journal.tasks[ref];
|
|
15059
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
15060
|
-
const entry = {
|
|
15061
|
-
ref,
|
|
15062
|
-
attempts: 0,
|
|
15063
|
-
exhausted: false,
|
|
15064
|
-
resumable: true,
|
|
15065
|
-
lastClass: prior?.lastClass ?? null,
|
|
15066
|
-
lastNote: prior?.lastNote ?? "",
|
|
15067
|
-
history: prior?.history ?? [],
|
|
15068
|
-
updatedAt: now
|
|
15069
|
-
};
|
|
15070
|
-
journal.tasks[ref] = entry;
|
|
15071
|
-
await writeRecovery(bundleDir, journal);
|
|
15072
|
-
});
|
|
15073
|
-
}
|
|
15074
|
-
function isExhausted(journal, ref) {
|
|
15075
|
-
return journal.tasks[ref]?.exhausted === true;
|
|
15076
|
-
}
|
|
15077
|
-
function describeRecovery(entry) {
|
|
15078
|
-
if (entry === void 0) {
|
|
15079
|
-
return "No recovery record. Run `jioogen resume`, then retry with a different approach.";
|
|
15080
|
-
}
|
|
15081
|
-
const lines = [];
|
|
15082
|
-
lines.push(
|
|
15083
|
-
`Task ${entry.ref}: ${entry.attempts}/${RECOVERY_BUDGET.maxAttempts} attempts, last=${entry.lastClass ?? "none"}.`
|
|
15084
|
-
);
|
|
15085
|
-
if (entry.lastNote.length > 0) lines.push(`Last note: ${entry.lastNote}`);
|
|
15086
|
-
lines.push("Run `jioogen resume`, then retry with a different approach.");
|
|
15087
|
-
return lines.join("\n");
|
|
15088
|
-
}
|
|
15089
|
-
|
|
15090
15554
|
// src/session.ts
|
|
15091
15555
|
import { rm as rm9, stat as stat7 } from "node:fs/promises";
|
|
15092
15556
|
import { resolve as resolve4 } from "node:path";
|
|
@@ -15243,7 +15707,7 @@ async function removeStaleLock2(bundleDir) {
|
|
|
15243
15707
|
try {
|
|
15244
15708
|
info = await stat7(target);
|
|
15245
15709
|
} catch (error) {
|
|
15246
|
-
if (
|
|
15710
|
+
if (isMissingFile7(error)) return;
|
|
15247
15711
|
throw error;
|
|
15248
15712
|
}
|
|
15249
15713
|
if (Date.now() - info.mtimeMs <= LOCK_STALE_MS3) return;
|
|
@@ -15255,14 +15719,14 @@ function envFirst(primary, legacy) {
|
|
|
15255
15719
|
const fallback = process.env[legacy]?.trim();
|
|
15256
15720
|
return fallback !== void 0 && fallback.length > 0 ? fallback : void 0;
|
|
15257
15721
|
}
|
|
15258
|
-
function
|
|
15722
|
+
function isMissingFile7(error) {
|
|
15259
15723
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
15260
15724
|
}
|
|
15261
15725
|
|
|
15262
15726
|
// src/zip.ts
|
|
15263
15727
|
var import_adm_zip = __toESM(require_adm_zip(), 1);
|
|
15264
|
-
import { mkdir as
|
|
15265
|
-
import { dirname as
|
|
15728
|
+
import { mkdir as mkdir10, writeFile as writeFile10 } from "node:fs/promises";
|
|
15729
|
+
import { dirname as dirname9, resolve as resolve5, sep } from "node:path";
|
|
15266
15730
|
var IGNORED_PREFIXES = [
|
|
15267
15731
|
".git/",
|
|
15268
15732
|
"node_modules/",
|
|
@@ -15303,10 +15767,10 @@ async function extractBundle(bytes, targetDir) {
|
|
|
15303
15767
|
if (!destination.startsWith(`${root}${sep}`)) {
|
|
15304
15768
|
throw new Error(`Path bundle keluar dari direktori target: ${entry.entryName}`);
|
|
15305
15769
|
}
|
|
15306
|
-
await
|
|
15770
|
+
await mkdir10(dirname9(destination), { recursive: true });
|
|
15307
15771
|
const raw = entry.getData();
|
|
15308
15772
|
const data = relative3.endsWith(".md") ? Buffer.from(sanitizeMarkdown(raw.toString("utf8")), "utf8") : raw;
|
|
15309
|
-
await
|
|
15773
|
+
await writeFile10(destination, data);
|
|
15310
15774
|
written.push(relative3);
|
|
15311
15775
|
}
|
|
15312
15776
|
return written;
|
|
@@ -15923,7 +16387,18 @@ async function doctorCommand(options) {
|
|
|
15923
16387
|
const report = await runDoctor({
|
|
15924
16388
|
bundleDir,
|
|
15925
16389
|
...projectId === void 0 ? {} : { projectId },
|
|
15926
|
-
fix: options.fix === true
|
|
16390
|
+
fix: options.fix === true,
|
|
16391
|
+
deps: {
|
|
16392
|
+
publishSidecar: async (bd) => {
|
|
16393
|
+
const pid = projectId ?? link?.projectId;
|
|
16394
|
+
if (pid === void 0) return;
|
|
16395
|
+
await pushSidecarBestEffort(options, {
|
|
16396
|
+
projectId: pid,
|
|
16397
|
+
bundleDir: bd,
|
|
16398
|
+
linkedApiUrl: link?.apiUrl
|
|
16399
|
+
});
|
|
16400
|
+
}
|
|
16401
|
+
}
|
|
15927
16402
|
});
|
|
15928
16403
|
if (options.json === true) {
|
|
15929
16404
|
console.log(JSON.stringify(report, null, 2));
|
|
@@ -16200,55 +16675,18 @@ async function taskExpandCommand(ref, options) {
|
|
|
16200
16675
|
);
|
|
16201
16676
|
if (definition === void 0) throw new Error(`Task ${ref} tidak ditemukan.`);
|
|
16202
16677
|
const cap = /^\s*cap:\s*(CAP-[A-Z0-9-]+)/im.exec(definition.content)?.[1];
|
|
16203
|
-
const breakdown = buildTaskBreakdown(definition);
|
|
16204
|
-
const authored = breakdown.authored;
|
|
16205
|
-
const items = authored.length > 0 ? authored : breakdown.derived;
|
|
16206
|
-
if (items.length === 0) {
|
|
16207
|
-
console.log(
|
|
16208
|
-
`Task ${definition.id} belum punya metadata breakdown. Tambahkan \`subtasks\`, \`acceptance\`, atau \`targetFiles\`.`
|
|
16209
|
-
);
|
|
16210
|
-
return;
|
|
16211
|
-
}
|
|
16212
|
-
const prefix = authored.length > 0 ? "SUB" : "BD";
|
|
16213
|
-
const section3 = `## ${authored.length > 0 ? "Subtasks" : "Breakdown"}
|
|
16214
|
-
|
|
16215
|
-
${items.map((item, index) => `- [ ] ${prefix}-${String(index + 1).padStart(2, "0")} \u2014 ${item}`).join("\n")}
|
|
16216
|
-
`;
|
|
16217
16678
|
console.log(`Task ${definition.id} \u2014 ${definition.title}`);
|
|
16218
16679
|
if (cap !== void 0) console.log(`CAP: ${cap}`);
|
|
16219
|
-
console.log(
|
|
16680
|
+
console.log(renderBreakdownScaffold(definition));
|
|
16220
16681
|
if (options.write !== true) {
|
|
16221
16682
|
console.log(
|
|
16222
|
-
"Preview saja. Tambahkan `--write` untuk menyimpan checklist
|
|
16223
|
-
);
|
|
16224
|
-
return;
|
|
16225
|
-
}
|
|
16226
|
-
if (authored.length > 0) {
|
|
16227
|
-
const path2 = join13(contractRoot(local.bundleDir), "tasks", definition.file);
|
|
16228
|
-
const current = await readFile12(path2, "utf8");
|
|
16229
|
-
const stripped = current.replace(/\n##\s+Subtasks\b[\s\S]*?(?=\n##\s|$)/i, "").replace(/\n{3,}/g, "\n\n");
|
|
16230
|
-
await writeFile10(path2, `${stripped.trimEnd()}
|
|
16231
|
-
|
|
16232
|
-
${section3}`, "utf8");
|
|
16233
|
-
console.log(
|
|
16234
|
-
`Ditulis ke tasks/${definition.file}. Parent task tetap satu; checklist tidak menambah task count.`
|
|
16683
|
+
"Preview saja. Tambahkan `--write` untuk menyimpan checklist ke `.jioogen/breakdown/<ref>.md`."
|
|
16235
16684
|
);
|
|
16236
16685
|
return;
|
|
16237
16686
|
}
|
|
16238
|
-
const
|
|
16239
|
-
const path = join13(dir, `${definition.id}.md`);
|
|
16240
|
-
await mkdir10(dir, { recursive: true });
|
|
16241
|
-
await writeFile10(
|
|
16242
|
-
path,
|
|
16243
|
-
`# Breakdown ${definition.id} \u2014 ${definition.title}
|
|
16244
|
-
|
|
16245
|
-
${section3}
|
|
16246
|
-
> Scaffold deterministik dari metadata task. Boleh ditambah detail, tapi item di atas tidak boleh dilewati.
|
|
16247
|
-
`,
|
|
16248
|
-
"utf8"
|
|
16249
|
-
);
|
|
16687
|
+
const path = await ensureBreakdownScaffold(local.bundleDir, definition);
|
|
16250
16688
|
console.log(
|
|
16251
|
-
`
|
|
16689
|
+
`Checklist siap di .jioogen/breakdown/${definition.id}.md (${path}). File kontrak tasks/*.md tidak disentuh; task count tidak berubah.`
|
|
16252
16690
|
);
|
|
16253
16691
|
}
|
|
16254
16692
|
async function taskStartCommand(ref, options) {
|
|
@@ -16275,8 +16713,8 @@ async function taskStartCommand(ref, options) {
|
|
|
16275
16713
|
const ledger = await readContractLedger(local.bundleDir);
|
|
16276
16714
|
const pinned = ledger?.server?.revision;
|
|
16277
16715
|
if (pinned !== void 0 && pinned !== null) updated.revision = pinned;
|
|
16278
|
-
await writeState(local.bundleDir, updated);
|
|
16279
16716
|
const definition = local.definitions.find((entry) => entry.id.toUpperCase() === key);
|
|
16717
|
+
await writeState(local.bundleDir, updated);
|
|
16280
16718
|
if (definition !== void 0) {
|
|
16281
16719
|
await captureTaskBaseline(local.bundleDir, definition).catch(() => {
|
|
16282
16720
|
});
|
|
@@ -16286,54 +16724,68 @@ async function taskStartCommand(ref, options) {
|
|
|
16286
16724
|
context: local
|
|
16287
16725
|
};
|
|
16288
16726
|
});
|
|
16727
|
+
const startedDefinition = context.definitions.find((entry) => entry.id.toUpperCase() === key);
|
|
16728
|
+
if (startedDefinition !== void 0) {
|
|
16729
|
+
await ensureBreakdownScaffold(context.bundleDir, startedDefinition);
|
|
16730
|
+
}
|
|
16289
16731
|
await pushSidecarBestEffort(options, context);
|
|
16290
|
-
console.log(
|
|
16732
|
+
console.log(
|
|
16733
|
+
`Started ${task?.ref ?? ref} (attempt ${task?.attempt ?? 1}). Checklist: .jioogen/breakdown/${task?.ref ?? ref}.md`
|
|
16734
|
+
);
|
|
16291
16735
|
}
|
|
16292
16736
|
async function finishTask(ref, options, extra = {}) {
|
|
16293
16737
|
return withLocalState(options, async (local) => {
|
|
16738
|
+
const adopted = extra.source !== void 0;
|
|
16294
16739
|
const resolvedState = await resolveOrAssertDependencies(
|
|
16295
16740
|
ref,
|
|
16296
16741
|
local.definitions,
|
|
16297
16742
|
local.state,
|
|
16298
16743
|
local.bundleDir,
|
|
16299
16744
|
options,
|
|
16300
|
-
"complete"
|
|
16745
|
+
"complete",
|
|
16746
|
+
adopted ? {} : { autoAdopt: false, allowForce: false }
|
|
16301
16747
|
);
|
|
16302
16748
|
const key = ref.trim().toUpperCase();
|
|
16303
16749
|
const definition = local.definitions.find((entry) => entry.id.toUpperCase() === key);
|
|
16304
|
-
|
|
16750
|
+
if (definition === void 0) {
|
|
16751
|
+
throw new Error(`Task ${ref} tidak ditemukan di bundle.`);
|
|
16752
|
+
}
|
|
16305
16753
|
const stateTask = resolvedState.tasks.find((entry) => entry.ref.toUpperCase() === key);
|
|
16306
|
-
if (
|
|
16307
|
-
|
|
16308
|
-
|
|
16309
|
-
|
|
16310
|
-
|
|
16311
|
-
|
|
16312
|
-
|
|
16313
|
-
|
|
16314
|
-
const expectedCommand = normalizeVerificationCommand(verificationCommand);
|
|
16315
|
-
const commandMatches = proofCommand !== void 0 && (proofCommand === expectedCommand || options.lenient === true);
|
|
16316
|
-
if (proof === void 0 || proof.exitCode !== 0 || !commandMatches) {
|
|
16317
|
-
throw new Error(`Task ${ref} belum diverifikasi. Jalankan \`jioogen task verify ${ref}\`.`);
|
|
16318
|
-
}
|
|
16319
|
-
if (stateTask?.designReview?.passed === false) {
|
|
16320
|
-
throw new Error(
|
|
16321
|
-
`Task ${ref} punya design review yang gagal. Perbaiki lalu verifikasi ulang dengan \`jioogen task verify ${ref} --visual "<catatan>"\`.`
|
|
16322
|
-
);
|
|
16323
|
-
}
|
|
16324
|
-
} else {
|
|
16325
|
-
if (verificationCommand !== null) {
|
|
16754
|
+
if (adopted) {
|
|
16755
|
+
const verificationCommand = verificationCommandFromContent(definition.content);
|
|
16756
|
+
if (options.force !== true) {
|
|
16757
|
+
if (verificationCommand === null) {
|
|
16758
|
+
throw new Error(
|
|
16759
|
+
`Task ${ref} tidak punya verificationCommand. Gunakan --force untuk jalur legacy.`
|
|
16760
|
+
);
|
|
16761
|
+
}
|
|
16326
16762
|
const proof = stateTask?.verification;
|
|
16327
|
-
|
|
16328
|
-
|
|
16329
|
-
|
|
16330
|
-
|
|
16763
|
+
if (proof === void 0 || proof.exitCode !== 0) {
|
|
16764
|
+
throw new Error(
|
|
16765
|
+
`Task ${ref} belum diverifikasi. Jalankan \`jioogen task adopt ${ref}\`.`
|
|
16766
|
+
);
|
|
16331
16767
|
}
|
|
16332
16768
|
if (stateTask?.designReview?.passed === false) {
|
|
16333
|
-
|
|
16769
|
+
throw new Error(
|
|
16770
|
+
`Task ${ref} punya design review yang gagal. Perbaiki lalu verifikasi ulang dengan \`jioogen task verify ${ref} --visual "<catatan>"\`.`
|
|
16771
|
+
);
|
|
16334
16772
|
}
|
|
16335
|
-
}
|
|
16336
|
-
|
|
16773
|
+
}
|
|
16774
|
+
} else {
|
|
16775
|
+
await ensureBreakdownScaffold(local.bundleDir, definition);
|
|
16776
|
+
const gate = await evaluateCompletionGate({
|
|
16777
|
+
bundleDir: local.bundleDir,
|
|
16778
|
+
definition,
|
|
16779
|
+
stateTask,
|
|
16780
|
+
definitions: local.definitions,
|
|
16781
|
+
state: resolvedState,
|
|
16782
|
+
lenient: options.lenient
|
|
16783
|
+
});
|
|
16784
|
+
if (!gate.ok) {
|
|
16785
|
+
if (options.force === true) {
|
|
16786
|
+
console.warn("Warning: --force tidak melewati gate completion task.");
|
|
16787
|
+
}
|
|
16788
|
+
throw new Error(formatCompletionGateFailure(ref, gate));
|
|
16337
16789
|
}
|
|
16338
16790
|
}
|
|
16339
16791
|
let completed = withStatus(resolvedState, ref, "done", {
|
|
@@ -17202,7 +17654,7 @@ function unmetDependencies(ref, definitions, states) {
|
|
|
17202
17654
|
(dependency) => byRef.get(dependency.toUpperCase())?.status !== "done"
|
|
17203
17655
|
);
|
|
17204
17656
|
}
|
|
17205
|
-
async function resolveOrAssertDependencies(ref, definitions, state, bundleDir, options, action) {
|
|
17657
|
+
async function resolveOrAssertDependencies(ref, definitions, state, bundleDir, options, action, policy = {}) {
|
|
17206
17658
|
const key = ref.toUpperCase();
|
|
17207
17659
|
const definition = definitions.find((task) => task.id.toUpperCase() === key);
|
|
17208
17660
|
if (definition === void 0) return state;
|
|
@@ -17213,7 +17665,7 @@ async function resolveOrAssertDependencies(ref, definitions, state, bundleDir, o
|
|
|
17213
17665
|
for (const depId of missing) {
|
|
17214
17666
|
const depDef = definitions.find((task) => task.id.toUpperCase() === depId.toUpperCase());
|
|
17215
17667
|
const filesExist = depDef !== void 0 ? await taskTargetFilesExist(bundleDir, depDef) : false;
|
|
17216
|
-
if (options.lenient === true || filesExist) {
|
|
17668
|
+
if (policy.autoAdopt !== false && (options.lenient === true || filesExist)) {
|
|
17217
17669
|
const reason = filesExist ? `target files terdeteksi di disk (diperlukan oleh ${ref})` : `auto-adopted via --lenient (diperlukan oleh ${ref})`;
|
|
17218
17670
|
currentState = withStatus(currentState, depId, "done", {
|
|
17219
17671
|
note: reason,
|
|
@@ -17232,10 +17684,11 @@ async function resolveOrAssertDependencies(ref, definitions, state, bundleDir, o
|
|
|
17232
17684
|
stillMissing.push(depId);
|
|
17233
17685
|
}
|
|
17234
17686
|
}
|
|
17235
|
-
if (stillMissing.length > 0 && options.force !== true) {
|
|
17687
|
+
if (stillMissing.length > 0 && (options.force !== true || policy.allowForce === false)) {
|
|
17236
17688
|
const verb = action === "start" ? "memulai" : action === "adopt" ? "mengadopsi" : "menyelesaikan";
|
|
17689
|
+
const hint = policy.allowForce === false ? "Dependency itu harus selesai lewat harness dan terverifikasi; `--force`/`--lenient` tidak berlaku untuk `task complete`." : "Selesaikan dependency itu lebih dulu, atau gunakan --lenient / --force bila disengaja.";
|
|
17237
17690
|
throw new Error(
|
|
17238
|
-
`Tidak bisa ${verb} ${ref}: dependency belum selesai (${stillMissing.join(", ")}).
|
|
17691
|
+
`Tidak bisa ${verb} ${ref}: dependency belum selesai (${stillMissing.join(", ")}). ${hint}`
|
|
17239
17692
|
);
|
|
17240
17693
|
}
|
|
17241
17694
|
return currentState;
|
|
@@ -17253,7 +17706,7 @@ async function assertPullTarget(target, projectId, force = false) {
|
|
|
17253
17706
|
try {
|
|
17254
17707
|
entries = await readdir8(target);
|
|
17255
17708
|
} catch (error) {
|
|
17256
|
-
if (
|
|
17709
|
+
if (isMissingFile8(error)) return;
|
|
17257
17710
|
throw error;
|
|
17258
17711
|
}
|
|
17259
17712
|
if (entries.length === 0) return;
|
|
@@ -17288,7 +17741,7 @@ async function hasBundleMarkers(target) {
|
|
|
17288
17741
|
await readFile12(join13(contractRoot(target), "PRD.md"));
|
|
17289
17742
|
return true;
|
|
17290
17743
|
} catch (error) {
|
|
17291
|
-
if (!
|
|
17744
|
+
if (!isMissingFile8(error)) throw error;
|
|
17292
17745
|
}
|
|
17293
17746
|
return hasTaskMarkdown(join13(contractRoot(target), "tasks"));
|
|
17294
17747
|
}
|
|
@@ -17297,7 +17750,7 @@ async function hasTaskMarkdown(directory) {
|
|
|
17297
17750
|
try {
|
|
17298
17751
|
names = await readdir8(directory);
|
|
17299
17752
|
} catch (error) {
|
|
17300
|
-
if (
|
|
17753
|
+
if (isMissingFile8(error)) return false;
|
|
17301
17754
|
throw error;
|
|
17302
17755
|
}
|
|
17303
17756
|
return names.some((name) => name.toLowerCase().endsWith(".md"));
|
|
@@ -17306,9 +17759,9 @@ async function scaffoldCustomLayer(bundleDir) {
|
|
|
17306
17759
|
const stackDir = join13(bundleDir, ".jioogen", "custom", "stack");
|
|
17307
17760
|
const knowledgeDir = join13(bundleDir, ".jioogen", "custom", "knowledge");
|
|
17308
17761
|
const designDir = join13(bundleDir, ".jioogen", "custom", "design");
|
|
17309
|
-
await
|
|
17310
|
-
await
|
|
17311
|
-
await
|
|
17762
|
+
await mkdir11(stackDir, { recursive: true });
|
|
17763
|
+
await mkdir11(knowledgeDir, { recursive: true });
|
|
17764
|
+
await mkdir11(designDir, { recursive: true });
|
|
17312
17765
|
const exampleFile = join13(stackDir, "STACK.md.example");
|
|
17313
17766
|
try {
|
|
17314
17767
|
await stat8(exampleFile);
|
|
@@ -17325,7 +17778,7 @@ async function scaffoldCustomLayer(bundleDir) {
|
|
|
17325
17778
|
"- Testing Runner: Vitest (bukan Jest)",
|
|
17326
17779
|
""
|
|
17327
17780
|
].join("\n");
|
|
17328
|
-
await
|
|
17781
|
+
await writeFile11(exampleFile, template, "utf8").catch(() => {
|
|
17329
17782
|
});
|
|
17330
17783
|
}
|
|
17331
17784
|
}
|
|
@@ -17431,7 +17884,7 @@ function envFirst2(primary, legacy) {
|
|
|
17431
17884
|
const fallback = process.env[legacy]?.trim();
|
|
17432
17885
|
return fallback !== void 0 && fallback.length > 0 ? fallback : void 0;
|
|
17433
17886
|
}
|
|
17434
|
-
function
|
|
17887
|
+
function isMissingFile8(error) {
|
|
17435
17888
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
17436
17889
|
}
|
|
17437
17890
|
async function authoringInstallCommand(options) {
|
|
@@ -17547,7 +18000,7 @@ async function readLine() {
|
|
|
17547
18000
|
}
|
|
17548
18001
|
|
|
17549
18002
|
// src/index.ts
|
|
17550
|
-
var VERSION = "0.
|
|
18003
|
+
var VERSION = "0.3.0";
|
|
17551
18004
|
function parseTaskModeOption(value) {
|
|
17552
18005
|
if (value === void 0) return void 0;
|
|
17553
18006
|
const parsed = TaskModeSchema.safeParse(value);
|
|
@@ -17601,7 +18054,7 @@ Usage:
|
|
|
17601
18054
|
jioogen handoff [--project <id>] [--json]
|
|
17602
18055
|
jioogen task next [--json] [--lenient]
|
|
17603
18056
|
jioogen task start <ref> [--lenient]
|
|
17604
|
-
jioogen task complete <ref> [--note <text>] [--lenient]
|
|
18057
|
+
jioogen task complete <ref> [--note <text>] [--lenient]
|
|
17605
18058
|
jioogen task adopt <ref> [--note <text>] [--visual <catatan>] [--lenient] [--force]
|
|
17606
18059
|
jioogen task verify <ref> [--dir <dir>] [--json]
|
|
17607
18060
|
jioogen task expand <ref> [--write]
|