@fusebase/harness-lead 0.2.41 → 0.3.0
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/CHANGELOG.md +19 -0
- package/README.md +14 -1
- package/dist/lead.mjs +1064 -246
- package/package.json +1 -1
- package/skills/lead/SKILL.md +1 -1
- package/skills/lead/delegates/codee/SKILL.md +2 -1
- package/skills/lead/references/adopt.md +71 -0
- package/skills/lead/references/project-documents.md +1 -1
package/dist/lead.mjs
CHANGED
|
@@ -966,13 +966,13 @@ var require_Collection = __commonJS({
|
|
|
966
966
|
var require_stringifyComment = __commonJS({
|
|
967
967
|
"node_modules/.pnpm/yaml@2.7.0/node_modules/yaml/dist/stringify/stringifyComment.js"(exports) {
|
|
968
968
|
"use strict";
|
|
969
|
-
var stringifyComment = (
|
|
969
|
+
var stringifyComment = (str3) => str3.replace(/^(?!$)(?: $)?/gm, "#");
|
|
970
970
|
function indentComment(comment, indent) {
|
|
971
971
|
if (/^\n+$/.test(comment))
|
|
972
972
|
return comment.substring(1);
|
|
973
973
|
return indent ? comment.replace(/^(?! *$)/gm, indent) : comment;
|
|
974
974
|
}
|
|
975
|
-
var lineComment = (
|
|
975
|
+
var lineComment = (str3, indent, comment) => str3.endsWith("\n") ? indentComment(comment, indent) : comment.includes("\n") ? "\n" + indentComment(comment, indent) : (str3.endsWith(" ") ? "" : " ") + comment;
|
|
976
976
|
exports.indentComment = indentComment;
|
|
977
977
|
exports.lineComment = lineComment;
|
|
978
978
|
exports.stringifyComment = stringifyComment;
|
|
@@ -1126,16 +1126,16 @@ var require_stringifyString = __commonJS({
|
|
|
1126
1126
|
lineWidth: ctx.options.lineWidth,
|
|
1127
1127
|
minContentWidth: ctx.options.minContentWidth
|
|
1128
1128
|
});
|
|
1129
|
-
var containsDocumentMarker = (
|
|
1130
|
-
function lineLengthOverLimit(
|
|
1129
|
+
var containsDocumentMarker = (str3) => /^(%|---|\.\.\.)/m.test(str3);
|
|
1130
|
+
function lineLengthOverLimit(str3, lineWidth, indentLength) {
|
|
1131
1131
|
if (!lineWidth || lineWidth < 0)
|
|
1132
1132
|
return false;
|
|
1133
1133
|
const limit = lineWidth - indentLength;
|
|
1134
|
-
const strLen =
|
|
1134
|
+
const strLen = str3.length;
|
|
1135
1135
|
if (strLen <= limit)
|
|
1136
1136
|
return false;
|
|
1137
1137
|
for (let i = 0, start = 0; i < strLen; ++i) {
|
|
1138
|
-
if (
|
|
1138
|
+
if (str3[i] === "\n") {
|
|
1139
1139
|
if (i - start > limit)
|
|
1140
1140
|
return true;
|
|
1141
1141
|
start = i + 1;
|
|
@@ -1152,11 +1152,11 @@ var require_stringifyString = __commonJS({
|
|
|
1152
1152
|
const { implicitKey } = ctx;
|
|
1153
1153
|
const minMultiLineLength = ctx.options.doubleQuotedMinMultiLineLength;
|
|
1154
1154
|
const indent = ctx.indent || (containsDocumentMarker(value) ? " " : "");
|
|
1155
|
-
let
|
|
1155
|
+
let str3 = "";
|
|
1156
1156
|
let start = 0;
|
|
1157
1157
|
for (let i = 0, ch = json[i]; ch; ch = json[++i]) {
|
|
1158
1158
|
if (ch === " " && json[i + 1] === "\\" && json[i + 2] === "n") {
|
|
1159
|
-
|
|
1159
|
+
str3 += json.slice(start, i) + "\\ ";
|
|
1160
1160
|
i += 1;
|
|
1161
1161
|
start = i;
|
|
1162
1162
|
ch = "\\";
|
|
@@ -1165,38 +1165,38 @@ var require_stringifyString = __commonJS({
|
|
|
1165
1165
|
switch (json[i + 1]) {
|
|
1166
1166
|
case "u":
|
|
1167
1167
|
{
|
|
1168
|
-
|
|
1168
|
+
str3 += json.slice(start, i);
|
|
1169
1169
|
const code = json.substr(i + 2, 4);
|
|
1170
1170
|
switch (code) {
|
|
1171
1171
|
case "0000":
|
|
1172
|
-
|
|
1172
|
+
str3 += "\\0";
|
|
1173
1173
|
break;
|
|
1174
1174
|
case "0007":
|
|
1175
|
-
|
|
1175
|
+
str3 += "\\a";
|
|
1176
1176
|
break;
|
|
1177
1177
|
case "000b":
|
|
1178
|
-
|
|
1178
|
+
str3 += "\\v";
|
|
1179
1179
|
break;
|
|
1180
1180
|
case "001b":
|
|
1181
|
-
|
|
1181
|
+
str3 += "\\e";
|
|
1182
1182
|
break;
|
|
1183
1183
|
case "0085":
|
|
1184
|
-
|
|
1184
|
+
str3 += "\\N";
|
|
1185
1185
|
break;
|
|
1186
1186
|
case "00a0":
|
|
1187
|
-
|
|
1187
|
+
str3 += "\\_";
|
|
1188
1188
|
break;
|
|
1189
1189
|
case "2028":
|
|
1190
|
-
|
|
1190
|
+
str3 += "\\L";
|
|
1191
1191
|
break;
|
|
1192
1192
|
case "2029":
|
|
1193
|
-
|
|
1193
|
+
str3 += "\\P";
|
|
1194
1194
|
break;
|
|
1195
1195
|
default:
|
|
1196
1196
|
if (code.substr(0, 2) === "00")
|
|
1197
|
-
|
|
1197
|
+
str3 += "\\x" + code.substr(2);
|
|
1198
1198
|
else
|
|
1199
|
-
|
|
1199
|
+
str3 += json.substr(i, 6);
|
|
1200
1200
|
}
|
|
1201
1201
|
i += 5;
|
|
1202
1202
|
start = i + 1;
|
|
@@ -1206,14 +1206,14 @@ var require_stringifyString = __commonJS({
|
|
|
1206
1206
|
if (implicitKey || json[i + 2] === '"' || json.length < minMultiLineLength) {
|
|
1207
1207
|
i += 1;
|
|
1208
1208
|
} else {
|
|
1209
|
-
|
|
1209
|
+
str3 += json.slice(start, i) + "\n\n";
|
|
1210
1210
|
while (json[i + 2] === "\\" && json[i + 3] === "n" && json[i + 4] !== '"') {
|
|
1211
|
-
|
|
1211
|
+
str3 += "\n";
|
|
1212
1212
|
i += 2;
|
|
1213
1213
|
}
|
|
1214
|
-
|
|
1214
|
+
str3 += indent;
|
|
1215
1215
|
if (json[i + 2] === " ")
|
|
1216
|
-
|
|
1216
|
+
str3 += "\\";
|
|
1217
1217
|
i += 1;
|
|
1218
1218
|
start = i + 1;
|
|
1219
1219
|
}
|
|
@@ -1222,8 +1222,8 @@ var require_stringifyString = __commonJS({
|
|
|
1222
1222
|
i += 1;
|
|
1223
1223
|
}
|
|
1224
1224
|
}
|
|
1225
|
-
|
|
1226
|
-
return implicitKey ?
|
|
1225
|
+
str3 = start ? str3 + json.slice(start) : json;
|
|
1226
|
+
return implicitKey ? str3 : foldFlowLines.foldFlowLines(str3, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx, false));
|
|
1227
1227
|
}
|
|
1228
1228
|
function singleQuotedString(value, ctx) {
|
|
1229
1229
|
if (ctx.options.singleQuote === false || ctx.implicitKey && value.includes("\n") || /[ \t]\n|\n[ \t]/.test(value))
|
|
@@ -1351,15 +1351,15 @@ ${indent}${start}${value}${end}`;
|
|
|
1351
1351
|
return quotedString(value, ctx);
|
|
1352
1352
|
}
|
|
1353
1353
|
}
|
|
1354
|
-
const
|
|
1354
|
+
const str3 = value.replace(/\n+/g, `$&
|
|
1355
1355
|
${indent}`);
|
|
1356
1356
|
if (actualString) {
|
|
1357
|
-
const test = (tag) => tag.default && tag.tag !== "tag:yaml.org,2002:str" && tag.test?.test(
|
|
1357
|
+
const test = (tag) => tag.default && tag.tag !== "tag:yaml.org,2002:str" && tag.test?.test(str3);
|
|
1358
1358
|
const { compat, tags } = ctx.doc.schema;
|
|
1359
1359
|
if (tags.some(test) || compat?.some(test))
|
|
1360
1360
|
return quotedString(value, ctx);
|
|
1361
1361
|
}
|
|
1362
|
-
return implicitKey ?
|
|
1362
|
+
return implicitKey ? str3 : foldFlowLines.foldFlowLines(str3, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false));
|
|
1363
1363
|
}
|
|
1364
1364
|
function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
1365
1365
|
const { implicitKey, inFlow } = ctx;
|
|
@@ -1488,7 +1488,7 @@ var require_stringify = __commonJS({
|
|
|
1488
1488
|
props.push(doc.directives.tagString(tag));
|
|
1489
1489
|
return props.join(" ");
|
|
1490
1490
|
}
|
|
1491
|
-
function
|
|
1491
|
+
function stringify3(item, ctx, onComment, onChompKeep) {
|
|
1492
1492
|
if (identity.isPair(item))
|
|
1493
1493
|
return item.toString(ctx, onComment, onChompKeep);
|
|
1494
1494
|
if (identity.isAlias(item)) {
|
|
@@ -1511,14 +1511,14 @@ var require_stringify = __commonJS({
|
|
|
1511
1511
|
const props = stringifyProps(node, tagObj, ctx);
|
|
1512
1512
|
if (props.length > 0)
|
|
1513
1513
|
ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
|
|
1514
|
-
const
|
|
1514
|
+
const str3 = typeof tagObj.stringify === "function" ? tagObj.stringify(node, ctx, onComment, onChompKeep) : identity.isScalar(node) ? stringifyString.stringifyString(node, ctx, onComment, onChompKeep) : node.toString(ctx, onComment, onChompKeep);
|
|
1515
1515
|
if (!props)
|
|
1516
|
-
return
|
|
1517
|
-
return identity.isScalar(node) ||
|
|
1518
|
-
${ctx.indent}${
|
|
1516
|
+
return str3;
|
|
1517
|
+
return identity.isScalar(node) || str3[0] === "{" || str3[0] === "[" ? `${props} ${str3}` : `${props}
|
|
1518
|
+
${ctx.indent}${str3}`;
|
|
1519
1519
|
}
|
|
1520
1520
|
exports.createStringifyContext = createStringifyContext;
|
|
1521
|
-
exports.stringify =
|
|
1521
|
+
exports.stringify = stringify3;
|
|
1522
1522
|
}
|
|
1523
1523
|
});
|
|
1524
1524
|
|
|
@@ -1528,7 +1528,7 @@ var require_stringifyPair = __commonJS({
|
|
|
1528
1528
|
"use strict";
|
|
1529
1529
|
var identity = require_identity();
|
|
1530
1530
|
var Scalar = require_Scalar();
|
|
1531
|
-
var
|
|
1531
|
+
var stringify3 = require_stringify();
|
|
1532
1532
|
var stringifyComment = require_stringifyComment();
|
|
1533
1533
|
function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
1534
1534
|
const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
|
|
@@ -1550,8 +1550,8 @@ var require_stringifyPair = __commonJS({
|
|
|
1550
1550
|
});
|
|
1551
1551
|
let keyCommentDone = false;
|
|
1552
1552
|
let chompKeep = false;
|
|
1553
|
-
let
|
|
1554
|
-
if (!explicitKey && !ctx.inFlow &&
|
|
1553
|
+
let str3 = stringify3.stringify(key, ctx, () => keyCommentDone = true, () => chompKeep = true);
|
|
1554
|
+
if (!explicitKey && !ctx.inFlow && str3.length > 1024) {
|
|
1555
1555
|
if (simpleKeys)
|
|
1556
1556
|
throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
|
|
1557
1557
|
explicitKey = true;
|
|
@@ -1560,27 +1560,27 @@ var require_stringifyPair = __commonJS({
|
|
|
1560
1560
|
if (allNullValues || value == null) {
|
|
1561
1561
|
if (keyCommentDone && onComment)
|
|
1562
1562
|
onComment();
|
|
1563
|
-
return
|
|
1563
|
+
return str3 === "" ? "?" : explicitKey ? `? ${str3}` : str3;
|
|
1564
1564
|
}
|
|
1565
1565
|
} else if (allNullValues && !simpleKeys || value == null && explicitKey) {
|
|
1566
|
-
|
|
1566
|
+
str3 = `? ${str3}`;
|
|
1567
1567
|
if (keyComment && !keyCommentDone) {
|
|
1568
|
-
|
|
1568
|
+
str3 += stringifyComment.lineComment(str3, ctx.indent, commentString(keyComment));
|
|
1569
1569
|
} else if (chompKeep && onChompKeep)
|
|
1570
1570
|
onChompKeep();
|
|
1571
|
-
return
|
|
1571
|
+
return str3;
|
|
1572
1572
|
}
|
|
1573
1573
|
if (keyCommentDone)
|
|
1574
1574
|
keyComment = null;
|
|
1575
1575
|
if (explicitKey) {
|
|
1576
1576
|
if (keyComment)
|
|
1577
|
-
|
|
1578
|
-
|
|
1577
|
+
str3 += stringifyComment.lineComment(str3, ctx.indent, commentString(keyComment));
|
|
1578
|
+
str3 = `? ${str3}
|
|
1579
1579
|
${indent}:`;
|
|
1580
1580
|
} else {
|
|
1581
|
-
|
|
1581
|
+
str3 = `${str3}:`;
|
|
1582
1582
|
if (keyComment)
|
|
1583
|
-
|
|
1583
|
+
str3 += stringifyComment.lineComment(str3, ctx.indent, commentString(keyComment));
|
|
1584
1584
|
}
|
|
1585
1585
|
let vsb, vcb, valueComment;
|
|
1586
1586
|
if (identity.isNode(value)) {
|
|
@@ -1596,13 +1596,13 @@ ${indent}:`;
|
|
|
1596
1596
|
}
|
|
1597
1597
|
ctx.implicitKey = false;
|
|
1598
1598
|
if (!explicitKey && !keyComment && identity.isScalar(value))
|
|
1599
|
-
ctx.indentAtStart =
|
|
1599
|
+
ctx.indentAtStart = str3.length + 1;
|
|
1600
1600
|
chompKeep = false;
|
|
1601
1601
|
if (!indentSeq && indentStep.length >= 2 && !ctx.inFlow && !explicitKey && identity.isSeq(value) && !value.flow && !value.tag && !value.anchor) {
|
|
1602
1602
|
ctx.indent = ctx.indent.substring(2);
|
|
1603
1603
|
}
|
|
1604
1604
|
let valueCommentDone = false;
|
|
1605
|
-
const valueStr =
|
|
1605
|
+
const valueStr = stringify3.stringify(value, ctx, () => valueCommentDone = true, () => chompKeep = true);
|
|
1606
1606
|
let ws = " ";
|
|
1607
1607
|
if (keyComment || vsb || vcb) {
|
|
1608
1608
|
ws = vsb ? "\n" : "";
|
|
@@ -1640,16 +1640,16 @@ ${ctx.indent}`;
|
|
|
1640
1640
|
} else if (valueStr === "" || valueStr[0] === "\n") {
|
|
1641
1641
|
ws = "";
|
|
1642
1642
|
}
|
|
1643
|
-
|
|
1643
|
+
str3 += ws + valueStr;
|
|
1644
1644
|
if (ctx.inFlow) {
|
|
1645
1645
|
if (valueCommentDone && onComment)
|
|
1646
1646
|
onComment();
|
|
1647
1647
|
} else if (valueComment && !valueCommentDone) {
|
|
1648
|
-
|
|
1648
|
+
str3 += stringifyComment.lineComment(str3, ctx.indent, commentString(valueComment));
|
|
1649
1649
|
} else if (chompKeep && onChompKeep) {
|
|
1650
1650
|
onChompKeep();
|
|
1651
1651
|
}
|
|
1652
|
-
return
|
|
1652
|
+
return str3;
|
|
1653
1653
|
}
|
|
1654
1654
|
exports.stringifyPair = stringifyPair;
|
|
1655
1655
|
}
|
|
@@ -1740,7 +1740,7 @@ var require_addPairToJSMap = __commonJS({
|
|
|
1740
1740
|
"use strict";
|
|
1741
1741
|
var log = require_log();
|
|
1742
1742
|
var merge = require_merge();
|
|
1743
|
-
var
|
|
1743
|
+
var stringify3 = require_stringify();
|
|
1744
1744
|
var identity = require_identity();
|
|
1745
1745
|
var toJS = require_toJS();
|
|
1746
1746
|
function addPairToJSMap(ctx, map, { key, value }) {
|
|
@@ -1776,7 +1776,7 @@ var require_addPairToJSMap = __commonJS({
|
|
|
1776
1776
|
if (typeof jsKey !== "object")
|
|
1777
1777
|
return String(jsKey);
|
|
1778
1778
|
if (identity.isNode(key) && ctx?.doc) {
|
|
1779
|
-
const strCtx =
|
|
1779
|
+
const strCtx = stringify3.createStringifyContext(ctx.doc, {});
|
|
1780
1780
|
strCtx.anchors = /* @__PURE__ */ new Set();
|
|
1781
1781
|
for (const node of ctx.anchors.keys())
|
|
1782
1782
|
strCtx.anchors.add(node.anchor);
|
|
@@ -1843,12 +1843,12 @@ var require_stringifyCollection = __commonJS({
|
|
|
1843
1843
|
"node_modules/.pnpm/yaml@2.7.0/node_modules/yaml/dist/stringify/stringifyCollection.js"(exports) {
|
|
1844
1844
|
"use strict";
|
|
1845
1845
|
var identity = require_identity();
|
|
1846
|
-
var
|
|
1846
|
+
var stringify3 = require_stringify();
|
|
1847
1847
|
var stringifyComment = require_stringifyComment();
|
|
1848
1848
|
function stringifyCollection(collection, ctx, options) {
|
|
1849
1849
|
const flow = ctx.inFlow ?? collection.flow;
|
|
1850
|
-
const
|
|
1851
|
-
return
|
|
1850
|
+
const stringify4 = flow ? stringifyFlowCollection : stringifyBlockCollection;
|
|
1851
|
+
return stringify4(collection, ctx, options);
|
|
1852
1852
|
}
|
|
1853
1853
|
function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, flowChars, itemIndent, onChompKeep, onComment }) {
|
|
1854
1854
|
const { indent, options: { commentString } } = ctx;
|
|
@@ -1873,31 +1873,31 @@ var require_stringifyCollection = __commonJS({
|
|
|
1873
1873
|
}
|
|
1874
1874
|
}
|
|
1875
1875
|
chompKeep = false;
|
|
1876
|
-
let
|
|
1876
|
+
let str4 = stringify3.stringify(item, itemCtx, () => comment2 = null, () => chompKeep = true);
|
|
1877
1877
|
if (comment2)
|
|
1878
|
-
|
|
1878
|
+
str4 += stringifyComment.lineComment(str4, itemIndent, commentString(comment2));
|
|
1879
1879
|
if (chompKeep && comment2)
|
|
1880
1880
|
chompKeep = false;
|
|
1881
|
-
lines.push(blockItemPrefix +
|
|
1881
|
+
lines.push(blockItemPrefix + str4);
|
|
1882
1882
|
}
|
|
1883
|
-
let
|
|
1883
|
+
let str3;
|
|
1884
1884
|
if (lines.length === 0) {
|
|
1885
|
-
|
|
1885
|
+
str3 = flowChars.start + flowChars.end;
|
|
1886
1886
|
} else {
|
|
1887
|
-
|
|
1887
|
+
str3 = lines[0];
|
|
1888
1888
|
for (let i = 1; i < lines.length; ++i) {
|
|
1889
1889
|
const line = lines[i];
|
|
1890
|
-
|
|
1890
|
+
str3 += line ? `
|
|
1891
1891
|
${indent}${line}` : "\n";
|
|
1892
1892
|
}
|
|
1893
1893
|
}
|
|
1894
1894
|
if (comment) {
|
|
1895
|
-
|
|
1895
|
+
str3 += "\n" + stringifyComment.indentComment(commentString(comment), indent);
|
|
1896
1896
|
if (onComment)
|
|
1897
1897
|
onComment();
|
|
1898
1898
|
} else if (chompKeep && onChompKeep)
|
|
1899
1899
|
onChompKeep();
|
|
1900
|
-
return
|
|
1900
|
+
return str3;
|
|
1901
1901
|
}
|
|
1902
1902
|
function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
|
|
1903
1903
|
const { indent, indentStep, flowCollectionPadding: fcPadding, options: { commentString } } = ctx;
|
|
@@ -1940,14 +1940,14 @@ ${indent}${line}` : "\n";
|
|
|
1940
1940
|
}
|
|
1941
1941
|
if (comment)
|
|
1942
1942
|
reqNewline = true;
|
|
1943
|
-
let
|
|
1943
|
+
let str3 = stringify3.stringify(item, itemCtx, () => comment = null);
|
|
1944
1944
|
if (i < items.length - 1)
|
|
1945
|
-
|
|
1945
|
+
str3 += ",";
|
|
1946
1946
|
if (comment)
|
|
1947
|
-
|
|
1948
|
-
if (!reqNewline && (lines.length > linesAtValue ||
|
|
1947
|
+
str3 += stringifyComment.lineComment(str3, itemIndent, commentString(comment));
|
|
1948
|
+
if (!reqNewline && (lines.length > linesAtValue || str3.includes("\n")))
|
|
1949
1949
|
reqNewline = true;
|
|
1950
|
-
lines.push(
|
|
1950
|
+
lines.push(str3);
|
|
1951
1951
|
linesAtValue = lines.length;
|
|
1952
1952
|
}
|
|
1953
1953
|
const { start, end } = flowChars;
|
|
@@ -1959,11 +1959,11 @@ ${indent}${line}` : "\n";
|
|
|
1959
1959
|
reqNewline = ctx.options.lineWidth > 0 && len > ctx.options.lineWidth;
|
|
1960
1960
|
}
|
|
1961
1961
|
if (reqNewline) {
|
|
1962
|
-
let
|
|
1962
|
+
let str3 = start;
|
|
1963
1963
|
for (const line of lines)
|
|
1964
|
-
|
|
1964
|
+
str3 += line ? `
|
|
1965
1965
|
${indentStep}${indent}${line}` : "\n";
|
|
1966
|
-
return `${
|
|
1966
|
+
return `${str3}
|
|
1967
1967
|
${indent}${end}`;
|
|
1968
1968
|
} else {
|
|
1969
1969
|
return `${start}${fcPadding}${lines.join(" ")}${fcPadding}${end}`;
|
|
@@ -2295,7 +2295,7 @@ var require_string = __commonJS({
|
|
|
2295
2295
|
identify: (value) => typeof value === "string",
|
|
2296
2296
|
default: true,
|
|
2297
2297
|
tag: "tag:yaml.org,2002:str",
|
|
2298
|
-
resolve: (
|
|
2298
|
+
resolve: (str3) => str3,
|
|
2299
2299
|
stringify(item, ctx, onComment, onChompKeep) {
|
|
2300
2300
|
ctx = Object.assign({ actualString: true }, ctx);
|
|
2301
2301
|
return stringifyString.stringifyString(item, ctx, onComment, onChompKeep);
|
|
@@ -2333,7 +2333,7 @@ var require_bool = __commonJS({
|
|
|
2333
2333
|
default: true,
|
|
2334
2334
|
tag: "tag:yaml.org,2002:bool",
|
|
2335
2335
|
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
2336
|
-
resolve: (
|
|
2336
|
+
resolve: (str3) => new Scalar.Scalar(str3[0] === "t" || str3[0] === "T"),
|
|
2337
2337
|
stringify({ source, value }, ctx) {
|
|
2338
2338
|
if (source && boolTag.test.test(source)) {
|
|
2339
2339
|
const sv = source[0] === "t" || source[0] === "T";
|
|
@@ -2385,7 +2385,7 @@ var require_float = __commonJS({
|
|
|
2385
2385
|
default: true,
|
|
2386
2386
|
tag: "tag:yaml.org,2002:float",
|
|
2387
2387
|
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
2388
|
-
resolve: (
|
|
2388
|
+
resolve: (str3) => str3.slice(-3).toLowerCase() === "nan" ? NaN : str3[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
2389
2389
|
stringify: stringifyNumber.stringifyNumber
|
|
2390
2390
|
};
|
|
2391
2391
|
var floatExp = {
|
|
@@ -2394,7 +2394,7 @@ var require_float = __commonJS({
|
|
|
2394
2394
|
tag: "tag:yaml.org,2002:float",
|
|
2395
2395
|
format: "EXP",
|
|
2396
2396
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
|
|
2397
|
-
resolve: (
|
|
2397
|
+
resolve: (str3) => parseFloat(str3),
|
|
2398
2398
|
stringify(node) {
|
|
2399
2399
|
const num = Number(node.value);
|
|
2400
2400
|
return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node);
|
|
@@ -2405,11 +2405,11 @@ var require_float = __commonJS({
|
|
|
2405
2405
|
default: true,
|
|
2406
2406
|
tag: "tag:yaml.org,2002:float",
|
|
2407
2407
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
|
|
2408
|
-
resolve(
|
|
2409
|
-
const node = new Scalar.Scalar(parseFloat(
|
|
2410
|
-
const dot =
|
|
2411
|
-
if (dot !== -1 &&
|
|
2412
|
-
node.minFractionDigits =
|
|
2408
|
+
resolve(str3) {
|
|
2409
|
+
const node = new Scalar.Scalar(parseFloat(str3));
|
|
2410
|
+
const dot = str3.indexOf(".");
|
|
2411
|
+
if (dot !== -1 && str3[str3.length - 1] === "0")
|
|
2412
|
+
node.minFractionDigits = str3.length - dot - 1;
|
|
2413
2413
|
return node;
|
|
2414
2414
|
},
|
|
2415
2415
|
stringify: stringifyNumber.stringifyNumber
|
|
@@ -2426,7 +2426,7 @@ var require_int = __commonJS({
|
|
|
2426
2426
|
"use strict";
|
|
2427
2427
|
var stringifyNumber = require_stringifyNumber();
|
|
2428
2428
|
var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
|
|
2429
|
-
var intResolve = (
|
|
2429
|
+
var intResolve = (str3, offset, radix, { intAsBigInt }) => intAsBigInt ? BigInt(str3) : parseInt(str3.substring(offset), radix);
|
|
2430
2430
|
function intStringify(node, radix, prefix) {
|
|
2431
2431
|
const { value } = node;
|
|
2432
2432
|
if (intIdentify(value) && value >= 0)
|
|
@@ -2439,7 +2439,7 @@ var require_int = __commonJS({
|
|
|
2439
2439
|
tag: "tag:yaml.org,2002:int",
|
|
2440
2440
|
format: "OCT",
|
|
2441
2441
|
test: /^0o[0-7]+$/,
|
|
2442
|
-
resolve: (
|
|
2442
|
+
resolve: (str3, _onError, opt) => intResolve(str3, 2, 8, opt),
|
|
2443
2443
|
stringify: (node) => intStringify(node, 8, "0o")
|
|
2444
2444
|
};
|
|
2445
2445
|
var int = {
|
|
@@ -2447,7 +2447,7 @@ var require_int = __commonJS({
|
|
|
2447
2447
|
default: true,
|
|
2448
2448
|
tag: "tag:yaml.org,2002:int",
|
|
2449
2449
|
test: /^[-+]?[0-9]+$/,
|
|
2450
|
-
resolve: (
|
|
2450
|
+
resolve: (str3, _onError, opt) => intResolve(str3, 0, 10, opt),
|
|
2451
2451
|
stringify: stringifyNumber.stringifyNumber
|
|
2452
2452
|
};
|
|
2453
2453
|
var intHex = {
|
|
@@ -2456,7 +2456,7 @@ var require_int = __commonJS({
|
|
|
2456
2456
|
tag: "tag:yaml.org,2002:int",
|
|
2457
2457
|
format: "HEX",
|
|
2458
2458
|
test: /^0x[0-9a-fA-F]+$/,
|
|
2459
|
-
resolve: (
|
|
2459
|
+
resolve: (str3, _onError, opt) => intResolve(str3, 2, 16, opt),
|
|
2460
2460
|
stringify: (node) => intStringify(node, 16, "0x")
|
|
2461
2461
|
};
|
|
2462
2462
|
exports.int = int;
|
|
@@ -2509,7 +2509,7 @@ var require_schema2 = __commonJS({
|
|
|
2509
2509
|
identify: (value) => typeof value === "string",
|
|
2510
2510
|
default: true,
|
|
2511
2511
|
tag: "tag:yaml.org,2002:str",
|
|
2512
|
-
resolve: (
|
|
2512
|
+
resolve: (str3) => str3,
|
|
2513
2513
|
stringify: stringifyJSON
|
|
2514
2514
|
},
|
|
2515
2515
|
{
|
|
@@ -2526,7 +2526,7 @@ var require_schema2 = __commonJS({
|
|
|
2526
2526
|
default: true,
|
|
2527
2527
|
tag: "tag:yaml.org,2002:bool",
|
|
2528
2528
|
test: /^true$|^false$/,
|
|
2529
|
-
resolve: (
|
|
2529
|
+
resolve: (str3) => str3 === "true",
|
|
2530
2530
|
stringify: stringifyJSON
|
|
2531
2531
|
},
|
|
2532
2532
|
{
|
|
@@ -2534,7 +2534,7 @@ var require_schema2 = __commonJS({
|
|
|
2534
2534
|
default: true,
|
|
2535
2535
|
tag: "tag:yaml.org,2002:int",
|
|
2536
2536
|
test: /^-?(?:0|[1-9][0-9]*)$/,
|
|
2537
|
-
resolve: (
|
|
2537
|
+
resolve: (str3, _onError, { intAsBigInt }) => intAsBigInt ? BigInt(str3) : parseInt(str3, 10),
|
|
2538
2538
|
stringify: ({ value }) => intIdentify(value) ? value.toString() : JSON.stringify(value)
|
|
2539
2539
|
},
|
|
2540
2540
|
{
|
|
@@ -2542,7 +2542,7 @@ var require_schema2 = __commonJS({
|
|
|
2542
2542
|
default: true,
|
|
2543
2543
|
tag: "tag:yaml.org,2002:float",
|
|
2544
2544
|
test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
|
|
2545
|
-
resolve: (
|
|
2545
|
+
resolve: (str3) => parseFloat(str3),
|
|
2546
2546
|
stringify: stringifyJSON
|
|
2547
2547
|
}
|
|
2548
2548
|
];
|
|
@@ -2550,9 +2550,9 @@ var require_schema2 = __commonJS({
|
|
|
2550
2550
|
default: true,
|
|
2551
2551
|
tag: "",
|
|
2552
2552
|
test: /^/,
|
|
2553
|
-
resolve(
|
|
2554
|
-
onError(`Unresolved plain scalar ${JSON.stringify(
|
|
2555
|
-
return
|
|
2553
|
+
resolve(str3, onError) {
|
|
2554
|
+
onError(`Unresolved plain scalar ${JSON.stringify(str3)}`);
|
|
2555
|
+
return str3;
|
|
2556
2556
|
}
|
|
2557
2557
|
};
|
|
2558
2558
|
var schema = [map.map, seq.seq].concat(jsonScalars, jsonError);
|
|
@@ -2584,10 +2584,10 @@ var require_binary = __commonJS({
|
|
|
2584
2584
|
if (typeof node_buffer.Buffer === "function") {
|
|
2585
2585
|
return node_buffer.Buffer.from(src, "base64");
|
|
2586
2586
|
} else if (typeof atob === "function") {
|
|
2587
|
-
const
|
|
2588
|
-
const buffer = new Uint8Array(
|
|
2589
|
-
for (let i = 0; i <
|
|
2590
|
-
buffer[i] =
|
|
2587
|
+
const str3 = atob(src.replace(/[\n\r]/g, ""));
|
|
2588
|
+
const buffer = new Uint8Array(str3.length);
|
|
2589
|
+
for (let i = 0; i < str3.length; ++i)
|
|
2590
|
+
buffer[i] = str3.charCodeAt(i);
|
|
2591
2591
|
return buffer;
|
|
2592
2592
|
} else {
|
|
2593
2593
|
onError("This environment does not support reading binary tags; either Buffer or atob is required");
|
|
@@ -2596,14 +2596,14 @@ var require_binary = __commonJS({
|
|
|
2596
2596
|
},
|
|
2597
2597
|
stringify({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
2598
2598
|
const buf = value;
|
|
2599
|
-
let
|
|
2599
|
+
let str3;
|
|
2600
2600
|
if (typeof node_buffer.Buffer === "function") {
|
|
2601
|
-
|
|
2601
|
+
str3 = buf instanceof node_buffer.Buffer ? buf.toString("base64") : node_buffer.Buffer.from(buf.buffer).toString("base64");
|
|
2602
2602
|
} else if (typeof btoa === "function") {
|
|
2603
2603
|
let s = "";
|
|
2604
2604
|
for (let i = 0; i < buf.length; ++i)
|
|
2605
2605
|
s += String.fromCharCode(buf[i]);
|
|
2606
|
-
|
|
2606
|
+
str3 = btoa(s);
|
|
2607
2607
|
} else {
|
|
2608
2608
|
throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");
|
|
2609
2609
|
}
|
|
@@ -2611,14 +2611,14 @@ var require_binary = __commonJS({
|
|
|
2611
2611
|
type = Scalar.Scalar.BLOCK_LITERAL;
|
|
2612
2612
|
if (type !== Scalar.Scalar.QUOTE_DOUBLE) {
|
|
2613
2613
|
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
|
|
2614
|
-
const n = Math.ceil(
|
|
2614
|
+
const n = Math.ceil(str3.length / lineWidth);
|
|
2615
2615
|
const lines = new Array(n);
|
|
2616
2616
|
for (let i = 0, o = 0; i < n; ++i, o += lineWidth) {
|
|
2617
|
-
lines[i] =
|
|
2617
|
+
lines[i] = str3.substr(o, lineWidth);
|
|
2618
2618
|
}
|
|
2619
|
-
|
|
2619
|
+
str3 = lines.join(type === Scalar.Scalar.BLOCK_LITERAL ? "\n" : " ");
|
|
2620
2620
|
}
|
|
2621
|
-
return stringifyString.stringifyString({ comment, type, value:
|
|
2621
|
+
return stringifyString.stringifyString({ comment, type, value: str3 }, ctx, onComment, onChompKeep);
|
|
2622
2622
|
}
|
|
2623
2623
|
};
|
|
2624
2624
|
exports.binary = binary;
|
|
@@ -2824,7 +2824,7 @@ var require_float2 = __commonJS({
|
|
|
2824
2824
|
default: true,
|
|
2825
2825
|
tag: "tag:yaml.org,2002:float",
|
|
2826
2826
|
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
2827
|
-
resolve: (
|
|
2827
|
+
resolve: (str3) => str3.slice(-3).toLowerCase() === "nan" ? NaN : str3[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
2828
2828
|
stringify: stringifyNumber.stringifyNumber
|
|
2829
2829
|
};
|
|
2830
2830
|
var floatExp = {
|
|
@@ -2833,7 +2833,7 @@ var require_float2 = __commonJS({
|
|
|
2833
2833
|
tag: "tag:yaml.org,2002:float",
|
|
2834
2834
|
format: "EXP",
|
|
2835
2835
|
test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
|
2836
|
-
resolve: (
|
|
2836
|
+
resolve: (str3) => parseFloat(str3.replace(/_/g, "")),
|
|
2837
2837
|
stringify(node) {
|
|
2838
2838
|
const num = Number(node.value);
|
|
2839
2839
|
return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node);
|
|
@@ -2844,11 +2844,11 @@ var require_float2 = __commonJS({
|
|
|
2844
2844
|
default: true,
|
|
2845
2845
|
tag: "tag:yaml.org,2002:float",
|
|
2846
2846
|
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
2847
|
-
resolve(
|
|
2848
|
-
const node = new Scalar.Scalar(parseFloat(
|
|
2849
|
-
const dot =
|
|
2847
|
+
resolve(str3) {
|
|
2848
|
+
const node = new Scalar.Scalar(parseFloat(str3.replace(/_/g, "")));
|
|
2849
|
+
const dot = str3.indexOf(".");
|
|
2850
2850
|
if (dot !== -1) {
|
|
2851
|
-
const f =
|
|
2851
|
+
const f = str3.substring(dot + 1).replace(/_/g, "");
|
|
2852
2852
|
if (f[f.length - 1] === "0")
|
|
2853
2853
|
node.minFractionDigits = f.length;
|
|
2854
2854
|
}
|
|
@@ -2868,34 +2868,34 @@ var require_int2 = __commonJS({
|
|
|
2868
2868
|
"use strict";
|
|
2869
2869
|
var stringifyNumber = require_stringifyNumber();
|
|
2870
2870
|
var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
|
|
2871
|
-
function intResolve(
|
|
2872
|
-
const sign =
|
|
2871
|
+
function intResolve(str3, offset, radix, { intAsBigInt }) {
|
|
2872
|
+
const sign = str3[0];
|
|
2873
2873
|
if (sign === "-" || sign === "+")
|
|
2874
2874
|
offset += 1;
|
|
2875
|
-
|
|
2875
|
+
str3 = str3.substring(offset).replace(/_/g, "");
|
|
2876
2876
|
if (intAsBigInt) {
|
|
2877
2877
|
switch (radix) {
|
|
2878
2878
|
case 2:
|
|
2879
|
-
|
|
2879
|
+
str3 = `0b${str3}`;
|
|
2880
2880
|
break;
|
|
2881
2881
|
case 8:
|
|
2882
|
-
|
|
2882
|
+
str3 = `0o${str3}`;
|
|
2883
2883
|
break;
|
|
2884
2884
|
case 16:
|
|
2885
|
-
|
|
2885
|
+
str3 = `0x${str3}`;
|
|
2886
2886
|
break;
|
|
2887
2887
|
}
|
|
2888
|
-
const n2 = BigInt(
|
|
2888
|
+
const n2 = BigInt(str3);
|
|
2889
2889
|
return sign === "-" ? BigInt(-1) * n2 : n2;
|
|
2890
2890
|
}
|
|
2891
|
-
const n = parseInt(
|
|
2891
|
+
const n = parseInt(str3, radix);
|
|
2892
2892
|
return sign === "-" ? -1 * n : n;
|
|
2893
2893
|
}
|
|
2894
2894
|
function intStringify(node, radix, prefix) {
|
|
2895
2895
|
const { value } = node;
|
|
2896
2896
|
if (intIdentify(value)) {
|
|
2897
|
-
const
|
|
2898
|
-
return value < 0 ? "-" + prefix +
|
|
2897
|
+
const str3 = value.toString(radix);
|
|
2898
|
+
return value < 0 ? "-" + prefix + str3.substr(1) : prefix + str3;
|
|
2899
2899
|
}
|
|
2900
2900
|
return stringifyNumber.stringifyNumber(node);
|
|
2901
2901
|
}
|
|
@@ -2905,7 +2905,7 @@ var require_int2 = __commonJS({
|
|
|
2905
2905
|
tag: "tag:yaml.org,2002:int",
|
|
2906
2906
|
format: "BIN",
|
|
2907
2907
|
test: /^[-+]?0b[0-1_]+$/,
|
|
2908
|
-
resolve: (
|
|
2908
|
+
resolve: (str3, _onError, opt) => intResolve(str3, 2, 2, opt),
|
|
2909
2909
|
stringify: (node) => intStringify(node, 2, "0b")
|
|
2910
2910
|
};
|
|
2911
2911
|
var intOct = {
|
|
@@ -2914,7 +2914,7 @@ var require_int2 = __commonJS({
|
|
|
2914
2914
|
tag: "tag:yaml.org,2002:int",
|
|
2915
2915
|
format: "OCT",
|
|
2916
2916
|
test: /^[-+]?0[0-7_]+$/,
|
|
2917
|
-
resolve: (
|
|
2917
|
+
resolve: (str3, _onError, opt) => intResolve(str3, 1, 8, opt),
|
|
2918
2918
|
stringify: (node) => intStringify(node, 8, "0")
|
|
2919
2919
|
};
|
|
2920
2920
|
var int = {
|
|
@@ -2922,7 +2922,7 @@ var require_int2 = __commonJS({
|
|
|
2922
2922
|
default: true,
|
|
2923
2923
|
tag: "tag:yaml.org,2002:int",
|
|
2924
2924
|
test: /^[-+]?[0-9][0-9_]*$/,
|
|
2925
|
-
resolve: (
|
|
2925
|
+
resolve: (str3, _onError, opt) => intResolve(str3, 0, 10, opt),
|
|
2926
2926
|
stringify: stringifyNumber.stringifyNumber
|
|
2927
2927
|
};
|
|
2928
2928
|
var intHex = {
|
|
@@ -2931,7 +2931,7 @@ var require_int2 = __commonJS({
|
|
|
2931
2931
|
tag: "tag:yaml.org,2002:int",
|
|
2932
2932
|
format: "HEX",
|
|
2933
2933
|
test: /^[-+]?0x[0-9a-fA-F_]+$/,
|
|
2934
|
-
resolve: (
|
|
2934
|
+
resolve: (str3, _onError, opt) => intResolve(str3, 2, 16, opt),
|
|
2935
2935
|
stringify: (node) => intStringify(node, 16, "0x")
|
|
2936
2936
|
};
|
|
2937
2937
|
exports.int = int;
|
|
@@ -3035,9 +3035,9 @@ var require_timestamp = __commonJS({
|
|
|
3035
3035
|
"node_modules/.pnpm/yaml@2.7.0/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js"(exports) {
|
|
3036
3036
|
"use strict";
|
|
3037
3037
|
var stringifyNumber = require_stringifyNumber();
|
|
3038
|
-
function parseSexagesimal(
|
|
3039
|
-
const sign =
|
|
3040
|
-
const parts = sign === "-" || sign === "+" ?
|
|
3038
|
+
function parseSexagesimal(str3, asBigInt) {
|
|
3039
|
+
const sign = str3[0];
|
|
3040
|
+
const parts = sign === "-" || sign === "+" ? str3.substring(1) : str3;
|
|
3041
3041
|
const num = (n) => asBigInt ? BigInt(n) : Number(n);
|
|
3042
3042
|
const res = parts.replace(/_/g, "").split(":").reduce((res2, p) => res2 * num(60) + num(p), num(0));
|
|
3043
3043
|
return sign === "-" ? num(-1) * res : res;
|
|
@@ -3074,7 +3074,7 @@ var require_timestamp = __commonJS({
|
|
|
3074
3074
|
tag: "tag:yaml.org,2002:int",
|
|
3075
3075
|
format: "TIME",
|
|
3076
3076
|
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
|
|
3077
|
-
resolve: (
|
|
3077
|
+
resolve: (str3, _onError, { intAsBigInt }) => parseSexagesimal(str3, intAsBigInt),
|
|
3078
3078
|
stringify: stringifySexagesimal
|
|
3079
3079
|
};
|
|
3080
3080
|
var floatTime = {
|
|
@@ -3083,7 +3083,7 @@ var require_timestamp = __commonJS({
|
|
|
3083
3083
|
tag: "tag:yaml.org,2002:float",
|
|
3084
3084
|
format: "TIME",
|
|
3085
3085
|
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
|
|
3086
|
-
resolve: (
|
|
3086
|
+
resolve: (str3) => parseSexagesimal(str3, false),
|
|
3087
3087
|
stringify: stringifySexagesimal
|
|
3088
3088
|
};
|
|
3089
3089
|
var timestamp = {
|
|
@@ -3094,8 +3094,8 @@ var require_timestamp = __commonJS({
|
|
|
3094
3094
|
// may be omitted altogether, resulting in a date format. In such a case, the time part is
|
|
3095
3095
|
// assumed to be 00:00:00Z (start of day, UTC).
|
|
3096
3096
|
test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),
|
|
3097
|
-
resolve(
|
|
3098
|
-
const match =
|
|
3097
|
+
resolve(str3) {
|
|
3098
|
+
const match = str3.match(timestamp.test);
|
|
3099
3099
|
if (!match)
|
|
3100
3100
|
throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
|
|
3101
3101
|
const [, year, month, day, hour, minute, second] = match.map(Number);
|
|
@@ -3293,7 +3293,7 @@ var require_stringifyDocument = __commonJS({
|
|
|
3293
3293
|
"node_modules/.pnpm/yaml@2.7.0/node_modules/yaml/dist/stringify/stringifyDocument.js"(exports) {
|
|
3294
3294
|
"use strict";
|
|
3295
3295
|
var identity = require_identity();
|
|
3296
|
-
var
|
|
3296
|
+
var stringify3 = require_stringify();
|
|
3297
3297
|
var stringifyComment = require_stringifyComment();
|
|
3298
3298
|
function stringifyDocument(doc, options) {
|
|
3299
3299
|
const lines = [];
|
|
@@ -3308,7 +3308,7 @@ var require_stringifyDocument = __commonJS({
|
|
|
3308
3308
|
}
|
|
3309
3309
|
if (hasDirectives)
|
|
3310
3310
|
lines.push("---");
|
|
3311
|
-
const ctx =
|
|
3311
|
+
const ctx = stringify3.createStringifyContext(doc, options);
|
|
3312
3312
|
const { commentString } = ctx.options;
|
|
3313
3313
|
if (doc.commentBefore) {
|
|
3314
3314
|
if (lines.length !== 1)
|
|
@@ -3330,7 +3330,7 @@ var require_stringifyDocument = __commonJS({
|
|
|
3330
3330
|
contentComment = doc.contents.comment;
|
|
3331
3331
|
}
|
|
3332
3332
|
const onChompKeep = contentComment ? void 0 : () => chompKeep = true;
|
|
3333
|
-
let body =
|
|
3333
|
+
let body = stringify3.stringify(doc.contents, ctx, () => contentComment = null, onChompKeep);
|
|
3334
3334
|
if (contentComment)
|
|
3335
3335
|
body += stringifyComment.lineComment(body, "", commentString(contentComment));
|
|
3336
3336
|
if ((body[0] === "|" || body[0] === ">") && lines[lines.length - 1] === "---") {
|
|
@@ -3338,7 +3338,7 @@ var require_stringifyDocument = __commonJS({
|
|
|
3338
3338
|
} else
|
|
3339
3339
|
lines.push(body);
|
|
3340
3340
|
} else {
|
|
3341
|
-
lines.push(
|
|
3341
|
+
lines.push(stringify3.stringify(doc.contents, ctx));
|
|
3342
3342
|
}
|
|
3343
3343
|
if (doc.directives?.docEnd) {
|
|
3344
3344
|
if (doc.comment) {
|
|
@@ -5468,7 +5468,7 @@ var require_cst_scalar = __commonJS({
|
|
|
5468
5468
|
var require_cst_stringify = __commonJS({
|
|
5469
5469
|
"node_modules/.pnpm/yaml@2.7.0/node_modules/yaml/dist/parse/cst-stringify.js"(exports) {
|
|
5470
5470
|
"use strict";
|
|
5471
|
-
var
|
|
5471
|
+
var stringify3 = (cst) => "type" in cst ? stringifyToken(cst) : stringifyItem(cst);
|
|
5472
5472
|
function stringifyToken(token) {
|
|
5473
5473
|
switch (token.type) {
|
|
5474
5474
|
case "block-scalar": {
|
|
@@ -5521,7 +5521,7 @@ var require_cst_stringify = __commonJS({
|
|
|
5521
5521
|
res += stringifyToken(value);
|
|
5522
5522
|
return res;
|
|
5523
5523
|
}
|
|
5524
|
-
exports.stringify =
|
|
5524
|
+
exports.stringify = stringify3;
|
|
5525
5525
|
}
|
|
5526
5526
|
});
|
|
5527
5527
|
|
|
@@ -7224,7 +7224,7 @@ var require_public_api = __commonJS({
|
|
|
7224
7224
|
}
|
|
7225
7225
|
return doc.toJS(Object.assign({ reviver: _reviver }, options));
|
|
7226
7226
|
}
|
|
7227
|
-
function
|
|
7227
|
+
function stringify3(value, replacer, options) {
|
|
7228
7228
|
let _replacer = null;
|
|
7229
7229
|
if (typeof replacer === "function" || Array.isArray(replacer)) {
|
|
7230
7230
|
_replacer = replacer;
|
|
@@ -7249,7 +7249,7 @@ var require_public_api = __commonJS({
|
|
|
7249
7249
|
exports.parse = parse4;
|
|
7250
7250
|
exports.parseAllDocuments = parseAllDocuments;
|
|
7251
7251
|
exports.parseDocument = parseDocument;
|
|
7252
|
-
exports.stringify =
|
|
7252
|
+
exports.stringify = stringify3;
|
|
7253
7253
|
}
|
|
7254
7254
|
});
|
|
7255
7255
|
|
|
@@ -7306,8 +7306,8 @@ var require_dist = __commonJS({
|
|
|
7306
7306
|
});
|
|
7307
7307
|
|
|
7308
7308
|
// src/cli.ts
|
|
7309
|
-
import { mkdirSync as
|
|
7310
|
-
import { dirname as
|
|
7309
|
+
import { mkdirSync as mkdirSync14, realpathSync as realpathSync5, writeFileSync as writeFileSync15 } from "node:fs";
|
|
7310
|
+
import { dirname as dirname6, join as join31, resolve as resolve3 } from "node:path";
|
|
7311
7311
|
import { fileURLToPath } from "node:url";
|
|
7312
7312
|
|
|
7313
7313
|
// src/check.ts
|
|
@@ -8092,7 +8092,8 @@ function parseTask(text, file) {
|
|
|
8092
8092
|
file,
|
|
8093
8093
|
criteria: parseCriteria(parsed.body),
|
|
8094
8094
|
...qa?.length ? { qa_required: qa } : {},
|
|
8095
|
-
...d.sync_jira === false ? { sync_jira: false } : {}
|
|
8095
|
+
...d.sync_jira === false ? { sync_jira: false } : {},
|
|
8096
|
+
...typeof d.repo === "string" && d.repo.trim() ? { repo: d.repo.trim() } : {}
|
|
8096
8097
|
},
|
|
8097
8098
|
issues
|
|
8098
8099
|
};
|
|
@@ -8207,9 +8208,9 @@ var TEMPLATES = {
|
|
|
8207
8208
|
"spec-04-acceptance.md": "---\nstage: acceptance\nstatus: draft\n---\n## 4. Acceptance\n\n<!-- Per scenario and screen: steps a browser can follow and what must be seen. Mark places that need a person as `needs human`. -->\n\n## Questions to earlier stages\n",
|
|
8208
8209
|
"task.md": '---\nid: T-001\ntitle: ""\nmilestone: mvp\ndemo: ""\nstatus: todo\ntype: feature\nblocked_by: []\ntouches: []\nqa_required: []\n# sync_jira: false # Keep this task outside Jira.\nwave: null\nclaim: null\nbranch: null\nchecks_run: null\nrounds: 0\nowner: ""\n---\n## Goal\n\n<!-- For FuseBase publication, write the full spec in work/task-specs/<task-id>.md using the task note template. -->\n<!-- For a new product feature, record its dedicated flag key, off fallback, dev-on and production-off settings. Add acceptance checks for both flag states. -->\n\n## Acceptance criteria\n\n- [not_tested] \n\n## Verification\n\n## Rounds\n\n## Summary\n',
|
|
8209
8210
|
"workspace-crew.md": "---\nname: crew-lead\ndescription: Run the lead workflow. Use only when the user invokes /crew-lead or $crew-lead.\n---\n<!-- evercrew:workspace-entry -->\nFollow the adjacent `../lead/SKILL.md` entry point as if the user invoked lead. Pass through the request and its arguments.\n",
|
|
8210
|
-
"workspace-entry.md": "---\nname: lead\ndescription: Run lead for this project or show the workspace overview. Use when the user types /lead or $lead, asks to use lead, or asks for an overview of all workspace projects.\n---\n<!-- evercrew:workspace-entry -->\
|
|
8211
|
+
"workspace-entry.md": "---\nname: lead\ndescription: Run lead for this project or show the workspace overview. Use when the user types /lead or $lead, asks to use lead, or asks for an overview of all workspace projects.\n---\n<!-- evercrew:workspace-entry -->\nIf the session context already names the lead launcher and kit, use them and skip the next two steps. Otherwise find the nearest `.lead/lead.mjs` from the directory this conversation started in. Preserve that starting directory as `--cwd` on the first call. Run `node <launcher> kit-path`, then read `skills/lead/SKILL.md` from the returned kit directory and follow it. References are relative to that kit directory. Keep the same session ID throughout this conversation. The launcher and kit path are local setup, not product state.\n",
|
|
8211
8212
|
"workspace-goal.md": "---\nname: lead-goal\ndescription: Record lead activity and keep the heartbeat for an active Cursor goal.\n---\n<!-- evercrew:workspace-entry -->\nRun `node .lead/lead.mjs kit-path` from the lead workspace or target checkout, then read `skills/lead-goal/SKILL.md` from the returned kit directory. Use the same repository scope and session ID as lead.\n",
|
|
8212
|
-
"workspace-launcher.mjs": "#!/usr/bin/env node\n// evercrew:workspace-entry\n// Portable entry point. The runtime belongs to the workspace or to the user's npm cache.\nimport { spawnSync } from 'node:child_process';\nimport { existsSync, mkdirSync, realpathSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst args = process.argv.slice(2);\nconst here = dirname(dirname(fileURLToPath(import.meta.url)));\nconst hook = args[0] === 'stop-check' || args[0] === 'session-start';\nconst cwdFlag = args.indexOf('--cwd');\nconst cwd = cwdFlag >= 0 && args[cwdFlag + 1] ? resolve(args[cwdFlag + 1]) : process.cwd();\nconst cli = (kit) => join(kit, 'dist/lead.mjs');\n\nfunction workspaceKit(start) {\n let dir = realpathSync(start);\n while (true) {\n if (existsSync(join(dir, '.lead/workspace.yml'))) {\n const kit = join(dir, '.lead/workspace-kit');\n if (existsSync(cli(kit))) return kit;\n if (hook) return;\n throw new Error(`The lead workspace at ${dir} has no runtime. Deploy its kit first.`);\n }\n if (dirname(dir) === dir) return;\n dir = dirname(dir);\n }\n}\n\nfunction run(bin, argv, diagnosticsOnly = false) {\n const result = spawnSync(bin, argv, { stdio: diagnosticsOnly ? ['inherit', 2, 2] : 'inherit', env: bin === 'npm' ? { ...process.env, 'npm_config_@fusebase:registry': 'https://registry.npmjs.org/' } : process.env });\n if (result.error) throw result.error;\n return result.status ?? 1;\n}\n\nfunction main() {\n const shared = workspaceKit(cwd) ?? workspaceKit(here);\n const installed = join(here, 'node_modules/@fusebase/harness-lead');\n const cache = join(process.env.XDG_CACHE_HOME || join(homedir(), '.cache'), 'harness-lead', 'standalone');\n const cached = join(cache, 'node_modules/@fusebase/harness-lead');\n let kit = shared ?? (existsSync(cli(cached)) ? cached : installed);\n if (!shared && (args[0] === 'update' || !existsSync(cli(kit)))) {\n if (hook) return 0;\n if (args[0] === 'update' && args.length > 1) throw new Error('Standalone launcher update refreshes the user cache. Run the chosen kit directly for an explicit source.');\n mkdirSync(cache, { recursive: true });\n const status = run('npm', ['install', '--prefix', cache, '--no-save', '--no-package-lock', '--ignore-scripts', '--no-audit', '--no-fund',\n args[0] === 'update' ? '@fusebase/harness-lead@latest' : '@fusebase/harness-lead@0.
|
|
8213
|
+
"workspace-launcher.mjs": "#!/usr/bin/env node\n// evercrew:workspace-entry\n// Portable entry point. The runtime belongs to the workspace or to the user's npm cache.\nimport { spawnSync } from 'node:child_process';\nimport { existsSync, mkdirSync, realpathSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst args = process.argv.slice(2);\nconst here = dirname(dirname(fileURLToPath(import.meta.url)));\nconst hook = args[0] === 'stop-check' || args[0] === 'session-start';\nconst cwdFlag = args.indexOf('--cwd');\nconst cwd = cwdFlag >= 0 && args[cwdFlag + 1] ? resolve(args[cwdFlag + 1]) : process.cwd();\nconst cli = (kit) => join(kit, 'dist/lead.mjs');\n\nfunction workspaceKit(start) {\n let dir = realpathSync(start);\n while (true) {\n if (existsSync(join(dir, '.lead/workspace.yml'))) {\n const kit = join(dir, '.lead/workspace-kit');\n if (existsSync(cli(kit))) return kit;\n if (hook) return;\n throw new Error(`The lead workspace at ${dir} has no runtime. Deploy its kit first.`);\n }\n if (dirname(dir) === dir) return;\n dir = dirname(dir);\n }\n}\n\nfunction run(bin, argv, diagnosticsOnly = false) {\n const result = spawnSync(bin, argv, { stdio: diagnosticsOnly ? ['inherit', 2, 2] : 'inherit', env: bin === 'npm' ? { ...process.env, 'npm_config_@fusebase:registry': 'https://registry.npmjs.org/' } : process.env });\n if (result.error) throw result.error;\n return result.status ?? 1;\n}\n\nfunction main() {\n const shared = workspaceKit(cwd) ?? workspaceKit(here);\n const installed = join(here, 'node_modules/@fusebase/harness-lead');\n const cache = join(process.env.XDG_CACHE_HOME || join(homedir(), '.cache'), 'harness-lead', 'standalone');\n const cached = join(cache, 'node_modules/@fusebase/harness-lead');\n let kit = shared ?? (existsSync(cli(cached)) ? cached : installed);\n if (!shared && (args[0] === 'update' || !existsSync(cli(kit)))) {\n if (hook) return 0;\n if (args[0] === 'update' && args.length > 1) throw new Error('Standalone launcher update refreshes the user cache. Run the chosen kit directly for an explicit source.');\n mkdirSync(cache, { recursive: true });\n const status = run('npm', ['install', '--prefix', cache, '--no-save', '--no-package-lock', '--ignore-scripts', '--no-audit', '--no-fund',\n args[0] === 'update' ? '@fusebase/harness-lead@latest' : '@fusebase/harness-lead@0.3.0'], true);\n if (status || !existsSync(cli(cached))) return status || 1;\n kit = cached;\n if (args[0] === 'update') return run(process.execPath, [cli(kit), 'version']);\n }\n if (args[0] === 'kit-path') {\n console.log(realpathSync(kit));\n return 0;\n }\n return run(process.execPath, [cli(kit), ...args]);\n}\n\ntry { process.exitCode = main(); }\ncatch (error) {\n if (!hook) console.error(`lead: ${error.message}`);\n process.exitCode = hook ? 0 : 1;\n}\n",
|
|
8213
8214
|
"backlog-index.md": '# <Project> Backlog\n\n[One Pager](one-pager.md)\n\n## Reviewed backlog\n\n<!-- evercrew:view kind="proposals" -->\n<!-- /evercrew:view -->\n\n## Needs triage\n\n<!-- For each candidate, link the task note and record what needs clarification. -->\n\n## Triage decisions\n\n<!-- Link source evidence and explain why an item was linked, completed, deferred or superseded. -->\n\n## History\n\n<!-- Link the complete source reconciliation, including repeated entries. -->\n',
|
|
8214
8215
|
"one-pager.md": '---\nmilestones:\n - id: mvp\n title: MVP\n shows: ""\n status: current\n---\n# <Project> \u2014 One Pager\n\n## Status now\n\n<!-- 3\u20134 sentences, written by a human. -->\n\n**What to show.**\n\n**What landed.**\n\n**Evidence.** <!-- Add the date, source revision, checks and open verification. -->\n\n<!-- evercrew:view kind="stats" -->\n<!-- /evercrew:view -->\n\n## Needs attention\n\n<!-- Decisions and immediate checks. Link the evidence and name the owner when known. -->\n\n## Product bet\n\n<!-- One sentence. -->\n\n## Research\n\nConclusions only. The long note is [the research](spec/01-research.md).\n\n<!-- Paste ### Conclusions from spec/01-research.md. Do not paste the rest. -->\n\n## Readiness\n\n<!-- evercrew:view kind="readiness" -->\n<!-- /evercrew:view -->\n\n## Roadmap\n\n<!-- evercrew:view kind="order" -->\n<!-- /evercrew:view -->\n\n## Next 3 steps\n\n<!-- evercrew:view kind="next-steps" -->\n<!-- /evercrew:view -->\n\n## Inbox triage\n\nTick an item when the team agrees to take it into the plan. Review higher priorities first, then use list order within each priority.\n\n<!-- Example: add real rows and remove this comment.\n:::checklist[Take into the plan]\n::check[:badge[Feature request]{tone="info"} :badge[High]{tone="danger"} Task summary \xB7 [Task note](tasks/T-001-example.md)]{done="false"}\n:::\n-->\n\n## Next versions (do not promise on a demo)\n\n## Reference\n\n- [Execution board](board.md)\n- [Backlog and triage decisions](backlog.md)\n<!-- Link history, architecture and QA evidence once available. -->\n',
|
|
8215
8216
|
"task-note.md": "# <Task summary>\n\n## Links\n\n<!-- Fill the links or document permitted exceptions before publishing. -->\n\n- [Epic](https://example.invalid/epic)\n- [Jira Story](https://example.invalid/story)\n- [Proposal](https://example.invalid/proposal)\n- [Mockup](https://example.invalid/mockup)\n- [One Pager](https://example.invalid/one-pager)\n\n## Goal\n\n<!-- Describe the user need and intended outcome. -->\n\n## User flow\n\n<!-- Add a Mermaid diagram covering the requested path. -->\n\n## Technical design\n\n<!-- Describe changes, interfaces, and relevant constraints. -->\n\n## Decisions\n\n<!-- Record agreed decisions and tradeoffs. -->\n\n## Acceptance criteria\n\n<!-- State observable checks and expected results. -->\n\n## Out of scope\n\n<!-- Name exclusions or say whether there are none. -->\n"
|
|
@@ -8287,7 +8288,7 @@ function ensureCodexHooks(root) {
|
|
|
8287
8288
|
}
|
|
8288
8289
|
|
|
8289
8290
|
// src/install.ts
|
|
8290
|
-
var VERSION = true ? "0.
|
|
8291
|
+
var VERSION = true ? "0.3.0" : "dev";
|
|
8291
8292
|
var LOCK_PATH = ".lead/kit.lock";
|
|
8292
8293
|
var SKILLS = ["lead", "crew-lead", "lead-goal"];
|
|
8293
8294
|
var SKILL_DIRS = [".agents/skills", ".claude/skills"];
|
|
@@ -8581,13 +8582,14 @@ function currentWave(tasks) {
|
|
|
8581
8582
|
return waves.length ? Math.min(...waves) : void 0;
|
|
8582
8583
|
}
|
|
8583
8584
|
var byOrder = (a, b) => (a.wave ?? 1e9) - (b.wave ?? 1e9) || a.id.localeCompare(b.id);
|
|
8585
|
+
var taskLink = (task) => `[${task.id}](${task.file.split("/").slice(-2).join("/")})`;
|
|
8584
8586
|
function renderBoard({ projectName: projectName2, tasks, onePager, config }) {
|
|
8585
8587
|
const byId = new Map(tasks.map((t) => [t.id, t]));
|
|
8586
8588
|
const ms = currentMilestone(onePager?.milestones ?? [], tasks);
|
|
8587
8589
|
const scope = ms ? tasks.filter((t) => t.milestone === ms.id) : tasks;
|
|
8588
8590
|
const wave = currentWave(scope);
|
|
8589
8591
|
const wip = tasks.filter((t) => t.status === "in_progress").length;
|
|
8590
|
-
const line = (t, extra = "") => `- ${t
|
|
8592
|
+
const line = (t, extra = "") => `- ${taskLink(t)} ${t.title}${t.owner ? ` \xB7 ${t.owner}` : ""}${t.delegate ? ` \u2192 ${t.delegate}${t.delegate_ref ? ` ${t.delegate_ref}` : ""}` : ""}${extra}`;
|
|
8591
8593
|
const section2 = (title, items) => [`## ${title}`, "", ...items.length ? items : ["- none"], ""];
|
|
8592
8594
|
const head = [
|
|
8593
8595
|
"<!-- Generated by lead. Do not edit: run `lead board`. -->",
|
|
@@ -8625,7 +8627,6 @@ function renderOnePagerBlocks(tasks, milestones, isMerged, showRule = "merged")
|
|
|
8625
8627
|
const byId = new Map(tasks.map((t) => [t.id, t]));
|
|
8626
8628
|
const ms = currentMilestone(milestones, tasks);
|
|
8627
8629
|
const msIndex = ms ? milestones.indexOf(ms) : -1;
|
|
8628
|
-
const link = (t) => `[${t.id}](${t.file.split("/").slice(-2).join("/")})`;
|
|
8629
8630
|
const shown = (t) => t.status === "done" && !!t.branch && isMerged(t.branch) && (showRule === "merged" || !!t.deployed);
|
|
8630
8631
|
const stats = milestones.map((m) => {
|
|
8631
8632
|
const scope2 = tasks.filter((t) => t.milestone === m.id);
|
|
@@ -8636,8 +8637,8 @@ function renderOnePagerBlocks(tasks, milestones, isMerged, showRule = "merged")
|
|
|
8636
8637
|
const basis = crit.length ? `${passed}/${crit.length} criteria` : `${scope2.filter((t) => t.status === "done").length}/${scope2.length} tasks`;
|
|
8637
8638
|
return `- ${m.title}: ${pct}% (${basis})`;
|
|
8638
8639
|
});
|
|
8639
|
-
const canShow = tasks.filter(shown).sort(byOrder).map((t) => `- ${showText(t)} (${
|
|
8640
|
-
const blocks = ms ? tasks.filter((t) => t.milestone === ms.id && !shown(t)).sort(byOrder).map((t) => `- ${showText(t)} (${
|
|
8640
|
+
const canShow = tasks.filter(shown).sort(byOrder).map((t) => `- ${showText(t)} (${taskLink(t)})`);
|
|
8641
|
+
const blocks = ms ? tasks.filter((t) => t.milestone === ms.id && !shown(t)).sort(byOrder).map((t) => `- ${showText(t)} (${taskLink(t)})`) : [];
|
|
8641
8642
|
const after = milestones.slice(msIndex + 1).filter((m) => m.status !== "done").map((m) => {
|
|
8642
8643
|
const n = tasks.filter((t) => t.milestone === m.id).length;
|
|
8643
8644
|
return `- ${m.title}: ${m.shows || "not described"}${n ? ` (${n} task${n === 1 ? "" : "s"})` : ""}`;
|
|
@@ -8749,14 +8750,21 @@ function findWorkspace(cwd) {
|
|
|
8749
8750
|
throw new Error(`${file}: expected version 1 and a repositories mapping`);
|
|
8750
8751
|
}
|
|
8751
8752
|
const destinations = /* @__PURE__ */ new Set();
|
|
8752
|
-
const
|
|
8753
|
+
const labels = {};
|
|
8754
|
+
const entries = Object.entries(repositories).map(([id, entry]) => {
|
|
8755
|
+
const path = typeof entry === "string" ? entry : entry?.path;
|
|
8753
8756
|
if (!ID2.test(id) || typeof path !== "string" || isAbsolute2(path)) throw new Error(`${file}: invalid repository ${id}`);
|
|
8757
|
+
if (typeof entry === "object" && entry) {
|
|
8758
|
+
const { title, apps = {} } = entry;
|
|
8759
|
+
if (title !== void 0 && typeof title !== "string" || typeof apps !== "object" || Array.isArray(apps) || !apps || Object.values(apps).some((t) => typeof t !== "string")) throw new Error(`${file}: invalid titles for ${id}`);
|
|
8760
|
+
labels[id] = { title, apps };
|
|
8761
|
+
}
|
|
8754
8762
|
const target = resolve2(root, path);
|
|
8755
8763
|
if (target === root || !within(root, target) || destinations.has(target)) throw new Error(`${file}: invalid or repeated checkout for ${id}`);
|
|
8756
8764
|
destinations.add(target);
|
|
8757
8765
|
return [id, target];
|
|
8758
8766
|
});
|
|
8759
|
-
return { root, repositories: Object.fromEntries(entries) };
|
|
8767
|
+
return { root, repositories: Object.fromEntries(entries), labels };
|
|
8760
8768
|
}
|
|
8761
8769
|
if (dirname3(root) === root) return void 0;
|
|
8762
8770
|
root = dirname3(root);
|
|
@@ -8825,10 +8833,16 @@ function routeScope(ws, cwd, session, repo, project) {
|
|
|
8825
8833
|
}
|
|
8826
8834
|
return { repo: chosen, cwd: local ? cwd : root, project: project ?? scope?.project, root };
|
|
8827
8835
|
}
|
|
8836
|
+
var readable = (name) => {
|
|
8837
|
+
const words = name.replace(/[-_]+/g, " ").trim();
|
|
8838
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
8839
|
+
};
|
|
8828
8840
|
function workspaceOverview(ws) {
|
|
8829
8841
|
const registered = new Set(Object.values(ws.repositories));
|
|
8830
8842
|
const candidates = readdirSync7(ws.root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && !registered.has(join14(ws.root, entry.name)) && existsSync13(join14(ws.root, entry.name, ".git"))).map((entry) => entry.name).sort();
|
|
8831
8843
|
const repositories = Object.keys(ws.repositories).map((id) => {
|
|
8844
|
+
const labels = ws.labels?.[id] ?? { apps: {} };
|
|
8845
|
+
const title = labels.title ?? readable(id);
|
|
8832
8846
|
try {
|
|
8833
8847
|
const root = repository(ws, id);
|
|
8834
8848
|
const base = loadContext(root);
|
|
@@ -8837,15 +8851,17 @@ function workspaceOverview(ws) {
|
|
|
8837
8851
|
const milestone = currentMilestone(ctx.onePager?.milestones ?? [], ctx.tasks);
|
|
8838
8852
|
return {
|
|
8839
8853
|
name: p.name,
|
|
8854
|
+
path: p.path,
|
|
8855
|
+
title: p.name === "." ? void 0 : labels.apps[p.name] ?? readable(p.name),
|
|
8840
8856
|
milestone: milestone?.title,
|
|
8841
8857
|
onePager: ctx.onePager && join14(root, ctx.onePager.file),
|
|
8842
8858
|
active: ctx.tasks.filter((t) => t.status === "in_progress" || t.status === "review").map((t) => ({ title: t.title, file: join14(root, t.file) })),
|
|
8843
8859
|
blocked: ctx.tasks.filter((t) => t.status === "blocked").map((t) => ({ title: t.title, file: join14(root, t.file) }))
|
|
8844
8860
|
};
|
|
8845
8861
|
});
|
|
8846
|
-
return { id, root, state: base.configExists ? "ready" : "not_configured", projects };
|
|
8862
|
+
return { id, title, root, state: base.configExists ? "ready" : "not_configured", projects };
|
|
8847
8863
|
} catch (error) {
|
|
8848
|
-
return { id, root: ws.repositories[id], state: "unavailable", reason: error.message, projects: [] };
|
|
8864
|
+
return { id, title, root: ws.repositories[id], state: "unavailable", reason: error.message, projects: [] };
|
|
8849
8865
|
}
|
|
8850
8866
|
});
|
|
8851
8867
|
return { root: ws.root, repositories, candidates };
|
|
@@ -8926,7 +8942,7 @@ function writeEntrypoints(root) {
|
|
|
8926
8942
|
|
|
8927
8943
|
// src/cli.ts
|
|
8928
8944
|
import { execFileSync as execFileSync6, spawnSync as spawnSync3 } from "node:child_process";
|
|
8929
|
-
import { existsSync as
|
|
8945
|
+
import { existsSync as existsSync29, mkdtempSync as mkdtempSync3, rmSync as rmSync6 } from "node:fs";
|
|
8930
8946
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
8931
8947
|
|
|
8932
8948
|
// src/mode.ts
|
|
@@ -9171,6 +9187,9 @@ function finishBlockers(ctx, t) {
|
|
|
9171
9187
|
}
|
|
9172
9188
|
function finishTask(ctx, t, opts) {
|
|
9173
9189
|
if (opts.merged) {
|
|
9190
|
+
if (!t.delegate && t.status !== "review" && t.status !== "done") {
|
|
9191
|
+
return { ok: false, message: `${t.id} is ${t.status}: hand it off (lead finish) before marking merged` };
|
|
9192
|
+
}
|
|
9174
9193
|
if (!t.branch || !(opts.isMerged?.(t.branch) ?? false)) return { ok: false, message: `${t.branch ?? t.id} is not merged yet` };
|
|
9175
9194
|
if (t.qa_required?.length && !runs(ctx.root).some((r) => r.kind === "task" && r.subject.project === ctx.project?.name && r.subject.task === t.id && r.subject.tree === t.checks_run?.commit && JSON.stringify(r.evidence.qa?.checks.map((c) => c.check)) === JSON.stringify(t.qa_required))) {
|
|
9176
9195
|
return { ok: false, message: "required browser QA needs a successful task handoff (lead finish) before marking merged" };
|
|
@@ -9464,6 +9483,38 @@ var NOTE_FILES = {
|
|
|
9464
9483
|
};
|
|
9465
9484
|
var isTaskNote = (key) => key.startsWith("tasks/") || key.startsWith("task-notes/");
|
|
9466
9485
|
var inArchive = (path) => /(?:^|[/\\])_?archive(?:[/\\]|$)/i.test(path);
|
|
9486
|
+
function activeNote(state, key) {
|
|
9487
|
+
const note = state.fusebase?.notes[key];
|
|
9488
|
+
return note && !inArchive(key) && !inArchive(note.path ?? "") ? note : void 0;
|
|
9489
|
+
}
|
|
9490
|
+
function adoptionMapping(ctx) {
|
|
9491
|
+
if (!ctx.project || ctx.config.planning !== "adopted") return [];
|
|
9492
|
+
const cfg = ctx.config.sync;
|
|
9493
|
+
const state = readSyncState(ctx.project.workDir);
|
|
9494
|
+
const rows = [];
|
|
9495
|
+
if (cfg?.fusebase) {
|
|
9496
|
+
const folder = state.fusebase?.folder;
|
|
9497
|
+
rows.push(folder && !inArchive(folder.title) ? `FuseBase product folder: ${folder.title} (${folder.id})` : "FuseBase product folder: no active mapping");
|
|
9498
|
+
if (!activeNote(state, "one-pager")) rows.push("FuseBase One Pager: no active mapping");
|
|
9499
|
+
for (const key of Object.keys(state.fusebase?.notes ?? {}).sort()) {
|
|
9500
|
+
const note = activeNote(state, key);
|
|
9501
|
+
if (note) rows.push(`FuseBase ${key}: ${note.title} (${note.id}, revision ${note.revision}) \u2014 ${key === "one-pager" || note.observeOnly ? "observe-only" : "managed"}`);
|
|
9502
|
+
}
|
|
9503
|
+
}
|
|
9504
|
+
if (cfg?.jira) {
|
|
9505
|
+
const story = state.jira?.story;
|
|
9506
|
+
rows.push(story ? `Jira Story (${story.key}) \u2014 ${story.observeOnly || !story.managed ? "observe-only" : "managed"}` : "Jira Story: unmapped");
|
|
9507
|
+
const tasks = new Map(ctx.tasks.map((task) => [task.id, task]));
|
|
9508
|
+
for (const [id, issue] of Object.entries(state.jira?.tasks ?? {}).sort(([a], [b]) => a.localeCompare(b))) {
|
|
9509
|
+
const task = tasks.get(id);
|
|
9510
|
+
const milestone = ctx.onePager?.milestones.find((m) => m.id === task?.milestone);
|
|
9511
|
+
const access = issue.observeOnly || !issue.managed ? "observe-only" : "managed";
|
|
9512
|
+
const observed = access === "observe-only" && issue.status ? ` \xB7 source status: ${issue.status}` : "";
|
|
9513
|
+
rows.push(`Jira ${task?.title ?? id} (${issue.key}) \u2014 ${access}${observed} \xB7 ${task ? `milestone: ${milestone?.title ?? task.milestone} \xB7 lead status: ${task.status}` : "no local task"}`);
|
|
9514
|
+
}
|
|
9515
|
+
}
|
|
9516
|
+
return rows;
|
|
9517
|
+
}
|
|
9467
9518
|
function fileUrl(links, path) {
|
|
9468
9519
|
if (!links?.repo) return void 0;
|
|
9469
9520
|
const p = posix.normalize(path).replace(/^\.\//, "");
|
|
@@ -9476,8 +9527,8 @@ function mergeRequestUrl(repo, branch) {
|
|
|
9476
9527
|
}
|
|
9477
9528
|
function remoteMarkdown(text, state, site, notes, links) {
|
|
9478
9529
|
const noteUrl2 = (key) => {
|
|
9479
|
-
const id = state
|
|
9480
|
-
return id && notes
|
|
9530
|
+
const id = activeNote(state, key)?.id;
|
|
9531
|
+
return id && notes ? `https://${notes.host}/space/${notes.workspace}/document/${id}` : void 0;
|
|
9481
9532
|
};
|
|
9482
9533
|
return text.replace(/^---\n[\s\S]*?\n---\n/, "").replace(/<!--[\s\S]*?-->\n?/g, "").replace(/\[(T-\d+)\]\([^)]*\)/g, (_m, id) => {
|
|
9483
9534
|
const taskNote = noteUrl2(`tasks/${id}`);
|
|
@@ -9666,10 +9717,10 @@ function taskSpecs(ctx, state) {
|
|
|
9666
9717
|
} catch {
|
|
9667
9718
|
}
|
|
9668
9719
|
}
|
|
9669
|
-
const onePager = state
|
|
9720
|
+
const onePager = activeNote(state, "one-pager");
|
|
9670
9721
|
const defaults = {
|
|
9671
9722
|
Epic: cfg.jira ? `https://${cfg.jira.site}/browse/${cfg.jira.epic}` : void 0,
|
|
9672
|
-
"One Pager": onePager
|
|
9723
|
+
"One Pager": onePager ? noteUrl(f, onePager.id) : fileUrl(cfg.links, posix.join(workDir, "one-pager.md"))
|
|
9673
9724
|
};
|
|
9674
9725
|
const linkLines = SPEC_LINKS.flatMap((label) => {
|
|
9675
9726
|
const url = links.get(label.toLowerCase()) ?? defaults[label];
|
|
@@ -9722,8 +9773,8 @@ function remoteOnePager(ctx, d, state, cfg) {
|
|
|
9722
9773
|
site: cfg.jira?.site,
|
|
9723
9774
|
keys: Object.fromEntries(Object.entries(state.jira?.tasks ?? {}).map(([id, t]) => [id, t.key]))
|
|
9724
9775
|
}, Object.fromEntries(ctx.tasks.flatMap((task) => {
|
|
9725
|
-
const note = state
|
|
9726
|
-
return note &&
|
|
9776
|
+
const note = activeNote(state, `tasks/${task.id}`);
|
|
9777
|
+
return note && cfg.fusebase ? [[task.id, { url: noteUrl(cfg.fusebase, note.id), evidenceVideo: note.evidenceVideo }]] : [];
|
|
9727
9778
|
})));
|
|
9728
9779
|
let text = replaceBlocks(d.text, (k) => blocks[k]);
|
|
9729
9780
|
if (!text.includes("```mermaid") && blocks.gantt) {
|
|
@@ -9812,9 +9863,12 @@ ${ev.map(([p, url]) => `- [${basename(p)}](${url})`).join("\n")}` : "",
|
|
|
9812
9863
|
].filter(Boolean).join("\n\n");
|
|
9813
9864
|
}
|
|
9814
9865
|
function storyDescription(ctx, state, cfg) {
|
|
9815
|
-
const status2 = ctx.onePager ? section(ctx.onePager.text, "Status") : "";
|
|
9866
|
+
const status2 = ctx.onePager ? section(ctx.onePager.text, "Status now") || section(ctx.onePager.text, "Status") : "";
|
|
9816
9867
|
const f = cfg.fusebase;
|
|
9817
|
-
const note = (
|
|
9868
|
+
const note = (key) => {
|
|
9869
|
+
const mapped = activeNote(state, key);
|
|
9870
|
+
return f && mapped ? noteUrl(f, mapped.id) : void 0;
|
|
9871
|
+
};
|
|
9818
9872
|
const work = ctx.project.path === "." ? "work" : `${ctx.project.path}/work`;
|
|
9819
9873
|
const links = [
|
|
9820
9874
|
note("one-pager") ? `[OnePager](${note("one-pager")})` : "",
|
|
@@ -9873,7 +9927,8 @@ function syncPlan(ctx) {
|
|
|
9873
9927
|
const actions = [];
|
|
9874
9928
|
const adopted = ctx.config.planning === "adopted";
|
|
9875
9929
|
const f = cfg.fusebase;
|
|
9876
|
-
const
|
|
9930
|
+
const onePager = activeNote(state, "one-pager");
|
|
9931
|
+
const onePagerUrl = f && onePager ? noteUrl(f, onePager.id) : void 0;
|
|
9877
9932
|
if (cfg.jira) {
|
|
9878
9933
|
const j = cfg.jira;
|
|
9879
9934
|
const story = state.jira?.story;
|
|
@@ -10091,7 +10146,7 @@ function writeBoard(ctx, isMerged = gitMergedChecker(ctx.root)) {
|
|
|
10091
10146
|
}
|
|
10092
10147
|
|
|
10093
10148
|
// src/cli.ts
|
|
10094
|
-
import { readFileSync as
|
|
10149
|
+
import { readFileSync as readFileSync26 } from "node:fs";
|
|
10095
10150
|
|
|
10096
10151
|
// src/cleanroom.ts
|
|
10097
10152
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -10496,25 +10551,645 @@ function oneLine2(s) {
|
|
|
10496
10551
|
return s.replace(/\s+/g, " ").trim();
|
|
10497
10552
|
}
|
|
10498
10553
|
|
|
10499
|
-
// src/
|
|
10554
|
+
// src/adapter.ts
|
|
10500
10555
|
import { existsSync as existsSync24, readdirSync as readdirSync12, readFileSync as readFileSync22 } from "node:fs";
|
|
10501
|
-
import { join as join26
|
|
10556
|
+
import { join as join26 } from "node:path";
|
|
10557
|
+
var ADAPTERS_DIR = ".lead/adapters";
|
|
10558
|
+
var ID3 = /^[a-z][a-z0-9-]*$/;
|
|
10559
|
+
function listAdapters(root) {
|
|
10560
|
+
const dir = join26(root, ADAPTERS_DIR);
|
|
10561
|
+
const adapters = [];
|
|
10562
|
+
const issues = [];
|
|
10563
|
+
if (!existsSync24(dir)) return { adapters, issues };
|
|
10564
|
+
for (const name of readdirSync12(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort()) {
|
|
10565
|
+
const rel = `${ADAPTERS_DIR}/${name}/SKILL.md`;
|
|
10566
|
+
const abs = join26(root, rel);
|
|
10567
|
+
if (!existsSync24(abs)) {
|
|
10568
|
+
issues.push(`${ADAPTERS_DIR}/${name}: no SKILL.md`);
|
|
10569
|
+
continue;
|
|
10570
|
+
}
|
|
10571
|
+
const { parsed } = parseFrontmatter(readFileSync22(abs, "utf8"), rel);
|
|
10572
|
+
const declared = typeof parsed?.data.name === "string" ? parsed.data.name : name;
|
|
10573
|
+
if (!ID3.test(name)) {
|
|
10574
|
+
issues.push(`${rel}: folder name must look like "private-space"`);
|
|
10575
|
+
} else if (declared !== name) {
|
|
10576
|
+
issues.push(`${rel}: name "${declared}" must match the folder "${name}"`);
|
|
10577
|
+
} else {
|
|
10578
|
+
adapters.push({
|
|
10579
|
+
id: name,
|
|
10580
|
+
title: typeof parsed?.data.title === "string" ? parsed.data.title : name,
|
|
10581
|
+
appliesTo: typeof parsed?.data.applies_to === "string" ? parsed.data.applies_to : "",
|
|
10582
|
+
file: rel
|
|
10583
|
+
});
|
|
10584
|
+
}
|
|
10585
|
+
}
|
|
10586
|
+
return { adapters, issues };
|
|
10587
|
+
}
|
|
10588
|
+
|
|
10589
|
+
// src/adopt.ts
|
|
10590
|
+
var import_yaml4 = __toESM(require_dist(), 1);
|
|
10591
|
+
import { existsSync as existsSync27, mkdirSync as mkdirSync13, readFileSync as readFileSync24, writeFileSync as writeFileSync14 } from "node:fs";
|
|
10592
|
+
import { dirname as dirname5, join as join29 } from "node:path";
|
|
10593
|
+
|
|
10594
|
+
// src/initiative.ts
|
|
10595
|
+
import { existsSync as existsSync26, readdirSync as readdirSync13, readFileSync as readFileSync23 } from "node:fs";
|
|
10596
|
+
import { join as join28 } from "node:path";
|
|
10597
|
+
|
|
10598
|
+
// src/initiative-tasks.ts
|
|
10599
|
+
import { existsSync as existsSync25 } from "node:fs";
|
|
10600
|
+
import { join as join27 } from "node:path";
|
|
10601
|
+
var REF = /^(?:([a-z][a-z0-9-]*):)?(T-\d{3,})$/;
|
|
10602
|
+
function parseRef(ref) {
|
|
10603
|
+
const m = REF.exec(ref);
|
|
10604
|
+
return m ? { ...m[1] ? { repo: m[1] } : {}, id: m[2] } : void 0;
|
|
10605
|
+
}
|
|
10606
|
+
var homeRepo = (i) => i.repos.find((r) => r.role === "home")?.name;
|
|
10607
|
+
var taskRepo = (t, i) => t.repo ?? homeRepo(i) ?? "";
|
|
10608
|
+
function loadInitiativeTasks(root, i) {
|
|
10609
|
+
return loadTasks(root, join27(root, i.dir));
|
|
10610
|
+
}
|
|
10611
|
+
function externalState(ws, repo, id) {
|
|
10612
|
+
if (!ws) return { state: "unresolved", reason: "no workspace catalog" };
|
|
10613
|
+
const path = ws.repositories[repo];
|
|
10614
|
+
if (!path) return { state: "unresolved", reason: `${repo} is not in the workspace` };
|
|
10615
|
+
if (!existsSync25(path)) return { state: "unresolved", reason: `checkout of ${repo} is missing` };
|
|
10616
|
+
try {
|
|
10617
|
+
const ctx = loadContext(path);
|
|
10618
|
+
if (!ctx.project) return { state: "unresolved", reason: `${repo} has no single lead project` };
|
|
10619
|
+
const t = ctx.tasks.find((x) => x.id === id);
|
|
10620
|
+
if (!t) return { state: "unresolved", reason: `${repo} has no task ${id}` };
|
|
10621
|
+
return { state: t.status === "done" ? "done" : "open" };
|
|
10622
|
+
} catch (error) {
|
|
10623
|
+
return { state: "unresolved", reason: error.message };
|
|
10624
|
+
}
|
|
10625
|
+
}
|
|
10626
|
+
function resolveRef(ref, tasks, ws) {
|
|
10627
|
+
const p = parseRef(ref);
|
|
10628
|
+
if (!p) return { ref, state: "unresolved", reason: "not a task reference" };
|
|
10629
|
+
if (!p.repo) return tasks.some((t) => t.id === p.id) ? { ref, state: "internal" } : { ref, state: "unresolved", reason: "no such task in this initiative" };
|
|
10630
|
+
return { ref, ...externalState(ws, p.repo, p.id) };
|
|
10631
|
+
}
|
|
10632
|
+
function scoped(tasks, i) {
|
|
10633
|
+
const ids = new Set(tasks.map((t) => t.id));
|
|
10634
|
+
return tasks.map((t) => ({
|
|
10635
|
+
...t,
|
|
10636
|
+
touches: t.touches.map((p) => `${taskRepo(t, i)}/${p.replace(/^\.\//, "")}`),
|
|
10637
|
+
blocked_by: t.blocked_by.filter((b) => ids.has(b))
|
|
10638
|
+
}));
|
|
10639
|
+
}
|
|
10640
|
+
function initiativeWaves(tasks, i) {
|
|
10641
|
+
return computeWaves(scoped(tasks, i), []);
|
|
10642
|
+
}
|
|
10643
|
+
function writeInitiativeWaves(root, i) {
|
|
10644
|
+
const { tasks } = loadInitiativeTasks(root, i);
|
|
10645
|
+
const waves = initiativeWaves(tasks, i);
|
|
10646
|
+
if (!waves) throw new Error("dependency cycle: fix blocked_by first (run `lead initiative check`)");
|
|
10647
|
+
const log = [];
|
|
10648
|
+
for (const t of tasks) {
|
|
10649
|
+
const w = waves.get(t.id);
|
|
10650
|
+
if (w === void 0 || w === t.wave || t.status === "done") continue;
|
|
10651
|
+
updateTask(root, t, (d) => {
|
|
10652
|
+
d.wave = w;
|
|
10653
|
+
});
|
|
10654
|
+
log.push(`${t.id}: wave ${t.wave ?? "-"} \u2192 ${w}`);
|
|
10655
|
+
}
|
|
10656
|
+
return log.length ? log : ["waves are up to date"];
|
|
10657
|
+
}
|
|
10658
|
+
function checkInitiative(root, i, ws) {
|
|
10659
|
+
const { tasks, issues } = loadInitiativeTasks(root, i);
|
|
10660
|
+
const out = [...issues];
|
|
10661
|
+
const repos = new Set(i.repos.map((r) => r.name));
|
|
10662
|
+
const home = homeRepo(i);
|
|
10663
|
+
const ms = new Set(loadOnePager(root, join27(root, i.dir)).onePager?.milestones.map((m) => m.id) ?? []);
|
|
10664
|
+
for (const t of tasks) {
|
|
10665
|
+
const e = (message, level = "error") => out.push({ level, file: t.file, message });
|
|
10666
|
+
if (t.repo ? !repos.has(t.repo) : !home) e(t.repo ? `repo "${t.repo}" is not listed in ${i.file}` : `no repo: the initiative has no home repository`);
|
|
10667
|
+
if (t.milestone && ms.size && !ms.has(t.milestone)) e(`milestone "${t.milestone}" is not defined in the initiative one-pager`);
|
|
10668
|
+
for (const ref of t.blocked_by) {
|
|
10669
|
+
const p = parseRef(ref);
|
|
10670
|
+
if (!p) e(`blocked_by ${ref}: use T-001 or <repo>:T-001`);
|
|
10671
|
+
else if (!p.repo && p.id === t.id) e(`${t.id} is blocked by itself`);
|
|
10672
|
+
else if (p.repo && !repos.has(p.repo)) e(`blocked_by ${ref}: repository ${p.repo} is not listed in ${i.file}`);
|
|
10673
|
+
else {
|
|
10674
|
+
const r = resolveRef(ref, tasks, ws);
|
|
10675
|
+
if (r.state === "unresolved") e(`blocked_by ${ref}: ${r.reason}`, p.repo ? "warning" : "error");
|
|
10676
|
+
}
|
|
10677
|
+
}
|
|
10678
|
+
if (t.touches.length === 0 && t.status !== "done") e("touches is empty: the task runs alone in its wave until its paths are known", "warning");
|
|
10679
|
+
}
|
|
10680
|
+
const sc = scoped(tasks, i);
|
|
10681
|
+
const byId = new Map(tasks.map((t) => [t.id, t]));
|
|
10682
|
+
for (const c of findCycles(sc)) out.push({ level: "error", file: byId.get(c[0]).file, message: `dependency cycle: ${c.join(" \u2192 ")}` });
|
|
10683
|
+
const waves = computeWaves(sc, []);
|
|
10684
|
+
const active = sc.filter((t) => t.status !== "done");
|
|
10685
|
+
for (const t of tasks) {
|
|
10686
|
+
if (t.wave === void 0) {
|
|
10687
|
+
if (t.status !== "done") out.push({ level: "warning", file: t.file, message: "wave not set; run `lead initiative waves <id> --write`" });
|
|
10688
|
+
continue;
|
|
10689
|
+
}
|
|
10690
|
+
for (const dep of t.blocked_by) {
|
|
10691
|
+
const d = byId.get(dep);
|
|
10692
|
+
if (d?.wave !== void 0 && d.wave >= t.wave) out.push({ level: "error", file: t.file, message: `blocked by ${dep} (wave ${d.wave}) but placed in wave ${t.wave}` });
|
|
10693
|
+
}
|
|
10694
|
+
const c = waves?.get(t.id);
|
|
10695
|
+
if (c !== void 0 && c !== t.wave && t.status !== "done") out.push({ level: "warning", file: t.file, message: `wave ${t.wave} differs from computed wave ${c}; run \`lead initiative waves <id> --write\`` });
|
|
10696
|
+
}
|
|
10697
|
+
for (let a = 0; a < active.length; a++) {
|
|
10698
|
+
for (let b = a + 1; b < active.length; b++) {
|
|
10699
|
+
const x = active[a];
|
|
10700
|
+
const y = active[b];
|
|
10701
|
+
if (x.wave === void 0 || x.wave !== y.wave) continue;
|
|
10702
|
+
const hits = touchesOverlap(x.touches, y.touches);
|
|
10703
|
+
if (hits.length) out.push({ level: "error", file: byId.get(y.id).file, message: `wave ${y.wave}: ${y.id} and ${x.id} touch the same paths (${hits.join(", ")})` });
|
|
10704
|
+
}
|
|
10705
|
+
}
|
|
10706
|
+
return out;
|
|
10707
|
+
}
|
|
10708
|
+
function initiativeTaskRows(root, i, ws) {
|
|
10709
|
+
const { tasks } = loadInitiativeTasks(root, i);
|
|
10710
|
+
return tasks.map((t) => ({
|
|
10711
|
+
id: t.id,
|
|
10712
|
+
title: t.title,
|
|
10713
|
+
repo: taskRepo(t, i),
|
|
10714
|
+
status: t.status,
|
|
10715
|
+
...t.wave !== void 0 ? { wave: t.wave } : {},
|
|
10716
|
+
...t.milestone ? { milestone: t.milestone } : {},
|
|
10717
|
+
blocked_by: t.blocked_by.map((b) => resolveRef(b, tasks, ws))
|
|
10718
|
+
}));
|
|
10719
|
+
}
|
|
10720
|
+
|
|
10721
|
+
// src/initiative.ts
|
|
10722
|
+
var INITIATIVES_DIR = "work/initiatives";
|
|
10723
|
+
var ID4 = /^[a-z][a-z0-9-]*$/;
|
|
10724
|
+
var ROLES = ["home", "reference"];
|
|
10725
|
+
var RESERVED = ["check", "waves"];
|
|
10726
|
+
var str = (v) => typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
10727
|
+
function loadInitiatives(root) {
|
|
10728
|
+
const base = join28(root, INITIATIVES_DIR);
|
|
10729
|
+
const initiatives = [];
|
|
10730
|
+
const issues = [];
|
|
10731
|
+
if (!existsSync26(base)) return { initiatives, issues };
|
|
10732
|
+
for (const entry of readdirSync13(base, { withFileTypes: true }).filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
10733
|
+
const dir = `${INITIATIVES_DIR}/${entry.name}`;
|
|
10734
|
+
const file = `${dir}/initiative.md`;
|
|
10735
|
+
const err = (message) => issues.push({ level: "error", file, message });
|
|
10736
|
+
const abs = join28(root, file);
|
|
10737
|
+
if (!existsSync26(abs)) {
|
|
10738
|
+
issues.push({ level: "warning", file: dir, message: "no initiative.md" });
|
|
10739
|
+
continue;
|
|
10740
|
+
}
|
|
10741
|
+
const { parsed, issues: parseIssues } = parseFrontmatter(readFileSync23(abs, "utf8"), file);
|
|
10742
|
+
issues.push(...parseIssues);
|
|
10743
|
+
if (!parsed) continue;
|
|
10744
|
+
const d = parsed.data;
|
|
10745
|
+
if (!ID4.test(entry.name) || RESERVED.includes(entry.name)) err('folder name must look like "private-space" and not be "check" or "waves"');
|
|
10746
|
+
if (str(d.id) !== entry.name) err(`id must equal the folder name "${entry.name}"`);
|
|
10747
|
+
const repos = [];
|
|
10748
|
+
if (d.repos !== void 0 && !Array.isArray(d.repos)) err("repos must be a list");
|
|
10749
|
+
for (const [i, r] of (Array.isArray(d.repos) ? d.repos : []).entries()) {
|
|
10750
|
+
const row = r ?? {};
|
|
10751
|
+
const name = str(row.name);
|
|
10752
|
+
const role = row.role === void 0 ? "reference" : row.role;
|
|
10753
|
+
if (!name || !ID4.test(name)) err(`repos[${i}].name must look like "org-service"`);
|
|
10754
|
+
else if (!ROLES.includes(role)) err(`repos[${i}].role must be one of ${ROLES.join(", ")}`);
|
|
10755
|
+
else if (repos.some((x) => x.name === name)) err(`repos[${i}]: "${name}" is listed twice`);
|
|
10756
|
+
else repos.push({ name, role, ...str(row.url) ? { url: str(row.url) } : {} });
|
|
10757
|
+
}
|
|
10758
|
+
if (repos.filter((r) => r.role === "home").length > 1) err("only one repository can be home");
|
|
10759
|
+
const map = {};
|
|
10760
|
+
if (d.map !== void 0 && (typeof d.map !== "object" || d.map === null || Array.isArray(d.map))) err("map must be a mapping from tracker key to a decision");
|
|
10761
|
+
for (const [key, v] of Object.entries(typeof d.map === "object" && d.map && !Array.isArray(d.map) ? d.map : {})) {
|
|
10762
|
+
const o = v ?? {};
|
|
10763
|
+
const bad = (m) => err(`map.${key}: ${m}`);
|
|
10764
|
+
if (!/^[A-Z][A-Z0-9]*-\d+$/.test(key)) bad("the key must look like KEY-123");
|
|
10765
|
+
else if (o.repo !== void 0 && (typeof o.repo !== "string" || !ID4.test(o.repo))) bad('repo must look like "org-service"');
|
|
10766
|
+
else if (typeof o.repo === "string" && !repos.some((r) => r.name === o.repo)) bad(`repo "${o.repo}" is not listed in repos`);
|
|
10767
|
+
else if (o.milestone !== void 0 && typeof o.milestone !== "string") bad("milestone must be a milestone id");
|
|
10768
|
+
else if (o.kind !== void 0 && !["work", "qa", "manual"].includes(o.kind)) bad("kind must be work, qa or manual");
|
|
10769
|
+
else map[key] = { ...o.repo ? { repo: o.repo } : {}, ...o.milestone ? { milestone: o.milestone } : {}, ...o.kind ? { kind: o.kind } : {} };
|
|
10770
|
+
}
|
|
10771
|
+
initiatives.push({
|
|
10772
|
+
id: entry.name,
|
|
10773
|
+
title: str(d.title) ?? entry.name,
|
|
10774
|
+
epic: str(d.epic),
|
|
10775
|
+
site: str(d.site),
|
|
10776
|
+
flag: str(d.flag),
|
|
10777
|
+
adapter: str(d.adapter),
|
|
10778
|
+
repos,
|
|
10779
|
+
map,
|
|
10780
|
+
dir,
|
|
10781
|
+
file
|
|
10782
|
+
});
|
|
10783
|
+
}
|
|
10784
|
+
return { initiatives, issues };
|
|
10785
|
+
}
|
|
10786
|
+
function optionalWorkspace(root) {
|
|
10787
|
+
try {
|
|
10788
|
+
return findWorkspace(root);
|
|
10789
|
+
} catch {
|
|
10790
|
+
return void 0;
|
|
10791
|
+
}
|
|
10792
|
+
}
|
|
10793
|
+
function observedCounts(root, i) {
|
|
10794
|
+
const file = join28(root, i.dir, "sync.json");
|
|
10795
|
+
if (!existsSync26(file)) return [];
|
|
10796
|
+
try {
|
|
10797
|
+
const issues = JSON.parse(readFileSync23(file, "utf8")).issues ?? {};
|
|
10798
|
+
const by = /* @__PURE__ */ new Map();
|
|
10799
|
+
for (const x of Object.values(issues)) {
|
|
10800
|
+
const m = x.milestone ?? "?";
|
|
10801
|
+
const row = by.get(m) ?? { milestone: m, total: 0, states: {} };
|
|
10802
|
+
row.total++;
|
|
10803
|
+
row.states[x.observed ?? "other"] = (row.states[x.observed ?? "other"] ?? 0) + 1;
|
|
10804
|
+
by.set(m, row);
|
|
10805
|
+
}
|
|
10806
|
+
return [...by.values()];
|
|
10807
|
+
} catch {
|
|
10808
|
+
return [];
|
|
10809
|
+
}
|
|
10810
|
+
}
|
|
10811
|
+
function initiativeOverview(root, i) {
|
|
10812
|
+
const ws = optionalWorkspace(root);
|
|
10813
|
+
const catalog = ws ? Object.entries(ws.repositories) : [];
|
|
10814
|
+
const op = loadOnePager(root, join28(root, i.dir));
|
|
10815
|
+
const adapters = i.adapter ? listAdapters(root).adapters : [];
|
|
10816
|
+
return {
|
|
10817
|
+
id: i.id,
|
|
10818
|
+
title: i.title,
|
|
10819
|
+
...i.epic ? { epic: i.epic } : {},
|
|
10820
|
+
...i.epic && i.site ? { epicUrl: `https://${i.site}/browse/${i.epic}` } : {},
|
|
10821
|
+
...i.flag ? { flag: i.flag } : {},
|
|
10822
|
+
...i.adapter ? { adapter: { name: i.adapter, state: adapters.some((a) => a.id === i.adapter) ? "found" : "missing" } } : {},
|
|
10823
|
+
...op.onePager ? { onePager: op.onePager.file } : {},
|
|
10824
|
+
milestones: op.onePager?.milestones ?? [],
|
|
10825
|
+
repos: i.repos.map((r) => {
|
|
10826
|
+
const path = catalog.find(([name]) => name === r.name)?.[1];
|
|
10827
|
+
const local = r.role === "home" ? "here" : !ws ? "no_workspace" : !path ? "not_in_workspace" : existsSync26(path) ? "available" : "missing";
|
|
10828
|
+
return { ...r, local };
|
|
10829
|
+
}),
|
|
10830
|
+
tasks: initiativeTaskRows(root, i, ws),
|
|
10831
|
+
observed: observedCounts(root, i)
|
|
10832
|
+
};
|
|
10833
|
+
}
|
|
10834
|
+
function observedRecords(root, i, repo) {
|
|
10835
|
+
const file = join28(root, i.dir, "sync.json");
|
|
10836
|
+
if (!existsSync26(file)) return [];
|
|
10837
|
+
try {
|
|
10838
|
+
const issues = JSON.parse(readFileSync23(file, "utf8")).issues ?? {};
|
|
10839
|
+
return Object.entries(issues).filter(([, x]) => !repo || x.repo === repo || (x.also ?? []).includes(repo)).map(([key, x]) => ({ key, ...x })).sort((a, b) => Number(a.key.split("-").pop()) - Number(b.key.split("-").pop()));
|
|
10840
|
+
} catch {
|
|
10841
|
+
return [];
|
|
10842
|
+
}
|
|
10843
|
+
}
|
|
10844
|
+
function renderInitiative(o) {
|
|
10845
|
+
const lines = [`${o.id} \u2014 ${o.title}${o.epic ? ` (${o.epic})` : ""}`];
|
|
10846
|
+
if (o.flag) lines.push(` flag: ${o.flag}`);
|
|
10847
|
+
if (o.adapter) lines.push(` adapter: ${o.adapter.name} (${o.adapter.state})`);
|
|
10848
|
+
lines.push(` one-pager: ${o.onePager ?? "none"}`);
|
|
10849
|
+
for (const m of o.milestones) lines.push(` milestone ${m.id} [${m.status}] ${m.title}${m.shows ? ` \u2014 ${m.shows}` : ""}`);
|
|
10850
|
+
for (const x of o.observed) lines.push(` observed ${x.milestone}: ${x.total} (${Object.entries(x.states).map(([k, v]) => `${k} ${v}`).join(", ")})`);
|
|
10851
|
+
for (const r of o.repos) lines.push(` repo ${r.name} (${r.role}) \u2014 ${r.local}`);
|
|
10852
|
+
for (const t of o.tasks) {
|
|
10853
|
+
const deps = t.blocked_by.map((b) => `${b.ref}${b.state === "internal" ? "" : ` ${b.state}`}`).join(", ");
|
|
10854
|
+
lines.push(` task ${t.id} [${t.status}]${t.wave ? ` w${t.wave}` : ""} ${t.repo} \u2014 ${t.title}${deps ? ` (after ${deps})` : ""}`);
|
|
10855
|
+
}
|
|
10856
|
+
return lines;
|
|
10857
|
+
}
|
|
10858
|
+
|
|
10859
|
+
// src/adopt.ts
|
|
10860
|
+
var REPO = /^[a-z][a-z0-9-]*$/;
|
|
10861
|
+
var keyNum = (key) => Number(/-(\d+)$/.exec(key)?.[1] ?? 0);
|
|
10862
|
+
function validateInventory(raw) {
|
|
10863
|
+
const errors = [];
|
|
10864
|
+
const r = raw ?? {};
|
|
10865
|
+
const str3 = (v) => typeof v === "string" && v.trim() !== "";
|
|
10866
|
+
if (!str3(r.site)) errors.push("site is required");
|
|
10867
|
+
const epic = r.epic;
|
|
10868
|
+
if (!epic || !str3(epic.key) || !str3(epic.summary)) errors.push("epic needs key and summary");
|
|
10869
|
+
const list = (name, need) => {
|
|
10870
|
+
const v = r[name];
|
|
10871
|
+
if (!Array.isArray(v)) return errors.push(`${name} must be a list`);
|
|
10872
|
+
v.forEach((x, i) => {
|
|
10873
|
+
for (const k of need) if (!str3(x?.[k])) errors.push(`${name}[${i}].${k} is required`);
|
|
10874
|
+
});
|
|
10875
|
+
};
|
|
10876
|
+
list("stories", ["key", "summary", "status"]);
|
|
10877
|
+
list("subtasks", ["key", "summary", "status", "parent"]);
|
|
10878
|
+
if (errors.length) return { errors };
|
|
10879
|
+
const subtasks = r.subtasks;
|
|
10880
|
+
const keys = subtasks.map((s) => s.key);
|
|
10881
|
+
const dup = keys.find((k, i) => keys.indexOf(k) !== i);
|
|
10882
|
+
if (dup) errors.push(`sub-task ${dup} is listed twice`);
|
|
10883
|
+
const storyKeys = new Set(r.stories.map((s) => s.key));
|
|
10884
|
+
for (const s of subtasks) if (!storyKeys.has(s.parent)) errors.push(`${s.key}: parent ${s.parent} is not in stories`);
|
|
10885
|
+
return errors.length ? { errors } : { inventory: r, errors };
|
|
10886
|
+
}
|
|
10887
|
+
function observedState(status2) {
|
|
10888
|
+
const n = status2.toLowerCase();
|
|
10889
|
+
if (/blocked/.test(n)) return "blocked";
|
|
10890
|
+
if (/review/.test(n)) return "review";
|
|
10891
|
+
if (/\b(done|closed|resolved|released)\b/.test(n)) return "done";
|
|
10892
|
+
if (/progress|doing|development/.test(n)) return "in_progress";
|
|
10893
|
+
if (/^(to do|todo|open|backlog|new)$/.test(n)) return "todo";
|
|
10894
|
+
return "other";
|
|
10895
|
+
}
|
|
10896
|
+
var kindOf = (summary) => ANY_QA.test(summary) ? "qa" : PERSON.test(summary) ? "manual" : "work";
|
|
10897
|
+
function parseTitle(summary) {
|
|
10898
|
+
const parts = summary.split(": ").map((p) => p.trim());
|
|
10899
|
+
const seg = parts.length >= 3 ? parts[1] : parts.length === 2 ? parts[0] : "";
|
|
10900
|
+
if (!seg) return { repos: [], reason: 'no "<repo>:" in the title' };
|
|
10901
|
+
const tokens = seg.split(/\s*(?:,|\/|\band\b)\s*/).filter(Boolean);
|
|
10902
|
+
if (!tokens.length || !tokens.every((t) => REPO.test(t))) return { repos: [], reason: `"${seg}" is not a repository name` };
|
|
10903
|
+
return { repos: tokens };
|
|
10904
|
+
}
|
|
10905
|
+
var QA = /\bQA stage (\d+)\b/i;
|
|
10906
|
+
var ANY_QA = /\bQA\b/;
|
|
10907
|
+
var PERSON = /\(person\)/i;
|
|
10908
|
+
function planRange(description) {
|
|
10909
|
+
const m = /\b[A-Z][A-Z0-9]*-(\d+)\b[^]{0,40}?\bto\b[^]{0,40}?\b[A-Z][A-Z0-9]*-(\d+)\b/.exec(description ?? "");
|
|
10910
|
+
return m ? [Number(m[1]), Number(m[2])] : void 0;
|
|
10911
|
+
}
|
|
10912
|
+
function goneRecords(previous, now) {
|
|
10913
|
+
const prev = previous ?? {};
|
|
10914
|
+
const out = {};
|
|
10915
|
+
for (const [key, v] of Object.entries(prev.gone ?? {})) if (!now[key]) out[key] = v;
|
|
10916
|
+
for (const [key, v] of Object.entries(prev.issues ?? {})) if (!now[key]) out[key] = { summary: v.summary ?? "", status: v.status ?? "" };
|
|
10917
|
+
return Object.fromEntries(Object.entries(out).sort(([a], [b]) => keyNum(a) - keyNum(b)));
|
|
10918
|
+
}
|
|
10919
|
+
function propose(inv, o) {
|
|
10920
|
+
const issues = {};
|
|
10921
|
+
const unmapped = [];
|
|
10922
|
+
const milestones = [];
|
|
10923
|
+
const withTasks = new Set(inv.subtasks.map((s) => s.parent));
|
|
10924
|
+
const scoped2 = withTasks.size > 1;
|
|
10925
|
+
for (const story of inv.stories.filter((s) => withTasks.has(s.key))) {
|
|
10926
|
+
const subs = inv.subtasks.filter((s) => s.parent === story.key).sort((a, b) => keyNum(a.key) - keyNum(b.key));
|
|
10927
|
+
const range = planRange(story.description);
|
|
10928
|
+
const prefix = scoped2 ? `${story.key.toLowerCase()}-` : "";
|
|
10929
|
+
const planned = subs.filter((s) => !range || keyNum(s.key) >= range[0] && keyNum(s.key) <= range[1]);
|
|
10930
|
+
const segments = [];
|
|
10931
|
+
let seg = { subs: [] };
|
|
10932
|
+
for (const s of planned) {
|
|
10933
|
+
seg.subs.push(s);
|
|
10934
|
+
const qa = QA.exec(s.summary);
|
|
10935
|
+
if (qa) {
|
|
10936
|
+
seg.qa = { n: Number(qa[1]), key: s.key };
|
|
10937
|
+
segments.push(seg);
|
|
10938
|
+
seg = { subs: [] };
|
|
10939
|
+
}
|
|
10940
|
+
}
|
|
10941
|
+
if (seg.subs.length) segments.push(seg);
|
|
10942
|
+
const lastStage = [...segments].reverse().find((x) => x.qa)?.qa?.n;
|
|
10943
|
+
let boundary;
|
|
10944
|
+
for (const sg of segments) {
|
|
10945
|
+
const [id, title] = sg.qa ? [`stage-${sg.qa.n}`, `Stage ${sg.qa.n}`] : lastStage !== void 0 ? [`after-stage-${lastStage}`, `After stage ${lastStage}`] : ["stage-1", "Stage 1"];
|
|
10946
|
+
const m = {
|
|
10947
|
+
id: `${prefix}${id}`,
|
|
10948
|
+
title: scoped2 ? `${story.key} ${title}` : title,
|
|
10949
|
+
shows: sg.qa ? subs.find((x) => x.key === sg.qa.key).summary.replace(/^.*?:\s*/, "") : "",
|
|
10950
|
+
issues: []
|
|
10951
|
+
};
|
|
10952
|
+
milestones.push(m);
|
|
10953
|
+
for (const s of sg.subs) {
|
|
10954
|
+
const kind = kindOf(s.summary);
|
|
10955
|
+
const t = parseTitle(s.summary);
|
|
10956
|
+
if (kind === "work" && !t.repos.length) unmapped.push({ key: s.key, reason: `repository: ${t.reason}` });
|
|
10957
|
+
issues[s.key] = {
|
|
10958
|
+
summary: s.summary,
|
|
10959
|
+
status: s.status,
|
|
10960
|
+
observed: observedState(s.status),
|
|
10961
|
+
story: story.key,
|
|
10962
|
+
kind,
|
|
10963
|
+
...kind !== "qa" && t.repos[0] ? { repo: t.repos[0] } : {},
|
|
10964
|
+
...kind !== "qa" && t.repos.length > 1 ? { also: t.repos.slice(1) } : {},
|
|
10965
|
+
milestone: m.id,
|
|
10966
|
+
...boundary ? { after: boundary } : {},
|
|
10967
|
+
observeOnly: true
|
|
10968
|
+
};
|
|
10969
|
+
m.issues.push(s.key);
|
|
10970
|
+
}
|
|
10971
|
+
if (sg.qa) boundary = sg.qa.key;
|
|
10972
|
+
}
|
|
10973
|
+
const outside = subs.filter((s) => !planned.includes(s));
|
|
10974
|
+
if (outside.length) {
|
|
10975
|
+
const id = `${prefix}outside-plan`;
|
|
10976
|
+
milestones.push({ id, title: scoped2 ? `${story.key} Outside the plan` : "Outside the plan", shows: "Sub-tasks added after the plan was written", issues: outside.map((s) => s.key) });
|
|
10977
|
+
for (const s of outside) {
|
|
10978
|
+
const t = parseTitle(s.summary);
|
|
10979
|
+
if (kindOf(s.summary) === "work" && !t.repos.length) unmapped.push({ key: s.key, reason: `repository: ${t.reason}` });
|
|
10980
|
+
issues[s.key] = {
|
|
10981
|
+
summary: s.summary,
|
|
10982
|
+
status: s.status,
|
|
10983
|
+
observed: observedState(s.status),
|
|
10984
|
+
story: story.key,
|
|
10985
|
+
kind: kindOf(s.summary),
|
|
10986
|
+
...t.repos[0] ? { repo: t.repos[0] } : {},
|
|
10987
|
+
...t.repos.length > 1 ? { also: t.repos.slice(1) } : {},
|
|
10988
|
+
milestone: id,
|
|
10989
|
+
observeOnly: true
|
|
10990
|
+
};
|
|
10991
|
+
}
|
|
10992
|
+
}
|
|
10993
|
+
}
|
|
10994
|
+
const decided = [];
|
|
10995
|
+
for (const [key, ov] of Object.entries(o.overrides ?? {})) {
|
|
10996
|
+
const it = issues[key];
|
|
10997
|
+
if (!it) continue;
|
|
10998
|
+
if (ov.milestone && ov.milestone !== it.milestone) {
|
|
10999
|
+
const to = milestones.find((m) => m.id === ov.milestone);
|
|
11000
|
+
if (!to) {
|
|
11001
|
+
unmapped.push({ key, reason: `decision: milestone "${ov.milestone}" does not exist` });
|
|
11002
|
+
continue;
|
|
11003
|
+
}
|
|
11004
|
+
const from = milestones.find((m) => m.id === it.milestone);
|
|
11005
|
+
if (from) from.issues = from.issues.filter((k) => k !== key);
|
|
11006
|
+
to.issues.push(key);
|
|
11007
|
+
to.issues.sort((a, b) => keyNum(a) - keyNum(b));
|
|
11008
|
+
it.milestone = to.id;
|
|
11009
|
+
}
|
|
11010
|
+
if (ov.kind) it.kind = ov.kind;
|
|
11011
|
+
if (ov.repo) {
|
|
11012
|
+
it.repo = ov.repo;
|
|
11013
|
+
delete it.also;
|
|
11014
|
+
}
|
|
11015
|
+
if (it.repo || it.kind !== "work") {
|
|
11016
|
+
const at = unmapped.findIndex((u) => u.key === key && u.reason.startsWith("repository:"));
|
|
11017
|
+
if (at >= 0) unmapped.splice(at, 1);
|
|
11018
|
+
}
|
|
11019
|
+
decided.push(key);
|
|
11020
|
+
}
|
|
11021
|
+
const counts = /* @__PURE__ */ new Map();
|
|
11022
|
+
for (const i of Object.values(issues)) for (const r of [i.repo, ...i.also ?? []]) if (r) counts.set(r, (counts.get(r) ?? 0) + 1);
|
|
11023
|
+
const repos = [{ name: o.home, role: "home", count: counts.get(o.home) ?? 0 }];
|
|
11024
|
+
for (const [name, count] of [...counts].sort(([a], [b]) => a.localeCompare(b))) if (name !== o.home) repos.push({ name, role: "reference", count });
|
|
11025
|
+
const statusCounts = /* @__PURE__ */ new Map();
|
|
11026
|
+
for (const i of Object.values(issues)) statusCounts.set(i.status, (statusCounts.get(i.status) ?? 0) + 1);
|
|
11027
|
+
const statuses = [...statusCounts].sort(([a], [b]) => a.localeCompare(b)).map(([name, count]) => ({ name, observed: observedState(name), count }));
|
|
11028
|
+
for (const s of statuses) if (s.observed === "other") unmapped.push({ key: `status:${s.name}`, reason: "status has no known meaning; add it to the adapter" });
|
|
11029
|
+
const mapped = new Set(Object.keys(issues));
|
|
11030
|
+
for (const s of inv.subtasks) if (!mapped.has(s.key)) unmapped.push({ key: s.key, reason: "sub-task was not placed in any milestone" });
|
|
11031
|
+
const flag = o.flag ?? inv.flag;
|
|
11032
|
+
return {
|
|
11033
|
+
id: o.id,
|
|
11034
|
+
title: o.title ?? inv.epic.summary,
|
|
11035
|
+
site: inv.site,
|
|
11036
|
+
epic: inv.epic,
|
|
11037
|
+
home: o.home,
|
|
11038
|
+
...flag ? { flag } : {},
|
|
11039
|
+
repos,
|
|
11040
|
+
milestones,
|
|
11041
|
+
issues,
|
|
11042
|
+
stories: Object.fromEntries(inv.stories.map((s) => [s.key, { summary: s.summary, status: s.status, observed: observedState(s.status), observeOnly: true }])),
|
|
11043
|
+
statuses,
|
|
11044
|
+
unmapped,
|
|
11045
|
+
decided,
|
|
11046
|
+
gone: goneRecords(o.previous, issues)
|
|
11047
|
+
};
|
|
11048
|
+
}
|
|
11049
|
+
function renderProposal(p) {
|
|
11050
|
+
const lines = [`adopt ${p.epic.key} "${p.epic.summary}" as initiative ${p.id} (home: ${p.home}${p.flag ? `, flag: ${p.flag}` : ""})`, "", "Milestones (inferred, Jira statuses are observations only):"];
|
|
11051
|
+
for (const m of p.milestones) lines.push(` ${m.id} \u2014 ${m.title}${m.shows ? ` \u2014 ${m.shows}` : ""}: ${m.issues.length} sub-tasks (${m.issues[0]} \u2026 ${m.issues.at(-1)})`);
|
|
11052
|
+
lines.push("", "Repositories:");
|
|
11053
|
+
for (const r of p.repos) lines.push(` ${r.name} (${r.role}) \u2014 ${r.count} sub-task${r.count === 1 ? "" : "s"}${r.role === "reference" ? "; lead is not installed there" : ""}`);
|
|
11054
|
+
lines.push("", "Observed statuses:");
|
|
11055
|
+
for (const s of p.statuses) lines.push(` ${s.name} \u2192 ${s.observed}: ${s.count}`);
|
|
11056
|
+
const manual = Object.entries(p.issues).filter(([, i]) => i.kind === "manual").map(([k]) => k);
|
|
11057
|
+
if (manual.length) lines.push("", `Need a person: ${manual.join(", ")}`);
|
|
11058
|
+
if (p.decided.length) lines.push("", `Decisions applied from initiative.md: ${p.decided.join(", ")}`);
|
|
11059
|
+
lines.push("", p.unmapped.length ? `Need a decision (${p.unmapped.length}):` : "Nothing unmapped.");
|
|
11060
|
+
for (const u of p.unmapped) lines.push(` ${u.key}: ${u.reason}`);
|
|
11061
|
+
return lines;
|
|
11062
|
+
}
|
|
11063
|
+
function diffObserved(previous, p) {
|
|
11064
|
+
const prev = (previous ?? {}).issues ?? {};
|
|
11065
|
+
const diff = { added: [], removed: [], changed: [] };
|
|
11066
|
+
for (const key of Object.keys(p.issues)) {
|
|
11067
|
+
const was = prev[key];
|
|
11068
|
+
if (!was) {
|
|
11069
|
+
diff.added.push(key);
|
|
11070
|
+
continue;
|
|
11071
|
+
}
|
|
11072
|
+
const now = p.issues[key];
|
|
11073
|
+
const what = ["summary", "status", "repo", "milestone", "kind"].filter((f) => (was[f] ?? void 0) !== (now[f] ?? void 0));
|
|
11074
|
+
if (what.length) diff.changed.push({ key, what: what.map((f) => `${f}: ${String(was[f] ?? "-")} \u2192 ${String(now[f] ?? "-")}`) });
|
|
11075
|
+
}
|
|
11076
|
+
for (const key of Object.keys(prev)) if (!p.issues[key]) diff.removed.push(key);
|
|
11077
|
+
return diff;
|
|
11078
|
+
}
|
|
11079
|
+
function renderDiff(d) {
|
|
11080
|
+
if (!d.added.length && !d.removed.length && !d.changed.length) return ["Since the last run: no changes."];
|
|
11081
|
+
const lines = ["Since the last run:"];
|
|
11082
|
+
if (d.added.length) lines.push(` new: ${d.added.join(", ")}`);
|
|
11083
|
+
if (d.removed.length) lines.push(` gone from the epic: ${d.removed.join(", ")} (kept under "gone" in sync.json)`);
|
|
11084
|
+
for (const c of d.changed) lines.push(` ${c.key}: ${c.what.join("; ")}`);
|
|
11085
|
+
return lines;
|
|
11086
|
+
}
|
|
11087
|
+
function adapterText(p) {
|
|
11088
|
+
const fm = (0, import_yaml4.stringify)({ name: p.id, title: p.title, applies_to: `Epic ${p.epic.key} (${p.epic.summary}) on ${p.site}` }).trimEnd();
|
|
11089
|
+
return `---
|
|
11090
|
+
${fm}
|
|
11091
|
+
---
|
|
11092
|
+
# Adapter: ${p.title}
|
|
11093
|
+
|
|
11094
|
+
Rules for reading the existing records of epic ${p.epic.key}. Generated by \`lead adopt\`; edit by hand if the rules are wrong. A new \`adopt\` run keeps this file when it differs. Facts about delegated services stay in their delegate skills.
|
|
11095
|
+
|
|
11096
|
+
## Source
|
|
11097
|
+
|
|
11098
|
+
- Tracker: https://${p.site}/browse/${p.epic.key}
|
|
11099
|
+
- Initiative: \`${INITIATIVES_DIR}/${p.id}/\`; observed records: \`${INITIATIVES_DIR}/${p.id}/sync.json\`.
|
|
11100
|
+
- Every tracker record here is **observe-only**. A tracker status never sets a lead status or marks a task done. Only \`finish\` does.
|
|
11101
|
+
|
|
11102
|
+
## Reading rules
|
|
11103
|
+
|
|
11104
|
+
- Repository: the second part of a sub-task title "Feature: <repo>: text", or the first part of "<repo>: text". Several names ("a and b", "a, b", "a/b") mean one main repository (the first) and the others as \`also\`. A title without a lowercase repository name needs a person's decision.
|
|
11105
|
+
- Milestones: sub-tasks are ordered by key. A sub-task titled "QA stage N" closes stage N. Sub-tasks after the last stage and inside the plan range belong to "after stage N". When the story description gives a range ("KEY-1 to KEY-9"), sub-tasks outside it are "outside the plan".
|
|
11106
|
+
- Order: a milestone is ordered after the previous stage's QA sub-task (\`after\` in the observed records). This is a hint, not a lead dependency.
|
|
11107
|
+
- Kinds: "QA stage N" is \`qa\`; a title with "(person)" is \`manual\` and needs a person.
|
|
11108
|
+
- Statuses: "blocked" \u2192 blocked, "review" \u2192 review, "to do" \u2192 todo, "progress" \u2192 in_progress, "done/closed/resolved" \u2192 done, anything else \u2192 other (needs a decision).
|
|
11109
|
+
|
|
11110
|
+
## Repositories
|
|
11111
|
+
|
|
11112
|
+
Home: ${p.home}. Other repositories are references: named, not installed.
|
|
11113
|
+
|
|
11114
|
+
${p.repos.map((r) => `- ${r.name} (${r.role})`).join("\n")}
|
|
11115
|
+
`;
|
|
11116
|
+
}
|
|
11117
|
+
function initiativeText(p) {
|
|
11118
|
+
const fm = (0, import_yaml4.stringify)({
|
|
11119
|
+
id: p.id,
|
|
11120
|
+
title: p.title,
|
|
11121
|
+
epic: p.epic.key,
|
|
11122
|
+
site: p.site,
|
|
11123
|
+
...p.flag ? { flag: p.flag } : {},
|
|
11124
|
+
adapter: p.id,
|
|
11125
|
+
repos: p.repos.map((r) => ({ name: r.name, role: r.role }))
|
|
11126
|
+
}).trimEnd();
|
|
11127
|
+
return `---
|
|
11128
|
+
${fm}
|
|
11129
|
+
---
|
|
11130
|
+
# ${p.title}
|
|
11131
|
+
|
|
11132
|
+
Adopted from ${p.epic.key}. Milestones and observed records are in \`one-pager.md\` and \`sync.json\`.
|
|
11133
|
+
|
|
11134
|
+
To settle a record that \`lead adopt\` could not place, or to override a guess, add a \`map:\` entry to the frontmatter, for example \`map: {KEY-123: {repo: org-service, milestone: stage-2}}\`. It survives every later run; the repository must be listed in \`repos\`.
|
|
11135
|
+
`;
|
|
11136
|
+
}
|
|
11137
|
+
function onePagerText(p) {
|
|
11138
|
+
const fm = (0, import_yaml4.stringify)({
|
|
11139
|
+
milestones: p.milestones.map((m, i) => ({ id: m.id, title: m.title, ...m.shows ? { shows: m.shows } : {}, status: i === 0 ? "current" : "next" }))
|
|
11140
|
+
}).trimEnd();
|
|
11141
|
+
return `---
|
|
11142
|
+
${fm}
|
|
11143
|
+
---
|
|
11144
|
+
# ${p.title} \u2014 One Pager
|
|
11145
|
+
|
|
11146
|
+
Human text goes here. Milestone status is lead's own; tracker statuses are in \`sync.json\`.
|
|
11147
|
+
`;
|
|
11148
|
+
}
|
|
11149
|
+
function syncText(p) {
|
|
11150
|
+
return `${JSON.stringify({ version: 1, site: p.site, epic: { ...p.epic, observeOnly: true }, stories: p.stories, issues: p.issues, unmapped: p.unmapped, gone: p.gone }, null, 2)}
|
|
11151
|
+
`;
|
|
11152
|
+
}
|
|
11153
|
+
function writeProposal(root, p, force = false) {
|
|
11154
|
+
const log = [];
|
|
11155
|
+
const put = (rel, text, regenerate) => {
|
|
11156
|
+
const abs = join29(root, rel);
|
|
11157
|
+
if (existsSync27(abs)) {
|
|
11158
|
+
const prev = readFileSync24(abs, "utf8");
|
|
11159
|
+
if (prev === text) return void log.push(`unchanged ${rel}`);
|
|
11160
|
+
if (!regenerate && !force) return void log.push(`kept ${rel}: it already exists and differs; --force replaces it`);
|
|
11161
|
+
}
|
|
11162
|
+
mkdirSync13(dirname5(abs), { recursive: true });
|
|
11163
|
+
writeFileSync14(abs, text);
|
|
11164
|
+
log.push(`wrote ${rel}`);
|
|
11165
|
+
};
|
|
11166
|
+
const dir = `${INITIATIVES_DIR}/${p.id}`;
|
|
11167
|
+
put(`${dir}/initiative.md`, initiativeText(p), false);
|
|
11168
|
+
put(`${dir}/one-pager.md`, onePagerText(p), false);
|
|
11169
|
+
put(`.lead/adapters/${p.id}/SKILL.md`, adapterText(p), false);
|
|
11170
|
+
put(`${dir}/sync.json`, syncText(p), true);
|
|
11171
|
+
return log;
|
|
11172
|
+
}
|
|
11173
|
+
|
|
11174
|
+
// src/score.ts
|
|
11175
|
+
import { existsSync as existsSync28, readdirSync as readdirSync14, readFileSync as readFileSync25 } from "node:fs";
|
|
11176
|
+
import { join as join30, relative as relative12 } from "node:path";
|
|
10502
11177
|
function rubrics(root, kit) {
|
|
10503
11178
|
const dirs = [
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
|
|
11179
|
+
join30(kit, "skills/lead/scorers"),
|
|
11180
|
+
join30(root, ".claude/skills/lead/scorers"),
|
|
11181
|
+
join30(root, ".agents/skills/lead/scorers"),
|
|
11182
|
+
join30(root, ".lead/local/scorers")
|
|
10508
11183
|
];
|
|
10509
11184
|
const all = /* @__PURE__ */ new Map();
|
|
10510
|
-
for (const dir of dirs.filter(
|
|
10511
|
-
for (const name of
|
|
10512
|
-
const file =
|
|
10513
|
-
if (
|
|
11185
|
+
for (const dir of dirs.filter(existsSync28)) {
|
|
11186
|
+
for (const name of readdirSync14(dir).sort()) {
|
|
11187
|
+
const file = join30(dir, name, "scorer.md");
|
|
11188
|
+
if (existsSync28(file)) all.set(name, file);
|
|
10514
11189
|
}
|
|
10515
11190
|
}
|
|
10516
11191
|
return [...all].map(([id, file]) => {
|
|
10517
|
-
const text =
|
|
11192
|
+
const text = readFileSync25(file, "utf8");
|
|
10518
11193
|
const { parsed } = parseFrontmatter(text, file);
|
|
10519
11194
|
const data = parsed?.data;
|
|
10520
11195
|
if (!data || !/^[a-z][a-z0-9_-]*$/.test(id) || data.id !== id || typeof data.version !== "number" || !Number.isInteger(data.version) || data.version < 1 || !["task", "mockup", "qa"].includes(String(data.applies_to)) || typeof data.sample_rate !== "number" || !(data.sample_rate >= 0 && data.sample_rate <= 1) || typeof data.pass_threshold !== "number" || !Number.isFinite(data.pass_threshold)) {
|
|
@@ -10650,6 +11325,13 @@ Usage: node .lead/lead.mjs <command> [options]
|
|
|
10650
11325
|
how how to work with lead: the scheme, where a person is needed
|
|
10651
11326
|
enable | disable | enabled turn lead's hooks on or off for you in this repo (local, not in git)
|
|
10652
11327
|
mode [auto|approve|clear] how lead treats a step inside the plan (local, not in git)
|
|
11328
|
+
adopt --input FILE --id ID --home REPO [--flag KEY] [--write] [--force] [--json]
|
|
11329
|
+
adopt a tracker epic as an initiative: preview the mapping, then write the adapter and observed records
|
|
11330
|
+
initiative [id] [--json] initiatives in work/initiatives/ (read-only: milestones, repositories, tasks, adapter)
|
|
11331
|
+
initiative [id] --in REPO only the tasks and tracker records of one repository
|
|
11332
|
+
initiative check [id] check the tasks of initiatives: repos, references, waves
|
|
11333
|
+
initiative waves <id> [--write] compute (and with --write store) waves across the initiative's repositories
|
|
11334
|
+
adapters [name] [--json] project adapters in .lead/adapters/ (rules for reading this project's existing records)
|
|
10653
11335
|
delegate [id] [check] [--json] services that can take a task, and tasks already handed off
|
|
10654
11336
|
watch [start|stop|interval 15m|ack] local clock for delegated tasks (default 15m; --close on start)
|
|
10655
11337
|
improve print .lead/improve.md (stops, asks, what a kit change would avoid)
|
|
@@ -10681,16 +11363,16 @@ function parseArgs(argv) {
|
|
|
10681
11363
|
}
|
|
10682
11364
|
return { cmd: args.shift(), args, flags };
|
|
10683
11365
|
}
|
|
10684
|
-
var
|
|
11366
|
+
var str2 = (v) => typeof v === "string" ? v : void 0;
|
|
10685
11367
|
function watchLine(root) {
|
|
10686
11368
|
const w = readWatch(root);
|
|
10687
11369
|
if (!alive(w.pid)) return [];
|
|
10688
11370
|
return [`lead: watch is on, every ${w.interval}${w.due ? `, check due since ${w.due}: follow references/watch.md` : ""}.`];
|
|
10689
11371
|
}
|
|
10690
11372
|
function kitRoot() {
|
|
10691
|
-
return resolve3(
|
|
11373
|
+
return resolve3(dirname6(fileURLToPath(import.meta.url)), "..");
|
|
10692
11374
|
}
|
|
10693
|
-
var KNOWN_FLAGS = /* @__PURE__ */ new Set(["from", "keep-modified", "deny", "confirm", "reopen", "source", "json", "session", "project", "cwd", "tool", "force", "only", "verdict", "notes", "merged", "question", "write", "id", "result", "status", "worktree", "help", "close", "kind", "where", "what", "avoid", "mr", "event", "day", "goal", "task", "since", "input", "scorer", "run", "limit", "preview", "retry", "action", "discard", "repo"]);
|
|
11375
|
+
var KNOWN_FLAGS = /* @__PURE__ */ new Set(["from", "keep-modified", "deny", "confirm", "reopen", "source", "json", "session", "project", "cwd", "tool", "force", "only", "verdict", "notes", "merged", "question", "write", "id", "result", "status", "worktree", "help", "close", "kind", "where", "what", "avoid", "mr", "event", "day", "goal", "task", "since", "input", "scorer", "run", "limit", "preview", "retry", "action", "discard", "repo", "home", "flag", "title", "in"]);
|
|
10694
11376
|
function main(argv, out = (s) => console.log(s)) {
|
|
10695
11377
|
const { cmd, args, flags } = parseArgs(argv);
|
|
10696
11378
|
const unknown = Object.keys(flags).filter((f) => !KNOWN_FLAGS.has(f));
|
|
@@ -10700,24 +11382,24 @@ function main(argv, out = (s) => console.log(s)) {
|
|
|
10700
11382
|
}
|
|
10701
11383
|
const hook = cmd === "session-start" || cmd === "stop-check";
|
|
10702
11384
|
const hookInput = hook ? readStdinJson() : {};
|
|
10703
|
-
const origin = resolve3(hookInput.cwd ??
|
|
11385
|
+
const origin = resolve3(hookInput.cwd ?? str2(flags.cwd) ?? process.cwd());
|
|
10704
11386
|
let cwd = origin;
|
|
10705
|
-
let project =
|
|
10706
|
-
const session = hookInput.session_id ??
|
|
11387
|
+
let project = str2(flags.project);
|
|
11388
|
+
const session = hookInput.session_id ?? str2(flags.session) ?? process.env.LEAD_SESSION;
|
|
10707
11389
|
let scope;
|
|
10708
11390
|
let sharedKit;
|
|
10709
11391
|
if (cmd && !["help", "--help", "version", "how", "install"].includes(cmd)) {
|
|
10710
11392
|
try {
|
|
10711
11393
|
const runningKit = kitRoot();
|
|
10712
|
-
const deployed = basename2(runningKit) === "workspace-kit" && basename2(
|
|
10713
|
-
const ws = deployed ? findWorkspace(
|
|
11394
|
+
const deployed = basename2(runningKit) === "workspace-kit" && basename2(dirname6(runningKit)) === ".lead";
|
|
11395
|
+
const ws = deployed ? findWorkspace(dirname6(dirname6(runningKit))) : findWorkspace(origin);
|
|
10714
11396
|
if (deployed && !ws) throw new Error("the shared workspace catalog is missing");
|
|
10715
11397
|
if (ws) {
|
|
10716
11398
|
const path = relative13(ws.root, realpathSync5(origin));
|
|
10717
11399
|
if (path === ".." || path.startsWith(".." + sep4)) throw new Error("the command directory is outside this workspace");
|
|
10718
|
-
sharedKit =
|
|
11400
|
+
sharedKit = join31(ws.root, RUNTIME);
|
|
10719
11401
|
}
|
|
10720
|
-
if (flags.repo && (!ws || !
|
|
11402
|
+
if (flags.repo && (!ws || !str2(flags.repo))) throw new Error("--repo requires a workspace and repository name");
|
|
10721
11403
|
if (cmd === "workspace") {
|
|
10722
11404
|
if (!ws) throw new Error("no workspace catalog (.lead/workspace.yml)");
|
|
10723
11405
|
if (args[0] === "overview") {
|
|
@@ -10758,34 +11440,34 @@ ${entry.source}:${entry.line}
|
|
|
10758
11440
|
}
|
|
10759
11441
|
if (args[0] === "attach" && args[1]) {
|
|
10760
11442
|
const target = routeScope(ws, ws.root, void 0, args[1]).root;
|
|
10761
|
-
if (
|
|
11443
|
+
if (existsSync29(join31(target, ".lead/lead.mjs")) && !isPortableLauncher(target)) throw new Error("a lead entry point already exists; review and migrate it before attaching");
|
|
10762
11444
|
writeEntrypoints(target);
|
|
10763
11445
|
for (const line of [...ensureGitIgnore(target), ...ensureClaudeSettings(target), ...ensureCodexHooks(target)]) out(line);
|
|
10764
11446
|
out(`attached ${args[1]} to the shared lead workspace`);
|
|
10765
11447
|
return 0;
|
|
10766
11448
|
}
|
|
10767
11449
|
if (args[0] === "deploy") {
|
|
10768
|
-
deployWorkspace(ws,
|
|
11450
|
+
deployWorkspace(ws, str2(flags.from) ? resolve3(origin, str2(flags.from)) : kitRoot());
|
|
10769
11451
|
out(`workspace lead deployed in ${ws.root}`);
|
|
10770
11452
|
return 0;
|
|
10771
11453
|
}
|
|
10772
11454
|
throw new Error("usage: workspace overview | improve | use <repo> --session ID [--project NAME] | attach <repo> | deploy [--from PATH]");
|
|
10773
11455
|
}
|
|
10774
|
-
if (ws && cmd === "update" && (origin === ws.root || routeScope(ws, origin, session,
|
|
11456
|
+
if (ws && cmd === "update" && (origin === ws.root || routeScope(ws, origin, session, str2(flags.repo), project))) {
|
|
10775
11457
|
const deploy = (source) => {
|
|
10776
11458
|
deployWorkspace(ws, source);
|
|
10777
11459
|
out(`updated the shared workspace kit in ${ws.root}`);
|
|
10778
11460
|
return 0;
|
|
10779
11461
|
};
|
|
10780
|
-
if (flags.from && !
|
|
10781
|
-
return
|
|
11462
|
+
if (flags.from && !str2(flags.from)) throw new Error("--from requires a local workspace-capable kit");
|
|
11463
|
+
return str2(flags.from) ? deploy(resolve3(origin, str2(flags.from))) : withRegistryKit(ws.root, out, deploy);
|
|
10782
11464
|
}
|
|
10783
11465
|
if (ws) {
|
|
10784
|
-
scope = routeScope(ws, origin, session,
|
|
11466
|
+
scope = routeScope(ws, origin, session, str2(flags.repo), project);
|
|
10785
11467
|
if (scope) {
|
|
10786
11468
|
cwd = scope.cwd;
|
|
10787
11469
|
project = scope.project;
|
|
10788
|
-
} else if (repoRoot(origin) === ws.root || !
|
|
11470
|
+
} else if (repoRoot(origin) === ws.root || !existsSync29(join31(repoRoot(origin), ".git"))) {
|
|
10789
11471
|
if (cmd === "session-start" && session) {
|
|
10790
11472
|
out(JSON.stringify({ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: `lead workspace session: ${session}. Pass --session ${session} to lead commands.` } }));
|
|
10791
11473
|
return 0;
|
|
@@ -10885,18 +11567,18 @@ ${entry.source}:${entry.line}
|
|
|
10885
11567
|
return 1;
|
|
10886
11568
|
}
|
|
10887
11569
|
let r;
|
|
10888
|
-
if (cmd === "start") r = startTask(ctx, task, { session, tool:
|
|
10889
|
-
else if (cmd === "record-checks") r = recordChecks(ctx, task, { session, only:
|
|
11570
|
+
if (cmd === "start") r = startTask(ctx, task, { session, tool: str2(flags.tool), force: !!flags.force });
|
|
11571
|
+
else if (cmd === "record-checks") r = recordChecks(ctx, task, { session, only: str2(flags.only)?.split(",") });
|
|
10890
11572
|
else if (cmd === "review") {
|
|
10891
|
-
const verdict =
|
|
11573
|
+
const verdict = str2(flags.verdict);
|
|
10892
11574
|
if (verdict !== "pass" && verdict !== "fail") {
|
|
10893
11575
|
out("--verdict pass|fail is required");
|
|
10894
11576
|
return 2;
|
|
10895
11577
|
}
|
|
10896
|
-
r = reviewTask(ctx, task, { session, verdict, notes:
|
|
11578
|
+
r = reviewTask(ctx, task, { session, verdict, notes: str2(flags.notes) });
|
|
10897
11579
|
} else if (cmd === "finish") r = finishTask(ctx, task, { session: session ?? "", merged: !!flags.merged, isMerged: gitMergedChecker(ctx.root) });
|
|
10898
11580
|
else {
|
|
10899
|
-
const question =
|
|
11581
|
+
const question = str2(flags.question);
|
|
10900
11582
|
if (!question) {
|
|
10901
11583
|
out("--question TEXT is required");
|
|
10902
11584
|
return 2;
|
|
@@ -10909,10 +11591,10 @@ ${entry.source}:${entry.line}
|
|
|
10909
11591
|
case "enable":
|
|
10910
11592
|
case "disable": {
|
|
10911
11593
|
const root = repoRoot(cwd);
|
|
10912
|
-
|
|
10913
|
-
if (cmd === "enable")
|
|
11594
|
+
mkdirSync14(join31(root, ".lead"), { recursive: true });
|
|
11595
|
+
if (cmd === "enable") writeFileSync15(join31(root, ENABLED_PATH), `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
10914
11596
|
`);
|
|
10915
|
-
else rmSync6(
|
|
11597
|
+
else rmSync6(join31(root, ENABLED_PATH), { force: true });
|
|
10916
11598
|
out(cmd === "enable" ? "lead is on for you in this repo (hooks active; stored in .lead/enabled, not in git)" : "lead is off for you in this repo: hooks are silent");
|
|
10917
11599
|
return 0;
|
|
10918
11600
|
}
|
|
@@ -10952,10 +11634,15 @@ ${entry.source}:${entry.line}
|
|
|
10952
11634
|
return 0;
|
|
10953
11635
|
}
|
|
10954
11636
|
case "session-start": {
|
|
10955
|
-
|
|
11637
|
+
const pointer = sharedKit && scope ? [`lead: this project runs with lead, no /lead needed. Launcher: ${join31(repoRoot(cwd), ".lead/lead.mjs")}; kit: ${sharedKit} (start from skills/lead/SKILL.md; references are relative to the kit). When the person asks about plans, tasks, status, handoffs or the board, read that SKILL.md and follow it; do not search for the launcher or run kit-path.`] : [];
|
|
11638
|
+
if (!isEnabled(repoRoot(cwd))) {
|
|
11639
|
+
if (pointer.length) out(JSON.stringify({ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: [...pointer, `lead: this session id is ${session ?? "unknown"}; pass --session ${session ?? "<id>"} to lead.mjs commands.`].join("\n") } }));
|
|
11640
|
+
return 0;
|
|
11641
|
+
}
|
|
10956
11642
|
const ctx = loadContext(cwd, project);
|
|
10957
11643
|
const s = status(ctx, { session });
|
|
10958
11644
|
const lines = [
|
|
11645
|
+
...pointer,
|
|
10959
11646
|
`lead: this session id is ${session ?? "unknown"}; pass --session ${session ?? "<id>"} to lead.mjs commands.`,
|
|
10960
11647
|
s.project ? `lead: project ${s.project.name === "." ? "(repo root)" : s.project.name}${s.milestone ? `, milestone ${s.milestone.title}` : ""}${s.wave !== void 0 ? `, wave ${s.wave}` : ""}; next: ${s.next.kind} \u2014 ${s.next.reason}.` : `lead: next: ${s.next.kind} \u2014 ${s.next.reason}.`,
|
|
10961
11648
|
...watchLine(ctx.root)
|
|
@@ -10970,8 +11657,8 @@ ${entry.source}:${entry.line}
|
|
|
10970
11657
|
return 1;
|
|
10971
11658
|
}
|
|
10972
11659
|
try {
|
|
10973
|
-
if (
|
|
10974
|
-
if (
|
|
11660
|
+
if (str2(flags.confirm)) out(setSectionStatus(ctx.root, ctx.project.workDir, str2(flags.confirm), "confirmed", ctx.project.name));
|
|
11661
|
+
if (str2(flags.reopen)) out(setSectionStatus(ctx.root, ctx.project.workDir, str2(flags.reopen), "draft"));
|
|
10975
11662
|
} catch (e) {
|
|
10976
11663
|
out(e.message);
|
|
10977
11664
|
return 1;
|
|
@@ -10983,13 +11670,13 @@ ${entry.source}:${entry.line}
|
|
|
10983
11670
|
}
|
|
10984
11671
|
case "builder-settings": {
|
|
10985
11672
|
const name = args[0];
|
|
10986
|
-
const source =
|
|
11673
|
+
const source = str2(flags.source);
|
|
10987
11674
|
if (!name || !source) {
|
|
10988
11675
|
out("usage: builder-settings <x> --source DIR");
|
|
10989
11676
|
return 2;
|
|
10990
11677
|
}
|
|
10991
11678
|
try {
|
|
10992
|
-
const r = builderSettings(repoRoot(cwd), name, source,
|
|
11679
|
+
const r = builderSettings(repoRoot(cwd), name, source, str2(flags.deny)?.split(",") ?? []);
|
|
10993
11680
|
out(`wrote ${r.path}
|
|
10994
11681
|
start the builder with: ${r.launch}`);
|
|
10995
11682
|
return 0;
|
|
@@ -10999,13 +11686,13 @@ start the builder with: ${r.launch}`);
|
|
|
10999
11686
|
}
|
|
11000
11687
|
}
|
|
11001
11688
|
case "similarity": {
|
|
11002
|
-
const source =
|
|
11689
|
+
const source = str2(flags.source);
|
|
11003
11690
|
if (!source) {
|
|
11004
11691
|
out("usage: similarity --source DIR [paths...]");
|
|
11005
11692
|
return 2;
|
|
11006
11693
|
}
|
|
11007
11694
|
const ctx = loadContext(cwd, project);
|
|
11008
|
-
const targets = args.length ? args.map((a) => resolve3(cwd, a)) : [
|
|
11695
|
+
const targets = args.length ? args.map((a) => resolve3(cwd, a)) : [join31(ctx.root, ctx.project?.path ?? ".")];
|
|
11009
11696
|
const matches = similarity(resolve3(cwd, source), targets, ctx.root);
|
|
11010
11697
|
for (const m of matches.slice(0, 50)) out(`${m.file}:${m.line} ${m.kind === "block" ? "block of lines" : "long line"} also in ${m.source}:${m.sourceLine}`);
|
|
11011
11698
|
out(`${matches.length} shared fragments`);
|
|
@@ -11018,9 +11705,9 @@ start the builder with: ${r.launch}`);
|
|
|
11018
11705
|
out(markdown.trimEnd());
|
|
11019
11706
|
return 0;
|
|
11020
11707
|
}
|
|
11021
|
-
const file =
|
|
11708
|
+
const file = str2(flags.input);
|
|
11022
11709
|
if (!file) throw new Error("--input FILE must point to the read-back Markdown");
|
|
11023
|
-
const mismatches = verifyOnePager(markdown,
|
|
11710
|
+
const mismatches = verifyOnePager(markdown, readFileSync26(resolve3(cwd, file), "utf8"));
|
|
11024
11711
|
out(mismatches.length ? mismatches.join("\n") : "One Pager read-back matches the roadmap, triage, widgets and links");
|
|
11025
11712
|
return mismatches.length ? 1 : 0;
|
|
11026
11713
|
} catch (e) {
|
|
@@ -11038,6 +11725,7 @@ start the builder with: ${r.launch}`);
|
|
|
11038
11725
|
const plan = syncPlan(ctx);
|
|
11039
11726
|
const journal = readSyncJournal(ctx.root, ctx.project.name);
|
|
11040
11727
|
const groups = {
|
|
11728
|
+
...ctx.config.planning === "adopted" ? { mapping: adoptionMapping(ctx) } : {},
|
|
11041
11729
|
blocked: taskSyncBlockers(ctx),
|
|
11042
11730
|
recorded: Object.values(journal).filter((entry) => entry.done).map((entry) => entry.label),
|
|
11043
11731
|
pending: plan.filter((action) => journal[syncActionKey(action)]?.done !== false).map(syncLabel),
|
|
@@ -11062,8 +11750,8 @@ start the builder with: ${r.launch}`);
|
|
|
11062
11750
|
return 0;
|
|
11063
11751
|
}
|
|
11064
11752
|
const actions = syncPlan(ctx).map((a, i) => ({ id: i + 1, ...a }));
|
|
11065
|
-
|
|
11066
|
-
|
|
11753
|
+
mkdirSync14(join31(ctx.root, ".lead/logs"), { recursive: true });
|
|
11754
|
+
writeFileSync15(syncPlanPath(ctx.root, ctx.project.name), JSON.stringify({ project: ctx.project.name, actions }, null, 2));
|
|
11067
11755
|
out(JSON.stringify(actions, null, 2));
|
|
11068
11756
|
return 0;
|
|
11069
11757
|
}
|
|
@@ -11073,7 +11761,7 @@ start the builder with: ${r.launch}`);
|
|
|
11073
11761
|
try {
|
|
11074
11762
|
if (!ctx.project) throw new Error("no project selected: --project NAME");
|
|
11075
11763
|
const journal = readSyncJournal(ctx.root, ctx.project.name);
|
|
11076
|
-
const ref =
|
|
11764
|
+
const ref = str2(flags.action);
|
|
11077
11765
|
if (cmd === "sync-attempt" && flags.discard) {
|
|
11078
11766
|
if (!ref || !Object.hasOwn(journal, ref) || journal[ref]?.done !== false) throw new Error("an uncertain action reference is required");
|
|
11079
11767
|
delete journal[ref];
|
|
@@ -11081,7 +11769,7 @@ start the builder with: ${r.launch}`);
|
|
|
11081
11769
|
out(`cleared verified no-effect action ${ref}`);
|
|
11082
11770
|
return 0;
|
|
11083
11771
|
}
|
|
11084
|
-
const action = cmd === "sync-record" && ref && !
|
|
11772
|
+
const action = cmd === "sync-record" && ref && !str2(flags.id) ? Object.hasOwn(journal, ref) ? journal[ref]?.action : void 0 : savedSyncAction(ctx.root, ctx.project.name, Number(str2(flags.id)));
|
|
11085
11773
|
if (!action) throw new Error("action not found in the sync plan or journal");
|
|
11086
11774
|
const key = syncActionKey(action);
|
|
11087
11775
|
if (ref && ref !== key) throw new Error("saved action changed: refresh sync-plan");
|
|
@@ -11100,7 +11788,7 @@ start the builder with: ${r.launch}`);
|
|
|
11100
11788
|
out(`already recorded ${journal[key].label}`);
|
|
11101
11789
|
return 0;
|
|
11102
11790
|
}
|
|
11103
|
-
const result = JSON.parse(
|
|
11791
|
+
const result = JSON.parse(str2(flags.result) ?? "{}");
|
|
11104
11792
|
out(syncRecord(ctx, action, result));
|
|
11105
11793
|
journal[key] = { label: syncLabel(action), done: true, action };
|
|
11106
11794
|
writeSyncJournal(ctx.root, ctx.project.name, journal);
|
|
@@ -11116,9 +11804,9 @@ start the builder with: ${r.launch}`);
|
|
|
11116
11804
|
try {
|
|
11117
11805
|
if (!ctx.project) throw new Error("no project selected: --project NAME");
|
|
11118
11806
|
const input = () => {
|
|
11119
|
-
const file =
|
|
11807
|
+
const file = str2(flags.input);
|
|
11120
11808
|
if (!file) throw new Error("--input FILE is required");
|
|
11121
|
-
return JSON.parse(
|
|
11809
|
+
return JSON.parse(readFileSync26(resolve3(cwd, file), "utf8"));
|
|
11122
11810
|
};
|
|
11123
11811
|
if (cmd === "qa-record") {
|
|
11124
11812
|
const task = ctx.tasks.find((t) => t.id === args[0]);
|
|
@@ -11126,8 +11814,8 @@ start the builder with: ${r.launch}`);
|
|
|
11126
11814
|
out(JSON.stringify(recordQa(ctx, task, treeId(taskDir(ctx, task)), session, input()), null, 2));
|
|
11127
11815
|
return 0;
|
|
11128
11816
|
}
|
|
11129
|
-
const scorer =
|
|
11130
|
-
const run2 =
|
|
11817
|
+
const scorer = str2(flags.scorer);
|
|
11818
|
+
const run2 = str2(flags.run);
|
|
11131
11819
|
if (args[0] === "record") {
|
|
11132
11820
|
if (!scorer || !run2) throw new Error("score record requires --scorer ID and --run ID");
|
|
11133
11821
|
out(JSON.stringify(recordScore(ctx, kitRoot(), scorer, run2, input()), null, 2));
|
|
@@ -11137,7 +11825,7 @@ start the builder with: ${r.launch}`);
|
|
|
11137
11825
|
out(JSON.stringify(runs(ctx.root).filter((row) => row.subject.project === ctx.project?.name).map(({ id, at, kind, subject }) => ({ id, at, kind, subject })), null, 2));
|
|
11138
11826
|
} else {
|
|
11139
11827
|
if (args.length) throw new Error("usage: score [runs|record|analyze]");
|
|
11140
|
-
const limit = Number(
|
|
11828
|
+
const limit = Number(str2(flags.limit) ?? 10);
|
|
11141
11829
|
if (!Number.isSafeInteger(limit) || limit < 1) throw new Error("--limit must be a positive integer");
|
|
11142
11830
|
out(JSON.stringify(scorePlan(ctx, kitRoot(), scorer, run2, limit), null, 2));
|
|
11143
11831
|
}
|
|
@@ -11166,9 +11854,9 @@ start the builder with: ${r.launch}`);
|
|
|
11166
11854
|
return 1;
|
|
11167
11855
|
}
|
|
11168
11856
|
let r;
|
|
11169
|
-
if (cmd === "claim") r = claimTask(ctx.root, task, { session, tool:
|
|
11857
|
+
if (cmd === "claim") r = claimTask(ctx.root, task, { session, tool: str2(flags.tool), worktree: str2(flags.worktree) });
|
|
11170
11858
|
else {
|
|
11171
|
-
const st =
|
|
11859
|
+
const st = str2(flags.status);
|
|
11172
11860
|
if (st && !STATUSES.includes(st)) {
|
|
11173
11861
|
out(`status must be one of ${STATUSES.join(", ")}`);
|
|
11174
11862
|
return 2;
|
|
@@ -11187,8 +11875,8 @@ start the builder with: ${r.launch}`);
|
|
|
11187
11875
|
out(`usage: use <project>; projects: ${projects.map((p) => p.name).join(", ") || "none"}`);
|
|
11188
11876
|
return 2;
|
|
11189
11877
|
}
|
|
11190
|
-
|
|
11191
|
-
|
|
11878
|
+
mkdirSync14(join31(root, ".lead"), { recursive: true });
|
|
11879
|
+
writeFileSync15(join31(root, CURRENT_PATH), `${name}
|
|
11192
11880
|
`);
|
|
11193
11881
|
out(`current project: ${name}`);
|
|
11194
11882
|
return 0;
|
|
@@ -11224,7 +11912,7 @@ start the builder with: ${r.launch}`);
|
|
|
11224
11912
|
}
|
|
11225
11913
|
case "update": {
|
|
11226
11914
|
const root = repoRoot(cwd);
|
|
11227
|
-
const from =
|
|
11915
|
+
const from = str2(flags.from);
|
|
11228
11916
|
if (flags.from && !from) {
|
|
11229
11917
|
out("usage: update --from GIT_URL|PATH");
|
|
11230
11918
|
return 2;
|
|
@@ -11234,7 +11922,7 @@ start the builder with: ${r.launch}`);
|
|
|
11234
11922
|
const before = readLock(root)?.version ?? "none";
|
|
11235
11923
|
const r = spawnSync3(
|
|
11236
11924
|
process.execPath,
|
|
11237
|
-
[
|
|
11925
|
+
[join31(kit, "dist/lead.mjs"), "install", root, ...flags.force ? [] : ["--keep-modified"]],
|
|
11238
11926
|
{ cwd: root, encoding: "utf8" }
|
|
11239
11927
|
);
|
|
11240
11928
|
const output = `${r.stdout ?? ""}${r.stderr ?? ""}`.trim();
|
|
@@ -11248,8 +11936,8 @@ start the builder with: ${r.launch}`);
|
|
|
11248
11936
|
try {
|
|
11249
11937
|
if (!from) return withRegistryKit(root, out, applyKit);
|
|
11250
11938
|
const path = resolve3(cwd, from);
|
|
11251
|
-
if (
|
|
11252
|
-
tmp = mkdtempSync3(
|
|
11939
|
+
if (existsSync29(path)) return applyKit(path);
|
|
11940
|
+
tmp = mkdtempSync3(join31(tmpdir3(), "lead-kit-"));
|
|
11253
11941
|
execFileSync6("git", ["clone", "-q", "--depth", "1", "--", from, tmp], { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
11254
11942
|
return applyKit(tmp);
|
|
11255
11943
|
} catch (e) {
|
|
@@ -11262,6 +11950,136 @@ start the builder with: ${r.launch}`);
|
|
|
11262
11950
|
case "how":
|
|
11263
11951
|
out(TEMPLATES["how.md"].trim());
|
|
11264
11952
|
return 0;
|
|
11953
|
+
case "adopt": {
|
|
11954
|
+
const root = repoRoot(cwd);
|
|
11955
|
+
const input = typeof flags.input === "string" ? flags.input : "";
|
|
11956
|
+
const id = typeof flags.id === "string" ? flags.id : "";
|
|
11957
|
+
const home = typeof flags.home === "string" ? flags.home : "";
|
|
11958
|
+
if (!input || !id || !home) {
|
|
11959
|
+
out("usage: adopt --input FILE --id ID --home REPO [--flag KEY] [--title TEXT] [--write] [--force]");
|
|
11960
|
+
return 2;
|
|
11961
|
+
}
|
|
11962
|
+
if (!/^[a-z][a-z0-9-]*$/.test(id) || id === "check" || id === "waves" || !/^[a-z][a-z0-9-]*$/.test(home)) {
|
|
11963
|
+
out('--id and --home must look like "private-space" (id cannot be check or waves)');
|
|
11964
|
+
return 2;
|
|
11965
|
+
}
|
|
11966
|
+
let raw;
|
|
11967
|
+
try {
|
|
11968
|
+
raw = JSON.parse(readFileSync26(resolve3(cwd, input), "utf8"));
|
|
11969
|
+
} catch (error) {
|
|
11970
|
+
out(`cannot read ${input}: ${error.message}`);
|
|
11971
|
+
return 2;
|
|
11972
|
+
}
|
|
11973
|
+
const { inventory, errors } = validateInventory(raw);
|
|
11974
|
+
if (!inventory) {
|
|
11975
|
+
for (const e of errors) out(`error ${e}`);
|
|
11976
|
+
return 2;
|
|
11977
|
+
}
|
|
11978
|
+
const syncFile = join31(root, "work/initiatives", id, "sync.json");
|
|
11979
|
+
let previous;
|
|
11980
|
+
try {
|
|
11981
|
+
previous = JSON.parse(readFileSync26(syncFile, "utf8"));
|
|
11982
|
+
} catch {
|
|
11983
|
+
previous = void 0;
|
|
11984
|
+
}
|
|
11985
|
+
const existing = loadInitiatives(root).initiatives.find((i) => i.id === id);
|
|
11986
|
+
const proposal = propose(inventory, { id, home, previous, ...existing ? { overrides: existing.map } : {}, ...typeof flags.title === "string" ? { title: flags.title } : {}, ...typeof flags.flag === "string" ? { flag: flags.flag } : {} });
|
|
11987
|
+
const diff = previous ? diffObserved(previous, proposal) : void 0;
|
|
11988
|
+
if (flags.json) out(JSON.stringify({ ...proposal, ...diff ? { diff } : {} }, null, 2));
|
|
11989
|
+
else {
|
|
11990
|
+
for (const line of renderProposal(proposal)) out(line);
|
|
11991
|
+
if (diff) for (const line of ["", ...renderDiff(diff)]) out(line);
|
|
11992
|
+
}
|
|
11993
|
+
if (!flags.write) {
|
|
11994
|
+
out(flags.json ? "" : "\n(preview only; nothing written. Add --write after the person agrees.)");
|
|
11995
|
+
return 0;
|
|
11996
|
+
}
|
|
11997
|
+
for (const line of writeProposal(root, proposal, flags.force === true)) out(line);
|
|
11998
|
+
return 0;
|
|
11999
|
+
}
|
|
12000
|
+
case "initiative": {
|
|
12001
|
+
const root = repoRoot(cwd);
|
|
12002
|
+
const { initiatives, issues } = loadInitiatives(root);
|
|
12003
|
+
const errors = issues.filter((i) => i.level === "error");
|
|
12004
|
+
const sub = args[0] === "check" || args[0] === "waves" ? args[0] : void 0;
|
|
12005
|
+
const id = sub ? args[1] : args[0];
|
|
12006
|
+
if (sub === "check" || sub === "waves") {
|
|
12007
|
+
if (id && !initiatives.some((i) => i.id === id)) {
|
|
12008
|
+
out(`no initiative "${id}". Known: ${initiatives.map((i) => i.id).join(", ") || "none"}`);
|
|
12009
|
+
return 1;
|
|
12010
|
+
}
|
|
12011
|
+
if (sub === "waves" && !id) {
|
|
12012
|
+
out("usage: initiative waves <id> [--write]");
|
|
12013
|
+
return 2;
|
|
12014
|
+
}
|
|
12015
|
+
const chosen = initiatives.filter((i) => !id || i.id === id);
|
|
12016
|
+
if (sub === "waves") {
|
|
12017
|
+
const target = chosen[0];
|
|
12018
|
+
if (flags.write) for (const line of writeInitiativeWaves(root, target)) out(line);
|
|
12019
|
+
else {
|
|
12020
|
+
const o = initiativeOverview(root, target);
|
|
12021
|
+
for (const t of o.tasks) out(`${t.id} ${t.repo} ${t.wave ? `w${t.wave}` : "no wave"}`);
|
|
12022
|
+
out("(not written; add --write)");
|
|
12023
|
+
}
|
|
12024
|
+
return 0;
|
|
12025
|
+
}
|
|
12026
|
+
const ws = optionalWorkspace(root);
|
|
12027
|
+
const all = [...issues, ...chosen.flatMap((i) => checkInitiative(root, i, ws))];
|
|
12028
|
+
out(all.length ? formatIssues(all) : "initiatives: ok");
|
|
12029
|
+
return all.some((i) => i.level === "error") ? 1 : 0;
|
|
12030
|
+
}
|
|
12031
|
+
if (id && !initiatives.some((i) => i.id === id)) {
|
|
12032
|
+
out(`no initiative "${id}". Known: ${initiatives.map((i) => i.id).join(", ") || "none"}`);
|
|
12033
|
+
return 1;
|
|
12034
|
+
}
|
|
12035
|
+
if (typeof flags.in === "string") {
|
|
12036
|
+
const repo = flags.in;
|
|
12037
|
+
const one = initiatives.filter((i) => !id || i.id === id);
|
|
12038
|
+
const rows = one.map((i) => {
|
|
12039
|
+
const o = initiativeOverview(root, i);
|
|
12040
|
+
return { id: i.id, repo, known: i.repos.some((r) => r.name === repo), tasks: o.tasks.filter((t) => t.repo === repo), observed: observedRecords(root, i, repo) };
|
|
12041
|
+
});
|
|
12042
|
+
if (flags.json) out(JSON.stringify({ repo, initiatives: rows }, null, 2));
|
|
12043
|
+
else {
|
|
12044
|
+
for (const r of rows) {
|
|
12045
|
+
out(`${r.id} \u2014 repository ${repo}${r.known ? "" : " (not listed in the initiative)"}`);
|
|
12046
|
+
for (const t of r.tasks) out(` task ${t.id} [${t.status}]${t.wave ? ` w${t.wave}` : ""} \u2014 ${t.title}`);
|
|
12047
|
+
for (const x of r.observed) out(` ${x.key} [${x.observed}] ${x.milestone}${x.repo !== repo ? ` (main: ${x.repo})` : ""} \u2014 ${x.summary}`);
|
|
12048
|
+
if (!r.tasks.length && !r.observed.length) out(" nothing for this repository");
|
|
12049
|
+
}
|
|
12050
|
+
}
|
|
12051
|
+
return errors.length ? 1 : 0;
|
|
12052
|
+
}
|
|
12053
|
+
const overview = initiatives.filter((i) => !id || i.id === id).map((i) => initiativeOverview(root, i));
|
|
12054
|
+
if (flags.json) out(JSON.stringify({ initiatives: overview, issues }, null, 2));
|
|
12055
|
+
else {
|
|
12056
|
+
for (const o of overview) for (const line of renderInitiative(o)) out(line);
|
|
12057
|
+
if (!overview.length) out("no initiatives (work/initiatives/<id>/initiative.md)");
|
|
12058
|
+
for (const i of issues) out(`${i.level} ${i.file}: ${i.message}`);
|
|
12059
|
+
}
|
|
12060
|
+
return errors.length ? 1 : 0;
|
|
12061
|
+
}
|
|
12062
|
+
case "adapters": {
|
|
12063
|
+
const root = repoRoot(cwd);
|
|
12064
|
+
const { adapters, issues } = listAdapters(root);
|
|
12065
|
+
const name = args[0];
|
|
12066
|
+
if (name) {
|
|
12067
|
+
const found = adapters.find((a) => a.id === name);
|
|
12068
|
+
if (!found) {
|
|
12069
|
+
out(`no adapter "${name}". Known: ${adapters.map((a) => a.id).join(", ") || "none"}`);
|
|
12070
|
+
return 1;
|
|
12071
|
+
}
|
|
12072
|
+
out(flags.json ? JSON.stringify({ ...found, text: readFileSync26(join31(root, found.file), "utf8") }, null, 2) : readFileSync26(join31(root, found.file), "utf8").trimEnd());
|
|
12073
|
+
return 0;
|
|
12074
|
+
}
|
|
12075
|
+
if (flags.json) out(JSON.stringify({ adapters, issues }, null, 2));
|
|
12076
|
+
else {
|
|
12077
|
+
for (const a of adapters) out(`${a.id} \u2014 ${a.appliesTo || a.title} (${a.file})`);
|
|
12078
|
+
if (!adapters.length) out("no adapters (.lead/adapters/<id>/SKILL.md)");
|
|
12079
|
+
for (const i of issues) out(`warn ${i}`);
|
|
12080
|
+
}
|
|
12081
|
+
return 0;
|
|
12082
|
+
}
|
|
11265
12083
|
case "delegate": {
|
|
11266
12084
|
const ctx = loadContext(cwd, project);
|
|
11267
12085
|
const services = listDelegates(ctx.root, kitRoot());
|
|
@@ -11309,9 +12127,9 @@ start the builder with: ${r.launch}`);
|
|
|
11309
12127
|
}
|
|
11310
12128
|
case "improve": {
|
|
11311
12129
|
const root = repoRoot(cwd);
|
|
11312
|
-
const kind =
|
|
11313
|
-
const where =
|
|
11314
|
-
const what =
|
|
12130
|
+
const kind = str2(flags.kind);
|
|
12131
|
+
const where = str2(flags.where);
|
|
12132
|
+
const what = str2(flags.what);
|
|
11315
12133
|
if (!kind && !where && !what) {
|
|
11316
12134
|
const text = readImprove(root);
|
|
11317
12135
|
out(text.trim() ? text.trimEnd() : `${IMPROVE_EMPTY}`);
|
|
@@ -11321,22 +12139,22 @@ start the builder with: ${r.launch}`);
|
|
|
11321
12139
|
out("usage: improve --kind stop|ask|avoidable --where TEXT --what TEXT [--avoid TEXT]");
|
|
11322
12140
|
return 2;
|
|
11323
12141
|
}
|
|
11324
|
-
const line = appendImprove(root, { kind, where, what, avoid:
|
|
12142
|
+
const line = appendImprove(root, { kind, where, what, avoid: str2(flags.avoid) });
|
|
11325
12143
|
out(`noted ${line} in ${IMPROVE_PATH}`);
|
|
11326
12144
|
return 0;
|
|
11327
12145
|
}
|
|
11328
12146
|
case "activity": {
|
|
11329
12147
|
const root = repoRoot(cwd);
|
|
11330
12148
|
if (args[0] === "analyze") {
|
|
11331
|
-
const rows = loadActivity(root, { day:
|
|
12149
|
+
const rows = loadActivity(root, { day: str2(flags.day), since: str2(flags.since) });
|
|
11332
12150
|
const report = analyzeActivity(rows);
|
|
11333
12151
|
out(flags.json ? JSON.stringify(report, null, 2) : formatActivityReport(report));
|
|
11334
12152
|
return 0;
|
|
11335
12153
|
}
|
|
11336
|
-
const event =
|
|
11337
|
-
const what =
|
|
12154
|
+
const event = str2(flags.event);
|
|
12155
|
+
const what = str2(flags.what);
|
|
11338
12156
|
if (!event && !what) {
|
|
11339
|
-
const day =
|
|
12157
|
+
const day = str2(flags.day);
|
|
11340
12158
|
if (day) {
|
|
11341
12159
|
const rows = readActivityDay(root, day);
|
|
11342
12160
|
out(rows.length ? rows.map((r) => JSON.stringify(r)).join("\n") : `no activity for ${day}`);
|
|
@@ -11353,11 +12171,11 @@ start the builder with: ${r.launch}`);
|
|
|
11353
12171
|
const rel = appendActivity(root, {
|
|
11354
12172
|
event,
|
|
11355
12173
|
what,
|
|
11356
|
-
where:
|
|
11357
|
-
task:
|
|
11358
|
-
project:
|
|
12174
|
+
where: str2(flags.where),
|
|
12175
|
+
task: str2(flags.task),
|
|
12176
|
+
project: str2(flags.project) ?? project,
|
|
11359
12177
|
session,
|
|
11360
|
-
goal:
|
|
12178
|
+
goal: str2(flags.goal)
|
|
11361
12179
|
});
|
|
11362
12180
|
out(`noted ${event} in ${rel}`);
|
|
11363
12181
|
return 0;
|
|
@@ -11375,7 +12193,7 @@ start the builder with: ${r.launch}`);
|
|
|
11375
12193
|
out(r2.message);
|
|
11376
12194
|
return r2.ok ? 0 : 1;
|
|
11377
12195
|
}
|
|
11378
|
-
const mr =
|
|
12196
|
+
const mr = str2(flags.mr);
|
|
11379
12197
|
if (!mr) {
|
|
11380
12198
|
out("usage: merge-hold <task> --session ID --mr N");
|
|
11381
12199
|
return 2;
|
|
@@ -11392,10 +12210,10 @@ ${HELP}`);
|
|
|
11392
12210
|
}
|
|
11393
12211
|
}
|
|
11394
12212
|
function syncPlanPath(root, project) {
|
|
11395
|
-
return
|
|
12213
|
+
return join31(root, ".lead/logs", `sync-plan-${project === "." ? "root" : project.replace(/[^a-zA-Z0-9_-]/g, "_")}.json`);
|
|
11396
12214
|
}
|
|
11397
12215
|
function savedSyncAction(root, project, id) {
|
|
11398
|
-
const saved = JSON.parse(
|
|
12216
|
+
const saved = JSON.parse(readFileSync26(syncPlanPath(root, project), "utf8"));
|
|
11399
12217
|
if (saved.project !== project) throw new Error(`the saved plan is for ${saved.project}, not ${project}`);
|
|
11400
12218
|
return saved.actions.find((action) => action.id === id);
|
|
11401
12219
|
}
|
|
@@ -11409,20 +12227,20 @@ function syncLabel(action) {
|
|
|
11409
12227
|
return `${action.kind}${target ? ` \xB7 ${target}` : ""}${transition}`;
|
|
11410
12228
|
}
|
|
11411
12229
|
function syncJournalPath(root, project) {
|
|
11412
|
-
return
|
|
12230
|
+
return join31(root, ".lead/logs", `sync-journal-${digest(project)}.json`);
|
|
11413
12231
|
}
|
|
11414
12232
|
function readSyncJournal(root, project) {
|
|
11415
12233
|
const file = syncJournalPath(root, project);
|
|
11416
|
-
return
|
|
12234
|
+
return existsSync29(file) ? JSON.parse(readFileSync26(file, "utf8")) : {};
|
|
11417
12235
|
}
|
|
11418
12236
|
function writeSyncJournal(root, project, journal) {
|
|
11419
12237
|
const file = syncJournalPath(root, project);
|
|
11420
|
-
|
|
11421
|
-
|
|
12238
|
+
mkdirSync14(dirname6(file), { recursive: true });
|
|
12239
|
+
writeFileSync15(file, JSON.stringify(journal, null, 2));
|
|
11422
12240
|
}
|
|
11423
12241
|
function readStdinJson() {
|
|
11424
12242
|
try {
|
|
11425
|
-
const text =
|
|
12243
|
+
const text = readFileSync26(0, "utf8");
|
|
11426
12244
|
return text.trim() ? JSON.parse(text) : {};
|
|
11427
12245
|
} catch {
|
|
11428
12246
|
return {};
|