minimal-forge-work-pack-sync 0.1.37 → 0.1.38
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 +19 -202
- package/dist/repair.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7607,7 +7607,7 @@ var DEFAULT_DEBUG_TRACE_LIMITS = {
|
|
|
7607
7607
|
// packages/shared/src/contracts/settings.ts
|
|
7608
7608
|
var DOCUMENT_READER_AGENT = "document-reader";
|
|
7609
7609
|
var OPENROUTER_ALIAS_PROVIDER_NAME = "OpenRouter (via Forge)";
|
|
7610
|
-
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.
|
|
7610
|
+
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.38";
|
|
7611
7611
|
var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
|
|
7612
7612
|
var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
|
|
7613
7613
|
var FIRECRAWL_KEYLESS_MCP_NAME = "firecrawl";
|
|
@@ -25079,21 +25079,21 @@ function jsonBytes(value) {
|
|
|
25079
25079
|
`);
|
|
25080
25080
|
}
|
|
25081
25081
|
async function removeLegacyDebugTraceRuntime(paths) {
|
|
25082
|
-
const
|
|
25083
|
-
const launchAgent = await readFile7(
|
|
25082
|
+
const launchAgentPath = path8.join(os4.homedir(), "Library", "LaunchAgents", "com.minimal-forge.debug-trace.plist");
|
|
25083
|
+
const launchAgent = await readFile7(launchAgentPath, "utf8").catch((error45) => {
|
|
25084
25084
|
if (error45.code === "ENOENT") return void 0;
|
|
25085
25085
|
throw error45;
|
|
25086
25086
|
});
|
|
25087
25087
|
if (launchAgent?.includes("<string>com.minimal-forge.debug-trace</string>")) {
|
|
25088
25088
|
if (process.platform === "darwin") {
|
|
25089
25089
|
const domain2 = `gui/${process.getuid?.() ?? 0}`;
|
|
25090
|
-
const stopped = spawnSync("launchctl", ["bootout", domain2,
|
|
25090
|
+
const stopped = spawnSync("launchctl", ["bootout", domain2, launchAgentPath], { encoding: "utf8" });
|
|
25091
25091
|
if (stopped.status !== 0) {
|
|
25092
25092
|
const stillRunning = spawnSync("launchctl", ["print", `${domain2}/com.minimal-forge.debug-trace`], { encoding: "utf8" });
|
|
25093
25093
|
if (stillRunning.status === 0) throw new Error("O servi\xE7o antigo de debug trace continua ativo; a sincroniza\xE7\xE3o n\xE3o removeu os seus ficheiros.");
|
|
25094
25094
|
}
|
|
25095
25095
|
}
|
|
25096
|
-
await rm4(
|
|
25096
|
+
await rm4(launchAgentPath, { force: true });
|
|
25097
25097
|
}
|
|
25098
25098
|
for (const filename of [
|
|
25099
25099
|
"debug-trace-service.sh",
|
|
@@ -26174,64 +26174,19 @@ exec '${nodePath.replace(/'/g, "'\\''")}' ./forge-repair.mjs "$@"
|
|
|
26174
26174
|
// packages/cli/src/rollback.ts
|
|
26175
26175
|
import { createHash as createHash6 } from "node:crypto";
|
|
26176
26176
|
import { chmod as chmod6, mkdir as mkdir6, readFile as readFile9, readdir as readdir4, rename as rename7, rm as rm5, stat as stat2, writeFile as writeFile7 } from "node:fs/promises";
|
|
26177
|
-
import os5 from "node:os";
|
|
26178
26177
|
import path10 from "node:path";
|
|
26179
|
-
|
|
26180
|
-
|
|
26181
|
-
var FORGE_DEBUG_TRACE_SERVICE_LABEL = "com.minimal-forge.debug-trace";
|
|
26182
|
-
var FORGE_DEBUG_TRACE_SERVICE_RUNNER_FILENAME = "debug-trace-service.sh";
|
|
26183
|
-
var FORGE_DEBUG_TRACE_SERVICE_STATE_FILENAME = "debug-trace-service-state.json";
|
|
26184
|
-
var FORGE_DEBUG_TRACE_OPENCODE_LAUNCHER_FILENAME = "opencode-debug-trace";
|
|
26185
|
-
var FORGE_DEBUG_TRACE_TAP_OUTPUT_DIRNAME = "claude-tap-traces";
|
|
26186
|
-
|
|
26187
|
-
// packages/cli/src/rollback.ts
|
|
26188
|
-
async function recordRollbackManagedState(paths, options = {}) {
|
|
26189
|
-
const lifecycle = await readRollbackLifecycle(paths);
|
|
26190
|
-
if (lifecycle?.state !== "pilot") return;
|
|
26178
|
+
async function recordRollbackEvidencePlugin(paths, expectedContent) {
|
|
26179
|
+
if ((await readRollbackLifecycle(paths))?.state !== "pilot") return;
|
|
26191
26180
|
const capsule = await readRollbackCapsule(paths);
|
|
26192
|
-
|
|
26193
|
-
const
|
|
26194
|
-
|
|
26195
|
-
const
|
|
26196
|
-
|
|
26197
|
-
const
|
|
26198
|
-
|
|
26199
|
-
|
|
26200
|
-
|
|
26201
|
-
if (!previous || options.refreshForgeStatic && isForgeStaticManagedPath(paths, options, file2.path) || refreshablePaths.has(file2.path)) return file2;
|
|
26202
|
-
if (removedManagedPaths.has(file2.path)) return { ...previous, removedByForge: true };
|
|
26203
|
-
return previous;
|
|
26204
|
-
});
|
|
26205
|
-
const observedPaths = new Set(files.map((file2) => file2.path));
|
|
26206
|
-
for (const previous of capsule.managed.files) {
|
|
26207
|
-
if (!observedPaths.has(previous.path)) {
|
|
26208
|
-
files.push(removedManagedPaths.has(previous.path) ? { ...previous, removedByForge: true } : previous);
|
|
26209
|
-
}
|
|
26210
|
-
}
|
|
26211
|
-
files.sort((left, right) => left.path.localeCompare(right.path));
|
|
26212
|
-
const credentials = await readJsonObject(paths.credentialsPath);
|
|
26213
|
-
const wellKnownUrls = [
|
|
26214
|
-
...Array.isArray(credentials?.forgeOwnedWellKnownUrls) ? credentials.forgeOwnedWellKnownUrls.filter((entry) => typeof entry === "string") : [],
|
|
26215
|
-
...typeof credentials?.forgeBaseUrl === "string" ? [credentials.forgeBaseUrl.replace(/\/+$/, "")] : []
|
|
26216
|
-
];
|
|
26217
|
-
const managed = {
|
|
26218
|
-
files,
|
|
26219
|
-
config: managedEntries(config2, [
|
|
26220
|
-
["$schema"],
|
|
26221
|
-
["share"],
|
|
26222
|
-
["autoupdate"],
|
|
26223
|
-
["model"],
|
|
26224
|
-
["small_model"],
|
|
26225
|
-
["provider", "forge"],
|
|
26226
|
-
["provider", "openrouter"],
|
|
26227
|
-
["agent", "document-reader"]
|
|
26228
|
-
]),
|
|
26229
|
-
tui: managedEntries(tui, [["theme"]]),
|
|
26230
|
-
dynamicPaths: dynamicPaths(paths),
|
|
26231
|
-
wellKnownUrls: [...new Set(wellKnownUrls)]
|
|
26232
|
-
};
|
|
26233
|
-
if (deepEqual(capsule.managed, managed)) return;
|
|
26234
|
-
await writeProtectedJsonAtomic(paths.rollbackCapsulePath, { ...capsule, managed });
|
|
26181
|
+
const pluginPath = path10.join(paths.pluginDir, FORGE_EVIDENCE_PLUGIN_FILENAME);
|
|
26182
|
+
const managed = capsule?.managed.files.find((file2) => file2.path === pluginPath);
|
|
26183
|
+
if (!capsule || !managed) return;
|
|
26184
|
+
const current = await readFile9(pluginPath, "utf8").catch(() => void 0);
|
|
26185
|
+
if (current !== expectedContent) return;
|
|
26186
|
+
const fingerprint = sha2562(Buffer.from(current));
|
|
26187
|
+
if (managed.sha256 === fingerprint) return;
|
|
26188
|
+
managed.sha256 = fingerprint;
|
|
26189
|
+
await writeProtectedJsonAtomic(paths.rollbackCapsulePath, capsule);
|
|
26235
26190
|
}
|
|
26236
26191
|
async function readRollbackLifecycle(paths) {
|
|
26237
26192
|
return readJson(paths.rollbackLifecyclePath);
|
|
@@ -26239,112 +26194,6 @@ async function readRollbackLifecycle(paths) {
|
|
|
26239
26194
|
async function readRollbackCapsule(paths) {
|
|
26240
26195
|
return readJson(paths.rollbackCapsulePath);
|
|
26241
26196
|
}
|
|
26242
|
-
async function discoverManagedFiles(paths, options) {
|
|
26243
|
-
const candidates = /* @__PURE__ */ new Set();
|
|
26244
|
-
for (const candidate of forgeStaticManagedPaths(paths)) candidates.add(candidate);
|
|
26245
|
-
for (const filename of [FORGE_PLUGIN_FILENAME, FORGE_EVIDENCE_PLUGIN_FILENAME, FORGE_DEBUG_TRACE_PLUGIN_FILENAME]) {
|
|
26246
|
-
const pluginPath = path10.join(paths.pluginDir, filename);
|
|
26247
|
-
const content = await readFile9(pluginPath, "utf8").catch(() => void 0);
|
|
26248
|
-
if (content?.startsWith(FORGE_PLUGIN_HEADER)) candidates.add(pluginPath);
|
|
26249
|
-
}
|
|
26250
|
-
const skillEntries = await readdir4(paths.skillsDir, { withFileTypes: true }).catch(() => []);
|
|
26251
|
-
for (const entry of skillEntries) {
|
|
26252
|
-
if (!entry.isDirectory() || entry.name.endsWith(".previous")) continue;
|
|
26253
|
-
const skillRoot = path10.join(paths.skillsDir, entry.name);
|
|
26254
|
-
if (!await stat2(path10.join(skillRoot, ".forge-version")).catch(() => void 0)) continue;
|
|
26255
|
-
await collectFiles(skillRoot, candidates);
|
|
26256
|
-
for (const [recordName, targetDir] of [
|
|
26257
|
-
[".forge-agents", paths.agentsDir],
|
|
26258
|
-
[".forge-commands", paths.commandsDir]
|
|
26259
|
-
]) {
|
|
26260
|
-
const record2 = await readFile9(path10.join(skillRoot, recordName), "utf8").catch(() => "");
|
|
26261
|
-
for (const filename of safeRecordedFilenames(record2)) candidates.add(path10.join(targetDir, filename));
|
|
26262
|
-
}
|
|
26263
|
-
}
|
|
26264
|
-
const serviceState = await readJsonObject(path10.join(paths.forgeDir, FORGE_DEBUG_TRACE_SERVICE_STATE_FILENAME));
|
|
26265
|
-
const expectedLaunchAgent = launchAgentPath(options);
|
|
26266
|
-
const launchAgent = serviceState?.launchAgentPath === expectedLaunchAgent ? serviceState.launchAgentPath : expectedLaunchAgent;
|
|
26267
|
-
const launchAgentContent = await readFile9(launchAgent, "utf8").catch(() => void 0);
|
|
26268
|
-
if (launchAgentContent?.includes(FORGE_DEBUG_TRACE_SERVICE_LABEL)) candidates.add(launchAgent);
|
|
26269
|
-
const files = [];
|
|
26270
|
-
for (const candidate of [...candidates].sort()) {
|
|
26271
|
-
const content = await readFile9(candidate).catch(() => void 0);
|
|
26272
|
-
if (content) files.push({ path: candidate, sha256: sha2562(content) });
|
|
26273
|
-
}
|
|
26274
|
-
return files;
|
|
26275
|
-
}
|
|
26276
|
-
async function refreshedWorkPackPaths(paths, slugs) {
|
|
26277
|
-
const refreshed = /* @__PURE__ */ new Set();
|
|
26278
|
-
for (const slug of slugs) {
|
|
26279
|
-
const skillRoot = path10.join(paths.skillsDir, slug);
|
|
26280
|
-
if (!isWithin(skillRoot, paths.skillsDir)) continue;
|
|
26281
|
-
await collectFiles(skillRoot, refreshed);
|
|
26282
|
-
for (const [recordName, targetDir] of [
|
|
26283
|
-
[".forge-agents", paths.agentsDir],
|
|
26284
|
-
[".forge-commands", paths.commandsDir]
|
|
26285
|
-
]) {
|
|
26286
|
-
const record2 = await readFile9(path10.join(skillRoot, recordName), "utf8").catch(() => "");
|
|
26287
|
-
for (const filename of safeRecordedFilenames(record2)) refreshed.add(path10.join(targetDir, filename));
|
|
26288
|
-
}
|
|
26289
|
-
}
|
|
26290
|
-
return refreshed;
|
|
26291
|
-
}
|
|
26292
|
-
function forgeStaticManagedPaths(paths) {
|
|
26293
|
-
return [
|
|
26294
|
-
paths.credentialsPath,
|
|
26295
|
-
paths.envPath,
|
|
26296
|
-
paths.powershellEnvPath,
|
|
26297
|
-
path10.join(paths.forgeDir, FORGE_DEBUG_TRACE_CONFIG_FILENAME),
|
|
26298
|
-
path10.join(paths.forgeDir, FORGE_DEBUG_TRACE_SERVICE_STATE_FILENAME),
|
|
26299
|
-
path10.join(paths.forgeDir, FORGE_DEBUG_TRACE_SERVICE_RUNNER_FILENAME),
|
|
26300
|
-
path10.join(paths.forgeDir, FORGE_DEBUG_TRACE_OPENCODE_LAUNCHER_FILENAME)
|
|
26301
|
-
];
|
|
26302
|
-
}
|
|
26303
|
-
function isForgeStaticManagedPath(paths, options, candidate) {
|
|
26304
|
-
return forgeStaticManagedPaths(paths).includes(candidate) || candidate === launchAgentPath(options) || [FORGE_PLUGIN_FILENAME, FORGE_EVIDENCE_PLUGIN_FILENAME, FORGE_DEBUG_TRACE_PLUGIN_FILENAME].some((filename) => candidate === path10.join(paths.pluginDir, filename));
|
|
26305
|
-
}
|
|
26306
|
-
async function collectFiles(root, output, include = () => true) {
|
|
26307
|
-
const entries = await readdir4(root, { withFileTypes: true }).catch(() => []);
|
|
26308
|
-
for (const entry of entries) {
|
|
26309
|
-
const absolute = path10.join(root, entry.name);
|
|
26310
|
-
if (!include(absolute)) continue;
|
|
26311
|
-
if (entry.isDirectory()) await collectFiles(absolute, output, include);
|
|
26312
|
-
else if (entry.isFile()) output.add(absolute);
|
|
26313
|
-
}
|
|
26314
|
-
}
|
|
26315
|
-
function managedEntries(config2, paths) {
|
|
26316
|
-
return paths.map((entryPath) => {
|
|
26317
|
-
const current = getAtPath(config2, entryPath);
|
|
26318
|
-
return current.present ? { path: entryPath, present: true, value: structuredClone(current.value) } : { path: entryPath, present: false };
|
|
26319
|
-
});
|
|
26320
|
-
}
|
|
26321
|
-
function dynamicPaths(paths) {
|
|
26322
|
-
return [
|
|
26323
|
-
path10.join(paths.forgeDir, "debug-trace-queue"),
|
|
26324
|
-
path10.join(paths.forgeDir, FORGE_DEBUG_TRACE_TAP_OUTPUT_DIRNAME),
|
|
26325
|
-
path10.join(paths.forgeDir, "verified-claude-tap"),
|
|
26326
|
-
path10.join(paths.forgeDir, "debug-trace-service.out.log"),
|
|
26327
|
-
path10.join(paths.forgeDir, "debug-trace-service.err.log")
|
|
26328
|
-
];
|
|
26329
|
-
}
|
|
26330
|
-
function getAtPath(root, entryPath) {
|
|
26331
|
-
let current = root;
|
|
26332
|
-
for (const segment of entryPath) {
|
|
26333
|
-
if (!isRecord5(current) || !Object.prototype.hasOwnProperty.call(current, segment)) return { present: false };
|
|
26334
|
-
current = current[segment];
|
|
26335
|
-
}
|
|
26336
|
-
return { present: true, value: current };
|
|
26337
|
-
}
|
|
26338
|
-
function safeRecordedFilenames(raw) {
|
|
26339
|
-
return raw.split("\n").map((line) => line.trim()).filter((line) => line.length > 0 && !line.includes("/") && !line.includes("\\") && line !== "..");
|
|
26340
|
-
}
|
|
26341
|
-
function deepEqual(left, right) {
|
|
26342
|
-
return JSON.stringify(left) === JSON.stringify(right);
|
|
26343
|
-
}
|
|
26344
|
-
function launchAgentPath(options) {
|
|
26345
|
-
const directory = options.launchAgentsDir ?? path10.join(os5.homedir(), "Library", "LaunchAgents");
|
|
26346
|
-
return path10.join(directory, `${FORGE_DEBUG_TRACE_SERVICE_LABEL}.plist`);
|
|
26347
|
-
}
|
|
26348
26197
|
async function writeProtectedJsonAtomic(filePath, value) {
|
|
26349
26198
|
const directory = path10.dirname(filePath);
|
|
26350
26199
|
await mkdir6(directory, { recursive: true, mode: 448 });
|
|
@@ -26366,32 +26215,9 @@ async function readJson(filePath) {
|
|
|
26366
26215
|
if (!raw) return void 0;
|
|
26367
26216
|
return JSON.parse(raw);
|
|
26368
26217
|
}
|
|
26369
|
-
async function readJsonObject(filePath) {
|
|
26370
|
-
const value = await readJson(filePath);
|
|
26371
|
-
return isRecord5(value) ? value : void 0;
|
|
26372
|
-
}
|
|
26373
|
-
async function readJsoncObject2(filePath) {
|
|
26374
|
-
const raw = await readFile9(filePath, "utf8").catch((error45) => {
|
|
26375
|
-
if (error45.code === "ENOENT") return "{}";
|
|
26376
|
-
throw error45;
|
|
26377
|
-
});
|
|
26378
|
-
try {
|
|
26379
|
-
const parsed = parseJsonc(raw);
|
|
26380
|
-
return isRecord5(parsed) ? parsed : {};
|
|
26381
|
-
} catch (error45) {
|
|
26382
|
-
throw new Error(`Configura\xE7\xE3o JSON/JSONC inv\xE1lida em ${filePath}`, { cause: error45 });
|
|
26383
|
-
}
|
|
26384
|
-
}
|
|
26385
|
-
function isWithin(candidate, root) {
|
|
26386
|
-
const relative = path10.relative(root, candidate);
|
|
26387
|
-
return relative === "" || !relative.startsWith("..") && !path10.isAbsolute(relative);
|
|
26388
|
-
}
|
|
26389
26218
|
function sha2562(value) {
|
|
26390
26219
|
return createHash6("sha256").update(value).digest("hex");
|
|
26391
26220
|
}
|
|
26392
|
-
function isRecord5(value) {
|
|
26393
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26394
|
-
}
|
|
26395
26221
|
|
|
26396
26222
|
// packages/cli/src/localWorkerSync.ts
|
|
26397
26223
|
async function syncLocalWorker(paths, credentials, manifest) {
|
|
@@ -26411,23 +26237,14 @@ async function syncLocalWorker(paths, credentials, manifest) {
|
|
|
26411
26237
|
throw new Error("A configura\xE7\xE3o local foi alterada ou a c\xF3pia v\xE1lida n\xE3o corresponde \xE0 credencial; preserve os ficheiros e pe\xE7a apoio.");
|
|
26412
26238
|
}
|
|
26413
26239
|
await installRecoveryLauncher(paths, credentials.forgeBaseUrl);
|
|
26414
|
-
const result = await applyManifest(paths, credentials, manifest
|
|
26415
|
-
beforeManagedPathsRemoved: (removedManagedPaths) => recordRollbackManagedState(paths, { removedManagedPaths })
|
|
26416
|
-
});
|
|
26240
|
+
const result = await applyManifest(paths, credentials, manifest);
|
|
26417
26241
|
await removeWellKnownAuth(paths, credentials);
|
|
26418
|
-
await
|
|
26419
|
-
refreshForgeStatic: true,
|
|
26420
|
-
updatedWorkPackSlugs: result.installed.map((entry) => {
|
|
26421
|
-
const separator = entry.lastIndexOf("@");
|
|
26422
|
-
return separator > 0 ? entry.slice(0, separator) : entry;
|
|
26423
|
-
}),
|
|
26424
|
-
removedManagedPaths: result.removedManagedPaths
|
|
26425
|
-
});
|
|
26242
|
+
await recordRollbackEvidencePlugin(paths, renderEvidencePlugin());
|
|
26426
26243
|
return result;
|
|
26427
26244
|
}
|
|
26428
26245
|
|
|
26429
26246
|
// packages/cli/src/workPackSyncPlugin.ts
|
|
26430
|
-
var PLUGIN_VERSION = "0.1.
|
|
26247
|
+
var PLUGIN_VERSION = "0.1.38";
|
|
26431
26248
|
var FORGE_DECISION_TIMEOUT_MS = 11e4;
|
|
26432
26249
|
var STATUS_FILENAME = "work-pack-startup-status.json";
|
|
26433
26250
|
var activeSync = /* @__PURE__ */ new Map();
|
package/dist/repair.js
CHANGED
|
@@ -401,7 +401,7 @@ var DEVICE_ENROLLMENT_PROTOCOL_VERSION = 1;
|
|
|
401
401
|
// packages/shared/src/contracts/settings.ts
|
|
402
402
|
var DOCUMENT_READER_AGENT = "document-reader";
|
|
403
403
|
var OPENROUTER_ALIAS_PROVIDER_NAME = "OpenRouter (via Forge)";
|
|
404
|
-
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.
|
|
404
|
+
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.38";
|
|
405
405
|
var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
|
|
406
406
|
var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
|
|
407
407
|
var FIRECRAWL_KEYLESS_MCP_NAME = "firecrawl";
|