minimal-forge-work-pack-sync 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +67 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10582,7 +10582,7 @@ var DEFAULT_DEBUG_TRACE_LIMITS = {
|
|
|
10582
10582
|
};
|
|
10583
10583
|
|
|
10584
10584
|
// packages/shared/src/contracts/settings.ts
|
|
10585
|
-
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.
|
|
10585
|
+
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.6";
|
|
10586
10586
|
var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
|
|
10587
10587
|
var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
|
|
10588
10588
|
|
|
@@ -10593,9 +10593,12 @@ async function reconcileWorkPacks(input) {
|
|
|
10593
10593
|
const outcomes = [];
|
|
10594
10594
|
let desiredFailed = false;
|
|
10595
10595
|
let uncertain = false;
|
|
10596
|
-
|
|
10596
|
+
const desiredSlugs = new Set(input.desired.map((pack) => pack.slug));
|
|
10597
|
+
const omittedManaged = input.managed.filter((pack) => !desiredSlugs.has(pack.slug));
|
|
10598
|
+
const earlyPrunedSlugs = /* @__PURE__ */ new Set();
|
|
10599
|
+
for (const pack of input.desired.filter((candidate) => !candidate.enabled)) {
|
|
10597
10600
|
const operation = {
|
|
10598
|
-
action:
|
|
10601
|
+
action: "remove",
|
|
10599
10602
|
reason: "desired",
|
|
10600
10603
|
pack
|
|
10601
10604
|
};
|
|
@@ -10607,6 +10610,36 @@ async function reconcileWorkPacks(input) {
|
|
|
10607
10610
|
break;
|
|
10608
10611
|
}
|
|
10609
10612
|
}
|
|
10613
|
+
for (const pack of input.desired.filter((candidate) => candidate.enabled)) {
|
|
10614
|
+
if (uncertain) break;
|
|
10615
|
+
const operation = { action: "install", reason: "desired", pack };
|
|
10616
|
+
let outcome = await runOperation(operation, input.operate);
|
|
10617
|
+
if (input.desiredIsComplete && outcome.status === "failed" && outcome.code === "projection-conflict") {
|
|
10618
|
+
const blockers = omittedProjectionOwners(omittedManaged, outcome.projectionConflict).filter((managed) => !earlyPrunedSlugs.has(managed.slug));
|
|
10619
|
+
let blockersRemoved = blockers.length === 1;
|
|
10620
|
+
for (const managed of blockersRemoved ? blockers : []) {
|
|
10621
|
+
const removal = await runOperation(
|
|
10622
|
+
{ action: "remove", reason: "omitted", pack: { ...managed, enabled: false } },
|
|
10623
|
+
input.operate
|
|
10624
|
+
);
|
|
10625
|
+
outcomes.push(removal);
|
|
10626
|
+
if (removal.status === "failed") {
|
|
10627
|
+
blockersRemoved = false;
|
|
10628
|
+
continue;
|
|
10629
|
+
}
|
|
10630
|
+
if (removal.status === "recovery-uncertain") {
|
|
10631
|
+
uncertain = true;
|
|
10632
|
+
blockersRemoved = false;
|
|
10633
|
+
break;
|
|
10634
|
+
}
|
|
10635
|
+
earlyPrunedSlugs.add(managed.slug);
|
|
10636
|
+
}
|
|
10637
|
+
if (blockersRemoved) outcome = await runOperation(operation, input.operate);
|
|
10638
|
+
}
|
|
10639
|
+
outcomes.push(outcome);
|
|
10640
|
+
if (outcome.status === "failed") desiredFailed = true;
|
|
10641
|
+
if (outcome.status === "recovery-uncertain") uncertain = true;
|
|
10642
|
+
}
|
|
10610
10643
|
let omissionPrune = "not-requested";
|
|
10611
10644
|
if (input.desiredIsComplete) {
|
|
10612
10645
|
if (uncertain) {
|
|
@@ -10615,9 +10648,8 @@ async function reconcileWorkPacks(input) {
|
|
|
10615
10648
|
omissionPrune = "suppressed-after-desired-failure";
|
|
10616
10649
|
} else {
|
|
10617
10650
|
omissionPrune = "completed";
|
|
10618
|
-
const desiredSlugs = new Set(input.desired.map((pack) => pack.slug));
|
|
10619
10651
|
for (const managed of input.managed) {
|
|
10620
|
-
if (desiredSlugs.has(managed.slug)) continue;
|
|
10652
|
+
if (desiredSlugs.has(managed.slug) || earlyPrunedSlugs.has(managed.slug)) continue;
|
|
10621
10653
|
const outcome = await runOperation(
|
|
10622
10654
|
{
|
|
10623
10655
|
action: "remove",
|
|
@@ -10666,6 +10698,11 @@ async function reconcileWorkPacks(input) {
|
|
|
10666
10698
|
receipt
|
|
10667
10699
|
};
|
|
10668
10700
|
}
|
|
10701
|
+
function omittedProjectionOwners(omitted, conflict) {
|
|
10702
|
+
if (!conflict) return [];
|
|
10703
|
+
const field = conflict.kind === "agent" ? "agents" : "commands";
|
|
10704
|
+
return omitted.filter((pack) => pack[field]?.includes(conflict.filename));
|
|
10705
|
+
}
|
|
10669
10706
|
async function runOperation(operation, operate) {
|
|
10670
10707
|
let result;
|
|
10671
10708
|
try {
|
|
@@ -10679,6 +10716,7 @@ async function runOperation(operation, operate) {
|
|
|
10679
10716
|
...outcomeIdentity(operation),
|
|
10680
10717
|
status: "failed",
|
|
10681
10718
|
code: stableCode(result.code),
|
|
10719
|
+
...result.projectionConflict ? { projectionConflict: result.projectionConflict } : {},
|
|
10682
10720
|
message: `O pacote "${operation.pack.slug}" falhou, mas o estado anterior foi restaurado exatamente. Corrija a causa indicada e volte a sincronizar.`
|
|
10683
10721
|
};
|
|
10684
10722
|
}
|
|
@@ -10768,7 +10806,9 @@ async function applyWorkPackManifest(paths, credentials, manifest, options) {
|
|
|
10768
10806
|
const cleanupPendingSlugs = await recoverInterruptedWorkPackInstalls(paths, options.cleanupWorkPackBackup);
|
|
10769
10807
|
const managed = await Promise.all((await managedWorkPackSlugs(paths.skillsDir)).map(async (slug) => ({
|
|
10770
10808
|
slug,
|
|
10771
|
-
version: (await readFile(path2.join(paths.skillsDir, slug, ".forge-version"), "utf8")).trim()
|
|
10809
|
+
version: (await readFile(path2.join(paths.skillsDir, slug, ".forge-version"), "utf8")).trim(),
|
|
10810
|
+
agents: await readAgentRecord(path2.join(paths.skillsDir, slug)),
|
|
10811
|
+
commands: await readCommandRecord(path2.join(paths.skillsDir, slug))
|
|
10772
10812
|
})));
|
|
10773
10813
|
const desired = manifest.skills.map((skill) => ({
|
|
10774
10814
|
slug: skill.slug,
|
|
@@ -10860,10 +10900,28 @@ async function operateWorkPack(paths, credentials, skillBySlug, approvedModelIds
|
|
|
10860
10900
|
}
|
|
10861
10901
|
}
|
|
10862
10902
|
function exactPackFailure(error) {
|
|
10903
|
+
if (error instanceof WorkPackProjectionConflictError) {
|
|
10904
|
+
return {
|
|
10905
|
+
status: "failed",
|
|
10906
|
+
restoration: "exact",
|
|
10907
|
+
code: "projection-conflict",
|
|
10908
|
+
projectionConflict: { kind: error.kind, filename: error.filename }
|
|
10909
|
+
};
|
|
10910
|
+
}
|
|
10863
10911
|
const message = error instanceof Error ? error.message : "";
|
|
10864
10912
|
const code = /Checksum/i.test(message) ? "checksum-mismatch" : /redirecionamento|mesmo servidor|outro servidor|\bURL\b/i.test(message) ? "archive-origin-rejected" : /transferência/i.test(message) ? "download-failed" : /modelo que não está aprovado/i.test(message) ? "model-not-approved" : /conflito/i.test(message) ? "projection-conflict" : /frontmatter|arquivo|marcador Forge reservado/i.test(message) ? "invalid-archive" : "operation-failed";
|
|
10865
10913
|
return { status: "failed", restoration: "exact", code };
|
|
10866
10914
|
}
|
|
10915
|
+
var WorkPackProjectionConflictError = class extends Error {
|
|
10916
|
+
constructor(kind, filename, slug) {
|
|
10917
|
+
super(`A proje\xE7\xE3o ${filename} do pacote de trabalho ${slug} entra em conflito com uma proje\xE7\xE3o existente`);
|
|
10918
|
+
this.kind = kind;
|
|
10919
|
+
this.filename = filename;
|
|
10920
|
+
this.name = "WorkPackProjectionConflictError";
|
|
10921
|
+
}
|
|
10922
|
+
kind;
|
|
10923
|
+
filename;
|
|
10924
|
+
};
|
|
10867
10925
|
async function downloadSkill(credentials, url) {
|
|
10868
10926
|
const forgeUrl = new URL(credentials.forgeBaseUrl);
|
|
10869
10927
|
const archiveUrl = new URL(url, forgeUrl);
|
|
@@ -11271,7 +11329,7 @@ async function assertNoForeignAgentConflicts(agentsDir, agentFiles, ownedFilenam
|
|
|
11271
11329
|
throw error;
|
|
11272
11330
|
});
|
|
11273
11331
|
if (existing !== void 0) {
|
|
11274
|
-
throw new
|
|
11332
|
+
throw new WorkPackProjectionConflictError("agent", agent.filename, slug);
|
|
11275
11333
|
}
|
|
11276
11334
|
}
|
|
11277
11335
|
}
|
|
@@ -11284,7 +11342,7 @@ async function assertNoForeignCommandConflicts(commandsDir, commandFiles, ownedF
|
|
|
11284
11342
|
throw error;
|
|
11285
11343
|
});
|
|
11286
11344
|
if (existing !== void 0) {
|
|
11287
|
-
throw new
|
|
11345
|
+
throw new WorkPackProjectionConflictError("command", command.filename, slug);
|
|
11288
11346
|
}
|
|
11289
11347
|
}
|
|
11290
11348
|
}
|
|
@@ -11432,7 +11490,7 @@ async function writeTextAtomic(filePath, content) {
|
|
|
11432
11490
|
}
|
|
11433
11491
|
|
|
11434
11492
|
// packages/cli/src/workPackSyncPlugin.ts
|
|
11435
|
-
var PLUGIN_VERSION = "0.1.
|
|
11493
|
+
var PLUGIN_VERSION = "0.1.6";
|
|
11436
11494
|
var STATUS_FILENAME = "work-pack-startup-status.json";
|
|
11437
11495
|
var activeSync = /* @__PURE__ */ new Map();
|
|
11438
11496
|
var ForgeWorkPackSyncServer = async (_input, options) => {
|