@defend-tech/opencode-optima 0.1.68 → 0.1.69
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 +261 -258
- package/dist/sanitize_cli.js +284 -281
- package/package.json +1 -1
package/dist/sanitize_cli.js
CHANGED
|
@@ -109,17 +109,17 @@ var require_visit = __commonJS({
|
|
|
109
109
|
visit.BREAK = BREAK;
|
|
110
110
|
visit.SKIP = SKIP;
|
|
111
111
|
visit.REMOVE = REMOVE;
|
|
112
|
-
function visit_(key, node, visitor,
|
|
113
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
112
|
+
function visit_(key, node, visitor, path8) {
|
|
113
|
+
const ctrl = callVisitor(key, node, visitor, path8);
|
|
114
114
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
115
|
-
replaceNode(key,
|
|
116
|
-
return visit_(key, ctrl, visitor,
|
|
115
|
+
replaceNode(key, path8, ctrl);
|
|
116
|
+
return visit_(key, ctrl, visitor, path8);
|
|
117
117
|
}
|
|
118
118
|
if (typeof ctrl !== "symbol") {
|
|
119
119
|
if (identity.isCollection(node)) {
|
|
120
|
-
|
|
120
|
+
path8 = Object.freeze(path8.concat(node));
|
|
121
121
|
for (let i = 0; i < node.items.length; ++i) {
|
|
122
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
122
|
+
const ci = visit_(i, node.items[i], visitor, path8);
|
|
123
123
|
if (typeof ci === "number")
|
|
124
124
|
i = ci - 1;
|
|
125
125
|
else if (ci === BREAK)
|
|
@@ -130,13 +130,13 @@ var require_visit = __commonJS({
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
} else if (identity.isPair(node)) {
|
|
133
|
-
|
|
134
|
-
const ck = visit_("key", node.key, visitor,
|
|
133
|
+
path8 = Object.freeze(path8.concat(node));
|
|
134
|
+
const ck = visit_("key", node.key, visitor, path8);
|
|
135
135
|
if (ck === BREAK)
|
|
136
136
|
return BREAK;
|
|
137
137
|
else if (ck === REMOVE)
|
|
138
138
|
node.key = null;
|
|
139
|
-
const cv = visit_("value", node.value, visitor,
|
|
139
|
+
const cv = visit_("value", node.value, visitor, path8);
|
|
140
140
|
if (cv === BREAK)
|
|
141
141
|
return BREAK;
|
|
142
142
|
else if (cv === REMOVE)
|
|
@@ -157,17 +157,17 @@ var require_visit = __commonJS({
|
|
|
157
157
|
visitAsync.BREAK = BREAK;
|
|
158
158
|
visitAsync.SKIP = SKIP;
|
|
159
159
|
visitAsync.REMOVE = REMOVE;
|
|
160
|
-
async function visitAsync_(key, node, visitor,
|
|
161
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
160
|
+
async function visitAsync_(key, node, visitor, path8) {
|
|
161
|
+
const ctrl = await callVisitor(key, node, visitor, path8);
|
|
162
162
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
163
|
-
replaceNode(key,
|
|
164
|
-
return visitAsync_(key, ctrl, visitor,
|
|
163
|
+
replaceNode(key, path8, ctrl);
|
|
164
|
+
return visitAsync_(key, ctrl, visitor, path8);
|
|
165
165
|
}
|
|
166
166
|
if (typeof ctrl !== "symbol") {
|
|
167
167
|
if (identity.isCollection(node)) {
|
|
168
|
-
|
|
168
|
+
path8 = Object.freeze(path8.concat(node));
|
|
169
169
|
for (let i = 0; i < node.items.length; ++i) {
|
|
170
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
170
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path8);
|
|
171
171
|
if (typeof ci === "number")
|
|
172
172
|
i = ci - 1;
|
|
173
173
|
else if (ci === BREAK)
|
|
@@ -178,13 +178,13 @@ var require_visit = __commonJS({
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
} else if (identity.isPair(node)) {
|
|
181
|
-
|
|
182
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
181
|
+
path8 = Object.freeze(path8.concat(node));
|
|
182
|
+
const ck = await visitAsync_("key", node.key, visitor, path8);
|
|
183
183
|
if (ck === BREAK)
|
|
184
184
|
return BREAK;
|
|
185
185
|
else if (ck === REMOVE)
|
|
186
186
|
node.key = null;
|
|
187
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
187
|
+
const cv = await visitAsync_("value", node.value, visitor, path8);
|
|
188
188
|
if (cv === BREAK)
|
|
189
189
|
return BREAK;
|
|
190
190
|
else if (cv === REMOVE)
|
|
@@ -211,23 +211,23 @@ var require_visit = __commonJS({
|
|
|
211
211
|
}
|
|
212
212
|
return visitor;
|
|
213
213
|
}
|
|
214
|
-
function callVisitor(key, node, visitor,
|
|
214
|
+
function callVisitor(key, node, visitor, path8) {
|
|
215
215
|
if (typeof visitor === "function")
|
|
216
|
-
return visitor(key, node,
|
|
216
|
+
return visitor(key, node, path8);
|
|
217
217
|
if (identity.isMap(node))
|
|
218
|
-
return visitor.Map?.(key, node,
|
|
218
|
+
return visitor.Map?.(key, node, path8);
|
|
219
219
|
if (identity.isSeq(node))
|
|
220
|
-
return visitor.Seq?.(key, node,
|
|
220
|
+
return visitor.Seq?.(key, node, path8);
|
|
221
221
|
if (identity.isPair(node))
|
|
222
|
-
return visitor.Pair?.(key, node,
|
|
222
|
+
return visitor.Pair?.(key, node, path8);
|
|
223
223
|
if (identity.isScalar(node))
|
|
224
|
-
return visitor.Scalar?.(key, node,
|
|
224
|
+
return visitor.Scalar?.(key, node, path8);
|
|
225
225
|
if (identity.isAlias(node))
|
|
226
|
-
return visitor.Alias?.(key, node,
|
|
226
|
+
return visitor.Alias?.(key, node, path8);
|
|
227
227
|
return void 0;
|
|
228
228
|
}
|
|
229
|
-
function replaceNode(key,
|
|
230
|
-
const parent =
|
|
229
|
+
function replaceNode(key, path8, node) {
|
|
230
|
+
const parent = path8[path8.length - 1];
|
|
231
231
|
if (identity.isCollection(parent)) {
|
|
232
232
|
parent.items[key] = node;
|
|
233
233
|
} else if (identity.isPair(parent)) {
|
|
@@ -835,10 +835,10 @@ var require_Collection = __commonJS({
|
|
|
835
835
|
var createNode = require_createNode();
|
|
836
836
|
var identity = require_identity();
|
|
837
837
|
var Node = require_Node();
|
|
838
|
-
function collectionFromPath(schema,
|
|
838
|
+
function collectionFromPath(schema, path8, value) {
|
|
839
839
|
let v = value;
|
|
840
|
-
for (let i =
|
|
841
|
-
const k =
|
|
840
|
+
for (let i = path8.length - 1; i >= 0; --i) {
|
|
841
|
+
const k = path8[i];
|
|
842
842
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
843
843
|
const a = [];
|
|
844
844
|
a[k] = v;
|
|
@@ -857,7 +857,7 @@ var require_Collection = __commonJS({
|
|
|
857
857
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
858
858
|
});
|
|
859
859
|
}
|
|
860
|
-
var isEmptyPath = (
|
|
860
|
+
var isEmptyPath = (path8) => path8 == null || typeof path8 === "object" && !!path8[Symbol.iterator]().next().done;
|
|
861
861
|
var Collection = class extends Node.NodeBase {
|
|
862
862
|
constructor(type, schema) {
|
|
863
863
|
super(type);
|
|
@@ -887,11 +887,11 @@ var require_Collection = __commonJS({
|
|
|
887
887
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
888
888
|
* that already exists in the map.
|
|
889
889
|
*/
|
|
890
|
-
addIn(
|
|
891
|
-
if (isEmptyPath(
|
|
890
|
+
addIn(path8, value) {
|
|
891
|
+
if (isEmptyPath(path8))
|
|
892
892
|
this.add(value);
|
|
893
893
|
else {
|
|
894
|
-
const [key, ...rest] =
|
|
894
|
+
const [key, ...rest] = path8;
|
|
895
895
|
const node = this.get(key, true);
|
|
896
896
|
if (identity.isCollection(node))
|
|
897
897
|
node.addIn(rest, value);
|
|
@@ -905,8 +905,8 @@ var require_Collection = __commonJS({
|
|
|
905
905
|
* Removes a value from the collection.
|
|
906
906
|
* @returns `true` if the item was found and removed.
|
|
907
907
|
*/
|
|
908
|
-
deleteIn(
|
|
909
|
-
const [key, ...rest] =
|
|
908
|
+
deleteIn(path8) {
|
|
909
|
+
const [key, ...rest] = path8;
|
|
910
910
|
if (rest.length === 0)
|
|
911
911
|
return this.delete(key);
|
|
912
912
|
const node = this.get(key, true);
|
|
@@ -920,8 +920,8 @@ var require_Collection = __commonJS({
|
|
|
920
920
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
921
921
|
* `true` (collections are always returned intact).
|
|
922
922
|
*/
|
|
923
|
-
getIn(
|
|
924
|
-
const [key, ...rest] =
|
|
923
|
+
getIn(path8, keepScalar) {
|
|
924
|
+
const [key, ...rest] = path8;
|
|
925
925
|
const node = this.get(key, true);
|
|
926
926
|
if (rest.length === 0)
|
|
927
927
|
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
|
@@ -939,8 +939,8 @@ var require_Collection = __commonJS({
|
|
|
939
939
|
/**
|
|
940
940
|
* Checks if the collection includes a value with the key `key`.
|
|
941
941
|
*/
|
|
942
|
-
hasIn(
|
|
943
|
-
const [key, ...rest] =
|
|
942
|
+
hasIn(path8) {
|
|
943
|
+
const [key, ...rest] = path8;
|
|
944
944
|
if (rest.length === 0)
|
|
945
945
|
return this.has(key);
|
|
946
946
|
const node = this.get(key, true);
|
|
@@ -950,8 +950,8 @@ var require_Collection = __commonJS({
|
|
|
950
950
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
951
951
|
* boolean to add/remove the item from the set.
|
|
952
952
|
*/
|
|
953
|
-
setIn(
|
|
954
|
-
const [key, ...rest] =
|
|
953
|
+
setIn(path8, value) {
|
|
954
|
+
const [key, ...rest] = path8;
|
|
955
955
|
if (rest.length === 0) {
|
|
956
956
|
this.set(key, value);
|
|
957
957
|
} else {
|
|
@@ -3455,9 +3455,9 @@ var require_Document = __commonJS({
|
|
|
3455
3455
|
this.contents.add(value);
|
|
3456
3456
|
}
|
|
3457
3457
|
/** Adds a value to the document. */
|
|
3458
|
-
addIn(
|
|
3458
|
+
addIn(path8, value) {
|
|
3459
3459
|
if (assertCollection(this.contents))
|
|
3460
|
-
this.contents.addIn(
|
|
3460
|
+
this.contents.addIn(path8, value);
|
|
3461
3461
|
}
|
|
3462
3462
|
/**
|
|
3463
3463
|
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
|
|
@@ -3532,14 +3532,14 @@ var require_Document = __commonJS({
|
|
|
3532
3532
|
* Removes a value from the document.
|
|
3533
3533
|
* @returns `true` if the item was found and removed.
|
|
3534
3534
|
*/
|
|
3535
|
-
deleteIn(
|
|
3536
|
-
if (Collection.isEmptyPath(
|
|
3535
|
+
deleteIn(path8) {
|
|
3536
|
+
if (Collection.isEmptyPath(path8)) {
|
|
3537
3537
|
if (this.contents == null)
|
|
3538
3538
|
return false;
|
|
3539
3539
|
this.contents = null;
|
|
3540
3540
|
return true;
|
|
3541
3541
|
}
|
|
3542
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
3542
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path8) : false;
|
|
3543
3543
|
}
|
|
3544
3544
|
/**
|
|
3545
3545
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
@@ -3554,10 +3554,10 @@ var require_Document = __commonJS({
|
|
|
3554
3554
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
3555
3555
|
* `true` (collections are always returned intact).
|
|
3556
3556
|
*/
|
|
3557
|
-
getIn(
|
|
3558
|
-
if (Collection.isEmptyPath(
|
|
3557
|
+
getIn(path8, keepScalar) {
|
|
3558
|
+
if (Collection.isEmptyPath(path8))
|
|
3559
3559
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
3560
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
3560
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path8, keepScalar) : void 0;
|
|
3561
3561
|
}
|
|
3562
3562
|
/**
|
|
3563
3563
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -3568,10 +3568,10 @@ var require_Document = __commonJS({
|
|
|
3568
3568
|
/**
|
|
3569
3569
|
* Checks if the document includes a value at `path`.
|
|
3570
3570
|
*/
|
|
3571
|
-
hasIn(
|
|
3572
|
-
if (Collection.isEmptyPath(
|
|
3571
|
+
hasIn(path8) {
|
|
3572
|
+
if (Collection.isEmptyPath(path8))
|
|
3573
3573
|
return this.contents !== void 0;
|
|
3574
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
3574
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path8) : false;
|
|
3575
3575
|
}
|
|
3576
3576
|
/**
|
|
3577
3577
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -3588,13 +3588,13 @@ var require_Document = __commonJS({
|
|
|
3588
3588
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
3589
3589
|
* boolean to add/remove the item from the set.
|
|
3590
3590
|
*/
|
|
3591
|
-
setIn(
|
|
3592
|
-
if (Collection.isEmptyPath(
|
|
3591
|
+
setIn(path8, value) {
|
|
3592
|
+
if (Collection.isEmptyPath(path8)) {
|
|
3593
3593
|
this.contents = value;
|
|
3594
3594
|
} else if (this.contents == null) {
|
|
3595
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
3595
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path8), value);
|
|
3596
3596
|
} else if (assertCollection(this.contents)) {
|
|
3597
|
-
this.contents.setIn(
|
|
3597
|
+
this.contents.setIn(path8, value);
|
|
3598
3598
|
}
|
|
3599
3599
|
}
|
|
3600
3600
|
/**
|
|
@@ -5546,9 +5546,9 @@ var require_cst_visit = __commonJS({
|
|
|
5546
5546
|
visit.BREAK = BREAK;
|
|
5547
5547
|
visit.SKIP = SKIP;
|
|
5548
5548
|
visit.REMOVE = REMOVE;
|
|
5549
|
-
visit.itemAtPath = (cst,
|
|
5549
|
+
visit.itemAtPath = (cst, path8) => {
|
|
5550
5550
|
let item = cst;
|
|
5551
|
-
for (const [field, index] of
|
|
5551
|
+
for (const [field, index] of path8) {
|
|
5552
5552
|
const tok = item?.[field];
|
|
5553
5553
|
if (tok && "items" in tok) {
|
|
5554
5554
|
item = tok.items[index];
|
|
@@ -5557,23 +5557,23 @@ var require_cst_visit = __commonJS({
|
|
|
5557
5557
|
}
|
|
5558
5558
|
return item;
|
|
5559
5559
|
};
|
|
5560
|
-
visit.parentCollection = (cst,
|
|
5561
|
-
const parent = visit.itemAtPath(cst,
|
|
5562
|
-
const field =
|
|
5560
|
+
visit.parentCollection = (cst, path8) => {
|
|
5561
|
+
const parent = visit.itemAtPath(cst, path8.slice(0, -1));
|
|
5562
|
+
const field = path8[path8.length - 1][0];
|
|
5563
5563
|
const coll = parent?.[field];
|
|
5564
5564
|
if (coll && "items" in coll)
|
|
5565
5565
|
return coll;
|
|
5566
5566
|
throw new Error("Parent collection not found");
|
|
5567
5567
|
};
|
|
5568
|
-
function _visit(
|
|
5569
|
-
let ctrl = visitor(item,
|
|
5568
|
+
function _visit(path8, item, visitor) {
|
|
5569
|
+
let ctrl = visitor(item, path8);
|
|
5570
5570
|
if (typeof ctrl === "symbol")
|
|
5571
5571
|
return ctrl;
|
|
5572
5572
|
for (const field of ["key", "value"]) {
|
|
5573
5573
|
const token = item[field];
|
|
5574
5574
|
if (token && "items" in token) {
|
|
5575
5575
|
for (let i = 0; i < token.items.length; ++i) {
|
|
5576
|
-
const ci = _visit(Object.freeze(
|
|
5576
|
+
const ci = _visit(Object.freeze(path8.concat([[field, i]])), token.items[i], visitor);
|
|
5577
5577
|
if (typeof ci === "number")
|
|
5578
5578
|
i = ci - 1;
|
|
5579
5579
|
else if (ci === BREAK)
|
|
@@ -5584,10 +5584,10 @@ var require_cst_visit = __commonJS({
|
|
|
5584
5584
|
}
|
|
5585
5585
|
}
|
|
5586
5586
|
if (typeof ctrl === "function" && field === "key")
|
|
5587
|
-
ctrl = ctrl(item,
|
|
5587
|
+
ctrl = ctrl(item, path8);
|
|
5588
5588
|
}
|
|
5589
5589
|
}
|
|
5590
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
5590
|
+
return typeof ctrl === "function" ? ctrl(item, path8) : ctrl;
|
|
5591
5591
|
}
|
|
5592
5592
|
exports.visit = visit;
|
|
5593
5593
|
}
|
|
@@ -7551,17 +7551,17 @@ var require_ignore = __commonJS({
|
|
|
7551
7551
|
var throwError = (message, Ctor) => {
|
|
7552
7552
|
throw new Ctor(message);
|
|
7553
7553
|
};
|
|
7554
|
-
var checkPath = (
|
|
7555
|
-
if (!isString(
|
|
7554
|
+
var checkPath = (path8, originalPath, doThrow) => {
|
|
7555
|
+
if (!isString(path8)) {
|
|
7556
7556
|
return doThrow(
|
|
7557
7557
|
`path must be a string, but got \`${originalPath}\``,
|
|
7558
7558
|
TypeError
|
|
7559
7559
|
);
|
|
7560
7560
|
}
|
|
7561
|
-
if (!
|
|
7561
|
+
if (!path8) {
|
|
7562
7562
|
return doThrow(`path must not be empty`, TypeError);
|
|
7563
7563
|
}
|
|
7564
|
-
if (checkPath.isNotRelative(
|
|
7564
|
+
if (checkPath.isNotRelative(path8)) {
|
|
7565
7565
|
const r = "`path.relative()`d";
|
|
7566
7566
|
return doThrow(
|
|
7567
7567
|
`path should be a ${r} string, but got "${originalPath}"`,
|
|
@@ -7570,7 +7570,7 @@ var require_ignore = __commonJS({
|
|
|
7570
7570
|
}
|
|
7571
7571
|
return true;
|
|
7572
7572
|
};
|
|
7573
|
-
var isNotRelative = (
|
|
7573
|
+
var isNotRelative = (path8) => REGEX_TEST_INVALID_PATH.test(path8);
|
|
7574
7574
|
checkPath.isNotRelative = isNotRelative;
|
|
7575
7575
|
checkPath.convert = (p) => p;
|
|
7576
7576
|
var Ignore = class {
|
|
@@ -7629,7 +7629,7 @@ var require_ignore = __commonJS({
|
|
|
7629
7629
|
// setting `checkUnignored` to `false` could reduce additional
|
|
7630
7630
|
// path matching.
|
|
7631
7631
|
// @returns {TestResult} true if a file is ignored
|
|
7632
|
-
_testOne(
|
|
7632
|
+
_testOne(path8, checkUnignored) {
|
|
7633
7633
|
let ignored = false;
|
|
7634
7634
|
let unignored = false;
|
|
7635
7635
|
this._rules.forEach((rule) => {
|
|
@@ -7637,7 +7637,7 @@ var require_ignore = __commonJS({
|
|
|
7637
7637
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
7638
7638
|
return;
|
|
7639
7639
|
}
|
|
7640
|
-
const matched = rule.regex.test(
|
|
7640
|
+
const matched = rule.regex.test(path8);
|
|
7641
7641
|
if (matched) {
|
|
7642
7642
|
ignored = !negative;
|
|
7643
7643
|
unignored = negative;
|
|
@@ -7650,24 +7650,24 @@ var require_ignore = __commonJS({
|
|
|
7650
7650
|
}
|
|
7651
7651
|
// @returns {TestResult}
|
|
7652
7652
|
_test(originalPath, cache, checkUnignored, slices) {
|
|
7653
|
-
const
|
|
7653
|
+
const path8 = originalPath && checkPath.convert(originalPath);
|
|
7654
7654
|
checkPath(
|
|
7655
|
-
|
|
7655
|
+
path8,
|
|
7656
7656
|
originalPath,
|
|
7657
7657
|
this._allowRelativePaths ? RETURN_FALSE : throwError
|
|
7658
7658
|
);
|
|
7659
|
-
return this._t(
|
|
7659
|
+
return this._t(path8, cache, checkUnignored, slices);
|
|
7660
7660
|
}
|
|
7661
|
-
_t(
|
|
7662
|
-
if (
|
|
7663
|
-
return cache[
|
|
7661
|
+
_t(path8, cache, checkUnignored, slices) {
|
|
7662
|
+
if (path8 in cache) {
|
|
7663
|
+
return cache[path8];
|
|
7664
7664
|
}
|
|
7665
7665
|
if (!slices) {
|
|
7666
|
-
slices =
|
|
7666
|
+
slices = path8.split(SLASH);
|
|
7667
7667
|
}
|
|
7668
7668
|
slices.pop();
|
|
7669
7669
|
if (!slices.length) {
|
|
7670
|
-
return cache[
|
|
7670
|
+
return cache[path8] = this._testOne(path8, checkUnignored);
|
|
7671
7671
|
}
|
|
7672
7672
|
const parent = this._t(
|
|
7673
7673
|
slices.join(SLASH) + SLASH,
|
|
@@ -7675,24 +7675,24 @@ var require_ignore = __commonJS({
|
|
|
7675
7675
|
checkUnignored,
|
|
7676
7676
|
slices
|
|
7677
7677
|
);
|
|
7678
|
-
return cache[
|
|
7678
|
+
return cache[path8] = parent.ignored ? parent : this._testOne(path8, checkUnignored);
|
|
7679
7679
|
}
|
|
7680
|
-
ignores(
|
|
7681
|
-
return this._test(
|
|
7680
|
+
ignores(path8) {
|
|
7681
|
+
return this._test(path8, this._ignoreCache, false).ignored;
|
|
7682
7682
|
}
|
|
7683
7683
|
createFilter() {
|
|
7684
|
-
return (
|
|
7684
|
+
return (path8) => !this.ignores(path8);
|
|
7685
7685
|
}
|
|
7686
7686
|
filter(paths) {
|
|
7687
7687
|
return makeArray(paths).filter(this.createFilter());
|
|
7688
7688
|
}
|
|
7689
7689
|
// @returns {TestResult}
|
|
7690
|
-
test(
|
|
7691
|
-
return this._test(
|
|
7690
|
+
test(path8) {
|
|
7691
|
+
return this._test(path8, this._testCache, true);
|
|
7692
7692
|
}
|
|
7693
7693
|
};
|
|
7694
7694
|
var factory = (options) => new Ignore(options);
|
|
7695
|
-
var isPathValid = (
|
|
7695
|
+
var isPathValid = (path8) => checkPath(path8 && checkPath.convert(path8), path8, RETURN_FALSE);
|
|
7696
7696
|
factory.isPathValid = isPathValid;
|
|
7697
7697
|
factory.default = factory;
|
|
7698
7698
|
module.exports = factory;
|
|
@@ -7703,7 +7703,7 @@ var require_ignore = __commonJS({
|
|
|
7703
7703
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
7704
7704
|
checkPath.convert = makePosix;
|
|
7705
7705
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
7706
|
-
checkPath.isNotRelative = (
|
|
7706
|
+
checkPath.isNotRelative = (path8) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path8) || isNotRelative(path8);
|
|
7707
7707
|
}
|
|
7708
7708
|
}
|
|
7709
7709
|
});
|
|
@@ -7711,7 +7711,7 @@ var require_ignore = __commonJS({
|
|
|
7711
7711
|
// src/sanitize_cli.js
|
|
7712
7712
|
import fs6 from "node:fs";
|
|
7713
7713
|
import os2 from "node:os";
|
|
7714
|
-
import
|
|
7714
|
+
import path7 from "node:path";
|
|
7715
7715
|
import { execFileSync as execFileSync2, spawnSync } from "node:child_process";
|
|
7716
7716
|
|
|
7717
7717
|
// src/index.js
|
|
@@ -7721,8 +7721,7 @@ import crypto from "node:crypto";
|
|
|
7721
7721
|
import fs5 from "node:fs";
|
|
7722
7722
|
import http from "node:http";
|
|
7723
7723
|
import os from "node:os";
|
|
7724
|
-
import
|
|
7725
|
-
import { fileURLToPath } from "node:url";
|
|
7724
|
+
import path6 from "node:path";
|
|
7726
7725
|
import { tool } from "@opencode-ai/plugin/tool";
|
|
7727
7726
|
|
|
7728
7727
|
// src/git_utils.js
|
|
@@ -8493,7 +8492,9 @@ async function optima_validate_logic(worktree) {
|
|
|
8493
8492
|
};
|
|
8494
8493
|
}
|
|
8495
8494
|
|
|
8496
|
-
// src/
|
|
8495
|
+
// src/constants.js
|
|
8496
|
+
import path5 from "node:path";
|
|
8497
|
+
import { fileURLToPath } from "node:url";
|
|
8497
8498
|
var PKG_ROOT = path5.resolve(path5.dirname(fileURLToPath(import.meta.url)), "..");
|
|
8498
8499
|
var BUNDLE_ASSETS_DIR = path5.join(PKG_ROOT, "assets");
|
|
8499
8500
|
var BUNDLE_AGENTS_DIR = path5.join(BUNDLE_ASSETS_DIR, "agents");
|
|
@@ -8624,20 +8625,22 @@ var REPO_LOCAL_POLICIES_README = [
|
|
|
8624
8625
|
"Only files in `.optima/policies/` affect runtime prompt behavior.",
|
|
8625
8626
|
""
|
|
8626
8627
|
].join("\n");
|
|
8628
|
+
var CLICKUP_WEBHOOK_CLEANUP_TIMEOUT_MS = 8e3;
|
|
8629
|
+
var CLICKUP_WEBHOOK_SIGNAL_STATE = Symbol.for("opencode-optima.clickup-webhook.signal-state");
|
|
8630
|
+
|
|
8631
|
+
// src/index.js
|
|
8627
8632
|
var activeWorkflows = /* @__PURE__ */ new Map();
|
|
8628
8633
|
var activeClickUpWebhookListeners = /* @__PURE__ */ new Map();
|
|
8629
8634
|
var activeClickUpWebhookLifecycleRegistry = /* @__PURE__ */ new Map();
|
|
8630
|
-
var CLICKUP_WEBHOOK_CLEANUP_TIMEOUT_MS = 8e3;
|
|
8631
|
-
var CLICKUP_WEBHOOK_SIGNAL_STATE = Symbol.for("opencode-optima.clickup-webhook.signal-state");
|
|
8632
8635
|
var activeClickUpTaskRoutes = /* @__PURE__ */ new Map();
|
|
8633
8636
|
function isRootDirectory(candidate) {
|
|
8634
|
-
const resolved =
|
|
8635
|
-
return resolved ===
|
|
8637
|
+
const resolved = path6.resolve(candidate);
|
|
8638
|
+
return resolved === path6.parse(resolved).root;
|
|
8636
8639
|
}
|
|
8637
8640
|
function isSafeWritableDirectory(candidate) {
|
|
8638
8641
|
if (typeof candidate !== "string" || !candidate.trim()) return false;
|
|
8639
|
-
if (!
|
|
8640
|
-
const resolved =
|
|
8642
|
+
if (!path6.isAbsolute(candidate)) return false;
|
|
8643
|
+
const resolved = path6.resolve(candidate);
|
|
8641
8644
|
if (isRootDirectory(resolved)) return false;
|
|
8642
8645
|
try {
|
|
8643
8646
|
const stat = fs5.statSync(resolved);
|
|
@@ -8658,7 +8661,7 @@ function resolveSafeWorktree(context = {}, pluginWorktree = null) {
|
|
|
8658
8661
|
];
|
|
8659
8662
|
for (const candidate of candidates) {
|
|
8660
8663
|
if (typeof candidate !== "string" || !candidate.trim()) continue;
|
|
8661
|
-
const resolved =
|
|
8664
|
+
const resolved = path6.resolve(candidate);
|
|
8662
8665
|
if (isSafeWritableDirectory(resolved)) return resolved;
|
|
8663
8666
|
}
|
|
8664
8667
|
throw new Error(SAFE_WORKTREE_FAILURE);
|
|
@@ -8673,13 +8676,13 @@ function safeWorktreeOrFailure(context, pluginWorktree) {
|
|
|
8673
8676
|
function explicitSafeInputWorktree(input = {}) {
|
|
8674
8677
|
for (const candidate of [input?.worktree, input?.directory]) {
|
|
8675
8678
|
if (typeof candidate !== "string" || !candidate.trim()) continue;
|
|
8676
|
-
const resolved =
|
|
8679
|
+
const resolved = path6.resolve(candidate);
|
|
8677
8680
|
if (isSafeWritableDirectory(resolved)) return resolved;
|
|
8678
8681
|
}
|
|
8679
8682
|
return null;
|
|
8680
8683
|
}
|
|
8681
8684
|
function isGitRepository(worktree) {
|
|
8682
|
-
return fs5.existsSync(
|
|
8685
|
+
return fs5.existsSync(path6.join(worktree, ".git"));
|
|
8683
8686
|
}
|
|
8684
8687
|
function normalizeLooseToken(value) {
|
|
8685
8688
|
return String(value ?? "").trim().normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -9174,7 +9177,7 @@ function buildClickUpSummaryPayload({ summaryMarkdown = "", summaryPath = "", ta
|
|
|
9174
9177
|
function deriveClickUpWorktree({ baseWorktree = "", taskId, taskType, parentTaskId, subtaskId } = {}) {
|
|
9175
9178
|
const branch = deriveClickUpBranchName({ taskType, parentTaskId, subtaskId, taskId });
|
|
9176
9179
|
const root = baseWorktree || process.cwd();
|
|
9177
|
-
return
|
|
9180
|
+
return path6.join(path6.dirname(root), `${path6.basename(root)}-${branch.replace(/\//g, "-")}`);
|
|
9178
9181
|
}
|
|
9179
9182
|
function clickUpCustomFieldValue(task = {}, names = []) {
|
|
9180
9183
|
const fields = Array.isArray(task.custom_fields) ? task.custom_fields : [];
|
|
@@ -9198,12 +9201,12 @@ function safeExistingClickUpWorktree({ metadata = {}, branch = "" } = {}) {
|
|
|
9198
9201
|
const taskMetadata = metadataTaskRouting(metadata);
|
|
9199
9202
|
const existingWorktree = typeof taskMetadata.worktree === "string" ? taskMetadata.worktree.trim() : "";
|
|
9200
9203
|
const existingBranch = typeof taskMetadata.branch === "string" ? taskMetadata.branch.trim() : "";
|
|
9201
|
-
if (!existingWorktree || !
|
|
9204
|
+
if (!existingWorktree || !path6.isAbsolute(existingWorktree) || !fs5.existsSync(existingWorktree)) return null;
|
|
9202
9205
|
try {
|
|
9203
9206
|
const stat = fs5.statSync(existingWorktree);
|
|
9204
9207
|
if (!stat.isDirectory()) return null;
|
|
9205
9208
|
if (branch && existingBranch && existingBranch !== branch) return null;
|
|
9206
|
-
return { branch: existingBranch || branch, worktree:
|
|
9209
|
+
return { branch: existingBranch || branch, worktree: path6.resolve(existingWorktree), reused: true };
|
|
9207
9210
|
} catch {
|
|
9208
9211
|
return null;
|
|
9209
9212
|
}
|
|
@@ -9289,17 +9292,17 @@ function openChamberEntryBranch(entry) {
|
|
|
9289
9292
|
return String(entry?.branch || entry?.branchName || entry?.branch_name || entry?.worktree?.branch || "").replace(/^refs\/heads\//, "");
|
|
9290
9293
|
}
|
|
9291
9294
|
function openChamberListIncludesDirectory(list, directory) {
|
|
9292
|
-
const resolved =
|
|
9295
|
+
const resolved = path6.resolve(directory);
|
|
9293
9296
|
return normalizeOpenChamberCollection(list).some((entry) => {
|
|
9294
9297
|
const entryDirectory = openChamberEntryDirectory(entry);
|
|
9295
|
-
return entryDirectory &&
|
|
9298
|
+
return entryDirectory && path6.resolve(entryDirectory) === resolved;
|
|
9296
9299
|
});
|
|
9297
9300
|
}
|
|
9298
9301
|
function openChamberListIncludesBranch(list, directory, branch) {
|
|
9299
|
-
const resolved =
|
|
9302
|
+
const resolved = path6.resolve(directory);
|
|
9300
9303
|
return normalizeOpenChamberCollection(list).some((entry) => {
|
|
9301
9304
|
const entryDirectory = openChamberEntryDirectory(entry);
|
|
9302
|
-
if (!entryDirectory ||
|
|
9305
|
+
if (!entryDirectory || path6.resolve(entryDirectory) !== resolved) return false;
|
|
9303
9306
|
const entryBranch = openChamberEntryBranch(entry);
|
|
9304
9307
|
return !entryBranch || entryBranch === branch;
|
|
9305
9308
|
});
|
|
@@ -9307,8 +9310,8 @@ function openChamberListIncludesBranch(list, directory, branch) {
|
|
|
9307
9310
|
async function findOpenChamberProject({ opencodeBaseUrl, baseWorktree, fetchImpl = globalThis.fetch } = {}) {
|
|
9308
9311
|
const projects = await requestOpenCodeJson({ baseUrl: opencodeBaseUrl, endpoint: "/project", directory: baseWorktree, fetchImpl });
|
|
9309
9312
|
if (!Array.isArray(projects)) return null;
|
|
9310
|
-
const resolvedBase =
|
|
9311
|
-
return projects.find((project) =>
|
|
9313
|
+
const resolvedBase = path6.resolve(baseWorktree);
|
|
9314
|
+
return projects.find((project) => path6.resolve(String(project?.worktree || project?.path || "")) === resolvedBase) || null;
|
|
9312
9315
|
}
|
|
9313
9316
|
async function refreshOpenChamberProjectCopy({ opencodeBaseUrl, projectId, fetchImpl = globalThis.fetch } = {}) {
|
|
9314
9317
|
if (!projectId) return { refreshed: false, reason: "project_id_unavailable" };
|
|
@@ -9363,18 +9366,18 @@ async function createOpenChamberClickUpWorktree({ openchamberBaseUrl, baseUrl, b
|
|
|
9363
9366
|
}
|
|
9364
9367
|
const createdDirectory = openChamberEntryDirectory(created);
|
|
9365
9368
|
const createdBranch = openChamberEntryBranch(created);
|
|
9366
|
-
if (!createdDirectory || !
|
|
9369
|
+
if (!createdDirectory || !path6.isAbsolute(createdDirectory)) {
|
|
9367
9370
|
throw new Error(`OpenChamber did not return an absolute worktree path for ${branch}.`);
|
|
9368
9371
|
}
|
|
9369
9372
|
if (createdBranch !== branch) {
|
|
9370
9373
|
throw new Error(`OpenChamber created unexpected branch ${createdBranch || "<unknown>"}; expected ${branch}.`);
|
|
9371
9374
|
}
|
|
9372
9375
|
const verified = await verifyOpenChamberGitWorktree({ openchamberBaseUrl: effectiveOpenChamberBaseUrl, baseWorktree, worktreePath: createdDirectory, branch, fetchImpl });
|
|
9373
|
-
return { created, worktree:
|
|
9376
|
+
return { created, worktree: path6.resolve(createdDirectory), branch: createdBranch, verified };
|
|
9374
9377
|
}
|
|
9375
9378
|
async function registerOpenChamberClickUpWorktree({ openchamberBaseUrl, opencodeBaseUrl, baseUrl, baseWorktree, branch, worktreePath, fetchImpl = globalThis.fetch, source = "reuse" } = {}) {
|
|
9376
9379
|
const visibility = await syncOpenChamberWorktreeVisibility({ openchamberBaseUrl: openchamberBaseUrl || baseUrl, opencodeBaseUrl: opencodeBaseUrl || baseUrl, baseWorktree, worktreePath, branch, fetchImpl });
|
|
9377
|
-
return { branch, worktree:
|
|
9380
|
+
return { branch, worktree: path6.resolve(worktreePath), reused: true, provider: "openchamber", openChamber: { source, visibility } };
|
|
9378
9381
|
}
|
|
9379
9382
|
async function ensureClickUpTaskWorktreeOpenChamber({ baseWorktree = "", taskId, taskType = "Tarea", parentTaskId = "", subtaskId = "", existingMetadata = {}, runGitFn = runGit, openchamberBaseUrl = "", opencodeBaseUrl = "", baseUrl = "", fetchImpl = globalThis.fetch, log = null } = {}) {
|
|
9380
9383
|
const effectiveOpenChamberBaseUrl = openchamberBaseUrl || baseUrl;
|
|
@@ -9437,10 +9440,10 @@ function ensureClickUpTaskWorktree({ baseWorktree = "", taskId, taskType = "Tare
|
|
|
9437
9440
|
const existing = safeExistingClickUpWorktree({ metadata: existingMetadata, branch });
|
|
9438
9441
|
if (existing) return { ...existing, branch, parentBranch: parentBranch || void 0, prTarget: parentBranch || "dev" };
|
|
9439
9442
|
const worktreePath = deriveClickUpWorktree({ baseWorktree, taskId, taskType, parentTaskId: effectiveParent, subtaskId });
|
|
9440
|
-
if (fs5.existsSync(worktreePath)) return { branch, worktree:
|
|
9443
|
+
if (fs5.existsSync(worktreePath)) return { branch, worktree: path6.resolve(worktreePath), reused: true, parentBranch: parentBranch || void 0, prTarget: parentBranch || "dev" };
|
|
9441
9444
|
if (allowNonGitFallback) {
|
|
9442
9445
|
fs5.mkdirSync(worktreePath, { recursive: true });
|
|
9443
|
-
return { branch, worktree:
|
|
9446
|
+
return { branch, worktree: path6.resolve(worktreePath), reused: false, fallback: "non_git", parentBranch: parentBranch || void 0, prTarget: parentBranch || "dev", startPoint: parentBranch || "dev" };
|
|
9444
9447
|
}
|
|
9445
9448
|
let parentBootstrap = null;
|
|
9446
9449
|
if (isSubtask) {
|
|
@@ -9449,14 +9452,14 @@ function ensureClickUpTaskWorktree({ baseWorktree = "", taskId, taskType = "Tare
|
|
|
9449
9452
|
const parentStartPoint = resolveClickUpDevStartPoint(baseWorktree, runGitFn);
|
|
9450
9453
|
const parentBranchExists = clickUpGitRefExists(baseWorktree, parentBranch, runGitFn);
|
|
9451
9454
|
addClickUpWorktreeForBranch({ baseWorktree, branch: parentBranch, worktreePath: parentWorktree, startPoint: parentStartPoint, runGitFn });
|
|
9452
|
-
parentBootstrap = { branch: parentBranch, worktree:
|
|
9455
|
+
parentBootstrap = { branch: parentBranch, worktree: path6.resolve(parentWorktree), startPoint: parentBranchExists ? parentBranch : parentStartPoint, reused: parentBranchExists };
|
|
9453
9456
|
} else {
|
|
9454
|
-
parentBootstrap = { branch: parentBranch, worktree:
|
|
9457
|
+
parentBootstrap = { branch: parentBranch, worktree: path6.resolve(parentWorktree), reused: true };
|
|
9455
9458
|
}
|
|
9456
9459
|
}
|
|
9457
9460
|
const startPoint = isSubtask ? parentBranch : resolveClickUpDevStartPoint(baseWorktree, runGitFn);
|
|
9458
9461
|
addClickUpWorktreeForBranch({ baseWorktree, branch, worktreePath, startPoint, runGitFn });
|
|
9459
|
-
return { branch, worktree:
|
|
9462
|
+
return { branch, worktree: path6.resolve(worktreePath), reused: false, startPoint, parentBranch: parentBranch || void 0, prTarget: parentBranch || "dev", parentBootstrap: parentBootstrap || void 0 };
|
|
9460
9463
|
}
|
|
9461
9464
|
function normalizeClickUpDefinitionDocParent(parent = {}) {
|
|
9462
9465
|
const docId = String(parent.doc_id || parent.docId || CLICKUP_DEFINITION_DOC_PARENT.doc_id).trim();
|
|
@@ -9606,7 +9609,7 @@ function buildClickUpTransitionPayload({ fromStatus, toStatus, validationPassed
|
|
|
9606
9609
|
}
|
|
9607
9610
|
function ensureOptimaGitignoreRules(worktree) {
|
|
9608
9611
|
if (!isGitRepository(worktree)) return { touched: false, added: [] };
|
|
9609
|
-
const gitignorePath =
|
|
9612
|
+
const gitignorePath = path6.join(worktree, ".gitignore");
|
|
9610
9613
|
const existing = fs5.existsSync(gitignorePath) ? fs5.readFileSync(gitignorePath, "utf8") : "";
|
|
9611
9614
|
const existingRules = new Set(existing.split(/\r?\n/).map((line) => line.trim()).filter(Boolean));
|
|
9612
9615
|
const missingRules = OPTIMA_GITIGNORE_RULES.filter((rule) => !existingRules.has(rule));
|
|
@@ -9622,40 +9625,40 @@ function ensureOptimaGitignoreRules(worktree) {
|
|
|
9622
9625
|
return { touched: true, added: missingRules };
|
|
9623
9626
|
}
|
|
9624
9627
|
function optimaDir(worktree) {
|
|
9625
|
-
return
|
|
9628
|
+
return path6.join(worktree, OPTIMA_DIRNAME);
|
|
9626
9629
|
}
|
|
9627
9630
|
function optimaLocalConfigDir(worktree) {
|
|
9628
|
-
return
|
|
9631
|
+
return path6.join(optimaDir(worktree), ".config");
|
|
9629
9632
|
}
|
|
9630
9633
|
function optimaConfigDir(worktree) {
|
|
9631
9634
|
return optimaLocalConfigDir(worktree);
|
|
9632
9635
|
}
|
|
9633
9636
|
function optimaCodemapPath(worktree) {
|
|
9634
|
-
return
|
|
9637
|
+
return path6.join(optimaDir(worktree), "codemap.yml");
|
|
9635
9638
|
}
|
|
9636
9639
|
function optimaTasksDir(worktree) {
|
|
9637
|
-
return
|
|
9640
|
+
return path6.join(optimaDir(worktree), "tasks");
|
|
9638
9641
|
}
|
|
9639
9642
|
function optimaEvidencesDir(worktree) {
|
|
9640
|
-
return
|
|
9643
|
+
return path6.join(optimaDir(worktree), "evidences");
|
|
9641
9644
|
}
|
|
9642
9645
|
function optimaScrsDir(worktree) {
|
|
9643
|
-
return
|
|
9646
|
+
return path6.join(optimaDir(worktree), "docs", "scrs");
|
|
9644
9647
|
}
|
|
9645
9648
|
function legacyNomadworkDir(worktree) {
|
|
9646
|
-
return
|
|
9649
|
+
return path6.join(worktree, LEGACY_NOMADWORK_DIRNAME);
|
|
9647
9650
|
}
|
|
9648
9651
|
function legacyNomadworksDir(worktree) {
|
|
9649
|
-
return
|
|
9652
|
+
return path6.join(worktree, LEGACY_NOMADWORKS_DIRNAME);
|
|
9650
9653
|
}
|
|
9651
9654
|
function legacyOrbitaDir(worktree) {
|
|
9652
|
-
return
|
|
9655
|
+
return path6.join(worktree, LEGACY_ORBITA_DIRNAME);
|
|
9653
9656
|
}
|
|
9654
9657
|
function legacyStaticEngDir(worktree) {
|
|
9655
|
-
return
|
|
9658
|
+
return path6.join(worktree, LEGACY_STATICENG_DIRNAME);
|
|
9656
9659
|
}
|
|
9657
9660
|
function repoConfigPath(worktree) {
|
|
9658
|
-
return
|
|
9661
|
+
return path6.join(optimaConfigDir(worktree), "optima.yaml");
|
|
9659
9662
|
}
|
|
9660
9663
|
function normalizeLegacyDiscussionEntry(entry) {
|
|
9661
9664
|
if (!entry || typeof entry !== "object") return entry;
|
|
@@ -9668,25 +9671,25 @@ function normalizeLegacyDiscussionEntry(entry) {
|
|
|
9668
9671
|
return next;
|
|
9669
9672
|
}
|
|
9670
9673
|
function repoPoliciesDir(worktree) {
|
|
9671
|
-
return
|
|
9674
|
+
return path6.join(optimaDir(worktree), "policies");
|
|
9672
9675
|
}
|
|
9673
9676
|
function generatedPoliciesDir(worktree) {
|
|
9674
|
-
return
|
|
9677
|
+
return path6.join(optimaLocalConfigDir(worktree), "generated", "policies");
|
|
9675
9678
|
}
|
|
9676
9679
|
function generatedAgentsDir(worktree) {
|
|
9677
|
-
return
|
|
9680
|
+
return path6.join(optimaLocalConfigDir(worktree), "generated", "agents");
|
|
9678
9681
|
}
|
|
9679
9682
|
function repoAgentsDir(worktree) {
|
|
9680
|
-
return
|
|
9683
|
+
return path6.join(optimaDir(worktree), "agents");
|
|
9681
9684
|
}
|
|
9682
9685
|
function repoAgentAdditionsDir(worktree) {
|
|
9683
|
-
return
|
|
9686
|
+
return path6.join(optimaDir(worktree), "agent-additions");
|
|
9684
9687
|
}
|
|
9685
9688
|
function legacyRepoAgentsDir(worktree) {
|
|
9686
|
-
return
|
|
9689
|
+
return path6.join(legacyNomadworksDir(worktree), "agents");
|
|
9687
9690
|
}
|
|
9688
9691
|
function runtimeDiscussionRegistryPath(worktree) {
|
|
9689
|
-
return
|
|
9692
|
+
return path6.join(optimaLocalConfigDir(worktree), "runtime", "discussions.json");
|
|
9690
9693
|
}
|
|
9691
9694
|
function resolveConfigPath(worktree) {
|
|
9692
9695
|
return repoConfigPath(worktree);
|
|
@@ -9729,32 +9732,32 @@ function mergeClickUpAgentMetadata(existing, update = {}) {
|
|
|
9729
9732
|
return JSON.stringify(sortJsonValue(merged), null, 2);
|
|
9730
9733
|
}
|
|
9731
9734
|
function optimaRuntimeDir(worktree) {
|
|
9732
|
-
return
|
|
9735
|
+
return path6.join(optimaLocalConfigDir(worktree), "runtime");
|
|
9733
9736
|
}
|
|
9734
9737
|
function clickUpWebhookStatePath(worktree) {
|
|
9735
|
-
return
|
|
9738
|
+
return path6.join(optimaRuntimeDir(worktree), "clickup-webhook.json");
|
|
9736
9739
|
}
|
|
9737
9740
|
function clickUpCommentLedgerPath(worktree) {
|
|
9738
|
-
return
|
|
9741
|
+
return path6.join(optimaRuntimeDir(worktree), "clickup-comment-ledger.jsonl");
|
|
9739
9742
|
}
|
|
9740
9743
|
function clickUpWebhookLogPath(worktree) {
|
|
9741
|
-
return
|
|
9744
|
+
return path6.join(optimaRuntimeDir(worktree), "clickup-webhook.log.jsonl");
|
|
9742
9745
|
}
|
|
9743
9746
|
function normalizeClickUpWebhookLogLevel(value) {
|
|
9744
9747
|
const level = String(value || "info").trim().toLowerCase();
|
|
9745
9748
|
return CLICKUP_WEBHOOK_LOG_LEVELS.has(level) ? level : "info";
|
|
9746
9749
|
}
|
|
9747
9750
|
function clickUpWebhookAuditLogDir() {
|
|
9748
|
-
const dataHome = process.env.XDG_DATA_HOME &&
|
|
9749
|
-
return
|
|
9751
|
+
const dataHome = process.env.XDG_DATA_HOME && path6.isAbsolute(process.env.XDG_DATA_HOME) ? process.env.XDG_DATA_HOME : path6.join(os.homedir(), ".local", "share", "opencode");
|
|
9752
|
+
return path6.join(dataHome, "opencode-optima");
|
|
9750
9753
|
}
|
|
9751
9754
|
function clickUpWebhookAuditLogPath(at = /* @__PURE__ */ new Date(), logDir = clickUpWebhookAuditLogDir()) {
|
|
9752
|
-
return
|
|
9755
|
+
return path6.join(logDir, `clickup-webhook-${at.toISOString().slice(0, 10)}.jsonl`);
|
|
9753
9756
|
}
|
|
9754
9757
|
function clickUpWebhookRequestFilePath(at = /* @__PURE__ */ new Date(), logDir = clickUpWebhookAuditLogDir()) {
|
|
9755
9758
|
const stamp = at.toISOString().replace(/:/g, "-").replace(/\./g, "-");
|
|
9756
9759
|
const shortId = crypto.randomBytes(4).toString("hex");
|
|
9757
|
-
return
|
|
9760
|
+
return path6.join(logDir, "requests", `clickup-webhook-${stamp}-${shortId}.json`);
|
|
9758
9761
|
}
|
|
9759
9762
|
function findOptimaPluginTupleOptions(pluginEntries = []) {
|
|
9760
9763
|
if (!Array.isArray(pluginEntries)) return null;
|
|
@@ -9853,7 +9856,7 @@ function normalizeClickUpWebhookConfig(rawClickUp = null, worktree = process.cwd
|
|
|
9853
9856
|
};
|
|
9854
9857
|
const errors = [];
|
|
9855
9858
|
if (!config.enabled) errors.push("clickup.enabled must be true");
|
|
9856
|
-
if (!config.basePath || !
|
|
9859
|
+
if (!config.basePath || !path6.isAbsolute(config.basePath)) errors.push("clickup.base_path must be an absolute path");
|
|
9857
9860
|
if (!config.teamId) errors.push("clickup.team_id is required");
|
|
9858
9861
|
if (!config.apiToken) errors.push("clickup.api_token is required");
|
|
9859
9862
|
if (!config.webhook.publicUrl) errors.push("clickup.webhook.public_url is required");
|
|
@@ -9911,7 +9914,7 @@ function readClickUpWebhookState(worktree, config = null) {
|
|
|
9911
9914
|
}
|
|
9912
9915
|
function writeClickUpWebhookState(worktree, state, config = null) {
|
|
9913
9916
|
const statePath = clickUpWebhookStatePath(worktree);
|
|
9914
|
-
fs5.mkdirSync(
|
|
9917
|
+
fs5.mkdirSync(path6.dirname(statePath), { recursive: true, mode: 448 });
|
|
9915
9918
|
const next = sanitizeClickUpWebhookState(state, config);
|
|
9916
9919
|
fs5.writeFileSync(statePath, `${JSON.stringify(next, null, 2)}
|
|
9917
9920
|
`, { encoding: "utf8", mode: 384 });
|
|
@@ -9932,7 +9935,7 @@ function isClickUpWebhookStateActive(state, config) {
|
|
|
9932
9935
|
function expandHomePath(value = "") {
|
|
9933
9936
|
const input = String(value || "").trim();
|
|
9934
9937
|
if (input === "~") return os.homedir();
|
|
9935
|
-
if (input.startsWith("~/")) return
|
|
9938
|
+
if (input.startsWith("~/")) return path6.join(os.homedir(), input.slice(2));
|
|
9936
9939
|
return input;
|
|
9937
9940
|
}
|
|
9938
9941
|
function resolveSecretReference(value = "") {
|
|
@@ -10308,7 +10311,7 @@ function readClickUpCommentLedger(ledgerPath) {
|
|
|
10308
10311
|
}
|
|
10309
10312
|
function appendClickUpCommentLedgerEntry(ledgerPath, entry = {}) {
|
|
10310
10313
|
if (!ledgerPath || !entry.key) return;
|
|
10311
|
-
fs5.mkdirSync(
|
|
10314
|
+
fs5.mkdirSync(path6.dirname(ledgerPath), { recursive: true, mode: 448 });
|
|
10312
10315
|
fs5.appendFileSync(ledgerPath, `${JSON.stringify(entry)}
|
|
10313
10316
|
`, { encoding: "utf8", mode: 384 });
|
|
10314
10317
|
try {
|
|
@@ -11171,7 +11174,7 @@ function formatClickUpWebhookPrompt({ eventType, taskId, payload, branch = "", w
|
|
|
11171
11174
|
}
|
|
11172
11175
|
function appendClickUpWebhookLocalLog(worktree, entry) {
|
|
11173
11176
|
const logPath = clickUpWebhookLogPath(worktree);
|
|
11174
|
-
fs5.mkdirSync(
|
|
11177
|
+
fs5.mkdirSync(path6.dirname(logPath), { recursive: true });
|
|
11175
11178
|
const safeEntry = { ...entry, at: entry.at || (/* @__PURE__ */ new Date()).toISOString() };
|
|
11176
11179
|
fs5.appendFileSync(logPath, `${JSON.stringify(safeEntry)}
|
|
11177
11180
|
`, "utf8");
|
|
@@ -11202,7 +11205,7 @@ function closeClickUpWebhookServer(server) {
|
|
|
11202
11205
|
});
|
|
11203
11206
|
}
|
|
11204
11207
|
function managedClickUpWebhookKey({ worktree, state, config } = {}) {
|
|
11205
|
-
return [
|
|
11208
|
+
return [path6.resolve(worktree || process.cwd()), state?.webhookId || "", config?.webhook?.publicUrl || ""].join("|");
|
|
11206
11209
|
}
|
|
11207
11210
|
async function deleteClickUpWebhookBestEffort({ webhookId, clickupClient, worktree, reason = "cleanup" } = {}) {
|
|
11208
11211
|
const id = String(webhookId || "").trim();
|
|
@@ -11307,8 +11310,8 @@ function writeClickUpWebhookAuditLog({ method, url, headers = {}, rawBody = "",
|
|
|
11307
11310
|
let requestFile;
|
|
11308
11311
|
if (level === "verbose") {
|
|
11309
11312
|
const absoluteRequestFile = clickUpWebhookRequestFilePath(at, logDir);
|
|
11310
|
-
fs5.mkdirSync(
|
|
11311
|
-
requestFile =
|
|
11313
|
+
fs5.mkdirSync(path6.dirname(absoluteRequestFile), { recursive: true });
|
|
11314
|
+
requestFile = path6.relative(logDir, absoluteRequestFile).split(path6.sep).join("/");
|
|
11312
11315
|
const parsedBody = payload || (() => {
|
|
11313
11316
|
try {
|
|
11314
11317
|
return JSON.parse(Buffer.isBuffer(rawBody) ? rawBody.toString("utf8") : String(rawBody || ""));
|
|
@@ -11919,17 +11922,17 @@ function startClickUpWebhookListener({ config, state, worktree, clickupClient, o
|
|
|
11919
11922
|
return result;
|
|
11920
11923
|
}
|
|
11921
11924
|
function legacyVariantPath(destinationPath) {
|
|
11922
|
-
const parsed =
|
|
11925
|
+
const parsed = path6.parse(destinationPath);
|
|
11923
11926
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:TZ.]/g, "").slice(0, 14);
|
|
11924
|
-
if (parsed.ext) return
|
|
11925
|
-
return
|
|
11927
|
+
if (parsed.ext) return path6.join(parsed.dir, `${parsed.name}.legacy-${stamp}${parsed.ext}`);
|
|
11928
|
+
return path6.join(parsed.dir, `${parsed.base}.legacy-${stamp}`);
|
|
11926
11929
|
}
|
|
11927
11930
|
function normalizeWorkflowTaskPath(taskPath) {
|
|
11928
11931
|
if (typeof taskPath !== "string") return { ok: false, message: "Error: task_path is required." };
|
|
11929
11932
|
const trimmed = taskPath.trim();
|
|
11930
11933
|
if (!trimmed) return { ok: false, message: "Error: task_path is required." };
|
|
11931
11934
|
const normalized = trimmed.replace(/\\/g, "/");
|
|
11932
|
-
if (
|
|
11935
|
+
if (path6.isAbsolute(trimmed)) return { ok: true, taskPath: trimmed };
|
|
11933
11936
|
if (normalized === "tasks" || normalized.startsWith("tasks/")) {
|
|
11934
11937
|
return {
|
|
11935
11938
|
ok: false,
|
|
@@ -11948,12 +11951,12 @@ function mergeFileIntoDestination(sourcePath, destinationPath, relativeSource, g
|
|
|
11948
11951
|
const sourceWasTracked = isGitTracked(gitState, sourcePath);
|
|
11949
11952
|
if (gitAwareMoveIfTracked(sourcePath, destinationPath, gitState)) return;
|
|
11950
11953
|
if (!fs5.existsSync(destinationPath)) {
|
|
11951
|
-
fs5.mkdirSync(
|
|
11954
|
+
fs5.mkdirSync(path6.dirname(destinationPath), { recursive: true });
|
|
11952
11955
|
fs5.renameSync(sourcePath, destinationPath);
|
|
11953
11956
|
if (sourceWasTracked) stageGitAwareMerge(sourcePath, destinationPath, gitState);
|
|
11954
11957
|
return;
|
|
11955
11958
|
}
|
|
11956
|
-
const ext =
|
|
11959
|
+
const ext = path6.extname(destinationPath).toLowerCase();
|
|
11957
11960
|
if ([".yaml", ".yml", ".json"].includes(ext)) {
|
|
11958
11961
|
const sourceRaw = fs5.readFileSync(sourcePath, "utf8");
|
|
11959
11962
|
const destRaw = fs5.readFileSync(destinationPath, "utf8");
|
|
@@ -11988,14 +11991,14 @@ ${sourceRaw}
|
|
|
11988
11991
|
fs5.renameSync(sourcePath, preservedPath);
|
|
11989
11992
|
stageGitAwareMerge(sourcePath, preservedPath, gitState);
|
|
11990
11993
|
}
|
|
11991
|
-
function mergePathIntoDestination(sourcePath, destinationPath, relativeSource =
|
|
11994
|
+
function mergePathIntoDestination(sourcePath, destinationPath, relativeSource = path6.basename(sourcePath), gitState = null) {
|
|
11992
11995
|
if (!fs5.existsSync(sourcePath)) return;
|
|
11993
11996
|
const stat = fs5.statSync(sourcePath);
|
|
11994
11997
|
if (stat.isDirectory()) {
|
|
11995
11998
|
const sourceWasTracked = isGitTracked(gitState, sourcePath) || hasGitTrackedChildren(gitState, sourcePath);
|
|
11996
11999
|
if (gitAwareMoveIfTracked(sourcePath, destinationPath, gitState)) return;
|
|
11997
12000
|
if (!fs5.existsSync(destinationPath)) {
|
|
11998
|
-
fs5.mkdirSync(
|
|
12001
|
+
fs5.mkdirSync(path6.dirname(destinationPath), { recursive: true });
|
|
11999
12002
|
fs5.renameSync(sourcePath, destinationPath);
|
|
12000
12003
|
if (sourceWasTracked) stageGitAwareMerge(sourcePath, destinationPath, gitState);
|
|
12001
12004
|
return;
|
|
@@ -12003,9 +12006,9 @@ function mergePathIntoDestination(sourcePath, destinationPath, relativeSource =
|
|
|
12003
12006
|
fs5.mkdirSync(destinationPath, { recursive: true });
|
|
12004
12007
|
for (const entry of fs5.readdirSync(sourcePath)) {
|
|
12005
12008
|
mergePathIntoDestination(
|
|
12006
|
-
|
|
12007
|
-
|
|
12008
|
-
|
|
12009
|
+
path6.join(sourcePath, entry),
|
|
12010
|
+
path6.join(destinationPath, entry),
|
|
12011
|
+
path6.join(relativeSource, entry),
|
|
12009
12012
|
gitState
|
|
12010
12013
|
);
|
|
12011
12014
|
}
|
|
@@ -12015,7 +12018,7 @@ function mergePathIntoDestination(sourcePath, destinationPath, relativeSource =
|
|
|
12015
12018
|
mergeFileIntoDestination(sourcePath, destinationPath, relativeSource, gitState);
|
|
12016
12019
|
}
|
|
12017
12020
|
function isOptimaPluginPackageWorktree(worktree) {
|
|
12018
|
-
const packageJsonPath =
|
|
12021
|
+
const packageJsonPath = path6.join(worktree, "package.json");
|
|
12019
12022
|
if (!fs5.existsSync(packageJsonPath)) return false;
|
|
12020
12023
|
try {
|
|
12021
12024
|
const pkg = JSON.parse(fs5.readFileSync(packageJsonPath, "utf8"));
|
|
@@ -12027,51 +12030,51 @@ function isOptimaPluginPackageWorktree(worktree) {
|
|
|
12027
12030
|
function migrateLegacyOptimaLayout(worktree) {
|
|
12028
12031
|
const gitState = gitMigrationState(worktree);
|
|
12029
12032
|
const migrations = [
|
|
12030
|
-
[
|
|
12031
|
-
[
|
|
12032
|
-
[
|
|
12033
|
-
[
|
|
12034
|
-
[
|
|
12035
|
-
[
|
|
12033
|
+
[path6.join(legacyOrbitaDir(worktree), "orbita.yaml"), repoConfigPath(worktree), path6.join(".orbita", "orbita.yaml")],
|
|
12034
|
+
[path6.join(legacyOrbitaDir(worktree), "staticeng.yaml"), repoConfigPath(worktree), path6.join(".orbita", "staticeng.yaml")],
|
|
12035
|
+
[path6.join(legacyOrbitaDir(worktree), ".config"), optimaLocalConfigDir(worktree), path6.join(".orbita", ".config")],
|
|
12036
|
+
[path6.join(legacyOrbitaDir(worktree), "config"), optimaLocalConfigDir(worktree), path6.join(".orbita", "config")],
|
|
12037
|
+
[path6.join(legacyOrbitaDir(worktree), "runtime"), path6.join(optimaLocalConfigDir(worktree), "runtime"), path6.join(".orbita", "runtime")],
|
|
12038
|
+
[path6.join(legacyOrbitaDir(worktree), "generated"), path6.join(optimaLocalConfigDir(worktree), "generated"), path6.join(".orbita", "generated")],
|
|
12036
12039
|
[legacyOrbitaDir(worktree), optimaDir(worktree), ".orbita"],
|
|
12037
|
-
[
|
|
12038
|
-
[
|
|
12039
|
-
[
|
|
12040
|
-
[
|
|
12041
|
-
[
|
|
12042
|
-
[
|
|
12040
|
+
[path6.join(legacyStaticEngDir(worktree), "staticeng.yaml"), repoConfigPath(worktree), path6.join(".staticeng", "staticeng.yaml")],
|
|
12041
|
+
[path6.join(legacyStaticEngDir(worktree), "orbita.yaml"), repoConfigPath(worktree), path6.join(".staticeng", "orbita.yaml")],
|
|
12042
|
+
[path6.join(legacyStaticEngDir(worktree), ".config"), optimaLocalConfigDir(worktree), path6.join(".staticeng", ".config")],
|
|
12043
|
+
[path6.join(legacyStaticEngDir(worktree), "config"), optimaLocalConfigDir(worktree), path6.join(".staticeng", "config")],
|
|
12044
|
+
[path6.join(legacyStaticEngDir(worktree), "runtime"), path6.join(optimaLocalConfigDir(worktree), "runtime"), path6.join(".staticeng", "runtime")],
|
|
12045
|
+
[path6.join(legacyStaticEngDir(worktree), "generated"), path6.join(optimaLocalConfigDir(worktree), "generated"), path6.join(".staticeng", "generated")],
|
|
12043
12046
|
[legacyStaticEngDir(worktree), optimaDir(worktree), ".staticeng"],
|
|
12044
|
-
[
|
|
12045
|
-
[
|
|
12046
|
-
[
|
|
12047
|
-
[
|
|
12048
|
-
[
|
|
12049
|
-
[
|
|
12050
|
-
[
|
|
12051
|
-
[
|
|
12052
|
-
[
|
|
12053
|
-
[
|
|
12054
|
-
[
|
|
12055
|
-
[
|
|
12047
|
+
[path6.join(legacyNomadworkDir(worktree), "nomadworks.yaml"), repoConfigPath(worktree), path6.join(".nomadwork", "nomadworks.yaml")],
|
|
12048
|
+
[path6.join(legacyNomadworksDir(worktree), "nomadworks.yaml"), repoConfigPath(worktree), path6.join(".nomadworks", "nomadworks.yaml")],
|
|
12049
|
+
[path6.join(legacyNomadworkDir(worktree), "staticeng.yaml"), repoConfigPath(worktree), path6.join(".nomadwork", "staticeng.yaml")],
|
|
12050
|
+
[path6.join(legacyNomadworksDir(worktree), "staticeng.yaml"), repoConfigPath(worktree), path6.join(".nomadworks", "staticeng.yaml")],
|
|
12051
|
+
[path6.join(legacyNomadworkDir(worktree), "orbita.yaml"), repoConfigPath(worktree), path6.join(".nomadwork", "orbita.yaml")],
|
|
12052
|
+
[path6.join(legacyNomadworksDir(worktree), "orbita.yaml"), repoConfigPath(worktree), path6.join(".nomadworks", "orbita.yaml")],
|
|
12053
|
+
[path6.join(legacyNomadworkDir(worktree), "runtime"), path6.join(optimaLocalConfigDir(worktree), "runtime"), path6.join(".nomadwork", "runtime")],
|
|
12054
|
+
[path6.join(legacyNomadworksDir(worktree), "runtime"), path6.join(optimaLocalConfigDir(worktree), "runtime"), path6.join(".nomadworks", "runtime")],
|
|
12055
|
+
[path6.join(legacyNomadworkDir(worktree), "generated"), path6.join(optimaLocalConfigDir(worktree), "generated"), path6.join(".nomadwork", "generated")],
|
|
12056
|
+
[path6.join(legacyNomadworksDir(worktree), "generated"), path6.join(optimaLocalConfigDir(worktree), "generated"), path6.join(".nomadworks", "generated")],
|
|
12057
|
+
[path6.join(legacyNomadworkDir(worktree), "config"), optimaLocalConfigDir(worktree), path6.join(".nomadwork", "config")],
|
|
12058
|
+
[path6.join(legacyNomadworksDir(worktree), "config"), optimaLocalConfigDir(worktree), path6.join(".nomadworks", "config")],
|
|
12056
12059
|
[legacyNomadworkDir(worktree), optimaDir(worktree), ".nomadwork"],
|
|
12057
12060
|
[legacyNomadworksDir(worktree), optimaDir(worktree), ".nomadworks"],
|
|
12058
|
-
[
|
|
12059
|
-
[
|
|
12060
|
-
[
|
|
12061
|
-
[
|
|
12062
|
-
[
|
|
12061
|
+
[path6.join(worktree, "tasks"), optimaTasksDir(worktree), "tasks"],
|
|
12062
|
+
[path6.join(worktree, "evidences"), optimaEvidencesDir(worktree), "evidences"],
|
|
12063
|
+
[path6.join(worktree, "docs", "scrs"), optimaScrsDir(worktree), path6.join("docs", "scrs")],
|
|
12064
|
+
[path6.join(worktree, "codemap.yml"), optimaCodemapPath(worktree), "codemap.yml"],
|
|
12065
|
+
[path6.join(worktree, "codemap.yaml"), optimaCodemapPath(worktree), "codemap.yaml"]
|
|
12063
12066
|
];
|
|
12064
12067
|
if (!isOptimaPluginPackageWorktree(worktree)) {
|
|
12065
|
-
migrations.push([
|
|
12068
|
+
migrations.push([path6.join(worktree, "policies"), repoPoliciesDir(worktree), "policies"]);
|
|
12066
12069
|
}
|
|
12067
12070
|
for (const [source, destination, relativeSource] of migrations) {
|
|
12068
12071
|
if (fs5.existsSync(source)) mergePathIntoDestination(source, destination, relativeSource, gitState);
|
|
12069
12072
|
}
|
|
12070
12073
|
for (const [source, destination, relativeSource] of [
|
|
12071
|
-
[
|
|
12072
|
-
[
|
|
12073
|
-
[
|
|
12074
|
-
[
|
|
12074
|
+
[path6.join(optimaDir(worktree), "optima.yaml"), repoConfigPath(worktree), path6.join(".optima", "optima.yaml")],
|
|
12075
|
+
[path6.join(optimaDir(worktree), "config"), optimaLocalConfigDir(worktree), path6.join(".optima", "config")],
|
|
12076
|
+
[path6.join(optimaDir(worktree), "runtime"), path6.join(optimaLocalConfigDir(worktree), "runtime"), path6.join(".optima", "runtime")],
|
|
12077
|
+
[path6.join(optimaDir(worktree), "generated"), path6.join(optimaLocalConfigDir(worktree), "generated"), path6.join(".optima", "generated")]
|
|
12075
12078
|
]) {
|
|
12076
12079
|
if (fs5.existsSync(source)) mergePathIntoDestination(source, destination, relativeSource, gitState);
|
|
12077
12080
|
}
|
|
@@ -12120,7 +12123,7 @@ function toModelString(provider, model) {
|
|
|
12120
12123
|
}
|
|
12121
12124
|
function readTaskMetadata(taskPath, worktree) {
|
|
12122
12125
|
if (!taskPath) return {};
|
|
12123
|
-
const absoluteTaskPath =
|
|
12126
|
+
const absoluteTaskPath = path6.isAbsolute(taskPath) ? taskPath : path6.join(worktree, taskPath);
|
|
12124
12127
|
if (!fs5.existsSync(absoluteTaskPath)) return {};
|
|
12125
12128
|
try {
|
|
12126
12129
|
const raw = fs5.readFileSync(absoluteTaskPath, "utf8");
|
|
@@ -12165,18 +12168,18 @@ function loadDiscussionRegistry(worktree) {
|
|
|
12165
12168
|
}
|
|
12166
12169
|
function saveDiscussionRegistry(worktree, registry) {
|
|
12167
12170
|
const registryPath = runtimeDiscussionRegistryPath(worktree);
|
|
12168
|
-
const runtimeDir =
|
|
12171
|
+
const runtimeDir = path6.dirname(registryPath);
|
|
12169
12172
|
if (!fs5.existsSync(runtimeDir)) fs5.mkdirSync(runtimeDir, { recursive: true });
|
|
12170
12173
|
fs5.writeFileSync(registryPath, JSON.stringify(registry, null, 2), "utf8");
|
|
12171
12174
|
}
|
|
12172
12175
|
function runtimeDiscussionsDir(worktree) {
|
|
12173
|
-
return
|
|
12176
|
+
return path6.join(optimaLocalConfigDir(worktree), "runtime", "discussions");
|
|
12174
12177
|
}
|
|
12175
12178
|
function archivedRuntimeDiscussionsDir(worktree) {
|
|
12176
|
-
return
|
|
12179
|
+
return path6.join(runtimeDiscussionsDir(worktree), "archive");
|
|
12177
12180
|
}
|
|
12178
12181
|
function finalDiscussionsDir(worktree) {
|
|
12179
|
-
return
|
|
12182
|
+
return path6.join(optimaTasksDir(worktree), "discussions");
|
|
12180
12183
|
}
|
|
12181
12184
|
function nextDiscussionIdentity(worktree, title) {
|
|
12182
12185
|
const discussionsDir = finalDiscussionsDir(worktree);
|
|
@@ -12187,11 +12190,11 @@ function nextDiscussionIdentity(worktree, title) {
|
|
|
12187
12190
|
while (true) {
|
|
12188
12191
|
const id = `DISCUSSION-${String(sequence).padStart(3, "0")}`;
|
|
12189
12192
|
const filename = `${id}-${slugifyTitle(title)}.md`;
|
|
12190
|
-
const summaryRelativePath =
|
|
12191
|
-
const summaryAbsolutePath =
|
|
12193
|
+
const summaryRelativePath = path6.join(".optima", "tasks", "discussions", filename);
|
|
12194
|
+
const summaryAbsolutePath = path6.join(worktree, summaryRelativePath);
|
|
12192
12195
|
const transcriptFilename = `${id}-transcript.md`;
|
|
12193
|
-
const transcriptRelativePath =
|
|
12194
|
-
const transcriptAbsolutePath =
|
|
12196
|
+
const transcriptRelativePath = path6.join(".optima", ".config", "runtime", "discussions", transcriptFilename);
|
|
12197
|
+
const transcriptAbsolutePath = path6.join(worktree, transcriptRelativePath);
|
|
12195
12198
|
if (!fs5.existsSync(summaryAbsolutePath) && !fs5.existsSync(transcriptAbsolutePath)) {
|
|
12196
12199
|
return {
|
|
12197
12200
|
id,
|
|
@@ -12216,11 +12219,11 @@ function findDiscussionById(worktree, discussionID) {
|
|
|
12216
12219
|
return {
|
|
12217
12220
|
id: discussionID,
|
|
12218
12221
|
filename,
|
|
12219
|
-
summaryRelativePath:
|
|
12220
|
-
summaryAbsolutePath:
|
|
12222
|
+
summaryRelativePath: path6.join(".optima", "tasks", "discussions", filename),
|
|
12223
|
+
summaryAbsolutePath: path6.join(discussionsDir, filename),
|
|
12221
12224
|
transcriptFilename,
|
|
12222
|
-
transcriptRelativePath:
|
|
12223
|
-
transcriptAbsolutePath:
|
|
12225
|
+
transcriptRelativePath: path6.join(".optima", ".config", "runtime", "discussions", transcriptFilename),
|
|
12226
|
+
transcriptAbsolutePath: path6.join(runtimeDiscussionsDir(worktree), transcriptFilename)
|
|
12224
12227
|
};
|
|
12225
12228
|
}
|
|
12226
12229
|
function parseDiscussionFile(filePath) {
|
|
@@ -12303,15 +12306,15 @@ async function appendMessageIfNeeded(client, worktree, registry, sessionID, mess
|
|
|
12303
12306
|
});
|
|
12304
12307
|
const text = extractTextParts(response.data.parts || []);
|
|
12305
12308
|
if (!text) return;
|
|
12306
|
-
appendDiscussionMessage(
|
|
12309
|
+
appendDiscussionMessage(path6.join(worktree, discussion.transcriptPath), speaker, text, messageID);
|
|
12307
12310
|
discussion.appendedMessageIDs ??= [];
|
|
12308
12311
|
discussion.appendedMessageIDs.push(messageID);
|
|
12309
12312
|
saveDiscussionRegistry(worktree, registry);
|
|
12310
12313
|
}
|
|
12311
12314
|
async function summarizeDiscussionWithBA(client, worktree, discussion) {
|
|
12312
|
-
const transcriptPath =
|
|
12313
|
-
const summaryPath =
|
|
12314
|
-
const summaryDir =
|
|
12315
|
+
const transcriptPath = path6.join(worktree, discussion.transcriptPath);
|
|
12316
|
+
const summaryPath = path6.join(worktree, discussion.summaryPath);
|
|
12317
|
+
const summaryDir = path6.dirname(summaryPath);
|
|
12315
12318
|
if (!fs5.existsSync(summaryDir)) fs5.mkdirSync(summaryDir, { recursive: true });
|
|
12316
12319
|
const hasExistingSummary = fs5.existsSync(summaryPath);
|
|
12317
12320
|
const priorMtimeMs = hasExistingSummary ? fs5.statSync(summaryPath).mtimeMs : null;
|
|
@@ -12414,11 +12417,11 @@ async function summarizeDiscussionWithBA(client, worktree, discussion) {
|
|
|
12414
12417
|
return { confirmation, summaryPath, transcriptPath, hasExistingSummary, priorMtimeMs };
|
|
12415
12418
|
}
|
|
12416
12419
|
function archiveDiscussionTranscript(worktree, transcriptRelativePath) {
|
|
12417
|
-
const sourcePath =
|
|
12420
|
+
const sourcePath = path6.join(worktree, transcriptRelativePath);
|
|
12418
12421
|
if (!fs5.existsSync(sourcePath)) return null;
|
|
12419
12422
|
const archiveDir = archivedRuntimeDiscussionsDir(worktree);
|
|
12420
12423
|
if (!fs5.existsSync(archiveDir)) fs5.mkdirSync(archiveDir, { recursive: true });
|
|
12421
|
-
const targetPath =
|
|
12424
|
+
const targetPath = path6.join(archiveDir, path6.basename(sourcePath));
|
|
12422
12425
|
fs5.renameSync(sourcePath, targetPath);
|
|
12423
12426
|
return targetPath;
|
|
12424
12427
|
}
|
|
@@ -12437,7 +12440,7 @@ async function finalizeClosingDiscussion(client, worktree, registry, sessionID,
|
|
|
12437
12440
|
if (!summaryContent) {
|
|
12438
12441
|
throw new Error(`Discussion summary file is empty at ${discussion.summaryPath}`);
|
|
12439
12442
|
}
|
|
12440
|
-
const transcriptPath =
|
|
12443
|
+
const transcriptPath = path6.join(worktree, discussion.transcriptPath);
|
|
12441
12444
|
setDiscussionStatus(transcriptPath, "closed");
|
|
12442
12445
|
const archivedTranscriptPath = archiveDiscussionTranscript(worktree, discussion.transcriptPath);
|
|
12443
12446
|
delete registry.active[sessionID];
|
|
@@ -12445,7 +12448,7 @@ async function finalizeClosingDiscussion(client, worktree, registry, sessionID,
|
|
|
12445
12448
|
return {
|
|
12446
12449
|
confirmation,
|
|
12447
12450
|
summaryPath: discussion.summaryPath,
|
|
12448
|
-
archivedTranscriptPath: archivedTranscriptPath ?
|
|
12451
|
+
archivedTranscriptPath: archivedTranscriptPath ? path6.relative(worktree, archivedTranscriptPath) : path6.join(".optima", ".config", "runtime", "discussions", "archive", path6.basename(discussion.transcriptPath))
|
|
12449
12452
|
};
|
|
12450
12453
|
}
|
|
12451
12454
|
function normalizeTeamMode(value) {
|
|
@@ -12517,7 +12520,7 @@ function syncGeneratedPolicies(worktree, repoCfg) {
|
|
|
12517
12520
|
if (!fs5.existsSync(generatedDir)) fs5.mkdirSync(generatedDir, { recursive: true });
|
|
12518
12521
|
const policyFiles = fs5.readdirSync(BUNDLE_POLICIES_DIR).filter((file) => file.endsWith(".md") && file !== "README.md");
|
|
12519
12522
|
for (const file of policyFiles) {
|
|
12520
|
-
const sourcePath =
|
|
12523
|
+
const sourcePath = path6.join(BUNDLE_POLICIES_DIR, file);
|
|
12521
12524
|
const source = fs5.readFileSync(sourcePath, "utf8").trimEnd();
|
|
12522
12525
|
const generated = [
|
|
12523
12526
|
"<!--",
|
|
@@ -12529,18 +12532,18 @@ function syncGeneratedPolicies(worktree, repoCfg) {
|
|
|
12529
12532
|
source,
|
|
12530
12533
|
""
|
|
12531
12534
|
].join("\n");
|
|
12532
|
-
fs5.writeFileSync(
|
|
12535
|
+
fs5.writeFileSync(path6.join(generatedDir, file), generated, "utf8");
|
|
12533
12536
|
}
|
|
12534
12537
|
}
|
|
12535
12538
|
function ensureReadmeFile(dirPath, content) {
|
|
12536
12539
|
if (!fs5.existsSync(dirPath)) fs5.mkdirSync(dirPath, { recursive: true });
|
|
12537
|
-
const readmePath =
|
|
12540
|
+
const readmePath = path6.join(dirPath, "README.md");
|
|
12538
12541
|
if (!fs5.existsSync(readmePath)) {
|
|
12539
12542
|
fs5.writeFileSync(readmePath, content, "utf8");
|
|
12540
12543
|
}
|
|
12541
12544
|
}
|
|
12542
12545
|
function ensureFileIfMissing(filePath, content) {
|
|
12543
|
-
if (!fs5.existsSync(
|
|
12546
|
+
if (!fs5.existsSync(path6.dirname(filePath))) fs5.mkdirSync(path6.dirname(filePath), { recursive: true });
|
|
12544
12547
|
if (!fs5.existsSync(filePath)) fs5.writeFileSync(filePath, content, "utf8");
|
|
12545
12548
|
}
|
|
12546
12549
|
function currentTasksRegistryContent() {
|
|
@@ -12627,13 +12630,13 @@ Never place implementation evidence under root \`evidences/\`.
|
|
|
12627
12630
|
}
|
|
12628
12631
|
function ensureOptimaTaskTemplates(worktree) {
|
|
12629
12632
|
const tasksDir = optimaTasksDir(worktree);
|
|
12630
|
-
ensureFileIfMissing(
|
|
12631
|
-
ensureFileIfMissing(
|
|
12633
|
+
ensureFileIfMissing(path6.join(tasksDir, "task-template.md"), taskTemplateContent());
|
|
12634
|
+
ensureFileIfMissing(path6.join(tasksDir, "subtask-template.md"), subtaskTemplateContent());
|
|
12632
12635
|
}
|
|
12633
12636
|
function scaffoldOptimaConfig(worktree, teamMode = "full") {
|
|
12634
12637
|
const configPath = repoConfigPath(worktree);
|
|
12635
12638
|
if (fs5.existsSync(configPath)) return false;
|
|
12636
|
-
const templatePath =
|
|
12639
|
+
const templatePath = path6.join(TEMPLATES_DIR, "optima.yaml.template");
|
|
12637
12640
|
if (!fs5.existsSync(templatePath)) return false;
|
|
12638
12641
|
const agentIds = fs5.existsSync(BUNDLE_AGENTS_DIR) ? fs5.readdirSync(BUNDLE_AGENTS_DIR).filter((f) => f.endsWith(".md")).map((f) => f.replace(".md", "")) : [];
|
|
12639
12642
|
let optimaConfig = fs5.readFileSync(templatePath, "utf8");
|
|
@@ -12652,9 +12655,9 @@ function scaffoldOptimaConfig(worktree, teamMode = "full") {
|
|
|
12652
12655
|
function scaffoldOptimaRootCodemap(worktree) {
|
|
12653
12656
|
const rootCodemapPath = optimaCodemapPath(worktree);
|
|
12654
12657
|
if (fs5.existsSync(rootCodemapPath)) return false;
|
|
12655
|
-
const templatePath =
|
|
12658
|
+
const templatePath = path6.join(TEMPLATES_DIR, "codemap.yml.template");
|
|
12656
12659
|
if (!fs5.existsSync(templatePath)) return false;
|
|
12657
|
-
const codemapConfig = fs5.readFileSync(templatePath, "utf8").replace("{{projectName}}",
|
|
12660
|
+
const codemapConfig = fs5.readFileSync(templatePath, "utf8").replace("{{projectName}}", path6.basename(worktree));
|
|
12658
12661
|
ensureFileIfMissing(rootCodemapPath, codemapConfig);
|
|
12659
12662
|
return fs5.existsSync(rootCodemapPath);
|
|
12660
12663
|
}
|
|
@@ -12663,10 +12666,10 @@ function ensureOptimaRegistries(worktree) {
|
|
|
12663
12666
|
const scrsDir = optimaScrsDir(worktree);
|
|
12664
12667
|
if (!fs5.existsSync(tasksDir)) fs5.mkdirSync(tasksDir, { recursive: true });
|
|
12665
12668
|
if (!fs5.existsSync(scrsDir)) fs5.mkdirSync(scrsDir, { recursive: true });
|
|
12666
|
-
ensureFileIfMissing(
|
|
12667
|
-
ensureFileIfMissing(
|
|
12668
|
-
ensureFileIfMissing(
|
|
12669
|
-
ensureFileIfMissing(
|
|
12669
|
+
ensureFileIfMissing(path6.join(tasksDir, "current.md"), currentTasksRegistryContent());
|
|
12670
|
+
ensureFileIfMissing(path6.join(tasksDir, "done.md"), doneTasksRegistryContent());
|
|
12671
|
+
ensureFileIfMissing(path6.join(scrsDir, "current.md"), currentScrRegistryContent());
|
|
12672
|
+
ensureFileIfMissing(path6.join(scrsDir, "done.md"), doneScrRegistryContent());
|
|
12670
12673
|
}
|
|
12671
12674
|
function scaffoldOptimaReadmes(worktree) {
|
|
12672
12675
|
ensureReadmeFile(repoPoliciesDir(worktree), REPO_LOCAL_POLICIES_README);
|
|
@@ -12828,12 +12831,12 @@ function shouldRegisterWorkflowProductManager(options = {}, worktree = process.c
|
|
|
12828
12831
|
}
|
|
12829
12832
|
function isClickUpDerivedWorktreeSibling(candidate, basePath) {
|
|
12830
12833
|
if (typeof candidate !== "string" || typeof basePath !== "string" || !candidate.trim() || !basePath.trim()) return false;
|
|
12831
|
-
const resolvedCandidate =
|
|
12832
|
-
const resolvedBase =
|
|
12833
|
-
const baseParent =
|
|
12834
|
-
if (
|
|
12835
|
-
const baseName =
|
|
12836
|
-
const candidateName =
|
|
12834
|
+
const resolvedCandidate = path6.resolve(candidate);
|
|
12835
|
+
const resolvedBase = path6.resolve(basePath);
|
|
12836
|
+
const baseParent = path6.dirname(resolvedBase);
|
|
12837
|
+
if (path6.dirname(resolvedCandidate) !== baseParent) return false;
|
|
12838
|
+
const baseName = path6.basename(resolvedBase);
|
|
12839
|
+
const candidateName = path6.basename(resolvedCandidate);
|
|
12837
12840
|
if (!candidateName.startsWith(`${baseName}-`)) return false;
|
|
12838
12841
|
const branchSlug = candidateName.slice(baseName.length + 1);
|
|
12839
12842
|
const parts = branchSlug.split("-").filter(Boolean);
|
|
@@ -12845,7 +12848,7 @@ function isClickUpDerivedWorktreeSibling(candidate, basePath) {
|
|
|
12845
12848
|
if (!candidateStat.isDirectory() || candidateStat.isSymbolicLink()) return false;
|
|
12846
12849
|
const realCandidate = fs5.realpathSync.native(resolvedCandidate);
|
|
12847
12850
|
const realBaseParent = fs5.realpathSync.native(baseParent);
|
|
12848
|
-
return
|
|
12851
|
+
return path6.dirname(realCandidate) === realBaseParent && path6.basename(realCandidate) === candidateName;
|
|
12849
12852
|
} catch {
|
|
12850
12853
|
return false;
|
|
12851
12854
|
}
|
|
@@ -12853,15 +12856,15 @@ function isClickUpDerivedWorktreeSibling(candidate, basePath) {
|
|
|
12853
12856
|
function resolveSessionToolDirectory({ requestedDirectory, context, pluginWorktree, clickUpWebhookValidation } = {}) {
|
|
12854
12857
|
const safe = safeWorktreeOrFailure(context, pluginWorktree);
|
|
12855
12858
|
if (!safe.ok) return { ok: false, error: safe.message };
|
|
12856
|
-
const requested = String(requestedDirectory || "").trim() ?
|
|
12859
|
+
const requested = String(requestedDirectory || "").trim() ? path6.resolve(safe.worktree, String(requestedDirectory).trim()) : safe.worktree;
|
|
12857
12860
|
if (!isSafeWritableDirectory(requested)) return { ok: false, error: `Directory is not a safe writable directory: ${requested}` };
|
|
12858
12861
|
if (isSameOrNestedPath(requested, safe.worktree)) return { ok: true, directory: requested, safeWorktree: safe.worktree, scope: "context_worktree" };
|
|
12859
12862
|
const clickUpBasePath = clickUpWebhookValidation?.complete === true && clickUpWebhookValidation?.ok !== false ? clickUpWebhookValidation.config?.basePath : "";
|
|
12860
12863
|
if (clickUpBasePath && isSameOrNestedPath(requested, clickUpBasePath)) {
|
|
12861
|
-
return { ok: true, directory: requested, safeWorktree: safe.worktree, scope: "clickup_base_path", clickupBasePath:
|
|
12864
|
+
return { ok: true, directory: requested, safeWorktree: safe.worktree, scope: "clickup_base_path", clickupBasePath: path6.resolve(clickUpBasePath) };
|
|
12862
12865
|
}
|
|
12863
12866
|
if (clickUpBasePath && isClickUpDerivedWorktreeSibling(requested, clickUpBasePath)) {
|
|
12864
|
-
return { ok: true, directory: requested, safeWorktree: safe.worktree, scope: "clickup_derived_worktree", clickupBasePath:
|
|
12867
|
+
return { ok: true, directory: requested, safeWorktree: safe.worktree, scope: "clickup_derived_worktree", clickupBasePath: path6.resolve(clickUpBasePath) };
|
|
12865
12868
|
}
|
|
12866
12869
|
return {
|
|
12867
12870
|
ok: false,
|
|
@@ -12895,8 +12898,8 @@ function buildOptimaAgents(repoCfg, operatingTeamMode, worktree, debugDir, optio
|
|
|
12895
12898
|
if (!enabled) continue;
|
|
12896
12899
|
}
|
|
12897
12900
|
const promptOptions = { preferCompactPromptDocs: repoCfg.features?.compact_prompt_docs !== false };
|
|
12898
|
-
const bundledDefinition = loadAgentDefinition(
|
|
12899
|
-
const repoDefinition = loadAgentDefinition(
|
|
12901
|
+
const bundledDefinition = loadAgentDefinition(path6.join(BUNDLE_AGENTS_DIR, file), worktree, promptOptions);
|
|
12902
|
+
const repoDefinition = loadAgentDefinition(path6.join(repoAgentDefinitions, file), worktree, promptOptions) || loadAgentDefinition(path6.join(legacyAgentsDir, file), worktree, promptOptions);
|
|
12900
12903
|
const activeDefinition = repoDefinition || bundledDefinition;
|
|
12901
12904
|
if (!activeDefinition) continue;
|
|
12902
12905
|
const { data } = activeDefinition;
|
|
@@ -12905,7 +12908,7 @@ function buildOptimaAgents(repoCfg, operatingTeamMode, worktree, debugDir, optio
|
|
|
12905
12908
|
if (modePromptFragment) finalPrompt = `${finalPrompt}
|
|
12906
12909
|
|
|
12907
12910
|
${modePromptFragment}`;
|
|
12908
|
-
const additionFragment = loadMarkdownFragment(
|
|
12911
|
+
const additionFragment = loadMarkdownFragment(path6.join(repoAgentAdditions, file), worktree);
|
|
12909
12912
|
if (additionFragment) {
|
|
12910
12913
|
finalPrompt = `${finalPrompt}
|
|
12911
12914
|
|
|
@@ -12958,7 +12961,7 @@ Use this Optima-provided fallback when the current task worktree lacks docs/core
|
|
|
12958
12961
|
}
|
|
12959
12962
|
ourAgents[id] = agentConfig;
|
|
12960
12963
|
if (repoCfg.features?.debug_dumps !== false) {
|
|
12961
|
-
const debugPath =
|
|
12964
|
+
const debugPath = path6.join(debugDir, `${id}.md`);
|
|
12962
12965
|
const { prompt, ...dumpConfig } = agentConfig;
|
|
12963
12966
|
const debugHeader = `---
|
|
12964
12967
|
${import_yaml3.default.stringify(dumpConfig).trim()}
|
|
@@ -13110,8 +13113,8 @@ async function OptimaPlugin(input = {}, pluginOptions = {}) {
|
|
|
13110
13113
|
migrateLegacyOptimaLayout(toolWorktree);
|
|
13111
13114
|
const cfgDir = optimaConfigDir(toolWorktree);
|
|
13112
13115
|
if (!fs5.existsSync(cfgDir)) fs5.mkdirSync(cfgDir, { recursive: true });
|
|
13113
|
-
const optimaTmplPath =
|
|
13114
|
-
const codemapTmplPath =
|
|
13116
|
+
const optimaTmplPath = path6.join(TEMPLATES_DIR, "optima.yaml.template");
|
|
13117
|
+
const codemapTmplPath = path6.join(TEMPLATES_DIR, "codemap.yml.template");
|
|
13115
13118
|
if (!fs5.existsSync(optimaTmplPath) || !fs5.existsSync(codemapTmplPath)) {
|
|
13116
13119
|
return "Error: Initialization templates not found in plugin.";
|
|
13117
13120
|
}
|
|
@@ -13233,14 +13236,14 @@ Restart or reload OpenCode manually if the newly scaffolded config or agents are
|
|
|
13233
13236
|
async execute(args, context) {
|
|
13234
13237
|
const safe = safeWorktreeOrFailure(context, worktree);
|
|
13235
13238
|
if (!safe.ok) return safe.message;
|
|
13236
|
-
const summaryPath =
|
|
13239
|
+
const summaryPath = path6.resolve(safe.worktree, args.summary_path || "");
|
|
13237
13240
|
if (!fs5.existsSync(summaryPath)) return `FAIL: summary_path not found: ${summaryPath}`;
|
|
13238
|
-
const taskPath = args.task_path ?
|
|
13241
|
+
const taskPath = args.task_path ? path6.resolve(safe.worktree, args.task_path) : "";
|
|
13239
13242
|
const payload = buildClickUpSummaryPayload({
|
|
13240
13243
|
summaryMarkdown: fs5.readFileSync(summaryPath, "utf8"),
|
|
13241
|
-
summaryPath:
|
|
13244
|
+
summaryPath: path6.relative(safe.worktree, summaryPath),
|
|
13242
13245
|
taskMarkdown: taskPath && fs5.existsSync(taskPath) ? fs5.readFileSync(taskPath, "utf8") : "",
|
|
13243
|
-
taskPath: taskPath ?
|
|
13246
|
+
taskPath: taskPath ? path6.relative(safe.worktree, taskPath) : "",
|
|
13244
13247
|
branch: args.branch,
|
|
13245
13248
|
worktree: args.worktree,
|
|
13246
13249
|
pr: args.pr
|
|
@@ -13319,12 +13322,12 @@ Restart or reload OpenCode manually if the newly scaffolded config or agents are
|
|
|
13319
13322
|
async execute(args, context) {
|
|
13320
13323
|
const safe = safeWorktreeOrFailure(context, worktree);
|
|
13321
13324
|
if (!safe.ok) return safe.message;
|
|
13322
|
-
const markdownPath =
|
|
13325
|
+
const markdownPath = path6.resolve(safe.worktree, args.markdown_path || "");
|
|
13323
13326
|
if (!fs5.existsSync(markdownPath)) return `FAIL: markdown_path not found: ${markdownPath}`;
|
|
13324
13327
|
const payload = buildClickUpCreateSubtasksPayload({
|
|
13325
13328
|
parentTaskId: args.parent_task_id,
|
|
13326
13329
|
markdown: fs5.readFileSync(markdownPath, "utf8"),
|
|
13327
|
-
sourcePath:
|
|
13330
|
+
sourcePath: path6.relative(safe.worktree, markdownPath),
|
|
13328
13331
|
parentBranch: args.parent_branch,
|
|
13329
13332
|
parentTaskType: args.parent_task_type || "Tarea",
|
|
13330
13333
|
apply: String(args.apply || "").toLowerCase() === "true"
|
|
@@ -13523,7 +13526,7 @@ Backfilled messages: ${backfilled}`;
|
|
|
13523
13526
|
if (!existing) {
|
|
13524
13527
|
return "FAIL: No active discussion exists for this session.";
|
|
13525
13528
|
}
|
|
13526
|
-
const discussionPath =
|
|
13529
|
+
const discussionPath = path6.join(toolWorktree, existing.transcriptPath);
|
|
13527
13530
|
setDiscussionStatus(discussionPath, "summarizing");
|
|
13528
13531
|
existing.status = "summarizing";
|
|
13529
13532
|
saveDiscussionRegistry(toolWorktree, toolRegistry);
|
|
@@ -13575,7 +13578,7 @@ Reason: ${err.message}`;
|
|
|
13575
13578
|
try {
|
|
13576
13579
|
const sessionResult = await client.session.create({
|
|
13577
13580
|
query: { directory: workflowDirectory },
|
|
13578
|
-
body: { title: `Workflow Run: ${
|
|
13581
|
+
body: { title: `Workflow Run: ${path6.basename(workflowTaskPath)}` }
|
|
13579
13582
|
});
|
|
13580
13583
|
const sessionId = sessionResult.data.id;
|
|
13581
13584
|
activeWorkflows.set(sessionId, { pmaSessionId, taskPath: workflowTaskPath, track: workflowTrack, directory: workflowDirectory });
|
|
@@ -13760,13 +13763,13 @@ function usage() {
|
|
|
13760
13763
|
}
|
|
13761
13764
|
function expandHome(inputPath) {
|
|
13762
13765
|
if (!inputPath || inputPath === "~") return os2.homedir();
|
|
13763
|
-
if (inputPath.startsWith("~/")) return
|
|
13766
|
+
if (inputPath.startsWith("~/")) return path7.join(os2.homedir(), inputPath.slice(2));
|
|
13764
13767
|
return inputPath;
|
|
13765
13768
|
}
|
|
13766
13769
|
function resolveOpenCodeDbPath(inputPath = null) {
|
|
13767
13770
|
const expanded = expandHome(inputPath || process.env.OPTIMA_OPENCODE_DB_PATH || DEFAULT_DB_PATH);
|
|
13768
13771
|
try {
|
|
13769
|
-
if (fs6.existsSync(expanded) && fs6.statSync(expanded).isDirectory()) return
|
|
13772
|
+
if (fs6.existsSync(expanded) && fs6.statSync(expanded).isDirectory()) return path7.join(expanded, "opencode.db");
|
|
13770
13773
|
} catch {
|
|
13771
13774
|
return expanded;
|
|
13772
13775
|
}
|
|
@@ -13830,8 +13833,8 @@ function extractOpenedPathValue(value) {
|
|
|
13830
13833
|
}
|
|
13831
13834
|
function normalizePathCandidate(candidate) {
|
|
13832
13835
|
const expanded = expandHome(candidate);
|
|
13833
|
-
if (!
|
|
13834
|
-
return
|
|
13836
|
+
if (!path7.isAbsolute(expanded)) return null;
|
|
13837
|
+
return path7.resolve(expanded);
|
|
13835
13838
|
}
|
|
13836
13839
|
function discoverOpenCodePaths(dbPath) {
|
|
13837
13840
|
const resolvedDb = resolveOpenCodeDbPath(dbPath);
|
|
@@ -13860,27 +13863,27 @@ function discoverOpenCodePaths(dbPath) {
|
|
|
13860
13863
|
function collectMarkdownOverridesFrom(baseDir) {
|
|
13861
13864
|
const files = [];
|
|
13862
13865
|
for (const dirName of OVERRIDE_DIRS) {
|
|
13863
|
-
const dirPath =
|
|
13866
|
+
const dirPath = path7.join(baseDir, dirName);
|
|
13864
13867
|
if (!fs6.existsSync(dirPath)) continue;
|
|
13865
13868
|
for (const entry of fs6.readdirSync(dirPath, { withFileTypes: true })) {
|
|
13866
13869
|
if (!entry.isFile()) continue;
|
|
13867
13870
|
if (!entry.name.endsWith(".md")) continue;
|
|
13868
13871
|
if (entry.name.toLowerCase() === "readme.md") continue;
|
|
13869
|
-
files.push(
|
|
13872
|
+
files.push(path7.join(dirPath, entry.name));
|
|
13870
13873
|
}
|
|
13871
13874
|
}
|
|
13872
13875
|
return files;
|
|
13873
13876
|
}
|
|
13874
13877
|
function collectOverrideFiles(worktree) {
|
|
13875
|
-
return collectMarkdownOverridesFrom(
|
|
13878
|
+
return collectMarkdownOverridesFrom(path7.join(worktree, ".optima")).sort();
|
|
13876
13879
|
}
|
|
13877
13880
|
function collectPlannedOverrideFiles(worktree) {
|
|
13878
13881
|
return [
|
|
13879
13882
|
...collectOverrideFiles(worktree),
|
|
13880
|
-
...collectMarkdownOverridesFrom(
|
|
13881
|
-
...collectMarkdownOverridesFrom(
|
|
13882
|
-
...collectMarkdownOverridesFrom(
|
|
13883
|
-
...collectMarkdownOverridesFrom(
|
|
13883
|
+
...collectMarkdownOverridesFrom(path7.join(worktree, ".staticeng")),
|
|
13884
|
+
...collectMarkdownOverridesFrom(path7.join(worktree, ".orbita")),
|
|
13885
|
+
...collectMarkdownOverridesFrom(path7.join(worktree, ".nomadwork")),
|
|
13886
|
+
...collectMarkdownOverridesFrom(path7.join(worktree, ".nomadworks"))
|
|
13884
13887
|
].sort();
|
|
13885
13888
|
}
|
|
13886
13889
|
var CRC_TABLE = (() => {
|
|
@@ -13913,14 +13916,14 @@ function writeUInt16LE(value) {
|
|
|
13913
13916
|
return buffer;
|
|
13914
13917
|
}
|
|
13915
13918
|
function createZipBackup(files, backupPath) {
|
|
13916
|
-
fs6.mkdirSync(
|
|
13919
|
+
fs6.mkdirSync(path7.dirname(backupPath), { recursive: true });
|
|
13917
13920
|
const localParts = [];
|
|
13918
13921
|
const centralParts = [];
|
|
13919
13922
|
let offset = 0;
|
|
13920
13923
|
const now = dosTimeDate();
|
|
13921
13924
|
for (const filePath of files) {
|
|
13922
13925
|
const data = fs6.readFileSync(filePath);
|
|
13923
|
-
const name =
|
|
13926
|
+
const name = path7.resolve(filePath).replace(/^\//, "").split(path7.sep).join("/");
|
|
13924
13927
|
const nameBuffer = Buffer.from(name, "utf8");
|
|
13925
13928
|
const crc = crc32(data);
|
|
13926
13929
|
const local = Buffer.concat([
|
|
@@ -13982,15 +13985,15 @@ function validationStatus(result) {
|
|
|
13982
13985
|
return result.ok ? "passed" : "failed";
|
|
13983
13986
|
}
|
|
13984
13987
|
function hasLegacyMarker(worktree) {
|
|
13985
|
-
return fs6.existsSync(
|
|
13988
|
+
return fs6.existsSync(path7.join(worktree, ".staticeng")) || fs6.existsSync(path7.join(worktree, ".orbita")) || fs6.existsSync(path7.join(worktree, ".nomadwork")) || fs6.existsSync(path7.join(worktree, ".nomadworks"));
|
|
13986
13989
|
}
|
|
13987
13990
|
function rootOptimaArtifacts(worktree) {
|
|
13988
13991
|
const artifacts = [
|
|
13989
|
-
["tasks/",
|
|
13990
|
-
["evidences/",
|
|
13991
|
-
["docs/scrs/",
|
|
13992
|
-
["codemap.yml",
|
|
13993
|
-
["codemap.yaml",
|
|
13992
|
+
["tasks/", path7.join(worktree, "tasks")],
|
|
13993
|
+
["evidences/", path7.join(worktree, "evidences")],
|
|
13994
|
+
["docs/scrs/", path7.join(worktree, "docs", "scrs")],
|
|
13995
|
+
["codemap.yml", path7.join(worktree, "codemap.yml")],
|
|
13996
|
+
["codemap.yaml", path7.join(worktree, "codemap.yaml")]
|
|
13994
13997
|
];
|
|
13995
13998
|
return artifacts.map(([display, artifactPath]) => ({ display, path: artifactPath })).filter((item) => fs6.existsSync(item.path));
|
|
13996
13999
|
}
|
|
@@ -14018,7 +14021,7 @@ function planOptimaMigration(worktree, dryRun) {
|
|
|
14018
14021
|
...overrides.map((file) => ({
|
|
14019
14022
|
category: "override",
|
|
14020
14023
|
action: dryRun ? "would_remove_after_backup" : "removed_after_backup",
|
|
14021
|
-
path:
|
|
14024
|
+
path: path7.relative(worktree, file).split(path7.sep).join("/"),
|
|
14022
14025
|
detail: "Remove implicit agent/policy override after host-level backup."
|
|
14023
14026
|
}))
|
|
14024
14027
|
],
|
|
@@ -14066,7 +14069,7 @@ async function sanitizeHost(options = {}) {
|
|
|
14066
14069
|
const overrides = repoStates.flatMap((state) => state.overrideFiles.map((file) => ({ repo: state.repo, file })));
|
|
14067
14070
|
report.totals.overrideFiles = overrides.length;
|
|
14068
14071
|
if (!dryRun && overrides.length > 0) {
|
|
14069
|
-
const backupPath =
|
|
14072
|
+
const backupPath = path7.join(os2.homedir(), BACKUP_DIRNAME, `${timestamp()}.zip`);
|
|
14070
14073
|
try {
|
|
14071
14074
|
createZipBackup(overrides.map((item) => item.file), backupPath);
|
|
14072
14075
|
report.backupPath = backupPath;
|
|
@@ -14095,7 +14098,7 @@ async function sanitizeHost(options = {}) {
|
|
|
14095
14098
|
repairActions: state.plan.actions.length,
|
|
14096
14099
|
repairSkipped: state.plan.skippedRepair === true,
|
|
14097
14100
|
overrideFiles: state.overrideFiles.length,
|
|
14098
|
-
overridePaths: state.overrideFiles.map((file) =>
|
|
14101
|
+
overridePaths: state.overrideFiles.map((file) => path7.relative(state.repo, file).split(path7.sep).join("/")),
|
|
14099
14102
|
validation: validation ? validationStatus(validation) : "skipped",
|
|
14100
14103
|
unresolved: state.plan.unresolved
|
|
14101
14104
|
});
|