minimal-forge-work-pack-sync 0.1.12 → 0.1.14
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 +520 -418
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -117,17 +117,17 @@ var require_visit = __commonJS({
|
|
|
117
117
|
visit.BREAK = BREAK;
|
|
118
118
|
visit.SKIP = SKIP;
|
|
119
119
|
visit.REMOVE = REMOVE;
|
|
120
|
-
function visit_(key, node, visitor,
|
|
121
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
120
|
+
function visit_(key, node, visitor, path6) {
|
|
121
|
+
const ctrl = callVisitor(key, node, visitor, path6);
|
|
122
122
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
123
|
-
replaceNode(key,
|
|
124
|
-
return visit_(key, ctrl, visitor,
|
|
123
|
+
replaceNode(key, path6, ctrl);
|
|
124
|
+
return visit_(key, ctrl, visitor, path6);
|
|
125
125
|
}
|
|
126
126
|
if (typeof ctrl !== "symbol") {
|
|
127
127
|
if (identity.isCollection(node)) {
|
|
128
|
-
|
|
128
|
+
path6 = Object.freeze(path6.concat(node));
|
|
129
129
|
for (let i = 0; i < node.items.length; ++i) {
|
|
130
|
-
const ci2 = visit_(i, node.items[i], visitor,
|
|
130
|
+
const ci2 = visit_(i, node.items[i], visitor, path6);
|
|
131
131
|
if (typeof ci2 === "number")
|
|
132
132
|
i = ci2 - 1;
|
|
133
133
|
else if (ci2 === BREAK)
|
|
@@ -138,13 +138,13 @@ var require_visit = __commonJS({
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
} else if (identity.isPair(node)) {
|
|
141
|
-
|
|
142
|
-
const ck = visit_("key", node.key, visitor,
|
|
141
|
+
path6 = Object.freeze(path6.concat(node));
|
|
142
|
+
const ck = visit_("key", node.key, visitor, path6);
|
|
143
143
|
if (ck === BREAK)
|
|
144
144
|
return BREAK;
|
|
145
145
|
else if (ck === REMOVE)
|
|
146
146
|
node.key = null;
|
|
147
|
-
const cv = visit_("value", node.value, visitor,
|
|
147
|
+
const cv = visit_("value", node.value, visitor, path6);
|
|
148
148
|
if (cv === BREAK)
|
|
149
149
|
return BREAK;
|
|
150
150
|
else if (cv === REMOVE)
|
|
@@ -165,17 +165,17 @@ var require_visit = __commonJS({
|
|
|
165
165
|
visitAsync.BREAK = BREAK;
|
|
166
166
|
visitAsync.SKIP = SKIP;
|
|
167
167
|
visitAsync.REMOVE = REMOVE;
|
|
168
|
-
async function visitAsync_(key, node, visitor,
|
|
169
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
168
|
+
async function visitAsync_(key, node, visitor, path6) {
|
|
169
|
+
const ctrl = await callVisitor(key, node, visitor, path6);
|
|
170
170
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
171
|
-
replaceNode(key,
|
|
172
|
-
return visitAsync_(key, ctrl, visitor,
|
|
171
|
+
replaceNode(key, path6, ctrl);
|
|
172
|
+
return visitAsync_(key, ctrl, visitor, path6);
|
|
173
173
|
}
|
|
174
174
|
if (typeof ctrl !== "symbol") {
|
|
175
175
|
if (identity.isCollection(node)) {
|
|
176
|
-
|
|
176
|
+
path6 = Object.freeze(path6.concat(node));
|
|
177
177
|
for (let i = 0; i < node.items.length; ++i) {
|
|
178
|
-
const ci2 = await visitAsync_(i, node.items[i], visitor,
|
|
178
|
+
const ci2 = await visitAsync_(i, node.items[i], visitor, path6);
|
|
179
179
|
if (typeof ci2 === "number")
|
|
180
180
|
i = ci2 - 1;
|
|
181
181
|
else if (ci2 === BREAK)
|
|
@@ -186,13 +186,13 @@ var require_visit = __commonJS({
|
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
} else if (identity.isPair(node)) {
|
|
189
|
-
|
|
190
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
189
|
+
path6 = Object.freeze(path6.concat(node));
|
|
190
|
+
const ck = await visitAsync_("key", node.key, visitor, path6);
|
|
191
191
|
if (ck === BREAK)
|
|
192
192
|
return BREAK;
|
|
193
193
|
else if (ck === REMOVE)
|
|
194
194
|
node.key = null;
|
|
195
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
195
|
+
const cv = await visitAsync_("value", node.value, visitor, path6);
|
|
196
196
|
if (cv === BREAK)
|
|
197
197
|
return BREAK;
|
|
198
198
|
else if (cv === REMOVE)
|
|
@@ -219,23 +219,23 @@ var require_visit = __commonJS({
|
|
|
219
219
|
}
|
|
220
220
|
return visitor;
|
|
221
221
|
}
|
|
222
|
-
function callVisitor(key, node, visitor,
|
|
222
|
+
function callVisitor(key, node, visitor, path6) {
|
|
223
223
|
if (typeof visitor === "function")
|
|
224
|
-
return visitor(key, node,
|
|
224
|
+
return visitor(key, node, path6);
|
|
225
225
|
if (identity.isMap(node))
|
|
226
|
-
return visitor.Map?.(key, node,
|
|
226
|
+
return visitor.Map?.(key, node, path6);
|
|
227
227
|
if (identity.isSeq(node))
|
|
228
|
-
return visitor.Seq?.(key, node,
|
|
228
|
+
return visitor.Seq?.(key, node, path6);
|
|
229
229
|
if (identity.isPair(node))
|
|
230
|
-
return visitor.Pair?.(key, node,
|
|
230
|
+
return visitor.Pair?.(key, node, path6);
|
|
231
231
|
if (identity.isScalar(node))
|
|
232
|
-
return visitor.Scalar?.(key, node,
|
|
232
|
+
return visitor.Scalar?.(key, node, path6);
|
|
233
233
|
if (identity.isAlias(node))
|
|
234
|
-
return visitor.Alias?.(key, node,
|
|
234
|
+
return visitor.Alias?.(key, node, path6);
|
|
235
235
|
return void 0;
|
|
236
236
|
}
|
|
237
|
-
function replaceNode(key,
|
|
238
|
-
const parent =
|
|
237
|
+
function replaceNode(key, path6, node) {
|
|
238
|
+
const parent = path6[path6.length - 1];
|
|
239
239
|
if (identity.isCollection(parent)) {
|
|
240
240
|
parent.items[key] = node;
|
|
241
241
|
} else if (identity.isPair(parent)) {
|
|
@@ -845,10 +845,10 @@ var require_Collection = __commonJS({
|
|
|
845
845
|
var createNode = require_createNode();
|
|
846
846
|
var identity = require_identity();
|
|
847
847
|
var Node = require_Node();
|
|
848
|
-
function collectionFromPath(schema,
|
|
848
|
+
function collectionFromPath(schema, path6, value) {
|
|
849
849
|
let v2 = value;
|
|
850
|
-
for (let i =
|
|
851
|
-
const k2 =
|
|
850
|
+
for (let i = path6.length - 1; i >= 0; --i) {
|
|
851
|
+
const k2 = path6[i];
|
|
852
852
|
if (typeof k2 === "number" && Number.isInteger(k2) && k2 >= 0) {
|
|
853
853
|
const a = [];
|
|
854
854
|
a[k2] = v2;
|
|
@@ -867,7 +867,7 @@ var require_Collection = __commonJS({
|
|
|
867
867
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
868
868
|
});
|
|
869
869
|
}
|
|
870
|
-
var isEmptyPath = (
|
|
870
|
+
var isEmptyPath = (path6) => path6 == null || typeof path6 === "object" && !!path6[Symbol.iterator]().next().done;
|
|
871
871
|
var Collection = class extends Node.NodeBase {
|
|
872
872
|
constructor(type, schema) {
|
|
873
873
|
super(type);
|
|
@@ -897,11 +897,11 @@ var require_Collection = __commonJS({
|
|
|
897
897
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
898
898
|
* that already exists in the map.
|
|
899
899
|
*/
|
|
900
|
-
addIn(
|
|
901
|
-
if (isEmptyPath(
|
|
900
|
+
addIn(path6, value) {
|
|
901
|
+
if (isEmptyPath(path6))
|
|
902
902
|
this.add(value);
|
|
903
903
|
else {
|
|
904
|
-
const [key, ...rest] =
|
|
904
|
+
const [key, ...rest] = path6;
|
|
905
905
|
const node = this.get(key, true);
|
|
906
906
|
if (identity.isCollection(node))
|
|
907
907
|
node.addIn(rest, value);
|
|
@@ -915,8 +915,8 @@ var require_Collection = __commonJS({
|
|
|
915
915
|
* Removes a value from the collection.
|
|
916
916
|
* @returns `true` if the item was found and removed.
|
|
917
917
|
*/
|
|
918
|
-
deleteIn(
|
|
919
|
-
const [key, ...rest] =
|
|
918
|
+
deleteIn(path6) {
|
|
919
|
+
const [key, ...rest] = path6;
|
|
920
920
|
if (rest.length === 0)
|
|
921
921
|
return this.delete(key);
|
|
922
922
|
const node = this.get(key, true);
|
|
@@ -930,8 +930,8 @@ var require_Collection = __commonJS({
|
|
|
930
930
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
931
931
|
* `true` (collections are always returned intact).
|
|
932
932
|
*/
|
|
933
|
-
getIn(
|
|
934
|
-
const [key, ...rest] =
|
|
933
|
+
getIn(path6, keepScalar) {
|
|
934
|
+
const [key, ...rest] = path6;
|
|
935
935
|
const node = this.get(key, true);
|
|
936
936
|
if (rest.length === 0)
|
|
937
937
|
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
|
@@ -949,8 +949,8 @@ var require_Collection = __commonJS({
|
|
|
949
949
|
/**
|
|
950
950
|
* Checks if the collection includes a value with the key `key`.
|
|
951
951
|
*/
|
|
952
|
-
hasIn(
|
|
953
|
-
const [key, ...rest] =
|
|
952
|
+
hasIn(path6) {
|
|
953
|
+
const [key, ...rest] = path6;
|
|
954
954
|
if (rest.length === 0)
|
|
955
955
|
return this.has(key);
|
|
956
956
|
const node = this.get(key, true);
|
|
@@ -960,8 +960,8 @@ var require_Collection = __commonJS({
|
|
|
960
960
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
961
961
|
* boolean to add/remove the item from the set.
|
|
962
962
|
*/
|
|
963
|
-
setIn(
|
|
964
|
-
const [key, ...rest] =
|
|
963
|
+
setIn(path6, value) {
|
|
964
|
+
const [key, ...rest] = path6;
|
|
965
965
|
if (rest.length === 0) {
|
|
966
966
|
this.set(key, value);
|
|
967
967
|
} else {
|
|
@@ -3476,9 +3476,9 @@ var require_Document = __commonJS({
|
|
|
3476
3476
|
this.contents.add(value);
|
|
3477
3477
|
}
|
|
3478
3478
|
/** Adds a value to the document. */
|
|
3479
|
-
addIn(
|
|
3479
|
+
addIn(path6, value) {
|
|
3480
3480
|
if (assertCollection(this.contents))
|
|
3481
|
-
this.contents.addIn(
|
|
3481
|
+
this.contents.addIn(path6, value);
|
|
3482
3482
|
}
|
|
3483
3483
|
/**
|
|
3484
3484
|
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
|
|
@@ -3553,14 +3553,14 @@ var require_Document = __commonJS({
|
|
|
3553
3553
|
* Removes a value from the document.
|
|
3554
3554
|
* @returns `true` if the item was found and removed.
|
|
3555
3555
|
*/
|
|
3556
|
-
deleteIn(
|
|
3557
|
-
if (Collection.isEmptyPath(
|
|
3556
|
+
deleteIn(path6) {
|
|
3557
|
+
if (Collection.isEmptyPath(path6)) {
|
|
3558
3558
|
if (this.contents == null)
|
|
3559
3559
|
return false;
|
|
3560
3560
|
this.contents = null;
|
|
3561
3561
|
return true;
|
|
3562
3562
|
}
|
|
3563
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
3563
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path6) : false;
|
|
3564
3564
|
}
|
|
3565
3565
|
/**
|
|
3566
3566
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
@@ -3575,10 +3575,10 @@ var require_Document = __commonJS({
|
|
|
3575
3575
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
3576
3576
|
* `true` (collections are always returned intact).
|
|
3577
3577
|
*/
|
|
3578
|
-
getIn(
|
|
3579
|
-
if (Collection.isEmptyPath(
|
|
3578
|
+
getIn(path6, keepScalar) {
|
|
3579
|
+
if (Collection.isEmptyPath(path6))
|
|
3580
3580
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
3581
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
3581
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path6, keepScalar) : void 0;
|
|
3582
3582
|
}
|
|
3583
3583
|
/**
|
|
3584
3584
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -3589,10 +3589,10 @@ var require_Document = __commonJS({
|
|
|
3589
3589
|
/**
|
|
3590
3590
|
* Checks if the document includes a value at `path`.
|
|
3591
3591
|
*/
|
|
3592
|
-
hasIn(
|
|
3593
|
-
if (Collection.isEmptyPath(
|
|
3592
|
+
hasIn(path6) {
|
|
3593
|
+
if (Collection.isEmptyPath(path6))
|
|
3594
3594
|
return this.contents !== void 0;
|
|
3595
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
3595
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path6) : false;
|
|
3596
3596
|
}
|
|
3597
3597
|
/**
|
|
3598
3598
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -3609,13 +3609,13 @@ var require_Document = __commonJS({
|
|
|
3609
3609
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
3610
3610
|
* boolean to add/remove the item from the set.
|
|
3611
3611
|
*/
|
|
3612
|
-
setIn(
|
|
3613
|
-
if (Collection.isEmptyPath(
|
|
3612
|
+
setIn(path6, value) {
|
|
3613
|
+
if (Collection.isEmptyPath(path6)) {
|
|
3614
3614
|
this.contents = value;
|
|
3615
3615
|
} else if (this.contents == null) {
|
|
3616
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
3616
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path6), value);
|
|
3617
3617
|
} else if (assertCollection(this.contents)) {
|
|
3618
|
-
this.contents.setIn(
|
|
3618
|
+
this.contents.setIn(path6, value);
|
|
3619
3619
|
}
|
|
3620
3620
|
}
|
|
3621
3621
|
/**
|
|
@@ -5575,9 +5575,9 @@ var require_cst_visit = __commonJS({
|
|
|
5575
5575
|
visit.BREAK = BREAK;
|
|
5576
5576
|
visit.SKIP = SKIP;
|
|
5577
5577
|
visit.REMOVE = REMOVE;
|
|
5578
|
-
visit.itemAtPath = (cst,
|
|
5578
|
+
visit.itemAtPath = (cst, path6) => {
|
|
5579
5579
|
let item = cst;
|
|
5580
|
-
for (const [field, index] of
|
|
5580
|
+
for (const [field, index] of path6) {
|
|
5581
5581
|
const tok = item?.[field];
|
|
5582
5582
|
if (tok && "items" in tok) {
|
|
5583
5583
|
item = tok.items[index];
|
|
@@ -5586,23 +5586,23 @@ var require_cst_visit = __commonJS({
|
|
|
5586
5586
|
}
|
|
5587
5587
|
return item;
|
|
5588
5588
|
};
|
|
5589
|
-
visit.parentCollection = (cst,
|
|
5590
|
-
const parent = visit.itemAtPath(cst,
|
|
5591
|
-
const field =
|
|
5589
|
+
visit.parentCollection = (cst, path6) => {
|
|
5590
|
+
const parent = visit.itemAtPath(cst, path6.slice(0, -1));
|
|
5591
|
+
const field = path6[path6.length - 1][0];
|
|
5592
5592
|
const coll = parent?.[field];
|
|
5593
5593
|
if (coll && "items" in coll)
|
|
5594
5594
|
return coll;
|
|
5595
5595
|
throw new Error("Parent collection not found");
|
|
5596
5596
|
};
|
|
5597
|
-
function _visit(
|
|
5598
|
-
let ctrl = visitor(item,
|
|
5597
|
+
function _visit(path6, item, visitor) {
|
|
5598
|
+
let ctrl = visitor(item, path6);
|
|
5599
5599
|
if (typeof ctrl === "symbol")
|
|
5600
5600
|
return ctrl;
|
|
5601
5601
|
for (const field of ["key", "value"]) {
|
|
5602
5602
|
const token = item[field];
|
|
5603
5603
|
if (token && "items" in token) {
|
|
5604
5604
|
for (let i = 0; i < token.items.length; ++i) {
|
|
5605
|
-
const ci2 = _visit(Object.freeze(
|
|
5605
|
+
const ci2 = _visit(Object.freeze(path6.concat([[field, i]])), token.items[i], visitor);
|
|
5606
5606
|
if (typeof ci2 === "number")
|
|
5607
5607
|
i = ci2 - 1;
|
|
5608
5608
|
else if (ci2 === BREAK)
|
|
@@ -5613,10 +5613,10 @@ var require_cst_visit = __commonJS({
|
|
|
5613
5613
|
}
|
|
5614
5614
|
}
|
|
5615
5615
|
if (typeof ctrl === "function" && field === "key")
|
|
5616
|
-
ctrl = ctrl(item,
|
|
5616
|
+
ctrl = ctrl(item, path6);
|
|
5617
5617
|
}
|
|
5618
5618
|
}
|
|
5619
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
5619
|
+
return typeof ctrl === "function" ? ctrl(item, path6) : ctrl;
|
|
5620
5620
|
}
|
|
5621
5621
|
exports.visit = visit;
|
|
5622
5622
|
}
|
|
@@ -7367,10 +7367,54 @@ var require_dist = __commonJS({
|
|
|
7367
7367
|
}
|
|
7368
7368
|
});
|
|
7369
7369
|
|
|
7370
|
+
// packages/cli/src/retireDebugCapture.ts
|
|
7371
|
+
import { lstat, readFile, rename, writeFile } from "node:fs/promises";
|
|
7372
|
+
import { randomUUID } from "node:crypto";
|
|
7373
|
+
import path from "node:path";
|
|
7374
|
+
var MANAGED_HEADER = "// Managed by Forge sync. Do not edit.";
|
|
7375
|
+
var RETIRED_DEBUG_PLUGIN = `${MANAGED_HEADER}
|
|
7376
|
+
// Detailed capture retired. Keep this module loadable for old OpenCode configs.
|
|
7377
|
+
export const ForgeDebugTrace = async () => ({})
|
|
7378
|
+
`;
|
|
7379
|
+
async function retireDebugCapture(paths) {
|
|
7380
|
+
const configPath = path.join(paths.forgeDir, "debug-trace.json");
|
|
7381
|
+
const raw = await readRegularFile(configPath);
|
|
7382
|
+
if (raw !== void 0) {
|
|
7383
|
+
const config2 = JSON.parse(raw);
|
|
7384
|
+
if (config2?.managedBy === "minimal-forge" && config2.enabled !== false) {
|
|
7385
|
+
await replaceFile(configPath, `${JSON.stringify({ ...config2, enabled: false }, null, 2)}
|
|
7386
|
+
`);
|
|
7387
|
+
}
|
|
7388
|
+
}
|
|
7389
|
+
const pluginPath = path.join(paths.pluginDir, "forge-debug-trace.js");
|
|
7390
|
+
const plugin = await readRegularFile(pluginPath);
|
|
7391
|
+
if (plugin?.startsWith(MANAGED_HEADER) && plugin !== RETIRED_DEBUG_PLUGIN) {
|
|
7392
|
+
await replaceFile(pluginPath, RETIRED_DEBUG_PLUGIN);
|
|
7393
|
+
}
|
|
7394
|
+
}
|
|
7395
|
+
async function readRegularFile(filename) {
|
|
7396
|
+
try {
|
|
7397
|
+
const directory = await lstat(path.dirname(filename));
|
|
7398
|
+
const info = await lstat(filename);
|
|
7399
|
+
if (!directory.isDirectory() || !info.isFile() || info.isSymbolicLink()) {
|
|
7400
|
+
throw new Error("Legacy debug capture path must be a regular file in a real directory");
|
|
7401
|
+
}
|
|
7402
|
+
return await readFile(filename, "utf8");
|
|
7403
|
+
} catch (error45) {
|
|
7404
|
+
if (error45.code === "ENOENT") return void 0;
|
|
7405
|
+
throw error45;
|
|
7406
|
+
}
|
|
7407
|
+
}
|
|
7408
|
+
async function replaceFile(filename, contents) {
|
|
7409
|
+
const temporary = `${filename}.retired-${randomUUID()}`;
|
|
7410
|
+
await writeFile(temporary, contents, { flag: "wx", mode: 384 });
|
|
7411
|
+
await rename(temporary, filename);
|
|
7412
|
+
}
|
|
7413
|
+
|
|
7370
7414
|
// packages/cli/src/workPackSyncPlugin.ts
|
|
7371
7415
|
var import_yaml = __toESM(require_dist(), 1);
|
|
7372
|
-
import { mkdir as mkdir3, readdir as readdir3, readFile as
|
|
7373
|
-
import
|
|
7416
|
+
import { mkdir as mkdir3, readdir as readdir3, readFile as readFile4, rename as rename4, writeFile as writeFile4 } from "node:fs/promises";
|
|
7417
|
+
import path5 from "node:path";
|
|
7374
7418
|
|
|
7375
7419
|
// node_modules/@opencode-ai/plugin/node_modules/zod/v4/classic/external.js
|
|
7376
7420
|
var external_exports = {};
|
|
@@ -8103,10 +8147,10 @@ function mergeDefs(...defs) {
|
|
|
8103
8147
|
function cloneDef(schema) {
|
|
8104
8148
|
return mergeDefs(schema._zod.def);
|
|
8105
8149
|
}
|
|
8106
|
-
function getElementAtPath(obj,
|
|
8107
|
-
if (!
|
|
8150
|
+
function getElementAtPath(obj, path6) {
|
|
8151
|
+
if (!path6)
|
|
8108
8152
|
return obj;
|
|
8109
|
-
return
|
|
8153
|
+
return path6.reduce((acc, key) => acc?.[key], obj);
|
|
8110
8154
|
}
|
|
8111
8155
|
function promiseAllObject(promisesObj) {
|
|
8112
8156
|
const keys = Object.keys(promisesObj);
|
|
@@ -8467,11 +8511,11 @@ function aborted(x, startIndex = 0) {
|
|
|
8467
8511
|
}
|
|
8468
8512
|
return false;
|
|
8469
8513
|
}
|
|
8470
|
-
function prefixIssues(
|
|
8514
|
+
function prefixIssues(path6, issues) {
|
|
8471
8515
|
return issues.map((iss) => {
|
|
8472
8516
|
var _a;
|
|
8473
8517
|
(_a = iss).path ?? (_a.path = []);
|
|
8474
|
-
iss.path.unshift(
|
|
8518
|
+
iss.path.unshift(path6);
|
|
8475
8519
|
return iss;
|
|
8476
8520
|
});
|
|
8477
8521
|
}
|
|
@@ -8639,7 +8683,7 @@ function treeifyError(error45, _mapper) {
|
|
|
8639
8683
|
return issue2.message;
|
|
8640
8684
|
};
|
|
8641
8685
|
const result = { errors: [] };
|
|
8642
|
-
const processError = (error46,
|
|
8686
|
+
const processError = (error46, path6 = []) => {
|
|
8643
8687
|
var _a, _b;
|
|
8644
8688
|
for (const issue2 of error46.issues) {
|
|
8645
8689
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -8649,7 +8693,7 @@ function treeifyError(error45, _mapper) {
|
|
|
8649
8693
|
} else if (issue2.code === "invalid_element") {
|
|
8650
8694
|
processError({ issues: issue2.issues }, issue2.path);
|
|
8651
8695
|
} else {
|
|
8652
|
-
const fullpath = [...
|
|
8696
|
+
const fullpath = [...path6, ...issue2.path];
|
|
8653
8697
|
if (fullpath.length === 0) {
|
|
8654
8698
|
result.errors.push(mapper(issue2));
|
|
8655
8699
|
continue;
|
|
@@ -8681,8 +8725,8 @@ function treeifyError(error45, _mapper) {
|
|
|
8681
8725
|
}
|
|
8682
8726
|
function toDotPath(_path) {
|
|
8683
8727
|
const segs = [];
|
|
8684
|
-
const
|
|
8685
|
-
for (const seg of
|
|
8728
|
+
const path6 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
8729
|
+
for (const seg of path6) {
|
|
8686
8730
|
if (typeof seg === "number")
|
|
8687
8731
|
segs.push(`[${seg}]`);
|
|
8688
8732
|
else if (typeof seg === "symbol")
|
|
@@ -19796,10 +19840,10 @@ tool.schema = external_exports;
|
|
|
19796
19840
|
|
|
19797
19841
|
// packages/cli/src/paths.ts
|
|
19798
19842
|
import os from "node:os";
|
|
19799
|
-
import
|
|
19843
|
+
import path2 from "node:path";
|
|
19800
19844
|
import { existsSync } from "node:fs";
|
|
19801
19845
|
function resolvePaths(home = os.homedir(), platform = process.platform, env = process.env, exists = existsSync) {
|
|
19802
|
-
const pathApi = platform === "win32" ?
|
|
19846
|
+
const pathApi = platform === "win32" ? path2.win32 : path2.posix;
|
|
19803
19847
|
const userHome = platform === "win32" ? env.USERPROFILE ?? home : home;
|
|
19804
19848
|
const forgeConfigRoot = env.XDG_CONFIG_HOME ?? pathApi.join(userHome, ".config");
|
|
19805
19849
|
const forgeDir = pathApi.join(forgeConfigRoot, "forge");
|
|
@@ -19882,11 +19926,230 @@ async function reportWorkPackObservations(credentials, kind, workPacks) {
|
|
|
19882
19926
|
}
|
|
19883
19927
|
}
|
|
19884
19928
|
|
|
19929
|
+
// packages/shared/src/contracts/models.ts
|
|
19930
|
+
var BUILT_IN_OPENROUTER_MODELS = [
|
|
19931
|
+
{
|
|
19932
|
+
id: "anthropic/claude-sonnet-4-6",
|
|
19933
|
+
name: "Assistente de trabalho profundo",
|
|
19934
|
+
approvedByDefault: true,
|
|
19935
|
+
requiredInConfig: false,
|
|
19936
|
+
upstreamModel: "anthropic/claude-sonnet-4.6",
|
|
19937
|
+
metadata: {
|
|
19938
|
+
family: "anthropic",
|
|
19939
|
+
release_date: "2026-02-17",
|
|
19940
|
+
attachment: true,
|
|
19941
|
+
reasoning: true,
|
|
19942
|
+
temperature: true,
|
|
19943
|
+
tool_call: true,
|
|
19944
|
+
limit: { context: 1e6, output: 128e3 },
|
|
19945
|
+
modalities: { input: ["text", "image", "pdf"], output: ["text"] }
|
|
19946
|
+
}
|
|
19947
|
+
},
|
|
19948
|
+
{
|
|
19949
|
+
id: "anthropic/claude-haiku-4-5",
|
|
19950
|
+
name: "Assistente r\xE1pido",
|
|
19951
|
+
approvedByDefault: true,
|
|
19952
|
+
requiredInConfig: false,
|
|
19953
|
+
upstreamModel: "anthropic/claude-haiku-4.5",
|
|
19954
|
+
metadata: {
|
|
19955
|
+
family: "anthropic",
|
|
19956
|
+
release_date: "2025-10-15",
|
|
19957
|
+
attachment: true,
|
|
19958
|
+
reasoning: true,
|
|
19959
|
+
temperature: true,
|
|
19960
|
+
tool_call: true,
|
|
19961
|
+
limit: { context: 2e5, output: 64e3 },
|
|
19962
|
+
modalities: { input: ["text", "image", "pdf"], output: ["text"] }
|
|
19963
|
+
}
|
|
19964
|
+
},
|
|
19965
|
+
{
|
|
19966
|
+
id: "openai/gpt-5.4-mini",
|
|
19967
|
+
name: "Assistente de ficheiros e ecr\xE3",
|
|
19968
|
+
approvedByDefault: true,
|
|
19969
|
+
requiredInConfig: false,
|
|
19970
|
+
metadata: {
|
|
19971
|
+
family: "gpt-mini",
|
|
19972
|
+
release_date: "2026-03-17",
|
|
19973
|
+
attachment: true,
|
|
19974
|
+
reasoning: true,
|
|
19975
|
+
temperature: false,
|
|
19976
|
+
tool_call: true,
|
|
19977
|
+
limit: { context: 4e5, input: 272e3, output: 128e3 },
|
|
19978
|
+
modalities: { input: ["text", "image", "pdf"], output: ["text"] },
|
|
19979
|
+
variants: openRouterReasoningVariants(["none", "xhigh"])
|
|
19980
|
+
}
|
|
19981
|
+
},
|
|
19982
|
+
{
|
|
19983
|
+
id: "minimax/minimax-m3",
|
|
19984
|
+
name: "Assistente de pesquisa",
|
|
19985
|
+
approvedByDefault: true,
|
|
19986
|
+
requiredInConfig: false,
|
|
19987
|
+
metadata: {
|
|
19988
|
+
family: "minimax",
|
|
19989
|
+
release_date: "2026-04-07",
|
|
19990
|
+
attachment: true,
|
|
19991
|
+
reasoning: true,
|
|
19992
|
+
temperature: true,
|
|
19993
|
+
tool_call: true,
|
|
19994
|
+
limit: { context: 524288, output: 512e3 },
|
|
19995
|
+
modalities: { input: ["text", "image", "video"], output: ["text"] }
|
|
19996
|
+
}
|
|
19997
|
+
},
|
|
19998
|
+
{
|
|
19999
|
+
id: "minimax/minimax-m2.7",
|
|
20000
|
+
name: "Assistente de reda\xE7\xE3o",
|
|
20001
|
+
approvedByDefault: true,
|
|
20002
|
+
requiredInConfig: false,
|
|
20003
|
+
metadata: {
|
|
20004
|
+
family: "minimax",
|
|
20005
|
+
release_date: "2026-03-18",
|
|
20006
|
+
attachment: false,
|
|
20007
|
+
reasoning: true,
|
|
20008
|
+
temperature: true,
|
|
20009
|
+
tool_call: true,
|
|
20010
|
+
limit: { context: 196608, output: 196608 },
|
|
20011
|
+
modalities: { input: ["text"], output: ["text"] }
|
|
20012
|
+
}
|
|
20013
|
+
},
|
|
20014
|
+
{
|
|
20015
|
+
id: "xiaomi/mimo-v2.5",
|
|
20016
|
+
name: "Assistente de revis\xE3o multim\xE9dia",
|
|
20017
|
+
approvedByDefault: true,
|
|
20018
|
+
requiredInConfig: false,
|
|
20019
|
+
metadata: {
|
|
20020
|
+
family: "mimo",
|
|
20021
|
+
release_date: "2026-04-22",
|
|
20022
|
+
attachment: true,
|
|
20023
|
+
reasoning: true,
|
|
20024
|
+
temperature: true,
|
|
20025
|
+
tool_call: true,
|
|
20026
|
+
interleaved: { field: "reasoning_details" },
|
|
20027
|
+
limit: { context: 32e3, output: 131072 },
|
|
20028
|
+
modalities: { input: ["text", "audio", "image", "video"], output: ["text"] }
|
|
20029
|
+
}
|
|
20030
|
+
},
|
|
20031
|
+
{
|
|
20032
|
+
id: "xiaomi/mimo-v2.5-pro",
|
|
20033
|
+
name: "Assistente de contexto longo",
|
|
20034
|
+
approvedByDefault: true,
|
|
20035
|
+
requiredInConfig: false,
|
|
20036
|
+
metadata: {
|
|
20037
|
+
family: "mimo",
|
|
20038
|
+
release_date: "2026-04-22",
|
|
20039
|
+
attachment: false,
|
|
20040
|
+
reasoning: true,
|
|
20041
|
+
temperature: true,
|
|
20042
|
+
tool_call: true,
|
|
20043
|
+
interleaved: { field: "reasoning_content" },
|
|
20044
|
+
limit: { context: 1048576, output: 131072 },
|
|
20045
|
+
modalities: { input: ["text"], output: ["text"] }
|
|
20046
|
+
}
|
|
20047
|
+
},
|
|
20048
|
+
{
|
|
20049
|
+
id: "z-ai/glm-5.2",
|
|
20050
|
+
name: "Assistente de an\xE1lise",
|
|
20051
|
+
approvedByDefault: false,
|
|
20052
|
+
requiredInConfig: false,
|
|
20053
|
+
metadata: {
|
|
20054
|
+
family: "glm",
|
|
20055
|
+
release_date: "2026-02-12",
|
|
20056
|
+
attachment: false,
|
|
20057
|
+
reasoning: true,
|
|
20058
|
+
temperature: true,
|
|
20059
|
+
tool_call: true,
|
|
20060
|
+
interleaved: { field: "reasoning_content" },
|
|
20061
|
+
limit: { context: 1048576, output: 32768 },
|
|
20062
|
+
modalities: { input: ["text"], output: ["text"] }
|
|
20063
|
+
}
|
|
20064
|
+
}
|
|
20065
|
+
];
|
|
20066
|
+
var APPROVED_MODELS = BUILT_IN_OPENROUTER_MODELS.filter((model) => model.approvedByDefault).map(stripCatalogFlags);
|
|
20067
|
+
function cloneModel(model) {
|
|
20068
|
+
return {
|
|
20069
|
+
id: model.id,
|
|
20070
|
+
name: model.name,
|
|
20071
|
+
...model.provider ? { provider: model.provider } : {},
|
|
20072
|
+
...model.upstreamModel ? { upstreamModel: model.upstreamModel } : {},
|
|
20073
|
+
...model.billingMode ? { billingMode: model.billingMode } : {},
|
|
20074
|
+
...model.metadata ? { metadata: structuredClone(model.metadata) } : {}
|
|
20075
|
+
};
|
|
20076
|
+
}
|
|
20077
|
+
function stripCatalogFlags(model) {
|
|
20078
|
+
const { approvedByDefault: _approvedByDefault, requiredInConfig: _requiredInConfig, ...approved } = model;
|
|
20079
|
+
return cloneModel(approved);
|
|
20080
|
+
}
|
|
20081
|
+
function openRouterReasoningVariants(efforts) {
|
|
20082
|
+
return Object.fromEntries(efforts.map((effort) => [effort, { reasoning: { effort } }]));
|
|
20083
|
+
}
|
|
20084
|
+
|
|
20085
|
+
// packages/shared/src/contracts/debugTrace.ts
|
|
20086
|
+
var DEFAULT_DEBUG_TRACE_LIMITS = {
|
|
20087
|
+
eventEnvelopeBytes: 256 * 1024,
|
|
20088
|
+
artifactChunkBytes: 2 * 1024 * 1024,
|
|
20089
|
+
// Serialized request bodies must remain comfortably below Vercel's 4.5 MB
|
|
20090
|
+
// function request limit after JSON and base64 overhead.
|
|
20091
|
+
uploadBatchBytes: 3 * 1024 * 1024,
|
|
20092
|
+
uploadBatchRecords: 100,
|
|
20093
|
+
fileSnapshotBytes: 1024 * 1024,
|
|
20094
|
+
serverTraceBudgetBytes: 250 * 1024 * 1024,
|
|
20095
|
+
workerTraceQuotaPer24h: 100,
|
|
20096
|
+
workerBytesQuotaPer24h: 1024 * 1024 * 1024,
|
|
20097
|
+
localQueueBytes: 1024 * 1024 * 1024,
|
|
20098
|
+
retryBackoffMinMs: 5e3,
|
|
20099
|
+
retryBackoffMaxMs: 5 * 60 * 1e3,
|
|
20100
|
+
queueMaxAgeDays: 7,
|
|
20101
|
+
rawTempExposureSeconds: 15 * 60
|
|
20102
|
+
};
|
|
20103
|
+
|
|
20104
|
+
// packages/shared/src/contracts/settings.ts
|
|
20105
|
+
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.14";
|
|
20106
|
+
var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
|
|
20107
|
+
var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
|
|
20108
|
+
var FIRECRAWL_KEYLESS_MCP_NAME = "firecrawl";
|
|
20109
|
+
var FIRECRAWL_KEYLESS_PERMISSION = `${FIRECRAWL_KEYLESS_MCP_NAME}_*`;
|
|
20110
|
+
|
|
20111
|
+
// packages/shared/src/workPackBaseline.ts
|
|
20112
|
+
function normalizePackExtensionModel(pathLabel, content, approvedModelIds, slug) {
|
|
20113
|
+
const match = /^---\n([\s\S]+?)\n---/.exec(content);
|
|
20114
|
+
const frontmatter = match?.[1];
|
|
20115
|
+
if (!match || frontmatter === void 0) return content;
|
|
20116
|
+
const modelLines = [...frontmatter.matchAll(/^model:\s*(.*?)\s*$/gm)];
|
|
20117
|
+
if (modelLines.length === 0) return content;
|
|
20118
|
+
if (modelLines.length > 1) {
|
|
20119
|
+
throw new Error(`A extens\xE3o ${pathLabel} do pacote de trabalho ${slug} define model mais do que uma vez`);
|
|
20120
|
+
}
|
|
20121
|
+
const rawModel = modelLines[0][1].replace(/^(['"])(.*)\1$/, "$2");
|
|
20122
|
+
const separator = rawModel.indexOf("/");
|
|
20123
|
+
const provider = separator > 0 ? rawModel.slice(0, separator) : "";
|
|
20124
|
+
const modelId = separator > 0 ? rawModel.slice(separator + 1) : "";
|
|
20125
|
+
if (provider !== "forge" && provider !== "openrouter" || !approvedModelIds.has(modelId)) {
|
|
20126
|
+
throw new Error(
|
|
20127
|
+
`A extens\xE3o ${pathLabel} do pacote de trabalho ${slug} usa um modelo que n\xE3o est\xE1 aprovado no Forge`
|
|
20128
|
+
);
|
|
20129
|
+
}
|
|
20130
|
+
if (provider === "forge") return content;
|
|
20131
|
+
const normalizedFrontmatter = frontmatter.replace(/^model:\s*.*?$/m, `model: forge/${modelId}`);
|
|
20132
|
+
return `${content.slice(0, match.index)}---
|
|
20133
|
+
${normalizedFrontmatter}
|
|
20134
|
+
---${content.slice(match.index + match[0].length)}`;
|
|
20135
|
+
}
|
|
20136
|
+
function canonicalWorkPackState(state) {
|
|
20137
|
+
const compare = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
20138
|
+
return JSON.stringify({
|
|
20139
|
+
schemaVersion: 1,
|
|
20140
|
+
version: state.version,
|
|
20141
|
+
files: [...state.files].sort((a, b2) => compare(a.path, b2.path)),
|
|
20142
|
+
directories: [...state.directories].sort(compare),
|
|
20143
|
+
agents: [...state.agents].sort((a, b2) => compare(a.filename, b2.filename)),
|
|
20144
|
+
commands: [...state.commands].sort((a, b2) => compare(a.filename, b2.filename))
|
|
20145
|
+
});
|
|
20146
|
+
}
|
|
20147
|
+
|
|
19885
20148
|
// packages/cli/src/sync.ts
|
|
19886
20149
|
import { createHash as createHash2 } from "node:crypto";
|
|
19887
|
-
import { chmod, cp, lstat as
|
|
20150
|
+
import { chmod, cp, lstat as lstat3, mkdtemp, mkdir as mkdir2, readdir as readdir2, readFile as readFile3, rm, rename as rename3, writeFile as writeFile3 } from "node:fs/promises";
|
|
19888
20151
|
import os4 from "node:os";
|
|
19889
|
-
import
|
|
20152
|
+
import path4 from "node:path";
|
|
19890
20153
|
|
|
19891
20154
|
// node_modules/tar/dist/esm/index.min.js
|
|
19892
20155
|
import Qr from "events";
|
|
@@ -22857,188 +23120,6 @@ var To = (s3) => {
|
|
|
22857
23120
|
s3.mtimeCache || (s3.mtimeCache = /* @__PURE__ */ new Map()), s3.filter = t ? (e, i) => t(e, i) && !((s3.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0)) : (e, i) => !((s3.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0));
|
|
22858
23121
|
};
|
|
22859
23122
|
|
|
22860
|
-
// packages/shared/src/contracts/models.ts
|
|
22861
|
-
var BUILT_IN_OPENROUTER_MODELS = [
|
|
22862
|
-
{
|
|
22863
|
-
id: "anthropic/claude-sonnet-4-6",
|
|
22864
|
-
name: "Assistente de trabalho profundo",
|
|
22865
|
-
approvedByDefault: true,
|
|
22866
|
-
requiredInConfig: false,
|
|
22867
|
-
upstreamModel: "anthropic/claude-sonnet-4.6",
|
|
22868
|
-
metadata: {
|
|
22869
|
-
family: "anthropic",
|
|
22870
|
-
release_date: "2026-02-17",
|
|
22871
|
-
attachment: true,
|
|
22872
|
-
reasoning: true,
|
|
22873
|
-
temperature: true,
|
|
22874
|
-
tool_call: true,
|
|
22875
|
-
limit: { context: 1e6, output: 128e3 },
|
|
22876
|
-
modalities: { input: ["text", "image", "pdf"], output: ["text"] }
|
|
22877
|
-
}
|
|
22878
|
-
},
|
|
22879
|
-
{
|
|
22880
|
-
id: "anthropic/claude-haiku-4-5",
|
|
22881
|
-
name: "Assistente r\xE1pido",
|
|
22882
|
-
approvedByDefault: true,
|
|
22883
|
-
requiredInConfig: false,
|
|
22884
|
-
upstreamModel: "anthropic/claude-haiku-4.5",
|
|
22885
|
-
metadata: {
|
|
22886
|
-
family: "anthropic",
|
|
22887
|
-
release_date: "2025-10-15",
|
|
22888
|
-
attachment: true,
|
|
22889
|
-
reasoning: true,
|
|
22890
|
-
temperature: true,
|
|
22891
|
-
tool_call: true,
|
|
22892
|
-
limit: { context: 2e5, output: 64e3 },
|
|
22893
|
-
modalities: { input: ["text", "image", "pdf"], output: ["text"] }
|
|
22894
|
-
}
|
|
22895
|
-
},
|
|
22896
|
-
{
|
|
22897
|
-
id: "openai/gpt-5.4-mini",
|
|
22898
|
-
name: "Assistente de ficheiros e ecr\xE3",
|
|
22899
|
-
approvedByDefault: true,
|
|
22900
|
-
requiredInConfig: false,
|
|
22901
|
-
metadata: {
|
|
22902
|
-
family: "gpt-mini",
|
|
22903
|
-
release_date: "2026-03-17",
|
|
22904
|
-
attachment: true,
|
|
22905
|
-
reasoning: true,
|
|
22906
|
-
temperature: false,
|
|
22907
|
-
tool_call: true,
|
|
22908
|
-
limit: { context: 4e5, input: 272e3, output: 128e3 },
|
|
22909
|
-
modalities: { input: ["text", "image", "pdf"], output: ["text"] },
|
|
22910
|
-
variants: openRouterReasoningVariants(["none", "xhigh"])
|
|
22911
|
-
}
|
|
22912
|
-
},
|
|
22913
|
-
{
|
|
22914
|
-
id: "minimax/minimax-m3",
|
|
22915
|
-
name: "Assistente de pesquisa",
|
|
22916
|
-
approvedByDefault: true,
|
|
22917
|
-
requiredInConfig: false,
|
|
22918
|
-
metadata: {
|
|
22919
|
-
family: "minimax",
|
|
22920
|
-
release_date: "2026-04-07",
|
|
22921
|
-
attachment: true,
|
|
22922
|
-
reasoning: true,
|
|
22923
|
-
temperature: true,
|
|
22924
|
-
tool_call: true,
|
|
22925
|
-
limit: { context: 524288, output: 512e3 },
|
|
22926
|
-
modalities: { input: ["text", "image", "video"], output: ["text"] }
|
|
22927
|
-
}
|
|
22928
|
-
},
|
|
22929
|
-
{
|
|
22930
|
-
id: "minimax/minimax-m2.7",
|
|
22931
|
-
name: "Assistente de reda\xE7\xE3o",
|
|
22932
|
-
approvedByDefault: true,
|
|
22933
|
-
requiredInConfig: false,
|
|
22934
|
-
metadata: {
|
|
22935
|
-
family: "minimax",
|
|
22936
|
-
release_date: "2026-03-18",
|
|
22937
|
-
attachment: false,
|
|
22938
|
-
reasoning: true,
|
|
22939
|
-
temperature: true,
|
|
22940
|
-
tool_call: true,
|
|
22941
|
-
limit: { context: 196608, output: 196608 },
|
|
22942
|
-
modalities: { input: ["text"], output: ["text"] }
|
|
22943
|
-
}
|
|
22944
|
-
},
|
|
22945
|
-
{
|
|
22946
|
-
id: "xiaomi/mimo-v2.5",
|
|
22947
|
-
name: "Assistente de revis\xE3o multim\xE9dia",
|
|
22948
|
-
approvedByDefault: true,
|
|
22949
|
-
requiredInConfig: false,
|
|
22950
|
-
metadata: {
|
|
22951
|
-
family: "mimo",
|
|
22952
|
-
release_date: "2026-04-22",
|
|
22953
|
-
attachment: true,
|
|
22954
|
-
reasoning: true,
|
|
22955
|
-
temperature: true,
|
|
22956
|
-
tool_call: true,
|
|
22957
|
-
interleaved: { field: "reasoning_details" },
|
|
22958
|
-
limit: { context: 32e3, output: 131072 },
|
|
22959
|
-
modalities: { input: ["text", "audio", "image", "video"], output: ["text"] }
|
|
22960
|
-
}
|
|
22961
|
-
},
|
|
22962
|
-
{
|
|
22963
|
-
id: "xiaomi/mimo-v2.5-pro",
|
|
22964
|
-
name: "Assistente de contexto longo",
|
|
22965
|
-
approvedByDefault: true,
|
|
22966
|
-
requiredInConfig: false,
|
|
22967
|
-
metadata: {
|
|
22968
|
-
family: "mimo",
|
|
22969
|
-
release_date: "2026-04-22",
|
|
22970
|
-
attachment: false,
|
|
22971
|
-
reasoning: true,
|
|
22972
|
-
temperature: true,
|
|
22973
|
-
tool_call: true,
|
|
22974
|
-
interleaved: { field: "reasoning_content" },
|
|
22975
|
-
limit: { context: 1048576, output: 131072 },
|
|
22976
|
-
modalities: { input: ["text"], output: ["text"] }
|
|
22977
|
-
}
|
|
22978
|
-
},
|
|
22979
|
-
{
|
|
22980
|
-
id: "z-ai/glm-5.2",
|
|
22981
|
-
name: "Assistente de an\xE1lise",
|
|
22982
|
-
approvedByDefault: false,
|
|
22983
|
-
requiredInConfig: false,
|
|
22984
|
-
metadata: {
|
|
22985
|
-
family: "glm",
|
|
22986
|
-
release_date: "2026-02-12",
|
|
22987
|
-
attachment: false,
|
|
22988
|
-
reasoning: true,
|
|
22989
|
-
temperature: true,
|
|
22990
|
-
tool_call: true,
|
|
22991
|
-
interleaved: { field: "reasoning_content" },
|
|
22992
|
-
limit: { context: 1048576, output: 32768 },
|
|
22993
|
-
modalities: { input: ["text"], output: ["text"] }
|
|
22994
|
-
}
|
|
22995
|
-
}
|
|
22996
|
-
];
|
|
22997
|
-
var APPROVED_MODELS = BUILT_IN_OPENROUTER_MODELS.filter((model) => model.approvedByDefault).map(stripCatalogFlags);
|
|
22998
|
-
function cloneModel(model) {
|
|
22999
|
-
return {
|
|
23000
|
-
id: model.id,
|
|
23001
|
-
name: model.name,
|
|
23002
|
-
...model.provider ? { provider: model.provider } : {},
|
|
23003
|
-
...model.upstreamModel ? { upstreamModel: model.upstreamModel } : {},
|
|
23004
|
-
...model.billingMode ? { billingMode: model.billingMode } : {},
|
|
23005
|
-
...model.metadata ? { metadata: structuredClone(model.metadata) } : {}
|
|
23006
|
-
};
|
|
23007
|
-
}
|
|
23008
|
-
function stripCatalogFlags(model) {
|
|
23009
|
-
const { approvedByDefault: _approvedByDefault, requiredInConfig: _requiredInConfig, ...approved } = model;
|
|
23010
|
-
return cloneModel(approved);
|
|
23011
|
-
}
|
|
23012
|
-
function openRouterReasoningVariants(efforts) {
|
|
23013
|
-
return Object.fromEntries(efforts.map((effort) => [effort, { reasoning: { effort } }]));
|
|
23014
|
-
}
|
|
23015
|
-
|
|
23016
|
-
// packages/shared/src/contracts/debugTrace.ts
|
|
23017
|
-
var DEFAULT_DEBUG_TRACE_LIMITS = {
|
|
23018
|
-
eventEnvelopeBytes: 256 * 1024,
|
|
23019
|
-
artifactChunkBytes: 2 * 1024 * 1024,
|
|
23020
|
-
// Serialized request bodies must remain comfortably below Vercel's 4.5 MB
|
|
23021
|
-
// function request limit after JSON and base64 overhead.
|
|
23022
|
-
uploadBatchBytes: 3 * 1024 * 1024,
|
|
23023
|
-
uploadBatchRecords: 100,
|
|
23024
|
-
fileSnapshotBytes: 1024 * 1024,
|
|
23025
|
-
serverTraceBudgetBytes: 250 * 1024 * 1024,
|
|
23026
|
-
workerTraceQuotaPer24h: 100,
|
|
23027
|
-
workerBytesQuotaPer24h: 1024 * 1024 * 1024,
|
|
23028
|
-
localQueueBytes: 1024 * 1024 * 1024,
|
|
23029
|
-
retryBackoffMinMs: 5e3,
|
|
23030
|
-
retryBackoffMaxMs: 5 * 60 * 1e3,
|
|
23031
|
-
queueMaxAgeDays: 7,
|
|
23032
|
-
rawTempExposureSeconds: 15 * 60
|
|
23033
|
-
};
|
|
23034
|
-
|
|
23035
|
-
// packages/shared/src/contracts/settings.ts
|
|
23036
|
-
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.12";
|
|
23037
|
-
var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
|
|
23038
|
-
var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
|
|
23039
|
-
var FIRECRAWL_KEYLESS_MCP_NAME = "firecrawl";
|
|
23040
|
-
var FIRECRAWL_KEYLESS_PERMISSION = `${FIRECRAWL_KEYLESS_MCP_NAME}_*`;
|
|
23041
|
-
|
|
23042
23123
|
// packages/cli/src/workPackReconciler.ts
|
|
23043
23124
|
async function reconcileWorkPacks(input) {
|
|
23044
23125
|
assertUniqueSlugs(input.desired, "desired");
|
|
@@ -23225,8 +23306,8 @@ function assertUniqueSlugs(packs, label) {
|
|
|
23225
23306
|
|
|
23226
23307
|
// packages/cli/src/workPackLocalState.ts
|
|
23227
23308
|
import { createHash } from "node:crypto";
|
|
23228
|
-
import { lstat, mkdir, readFile, readdir, rename, writeFile } from "node:fs/promises";
|
|
23229
|
-
import
|
|
23309
|
+
import { lstat as lstat2, mkdir, readFile as readFile2, readdir, rename as rename2, writeFile as writeFile2 } from "node:fs/promises";
|
|
23310
|
+
import path3 from "node:path";
|
|
23230
23311
|
var WORK_PACK_LOCAL_STATE_FILENAME = ".forge-installed-state.json";
|
|
23231
23312
|
async function writeWorkPackInstalledState(input) {
|
|
23232
23313
|
const tree = await digestPackTree(input.packDir);
|
|
@@ -23238,7 +23319,7 @@ async function writeWorkPackInstalledState(input) {
|
|
|
23238
23319
|
agents: digestProjectionContents(input.agents),
|
|
23239
23320
|
commands: digestProjectionContents(input.commands)
|
|
23240
23321
|
};
|
|
23241
|
-
await writeJsonAtomic(
|
|
23322
|
+
await writeJsonAtomic(path3.join(input.packDir, WORK_PACK_LOCAL_STATE_FILENAME), state);
|
|
23242
23323
|
}
|
|
23243
23324
|
async function checkWorkPackInstalledState(input) {
|
|
23244
23325
|
const state = await readInstalledState(input.packDir);
|
|
@@ -23254,11 +23335,39 @@ async function checkWorkPackTreeState(packDir) {
|
|
|
23254
23335
|
async function adoptWorkPackInstalledState(input) {
|
|
23255
23336
|
const state = await readInstalledState(input.expectedPackDir);
|
|
23256
23337
|
if (!state || !await matchesInstalledState(input, state)) return false;
|
|
23257
|
-
await writeJsonAtomic(
|
|
23338
|
+
await writeJsonAtomic(path3.join(input.packDir, WORK_PACK_LOCAL_STATE_FILENAME), state);
|
|
23258
23339
|
return checkWorkPackInstalledState(input).then((result) => result === "match");
|
|
23259
23340
|
}
|
|
23341
|
+
async function adoptVerifiedWorkPackState(input) {
|
|
23342
|
+
const tree = await digestPackTree(input.packDir);
|
|
23343
|
+
if (!tree) return false;
|
|
23344
|
+
const projections = async (kind, directory) => {
|
|
23345
|
+
const prefix = `${kind}/`;
|
|
23346
|
+
const expected = tree.files.filter((file2) => file2.path.startsWith(prefix) && !file2.path.slice(prefix.length).includes("/") && file2.path.endsWith(".md") && !file2.path.slice(prefix.length).startsWith("._"));
|
|
23347
|
+
const result = [];
|
|
23348
|
+
for (const file2 of expected) {
|
|
23349
|
+
const filename = file2.path.slice(prefix.length);
|
|
23350
|
+
const absolute = path3.join(directory, filename);
|
|
23351
|
+
const info = await lstat2(absolute);
|
|
23352
|
+
if (!info.isFile() || info.isSymbolicLink()) throw new Error("Unsafe projection");
|
|
23353
|
+
result.push({ filename, sha256: digest(await readFile2(absolute)) });
|
|
23354
|
+
}
|
|
23355
|
+
return result.sort((a, b2) => a.filename.localeCompare(b2.filename));
|
|
23356
|
+
};
|
|
23357
|
+
const state = {
|
|
23358
|
+
schemaVersion: 1,
|
|
23359
|
+
version: input.version,
|
|
23360
|
+
...tree,
|
|
23361
|
+
agents: await projections("agents", input.agentsDir),
|
|
23362
|
+
commands: await projections("commands", input.commandsDir)
|
|
23363
|
+
};
|
|
23364
|
+
if (digest(Buffer.from(canonicalWorkPackState(state))) !== input.fingerprint) return false;
|
|
23365
|
+
if (!await matchesInstalledState(input, state)) return false;
|
|
23366
|
+
await writeJsonAtomic(path3.join(input.packDir, WORK_PACK_LOCAL_STATE_FILENAME), state);
|
|
23367
|
+
return await checkWorkPackInstalledState(input) === "match";
|
|
23368
|
+
}
|
|
23260
23369
|
async function readInstalledState(packDir) {
|
|
23261
|
-
const raw = await
|
|
23370
|
+
const raw = await readFile2(path3.join(packDir, WORK_PACK_LOCAL_STATE_FILENAME), "utf8").catch(() => void 0);
|
|
23262
23371
|
if (!raw) return void 0;
|
|
23263
23372
|
try {
|
|
23264
23373
|
const value = JSON.parse(raw);
|
|
@@ -23280,14 +23389,14 @@ async function digestPackTree(root) {
|
|
|
23280
23389
|
for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
|
|
23281
23390
|
if (!prefix && entry.name === WORK_PACK_LOCAL_STATE_FILENAME) continue;
|
|
23282
23391
|
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
23283
|
-
const absolute =
|
|
23392
|
+
const absolute = path3.join(directory, entry.name);
|
|
23284
23393
|
if (entry.isDirectory()) {
|
|
23285
23394
|
directories.push(relative);
|
|
23286
23395
|
if (!await visit(absolute, relative)) return false;
|
|
23287
23396
|
continue;
|
|
23288
23397
|
}
|
|
23289
23398
|
if (!entry.isFile()) return false;
|
|
23290
|
-
files.push({ path: relative, sha256: digest(await
|
|
23399
|
+
files.push({ path: relative, sha256: digest(await readFile2(absolute)) });
|
|
23291
23400
|
}
|
|
23292
23401
|
return true;
|
|
23293
23402
|
};
|
|
@@ -23298,10 +23407,10 @@ function digestProjectionContents(files) {
|
|
|
23298
23407
|
}
|
|
23299
23408
|
async function projectionsMatch(directory, expected) {
|
|
23300
23409
|
for (const projection of expected) {
|
|
23301
|
-
const absolute =
|
|
23302
|
-
const info = await
|
|
23410
|
+
const absolute = path3.join(directory, projection.filename);
|
|
23411
|
+
const info = await lstat2(absolute).catch(() => void 0);
|
|
23303
23412
|
if (!info?.isFile() || info.isSymbolicLink()) return false;
|
|
23304
|
-
const bytes = await
|
|
23413
|
+
const bytes = await readFile2(absolute).catch(() => void 0);
|
|
23305
23414
|
if (!bytes || digest(bytes) !== projection.sha256) return false;
|
|
23306
23415
|
}
|
|
23307
23416
|
return true;
|
|
@@ -23319,7 +23428,7 @@ async function matchesInstalledState(input, state) {
|
|
|
23319
23428
|
return projectionsMatch(input.commandsDir, state.commands);
|
|
23320
23429
|
}
|
|
23321
23430
|
function validRelativePath(value, filenameOnly) {
|
|
23322
|
-
if (!value ||
|
|
23431
|
+
if (!value || path3.isAbsolute(value) || value.includes("\\")) return false;
|
|
23323
23432
|
const parts = value.split("/");
|
|
23324
23433
|
if (parts.some((part) => !part || part === "." || part === "..")) return false;
|
|
23325
23434
|
return !filenameOnly || parts.length === 1;
|
|
@@ -23334,11 +23443,11 @@ function digest(bytes) {
|
|
|
23334
23443
|
return createHash("sha256").update(bytes).digest("hex");
|
|
23335
23444
|
}
|
|
23336
23445
|
async function writeJsonAtomic(filePath, value) {
|
|
23337
|
-
await mkdir(
|
|
23338
|
-
const tempPath =
|
|
23339
|
-
await
|
|
23446
|
+
await mkdir(path3.dirname(filePath), { recursive: true });
|
|
23447
|
+
const tempPath = path3.join(path3.dirname(filePath), `.${path3.basename(filePath)}.${process.pid}.tmp`);
|
|
23448
|
+
await writeFile2(tempPath, `${JSON.stringify(value, null, 2)}
|
|
23340
23449
|
`);
|
|
23341
|
-
await
|
|
23450
|
+
await rename2(tempPath, filePath);
|
|
23342
23451
|
}
|
|
23343
23452
|
|
|
23344
23453
|
// packages/cli/src/sync.ts
|
|
@@ -23389,9 +23498,9 @@ async function applyWorkPackManifest(paths, credentials, manifest, options) {
|
|
|
23389
23498
|
const recovery = await recoverInterruptedWorkPackInstalls(paths, options.cleanupWorkPackBackup, options.workPackProjectionBoundary);
|
|
23390
23499
|
const managed = await Promise.all((await managedWorkPackSlugs(paths.skillsDir)).map(async (slug) => ({
|
|
23391
23500
|
slug,
|
|
23392
|
-
version: (await
|
|
23393
|
-
agents: await readAgentRecord(
|
|
23394
|
-
commands: await readCommandRecord(
|
|
23501
|
+
version: (await readFile3(path4.join(paths.skillsDir, slug, ".forge-version"), "utf8")).trim(),
|
|
23502
|
+
agents: await readAgentRecord(path4.join(paths.skillsDir, slug)),
|
|
23503
|
+
commands: await readCommandRecord(path4.join(paths.skillsDir, slug))
|
|
23395
23504
|
})));
|
|
23396
23505
|
const desired = manifest.skills.map((skill) => ({
|
|
23397
23506
|
slug: skill.slug,
|
|
@@ -23415,7 +23524,7 @@ async function applyWorkPackManifest(paths, credentials, manifest, options) {
|
|
|
23415
23524
|
options
|
|
23416
23525
|
),
|
|
23417
23526
|
recoveryFailures: recovery.failures,
|
|
23418
|
-
writeAtomicReceipt: (receipt) => writeJsonAtomic2(
|
|
23527
|
+
writeAtomicReceipt: (receipt) => writeJsonAtomic2(path4.join(paths.forgeDir, "work-pack-sync-receipt.json"), receipt)
|
|
23419
23528
|
});
|
|
23420
23529
|
const installed = workPacks.outcomes.filter((outcome) => outcome.status === "installed").map((outcome) => `${outcome.slug}@${outcome.version}`);
|
|
23421
23530
|
const removed = workPacks.outcomes.filter((outcome) => outcome.status === "removed").map((outcome) => outcome.slug);
|
|
@@ -23426,7 +23535,7 @@ async function applyWorkPackManifest(paths, credentials, manifest, options) {
|
|
|
23426
23535
|
async function collectWorkPackObservations(paths, reconciliation) {
|
|
23427
23536
|
const installedVersions = /* @__PURE__ */ new Map();
|
|
23428
23537
|
for (const slug of await managedWorkPackSlugs(paths.skillsDir)) {
|
|
23429
|
-
const version2 = (await
|
|
23538
|
+
const version2 = (await readFile3(path4.join(paths.skillsDir, slug, ".forge-version"), "utf8")).trim();
|
|
23430
23539
|
if (version2) installedVersions.set(slug, version2);
|
|
23431
23540
|
}
|
|
23432
23541
|
const observations = new Map(
|
|
@@ -23445,7 +23554,7 @@ async function collectWorkPackObservations(paths, reconciliation) {
|
|
|
23445
23554
|
return [...observations.values()].sort((a, b2) => a.slug.localeCompare(b2.slug));
|
|
23446
23555
|
}
|
|
23447
23556
|
async function operateWorkPack(paths, credentials, skillBySlug, approvedModelIds, cleanupPendingSlugs, recoveryFailures, operation, options) {
|
|
23448
|
-
const target =
|
|
23557
|
+
const target = path4.join(paths.skillsDir, operation.pack.slug);
|
|
23449
23558
|
const recoveryFailure = recoveryFailures.get(operation.pack.slug);
|
|
23450
23559
|
if (recoveryFailure) return { status: "failed", restoration: "exact", code: recoveryFailure };
|
|
23451
23560
|
let ownership;
|
|
@@ -23484,7 +23593,7 @@ async function operateWorkPack(paths, credentials, skillBySlug, approvedModelIds
|
|
|
23484
23593
|
let previousManagedPaths;
|
|
23485
23594
|
let archive;
|
|
23486
23595
|
try {
|
|
23487
|
-
const currentVersion = await
|
|
23596
|
+
const currentVersion = await readFile3(path4.join(target, ".forge-version"), "utf8").catch(() => "");
|
|
23488
23597
|
const sameVersion = currentVersion.trim() === skill.version;
|
|
23489
23598
|
if (sameVersion) {
|
|
23490
23599
|
let localState = await checkWorkPackInstalledState({
|
|
@@ -23512,11 +23621,27 @@ async function operateWorkPack(paths, credentials, skillBySlug, approvedModelIds
|
|
|
23512
23621
|
}
|
|
23513
23622
|
}
|
|
23514
23623
|
if (ownership === "managed" && !sameVersion) {
|
|
23515
|
-
|
|
23624
|
+
let localState = await checkWorkPackInstalledState({
|
|
23516
23625
|
packDir: target,
|
|
23517
23626
|
agentsDir: paths.agentsDir,
|
|
23518
23627
|
commandsDir: paths.commandsDir
|
|
23519
23628
|
});
|
|
23629
|
+
if (localState === "missing") {
|
|
23630
|
+
try {
|
|
23631
|
+
const baselineUrl = `/sync/skills/${encodeURIComponent(skill.slug)}/baseline/${encodeURIComponent(currentVersion.trim())}`;
|
|
23632
|
+
const baseline = JSON.parse(new TextDecoder().decode(await downloadSkill(credentials, baselineUrl)));
|
|
23633
|
+
if (typeof baseline.fingerprint === "string" && /^[a-f0-9]{64}$/.test(baseline.fingerprint)) {
|
|
23634
|
+
localState = await adoptVerifiedWorkPackState({
|
|
23635
|
+
packDir: target,
|
|
23636
|
+
agentsDir: paths.agentsDir,
|
|
23637
|
+
commandsDir: paths.commandsDir,
|
|
23638
|
+
version: currentVersion.trim(),
|
|
23639
|
+
fingerprint: baseline.fingerprint
|
|
23640
|
+
}) ? "match" : "missing";
|
|
23641
|
+
}
|
|
23642
|
+
} catch {
|
|
23643
|
+
}
|
|
23644
|
+
}
|
|
23520
23645
|
if (localState !== "match") {
|
|
23521
23646
|
return {
|
|
23522
23647
|
status: "failed",
|
|
@@ -23641,7 +23766,7 @@ var WorkPackLocalEditsError = class extends Error {
|
|
|
23641
23766
|
async function assertWorkPackUnchangedAtBoundary(paths, target) {
|
|
23642
23767
|
const ownership = await workPackOwnership(target);
|
|
23643
23768
|
if (ownership === "absent") return;
|
|
23644
|
-
if (ownership === "foreign") throw foreignWorkPackError(
|
|
23769
|
+
if (ownership === "foreign") throw foreignWorkPackError(path4.basename(target));
|
|
23645
23770
|
const localState = await checkWorkPackInstalledState({
|
|
23646
23771
|
packDir: target,
|
|
23647
23772
|
agentsDir: paths.agentsDir,
|
|
@@ -23665,21 +23790,21 @@ function skillSlugFromUrl(value) {
|
|
|
23665
23790
|
}
|
|
23666
23791
|
}
|
|
23667
23792
|
async function installSkillArchive(paths, slug, version2, archive, options = {}) {
|
|
23668
|
-
const tempRoot = await mkdtemp(
|
|
23669
|
-
const archivePath =
|
|
23670
|
-
const extractPath =
|
|
23671
|
-
const nextPath =
|
|
23672
|
-
const target =
|
|
23673
|
-
const backup =
|
|
23793
|
+
const tempRoot = await mkdtemp(path4.join(os4.tmpdir(), `forge-${slug}-`));
|
|
23794
|
+
const archivePath = path4.join(tempRoot, `${slug}.tar`);
|
|
23795
|
+
const extractPath = path4.join(tempRoot, "extract");
|
|
23796
|
+
const nextPath = path4.join(tempRoot, slug);
|
|
23797
|
+
const target = path4.join(paths.skillsDir, slug);
|
|
23798
|
+
const backup = path4.join(paths.skillsDir, `${slug}.previous`);
|
|
23674
23799
|
let agentFiles;
|
|
23675
23800
|
let commandFiles;
|
|
23676
23801
|
let previousAgents;
|
|
23677
23802
|
let previousCommands;
|
|
23678
23803
|
try {
|
|
23679
23804
|
await mkdir2(extractPath, { recursive: true });
|
|
23680
|
-
await
|
|
23805
|
+
await writeFile3(archivePath, archive);
|
|
23681
23806
|
await So({ file: archivePath, cwd: extractPath, strict: true });
|
|
23682
|
-
const extractedSkillPath =
|
|
23807
|
+
const extractedSkillPath = path4.join(extractPath, slug);
|
|
23683
23808
|
await assertNoReservedMarkerAliases(extractedSkillPath);
|
|
23684
23809
|
await validateSkillFolder(extractedSkillPath, slug);
|
|
23685
23810
|
agentFiles = await normalizePackAgentModels(
|
|
@@ -23706,15 +23831,15 @@ async function installSkillArchive(paths, slug, version2, archive, options = {})
|
|
|
23706
23831
|
}
|
|
23707
23832
|
throw error45;
|
|
23708
23833
|
}
|
|
23709
|
-
await
|
|
23710
|
-
await
|
|
23834
|
+
await rename3(path4.join(extractPath, slug), nextPath);
|
|
23835
|
+
await writeFile3(path4.join(nextPath, ".forge-version"), `${version2}
|
|
23711
23836
|
`);
|
|
23712
23837
|
if (agentFiles.length > 0) {
|
|
23713
|
-
await
|
|
23838
|
+
await writeFile3(path4.join(nextPath, ".forge-agents"), `${agentFiles.map((agent) => agent.filename).join("\n")}
|
|
23714
23839
|
`);
|
|
23715
23840
|
}
|
|
23716
23841
|
if (commandFiles.length > 0) {
|
|
23717
|
-
await
|
|
23842
|
+
await writeFile3(path4.join(nextPath, ".forge-commands"), `${commandFiles.map((command) => command.filename).join("\n")}
|
|
23718
23843
|
`);
|
|
23719
23844
|
}
|
|
23720
23845
|
await writeWorkPackInstalledState({ packDir: nextPath, version: version2, agents: agentFiles, commands: commandFiles });
|
|
@@ -23725,13 +23850,13 @@ async function installSkillArchive(paths, slug, version2, archive, options = {})
|
|
|
23725
23850
|
const agentTransactionState = new Map(
|
|
23726
23851
|
[...agentSnapshot.keys()].map((filePath) => [
|
|
23727
23852
|
filePath,
|
|
23728
|
-
agentFiles.find((agent) => agent.filename ===
|
|
23853
|
+
agentFiles.find((agent) => agent.filename === path4.basename(filePath))?.content
|
|
23729
23854
|
])
|
|
23730
23855
|
);
|
|
23731
23856
|
const commandTransactionState = new Map(
|
|
23732
23857
|
[...commandSnapshot.keys()].map((filePath) => [
|
|
23733
23858
|
filePath,
|
|
23734
|
-
commandFiles.find((command) => command.filename ===
|
|
23859
|
+
commandFiles.find((command) => command.filename === path4.basename(filePath))?.content
|
|
23735
23860
|
])
|
|
23736
23861
|
);
|
|
23737
23862
|
const previousManagedPaths = await managedWorkPackPaths(paths, target);
|
|
@@ -23743,7 +23868,7 @@ async function installSkillArchive(paths, slug, version2, archive, options = {})
|
|
|
23743
23868
|
throw error45;
|
|
23744
23869
|
}
|
|
23745
23870
|
const writeProjection = options.writeWorkPackProjection ?? writeTextAtomic;
|
|
23746
|
-
const claimedBackup =
|
|
23871
|
+
const claimedBackup = path4.join(tempRoot, `${slug}-claimed-previous`);
|
|
23747
23872
|
const transactionPath = `${backup}${WORK_PACK_TRANSACTION_SUFFIX}`;
|
|
23748
23873
|
let targetBackedUp = false;
|
|
23749
23874
|
let targetInstalled = false;
|
|
@@ -23753,7 +23878,7 @@ async function installSkillArchive(paths, slug, version2, archive, options = {})
|
|
|
23753
23878
|
await rm(transactionPath, { force: true });
|
|
23754
23879
|
await writeTextAtomic(transactionPath, "install\n");
|
|
23755
23880
|
try {
|
|
23756
|
-
await
|
|
23881
|
+
await rename3(target, backup);
|
|
23757
23882
|
targetBackedUp = true;
|
|
23758
23883
|
} catch (error45) {
|
|
23759
23884
|
if (error45.code !== "ENOENT") throw error45;
|
|
@@ -23763,10 +23888,10 @@ async function installSkillArchive(paths, slug, version2, archive, options = {})
|
|
|
23763
23888
|
await options.installWorkPackBoundary?.("after-backup");
|
|
23764
23889
|
await assertWorkPackUnchangedAtBoundary(paths, backup);
|
|
23765
23890
|
}
|
|
23766
|
-
await
|
|
23891
|
+
await rename3(nextPath, target);
|
|
23767
23892
|
targetInstalled = true;
|
|
23768
23893
|
for (const filename of previousAgents.filter((name) => !nextAgentNames.has(name))) {
|
|
23769
|
-
const filePath =
|
|
23894
|
+
const filePath = path4.join(paths.agentsDir, filename);
|
|
23770
23895
|
await options.workPackProjectionBoundary?.("install", filePath);
|
|
23771
23896
|
await assertProjectionState(filePath, agentSnapshot.get(filePath));
|
|
23772
23897
|
await rm(filePath, { force: true });
|
|
@@ -23774,14 +23899,14 @@ async function installSkillArchive(paths, slug, version2, archive, options = {})
|
|
|
23774
23899
|
if (agentFiles.length > 0) {
|
|
23775
23900
|
await mkdir2(paths.agentsDir, { recursive: true });
|
|
23776
23901
|
for (const agent of agentFiles) {
|
|
23777
|
-
const filePath =
|
|
23902
|
+
const filePath = path4.join(paths.agentsDir, agent.filename);
|
|
23778
23903
|
await options.workPackProjectionBoundary?.("install", filePath);
|
|
23779
23904
|
await assertProjectionState(filePath, agentSnapshot.get(filePath));
|
|
23780
23905
|
await writeProjection(filePath, agent.content);
|
|
23781
23906
|
}
|
|
23782
23907
|
}
|
|
23783
23908
|
for (const filename of previousCommands.filter((name) => !nextCommandNames.has(name))) {
|
|
23784
|
-
const filePath =
|
|
23909
|
+
const filePath = path4.join(paths.commandsDir, filename);
|
|
23785
23910
|
await options.workPackProjectionBoundary?.("install", filePath);
|
|
23786
23911
|
await assertProjectionState(filePath, commandSnapshot.get(filePath));
|
|
23787
23912
|
await rm(filePath, { force: true });
|
|
@@ -23789,7 +23914,7 @@ async function installSkillArchive(paths, slug, version2, archive, options = {})
|
|
|
23789
23914
|
if (commandFiles.length > 0) {
|
|
23790
23915
|
await mkdir2(paths.commandsDir, { recursive: true });
|
|
23791
23916
|
for (const command of commandFiles) {
|
|
23792
|
-
const filePath =
|
|
23917
|
+
const filePath = path4.join(paths.commandsDir, command.filename);
|
|
23793
23918
|
await options.workPackProjectionBoundary?.("install", filePath);
|
|
23794
23919
|
await assertProjectionState(filePath, commandSnapshot.get(filePath));
|
|
23795
23920
|
await writeProjection(filePath, command.content);
|
|
@@ -23798,10 +23923,10 @@ async function installSkillArchive(paths, slug, version2, archive, options = {})
|
|
|
23798
23923
|
if (targetBackedUp) await assertWorkPackTreeUnchangedAtBoundary(backup);
|
|
23799
23924
|
if (targetBackedUp) await options.installWorkPackBoundary?.("before-commit");
|
|
23800
23925
|
if (targetBackedUp) {
|
|
23801
|
-
await
|
|
23926
|
+
await rename3(backup, claimedBackup);
|
|
23802
23927
|
backupClaimed = true;
|
|
23803
23928
|
await assertWorkPackTreeUnchangedAtBoundary(claimedBackup);
|
|
23804
|
-
await
|
|
23929
|
+
await writeFile3(path4.join(claimedBackup, WORK_PACK_COMMITTED_MARKER), `${version2}
|
|
23805
23930
|
`);
|
|
23806
23931
|
await writeTextAtomic(transactionPath, "committed\n");
|
|
23807
23932
|
}
|
|
@@ -23812,11 +23937,11 @@ async function installSkillArchive(paths, slug, version2, archive, options = {})
|
|
|
23812
23937
|
await restoreProjectionState(commandSnapshot, commandTransactionState);
|
|
23813
23938
|
}
|
|
23814
23939
|
if (targetBackedUp) {
|
|
23815
|
-
const restoredTarget =
|
|
23940
|
+
const restoredTarget = path4.join(tempRoot, `${slug}-restore`);
|
|
23816
23941
|
const rollbackSource = backupClaimed ? claimedBackup : backup;
|
|
23817
23942
|
await cp(rollbackSource, restoredTarget, { recursive: true });
|
|
23818
23943
|
if (targetInstalled) await rm(target, { recursive: true, force: true });
|
|
23819
|
-
await
|
|
23944
|
+
await rename3(restoredTarget, target);
|
|
23820
23945
|
await rm(rollbackSource, { recursive: true, force: true });
|
|
23821
23946
|
await rm(transactionPath, { force: true });
|
|
23822
23947
|
} else if (targetInstalled) {
|
|
@@ -23842,26 +23967,26 @@ async function installSkillArchive(paths, slug, version2, archive, options = {})
|
|
|
23842
23967
|
await rm(transactionPath, { force: true });
|
|
23843
23968
|
} else {
|
|
23844
23969
|
cleanup = "pending";
|
|
23845
|
-
if (backupClaimed) await
|
|
23970
|
+
if (backupClaimed) await rename3(claimedBackup, backup);
|
|
23846
23971
|
}
|
|
23847
23972
|
}
|
|
23848
23973
|
await rm(tempRoot, { recursive: true, force: true }).catch(() => void 0);
|
|
23849
23974
|
return { cleanup };
|
|
23850
23975
|
}
|
|
23851
23976
|
async function adoptLegacyWorkPackState(paths, slug, version2, archive, approvedModelIds) {
|
|
23852
|
-
const comparisonRoot = await mkdtemp(
|
|
23977
|
+
const comparisonRoot = await mkdtemp(path4.join(os4.tmpdir(), `forge-${slug}-baseline-`));
|
|
23853
23978
|
const comparisonPaths = {
|
|
23854
23979
|
...paths,
|
|
23855
|
-
skillsDir:
|
|
23856
|
-
agentsDir:
|
|
23857
|
-
commandsDir:
|
|
23980
|
+
skillsDir: path4.join(comparisonRoot, "skills"),
|
|
23981
|
+
agentsDir: path4.join(comparisonRoot, "agents"),
|
|
23982
|
+
commandsDir: path4.join(comparisonRoot, "commands")
|
|
23858
23983
|
};
|
|
23859
23984
|
try {
|
|
23860
23985
|
await mkdir2(comparisonPaths.skillsDir, { recursive: true });
|
|
23861
23986
|
await installSkillArchive(comparisonPaths, slug, version2, archive, { approvedModelIds });
|
|
23862
23987
|
return adoptWorkPackInstalledState({
|
|
23863
|
-
expectedPackDir:
|
|
23864
|
-
packDir:
|
|
23988
|
+
expectedPackDir: path4.join(comparisonPaths.skillsDir, slug),
|
|
23989
|
+
packDir: path4.join(paths.skillsDir, slug),
|
|
23865
23990
|
agentsDir: paths.agentsDir,
|
|
23866
23991
|
commandsDir: paths.commandsDir
|
|
23867
23992
|
});
|
|
@@ -23880,7 +24005,7 @@ async function recoverInterruptedWorkPackInstalls(paths, cleanupWorkPackBackup,
|
|
|
23880
24005
|
if (!entry.name.endsWith(".previous")) continue;
|
|
23881
24006
|
const slug = entry.name.slice(0, -".previous".length);
|
|
23882
24007
|
if (!slug) continue;
|
|
23883
|
-
const target =
|
|
24008
|
+
const target = path4.join(paths.skillsDir, slug);
|
|
23884
24009
|
const backup = `${target}.previous`;
|
|
23885
24010
|
const transactionState = await readWorkPackTransactionState(backup);
|
|
23886
24011
|
if (transactionState === "committed") {
|
|
@@ -23913,9 +24038,9 @@ async function recoverInterruptedWorkPackInstall(paths, target, cleanupWorkPackB
|
|
|
23913
24038
|
const backup = `${target}.previous`;
|
|
23914
24039
|
const backupOwnership = await workPackOwnership(backup);
|
|
23915
24040
|
if (backupOwnership === "absent") return "recovered";
|
|
23916
|
-
if (backupOwnership === "foreign") throw foreignWorkPackError(
|
|
23917
|
-
if (await workPackOwnership(target) === "foreign") throw foreignWorkPackError(
|
|
23918
|
-
const committed = await
|
|
24041
|
+
if (backupOwnership === "foreign") throw foreignWorkPackError(path4.basename(target));
|
|
24042
|
+
if (await workPackOwnership(target) === "foreign") throw foreignWorkPackError(path4.basename(target));
|
|
24043
|
+
const committed = await readFile3(path4.join(backup, WORK_PACK_COMMITTED_MARKER), "utf8").catch((error45) => {
|
|
23919
24044
|
if (error45.code === "ENOENT") return void 0;
|
|
23920
24045
|
throw error45;
|
|
23921
24046
|
});
|
|
@@ -23957,38 +24082,38 @@ async function recoverInterruptedWorkPackInstall(paths, target, cleanupWorkPackB
|
|
|
23957
24082
|
);
|
|
23958
24083
|
const previousAgentNames = new Set(previousAgents.map((agent) => agent.filename));
|
|
23959
24084
|
const previousCommandNames = new Set(previousCommands.map((command) => command.filename));
|
|
23960
|
-
const recoveryRoot = await mkdtemp(
|
|
23961
|
-
const recoveredTarget =
|
|
24085
|
+
const recoveryRoot = await mkdtemp(path4.join(os4.tmpdir(), "forge-recover-"));
|
|
24086
|
+
const recoveredTarget = path4.join(recoveryRoot, path4.basename(target));
|
|
23962
24087
|
await cp(backup, recoveredTarget, { recursive: true });
|
|
23963
24088
|
try {
|
|
23964
24089
|
for (const filename of currentAgents.filter((name) => !previousAgentNames.has(name))) {
|
|
23965
|
-
const filePath =
|
|
24090
|
+
const filePath = path4.join(paths.agentsDir, filename);
|
|
23966
24091
|
await workPackProjectionBoundary?.("recover", filePath);
|
|
23967
24092
|
await assertProjectionState(filePath, agentRecoveryState.get(filePath));
|
|
23968
24093
|
await rm(filePath, { force: true });
|
|
23969
24094
|
}
|
|
23970
24095
|
await mkdir2(paths.agentsDir, { recursive: true });
|
|
23971
24096
|
for (const agent of previousAgents) {
|
|
23972
|
-
const filePath =
|
|
24097
|
+
const filePath = path4.join(paths.agentsDir, agent.filename);
|
|
23973
24098
|
await workPackProjectionBoundary?.("recover", filePath);
|
|
23974
24099
|
await assertProjectionState(filePath, agentRecoveryState.get(filePath));
|
|
23975
24100
|
await writeTextAtomic(filePath, agent.content);
|
|
23976
24101
|
}
|
|
23977
24102
|
for (const filename of currentCommands.filter((name) => !previousCommandNames.has(name))) {
|
|
23978
|
-
const filePath =
|
|
24103
|
+
const filePath = path4.join(paths.commandsDir, filename);
|
|
23979
24104
|
await workPackProjectionBoundary?.("recover", filePath);
|
|
23980
24105
|
await assertProjectionState(filePath, commandRecoveryState.get(filePath));
|
|
23981
24106
|
await rm(filePath, { force: true });
|
|
23982
24107
|
}
|
|
23983
24108
|
await mkdir2(paths.commandsDir, { recursive: true });
|
|
23984
24109
|
for (const command of previousCommands) {
|
|
23985
|
-
const filePath =
|
|
24110
|
+
const filePath = path4.join(paths.commandsDir, command.filename);
|
|
23986
24111
|
await workPackProjectionBoundary?.("recover", filePath);
|
|
23987
24112
|
await assertProjectionState(filePath, commandRecoveryState.get(filePath));
|
|
23988
24113
|
await writeTextAtomic(filePath, command.content);
|
|
23989
24114
|
}
|
|
23990
24115
|
await rm(target, { recursive: true, force: true });
|
|
23991
|
-
await
|
|
24116
|
+
await rename3(recoveredTarget, target);
|
|
23992
24117
|
await rm(backup, { recursive: true, force: true });
|
|
23993
24118
|
await rm(`${backup}${WORK_PACK_TRANSACTION_SUFFIX}`, { force: true });
|
|
23994
24119
|
} finally {
|
|
@@ -24000,7 +24125,7 @@ async function removeWorkPackBackup(backupPath) {
|
|
|
24000
24125
|
await rm(backupPath, { recursive: true, force: true });
|
|
24001
24126
|
}
|
|
24002
24127
|
async function readWorkPackTransactionFile(backup) {
|
|
24003
|
-
return
|
|
24128
|
+
return readFile3(`${backup}${WORK_PACK_TRANSACTION_SUFFIX}`, "utf8").catch((error45) => {
|
|
24004
24129
|
if (error45.code === "ENOENT") return void 0;
|
|
24005
24130
|
throw error45;
|
|
24006
24131
|
});
|
|
@@ -24014,7 +24139,7 @@ function isManagedProjectionName(filename) {
|
|
|
24014
24139
|
return filename.length > 0 && !filename.includes("/") && !filename.includes("\\") && filename !== "..";
|
|
24015
24140
|
}
|
|
24016
24141
|
async function recordRemovedProjection(transactionPath, kind, filename) {
|
|
24017
|
-
const current = await
|
|
24142
|
+
const current = await readFile3(transactionPath, "utf8");
|
|
24018
24143
|
await writeTextAtomic(transactionPath, `${current.trimEnd()}
|
|
24019
24144
|
${kind}:${filename}
|
|
24020
24145
|
`);
|
|
@@ -24039,19 +24164,19 @@ async function readWorkPackRemovedProjections(backup) {
|
|
|
24039
24164
|
return { agents, commands };
|
|
24040
24165
|
}
|
|
24041
24166
|
async function pathExists(filePath) {
|
|
24042
|
-
return
|
|
24167
|
+
return lstat3(filePath).then(() => true, (error45) => {
|
|
24043
24168
|
if (error45.code === "ENOENT") return false;
|
|
24044
24169
|
throw error45;
|
|
24045
24170
|
});
|
|
24046
24171
|
}
|
|
24047
24172
|
async function workPackOwnership(target) {
|
|
24048
|
-
const targetStat = await
|
|
24173
|
+
const targetStat = await lstat3(target).catch((error45) => {
|
|
24049
24174
|
if (error45.code === "ENOENT") return void 0;
|
|
24050
24175
|
throw error45;
|
|
24051
24176
|
});
|
|
24052
24177
|
if (!targetStat) return "absent";
|
|
24053
24178
|
if (!targetStat.isDirectory()) return "foreign";
|
|
24054
|
-
const marker = await
|
|
24179
|
+
const marker = await readFile3(path4.join(target, ".forge-version"), "utf8").catch((error45) => {
|
|
24055
24180
|
if (error45.code === "ENOENT") return void 0;
|
|
24056
24181
|
throw error45;
|
|
24057
24182
|
});
|
|
@@ -24077,11 +24202,11 @@ async function assertProjectionRecoveryIsSafe(directory, currentFiles, previousF
|
|
|
24077
24202
|
expected.set(file2.filename, contents);
|
|
24078
24203
|
}
|
|
24079
24204
|
for (const [filename, contents] of expected) {
|
|
24080
|
-
const projected = await
|
|
24205
|
+
const projected = await readFile3(path4.join(directory, filename), "utf8").catch((error45) => {
|
|
24081
24206
|
if (error45.code === "ENOENT") return void 0;
|
|
24082
24207
|
throw error45;
|
|
24083
24208
|
});
|
|
24084
|
-
validated.set(
|
|
24209
|
+
validated.set(path4.join(directory, filename), projected);
|
|
24085
24210
|
const missingPreviousProjection = missingPreviousProjectionIsLocalDeletion(
|
|
24086
24211
|
filename,
|
|
24087
24212
|
projected,
|
|
@@ -24099,19 +24224,19 @@ async function assertProjectionRecoveryIsSafe(directory, currentFiles, previousF
|
|
|
24099
24224
|
return validated;
|
|
24100
24225
|
}
|
|
24101
24226
|
async function assertProjectionState(filePath, expected) {
|
|
24102
|
-
const current = await
|
|
24227
|
+
const current = await readFile3(filePath, "utf8").catch((error45) => {
|
|
24103
24228
|
if (error45.code === "ENOENT") return void 0;
|
|
24104
24229
|
throw error45;
|
|
24105
24230
|
});
|
|
24106
24231
|
if (current !== expected) {
|
|
24107
|
-
throw new WorkPackLocalEditsError("local-edits-preserved", `A proje\xE7\xE3o ${
|
|
24232
|
+
throw new WorkPackLocalEditsError("local-edits-preserved", `A proje\xE7\xE3o ${path4.basename(filePath)} foi alterada durante a opera\xE7\xE3o`);
|
|
24108
24233
|
}
|
|
24109
24234
|
}
|
|
24110
24235
|
async function captureProjectionState(directory, filenames) {
|
|
24111
24236
|
const snapshot = /* @__PURE__ */ new Map();
|
|
24112
24237
|
for (const filename of filenames) {
|
|
24113
|
-
const filePath =
|
|
24114
|
-
const content = await
|
|
24238
|
+
const filePath = path4.join(directory, filename);
|
|
24239
|
+
const content = await readFile3(filePath, "utf8").catch((error45) => {
|
|
24115
24240
|
if (error45.code === "ENOENT") return void 0;
|
|
24116
24241
|
throw error45;
|
|
24117
24242
|
});
|
|
@@ -24122,7 +24247,7 @@ async function captureProjectionState(directory, filenames) {
|
|
|
24122
24247
|
async function restoreProjectionState(snapshot, transactionState) {
|
|
24123
24248
|
for (const [filePath, content] of snapshot) {
|
|
24124
24249
|
if (transactionState) {
|
|
24125
|
-
const current = await
|
|
24250
|
+
const current = await readFile3(filePath, "utf8").catch((error45) => {
|
|
24126
24251
|
if (error45.code === "ENOENT") return void 0;
|
|
24127
24252
|
throw error45;
|
|
24128
24253
|
});
|
|
@@ -24133,7 +24258,7 @@ async function restoreProjectionState(snapshot, transactionState) {
|
|
|
24133
24258
|
}
|
|
24134
24259
|
}
|
|
24135
24260
|
async function readPackAgentFiles(skillFolder) {
|
|
24136
|
-
const agentsFolder =
|
|
24261
|
+
const agentsFolder = path4.join(skillFolder, "agents");
|
|
24137
24262
|
const entries = await readdir2(agentsFolder, { withFileTypes: true }).catch((error45) => {
|
|
24138
24263
|
if (error45.code === "ENOENT") return [];
|
|
24139
24264
|
throw error45;
|
|
@@ -24142,7 +24267,7 @@ async function readPackAgentFiles(skillFolder) {
|
|
|
24142
24267
|
for (const entry of entries) {
|
|
24143
24268
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
24144
24269
|
if (entry.name.startsWith("._")) continue;
|
|
24145
|
-
const content = await
|
|
24270
|
+
const content = await readFile3(path4.join(agentsFolder, entry.name), "utf8");
|
|
24146
24271
|
validateAgentFile(entry.name, content);
|
|
24147
24272
|
files.push({ filename: entry.name, content });
|
|
24148
24273
|
}
|
|
@@ -24153,7 +24278,7 @@ async function normalizePackAgentModels(skillFolder, agentFiles, approvedModelId
|
|
|
24153
24278
|
for (const agent of agentFiles) {
|
|
24154
24279
|
const content = normalizePackAgentModel(agent.filename, agent.content, approvedModelIds, slug);
|
|
24155
24280
|
if (content !== agent.content) {
|
|
24156
|
-
await
|
|
24281
|
+
await writeFile3(path4.join(skillFolder, "agents", agent.filename), content);
|
|
24157
24282
|
}
|
|
24158
24283
|
normalized.push({ ...agent, content });
|
|
24159
24284
|
}
|
|
@@ -24172,32 +24297,8 @@ async function workPackNeedsModelNormalization(target, approvedModelIds, slug) {
|
|
|
24172
24297
|
function normalizePackAgentModel(filename, content, approvedModelIds, slug) {
|
|
24173
24298
|
return normalizePackExtensionModel(`agents/${filename}`, content, approvedModelIds, slug);
|
|
24174
24299
|
}
|
|
24175
|
-
function normalizePackExtensionModel(pathLabel, content, approvedModelIds, slug) {
|
|
24176
|
-
const match = /^---\n([\s\S]+?)\n---/.exec(content);
|
|
24177
|
-
const frontmatter = match?.[1];
|
|
24178
|
-
if (!match || frontmatter === void 0) return content;
|
|
24179
|
-
const modelLines = [...frontmatter.matchAll(/^model:\s*(.*?)\s*$/gm)];
|
|
24180
|
-
if (modelLines.length === 0) return content;
|
|
24181
|
-
if (modelLines.length > 1) {
|
|
24182
|
-
throw new Error(`A extens\xE3o ${pathLabel} do pacote de trabalho ${slug} define model mais do que uma vez`);
|
|
24183
|
-
}
|
|
24184
|
-
const rawModel = modelLines[0][1].replace(/^(['"])(.*)\1$/, "$2");
|
|
24185
|
-
const separator = rawModel.indexOf("/");
|
|
24186
|
-
const provider = separator > 0 ? rawModel.slice(0, separator) : "";
|
|
24187
|
-
const modelId = separator > 0 ? rawModel.slice(separator + 1) : "";
|
|
24188
|
-
if (provider !== "forge" && provider !== "openrouter" || !approvedModelIds.has(modelId)) {
|
|
24189
|
-
throw new Error(
|
|
24190
|
-
`A extens\xE3o ${pathLabel} do pacote de trabalho ${slug} usa um modelo que n\xE3o est\xE1 aprovado no Forge`
|
|
24191
|
-
);
|
|
24192
|
-
}
|
|
24193
|
-
if (provider === "forge") return content;
|
|
24194
|
-
const normalizedFrontmatter = frontmatter.replace(/^model:\s*.*?$/m, `model: forge/${modelId}`);
|
|
24195
|
-
return `${content.slice(0, match.index)}---
|
|
24196
|
-
${normalizedFrontmatter}
|
|
24197
|
-
---${content.slice(match.index + match[0].length)}`;
|
|
24198
|
-
}
|
|
24199
24300
|
async function readPackCommandFiles(skillFolder) {
|
|
24200
|
-
const commandsFolder =
|
|
24301
|
+
const commandsFolder = path4.join(skillFolder, "commands");
|
|
24201
24302
|
const entries = await readdir2(commandsFolder, { withFileTypes: true }).catch((error45) => {
|
|
24202
24303
|
if (error45.code === "ENOENT") return [];
|
|
24203
24304
|
throw error45;
|
|
@@ -24206,7 +24307,7 @@ async function readPackCommandFiles(skillFolder) {
|
|
|
24206
24307
|
for (const entry of entries) {
|
|
24207
24308
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
24208
24309
|
if (entry.name.startsWith("._")) continue;
|
|
24209
|
-
const content = await
|
|
24310
|
+
const content = await readFile3(path4.join(commandsFolder, entry.name), "utf8");
|
|
24210
24311
|
validateCommandFile(entry.name, content);
|
|
24211
24312
|
files.push({ filename: entry.name, content });
|
|
24212
24313
|
}
|
|
@@ -24217,7 +24318,7 @@ async function normalizePackCommandModels(skillFolder, commandFiles, approvedMod
|
|
|
24217
24318
|
for (const command of commandFiles) {
|
|
24218
24319
|
const content = normalizePackExtensionModel(`commands/${command.filename}`, command.content, approvedModelIds, slug);
|
|
24219
24320
|
if (content !== command.content) {
|
|
24220
|
-
await
|
|
24321
|
+
await writeFile3(path4.join(skillFolder, "commands", command.filename), content);
|
|
24221
24322
|
}
|
|
24222
24323
|
normalized.push({ ...command, content });
|
|
24223
24324
|
}
|
|
@@ -24239,7 +24340,7 @@ async function assertNoForeignAgentConflicts(agentsDir, agentFiles, ownedFilenam
|
|
|
24239
24340
|
const owned = new Set(ownedFilenames);
|
|
24240
24341
|
for (const agent of agentFiles) {
|
|
24241
24342
|
if (owned.has(agent.filename)) continue;
|
|
24242
|
-
const existing = await
|
|
24343
|
+
const existing = await readFile3(path4.join(agentsDir, agent.filename), "utf8").catch((error45) => {
|
|
24243
24344
|
if (error45.code === "ENOENT") return void 0;
|
|
24244
24345
|
throw error45;
|
|
24245
24346
|
});
|
|
@@ -24252,7 +24353,7 @@ async function assertNoForeignCommandConflicts(commandsDir, commandFiles, ownedF
|
|
|
24252
24353
|
const owned = new Set(ownedFilenames);
|
|
24253
24354
|
for (const command of commandFiles) {
|
|
24254
24355
|
if (owned.has(command.filename)) continue;
|
|
24255
|
-
const existing = await
|
|
24356
|
+
const existing = await readFile3(path4.join(commandsDir, command.filename), "utf8").catch((error45) => {
|
|
24256
24357
|
if (error45.code === "ENOENT") return void 0;
|
|
24257
24358
|
throw error45;
|
|
24258
24359
|
});
|
|
@@ -24262,17 +24363,17 @@ async function assertNoForeignCommandConflicts(commandsDir, commandFiles, ownedF
|
|
|
24262
24363
|
}
|
|
24263
24364
|
}
|
|
24264
24365
|
async function readAgentRecord(skillFolder) {
|
|
24265
|
-
const raw = await
|
|
24366
|
+
const raw = await readFile3(path4.join(skillFolder, ".forge-agents"), "utf8").catch(() => "");
|
|
24266
24367
|
return raw.split("\n").map((line) => line.trim()).filter((line) => line.length > 0 && !line.includes("/") && !line.includes("\\") && line !== "..");
|
|
24267
24368
|
}
|
|
24268
24369
|
async function readCommandRecord(skillFolder) {
|
|
24269
|
-
const raw = await
|
|
24370
|
+
const raw = await readFile3(path4.join(skillFolder, ".forge-commands"), "utf8").catch(() => "");
|
|
24270
24371
|
return raw.split("\n").map((line) => line.trim()).filter((line) => line.length > 0 && !line.includes("/") && !line.includes("\\") && line !== "..");
|
|
24271
24372
|
}
|
|
24272
24373
|
async function managedWorkPackPaths(paths, skillFolder) {
|
|
24273
24374
|
const files = await listFilesRecursively(skillFolder);
|
|
24274
|
-
const agents = (await readAgentRecord(skillFolder)).map((filename) =>
|
|
24275
|
-
const commands = (await readCommandRecord(skillFolder)).map((filename) =>
|
|
24375
|
+
const agents = (await readAgentRecord(skillFolder)).map((filename) => path4.join(paths.agentsDir, filename));
|
|
24376
|
+
const commands = (await readCommandRecord(skillFolder)).map((filename) => path4.join(paths.commandsDir, filename));
|
|
24276
24377
|
return [.../* @__PURE__ */ new Set([...files, ...agents, ...commands])];
|
|
24277
24378
|
}
|
|
24278
24379
|
async function managedWorkPackSlugs(skillsDir) {
|
|
@@ -24283,7 +24384,7 @@ async function managedWorkPackSlugs(skillsDir) {
|
|
|
24283
24384
|
const slugs = [];
|
|
24284
24385
|
for (const entry of entries) {
|
|
24285
24386
|
if (!entry.isDirectory() || entry.name.endsWith(".previous")) continue;
|
|
24286
|
-
if (await workPackOwnership(
|
|
24387
|
+
if (await workPackOwnership(path4.join(skillsDir, entry.name)) === "managed") slugs.push(entry.name);
|
|
24287
24388
|
}
|
|
24288
24389
|
return slugs.sort((left, right) => left.localeCompare(right));
|
|
24289
24390
|
}
|
|
@@ -24293,21 +24394,21 @@ async function removeManagedWorkPackTransaction(paths, target, options) {
|
|
|
24293
24394
|
const agents = await readAgentRecord(target);
|
|
24294
24395
|
const commands = await readCommandRecord(target);
|
|
24295
24396
|
const snapshots = await Promise.all([
|
|
24296
|
-
...agents.map((filename) => captureExactFile(
|
|
24297
|
-
...commands.map((filename) => captureExactFile(
|
|
24397
|
+
...agents.map((filename) => captureExactFile(path4.join(paths.agentsDir, filename))),
|
|
24398
|
+
...commands.map((filename) => captureExactFile(path4.join(paths.commandsDir, filename)))
|
|
24298
24399
|
]);
|
|
24299
24400
|
await assertWorkPackUnchangedAtBoundary(paths, target);
|
|
24300
24401
|
const backup = `${target}.previous`;
|
|
24301
24402
|
const transactionPath = `${backup}${WORK_PACK_TRANSACTION_SUFFIX}`;
|
|
24302
|
-
const transactionRoot = await mkdtemp(
|
|
24303
|
-
const claimedBackup =
|
|
24403
|
+
const transactionRoot = await mkdtemp(path4.join(os4.tmpdir(), "forge-remove-"));
|
|
24404
|
+
const claimedBackup = path4.join(transactionRoot, path4.basename(target));
|
|
24304
24405
|
let projectionsRemoved = false;
|
|
24305
24406
|
let backupClaimed = false;
|
|
24306
24407
|
try {
|
|
24307
24408
|
await rm(backup, { recursive: true, force: true });
|
|
24308
24409
|
await rm(transactionPath, { force: true });
|
|
24309
24410
|
await writeTextAtomic(transactionPath, "remove\n");
|
|
24310
|
-
await
|
|
24411
|
+
await rename3(target, backup);
|
|
24311
24412
|
} catch (error45) {
|
|
24312
24413
|
await rm(transactionPath, { force: true }).catch(() => void 0);
|
|
24313
24414
|
await rm(transactionRoot, { recursive: true, force: true }).catch(() => void 0);
|
|
@@ -24318,7 +24419,7 @@ async function removeManagedWorkPackTransaction(paths, target, options) {
|
|
|
24318
24419
|
await assertWorkPackUnchangedAtBoundary(paths, backup);
|
|
24319
24420
|
projectionsRemoved = agents.length > 0;
|
|
24320
24421
|
for (const filename of agents) {
|
|
24321
|
-
const filePath =
|
|
24422
|
+
const filePath = path4.join(paths.agentsDir, filename);
|
|
24322
24423
|
await options.workPackProjectionBoundary?.("remove", filePath);
|
|
24323
24424
|
await assertExactFileState(snapshots, filePath);
|
|
24324
24425
|
await recordRemovedProjection(transactionPath, "agent", filename);
|
|
@@ -24327,7 +24428,7 @@ async function removeManagedWorkPackTransaction(paths, target, options) {
|
|
|
24327
24428
|
await options.removeWorkPackBoundary?.("after-agents");
|
|
24328
24429
|
projectionsRemoved ||= commands.length > 0;
|
|
24329
24430
|
for (const filename of commands) {
|
|
24330
|
-
const filePath =
|
|
24431
|
+
const filePath = path4.join(paths.commandsDir, filename);
|
|
24331
24432
|
await options.workPackProjectionBoundary?.("remove", filePath);
|
|
24332
24433
|
await assertExactFileState(snapshots, filePath);
|
|
24333
24434
|
await recordRemovedProjection(transactionPath, "command", filename);
|
|
@@ -24336,7 +24437,7 @@ async function removeManagedWorkPackTransaction(paths, target, options) {
|
|
|
24336
24437
|
await options.removeWorkPackBoundary?.("after-commands");
|
|
24337
24438
|
await assertWorkPackTreeUnchangedAtBoundary(backup);
|
|
24338
24439
|
await options.removeWorkPackBoundary?.("before-commit");
|
|
24339
|
-
await
|
|
24440
|
+
await rename3(backup, claimedBackup);
|
|
24340
24441
|
backupClaimed = true;
|
|
24341
24442
|
await assertWorkPackTreeUnchangedAtBoundary(claimedBackup);
|
|
24342
24443
|
await writeTextAtomic(transactionPath, "committed\n");
|
|
@@ -24347,13 +24448,13 @@ async function removeManagedWorkPackTransaction(paths, target, options) {
|
|
|
24347
24448
|
} catch (error45) {
|
|
24348
24449
|
try {
|
|
24349
24450
|
if (projectionsRemoved) await restoreRemovedExactFiles(snapshots);
|
|
24350
|
-
await
|
|
24451
|
+
await rename3(backupClaimed ? claimedBackup : backup, target);
|
|
24351
24452
|
await rm(transactionPath, { force: true });
|
|
24352
24453
|
if (projectionsRemoved) await verifyRestoredOrLocallyChangedFiles(snapshots);
|
|
24353
24454
|
if (await workPackOwnership(target) !== "managed") throw new Error("restored Work Pack marker missing");
|
|
24354
24455
|
await rm(transactionRoot, { recursive: true, force: true }).catch(() => void 0);
|
|
24355
24456
|
} catch (restoreError) {
|
|
24356
|
-
throw new WorkPackRecoveryUncertainError(`Falha ao remover e restaurar o pacote de trabalho ${
|
|
24457
|
+
throw new WorkPackRecoveryUncertainError(`Falha ao remover e restaurar o pacote de trabalho ${path4.basename(target)}`, {
|
|
24357
24458
|
cause: new AggregateError([error45, restoreError])
|
|
24358
24459
|
});
|
|
24359
24460
|
}
|
|
@@ -24362,9 +24463,9 @@ async function removeManagedWorkPackTransaction(paths, target, options) {
|
|
|
24362
24463
|
}
|
|
24363
24464
|
async function captureExactFile(filePath) {
|
|
24364
24465
|
try {
|
|
24365
|
-
const info = await
|
|
24466
|
+
const info = await lstat3(filePath);
|
|
24366
24467
|
if (!info.isFile()) throw new Error(`A proje\xE7\xE3o gerida n\xE3o \xE9 um ficheiro regular: ${filePath}`);
|
|
24367
|
-
return { path: filePath, exists: true, bytes: await
|
|
24468
|
+
return { path: filePath, exists: true, bytes: await readFile3(filePath), mode: info.mode & 4095 };
|
|
24368
24469
|
} catch (error45) {
|
|
24369
24470
|
if (error45.code === "ENOENT") return { path: filePath, exists: false };
|
|
24370
24471
|
throw error45;
|
|
@@ -24374,18 +24475,18 @@ async function assertExactFileState(snapshots, filePath) {
|
|
|
24374
24475
|
const expected = snapshots.find((snapshot) => snapshot.path === filePath);
|
|
24375
24476
|
const current = await captureExactFile(filePath);
|
|
24376
24477
|
if (!expected || current.exists !== expected.exists) {
|
|
24377
|
-
throw new WorkPackLocalEditsError("local-edits-preserved", `A proje\xE7\xE3o ${
|
|
24478
|
+
throw new WorkPackLocalEditsError("local-edits-preserved", `A proje\xE7\xE3o ${path4.basename(filePath)} foi alterada durante a opera\xE7\xE3o`);
|
|
24378
24479
|
}
|
|
24379
24480
|
if (current.exists && (!current.bytes?.equals(expected.bytes) || current.mode !== expected.mode)) {
|
|
24380
|
-
throw new WorkPackLocalEditsError("local-edits-preserved", `A proje\xE7\xE3o ${
|
|
24481
|
+
throw new WorkPackLocalEditsError("local-edits-preserved", `A proje\xE7\xE3o ${path4.basename(filePath)} foi alterada durante a opera\xE7\xE3o`);
|
|
24381
24482
|
}
|
|
24382
24483
|
}
|
|
24383
24484
|
async function restoreRemovedExactFiles(snapshots) {
|
|
24384
24485
|
for (const snapshot of snapshots) {
|
|
24385
24486
|
if ((await captureExactFile(snapshot.path)).exists) continue;
|
|
24386
24487
|
if (!snapshot.exists) continue;
|
|
24387
|
-
await mkdir2(
|
|
24388
|
-
await
|
|
24488
|
+
await mkdir2(path4.dirname(snapshot.path), { recursive: true });
|
|
24489
|
+
await writeFile3(snapshot.path, snapshot.bytes);
|
|
24389
24490
|
await chmod(snapshot.path, snapshot.mode);
|
|
24390
24491
|
}
|
|
24391
24492
|
}
|
|
@@ -24402,14 +24503,14 @@ async function listFilesRecursively(root) {
|
|
|
24402
24503
|
});
|
|
24403
24504
|
const files = [];
|
|
24404
24505
|
for (const entry of entries) {
|
|
24405
|
-
const absolute =
|
|
24506
|
+
const absolute = path4.join(root, entry.name);
|
|
24406
24507
|
if (entry.isDirectory()) files.push(...await listFilesRecursively(absolute));
|
|
24407
24508
|
else if (entry.isFile()) files.push(absolute);
|
|
24408
24509
|
}
|
|
24409
24510
|
return files;
|
|
24410
24511
|
}
|
|
24411
24512
|
async function validateSkillFolder(folder, slug) {
|
|
24412
|
-
const skillMd = await
|
|
24513
|
+
const skillMd = await readFile3(path4.join(folder, "SKILL.md"), "utf8");
|
|
24413
24514
|
const frontmatter = /^---\n([\s\S]+?)\n---/.exec(skillMd)?.[1] ?? "";
|
|
24414
24515
|
if (!frontmatter.includes(`name: ${slug}`) && !frontmatter.includes(`name: "${slug}"`)) {
|
|
24415
24516
|
throw new Error(`O campo name no frontmatter de SKILL.md tem de corresponder a ${slug}`);
|
|
@@ -24430,15 +24531,15 @@ async function writeJsonAtomic2(filePath, value) {
|
|
|
24430
24531
|
await writeTextAtomic(filePath, content);
|
|
24431
24532
|
}
|
|
24432
24533
|
async function writeTextAtomic(filePath, content) {
|
|
24433
|
-
const dir =
|
|
24534
|
+
const dir = path4.dirname(filePath);
|
|
24434
24535
|
await mkdir2(dir, { recursive: true });
|
|
24435
|
-
const tempPath =
|
|
24436
|
-
await
|
|
24437
|
-
await
|
|
24536
|
+
const tempPath = path4.join(dir, `.${path4.basename(filePath)}.${process.pid}.tmp`);
|
|
24537
|
+
await writeFile3(tempPath, content);
|
|
24538
|
+
await rename3(tempPath, filePath);
|
|
24438
24539
|
}
|
|
24439
24540
|
|
|
24440
24541
|
// packages/cli/src/workPackSyncPlugin.ts
|
|
24441
|
-
var PLUGIN_VERSION = "0.1.
|
|
24542
|
+
var PLUGIN_VERSION = "0.1.14";
|
|
24442
24543
|
var STATUS_FILENAME = "work-pack-startup-status.json";
|
|
24443
24544
|
var activeSync = /* @__PURE__ */ new Map();
|
|
24444
24545
|
var ForgeWorkPackSyncServer = async (_input, options) => {
|
|
@@ -24491,6 +24592,7 @@ async function synchronizeAtStartup(forgeBaseUrl) {
|
|
|
24491
24592
|
const before = await managedProjectionNames(paths);
|
|
24492
24593
|
let credentials;
|
|
24493
24594
|
try {
|
|
24595
|
+
await retireDebugCapture(paths);
|
|
24494
24596
|
credentials = await readWellKnownForgeCredentials(paths.opencodeAuthPath, forgeBaseUrl);
|
|
24495
24597
|
const manifest = await fetchManifest(credentials);
|
|
24496
24598
|
const result = await applyWorkPackManifest(paths, credentials, manifest, {});
|
|
@@ -24534,7 +24636,7 @@ function resolveStartupPaths() {
|
|
|
24534
24636
|
return resolvePaths(void 0, void 0, env);
|
|
24535
24637
|
}
|
|
24536
24638
|
async function readWellKnownForgeCredentials(authPath, forgeBaseUrl) {
|
|
24537
|
-
const raw = await
|
|
24639
|
+
const raw = await readFile4(authPath, "utf8");
|
|
24538
24640
|
const parsed = JSON.parse(raw.startsWith("\uFEFF") ? raw.slice(1) : raw);
|
|
24539
24641
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
24540
24642
|
throw new Error("A autentica\xE7\xE3o do OpenCode n\xE3o \xE9 um objeto JSON v\xE1lido");
|
|
@@ -24571,16 +24673,16 @@ async function managedProjectionNames(paths) {
|
|
|
24571
24673
|
});
|
|
24572
24674
|
for (const entry of entries) {
|
|
24573
24675
|
if (!entry.isDirectory()) continue;
|
|
24574
|
-
const folder =
|
|
24575
|
-
const marker = await
|
|
24676
|
+
const folder = path5.join(paths.skillsDir, entry.name);
|
|
24677
|
+
const marker = await readFile4(path5.join(folder, ".forge-version"), "utf8").catch(() => "");
|
|
24576
24678
|
if (!marker.trim()) continue;
|
|
24577
|
-
for (const name of await readProjectionRecord(
|
|
24578
|
-
for (const name of await readProjectionRecord(
|
|
24679
|
+
for (const name of await readProjectionRecord(path5.join(folder, ".forge-agents"))) agents.add(stripMarkdownExtension(name));
|
|
24680
|
+
for (const name of await readProjectionRecord(path5.join(folder, ".forge-commands"))) commands.add(stripMarkdownExtension(name));
|
|
24579
24681
|
}
|
|
24580
24682
|
return { agents, commands };
|
|
24581
24683
|
}
|
|
24582
24684
|
async function readProjectionRecord(filePath) {
|
|
24583
|
-
const raw = await
|
|
24685
|
+
const raw = await readFile4(filePath, "utf8").catch(() => "");
|
|
24584
24686
|
return raw.split("\n").map((line) => line.trim()).filter(
|
|
24585
24687
|
(line) => line.endsWith(".md") && !line.includes("/") && !line.includes("\\") && line !== ".."
|
|
24586
24688
|
);
|
|
@@ -24591,21 +24693,21 @@ async function projectCurrentExtensions(config2, state) {
|
|
|
24591
24693
|
for (const name of state.before.agents) if (!state.after.agents.has(name)) delete agents[name];
|
|
24592
24694
|
for (const name of state.before.commands) if (!state.after.commands.has(name)) delete commands[name];
|
|
24593
24695
|
for (const name of state.after.agents) {
|
|
24594
|
-
agents[name] = await parseMarkdownConfig(
|
|
24696
|
+
agents[name] = await parseMarkdownConfig(path5.join(state.paths.agentsDir, `${name}.md`), "prompt");
|
|
24595
24697
|
}
|
|
24596
24698
|
for (const name of state.after.commands) {
|
|
24597
|
-
commands[name] = await parseMarkdownConfig(
|
|
24699
|
+
commands[name] = await parseMarkdownConfig(path5.join(state.paths.commandsDir, `${name}.md`), "template");
|
|
24598
24700
|
}
|
|
24599
24701
|
config2.agent = agents;
|
|
24600
24702
|
config2.command = commands;
|
|
24601
24703
|
}
|
|
24602
24704
|
async function parseMarkdownConfig(filePath, bodyField) {
|
|
24603
|
-
const raw = await
|
|
24705
|
+
const raw = await readFile4(filePath, "utf8");
|
|
24604
24706
|
const match = /^---\r?\n([\s\S]+?)\r?\n---\r?\n?([\s\S]*)$/.exec(raw);
|
|
24605
|
-
if (!match) throw new Error(`A extens\xE3o Forge ${
|
|
24707
|
+
if (!match) throw new Error(`A extens\xE3o Forge ${path5.basename(filePath)} n\xE3o tem frontmatter v\xE1lido`);
|
|
24606
24708
|
const data = (0, import_yaml.parse)(match[1]);
|
|
24607
24709
|
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
24608
|
-
throw new Error(`A extens\xE3o Forge ${
|
|
24710
|
+
throw new Error(`A extens\xE3o Forge ${path5.basename(filePath)} n\xE3o tem frontmatter v\xE1lido`);
|
|
24609
24711
|
}
|
|
24610
24712
|
const config2 = { ...data, [bodyField]: match[2].trim() };
|
|
24611
24713
|
if (bodyField === "prompt" && typeof config2.permission === "string" && ["allow", "ask", "deny"].includes(config2.permission)) {
|
|
@@ -24621,11 +24723,11 @@ function stripMarkdownExtension(filename) {
|
|
|
24621
24723
|
}
|
|
24622
24724
|
async function writeStatus(paths, value) {
|
|
24623
24725
|
await mkdir3(paths.forgeDir, { recursive: true });
|
|
24624
|
-
const target =
|
|
24625
|
-
const temporary =
|
|
24626
|
-
await
|
|
24726
|
+
const target = path5.join(paths.forgeDir, STATUS_FILENAME);
|
|
24727
|
+
const temporary = path5.join(paths.forgeDir, `.${STATUS_FILENAME}.${process.pid}.tmp`);
|
|
24728
|
+
await writeFile4(temporary, `${JSON.stringify(value, null, 2)}
|
|
24627
24729
|
`, { mode: 384 });
|
|
24628
|
-
await
|
|
24730
|
+
await rename4(temporary, target);
|
|
24629
24731
|
}
|
|
24630
24732
|
function safeErrorMessage(error45) {
|
|
24631
24733
|
const message = error45 instanceof Error ? error45.message : "erro desconhecido";
|