minimal-forge-work-pack-sync 0.1.49 → 0.1.51
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 +96 -61
- package/dist/repair.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7374,63 +7374,6 @@ var require_dist = __commonJS({
|
|
|
7374
7374
|
var import_yaml = __toESM(require_dist(), 1);
|
|
7375
7375
|
import { readFile, readdir } from "node:fs/promises";
|
|
7376
7376
|
import path from "node:path";
|
|
7377
|
-
async function managedProjectionNames(paths) {
|
|
7378
|
-
const agents = /* @__PURE__ */ new Set();
|
|
7379
|
-
const commands = /* @__PURE__ */ new Set();
|
|
7380
|
-
const entries = await readdir(paths.skillsDir, { withFileTypes: true }).catch((error45) => {
|
|
7381
|
-
if (error45.code === "ENOENT") return [];
|
|
7382
|
-
throw error45;
|
|
7383
|
-
});
|
|
7384
|
-
for (const entry of entries) {
|
|
7385
|
-
if (!entry.isDirectory()) continue;
|
|
7386
|
-
const folder = path.join(paths.skillsDir, entry.name);
|
|
7387
|
-
const marker = await readFile(path.join(folder, ".forge-version"), "utf8").catch(() => "");
|
|
7388
|
-
if (!marker.trim()) continue;
|
|
7389
|
-
for (const name of await readProjectionRecord(path.join(folder, ".forge-agents"))) agents.add(stripMarkdownExtension(name));
|
|
7390
|
-
for (const name of await readProjectionRecord(path.join(folder, ".forge-commands"))) commands.add(stripMarkdownExtension(name));
|
|
7391
|
-
}
|
|
7392
|
-
return { agents, commands };
|
|
7393
|
-
}
|
|
7394
|
-
async function readProjectionRecord(filePath) {
|
|
7395
|
-
const raw = await readFile(filePath, "utf8").catch(() => "");
|
|
7396
|
-
return raw.split("\n").map((line) => line.trim()).filter(
|
|
7397
|
-
(line) => line.endsWith(".md") && !line.includes("/") && !line.includes("\\") && line !== ".."
|
|
7398
|
-
);
|
|
7399
|
-
}
|
|
7400
|
-
async function projectCurrentExtensions(config2, state) {
|
|
7401
|
-
const agents = objectRecord(config2.agent);
|
|
7402
|
-
const commands = objectRecord(config2.command);
|
|
7403
|
-
for (const name of state.before.agents) if (!state.after.agents.has(name)) delete agents[name];
|
|
7404
|
-
for (const name of state.before.commands) if (!state.after.commands.has(name)) delete commands[name];
|
|
7405
|
-
for (const name of state.after.agents) {
|
|
7406
|
-
agents[name] = await parseMarkdownConfig(path.join(state.paths.agentsDir, `${name}.md`), "prompt");
|
|
7407
|
-
}
|
|
7408
|
-
for (const name of state.after.commands) {
|
|
7409
|
-
commands[name] = await parseMarkdownConfig(path.join(state.paths.commandsDir, `${name}.md`), "template");
|
|
7410
|
-
}
|
|
7411
|
-
config2.agent = agents;
|
|
7412
|
-
config2.command = commands;
|
|
7413
|
-
}
|
|
7414
|
-
async function parseMarkdownConfig(filePath, bodyField) {
|
|
7415
|
-
const raw = await readFile(filePath, "utf8");
|
|
7416
|
-
const match = /^---\r?\n([\s\S]+?)\r?\n---\r?\n?([\s\S]*)$/.exec(raw);
|
|
7417
|
-
if (!match) throw new Error(`A extens\xE3o Forge ${path.basename(filePath)} n\xE3o tem frontmatter v\xE1lido`);
|
|
7418
|
-
const data = (0, import_yaml.parse)(match[1]);
|
|
7419
|
-
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
7420
|
-
throw new Error(`A extens\xE3o Forge ${path.basename(filePath)} n\xE3o tem frontmatter v\xE1lido`);
|
|
7421
|
-
}
|
|
7422
|
-
const config2 = { ...data, [bodyField]: match[2].trim() };
|
|
7423
|
-
if (bodyField === "prompt" && typeof config2.permission === "string" && ["allow", "ask", "deny"].includes(config2.permission)) {
|
|
7424
|
-
config2.permission = { "*": config2.permission };
|
|
7425
|
-
}
|
|
7426
|
-
return config2;
|
|
7427
|
-
}
|
|
7428
|
-
function objectRecord(value) {
|
|
7429
|
-
return value && typeof value === "object" && !Array.isArray(value) ? { ...value } : {};
|
|
7430
|
-
}
|
|
7431
|
-
function stripMarkdownExtension(filename) {
|
|
7432
|
-
return filename.slice(0, -3);
|
|
7433
|
-
}
|
|
7434
7377
|
|
|
7435
7378
|
// packages/shared/src/contracts/models.ts
|
|
7436
7379
|
var BUILT_IN_OPENROUTER_MODELS = [
|
|
@@ -7672,7 +7615,7 @@ var WORKER_FEEDBACK_MAX_MESSAGE_LENGTH = 24e3;
|
|
|
7672
7615
|
// packages/shared/src/contracts/settings.ts
|
|
7673
7616
|
var DOCUMENT_READER_AGENT = "document-reader";
|
|
7674
7617
|
var OPENROUTER_ALIAS_PROVIDER_NAME = "OpenRouter (via Forge)";
|
|
7675
|
-
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.
|
|
7618
|
+
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.51";
|
|
7676
7619
|
var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
|
|
7677
7620
|
var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
|
|
7678
7621
|
var FIRECRAWL_KEYLESS_MCP_NAME = "firecrawl";
|
|
@@ -7900,6 +7843,90 @@ function integrityKind(summary) {
|
|
|
7900
7843
|
return "match";
|
|
7901
7844
|
}
|
|
7902
7845
|
|
|
7846
|
+
// packages/cli/src/workPackExtensions.ts
|
|
7847
|
+
async function managedProjectionNames(paths, slugs) {
|
|
7848
|
+
const agents = /* @__PURE__ */ new Set();
|
|
7849
|
+
const commands = /* @__PURE__ */ new Set();
|
|
7850
|
+
if (slugs?.size === 0) return { agents, commands };
|
|
7851
|
+
const entries = await readdir(paths.skillsDir, { withFileTypes: true }).catch((error45) => {
|
|
7852
|
+
if (error45.code === "ENOENT") return [];
|
|
7853
|
+
throw error45;
|
|
7854
|
+
});
|
|
7855
|
+
for (const entry of entries) {
|
|
7856
|
+
if (!entry.isDirectory() || slugs && !slugs.has(entry.name)) continue;
|
|
7857
|
+
const folder = path.join(paths.skillsDir, entry.name);
|
|
7858
|
+
const marker = await readFile(path.join(folder, ".forge-version"), "utf8").catch(() => "");
|
|
7859
|
+
if (!marker.trim()) continue;
|
|
7860
|
+
for (const name of await readProjectionRecord(path.join(folder, ".forge-agents"))) agents.add(stripMarkdownExtension(name));
|
|
7861
|
+
for (const name of await readProjectionRecord(path.join(folder, ".forge-commands"))) commands.add(stripMarkdownExtension(name));
|
|
7862
|
+
}
|
|
7863
|
+
return { agents, commands };
|
|
7864
|
+
}
|
|
7865
|
+
async function readProjectionRecord(filePath) {
|
|
7866
|
+
const raw = await readFile(filePath, "utf8").catch(() => "");
|
|
7867
|
+
return raw.split("\n").map((line) => line.trim()).filter(
|
|
7868
|
+
(line) => line.endsWith(".md") && !line.includes("/") && !line.includes("\\") && line !== ".."
|
|
7869
|
+
);
|
|
7870
|
+
}
|
|
7871
|
+
async function projectCurrentExtensions(config2, state) {
|
|
7872
|
+
const agents = objectRecord(config2.agent);
|
|
7873
|
+
const commands = objectRecord(config2.command);
|
|
7874
|
+
for (const name of state.before.agents) if (!state.after.agents.has(name)) delete agents[name];
|
|
7875
|
+
for (const name of state.before.commands) if (!state.after.commands.has(name)) delete commands[name];
|
|
7876
|
+
for (const name of state.after.agents) {
|
|
7877
|
+
agents[name] = await parseMarkdownConfig(path.join(state.paths.agentsDir, `${name}.md`), "prompt");
|
|
7878
|
+
}
|
|
7879
|
+
for (const name of state.after.commands) {
|
|
7880
|
+
commands[name] = await parseMarkdownConfig(path.join(state.paths.commandsDir, `${name}.md`), "template");
|
|
7881
|
+
}
|
|
7882
|
+
config2.agent = agents;
|
|
7883
|
+
config2.command = commands;
|
|
7884
|
+
}
|
|
7885
|
+
async function refreshPartialProjections(config2, previous, paths, before, result) {
|
|
7886
|
+
const existing = objectRecord(previous);
|
|
7887
|
+
const agents = objectRecord(existing.agent);
|
|
7888
|
+
const commands = objectRecord(existing.command);
|
|
7889
|
+
if (!before.agents.has(DOCUMENT_READER_AGENT)) delete agents[DOCUMENT_READER_AGENT];
|
|
7890
|
+
for (const file2 of result.removedManagedPaths) {
|
|
7891
|
+
if (path.extname(file2) !== ".md") continue;
|
|
7892
|
+
const directory = path.dirname(file2);
|
|
7893
|
+
const name = path.basename(file2, ".md");
|
|
7894
|
+
if (directory === paths.agentsDir) delete agents[name];
|
|
7895
|
+
if (directory === paths.commandsDir) delete commands[name];
|
|
7896
|
+
}
|
|
7897
|
+
config2.agent = { ...objectRecord(config2.agent), ...agents };
|
|
7898
|
+
config2.command = commands;
|
|
7899
|
+
const confirmed = new Set(result.workPacks.outcomes.filter(
|
|
7900
|
+
({ action, status }) => action === "install" && (status === "installed" || status === "unchanged")
|
|
7901
|
+
).map(({ slug }) => slug));
|
|
7902
|
+
await projectInstalledExtensions(config2, paths, confirmed);
|
|
7903
|
+
}
|
|
7904
|
+
async function parseMarkdownConfig(filePath, bodyField) {
|
|
7905
|
+
const raw = await readFile(filePath, "utf8");
|
|
7906
|
+
const match = /^---\r?\n([\s\S]+?)\r?\n---\r?\n?([\s\S]*)$/.exec(raw);
|
|
7907
|
+
if (!match) throw new Error(`A extens\xE3o Forge ${path.basename(filePath)} n\xE3o tem frontmatter v\xE1lido`);
|
|
7908
|
+
const data = (0, import_yaml.parse)(match[1]);
|
|
7909
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
7910
|
+
throw new Error(`A extens\xE3o Forge ${path.basename(filePath)} n\xE3o tem frontmatter v\xE1lido`);
|
|
7911
|
+
}
|
|
7912
|
+
const config2 = { ...data, [bodyField]: match[2].trim() };
|
|
7913
|
+
if (bodyField === "prompt" && typeof config2.permission === "string" && ["allow", "ask", "deny"].includes(config2.permission)) {
|
|
7914
|
+
config2.permission = { "*": config2.permission };
|
|
7915
|
+
}
|
|
7916
|
+
return config2;
|
|
7917
|
+
}
|
|
7918
|
+
function objectRecord(value) {
|
|
7919
|
+
return value && typeof value === "object" && !Array.isArray(value) ? { ...value } : {};
|
|
7920
|
+
}
|
|
7921
|
+
function stripMarkdownExtension(filename) {
|
|
7922
|
+
return filename.slice(0, -3);
|
|
7923
|
+
}
|
|
7924
|
+
async function projectInstalledExtensions(config2, paths, slugs) {
|
|
7925
|
+
const names = await managedProjectionNames(paths, slugs);
|
|
7926
|
+
await projectCurrentExtensions(config2, { paths, before: names, after: names });
|
|
7927
|
+
for (const key of ["agent", "command"]) if (Object.keys(objectRecord(config2[key])).length === 0) delete config2[key];
|
|
7928
|
+
}
|
|
7929
|
+
|
|
7903
7930
|
// packages/cli/src/runtimeObservation.ts
|
|
7904
7931
|
var UNKNOWN_RUNTIME = {
|
|
7905
7932
|
opencode: { status: "unknown" },
|
|
@@ -26758,7 +26785,7 @@ async function writeOpenworkEngineConfig(directory, config2) {
|
|
|
26758
26785
|
}
|
|
26759
26786
|
|
|
26760
26787
|
// packages/cli/src/workPackSyncPlugin.ts
|
|
26761
|
-
var PLUGIN_VERSION = "0.1.
|
|
26788
|
+
var PLUGIN_VERSION = "0.1.51";
|
|
26762
26789
|
var FORGE_DECISION_TIMEOUT_MS = 11e4;
|
|
26763
26790
|
var STATUS_FILENAME = "work-pack-startup-status.json";
|
|
26764
26791
|
var activeSync = /* @__PURE__ */ new Map();
|
|
@@ -26866,7 +26893,13 @@ async function ForgeWorkPackSyncSetup(ctx) {
|
|
|
26866
26893
|
const credentials = await readForgeCredentials(state.paths, forgeBaseUrl);
|
|
26867
26894
|
const canonical = objectRecord2(parseJsonc(await readFile13(state.paths.opencodeConfigPath, "utf8")));
|
|
26868
26895
|
const config2 = renderOpenworkEngineConfig(state.manifest, credentials, state.paths, directory, canonical);
|
|
26869
|
-
|
|
26896
|
+
if (state.partialWorkPackSync) {
|
|
26897
|
+
const companion = await inspectOpenworkEngineConfig(directory);
|
|
26898
|
+
if (!companion.content) return createForgeTools(forgeBaseUrl, state);
|
|
26899
|
+
await refreshPartialProjections(config2, parseJsonc(companion.content), state.paths, state.before, state.partialWorkPackSync);
|
|
26900
|
+
} else {
|
|
26901
|
+
await projectCurrentExtensions(config2, state);
|
|
26902
|
+
}
|
|
26870
26903
|
for (const key of ["agent", "command"]) if (Object.keys(objectRecord2(config2[key])).length === 0) delete config2[key];
|
|
26871
26904
|
await writeOpenworkEngineConfig(directory, config2);
|
|
26872
26905
|
}
|
|
@@ -27387,6 +27420,7 @@ async function synchronizeAtStartup(forgeBaseUrl, observe, localConfig, input) {
|
|
|
27387
27420
|
const before = await managedProjectionNames(paths);
|
|
27388
27421
|
let credentials;
|
|
27389
27422
|
let forgeConfigVerified = false;
|
|
27423
|
+
let appliedLocalSync;
|
|
27390
27424
|
let pluginUpdate;
|
|
27391
27425
|
let decisionBaseUrl = forgeBaseUrl;
|
|
27392
27426
|
const runtime = await observe();
|
|
@@ -27398,6 +27432,7 @@ async function synchronizeAtStartup(forgeBaseUrl, observe, localConfig, input) {
|
|
|
27398
27432
|
forgeConfigVerified = true;
|
|
27399
27433
|
const result = localConfig ? await syncLocalWorker(paths, credentials, manifest) : await applyWorkPackManifest(paths, credentials, manifest, {});
|
|
27400
27434
|
if (localConfig) {
|
|
27435
|
+
appliedLocalSync = { manifest, partialWorkPackSync: result };
|
|
27401
27436
|
const config2 = objectRecord2(parseJsonc(await readFile13(paths.opencodeConfigPath, "utf8")));
|
|
27402
27437
|
const targetVersion = configuredWorkPackSyncPluginVersion(config2);
|
|
27403
27438
|
if (targetVersion) pluginUpdate = { targetVersion, restartRequired: targetVersion !== PLUGIN_VERSION };
|
|
@@ -27445,7 +27480,7 @@ async function synchronizeAtStartup(forgeBaseUrl, observe, localConfig, input) {
|
|
|
27445
27480
|
decisionBaseUrl = await savedGatewayBaseUrl(paths, credentials, forgeBaseUrl) ?? decisionBaseUrl;
|
|
27446
27481
|
}
|
|
27447
27482
|
const after = await managedProjectionNames(paths).catch(() => before);
|
|
27448
|
-
return { paths, before, after, forgeConfigVerified, decisionBaseUrl };
|
|
27483
|
+
return { paths, before, after, forgeConfigVerified, decisionBaseUrl, ...appliedLocalSync };
|
|
27449
27484
|
}
|
|
27450
27485
|
}
|
|
27451
27486
|
async function savedGatewayBaseUrl(paths, credentials, forgeBaseUrl) {
|
package/dist/repair.js
CHANGED
|
@@ -419,7 +419,7 @@ var DEVICE_ENROLLMENT_PROTOCOL_VERSION = 1;
|
|
|
419
419
|
// packages/shared/src/contracts/settings.ts
|
|
420
420
|
var DOCUMENT_READER_AGENT = "document-reader";
|
|
421
421
|
var OPENROUTER_ALIAS_PROVIDER_NAME = "OpenRouter (via Forge)";
|
|
422
|
-
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.
|
|
422
|
+
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.51";
|
|
423
423
|
var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
|
|
424
424
|
var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
|
|
425
425
|
var FIRECRAWL_KEYLESS_MCP_NAME = "firecrawl";
|