jioogen 0.2.13 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +746 -176
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -358,7 +358,7 @@ var require_utils = __commonJS({
|
|
|
358
358
|
module.exports = Utils;
|
|
359
359
|
Utils.prototype.makeDir = function(folder) {
|
|
360
360
|
const self = this;
|
|
361
|
-
function
|
|
361
|
+
function mkdirSync2(fpath) {
|
|
362
362
|
let resolvedPath = fpath.split(self.sep)[0];
|
|
363
363
|
fpath.split(self.sep).forEach(function(name) {
|
|
364
364
|
if (!name || name.substr(-1, 1) === ":") return;
|
|
@@ -376,7 +376,7 @@ var require_utils = __commonJS({
|
|
|
376
376
|
if (stat9 && stat9.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
|
-
|
|
379
|
+
mkdirSync2(folder);
|
|
380
380
|
};
|
|
381
381
|
Utils.prototype.writeFileTo = function(path, content, overwrite, attr) {
|
|
382
382
|
const self = this;
|
|
@@ -2124,8 +2124,8 @@ var require_adm_zip = __commonJS({
|
|
|
2124
2124
|
return null;
|
|
2125
2125
|
}
|
|
2126
2126
|
function fixPath(zipPath) {
|
|
2127
|
-
const { join:
|
|
2128
|
-
return
|
|
2127
|
+
const { join: join14, normalize: normalize2, sep: sep2 } = pth.posix;
|
|
2128
|
+
return join14(pth.isAbsolute(zipPath) ? "/" : ".", normalize2(sep2 + zipPath.split("\\").join(sep2) + sep2));
|
|
2129
2129
|
}
|
|
2130
2130
|
function filenameFilter(filterfn) {
|
|
2131
2131
|
if (filterfn instanceof RegExp) {
|
|
@@ -9957,6 +9957,34 @@ function computeCompletion(tasks, definitions) {
|
|
|
9957
9957
|
return { tasksDone, totalTasks: tasks.length, features, projectComplete };
|
|
9958
9958
|
}
|
|
9959
9959
|
|
|
9960
|
+
// ../contracts/src/layout.ts
|
|
9961
|
+
var LAYOUT_MARKER = ".bundle-layout.json";
|
|
9962
|
+
var CONTRACT_ROOT_REL = "docs/00-contract";
|
|
9963
|
+
function isContractArtifactPath(relative3) {
|
|
9964
|
+
return relative3 === "PRD.md" || relative3 === "traceability.md" || relative3.startsWith("specs/") || relative3.startsWith("tasks/");
|
|
9965
|
+
}
|
|
9966
|
+
function normalizeContractRoot(value) {
|
|
9967
|
+
if (typeof value !== "string") return null;
|
|
9968
|
+
const normalized = value.replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
|
|
9969
|
+
if (normalized.length === 0 || normalized === ".") return ".";
|
|
9970
|
+
if (normalized.includes("..") || normalized.startsWith("/")) return null;
|
|
9971
|
+
if (!/^[A-Za-z0-9._/-]+$/.test(normalized)) return null;
|
|
9972
|
+
return normalized;
|
|
9973
|
+
}
|
|
9974
|
+
function parseLayoutMarker(value) {
|
|
9975
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
9976
|
+
const record = value;
|
|
9977
|
+
if (record.schemaVersion !== 1 || record.layout !== "docs") return null;
|
|
9978
|
+
return normalizeContractRoot(record.contractRoot);
|
|
9979
|
+
}
|
|
9980
|
+
function layoutMarker(contractRoot2 = CONTRACT_ROOT_REL) {
|
|
9981
|
+
return {
|
|
9982
|
+
schemaVersion: 1,
|
|
9983
|
+
layout: "docs",
|
|
9984
|
+
contractRoot: normalizeContractRoot(contractRoot2) ?? CONTRACT_ROOT_REL
|
|
9985
|
+
};
|
|
9986
|
+
}
|
|
9987
|
+
|
|
9960
9988
|
// src/api.ts
|
|
9961
9989
|
var DEFAULT_API_URL = "https://gen.jioo.site";
|
|
9962
9990
|
var SESSION_COOKIE = "jioo_session";
|
|
@@ -10046,6 +10074,12 @@ var ApiClient = class {
|
|
|
10046
10074
|
async getWorkspaceArtifacts(projectId) {
|
|
10047
10075
|
return this.getJson(projectPath(projectId, "/artifacts"));
|
|
10048
10076
|
}
|
|
10077
|
+
async ensureProjectLayout(projectId) {
|
|
10078
|
+
return this.postJson(
|
|
10079
|
+
projectPath(projectId, "/layout"),
|
|
10080
|
+
{ layout: "docs" }
|
|
10081
|
+
);
|
|
10082
|
+
}
|
|
10049
10083
|
async getPrdConfirmation(projectId) {
|
|
10050
10084
|
return this.getJson(projectPath(projectId, "/prd-confirmation"));
|
|
10051
10085
|
}
|
|
@@ -10075,13 +10109,14 @@ var ApiClient = class {
|
|
|
10075
10109
|
|
|
10076
10110
|
// src/commands.ts
|
|
10077
10111
|
import { spawn as spawn2 } from "node:child_process";
|
|
10112
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
10078
10113
|
import { mkdir as mkdir10, readdir as readdir8, readFile as readFile12, stat as stat8, writeFile as writeFile10 } from "node:fs/promises";
|
|
10079
|
-
import { join as
|
|
10114
|
+
import { join as join13, resolve as resolve6 } from "node:path";
|
|
10080
10115
|
|
|
10081
10116
|
// src/align.ts
|
|
10082
10117
|
import { spawn } from "node:child_process";
|
|
10083
10118
|
import { mkdir as mkdir5, readFile as readFile7, rm as rm4, stat as stat4, writeFile as writeFile5 } from "node:fs/promises";
|
|
10084
|
-
import { join as
|
|
10119
|
+
import { join as join8 } from "node:path";
|
|
10085
10120
|
|
|
10086
10121
|
// src/authoring.ts
|
|
10087
10122
|
import { existsSync } from "node:fs";
|
|
@@ -10251,7 +10286,339 @@ async function removeAuthoringContract(dir) {
|
|
|
10251
10286
|
|
|
10252
10287
|
// src/check.ts
|
|
10253
10288
|
import { readdir as readdir2, readFile as readFile2 } from "node:fs/promises";
|
|
10254
|
-
import { join as
|
|
10289
|
+
import { join as join3, relative } from "node:path";
|
|
10290
|
+
|
|
10291
|
+
// src/layout.ts
|
|
10292
|
+
import {
|
|
10293
|
+
cpSync,
|
|
10294
|
+
existsSync as existsSync2,
|
|
10295
|
+
mkdirSync,
|
|
10296
|
+
readdirSync,
|
|
10297
|
+
readFileSync,
|
|
10298
|
+
renameSync,
|
|
10299
|
+
rmSync,
|
|
10300
|
+
statSync,
|
|
10301
|
+
writeFileSync
|
|
10302
|
+
} from "node:fs";
|
|
10303
|
+
import { join as join2 } from "node:path";
|
|
10304
|
+
var contractRootCache = /* @__PURE__ */ new Map();
|
|
10305
|
+
function resetLayoutCache() {
|
|
10306
|
+
contractRootCache.clear();
|
|
10307
|
+
}
|
|
10308
|
+
function contractRoot(bundleDir) {
|
|
10309
|
+
const cached = contractRootCache.get(bundleDir);
|
|
10310
|
+
if (cached !== void 0) return cached;
|
|
10311
|
+
let resolved = bundleDir;
|
|
10312
|
+
try {
|
|
10313
|
+
const parsed = parseLayoutMarker(
|
|
10314
|
+
JSON.parse(readFileSync(join2(bundleDir, LAYOUT_MARKER), "utf8"))
|
|
10315
|
+
);
|
|
10316
|
+
if (parsed !== null) {
|
|
10317
|
+
resolved = parsed === "." ? bundleDir : join2(bundleDir, parsed);
|
|
10318
|
+
}
|
|
10319
|
+
} catch {
|
|
10320
|
+
if (existsSync2(join2(bundleDir, CONTRACT_ROOT_REL))) {
|
|
10321
|
+
resolved = join2(bundleDir, CONTRACT_ROOT_REL);
|
|
10322
|
+
}
|
|
10323
|
+
}
|
|
10324
|
+
contractRootCache.set(bundleDir, resolved);
|
|
10325
|
+
return resolved;
|
|
10326
|
+
}
|
|
10327
|
+
function resolveProjectPath(bundleDir, relative3) {
|
|
10328
|
+
return isContractArtifactPath(relative3) ? join2(contractRoot(bundleDir), relative3) : join2(bundleDir, relative3);
|
|
10329
|
+
}
|
|
10330
|
+
function ensureDocsLayout(bundleDir, contractRootRel = CONTRACT_ROOT_REL) {
|
|
10331
|
+
const normalized = normalizeContractRoot(contractRootRel) ?? CONTRACT_ROOT_REL;
|
|
10332
|
+
const physical = normalized === "." ? bundleDir : join2(bundleDir, normalized);
|
|
10333
|
+
mkdirSync(physical, { recursive: true });
|
|
10334
|
+
const markerPath = join2(bundleDir, LAYOUT_MARKER);
|
|
10335
|
+
if (!existsSync2(markerPath)) {
|
|
10336
|
+
writeFileSync(markerPath, `${JSON.stringify(layoutMarker(normalized), null, 2)}
|
|
10337
|
+
`, "utf8");
|
|
10338
|
+
}
|
|
10339
|
+
resetLayoutCache();
|
|
10340
|
+
}
|
|
10341
|
+
var CONTRACT_ENTRIES = ["PRD.md", "traceability.md", "specs", "tasks"];
|
|
10342
|
+
function timestamp() {
|
|
10343
|
+
return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
10344
|
+
}
|
|
10345
|
+
function copyEntry(source, destination) {
|
|
10346
|
+
cpSync(source, destination, { recursive: true, errorOnExist: true, force: false });
|
|
10347
|
+
}
|
|
10348
|
+
function moveEntry(source, destination) {
|
|
10349
|
+
try {
|
|
10350
|
+
renameSync(source, destination);
|
|
10351
|
+
} catch (error) {
|
|
10352
|
+
const code = error.code;
|
|
10353
|
+
if (code !== "EXDEV") throw error;
|
|
10354
|
+
copyEntry(source, destination);
|
|
10355
|
+
rmSync(source, { recursive: true, force: true });
|
|
10356
|
+
}
|
|
10357
|
+
}
|
|
10358
|
+
function collectFiles(root, relative3) {
|
|
10359
|
+
const absolute = join2(root, relative3);
|
|
10360
|
+
if (!existsSync2(absolute)) return [];
|
|
10361
|
+
try {
|
|
10362
|
+
return readdirSync(absolute, { withFileTypes: true }).flatMap(
|
|
10363
|
+
(entry) => entry.isDirectory() ? collectFiles(root, `${relative3}/${entry.name}`) : entry.isFile() ? [`${relative3}/${entry.name}`] : []
|
|
10364
|
+
);
|
|
10365
|
+
} catch {
|
|
10366
|
+
return [];
|
|
10367
|
+
}
|
|
10368
|
+
}
|
|
10369
|
+
function normalizeContractLayout(bundleDir, options = {}) {
|
|
10370
|
+
ensureDocsLayout(bundleDir);
|
|
10371
|
+
const destination = join2(bundleDir, CONTRACT_ROOT_REL);
|
|
10372
|
+
const sources = CONTRACT_ENTRIES.filter((entry) => existsSync2(join2(bundleDir, entry)));
|
|
10373
|
+
if (sources.length === 0) return { moved: [], replaced: [], backup: null };
|
|
10374
|
+
const actions = [];
|
|
10375
|
+
for (const entry of sources) {
|
|
10376
|
+
const target = join2(destination, entry);
|
|
10377
|
+
if (!existsSync2(target)) {
|
|
10378
|
+
actions.push({ from: join2(bundleDir, entry), to: target, replace: false });
|
|
10379
|
+
continue;
|
|
10380
|
+
}
|
|
10381
|
+
const sourceIsDir = statSync(join2(bundleDir, entry)).isDirectory();
|
|
10382
|
+
if (!sourceIsDir) {
|
|
10383
|
+
const source = readFileSync(join2(bundleDir, entry));
|
|
10384
|
+
const dest = readFileSync(target);
|
|
10385
|
+
if (!source.equals(dest))
|
|
10386
|
+
actions.push({ from: join2(bundleDir, entry), to: target, replace: true });
|
|
10387
|
+
else actions.push({ from: join2(bundleDir, entry), to: target, replace: false });
|
|
10388
|
+
continue;
|
|
10389
|
+
}
|
|
10390
|
+
for (const relative3 of collectFiles(bundleDir, entry)) {
|
|
10391
|
+
const targetFile = join2(destination, relative3);
|
|
10392
|
+
const sourceFile = join2(bundleDir, relative3);
|
|
10393
|
+
if (!existsSync2(targetFile)) {
|
|
10394
|
+
actions.push({ from: sourceFile, to: targetFile, replace: false });
|
|
10395
|
+
} else {
|
|
10396
|
+
const source = readFileSync(sourceFile);
|
|
10397
|
+
const dest = readFileSync(targetFile);
|
|
10398
|
+
actions.push({ from: sourceFile, to: targetFile, replace: !source.equals(dest) });
|
|
10399
|
+
}
|
|
10400
|
+
}
|
|
10401
|
+
}
|
|
10402
|
+
if (options.dryRun) {
|
|
10403
|
+
return {
|
|
10404
|
+
moved: actions.filter((action) => !action.replace).map((a) => a.from),
|
|
10405
|
+
replaced: actions.filter((action) => action.replace).map((a) => a.from),
|
|
10406
|
+
backup: null
|
|
10407
|
+
};
|
|
10408
|
+
}
|
|
10409
|
+
const backup = join2(bundleDir, ".jioogen", "backups", `normalize-${timestamp()}`);
|
|
10410
|
+
for (const action of actions) {
|
|
10411
|
+
if (action.replace) {
|
|
10412
|
+
mkdirSync(join2(backup, "replaced"), { recursive: true });
|
|
10413
|
+
cpSync(action.to, join2(backup, "replaced", action.to.replace(/[/\\]/g, "__")), {
|
|
10414
|
+
recursive: true
|
|
10415
|
+
});
|
|
10416
|
+
rmSync(action.to, { recursive: true, force: true });
|
|
10417
|
+
}
|
|
10418
|
+
if (!action.replace && existsSync2(action.to)) {
|
|
10419
|
+
rmSync(action.from, { recursive: true, force: true });
|
|
10420
|
+
continue;
|
|
10421
|
+
}
|
|
10422
|
+
mkdirSync(join2(action.to, ".."), { recursive: true });
|
|
10423
|
+
moveEntry(action.from, action.to);
|
|
10424
|
+
}
|
|
10425
|
+
for (const entry of sources) {
|
|
10426
|
+
const remaining = collectFiles(bundleDir, entry);
|
|
10427
|
+
if (remaining.length === 0) rmSync(join2(bundleDir, entry), { recursive: true, force: true });
|
|
10428
|
+
}
|
|
10429
|
+
resetLayoutCache();
|
|
10430
|
+
return {
|
|
10431
|
+
moved: actions.filter((action) => !action.replace).map((a) => a.from),
|
|
10432
|
+
replaced: actions.filter((action) => action.replace).map((a) => a.from),
|
|
10433
|
+
backup
|
|
10434
|
+
};
|
|
10435
|
+
}
|
|
10436
|
+
function migrateContractLayout(bundleDir, options = {}) {
|
|
10437
|
+
const destination = join2(bundleDir, CONTRACT_ROOT_REL);
|
|
10438
|
+
const existingMarker = existsSync2(join2(bundleDir, LAYOUT_MARKER));
|
|
10439
|
+
const sources = CONTRACT_ENTRIES.filter((entry) => existsSync2(join2(bundleDir, entry)));
|
|
10440
|
+
if (existingMarker && sources.length > 0) {
|
|
10441
|
+
const normalized = normalizeContractLayout(
|
|
10442
|
+
bundleDir,
|
|
10443
|
+
options.dryRun === true ? { dryRun: true } : {}
|
|
10444
|
+
);
|
|
10445
|
+
return {
|
|
10446
|
+
migrated: normalized.moved.length + normalized.replaced.length > 0,
|
|
10447
|
+
moved: [...normalized.moved, ...normalized.replaced].map(
|
|
10448
|
+
(path) => path.replace(bundleDir + "/", "")
|
|
10449
|
+
),
|
|
10450
|
+
backup: normalized.backup
|
|
10451
|
+
};
|
|
10452
|
+
}
|
|
10453
|
+
if (sources.length === 0) {
|
|
10454
|
+
if (!options.dryRun) ensureDocsLayout(bundleDir);
|
|
10455
|
+
return {
|
|
10456
|
+
migrated: !existingMarker,
|
|
10457
|
+
moved: [],
|
|
10458
|
+
backup: null,
|
|
10459
|
+
...existingMarker ? { reason: "sudah memakai layout docs" } : {}
|
|
10460
|
+
};
|
|
10461
|
+
}
|
|
10462
|
+
for (const entry of sources) {
|
|
10463
|
+
if (existsSync2(join2(destination, entry))) {
|
|
10464
|
+
return {
|
|
10465
|
+
migrated: false,
|
|
10466
|
+
moved: [],
|
|
10467
|
+
backup: null,
|
|
10468
|
+
reason: `tujuan sudah berisi ${entry}`
|
|
10469
|
+
};
|
|
10470
|
+
}
|
|
10471
|
+
}
|
|
10472
|
+
if (options.dryRun) {
|
|
10473
|
+
return {
|
|
10474
|
+
migrated: true,
|
|
10475
|
+
moved: sources.map((entry) => `${entry} \u2192 ${CONTRACT_ROOT_REL}/${entry}`),
|
|
10476
|
+
backup: null
|
|
10477
|
+
};
|
|
10478
|
+
}
|
|
10479
|
+
mkdirSync(destination, { recursive: true });
|
|
10480
|
+
const backup = join2(bundleDir, ".jioogen", "backups", `layout-${timestamp()}`);
|
|
10481
|
+
mkdirSync(backup, { recursive: true });
|
|
10482
|
+
for (const entry of sources) copyEntry(join2(bundleDir, entry), join2(backup, entry));
|
|
10483
|
+
for (const entry of sources) {
|
|
10484
|
+
moveEntry(join2(bundleDir, entry), join2(destination, entry));
|
|
10485
|
+
}
|
|
10486
|
+
ensureDocsLayout(bundleDir);
|
|
10487
|
+
return {
|
|
10488
|
+
migrated: true,
|
|
10489
|
+
moved: sources.map((entry) => `${entry} \u2192 ${CONTRACT_ROOT_REL}/${entry}`),
|
|
10490
|
+
backup
|
|
10491
|
+
};
|
|
10492
|
+
}
|
|
10493
|
+
var DOCS_DOMAINS = [
|
|
10494
|
+
"01-product",
|
|
10495
|
+
"02-design",
|
|
10496
|
+
"03-architecture",
|
|
10497
|
+
"04-domain",
|
|
10498
|
+
"05-operations",
|
|
10499
|
+
"06-quality",
|
|
10500
|
+
"99-archive"
|
|
10501
|
+
];
|
|
10502
|
+
function ensureDocsTree(bundleDir) {
|
|
10503
|
+
mkdirSync(join2(bundleDir, "docs"), { recursive: true });
|
|
10504
|
+
for (const domain of DOCS_DOMAINS)
|
|
10505
|
+
mkdirSync(join2(bundleDir, "docs", domain), { recursive: true });
|
|
10506
|
+
}
|
|
10507
|
+
var ROOT_DOC_KEEP = /* @__PURE__ */ new Set([
|
|
10508
|
+
"agents.md",
|
|
10509
|
+
"readme.md",
|
|
10510
|
+
"prd.md",
|
|
10511
|
+
"traceability.md",
|
|
10512
|
+
"license.md",
|
|
10513
|
+
"changelog.md",
|
|
10514
|
+
"contributing.md"
|
|
10515
|
+
]);
|
|
10516
|
+
function classifyRootDoc(name) {
|
|
10517
|
+
const lower = name.toLowerCase();
|
|
10518
|
+
if (lower.includes("design") || lower.includes("style") || lower.includes("ui-ux")) {
|
|
10519
|
+
return "docs/02-design";
|
|
10520
|
+
}
|
|
10521
|
+
if (lower.includes("stack") || lower.includes("architecture") || lower.includes("adr") || lower.includes("decision")) {
|
|
10522
|
+
return "docs/03-architecture";
|
|
10523
|
+
}
|
|
10524
|
+
if (lower.includes("runbook") || lower.includes("deploy") || lower.includes("operation") || lower.includes("ops")) {
|
|
10525
|
+
return "docs/05-operations";
|
|
10526
|
+
}
|
|
10527
|
+
if (lower.includes("test") || lower.includes("qa") || lower.includes("quality")) {
|
|
10528
|
+
return "docs/06-quality";
|
|
10529
|
+
}
|
|
10530
|
+
if (lower.includes("domain") || lower.includes("schema") || lower.includes("model")) {
|
|
10531
|
+
return "docs/04-domain";
|
|
10532
|
+
}
|
|
10533
|
+
if (lower.includes("product") || lower.includes("vision") || lower.includes("persona") || lower.includes("glossary")) {
|
|
10534
|
+
return "docs/01-product";
|
|
10535
|
+
}
|
|
10536
|
+
return "docs/99-archive/unsorted";
|
|
10537
|
+
}
|
|
10538
|
+
var KNOWN_DOC_TARGETS = {
|
|
10539
|
+
"DESIGN.md": "docs/02-design/DESIGN.md",
|
|
10540
|
+
"STACK.md": "docs/03-architecture/STACK.md",
|
|
10541
|
+
"ARCHITECTURE.md": "docs/03-architecture/ARCHITECTURE.md",
|
|
10542
|
+
"RUNBOOK.md": "docs/05-operations/RUNBOOK.md",
|
|
10543
|
+
"TESTING.md": "docs/06-quality/TESTING.md"
|
|
10544
|
+
};
|
|
10545
|
+
function migrateKnownDocs(bundleDir, options = {}) {
|
|
10546
|
+
ensureDocsTree(bundleDir);
|
|
10547
|
+
const moves = [];
|
|
10548
|
+
for (const [name, target] of Object.entries(KNOWN_DOC_TARGETS)) {
|
|
10549
|
+
if (existsSync2(join2(bundleDir, name)) && !existsSync2(join2(bundleDir, target))) {
|
|
10550
|
+
moves.push({ from: name, to: target });
|
|
10551
|
+
}
|
|
10552
|
+
}
|
|
10553
|
+
try {
|
|
10554
|
+
for (const entry of readdirSync(bundleDir, { withFileTypes: true })) {
|
|
10555
|
+
if (!entry.isFile() || !/\.mdx?$/i.test(entry.name)) continue;
|
|
10556
|
+
if (ROOT_DOC_KEEP.has(entry.name.toLowerCase())) continue;
|
|
10557
|
+
if (Object.hasOwn(KNOWN_DOC_TARGETS, entry.name)) continue;
|
|
10558
|
+
const folder = classifyRootDoc(entry.name);
|
|
10559
|
+
const to = `${folder}/${entry.name}`;
|
|
10560
|
+
if (!existsSync2(join2(bundleDir, to))) moves.push({ from: entry.name, to });
|
|
10561
|
+
}
|
|
10562
|
+
} catch {
|
|
10563
|
+
}
|
|
10564
|
+
const stitch = join2(bundleDir, "assets", "stitch");
|
|
10565
|
+
if (existsSync2(stitch)) {
|
|
10566
|
+
for (const entry of readdirSync(stitch, { withFileTypes: true })) {
|
|
10567
|
+
if (!entry.isDirectory()) continue;
|
|
10568
|
+
const from = `assets/stitch/${entry.name}/DESIGN.md`;
|
|
10569
|
+
const to = `docs/99-archive/stitch/${entry.name}/DESIGN.md`;
|
|
10570
|
+
if (existsSync2(join2(bundleDir, from)) && !existsSync2(join2(bundleDir, to))) {
|
|
10571
|
+
moves.push({ from, to });
|
|
10572
|
+
}
|
|
10573
|
+
}
|
|
10574
|
+
}
|
|
10575
|
+
if (options.dryRun) {
|
|
10576
|
+
return { moved: moves.map((move) => `${move.from} \u2192 ${move.to}`), skipped: [], backup: null };
|
|
10577
|
+
}
|
|
10578
|
+
if (moves.length === 0) return { moved: [], skipped: [], backup: null };
|
|
10579
|
+
const backup = join2(bundleDir, ".jioogen", "backups", `docs-${timestamp()}`);
|
|
10580
|
+
mkdirSync(backup, { recursive: true });
|
|
10581
|
+
for (const move of moves) {
|
|
10582
|
+
const target = join2(bundleDir, move.to);
|
|
10583
|
+
mkdirSync(join2(target, ".."), { recursive: true });
|
|
10584
|
+
cpSync(join2(bundleDir, move.from), join2(backup, move.from.replace(/[/\\]/g, "__")), {
|
|
10585
|
+
recursive: true
|
|
10586
|
+
});
|
|
10587
|
+
moveEntry(join2(bundleDir, move.from), target);
|
|
10588
|
+
}
|
|
10589
|
+
return { moved: moves.map((move) => `${move.from} \u2192 ${move.to}`), skipped: [], backup };
|
|
10590
|
+
}
|
|
10591
|
+
function docsReadme() {
|
|
10592
|
+
return `# Dokumentasi Project
|
|
10593
|
+
|
|
10594
|
+
> Peta dokumen. Baca berurutan; jangan menganggap arsip sebagai sumber kebenaran.
|
|
10595
|
+
|
|
10596
|
+
## Urutan baca
|
|
10597
|
+
1. \`docs/00-contract/PRD.md\` \u2014 maksud dan scope produk
|
|
10598
|
+
2. \`docs/01-product/\` \u2014 konteks produk
|
|
10599
|
+
3. \`docs/00-contract/specs/\` \u2014 kontrak teknis
|
|
10600
|
+
4. \`docs/02-design/\` \u2014 desain dan token
|
|
10601
|
+
5. \`docs/03-architecture/\` \u2014 stack dan keputusan
|
|
10602
|
+
6. \`docs/04-domain/\` \u2014 aturan domain
|
|
10603
|
+
7. \`docs/00-contract/tasks/\` \u2014 urutan pekerjaan
|
|
10604
|
+
8. kode \u2014 kenyataan implementasi
|
|
10605
|
+
|
|
10606
|
+
## Lokasi contract
|
|
10607
|
+
- \`PRD.md\`, \`specs/\`, \`tasks/\`, \`traceability.md\` disimpan di \`docs/00-contract/\`.
|
|
10608
|
+
|
|
10609
|
+
## Aturan konflik
|
|
10610
|
+
Dokumen = niat. Kode = kenyataan. Bila berbeda, jangan menebak; tanyakan mana yang benar.
|
|
10611
|
+
`;
|
|
10612
|
+
}
|
|
10613
|
+
function writeDocsReadme(bundleDir, overwrite = false) {
|
|
10614
|
+
const target = join2(bundleDir, "docs", "README.md");
|
|
10615
|
+
if (existsSync2(target) && !overwrite) return false;
|
|
10616
|
+
mkdirSync(join2(bundleDir, "docs"), { recursive: true });
|
|
10617
|
+
writeFileSync(target, docsReadme(), "utf8");
|
|
10618
|
+
return true;
|
|
10619
|
+
}
|
|
10620
|
+
|
|
10621
|
+
// src/check.ts
|
|
10255
10622
|
var EXCLUDED_DIRS = /* @__PURE__ */ new Set([".execution", ".jioogen", ".jioocode", ".git", "node_modules"]);
|
|
10256
10623
|
async function collectMarkdownFiles(root) {
|
|
10257
10624
|
const found = [];
|
|
@@ -10265,13 +10632,16 @@ async function collectMarkdownFiles(root) {
|
|
|
10265
10632
|
for (const entry of entries) {
|
|
10266
10633
|
if (entry.isDirectory()) {
|
|
10267
10634
|
if (EXCLUDED_DIRS.has(entry.name)) continue;
|
|
10268
|
-
await walk2(
|
|
10635
|
+
await walk2(join3(dir, entry.name));
|
|
10269
10636
|
continue;
|
|
10270
10637
|
}
|
|
10271
10638
|
if (!entry.isFile() || !entry.name.toLowerCase().endsWith(".md")) continue;
|
|
10272
|
-
const absolute =
|
|
10639
|
+
const absolute = join3(dir, entry.name);
|
|
10640
|
+
const contract = contractRoot(root);
|
|
10641
|
+
const fromContract = relative(contract, absolute);
|
|
10642
|
+
const insideContract = fromContract.length > 0 && !fromContract.startsWith("..") && !fromContract.startsWith("/");
|
|
10273
10643
|
found.push({
|
|
10274
|
-
path: relative(root, absolute).replace(/\\/g, "/"),
|
|
10644
|
+
path: (insideContract ? fromContract : relative(root, absolute)).replace(/\\/g, "/"),
|
|
10275
10645
|
content: await readFile2(absolute, "utf8")
|
|
10276
10646
|
});
|
|
10277
10647
|
}
|
|
@@ -10401,9 +10771,9 @@ function formatBundleCheck(check) {
|
|
|
10401
10771
|
// src/contract.ts
|
|
10402
10772
|
import { createHash } from "node:crypto";
|
|
10403
10773
|
import { mkdir as mkdir2, readdir as readdir3, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
|
|
10404
|
-
import { dirname as dirname2, join as
|
|
10405
|
-
var CONTRACT_LEDGER_PATH =
|
|
10406
|
-
var APPROVALS_PATH =
|
|
10774
|
+
import { dirname as dirname2, join as join4, relative as relative2 } from "node:path";
|
|
10775
|
+
var CONTRACT_LEDGER_PATH = join4(".jioogen", "contract.json");
|
|
10776
|
+
var APPROVALS_PATH = join4(".jioogen", "approvals.json");
|
|
10407
10777
|
var LOCAL_IGNORED_DIRS = /* @__PURE__ */ new Set([".execution", ".jioogen", ".git", "node_modules"]);
|
|
10408
10778
|
function sha256(bytes) {
|
|
10409
10779
|
return createHash("sha256").update(bytes).digest("hex");
|
|
@@ -10420,14 +10790,14 @@ async function walkMarkdown(root, directory) {
|
|
|
10420
10790
|
for (const entry of entries) {
|
|
10421
10791
|
if (entry.isDirectory()) {
|
|
10422
10792
|
if (LOCAL_IGNORED_DIRS.has(entry.name)) continue;
|
|
10423
|
-
await walk2(
|
|
10793
|
+
await walk2(join4(current, entry.name));
|
|
10424
10794
|
continue;
|
|
10425
10795
|
}
|
|
10426
10796
|
if (!entry.isFile() || !entry.name.toLowerCase().endsWith(".md")) continue;
|
|
10427
|
-
found.push(relative2(root,
|
|
10797
|
+
found.push(relative2(root, join4(current, entry.name)).replace(/\\/g, "/"));
|
|
10428
10798
|
}
|
|
10429
10799
|
}
|
|
10430
|
-
await walk2(
|
|
10800
|
+
await walk2(join4(root, directory));
|
|
10431
10801
|
return found.sort();
|
|
10432
10802
|
}
|
|
10433
10803
|
function fingerprint(files, matches) {
|
|
@@ -10436,21 +10806,25 @@ function fingerprint(files, matches) {
|
|
|
10436
10806
|
return sha256(entries.map(([path, hash]) => `${path}:${hash}`).join("\n"));
|
|
10437
10807
|
}
|
|
10438
10808
|
async function snapshotContract(bundleDir) {
|
|
10809
|
+
const root = contractRoot(bundleDir);
|
|
10439
10810
|
const paths = /* @__PURE__ */ new Set();
|
|
10440
10811
|
for (const name of ["PRD.md", "traceability.md"]) {
|
|
10441
10812
|
try {
|
|
10442
|
-
const content = await readFile3(
|
|
10813
|
+
const content = await readFile3(join4(root, name));
|
|
10443
10814
|
if (content.byteLength > 0) paths.add(name);
|
|
10444
10815
|
} catch {
|
|
10445
10816
|
}
|
|
10446
10817
|
}
|
|
10447
10818
|
for (const directory of ["specs", "tasks"]) {
|
|
10448
|
-
for (const path of await walkMarkdown(
|
|
10819
|
+
for (const path of await walkMarkdown(root, directory)) paths.add(path);
|
|
10820
|
+
}
|
|
10821
|
+
for (const path of await walkMarkdown(bundleDir, "docs")) {
|
|
10822
|
+
if (!path.startsWith("docs/00-contract/")) paths.add(path);
|
|
10449
10823
|
}
|
|
10450
10824
|
const files = {};
|
|
10451
10825
|
for (const path of [...paths].sort()) {
|
|
10452
10826
|
try {
|
|
10453
|
-
files[path] = sha256(await readFile3(
|
|
10827
|
+
files[path] = sha256(await readFile3(join4(root, path)));
|
|
10454
10828
|
} catch {
|
|
10455
10829
|
}
|
|
10456
10830
|
}
|
|
@@ -10459,6 +10833,7 @@ async function snapshotContract(bundleDir) {
|
|
|
10459
10833
|
prd: files["PRD.md"] ?? null,
|
|
10460
10834
|
specs: fingerprint(files, (path) => path.startsWith("specs/")),
|
|
10461
10835
|
tasks: fingerprint(files, tasksMatch),
|
|
10836
|
+
docs: fingerprint(files, (path) => path.startsWith("docs/")),
|
|
10462
10837
|
files
|
|
10463
10838
|
};
|
|
10464
10839
|
}
|
|
@@ -10488,13 +10863,15 @@ function changedSince(current, previous) {
|
|
|
10488
10863
|
const prd = previous === null ? current.prd !== null : current.prd !== previous.prd;
|
|
10489
10864
|
const specs = previous === null ? current.specs !== null : current.specs !== previous.specs;
|
|
10490
10865
|
const tasks = previous === null ? current.tasks !== null : current.tasks !== previous.tasks;
|
|
10491
|
-
|
|
10866
|
+
const docs = previous === null ? current.docs !== null : current.docs !== previous.docs;
|
|
10867
|
+
return { prd, specs, tasks, docs, any: prd || specs || tasks || docs };
|
|
10492
10868
|
}
|
|
10493
10869
|
function serverAsSnapshot(server) {
|
|
10494
10870
|
return {
|
|
10495
10871
|
prd: server.prd,
|
|
10496
10872
|
specs: server.specs,
|
|
10497
10873
|
tasks: server.tasks,
|
|
10874
|
+
docs: server.docs,
|
|
10498
10875
|
files: {}
|
|
10499
10876
|
};
|
|
10500
10877
|
}
|
|
@@ -10520,7 +10897,7 @@ function parseDerivation(value) {
|
|
|
10520
10897
|
async function readContractLedger(bundleDir) {
|
|
10521
10898
|
let raw;
|
|
10522
10899
|
try {
|
|
10523
|
-
raw = await readFile3(
|
|
10900
|
+
raw = await readFile3(join4(bundleDir, CONTRACT_LEDGER_PATH), "utf8");
|
|
10524
10901
|
} catch {
|
|
10525
10902
|
return null;
|
|
10526
10903
|
}
|
|
@@ -10539,6 +10916,7 @@ async function readContractLedger(bundleDir) {
|
|
|
10539
10916
|
prd: typeof value.prd === "string" ? value.prd : null,
|
|
10540
10917
|
specs: typeof value.specs === "string" ? value.specs : null,
|
|
10541
10918
|
tasks: typeof value.tasks === "string" ? value.tasks : null,
|
|
10919
|
+
docs: typeof value.docs === "string" ? value.docs : null,
|
|
10542
10920
|
files: Object.fromEntries(
|
|
10543
10921
|
Object.entries(files).filter(
|
|
10544
10922
|
(entry) => typeof entry[1] === "string"
|
|
@@ -10550,6 +10928,7 @@ async function readContractLedger(bundleDir) {
|
|
|
10550
10928
|
prd: typeof serverRecord.prd === "string" ? serverRecord.prd : null,
|
|
10551
10929
|
specs: typeof serverRecord.specs === "string" ? serverRecord.specs : null,
|
|
10552
10930
|
tasks: typeof serverRecord.tasks === "string" ? serverRecord.tasks : null,
|
|
10931
|
+
docs: typeof serverRecord.docs === "string" ? serverRecord.docs : null,
|
|
10553
10932
|
derivation: parseDerivation(serverRecord.derivation)
|
|
10554
10933
|
};
|
|
10555
10934
|
return {
|
|
@@ -10561,7 +10940,7 @@ async function readContractLedger(bundleDir) {
|
|
|
10561
10940
|
};
|
|
10562
10941
|
}
|
|
10563
10942
|
async function writeContractLedger(bundleDir, ledger) {
|
|
10564
|
-
const target =
|
|
10943
|
+
const target = join4(bundleDir, CONTRACT_LEDGER_PATH);
|
|
10565
10944
|
await mkdir2(dirname2(target), { recursive: true });
|
|
10566
10945
|
await writeFile2(target, `${JSON.stringify(ledger, null, 2)}
|
|
10567
10946
|
`, "utf8");
|
|
@@ -10578,7 +10957,7 @@ function buildContractLedger(local, server, derivation, now = /* @__PURE__ */ ne
|
|
|
10578
10957
|
async function readApproval(bundleDir) {
|
|
10579
10958
|
let raw;
|
|
10580
10959
|
try {
|
|
10581
|
-
raw = await readFile3(
|
|
10960
|
+
raw = await readFile3(join4(bundleDir, APPROVALS_PATH), "utf8");
|
|
10582
10961
|
} catch {
|
|
10583
10962
|
return null;
|
|
10584
10963
|
}
|
|
@@ -10601,13 +10980,13 @@ async function readApproval(bundleDir) {
|
|
|
10601
10980
|
};
|
|
10602
10981
|
}
|
|
10603
10982
|
async function writeApproval(bundleDir, record) {
|
|
10604
|
-
const target =
|
|
10983
|
+
const target = join4(bundleDir, APPROVALS_PATH);
|
|
10605
10984
|
await mkdir2(dirname2(target), { recursive: true });
|
|
10606
10985
|
await writeFile2(target, `${JSON.stringify(record, null, 2)}
|
|
10607
10986
|
`, "utf8");
|
|
10608
10987
|
}
|
|
10609
10988
|
async function appendApprovalNote(bundleDir, input) {
|
|
10610
|
-
const target =
|
|
10989
|
+
const target = join4(bundleDir, ".jioogen", "custom", "knowledge", "approved-patches.md");
|
|
10611
10990
|
await mkdir2(dirname2(target), { recursive: true });
|
|
10612
10991
|
let existing = "";
|
|
10613
10992
|
try {
|
|
@@ -10630,22 +11009,22 @@ async function appendApprovalNote(bundleDir, input) {
|
|
|
10630
11009
|
// src/drift.ts
|
|
10631
11010
|
import { createHash as createHash2 } from "node:crypto";
|
|
10632
11011
|
import { mkdir as mkdir4, readdir as readdir5, readFile as readFile6, rm as rm3, stat as stat3, writeFile as writeFile4 } from "node:fs/promises";
|
|
10633
|
-
import { dirname as dirname4, isAbsolute as isAbsolute2, join as
|
|
11012
|
+
import { dirname as dirname4, isAbsolute as isAbsolute2, join as join7 } from "node:path";
|
|
10634
11013
|
|
|
10635
11014
|
// src/tasks.ts
|
|
10636
|
-
import { readdirSync, readFileSync } from "node:fs";
|
|
11015
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
10637
11016
|
import { readdir as readdir4, readFile as readFile5, stat as stat2 } from "node:fs/promises";
|
|
10638
|
-
import { isAbsolute, join as
|
|
11017
|
+
import { isAbsolute, join as join6 } from "node:path";
|
|
10639
11018
|
|
|
10640
11019
|
// src/sidecar.ts
|
|
10641
11020
|
import { randomUUID } from "node:crypto";
|
|
10642
11021
|
import { mkdir as mkdir3, open, readFile as readFile4, rename, rm as rm2, stat, writeFile as writeFile3 } from "node:fs/promises";
|
|
10643
|
-
import { dirname as dirname3, join as
|
|
11022
|
+
import { dirname as dirname3, join as join5 } from "node:path";
|
|
10644
11023
|
var LOCK_RETRY_MS = 25;
|
|
10645
11024
|
var LOCK_TIMEOUT_MS = 3e3;
|
|
10646
11025
|
var LOCK_STALE_MS = 1e4;
|
|
10647
11026
|
function sidecarPath(bundleDir) {
|
|
10648
|
-
return
|
|
11027
|
+
return join5(contractRoot(bundleDir), EXECUTION_SIDECAR_PATH);
|
|
10649
11028
|
}
|
|
10650
11029
|
function lockPath(bundleDir) {
|
|
10651
11030
|
return `${sidecarPath(bundleDir)}.lock`;
|
|
@@ -10870,10 +11249,10 @@ async function writeState(bundleDir, state) {
|
|
|
10870
11249
|
async function backupExecutionState(bundleDir) {
|
|
10871
11250
|
const current = await readState(bundleDir);
|
|
10872
11251
|
if (current === null) return null;
|
|
10873
|
-
const backupDir =
|
|
11252
|
+
const backupDir = join5(bundleDir, ".jioogen");
|
|
10874
11253
|
await mkdir3(backupDir, { recursive: true });
|
|
10875
|
-
const
|
|
10876
|
-
const backupFile =
|
|
11254
|
+
const timestamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
11255
|
+
const backupFile = join5(backupDir, `state.backup-${timestamp2}.json`);
|
|
10877
11256
|
await writeFile3(backupFile, `${JSON.stringify(current, null, 2)}
|
|
10878
11257
|
`, "utf8");
|
|
10879
11258
|
return backupFile;
|
|
@@ -11004,7 +11383,7 @@ var LAYER_CHECKLISTS = {
|
|
|
11004
11383
|
]
|
|
11005
11384
|
};
|
|
11006
11385
|
async function loadTasks(bundleDir) {
|
|
11007
|
-
const tasksDir =
|
|
11386
|
+
const tasksDir = join6(contractRoot(bundleDir), "tasks");
|
|
11008
11387
|
let entries;
|
|
11009
11388
|
try {
|
|
11010
11389
|
entries = await readdir4(tasksDir, { withFileTypes: true });
|
|
@@ -11018,11 +11397,11 @@ async function loadTasks(bundleDir) {
|
|
|
11018
11397
|
const tasks = [];
|
|
11019
11398
|
if (names.length > 0) {
|
|
11020
11399
|
for (const name of names) {
|
|
11021
|
-
const content = await readFile5(
|
|
11400
|
+
const content = await readFile5(join6(tasksDir, name), "utf8");
|
|
11022
11401
|
tasks.push(parseSingleTask(name, content));
|
|
11023
11402
|
}
|
|
11024
11403
|
} else {
|
|
11025
|
-
const singlePath =
|
|
11404
|
+
const singlePath = join6(tasksDir, "TASKS.md");
|
|
11026
11405
|
let content;
|
|
11027
11406
|
try {
|
|
11028
11407
|
content = await readFile5(singlePath, "utf8");
|
|
@@ -11096,7 +11475,7 @@ function renderActiveTask(task, context) {
|
|
|
11096
11475
|
"- Jangan pindah task, jangan mengerjakan task lain, jangan melebar ke file di luar targetFiles (file/direktori/glob).",
|
|
11097
11476
|
"- Jangan mengarang fitur/endpoint/kolom di luar PRD.md/specs/.",
|
|
11098
11477
|
"- Detail implementasi (pola, struktur file dalam scope, library yang sudah ada) milikmu; ikuti konvensi proyek.",
|
|
11099
|
-
"- Jangan mengubah PRD.md/specs/kontrak. Butuh perubahan
|
|
11478
|
+
"- Jangan mengubah PRD.md/specs/kontrak saat task berjalan. Butuh perubahan? Hentikan task, minta izin sekali, jalankan `npx jioogen approve` + `npx jioogen align`, lalu lanjut.",
|
|
11100
11479
|
"- Selesai: `npx jioogen task complete <ref>`, lalu `npx jioogen sync`."
|
|
11101
11480
|
);
|
|
11102
11481
|
const checklist = renderQualityChecklist(task.layer, context);
|
|
@@ -11113,6 +11492,8 @@ function renderActiveTask(task, context) {
|
|
|
11113
11492
|
if (preferencesBlock.length > 0) lines.push("", preferencesBlock);
|
|
11114
11493
|
const knowledgeBlock = buildCustomKnowledgeBlock(context.bundleDir);
|
|
11115
11494
|
if (knowledgeBlock.length > 0) lines.push("", knowledgeBlock);
|
|
11495
|
+
const docsMap = buildDocsMap(context.bundleDir);
|
|
11496
|
+
if (docsMap.length > 0) lines.push("", docsMap);
|
|
11116
11497
|
}
|
|
11117
11498
|
return lines.join("\n");
|
|
11118
11499
|
}
|
|
@@ -11253,7 +11634,7 @@ async function taskTargetFilesExist(bundleDir, task) {
|
|
|
11253
11634
|
if (cleaned.length === 0) continue;
|
|
11254
11635
|
const staticPart = cleaned.replace(/[*?[][\s\S]*$/, "").replace(/\/+$/, "");
|
|
11255
11636
|
const testPath = staticPart.length > 0 ? staticPart : cleaned;
|
|
11256
|
-
const fullPath = isAbsolute(testPath) ? testPath :
|
|
11637
|
+
const fullPath = isAbsolute(testPath) ? testPath : join6(bundleDir, testPath);
|
|
11257
11638
|
try {
|
|
11258
11639
|
await stat2(fullPath);
|
|
11259
11640
|
return true;
|
|
@@ -11394,24 +11775,30 @@ function isVerificationPlaceholder(value) {
|
|
|
11394
11775
|
var CUSTOM_PREFERENCES_HEADER = "## USER CUSTOM PREFERENCES & STACK (.jioogen/custom/)";
|
|
11395
11776
|
function buildCustomPreferencesBlock(bundleDir) {
|
|
11396
11777
|
const parts = [];
|
|
11397
|
-
const
|
|
11398
|
-
|
|
11399
|
-
|
|
11400
|
-
|
|
11401
|
-
|
|
11402
|
-
|
|
11403
|
-
|
|
11404
|
-
} catch {
|
|
11405
|
-
}
|
|
11406
|
-
const designFile = join5(bundleDir, ".jioogen", "custom", "design", "DESIGN.md");
|
|
11407
|
-
try {
|
|
11408
|
-
const designContent = readFileSync(designFile, "utf8").trim();
|
|
11409
|
-
if (designContent.length > 0) {
|
|
11410
|
-
parts.push(`### User Custom Design (.jioogen/custom/design/DESIGN.md)
|
|
11411
|
-
${designContent}`);
|
|
11778
|
+
const readFirst = (candidates) => {
|
|
11779
|
+
for (const relative3 of candidates) {
|
|
11780
|
+
try {
|
|
11781
|
+
const content = readFileSync2(join6(bundleDir, relative3), "utf8").trim();
|
|
11782
|
+
if (content.length > 0) return { path: relative3, content };
|
|
11783
|
+
} catch {
|
|
11784
|
+
}
|
|
11412
11785
|
}
|
|
11413
|
-
|
|
11414
|
-
}
|
|
11786
|
+
return null;
|
|
11787
|
+
};
|
|
11788
|
+
const stack = readFirst([
|
|
11789
|
+
".jioogen/custom/stack/STACK.md",
|
|
11790
|
+
"docs/03-architecture/STACK.md",
|
|
11791
|
+
"STACK.md"
|
|
11792
|
+
]);
|
|
11793
|
+
if (stack !== null) parts.push(`### User Custom Stack (${stack.path})
|
|
11794
|
+
${stack.content}`);
|
|
11795
|
+
const design = readFirst([
|
|
11796
|
+
".jioogen/custom/design/DESIGN.md",
|
|
11797
|
+
"docs/02-design/DESIGN.md",
|
|
11798
|
+
"DESIGN.md"
|
|
11799
|
+
]);
|
|
11800
|
+
if (design !== null) parts.push(`### User Custom Design (${design.path})
|
|
11801
|
+
${design.content}`);
|
|
11415
11802
|
if (parts.length === 0) return "";
|
|
11416
11803
|
return [
|
|
11417
11804
|
CUSTOM_PREFERENCES_HEADER,
|
|
@@ -11420,10 +11807,10 @@ ${designContent}`);
|
|
|
11420
11807
|
].join("\n\n");
|
|
11421
11808
|
}
|
|
11422
11809
|
function listCustomKnowledgeFiles(bundleDir) {
|
|
11423
|
-
const dir =
|
|
11810
|
+
const dir = join6(bundleDir, ".jioogen", "custom", "knowledge");
|
|
11424
11811
|
let entries;
|
|
11425
11812
|
try {
|
|
11426
|
-
entries =
|
|
11813
|
+
entries = readdirSync2(dir, { withFileTypes: true });
|
|
11427
11814
|
} catch {
|
|
11428
11815
|
return [];
|
|
11429
11816
|
}
|
|
@@ -11431,9 +11818,9 @@ function listCustomKnowledgeFiles(bundleDir) {
|
|
|
11431
11818
|
const result = [];
|
|
11432
11819
|
for (const name of names) {
|
|
11433
11820
|
if (result.length >= MAX_CUSTOM_KNOWLEDGE_FILES) break;
|
|
11434
|
-
const full =
|
|
11821
|
+
const full = join6(dir, name);
|
|
11435
11822
|
try {
|
|
11436
|
-
const content =
|
|
11823
|
+
const content = readFileSync2(full, "utf8");
|
|
11437
11824
|
if (content.trim().length === 0) continue;
|
|
11438
11825
|
} catch {
|
|
11439
11826
|
continue;
|
|
@@ -11442,6 +11829,51 @@ function listCustomKnowledgeFiles(bundleDir) {
|
|
|
11442
11829
|
}
|
|
11443
11830
|
return result.slice(0, MAX_CUSTOM_KNOWLEDGE_FILES);
|
|
11444
11831
|
}
|
|
11832
|
+
function buildDocsMap(bundleDir) {
|
|
11833
|
+
const contract = contractRoot(bundleDir);
|
|
11834
|
+
const entries = [];
|
|
11835
|
+
for (const name of ["PRD.md", "traceability.md"]) {
|
|
11836
|
+
try {
|
|
11837
|
+
if (readFileSync2(join6(contract, name), "utf8").trim().length > 0) entries.push(name);
|
|
11838
|
+
} catch {
|
|
11839
|
+
}
|
|
11840
|
+
}
|
|
11841
|
+
const collect = (root, prefix) => {
|
|
11842
|
+
let names;
|
|
11843
|
+
try {
|
|
11844
|
+
names = readdirSync2(join6(root, prefix));
|
|
11845
|
+
} catch {
|
|
11846
|
+
return;
|
|
11847
|
+
}
|
|
11848
|
+
for (const name of names.sort()) {
|
|
11849
|
+
const relative3 = `${prefix}/${name}`;
|
|
11850
|
+
try {
|
|
11851
|
+
if (readdirSync2(join6(root, relative3)).length >= 0) {
|
|
11852
|
+
if (relative3 === "docs/99-archive") continue;
|
|
11853
|
+
collect(root, relative3);
|
|
11854
|
+
continue;
|
|
11855
|
+
}
|
|
11856
|
+
} catch {
|
|
11857
|
+
}
|
|
11858
|
+
if (name.toLowerCase().endsWith(".md")) entries.push(relative3);
|
|
11859
|
+
}
|
|
11860
|
+
};
|
|
11861
|
+
collect(contract, "specs");
|
|
11862
|
+
collect(contract, "tasks");
|
|
11863
|
+
collect(bundleDir, "docs");
|
|
11864
|
+
const unique2 = [...new Set(entries)].filter((path) => !path.startsWith("docs/00-contract/"));
|
|
11865
|
+
if (unique2.length === 0) return "";
|
|
11866
|
+
const lines = [
|
|
11867
|
+
"## DOC MAP (baca path ini, jangan menebak)",
|
|
11868
|
+
"Kontrak fisik ada di docs/00-contract/; path virtualnya PRD.md, specs/, tasks/.",
|
|
11869
|
+
"Urutan: docs/00-contract/PRD.md \u2192 docs/01-product \u2192 docs/00-contract/specs \u2192 docs/02-design \u2192 docs/03-architecture \u2192 docs/04-domain \u2192 docs/00-contract/tasks \u2192 kode.",
|
|
11870
|
+
"Dokumen = niat; kode = kenyataan. Bila berbeda, tanyakan mana yang benar.",
|
|
11871
|
+
...unique2.slice(0, 40).map((path) => `- ${path}`)
|
|
11872
|
+
];
|
|
11873
|
+
if (unique2.length > 40)
|
|
11874
|
+
lines.push(`- \u2026 (${unique2.length - 40} dokumen lain; lihat docs/README.md)`);
|
|
11875
|
+
return lines.join("\n");
|
|
11876
|
+
}
|
|
11445
11877
|
function buildCustomKnowledgeBlock(bundleDir) {
|
|
11446
11878
|
const files = listCustomKnowledgeFiles(bundleDir);
|
|
11447
11879
|
if (files.length === 0) return "";
|
|
@@ -11459,7 +11891,7 @@ function isMissingFile2(error) {
|
|
|
11459
11891
|
}
|
|
11460
11892
|
|
|
11461
11893
|
// src/drift.ts
|
|
11462
|
-
var DRIFT_BASELINE_PATH =
|
|
11894
|
+
var DRIFT_BASELINE_PATH = join7("tasks", ".execution", "baseline.json");
|
|
11463
11895
|
var BASELINE_VERSION = 1;
|
|
11464
11896
|
var MAX_TARGET_FILES = 2e3;
|
|
11465
11897
|
var MAX_BUNDLE_FILE_BYTES = 1048576;
|
|
@@ -11487,7 +11919,10 @@ var IGNORED_TOP_FILES = /* @__PURE__ */ new Set(["AGENTS.md"]);
|
|
|
11487
11919
|
async function readAcknowledged(bundleDir) {
|
|
11488
11920
|
let raw;
|
|
11489
11921
|
try {
|
|
11490
|
-
raw = await readFile6(
|
|
11922
|
+
raw = await readFile6(
|
|
11923
|
+
join7(contractRoot(bundleDir), "tasks", ".execution", "acknowledged.json"),
|
|
11924
|
+
"utf8"
|
|
11925
|
+
);
|
|
11491
11926
|
} catch {
|
|
11492
11927
|
return null;
|
|
11493
11928
|
}
|
|
@@ -11518,14 +11953,14 @@ async function acknowledgeDrift(bundleDir, flags = {}, note, now = /* @__PURE__
|
|
|
11518
11953
|
};
|
|
11519
11954
|
const mergedNote = note ?? existing?.note;
|
|
11520
11955
|
if (mergedNote !== void 0) merged.note = mergedNote;
|
|
11521
|
-
const target =
|
|
11956
|
+
const target = join7(contractRoot(bundleDir), "tasks", ".execution", "acknowledged.json");
|
|
11522
11957
|
await mkdir4(dirname4(target), { recursive: true });
|
|
11523
11958
|
await writeFile4(target, `${JSON.stringify(merged, null, 2)}
|
|
11524
11959
|
`, "utf8");
|
|
11525
11960
|
return merged;
|
|
11526
11961
|
}
|
|
11527
11962
|
function baselinePath(bundleDir) {
|
|
11528
|
-
return
|
|
11963
|
+
return join7(contractRoot(bundleDir), DRIFT_BASELINE_PATH);
|
|
11529
11964
|
}
|
|
11530
11965
|
async function readBaseline(bundleDir) {
|
|
11531
11966
|
let raw;
|
|
@@ -11705,7 +12140,7 @@ async function expandPattern(bundleDir, raw) {
|
|
|
11705
12140
|
const pattern = normalizePattern(raw);
|
|
11706
12141
|
if (pattern === null) return [];
|
|
11707
12142
|
if (!/[*?[]/.test(pattern)) {
|
|
11708
|
-
const info = await statMaybe(
|
|
12143
|
+
const info = await statMaybe(join7(bundleDir, pattern));
|
|
11709
12144
|
if (info === null) return [];
|
|
11710
12145
|
if (info.isDirectory()) {
|
|
11711
12146
|
return (await walk(bundleDir, pattern, MAX_TARGET_FILES)).files;
|
|
@@ -11766,7 +12201,7 @@ async function walk(bundleDir, start, limit) {
|
|
|
11766
12201
|
if (truncated) return;
|
|
11767
12202
|
let entries;
|
|
11768
12203
|
try {
|
|
11769
|
-
entries = await readdir5(relative3.length === 0 ? bundleDir :
|
|
12204
|
+
entries = await readdir5(relative3.length === 0 ? bundleDir : join7(bundleDir, relative3), {
|
|
11770
12205
|
withFileTypes: true
|
|
11771
12206
|
});
|
|
11772
12207
|
} catch {
|
|
@@ -11792,16 +12227,16 @@ async function walk(bundleDir, start, limit) {
|
|
|
11792
12227
|
return { files, truncated };
|
|
11793
12228
|
}
|
|
11794
12229
|
async function fingerprintRelative(bundleDir, relative3) {
|
|
11795
|
-
const info = await statMaybe(
|
|
12230
|
+
const info = await statMaybe(join7(bundleDir, relative3));
|
|
11796
12231
|
if (info === null || !info.isFile()) return null;
|
|
11797
12232
|
return `${info.size}:${Math.trunc(info.mtimeMs)}`;
|
|
11798
12233
|
}
|
|
11799
12234
|
async function hashRelative(bundleDir, relative3) {
|
|
11800
|
-
const info = await statMaybe(
|
|
12235
|
+
const info = await statMaybe(join7(bundleDir, relative3));
|
|
11801
12236
|
if (info === null || !info.isFile()) return null;
|
|
11802
12237
|
if (info.size > MAX_BUNDLE_FILE_BYTES) return `size:${info.size}`;
|
|
11803
12238
|
try {
|
|
11804
|
-
const bytes = await readFile6(
|
|
12239
|
+
const bytes = await readFile6(join7(bundleDir, relative3));
|
|
11805
12240
|
return createHash2("sha256").update(bytes).digest("hex");
|
|
11806
12241
|
} catch {
|
|
11807
12242
|
return null;
|
|
@@ -11825,13 +12260,14 @@ function diffHashes(before, after) {
|
|
|
11825
12260
|
return [...changed].sort();
|
|
11826
12261
|
}
|
|
11827
12262
|
async function bundleHashOf(bundleDir) {
|
|
12263
|
+
const root = contractRoot(bundleDir);
|
|
11828
12264
|
const files = [];
|
|
11829
12265
|
for (const name of ["PRD.md", "traceability.md"]) {
|
|
11830
|
-
const info = await statMaybe(
|
|
12266
|
+
const info = await statMaybe(join7(root, name));
|
|
11831
12267
|
if (info?.isFile()) files.push(name);
|
|
11832
12268
|
}
|
|
11833
12269
|
for (const directory of ["specs", "tasks"]) {
|
|
11834
|
-
const walked = await walk(
|
|
12270
|
+
const walked = await walk(root, directory, MAX_TARGET_FILES);
|
|
11835
12271
|
for (const file of walked.files) {
|
|
11836
12272
|
if (file.startsWith("tasks/.execution/")) continue;
|
|
11837
12273
|
if (IGNORED_TOP_FILES.has(file)) continue;
|
|
@@ -11841,7 +12277,7 @@ async function bundleHashOf(bundleDir) {
|
|
|
11841
12277
|
}
|
|
11842
12278
|
const lines = [];
|
|
11843
12279
|
for (const file of files.sort()) {
|
|
11844
|
-
const hash = await hashRelative(
|
|
12280
|
+
const hash = await hashRelative(root, file);
|
|
11845
12281
|
if (hash !== null) lines.push(`${file}\0${hash}`);
|
|
11846
12282
|
}
|
|
11847
12283
|
return createHash2("sha256").update(lines.join("\n")).digest("hex");
|
|
@@ -11855,6 +12291,7 @@ function serverStateFromWorkspace(state) {
|
|
|
11855
12291
|
prd: state.derivation.prdHash ?? files["PRD.md"] ?? null,
|
|
11856
12292
|
specs: fingerprint(files, (path) => path.startsWith("specs/")),
|
|
11857
12293
|
tasks: fingerprint(files, (path) => path.startsWith("tasks/") || path === "traceability.md"),
|
|
12294
|
+
docs: fingerprint(files, (path) => path.startsWith("docs/")),
|
|
11858
12295
|
derivation: parseDerivation(state.derivation)
|
|
11859
12296
|
};
|
|
11860
12297
|
}
|
|
@@ -11868,7 +12305,8 @@ async function fetchServerState(deps) {
|
|
|
11868
12305
|
}
|
|
11869
12306
|
async function mtime(bundleDir, relative3) {
|
|
11870
12307
|
try {
|
|
11871
|
-
|
|
12308
|
+
const target = isContractArtifactPath(relative3) ? resolveProjectPath(bundleDir, relative3) : join8(bundleDir, relative3);
|
|
12309
|
+
return (await stat4(target)).mtimeMs;
|
|
11872
12310
|
} catch {
|
|
11873
12311
|
return 0;
|
|
11874
12312
|
}
|
|
@@ -11908,7 +12346,7 @@ function issuesForStage(check, stage) {
|
|
|
11908
12346
|
function planAlignment(local, ledger, server, check) {
|
|
11909
12347
|
const localChanges = changedSince(local, ledger.local);
|
|
11910
12348
|
const previousServer = ledger.server === null ? null : serverAsSnapshot(ledger.server);
|
|
11911
|
-
const serverChanges = server === null || previousServer === null ? { prd: false, specs: false, tasks: false, any: false } : changedSince(serverAsSnapshot(server), previousServer);
|
|
12349
|
+
const serverChanges = server === null || previousServer === null ? { prd: false, specs: false, tasks: false, docs: false, any: false } : changedSince(serverAsSnapshot(server), previousServer);
|
|
11912
12350
|
if (localChanges.prd && serverChanges.prd && local.prd !== server?.prd) {
|
|
11913
12351
|
return {
|
|
11914
12352
|
kind: "conflict",
|
|
@@ -11970,13 +12408,15 @@ async function readContractFiles(bundleDir, snapshot, stages) {
|
|
|
11970
12408
|
const isPrd = path === "PRD.md";
|
|
11971
12409
|
const isSpecs = path.startsWith("specs/");
|
|
11972
12410
|
const isTasks = path.startsWith("tasks/") || path === "traceability.md";
|
|
12411
|
+
const isDocs = path.startsWith("docs/");
|
|
11973
12412
|
if (isPrd && !stages.prd) continue;
|
|
11974
12413
|
if (isSpecs && !stages.specs) continue;
|
|
11975
12414
|
if (isTasks && !stages.tasks) continue;
|
|
11976
|
-
|
|
12415
|
+
if (isDocs && !stages.docs) continue;
|
|
12416
|
+
files.push({ path, content: await readFile7(resolveProjectPath(bundleDir, path), "utf8") });
|
|
11977
12417
|
}
|
|
11978
12418
|
try {
|
|
11979
|
-
const state = await readFile7(
|
|
12419
|
+
const state = await readFile7(resolveProjectPath(bundleDir, EXECUTION_SIDECAR_PATH), "utf8");
|
|
11980
12420
|
files.push({ path: EXECUTION_SIDECAR_PATH, content: state });
|
|
11981
12421
|
} catch {
|
|
11982
12422
|
}
|
|
@@ -12003,6 +12443,7 @@ async function pushContract(deps, bundleDir, snapshot, stages, server) {
|
|
|
12003
12443
|
);
|
|
12004
12444
|
}
|
|
12005
12445
|
}
|
|
12446
|
+
await deps.client.ensureProjectLayout(deps.projectId).catch(() => null);
|
|
12006
12447
|
const files = await readContractFiles(bundleDir, snapshot, stages);
|
|
12007
12448
|
let result;
|
|
12008
12449
|
try {
|
|
@@ -12037,7 +12478,7 @@ async function pullContract(deps, bundleDir) {
|
|
|
12037
12478
|
try {
|
|
12038
12479
|
const listing = await deps.client.getWorkspaceArtifacts(deps.projectId);
|
|
12039
12480
|
const wanted = listing.files.filter(
|
|
12040
|
-
(path) => path === "PRD.md" || path === "traceability.md" || path.startsWith("specs/") || path.startsWith("tasks/")
|
|
12481
|
+
(path) => path === "PRD.md" || path === "traceability.md" || path.startsWith("specs/") || path.startsWith("tasks/") || path.startsWith("docs/")
|
|
12041
12482
|
);
|
|
12042
12483
|
const contents = /* @__PURE__ */ new Map();
|
|
12043
12484
|
for (const path of wanted) {
|
|
@@ -12049,11 +12490,12 @@ async function pullContract(deps, bundleDir) {
|
|
|
12049
12490
|
}
|
|
12050
12491
|
const local = await snapshotContract(bundleDir);
|
|
12051
12492
|
for (const path of Object.keys(local.files)) {
|
|
12052
|
-
if (
|
|
12493
|
+
if (path.startsWith("docs/")) continue;
|
|
12494
|
+
if (!contents.has(path)) await rm4(resolveProjectPath(bundleDir, path), { force: true });
|
|
12053
12495
|
}
|
|
12054
12496
|
for (const [path, content] of contents) {
|
|
12055
|
-
const target =
|
|
12056
|
-
await mkdir5(
|
|
12497
|
+
const target = resolveProjectPath(bundleDir, path);
|
|
12498
|
+
await mkdir5(join8(target, ".."), { recursive: true });
|
|
12057
12499
|
await writeFile5(target, content, "utf8");
|
|
12058
12500
|
}
|
|
12059
12501
|
await clearBaseline(bundleDir).catch(() => {
|
|
@@ -12087,8 +12529,8 @@ function authoringTimeoutMs() {
|
|
|
12087
12529
|
return Number.isFinite(value) && value > 0 ? value : 30 * 60 * 1e3;
|
|
12088
12530
|
}
|
|
12089
12531
|
async function runLocalAuthoring(stage, bundleDir, issues) {
|
|
12090
|
-
const configDir2 =
|
|
12091
|
-
const configPath =
|
|
12532
|
+
const configDir2 = join8(bundleDir, ".jioogen", "align");
|
|
12533
|
+
const configPath = join8(configDir2, "opencode.json");
|
|
12092
12534
|
await mkdir5(configDir2, { recursive: true });
|
|
12093
12535
|
const config = await buildAuthoringOpencodeConfig(bundledAuthoringPackDir());
|
|
12094
12536
|
await writeFile5(configPath, `${JSON.stringify(config, null, 2)}
|
|
@@ -12143,6 +12585,9 @@ async function runLocalAuthoring(stage, bundleDir, issues) {
|
|
|
12143
12585
|
});
|
|
12144
12586
|
}
|
|
12145
12587
|
async function alignBundle(bundleDir, deps = {}) {
|
|
12588
|
+
if (deps.client !== void 0 && deps.projectId !== void 0) {
|
|
12589
|
+
await deps.client.ensureProjectLayout(deps.projectId).catch(() => null);
|
|
12590
|
+
}
|
|
12146
12591
|
const applied = [];
|
|
12147
12592
|
let local = await snapshotContract(bundleDir);
|
|
12148
12593
|
let server = await fetchServerState(deps);
|
|
@@ -12280,7 +12725,7 @@ function formatAlign(result) {
|
|
|
12280
12725
|
// src/config.ts
|
|
12281
12726
|
import { chmod, mkdir as mkdir6, readFile as readFile8, rm as rm5, writeFile as writeFile6 } from "node:fs/promises";
|
|
12282
12727
|
import { homedir } from "node:os";
|
|
12283
|
-
import { dirname as dirname5, join as
|
|
12728
|
+
import { dirname as dirname5, join as join9, resolve as resolve2 } from "node:path";
|
|
12284
12729
|
|
|
12285
12730
|
// src/types.ts
|
|
12286
12731
|
var UI_QUALITY_MODES = ["auto", "on", "off"];
|
|
@@ -12302,13 +12747,13 @@ function configDirOverride() {
|
|
|
12302
12747
|
}
|
|
12303
12748
|
function configDir() {
|
|
12304
12749
|
const override = configDirOverride();
|
|
12305
|
-
return override !== void 0 ? resolve2(override) :
|
|
12750
|
+
return override !== void 0 ? resolve2(override) : join9(homedir(), ".config", "jioogen");
|
|
12306
12751
|
}
|
|
12307
12752
|
function legacyConfigDir() {
|
|
12308
|
-
return
|
|
12753
|
+
return join9(homedir(), ".config", "jioocode");
|
|
12309
12754
|
}
|
|
12310
12755
|
function credentialsPath() {
|
|
12311
|
-
return
|
|
12756
|
+
return join9(configDir(), CREDENTIALS_FILE);
|
|
12312
12757
|
}
|
|
12313
12758
|
function isRecord(value) {
|
|
12314
12759
|
return typeof value === "object" && value !== null;
|
|
@@ -12342,7 +12787,7 @@ async function readCredentials() {
|
|
|
12342
12787
|
const primary = await readCredentialsFile(credentialsPath());
|
|
12343
12788
|
if (primary !== null) return primary;
|
|
12344
12789
|
if (configDirOverride() !== void 0) return null;
|
|
12345
|
-
const legacyPath =
|
|
12790
|
+
const legacyPath = join9(legacyConfigDir(), CREDENTIALS_FILE);
|
|
12346
12791
|
if (legacyPath === credentialsPath()) return null;
|
|
12347
12792
|
return readCredentialsFile(legacyPath);
|
|
12348
12793
|
}
|
|
@@ -12359,7 +12804,7 @@ async function writeCredentials(credentials) {
|
|
|
12359
12804
|
}
|
|
12360
12805
|
async function clearCredentials() {
|
|
12361
12806
|
const removed = await removeCredentialsFile(credentialsPath());
|
|
12362
|
-
const legacyPath =
|
|
12807
|
+
const legacyPath = join9(legacyConfigDir(), CREDENTIALS_FILE);
|
|
12363
12808
|
if (legacyPath === credentialsPath()) return removed;
|
|
12364
12809
|
const removedLegacy = await removeCredentialsFile(legacyPath);
|
|
12365
12810
|
return removed || removedLegacy;
|
|
@@ -12429,7 +12874,7 @@ function parseTaskMode(value) {
|
|
|
12429
12874
|
}
|
|
12430
12875
|
async function readProjectLink(bundleDir) {
|
|
12431
12876
|
for (const directoryName of [PROJECT_DIR, LEGACY_PROJECT_DIR]) {
|
|
12432
|
-
const candidate =
|
|
12877
|
+
const candidate = join9(bundleDir, directoryName, PROJECT_FILE);
|
|
12433
12878
|
let raw = null;
|
|
12434
12879
|
try {
|
|
12435
12880
|
raw = await readFile8(candidate, "utf8");
|
|
@@ -12460,10 +12905,10 @@ async function findProjectLink(startDir) {
|
|
|
12460
12905
|
}
|
|
12461
12906
|
}
|
|
12462
12907
|
async function writeProjectLink(bundleDir, link) {
|
|
12463
|
-
const directory =
|
|
12908
|
+
const directory = join9(resolve2(bundleDir), PROJECT_DIR);
|
|
12464
12909
|
await mkdir6(directory, { recursive: true });
|
|
12465
12910
|
await writeFile6(
|
|
12466
|
-
|
|
12911
|
+
join9(directory, PROJECT_FILE),
|
|
12467
12912
|
`${JSON.stringify(
|
|
12468
12913
|
{
|
|
12469
12914
|
projectId: link.projectId,
|
|
@@ -12484,7 +12929,7 @@ async function writeProjectLink(bundleDir, link) {
|
|
|
12484
12929
|
async function removeProjectLink(bundleDir) {
|
|
12485
12930
|
let removedKey = false;
|
|
12486
12931
|
for (const directoryName of [PROJECT_DIR, LEGACY_PROJECT_DIR]) {
|
|
12487
|
-
const candidate =
|
|
12932
|
+
const candidate = join9(resolve2(bundleDir), directoryName, PROJECT_FILE);
|
|
12488
12933
|
try {
|
|
12489
12934
|
await rm5(candidate);
|
|
12490
12935
|
removedKey = true;
|
|
@@ -12508,13 +12953,13 @@ function isMissingFile3(error) {
|
|
|
12508
12953
|
|
|
12509
12954
|
// src/doctor.ts
|
|
12510
12955
|
import { readdir as readdir7, readFile as readFile10, rm as rm7, stat as stat6 } from "node:fs/promises";
|
|
12511
|
-
import { join as
|
|
12956
|
+
import { join as join11 } from "node:path";
|
|
12512
12957
|
|
|
12513
12958
|
// src/skills.ts
|
|
12514
12959
|
import { createHash as createHash3 } from "node:crypto";
|
|
12515
12960
|
import { cp as cp2, mkdir as mkdir7, readdir as readdir6, readFile as readFile9, rename as rename2, rm as rm6, stat as stat5, writeFile as writeFile7 } from "node:fs/promises";
|
|
12516
12961
|
import { homedir as homedir2 } from "node:os";
|
|
12517
|
-
import { dirname as dirname6, join as
|
|
12962
|
+
import { dirname as dirname6, join as join10, resolve as resolve3 } from "node:path";
|
|
12518
12963
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
12519
12964
|
var EXECUTION_SKILL_NAME = "jioogen-execution";
|
|
12520
12965
|
var AGENT_SKILL_DIRS = [
|
|
@@ -12572,7 +13017,7 @@ var JIOOGEN_AGENTS_MD = `${MARKER}
|
|
|
12572
13017
|
- Kamu mengeksekusi task; \`jioogen\` hanya memilih task dan menyinkronkan status.
|
|
12573
13018
|
|
|
12574
13019
|
## 0b. Peran & batas
|
|
12575
|
-
- **JiooGen (read-only):** pemilik konteks & kontrak \u2014 \`PRD.md\`, \`specs/\`, \`tasks/\`,
|
|
13020
|
+
- **JiooGen (read-only):** pemilik konteks & kontrak \u2014 \`docs/00-contract/PRD.md\`, \`specs/\`, \`tasks/\`,
|
|
12576
13021
|
urutan task, monitoring. Ia memilih task dan menyinkronkan status; **tidak**
|
|
12577
13022
|
mendesain, memecah task, mengedit kode, atau menjalankan test.
|
|
12578
13023
|
- **Kamu (Local Harness):** pembangun produk \u2014 desain UI/UX, breakdown naratif \u2192
|
|
@@ -12595,12 +13040,30 @@ var JIOOGEN_AGENTS_MD = `${MARKER}
|
|
|
12595
13040
|
bertanya. Cukup satu kalimat tentang dampaknya bagi produk.
|
|
12596
13041
|
- Contoh: "Saya mau mengubah PRD, lalu specs, lalu tasks. Boleh? (ya/tidak)".
|
|
12597
13042
|
|
|
13043
|
+
## 0d. Otonomi penyelarasan kontrak (wajib)
|
|
13044
|
+
|
|
13045
|
+
- **Jangan menyuruh user mengetik perintah \`jioogen\`.** Kamu yang menjalankan
|
|
13046
|
+
\`jioogen approve\`, \`jioogen align\`, dan \`jioogen docs\`.
|
|
13047
|
+
- Kontrak ada di \`docs/00-contract/\` (\`PRD.md\`, \`specs/\`, \`tasks/\`); dokumen lain
|
|
13048
|
+
ada di \`docs/01-product\`, \`02-design\`, \`03-architecture\`, \`04-domain\`,
|
|
13049
|
+
\`05-operations\`, \`06-quality\`. Baca \`docs/README.md\` lebih dulu.
|
|
13050
|
+
- Bila user bilang PRD berubah, minta ubah produk, atau specs/tasks tampak basi:
|
|
13051
|
+
tanya **sekali** dengan bahasa manusia, mis. "Mau saya rapikan specs, tasks,
|
|
13052
|
+
dan web sekaligus? (ya/tidak)". Setelah "ya", jalankan sendiri \`jioogen approve\`
|
|
13053
|
+
(bila PRD lokal berbeda dari web) lalu \`jioogen align\`.
|
|
13054
|
+
- Bila output CLI menyebut \`ALIGN_NEXT\` atau "kontrak belum selaras": jalankan
|
|
13055
|
+
aksinya sendiri. \`ALIGN_NEXT: approve\` \u2192 tanya sekali, lalu \`approve\` + \`align\`.
|
|
13056
|
+
- **Batch vs Manual:** tanyakan "Batch (sekaligus) atau Manual (satu per satu)?
|
|
13057
|
+
(batch/manual)". Pilihan disimpan; ganti hanya bila user memintanya eksplisit.
|
|
13058
|
+
- Dokumen = niat, kode = kenyataan. Bila berbeda, jangan menebak; tanyakan
|
|
13059
|
+
"Dokumen bilang A, kode melakukan B. Mana yang benar? (dokumen/kode)".
|
|
13060
|
+
|
|
12598
13061
|
## 1. Prioritas mutlak (keras)
|
|
12599
13062
|
- **Task aktif menang** atas ide, refactor, perbaikan, atau fitur lain.
|
|
12600
13063
|
- **Satu task per giliran.** Dilarang mengerjakan lebih dari satu task sekaligus.
|
|
12601
13064
|
- Dilarang pindah task sebelum task aktif \`done\` atau \`failed\`.
|
|
12602
13065
|
- Jangan mengarang fitur/endpoint/kolom yang tidak ada di \`PRD.md\`/\`specs/\`.
|
|
12603
|
-
- Jangan mengubah \`PRD.md
|
|
13066
|
+
- Jangan mengubah \`PRD.md\`/\`specs/\` di luar alur \xA70d; itu kontrak, bukan hasil eksekusi.
|
|
12604
13067
|
- **Warning CLI \u2260 BLOCKER, jangan loop.** Warning seperti ID task duplikat atau
|
|
12605
13068
|
drift bukan alasan menghentikan atau mengulang-ulang eksekusi: baca pesannya,
|
|
12606
13069
|
tandai kondisi di note (\`task start/complete --note "...id duplikat, default pakai
|
|
@@ -12665,8 +13128,8 @@ tangan) sebelum task dijalankan, jangan pura-pura mengerjakannya:
|
|
|
12665
13128
|
- Detail implementasi milikmu: pola komponen/state, struktur file di dalam
|
|
12666
13129
|
\`targetFiles\`, struktur test, dan library yang sudah ada. Ikuti konvensi proyek.
|
|
12667
13130
|
- \`targetFiles\` boleh file exact, direktori, atau glob. File baru hanya di area itu.
|
|
12668
|
-
- Jangan mengubah \`PRD.md\`/\`specs/\`/kontrak. Butuh perubahan
|
|
12669
|
-
|
|
13131
|
+
- Jangan mengubah \`PRD.md\`/\`specs/\`/kontrak di luar alur \xA70d. Butuh perubahan
|
|
13132
|
+
kontrak/data model? Hentikan task, minta izin sekali, lalu jalankan \xA70d.
|
|
12670
13133
|
|
|
12671
13134
|
## 3c. Micro-fix dalam task aktif (tanpa task baru)
|
|
12672
13135
|
Perbaikan kecil yang **wajib** agar Acceptance Criteria task aktif lulus boleh
|
|
@@ -12742,7 +13205,7 @@ atas ide, refactor, perbaikan, atau fitur lain.
|
|
|
12742
13205
|
|
|
12743
13206
|
## 0b. Peran & batas (JiooGen vs Local Harness)
|
|
12744
13207
|
|
|
12745
|
-
- **JiooGen (read-only):** pemilik konteks & kontrak \u2014 \`PRD.md\`, \`specs/\`, \`tasks/\`,
|
|
13208
|
+
- **JiooGen (read-only):** pemilik konteks & kontrak \u2014 \`docs/00-contract/PRD.md\`, \`specs/\`, \`tasks/\`,
|
|
12746
13209
|
urutan task, dan monitoring. Ia memilih task dan menyinkronkan status; **tidak**
|
|
12747
13210
|
mendesain, memecah task, mengedit kode, atau menjalankan test.
|
|
12748
13211
|
- **Kamu (Local Harness):** pembangun produk \u2014 desain UI/UX, breakdown naratif \u2192
|
|
@@ -12761,6 +13224,24 @@ atas ide, refactor, perbaikan, atau fitur lain.
|
|
|
12761
13224
|
- Skill UI (capability \`ui-quality\`, bila terpasang) dipakai untuk desain dan
|
|
12762
13225
|
review; tetap tunduk pada kontrak ini.
|
|
12763
13226
|
|
|
13227
|
+
## 0d. Otonomi penyelarasan kontrak (wajib)
|
|
13228
|
+
|
|
13229
|
+
- **Jangan menyuruh user mengetik perintah \`jioogen\`.** Kamu yang menjalankan
|
|
13230
|
+
\`jioogen approve\`, \`jioogen align\`, dan \`jioogen docs\`.
|
|
13231
|
+
- Kontrak ada di \`docs/00-contract/\` (\`PRD.md\`, \`specs/\`, \`tasks/\`); dokumen lain
|
|
13232
|
+
ada di \`docs/01-product\`, \`02-design\`, \`03-architecture\`, \`04-domain\`,
|
|
13233
|
+
\`05-operations\`, \`06-quality\`. Baca \`docs/README.md\` lebih dulu.
|
|
13234
|
+
- Bila user bilang PRD berubah, minta ubah produk, atau specs/tasks tampak basi:
|
|
13235
|
+
tanya **sekali** dengan bahasa manusia, mis. "Mau saya rapikan specs, tasks,
|
|
13236
|
+
dan web sekaligus? (ya/tidak)". Setelah "ya", jalankan sendiri \`jioogen approve\`
|
|
13237
|
+
(bila PRD lokal berbeda dari web) lalu \`jioogen align\`.
|
|
13238
|
+
- Bila output CLI menyebut \`ALIGN_NEXT\` atau "kontrak belum selaras": jalankan
|
|
13239
|
+
aksinya sendiri. \`ALIGN_NEXT: approve\` \u2192 tanya sekali, lalu \`approve\` + \`align\`.
|
|
13240
|
+
- **Batch vs Manual:** tanyakan "Batch (sekaligus) atau Manual (satu per satu)?
|
|
13241
|
+
(batch/manual)". Pilihan disimpan; ganti hanya bila user memintanya eksplisit.
|
|
13242
|
+
- Dokumen = niat, kode = kenyataan. Bila berbeda, jangan menebak; tanyakan
|
|
13243
|
+
"Dokumen bilang A, kode melakukan B. Mana yang benar? (dokumen/kode)".
|
|
13244
|
+
|
|
12764
13245
|
## 1. Prioritas mutlak (keras)
|
|
12765
13246
|
|
|
12766
13247
|
- **Kerjakan HANYA task aktif.** Task aktif menang atas semua pekerjaan lain.
|
|
@@ -12768,7 +13249,7 @@ atas ide, refactor, perbaikan, atau fitur lain.
|
|
|
12768
13249
|
- Dilarang pindah task sebelum task aktif \`done\` atau \`failed\`.
|
|
12769
13250
|
- Dilarang mengerjakan task yang belum dipilih \`task next\`, walau terlihat mudah.
|
|
12770
13251
|
- Jangan mengarang fitur/endpoint/kolom/state yang tidak ada di \`PRD.md\`/\`specs/\`.
|
|
12771
|
-
- Jangan mengubah \`PRD.md
|
|
13252
|
+
- Jangan mengubah \`PRD.md\`/\`specs/\` di luar alur \xA70d.
|
|
12772
13253
|
|
|
12773
13254
|
## 2. Siklus per giliran
|
|
12774
13255
|
|
|
@@ -12829,9 +13310,9 @@ atau ditulis tangan \u2014 sebelum task dijalankan, jangan pura-pura mengerjakan
|
|
|
12829
13310
|
- Ikuti konvensi proyek lebih dulu; jangan refactor di luar scope task.
|
|
12830
13311
|
- \`targetFiles\` boleh file exact, direktori, atau glob (mis.
|
|
12831
13312
|
\`src/features/booking/**\`). File baru hanya di dalam area itu.
|
|
12832
|
-
- Jangan mengubah \`PRD.md\`, \`specs/\`, atau kontrak (\`CONTRACT-XXX\`).
|
|
12833
|
-
implementasi menuntut perubahan kontrak/data model/scope:
|
|
12834
|
-
|
|
13313
|
+
- Jangan mengubah \`PRD.md\`, \`specs/\`, atau kontrak (\`CONTRACT-XXX\`) di luar \xA70d.
|
|
13314
|
+
Bila implementasi menuntut perubahan kontrak/data model/scope: hentikan task,
|
|
13315
|
+
minta izin sekali, lalu jalankan \xA70d \u2014 bukan mengarang atau menyimpang diam-diam.
|
|
12835
13316
|
|
|
12836
13317
|
## 3c. Micro-fix dalam task aktif (tanpa task baru)
|
|
12837
13318
|
|
|
@@ -12885,7 +13366,7 @@ Tanya: "Apakah senior engineer bilang ini overcomplicated?" Bila ya, sederhanaka
|
|
|
12885
13366
|
mengeditnya antar-sesi; agent **reuse/extend**, **jangan menimpa** edit user saat
|
|
12886
13367
|
task berjalan. Preferensi tambahan user di \`.jioogen/custom/design/\` (additive).
|
|
12887
13368
|
- Inspeksi token/theme/CSS variables/Tailwind/komponen/design reference yang sudah ada
|
|
12888
|
-
(specs/design.md, custom/design/, docs/DESIGN.md, specs, codebase). Reuse dulu;
|
|
13369
|
+
(specs/design.md, custom/design/, docs/02-design/DESIGN.md, specs, codebase). Reuse dulu;
|
|
12889
13370
|
token baru hanya untuk nilai visual berulang yang nyata; jangan hardcode nilai yang
|
|
12890
13371
|
sudah punya token; jangan membuat design system baru atau mengganti styling di luar
|
|
12891
13372
|
scope. Produk tanpa UI: \`N/A \u2014 tidak ada surface visual\`.
|
|
@@ -12949,11 +13430,11 @@ Gap non-material \u2192 tafsir paling sempit + catat asumsi di note, lanjut. Gap
|
|
|
12949
13430
|
Jangan menebak scope baru.
|
|
12950
13431
|
`;
|
|
12951
13432
|
async function ensureCustomScaffold(root) {
|
|
12952
|
-
const base =
|
|
13433
|
+
const base = join10(root, ".jioogen", "custom");
|
|
12953
13434
|
for (const dir of CUSTOM_SCAFFOLD_DIRS) {
|
|
12954
|
-
await mkdir7(
|
|
13435
|
+
await mkdir7(join10(base, dir), { recursive: true });
|
|
12955
13436
|
}
|
|
12956
|
-
const readme =
|
|
13437
|
+
const readme = join10(root, CUSTOM_SCAFFOLD_README_PATH);
|
|
12957
13438
|
if (await readFileSafe(readme) !== void 0) return [];
|
|
12958
13439
|
await writeFile7(readme, CUSTOM_SCAFFOLD_README, "utf8");
|
|
12959
13440
|
return [CUSTOM_SCAFFOLD_README_PATH];
|
|
@@ -13049,7 +13530,7 @@ function parseHarnessManifest(value) {
|
|
|
13049
13530
|
};
|
|
13050
13531
|
}
|
|
13051
13532
|
async function readHarnessManifest(bundleDir) {
|
|
13052
|
-
const path =
|
|
13533
|
+
const path = join10(resolve3(bundleDir), HARNESS_MANIFEST_PATH);
|
|
13053
13534
|
let raw;
|
|
13054
13535
|
try {
|
|
13055
13536
|
raw = await readFile9(path, "utf8");
|
|
@@ -13064,14 +13545,14 @@ async function readHarnessManifest(bundleDir) {
|
|
|
13064
13545
|
}
|
|
13065
13546
|
}
|
|
13066
13547
|
async function writeHarnessManifest(bundleDir, manifest) {
|
|
13067
|
-
const path =
|
|
13548
|
+
const path = join10(resolve3(bundleDir), HARNESS_MANIFEST_PATH);
|
|
13068
13549
|
await mkdir7(dirname6(path), { recursive: true });
|
|
13069
13550
|
await writeFile7(path, `${JSON.stringify(manifest, null, 2)}
|
|
13070
13551
|
`, "utf8");
|
|
13071
13552
|
return path;
|
|
13072
13553
|
}
|
|
13073
13554
|
async function detectProductKind(bundleDir) {
|
|
13074
|
-
const tasksDir =
|
|
13555
|
+
const tasksDir = join10(contractRoot(resolve3(bundleDir)), "tasks");
|
|
13075
13556
|
let entries;
|
|
13076
13557
|
try {
|
|
13077
13558
|
entries = await readdir6(tasksDir, { withFileTypes: true });
|
|
@@ -13081,7 +13562,7 @@ async function detectProductKind(bundleDir) {
|
|
|
13081
13562
|
}
|
|
13082
13563
|
for (const entry of entries) {
|
|
13083
13564
|
if (!entry.isFile() || !entry.name.toLowerCase().endsWith(".md")) continue;
|
|
13084
|
-
const content = await readFileSafe(
|
|
13565
|
+
const content = await readFileSafe(join10(tasksDir, entry.name));
|
|
13085
13566
|
if (content !== void 0 && FRONTEND_MOCK_LAYER_RE.test(content)) return "ui";
|
|
13086
13567
|
}
|
|
13087
13568
|
return "non-ui";
|
|
@@ -13102,25 +13583,25 @@ function cliPackageRoot2() {
|
|
|
13102
13583
|
function skillSourceCandidates(pack, name) {
|
|
13103
13584
|
const candidates = [];
|
|
13104
13585
|
const override = process.env.JIOOGEN_SKILLS_DIR?.trim();
|
|
13105
|
-
if (override !== void 0 && override.length > 0) candidates.push(
|
|
13106
|
-
candidates.push(
|
|
13107
|
-
candidates.push(
|
|
13586
|
+
if (override !== void 0 && override.length > 0) candidates.push(join10(override, name));
|
|
13587
|
+
candidates.push(join10(configDir(), "skill-cache", name));
|
|
13588
|
+
candidates.push(join10(cliPackageRoot2(), "skills-pack", pack, name));
|
|
13108
13589
|
const home = homedir2();
|
|
13109
|
-
candidates.push(
|
|
13110
|
-
candidates.push(
|
|
13111
|
-
candidates.push(
|
|
13590
|
+
candidates.push(join10(home, ".agents", "skills", name));
|
|
13591
|
+
candidates.push(join10(home, ".config", "opencode", "skills", name));
|
|
13592
|
+
candidates.push(join10(home, ".claude", "skills", name));
|
|
13112
13593
|
return candidates;
|
|
13113
13594
|
}
|
|
13114
13595
|
async function resolveSkillSource(pack, name) {
|
|
13115
13596
|
for (const candidate of skillSourceCandidates(pack, name)) {
|
|
13116
|
-
if (await isDirectory(candidate) && await isFile(
|
|
13597
|
+
if (await isDirectory(candidate) && await isFile(join10(candidate, "SKILL.md"))) {
|
|
13117
13598
|
return candidate;
|
|
13118
13599
|
}
|
|
13119
13600
|
}
|
|
13120
13601
|
return null;
|
|
13121
13602
|
}
|
|
13122
13603
|
async function collectRelativeFiles(root, prefix) {
|
|
13123
|
-
const entries = await readdir6(
|
|
13604
|
+
const entries = await readdir6(join10(root, prefix), { withFileTypes: true });
|
|
13124
13605
|
const files = [];
|
|
13125
13606
|
for (const entry of entries) {
|
|
13126
13607
|
const relative3 = prefix.length === 0 ? entry.name : `${prefix}/${entry.name}`;
|
|
@@ -13139,7 +13620,7 @@ async function hashSkillDirectory(directory) {
|
|
|
13139
13620
|
for (const relative3 of files) {
|
|
13140
13621
|
hash.update(relative3);
|
|
13141
13622
|
hash.update("\0");
|
|
13142
|
-
hash.update(await readFile9(
|
|
13623
|
+
hash.update(await readFile9(join10(root, ...relative3.split("/"))));
|
|
13143
13624
|
hash.update("\0");
|
|
13144
13625
|
}
|
|
13145
13626
|
return hash.digest("hex");
|
|
@@ -13166,8 +13647,8 @@ async function provisionPack(root, pack, prior, written, preserved) {
|
|
|
13166
13647
|
const previous = prior?.skills.find((entry) => entry.name === name);
|
|
13167
13648
|
let owned = previous !== void 0;
|
|
13168
13649
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13169
|
-
const targetDir =
|
|
13170
|
-
const skillMd =
|
|
13650
|
+
const targetDir = join10(root, dir, name);
|
|
13651
|
+
const skillMd = join10(targetDir, "SKILL.md");
|
|
13171
13652
|
if (await isFile(skillMd)) {
|
|
13172
13653
|
const targetHash = await hashSkillDirectory(targetDir);
|
|
13173
13654
|
if (previous === void 0) {
|
|
@@ -13198,7 +13679,7 @@ async function provisionCustomSkills(root, prior) {
|
|
|
13198
13679
|
const conflicts = [];
|
|
13199
13680
|
const removed = [];
|
|
13200
13681
|
const sources = /* @__PURE__ */ new Set();
|
|
13201
|
-
const base =
|
|
13682
|
+
const base = join10(root, CUSTOM_SKILLS_DIR);
|
|
13202
13683
|
const reserved = /* @__PURE__ */ new Set([EXECUTION_SKILL_NAME, ...Object.values(SKILL_PACKS).flat()]);
|
|
13203
13684
|
let entries = [];
|
|
13204
13685
|
try {
|
|
@@ -13208,8 +13689,8 @@ async function provisionCustomSkills(root, prior) {
|
|
|
13208
13689
|
}
|
|
13209
13690
|
const names = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
13210
13691
|
for (const name of names) {
|
|
13211
|
-
const source =
|
|
13212
|
-
if (!await isFile(
|
|
13692
|
+
const source = join10(base, name);
|
|
13693
|
+
if (!await isFile(join10(source, "SKILL.md"))) continue;
|
|
13213
13694
|
sources.add(name);
|
|
13214
13695
|
if (reserved.has(name)) {
|
|
13215
13696
|
conflicts.push(name);
|
|
@@ -13219,8 +13700,8 @@ async function provisionCustomSkills(root, prior) {
|
|
|
13219
13700
|
const previous = prior.find((entry) => entry.name === name);
|
|
13220
13701
|
let owned = previous !== void 0;
|
|
13221
13702
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13222
|
-
const targetDir =
|
|
13223
|
-
const skillMd =
|
|
13703
|
+
const targetDir = join10(root, dir, name);
|
|
13704
|
+
const skillMd = join10(targetDir, "SKILL.md");
|
|
13224
13705
|
if (await isFile(skillMd)) {
|
|
13225
13706
|
const targetHash = await hashSkillDirectory(targetDir);
|
|
13226
13707
|
if (previous === void 0) {
|
|
@@ -13254,8 +13735,8 @@ async function provisionCustomSkills(root, prior) {
|
|
|
13254
13735
|
if (sources.has(entry.name) && !reserved.has(entry.name)) continue;
|
|
13255
13736
|
if (reserved.has(entry.name)) continue;
|
|
13256
13737
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13257
|
-
const targetDir =
|
|
13258
|
-
const skillMd =
|
|
13738
|
+
const targetDir = join10(root, dir, entry.name);
|
|
13739
|
+
const skillMd = join10(targetDir, "SKILL.md");
|
|
13259
13740
|
if (!await isFile(skillMd)) continue;
|
|
13260
13741
|
const targetHash = await hashSkillDirectory(targetDir);
|
|
13261
13742
|
if (targetHash !== entry.sha256) {
|
|
@@ -13306,7 +13787,7 @@ async function provisionSkillPacks(bundleDir, packNames, productKind) {
|
|
|
13306
13787
|
};
|
|
13307
13788
|
}
|
|
13308
13789
|
async function ensureBundleGitignore(root) {
|
|
13309
|
-
const path =
|
|
13790
|
+
const path = join10(resolve3(root), ".gitignore");
|
|
13310
13791
|
const existing = await readFileSafe(path);
|
|
13311
13792
|
if (existing === void 0) {
|
|
13312
13793
|
await writeFile7(path, GITIGNORE_BLOCK, "utf8");
|
|
@@ -13325,8 +13806,8 @@ async function installAgentSkills(bundleDir, options = {}) {
|
|
|
13325
13806
|
const written = [];
|
|
13326
13807
|
const preserved = [];
|
|
13327
13808
|
const productKind = options.productKind ?? await detectProductKind(root);
|
|
13328
|
-
const harnessPath =
|
|
13329
|
-
const agentsPath =
|
|
13809
|
+
const harnessPath = join10(root, HARNESS_MANIFEST_PATH);
|
|
13810
|
+
const agentsPath = join10(root, "AGENTS.md");
|
|
13330
13811
|
const existing = await readFileSafe(agentsPath);
|
|
13331
13812
|
if (existing === void 0 || existing.includes(MARKER_PREFIX)) {
|
|
13332
13813
|
await writeFile7(agentsPath, JIOOGEN_AGENTS_MD, "utf8");
|
|
@@ -13336,7 +13817,7 @@ async function installAgentSkills(bundleDir, options = {}) {
|
|
|
13336
13817
|
}
|
|
13337
13818
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13338
13819
|
const relative3 = `${dir}/${EXECUTION_SKILL_NAME}/SKILL.md`;
|
|
13339
|
-
const target =
|
|
13820
|
+
const target = join10(root, relative3);
|
|
13340
13821
|
await mkdir7(dirname6(target), { recursive: true });
|
|
13341
13822
|
await writeFile7(target, JIOOGEN_EXECUTION_SKILL, "utf8");
|
|
13342
13823
|
written.push(relative3);
|
|
@@ -13406,7 +13887,7 @@ async function removeExecutionContract(bundleDir) {
|
|
|
13406
13887
|
const root = resolve3(bundleDir);
|
|
13407
13888
|
const removed = [];
|
|
13408
13889
|
const preserved = [];
|
|
13409
|
-
const agentsPath =
|
|
13890
|
+
const agentsPath = join10(root, "AGENTS.md");
|
|
13410
13891
|
const existingAgents = await readFileSafe(agentsPath);
|
|
13411
13892
|
if (existingAgents !== void 0) {
|
|
13412
13893
|
if (existingAgents.includes(MARKER_PREFIX)) {
|
|
@@ -13417,7 +13898,7 @@ async function removeExecutionContract(bundleDir) {
|
|
|
13417
13898
|
}
|
|
13418
13899
|
}
|
|
13419
13900
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13420
|
-
const target =
|
|
13901
|
+
const target = join10(root, dir, EXECUTION_SKILL_NAME);
|
|
13421
13902
|
try {
|
|
13422
13903
|
const info = await stat5(target);
|
|
13423
13904
|
if (info.isDirectory()) {
|
|
@@ -13440,8 +13921,8 @@ async function removeSkillPack(bundleDir, pack) {
|
|
|
13440
13921
|
if (entry !== void 0) {
|
|
13441
13922
|
for (const skill of entry.skills) {
|
|
13442
13923
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13443
|
-
const targetDir =
|
|
13444
|
-
const skillMd =
|
|
13924
|
+
const targetDir = join10(root, dir, skill.name);
|
|
13925
|
+
const skillMd = join10(targetDir, "SKILL.md");
|
|
13445
13926
|
if (!await isFile(skillMd)) continue;
|
|
13446
13927
|
const targetHash = await hashSkillDirectory(targetDir);
|
|
13447
13928
|
if (targetHash !== skill.sha256) {
|
|
@@ -13484,7 +13965,7 @@ async function restoreSkillPack(bundleDir, packArgument) {
|
|
|
13484
13965
|
}
|
|
13485
13966
|
const sha2562 = await hashSkillDirectory(source);
|
|
13486
13967
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13487
|
-
const targetDir =
|
|
13968
|
+
const targetDir = join10(root, dir, name);
|
|
13488
13969
|
await replaceDirectory(source, targetDir);
|
|
13489
13970
|
restored.push(`${dir}/${name}`);
|
|
13490
13971
|
}
|
|
@@ -13510,7 +13991,7 @@ async function disableSkill(bundleDir, name) {
|
|
|
13510
13991
|
const root = resolve3(bundleDir);
|
|
13511
13992
|
const disabled = [];
|
|
13512
13993
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13513
|
-
const targetDir =
|
|
13994
|
+
const targetDir = join10(root, dir, name);
|
|
13514
13995
|
const disabledDir = `${targetDir}.disabled`;
|
|
13515
13996
|
if (!await isDirectory(targetDir)) continue;
|
|
13516
13997
|
if (await isDirectory(disabledDir)) await rm6(disabledDir, { recursive: true, force: true });
|
|
@@ -13523,7 +14004,7 @@ async function enableSkill(bundleDir, name) {
|
|
|
13523
14004
|
const root = resolve3(bundleDir);
|
|
13524
14005
|
const enabled = [];
|
|
13525
14006
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13526
|
-
const targetDir =
|
|
14007
|
+
const targetDir = join10(root, dir, name);
|
|
13527
14008
|
const disabledDir = `${targetDir}.disabled`;
|
|
13528
14009
|
if (!await isDirectory(disabledDir)) continue;
|
|
13529
14010
|
if (await isDirectory(targetDir)) await rm6(disabledDir, { recursive: true, force: true });
|
|
@@ -13712,17 +14193,18 @@ async function listMarkdownFiles(directory) {
|
|
|
13712
14193
|
}
|
|
13713
14194
|
async function checkBundle(bundleDir) {
|
|
13714
14195
|
const missing = [];
|
|
13715
|
-
|
|
13716
|
-
|
|
14196
|
+
const contract = contractRoot(bundleDir);
|
|
14197
|
+
if (!await isFile2(join11(contract, "PRD.md"))) missing.push("PRD.md");
|
|
14198
|
+
const specsDir = join11(contract, "specs");
|
|
13717
14199
|
if (!await isDirectory2(specsDir)) {
|
|
13718
14200
|
missing.push("specs/");
|
|
13719
14201
|
} else {
|
|
13720
14202
|
const markdown = await listMarkdownFiles(specsDir);
|
|
13721
|
-
const readme = await readFile10(
|
|
14203
|
+
const readme = await readFile10(join11(specsDir, "SPECS.md"), "utf8").catch(() => "");
|
|
13722
14204
|
const hasContent = markdown.some((name) => name.toLowerCase() !== "specs.md") || specReadmeIsContent(readme);
|
|
13723
14205
|
if (!hasContent) missing.push("specs/*.md (konten)");
|
|
13724
14206
|
}
|
|
13725
|
-
const tasksDir =
|
|
14207
|
+
const tasksDir = join11(contract, "tasks");
|
|
13726
14208
|
if (!await isDirectory2(tasksDir)) {
|
|
13727
14209
|
missing.push("tasks/");
|
|
13728
14210
|
} else {
|
|
@@ -13815,7 +14297,7 @@ async function checkDrift(bundleDir) {
|
|
|
13815
14297
|
}
|
|
13816
14298
|
}
|
|
13817
14299
|
async function checkRecovery(bundleDir) {
|
|
13818
|
-
const path =
|
|
14300
|
+
const path = join11(contractRoot(bundleDir), "tasks/.execution/recovery.json");
|
|
13819
14301
|
let raw;
|
|
13820
14302
|
try {
|
|
13821
14303
|
raw = await readFile10(path, "utf8");
|
|
@@ -13875,7 +14357,7 @@ async function checkLock(bundleDir) {
|
|
|
13875
14357
|
async function checkAgents(bundleDir) {
|
|
13876
14358
|
let content;
|
|
13877
14359
|
try {
|
|
13878
|
-
content = await readFile10(
|
|
14360
|
+
content = await readFile10(join11(bundleDir, "AGENTS.md"), "utf8");
|
|
13879
14361
|
} catch (error) {
|
|
13880
14362
|
if (isMissingFile5(error)) {
|
|
13881
14363
|
return makeCheck(
|
|
@@ -13905,7 +14387,7 @@ async function checkAgents(bundleDir) {
|
|
|
13905
14387
|
async function checkExecutionSkill(bundleDir) {
|
|
13906
14388
|
const missing = [];
|
|
13907
14389
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13908
|
-
const target =
|
|
14390
|
+
const target = join11(bundleDir, dir, EXECUTION_SKILL_NAME, "SKILL.md");
|
|
13909
14391
|
if (!await isFile2(target)) missing.push(dir);
|
|
13910
14392
|
}
|
|
13911
14393
|
if (missing.length > 0) {
|
|
@@ -13953,8 +14435,8 @@ async function checkSkillPacks(bundleDir) {
|
|
|
13953
14435
|
for (const skill of pack.skills) {
|
|
13954
14436
|
let matched = false;
|
|
13955
14437
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
13956
|
-
const target =
|
|
13957
|
-
if (!await isFile2(
|
|
14438
|
+
const target = join11(bundleDir, dir, skill.name);
|
|
14439
|
+
if (!await isFile2(join11(target, "SKILL.md"))) continue;
|
|
13958
14440
|
try {
|
|
13959
14441
|
if (await hashSkillDirectory(target) === skill.sha256) {
|
|
13960
14442
|
matched = true;
|
|
@@ -14001,7 +14483,7 @@ function capabilityModelNotRequired(content) {
|
|
|
14001
14483
|
return notRequired;
|
|
14002
14484
|
}
|
|
14003
14485
|
async function collectMarkdownFiles2(root, prefix = "") {
|
|
14004
|
-
const dir =
|
|
14486
|
+
const dir = join11(root, prefix);
|
|
14005
14487
|
let entries;
|
|
14006
14488
|
try {
|
|
14007
14489
|
entries = await readdir7(dir, { withFileTypes: true });
|
|
@@ -14017,18 +14499,19 @@ async function collectMarkdownFiles2(root, prefix = "") {
|
|
|
14017
14499
|
return files;
|
|
14018
14500
|
}
|
|
14019
14501
|
async function checkCapabilityCoverage(bundleDir) {
|
|
14502
|
+
const contract = contractRoot(bundleDir);
|
|
14020
14503
|
const taskCaps = /* @__PURE__ */ new Map();
|
|
14021
|
-
for (const relative3 of await collectMarkdownFiles2(
|
|
14504
|
+
for (const relative3 of await collectMarkdownFiles2(contract, "tasks")) {
|
|
14022
14505
|
if (relative3 === BUNDLE_PATHS.TASKS_INDEX) continue;
|
|
14023
|
-
const content = await readFile10(
|
|
14506
|
+
const content = await readFile10(join11(contract, relative3), "utf8");
|
|
14024
14507
|
const cap = TASK_CAP_RE.exec(content)?.[1]?.toUpperCase();
|
|
14025
14508
|
if (cap === void 0) continue;
|
|
14026
14509
|
taskCaps.set(cap, relative3);
|
|
14027
14510
|
}
|
|
14028
14511
|
const specCaps = /* @__PURE__ */ new Set();
|
|
14029
14512
|
const notRequiredCaps = /* @__PURE__ */ new Set();
|
|
14030
|
-
for (const relative3 of await collectMarkdownFiles2(
|
|
14031
|
-
const content = await readFile10(
|
|
14513
|
+
for (const relative3 of await collectMarkdownFiles2(contract, "specs")) {
|
|
14514
|
+
const content = await readFile10(join11(contract, relative3), "utf8");
|
|
14032
14515
|
for (const match of content.matchAll(CAP_ID_RE)) {
|
|
14033
14516
|
const id = match[0].toUpperCase();
|
|
14034
14517
|
if (CAP_PLACEHOLDER_RE.test(id)) continue;
|
|
@@ -14079,7 +14562,7 @@ async function checkDuplicates(bundleDir) {
|
|
|
14079
14562
|
}
|
|
14080
14563
|
const dirsByName = /* @__PURE__ */ new Map();
|
|
14081
14564
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14082
|
-
const root =
|
|
14565
|
+
const root = join11(bundleDir, dir);
|
|
14083
14566
|
if (!await isDirectory2(root)) continue;
|
|
14084
14567
|
let entries;
|
|
14085
14568
|
try {
|
|
@@ -14090,7 +14573,7 @@ async function checkDuplicates(bundleDir) {
|
|
|
14090
14573
|
for (const entry of entries) {
|
|
14091
14574
|
if (!entry.isDirectory()) continue;
|
|
14092
14575
|
if (managed.has(entry.name)) continue;
|
|
14093
|
-
if (!await isFile2(
|
|
14576
|
+
if (!await isFile2(join11(root, entry.name, "SKILL.md"))) continue;
|
|
14094
14577
|
const owners = dirsByName.get(entry.name) ?? [];
|
|
14095
14578
|
owners.push(dir);
|
|
14096
14579
|
dirsByName.set(entry.name, owners);
|
|
@@ -14110,7 +14593,7 @@ async function checkDuplicates(bundleDir) {
|
|
|
14110
14593
|
async function checkHarness(bundleDir) {
|
|
14111
14594
|
const detected = [];
|
|
14112
14595
|
for (const dir of AGENT_SKILL_DIRS) {
|
|
14113
|
-
if (await isDirectory2(
|
|
14596
|
+
if (await isDirectory2(join11(bundleDir, dir))) detected.push(dir);
|
|
14114
14597
|
}
|
|
14115
14598
|
if (detected.length === 0) {
|
|
14116
14599
|
return makeCheck("harness", "pass", "Tidak ada direktori harness terdeteksi.");
|
|
@@ -14208,7 +14691,7 @@ function formatTable(headers, rows) {
|
|
|
14208
14691
|
// src/recovery.ts
|
|
14209
14692
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
14210
14693
|
import { mkdir as mkdir8, readFile as readFile11, rename as rename3, rm as rm8, writeFile as writeFile8 } from "node:fs/promises";
|
|
14211
|
-
import { dirname as dirname7, join as
|
|
14694
|
+
import { dirname as dirname7, join as join12 } from "node:path";
|
|
14212
14695
|
var RECOVERY_PATH = "tasks/.execution/recovery.json";
|
|
14213
14696
|
var RECOVERY_BUDGET = { maxAttempts: 3 };
|
|
14214
14697
|
var RECOVERY_BASE_ATTEMPTS = 3;
|
|
@@ -14220,7 +14703,7 @@ function recoveryBudget(input) {
|
|
|
14220
14703
|
return Math.min(budget, RECOVERY_MAX_ATTEMPTS);
|
|
14221
14704
|
}
|
|
14222
14705
|
function recoveryPath(bundleDir) {
|
|
14223
|
-
return
|
|
14706
|
+
return join12(bundleDir, RECOVERY_PATH);
|
|
14224
14707
|
}
|
|
14225
14708
|
function emptyJournal() {
|
|
14226
14709
|
return { schemaVersion: 1, tasks: {} };
|
|
@@ -14561,7 +15044,7 @@ async function extractBundle(bytes, targetDir) {
|
|
|
14561
15044
|
throw new Error(`Path bundle tidak aman: ${entry.entryName}`);
|
|
14562
15045
|
}
|
|
14563
15046
|
if (isIgnoredBundlePath(relative3)) continue;
|
|
14564
|
-
const destination =
|
|
15047
|
+
const destination = resolveProjectPath(root, relative3);
|
|
14565
15048
|
if (!destination.startsWith(`${root}${sep}`)) {
|
|
14566
15049
|
throw new Error(`Path bundle keluar dari direktori target: ${entry.entryName}`);
|
|
14567
15050
|
}
|
|
@@ -14724,9 +15207,13 @@ async function pullCommand(projectId, options) {
|
|
|
14724
15207
|
const target = resolve6(options.dir ?? projectId);
|
|
14725
15208
|
await assertPullTarget(target, projectId, options.force === true);
|
|
14726
15209
|
const bytes = await client.getBytes(projectPath(projectId, "/bundle"));
|
|
15210
|
+
const layout = migrateContractLayout(target);
|
|
15211
|
+
ensureDocsTree(target);
|
|
15212
|
+
writeDocsReadme(target);
|
|
14727
15213
|
const written = await extractBundle(bytes, target);
|
|
14728
15214
|
await clearBaseline(target).catch(() => {
|
|
14729
15215
|
});
|
|
15216
|
+
migrateKnownDocs(target);
|
|
14730
15217
|
const localContract = await snapshotContract(target);
|
|
14731
15218
|
const serverContract = await client.getWorkspaceArtifacts(projectId).then(serverStateFromWorkspace).catch(() => null);
|
|
14732
15219
|
await writeContractLedger(
|
|
@@ -14754,6 +15241,9 @@ async function pullCommand(projectId, options) {
|
|
|
14754
15241
|
console.log(JSON.stringify({ projectId, target, files: written, skills }, null, 2));
|
|
14755
15242
|
return;
|
|
14756
15243
|
}
|
|
15244
|
+
if (layout.migrated && layout.moved.length > 0) {
|
|
15245
|
+
console.log("Struktur dokumen dirapikan: kontrak dipindah ke docs/00-contract.");
|
|
15246
|
+
}
|
|
14757
15247
|
console.log(`Pulled ${written.length} file ke ${target}`);
|
|
14758
15248
|
console.log("Project ter-bind lewat .jioogen/project.json.");
|
|
14759
15249
|
console.log(`Skills eksekusi terpasang: ${skills.written.length} file.`);
|
|
@@ -14764,6 +15254,11 @@ async function linkCommand(projectId, options) {
|
|
|
14764
15254
|
const target = resolve6(options.dir ?? process.cwd());
|
|
14765
15255
|
await assertLinkTarget(target, projectId);
|
|
14766
15256
|
await verifyProjectAccess(client, projectId);
|
|
15257
|
+
const layout = migrateContractLayout(target);
|
|
15258
|
+
ensureDocsTree(target);
|
|
15259
|
+
migrateKnownDocs(target);
|
|
15260
|
+
writeDocsReadme(target);
|
|
15261
|
+
await client.ensureProjectLayout(projectId).catch(() => null);
|
|
14767
15262
|
const taskMode = options.taskMode ?? await readTaskMode(target);
|
|
14768
15263
|
const uiQuality = options.uiQuality ?? await readUiQuality(target);
|
|
14769
15264
|
await writeProjectLink(target, {
|
|
@@ -14788,12 +15283,15 @@ async function linkCommand(projectId, options) {
|
|
|
14788
15283
|
serverContract?.derivation ?? freshDerivation(localContract)
|
|
14789
15284
|
)
|
|
14790
15285
|
);
|
|
14791
|
-
const linkedFile =
|
|
15286
|
+
const linkedFile = join13(target, ".jioogen", "project.json");
|
|
14792
15287
|
if (options.json === true) {
|
|
14793
15288
|
console.log(JSON.stringify({ projectId, target, apiUrl, linkedFile, skills }, null, 2));
|
|
14794
15289
|
return;
|
|
14795
15290
|
}
|
|
14796
15291
|
console.log(`Project ${projectId} ter-bind ke ${target}.`);
|
|
15292
|
+
if (layout.migrated && layout.moved.length > 0) {
|
|
15293
|
+
console.log("Struktur dokumen dirapikan: kontrak dipindah ke docs/00-contract.");
|
|
15294
|
+
}
|
|
14797
15295
|
console.log(`File link: ${linkedFile} (API ${apiUrl}).`);
|
|
14798
15296
|
console.log(`Skills eksekusi terpasang: ${skills.written.length} file.`);
|
|
14799
15297
|
printSkillPacks(skills.packs, skills.missing, skills.custom, skills.conflicts);
|
|
@@ -14964,6 +15462,10 @@ function printSkillPacks(packs, missing, custom2 = [], conflicts = []) {
|
|
|
14964
15462
|
}
|
|
14965
15463
|
async function alignCommand(options) {
|
|
14966
15464
|
const local = await resolveLocalBundle(options);
|
|
15465
|
+
migrateContractLayout(local.bundleDir);
|
|
15466
|
+
ensureDocsTree(local.bundleDir);
|
|
15467
|
+
migrateKnownDocs(local.bundleDir);
|
|
15468
|
+
writeDocsReadme(local.bundleDir);
|
|
14967
15469
|
let client;
|
|
14968
15470
|
const noSync = options.noSync === true || process.env.JIOOGEN_NO_SYNC === "1";
|
|
14969
15471
|
if (!noSync) {
|
|
@@ -14992,6 +15494,63 @@ async function alignCommand(options) {
|
|
|
14992
15494
|
}
|
|
14993
15495
|
if (!result.ok) process.exitCode = 1;
|
|
14994
15496
|
}
|
|
15497
|
+
async function docsCommand(options, subcommand) {
|
|
15498
|
+
const link = await findProjectLink(options.dir ?? process.cwd());
|
|
15499
|
+
const bundleDir = resolve6(link?.bundleDir ?? options.dir ?? process.cwd());
|
|
15500
|
+
if (subcommand === "migrate") {
|
|
15501
|
+
const contract = migrateContractLayout(bundleDir, { dryRun: options.dryRun === true });
|
|
15502
|
+
const docs = migrateKnownDocs(bundleDir, { dryRun: options.dryRun === true });
|
|
15503
|
+
if (options.dryRun !== true) {
|
|
15504
|
+
ensureDocsTree(bundleDir);
|
|
15505
|
+
writeDocsReadme(bundleDir);
|
|
15506
|
+
}
|
|
15507
|
+
if (options.json === true) {
|
|
15508
|
+
console.log(JSON.stringify({ contract, docs, dryRun: options.dryRun === true }, null, 2));
|
|
15509
|
+
return;
|
|
15510
|
+
}
|
|
15511
|
+
if (contract.moved.length === 0 && docs.moved.length === 0) {
|
|
15512
|
+
console.log("Dokumen sudah rapi; tidak ada yang dipindah.");
|
|
15513
|
+
return;
|
|
15514
|
+
}
|
|
15515
|
+
for (const move of [...contract.moved, ...docs.moved]) console.log(`- ${move}`);
|
|
15516
|
+
if (options.dryRun === true) console.log("(dry-run: belum ada file yang dipindah)");
|
|
15517
|
+
return;
|
|
15518
|
+
}
|
|
15519
|
+
if (subcommand === "index") {
|
|
15520
|
+
ensureDocsTree(bundleDir);
|
|
15521
|
+
writeDocsReadme(bundleDir, true);
|
|
15522
|
+
console.log("docs/README.md ditulis ulang.");
|
|
15523
|
+
return;
|
|
15524
|
+
}
|
|
15525
|
+
if (subcommand === "scan") {
|
|
15526
|
+
const rootEntries = await readdir8(bundleDir, { withFileTypes: true }).catch(() => []);
|
|
15527
|
+
const misplaced = rootEntries.filter(
|
|
15528
|
+
(entry) => entry.isFile() && entry.name.toLowerCase().endsWith(".md") && entry.name.toLowerCase() !== "agents.md" && entry.name.toLowerCase() !== "prd.md"
|
|
15529
|
+
).map((entry) => entry.name);
|
|
15530
|
+
const result = { misplaced, docsReadme: existsSync3(join13(bundleDir, "docs", "README.md")) };
|
|
15531
|
+
if (options.json === true) console.log(JSON.stringify(result, null, 2));
|
|
15532
|
+
else {
|
|
15533
|
+
console.log(`Dokumen di root yang sebaiknya dipindah: ${misplaced.length}`);
|
|
15534
|
+
for (const name of misplaced) console.log(`- ${name}`);
|
|
15535
|
+
console.log(result.docsReadme ? "docs/README.md ada." : "docs/README.md belum ada.");
|
|
15536
|
+
}
|
|
15537
|
+
return;
|
|
15538
|
+
}
|
|
15539
|
+
if (subcommand === "check") {
|
|
15540
|
+
const issues = [];
|
|
15541
|
+
if (!existsSync3(join13(bundleDir, "docs", "README.md"))) issues.push("docs/README.md belum ada");
|
|
15542
|
+
if (existsSync3(join13(bundleDir, "DESIGN.md"))) issues.push("DESIGN.md masih di root");
|
|
15543
|
+
if (existsSync3(join13(bundleDir, "STACK.md"))) issues.push("STACK.md masih di root");
|
|
15544
|
+
if (issues.length > 0) {
|
|
15545
|
+
for (const issue2 of issues) console.log(`\u26A0 ${issue2}`);
|
|
15546
|
+
process.exitCode = 1;
|
|
15547
|
+
} else {
|
|
15548
|
+
console.log("Struktur dokumen rapi.");
|
|
15549
|
+
}
|
|
15550
|
+
return;
|
|
15551
|
+
}
|
|
15552
|
+
throw new UsageError("Subcommand docs: scan | migrate | index | check");
|
|
15553
|
+
}
|
|
14995
15554
|
async function approveCommand(options) {
|
|
14996
15555
|
const { bundleDir } = await resolveLocalBundle(options);
|
|
14997
15556
|
const local = await snapshotContract(bundleDir);
|
|
@@ -15046,6 +15605,7 @@ async function doctorCommand(options) {
|
|
|
15046
15605
|
const link = await findProjectLink(options.dir ?? process.cwd());
|
|
15047
15606
|
const bundleDir = resolve6(link?.bundleDir ?? options.dir ?? process.cwd());
|
|
15048
15607
|
const projectId = options.project ?? link?.projectId;
|
|
15608
|
+
if (options.fix === true) migrateContractLayout(bundleDir);
|
|
15049
15609
|
const report = await runDoctor({
|
|
15050
15610
|
bundleDir,
|
|
15051
15611
|
...projectId === void 0 ? {} : { projectId },
|
|
@@ -15159,6 +15719,11 @@ async function handoffCommand(options) {
|
|
|
15159
15719
|
}
|
|
15160
15720
|
async function alignBeforeTask(options) {
|
|
15161
15721
|
const local = await resolveLocalBundle(options);
|
|
15722
|
+
migrateContractLayout(local.bundleDir);
|
|
15723
|
+
ensureDocsTree(local.bundleDir);
|
|
15724
|
+
migrateKnownDocs(local.bundleDir);
|
|
15725
|
+
writeDocsReadme(local.bundleDir);
|
|
15726
|
+
await installAgentSkills(local.bundleDir, { noSkills: true }).catch(() => null);
|
|
15162
15727
|
const contract = await snapshotContract(local.bundleDir);
|
|
15163
15728
|
if (!hasContractArtifacts(contract)) return true;
|
|
15164
15729
|
const ledger = await readContractLedger(local.bundleDir);
|
|
@@ -15338,7 +15903,7 @@ ${items.map((item, index) => `- [ ] ${prefix}-${String(index + 1).padStart(2, "0
|
|
|
15338
15903
|
return;
|
|
15339
15904
|
}
|
|
15340
15905
|
if (authored.length > 0) {
|
|
15341
|
-
const path2 =
|
|
15906
|
+
const path2 = join13(contractRoot(local.bundleDir), "tasks", definition.file);
|
|
15342
15907
|
const current = await readFile12(path2, "utf8");
|
|
15343
15908
|
const stripped = current.replace(/\n##\s+Subtasks\b[\s\S]*?(?=\n##\s|$)/i, "").replace(/\n{3,}/g, "\n\n");
|
|
15344
15909
|
await writeFile10(path2, `${stripped.trimEnd()}
|
|
@@ -15349,8 +15914,8 @@ ${section3}`, "utf8");
|
|
|
15349
15914
|
);
|
|
15350
15915
|
return;
|
|
15351
15916
|
}
|
|
15352
|
-
const dir =
|
|
15353
|
-
const path =
|
|
15917
|
+
const dir = join13(local.bundleDir, ".jioogen", "breakdown");
|
|
15918
|
+
const path = join13(dir, `${definition.id}.md`);
|
|
15354
15919
|
await mkdir10(dir, { recursive: true });
|
|
15355
15920
|
await writeFile10(
|
|
15356
15921
|
path,
|
|
@@ -15559,7 +16124,7 @@ async function stampVerification(context, definitions, ref, proof, visualSummary
|
|
|
15559
16124
|
async function resolveFallbackVerificationCommand(bundleDir, failedCommand) {
|
|
15560
16125
|
let pkgRaw;
|
|
15561
16126
|
try {
|
|
15562
|
-
pkgRaw = await readFile12(
|
|
16127
|
+
pkgRaw = await readFile12(join13(bundleDir, "package.json"), "utf8");
|
|
15563
16128
|
} catch {
|
|
15564
16129
|
return null;
|
|
15565
16130
|
}
|
|
@@ -15989,7 +16554,7 @@ async function driftCommand(options) {
|
|
|
15989
16554
|
async function baselineListCommand(options) {
|
|
15990
16555
|
const bundleDir = await resolveSkillsBundleDir(options);
|
|
15991
16556
|
const manifest = await readHarnessManifest(bundleDir);
|
|
15992
|
-
const knowledgeDir =
|
|
16557
|
+
const knowledgeDir = join13(bundleDir, ".jioogen", "custom", "knowledge");
|
|
15993
16558
|
let knowledgeFiles = [];
|
|
15994
16559
|
try {
|
|
15995
16560
|
const entries = await readdir8(knowledgeDir, { withFileTypes: true });
|
|
@@ -16000,12 +16565,12 @@ async function baselineListCommand(options) {
|
|
|
16000
16565
|
const nonEmptyKnowledge = [];
|
|
16001
16566
|
for (const name of knowledgeFiles) {
|
|
16002
16567
|
try {
|
|
16003
|
-
const content = await readFile12(
|
|
16568
|
+
const content = await readFile12(join13(knowledgeDir, name), "utf8");
|
|
16004
16569
|
if (content.trim().length > 0) nonEmptyKnowledge.push(name);
|
|
16005
16570
|
} catch {
|
|
16006
16571
|
}
|
|
16007
16572
|
}
|
|
16008
|
-
const customSkillsDir =
|
|
16573
|
+
const customSkillsDir = join13(bundleDir, ".jioogen", "custom", "skills");
|
|
16009
16574
|
let customSkillNames = [];
|
|
16010
16575
|
try {
|
|
16011
16576
|
const entries = await readdir8(customSkillsDir, { withFileTypes: true });
|
|
@@ -16013,7 +16578,7 @@ async function baselineListCommand(options) {
|
|
|
16013
16578
|
} catch {
|
|
16014
16579
|
customSkillNames = [];
|
|
16015
16580
|
}
|
|
16016
|
-
const agentsPath =
|
|
16581
|
+
const agentsPath = join13(bundleDir, "AGENTS.md");
|
|
16017
16582
|
let agentsExists = false;
|
|
16018
16583
|
let agentsBaseline = false;
|
|
16019
16584
|
try {
|
|
@@ -16106,10 +16671,11 @@ async function syncCommand(options) {
|
|
|
16106
16671
|
assertBundleRelative(relative3);
|
|
16107
16672
|
files.push({
|
|
16108
16673
|
path: relative3,
|
|
16109
|
-
content: await readFile12(
|
|
16674
|
+
content: await readFile12(resolveProjectPath(bundleDir, relative3), "utf8")
|
|
16110
16675
|
});
|
|
16111
16676
|
}
|
|
16112
16677
|
}
|
|
16678
|
+
await client.ensureProjectLayout(projectId).catch(() => null);
|
|
16113
16679
|
let result;
|
|
16114
16680
|
try {
|
|
16115
16681
|
result = await client.postJson(projectPath(projectId, "/artifacts"), {
|
|
@@ -16395,12 +16961,12 @@ async function assertLinkTarget(target, projectId) {
|
|
|
16395
16961
|
}
|
|
16396
16962
|
async function hasBundleMarkers(target) {
|
|
16397
16963
|
try {
|
|
16398
|
-
await readFile12(
|
|
16964
|
+
await readFile12(join13(contractRoot(target), "PRD.md"));
|
|
16399
16965
|
return true;
|
|
16400
16966
|
} catch (error) {
|
|
16401
16967
|
if (!isMissingFile7(error)) throw error;
|
|
16402
16968
|
}
|
|
16403
|
-
return hasTaskMarkdown(
|
|
16969
|
+
return hasTaskMarkdown(join13(contractRoot(target), "tasks"));
|
|
16404
16970
|
}
|
|
16405
16971
|
async function hasTaskMarkdown(directory) {
|
|
16406
16972
|
let names;
|
|
@@ -16413,13 +16979,13 @@ async function hasTaskMarkdown(directory) {
|
|
|
16413
16979
|
return names.some((name) => name.toLowerCase().endsWith(".md"));
|
|
16414
16980
|
}
|
|
16415
16981
|
async function scaffoldCustomLayer(bundleDir) {
|
|
16416
|
-
const stackDir =
|
|
16417
|
-
const knowledgeDir =
|
|
16418
|
-
const designDir =
|
|
16982
|
+
const stackDir = join13(bundleDir, ".jioogen", "custom", "stack");
|
|
16983
|
+
const knowledgeDir = join13(bundleDir, ".jioogen", "custom", "knowledge");
|
|
16984
|
+
const designDir = join13(bundleDir, ".jioogen", "custom", "design");
|
|
16419
16985
|
await mkdir10(stackDir, { recursive: true });
|
|
16420
16986
|
await mkdir10(knowledgeDir, { recursive: true });
|
|
16421
16987
|
await mkdir10(designDir, { recursive: true });
|
|
16422
|
-
const exampleFile =
|
|
16988
|
+
const exampleFile = join13(stackDir, "STACK.md.example");
|
|
16423
16989
|
try {
|
|
16424
16990
|
await stat8(exampleFile);
|
|
16425
16991
|
} catch {
|
|
@@ -16637,7 +17203,7 @@ async function readLine() {
|
|
|
16637
17203
|
}
|
|
16638
17204
|
|
|
16639
17205
|
// src/index.ts
|
|
16640
|
-
var VERSION = "0.2.
|
|
17206
|
+
var VERSION = "0.2.15";
|
|
16641
17207
|
function parseTaskModeOption(value) {
|
|
16642
17208
|
if (value === void 0) return void 0;
|
|
16643
17209
|
const parsed = TaskModeSchema.safeParse(value);
|
|
@@ -16677,6 +17243,7 @@ Usage:
|
|
|
16677
17243
|
jioogen authoring remove [--dir <dir>]
|
|
16678
17244
|
jioogen align [--dir <dir>] [--json]
|
|
16679
17245
|
jioogen approve [--dir <dir>] [--note <text>] [--json]
|
|
17246
|
+
jioogen docs (scan|migrate|index|check) [--dir <dir>] [--dry-run] [--json]
|
|
16680
17247
|
jioogen check [--dir <dir>] [--json]
|
|
16681
17248
|
jioogen doctor [--fix] [--dir <dir>] [--json]
|
|
16682
17249
|
jioogen drift [--dir <dir>] [--json] [--strict] [--acknowledge] [--prd] [--specs] [--tasks] [--note <text>]
|
|
@@ -16888,6 +17455,9 @@ async function dispatch(command, rest, options) {
|
|
|
16888
17455
|
case "align":
|
|
16889
17456
|
await alignCommand(options);
|
|
16890
17457
|
return;
|
|
17458
|
+
case "docs":
|
|
17459
|
+
await docsCommand(options, rest[0] ?? "scan");
|
|
17460
|
+
return;
|
|
16891
17461
|
case "approve":
|
|
16892
17462
|
await approveCommand(options);
|
|
16893
17463
|
return;
|