@fusebase/harness-lead 0.2.42 → 0.3.2
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 +33 -0
- package/README.md +14 -1
- package/dist/lead.mjs +1502 -560
- package/package.json +1 -1
- package/skills/lead/SKILL.md +2 -2
- package/skills/lead/delegates/codee/SKILL.md +2 -1
- package/skills/lead/references/adopt.md +71 -0
- package/skills/lead/references/status.md +2 -2
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) {
|
|
@@ -3973,10 +3973,10 @@ var require_resolve_block_map = __commonJS({
|
|
|
3973
3973
|
let offset = bm.offset;
|
|
3974
3974
|
let commentEnd = null;
|
|
3975
3975
|
for (const collItem of bm.items) {
|
|
3976
|
-
const { start, key, sep:
|
|
3976
|
+
const { start, key, sep: sep6, value } = collItem;
|
|
3977
3977
|
const keyProps = resolveProps.resolveProps(start, {
|
|
3978
3978
|
indicator: "explicit-key-ind",
|
|
3979
|
-
next: key ??
|
|
3979
|
+
next: key ?? sep6?.[0],
|
|
3980
3980
|
offset,
|
|
3981
3981
|
onError,
|
|
3982
3982
|
parentIndent: bm.indent,
|
|
@@ -3990,7 +3990,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
3990
3990
|
else if ("indent" in key && key.indent !== bm.indent)
|
|
3991
3991
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
3992
3992
|
}
|
|
3993
|
-
if (!keyProps.anchor && !keyProps.tag && !
|
|
3993
|
+
if (!keyProps.anchor && !keyProps.tag && !sep6) {
|
|
3994
3994
|
commentEnd = keyProps.end;
|
|
3995
3995
|
if (keyProps.comment) {
|
|
3996
3996
|
if (map.comment)
|
|
@@ -4014,7 +4014,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
4014
4014
|
ctx.atKey = false;
|
|
4015
4015
|
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
|
|
4016
4016
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
4017
|
-
const valueProps = resolveProps.resolveProps(
|
|
4017
|
+
const valueProps = resolveProps.resolveProps(sep6 ?? [], {
|
|
4018
4018
|
indicator: "map-value-ind",
|
|
4019
4019
|
next: value,
|
|
4020
4020
|
offset: keyNode.range[2],
|
|
@@ -4030,7 +4030,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
4030
4030
|
if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
|
|
4031
4031
|
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
|
|
4032
4032
|
}
|
|
4033
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset,
|
|
4033
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep6, null, valueProps, onError);
|
|
4034
4034
|
if (ctx.schema.compat)
|
|
4035
4035
|
utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
|
|
4036
4036
|
offset = valueNode.range[2];
|
|
@@ -4121,7 +4121,7 @@ var require_resolve_end = __commonJS({
|
|
|
4121
4121
|
let comment = "";
|
|
4122
4122
|
if (end) {
|
|
4123
4123
|
let hasSpace = false;
|
|
4124
|
-
let
|
|
4124
|
+
let sep6 = "";
|
|
4125
4125
|
for (const token of end) {
|
|
4126
4126
|
const { source, type } = token;
|
|
4127
4127
|
switch (type) {
|
|
@@ -4135,13 +4135,13 @@ var require_resolve_end = __commonJS({
|
|
|
4135
4135
|
if (!comment)
|
|
4136
4136
|
comment = cb;
|
|
4137
4137
|
else
|
|
4138
|
-
comment +=
|
|
4139
|
-
|
|
4138
|
+
comment += sep6 + cb;
|
|
4139
|
+
sep6 = "";
|
|
4140
4140
|
break;
|
|
4141
4141
|
}
|
|
4142
4142
|
case "newline":
|
|
4143
4143
|
if (comment)
|
|
4144
|
-
|
|
4144
|
+
sep6 += source;
|
|
4145
4145
|
hasSpace = true;
|
|
4146
4146
|
break;
|
|
4147
4147
|
default:
|
|
@@ -4184,18 +4184,18 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4184
4184
|
let offset = fc.offset + fc.start.source.length;
|
|
4185
4185
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
4186
4186
|
const collItem = fc.items[i];
|
|
4187
|
-
const { start, key, sep:
|
|
4187
|
+
const { start, key, sep: sep6, value } = collItem;
|
|
4188
4188
|
const props = resolveProps.resolveProps(start, {
|
|
4189
4189
|
flow: fcName,
|
|
4190
4190
|
indicator: "explicit-key-ind",
|
|
4191
|
-
next: key ??
|
|
4191
|
+
next: key ?? sep6?.[0],
|
|
4192
4192
|
offset,
|
|
4193
4193
|
onError,
|
|
4194
4194
|
parentIndent: fc.indent,
|
|
4195
4195
|
startOnNewline: false
|
|
4196
4196
|
});
|
|
4197
4197
|
if (!props.found) {
|
|
4198
|
-
if (!props.anchor && !props.tag && !
|
|
4198
|
+
if (!props.anchor && !props.tag && !sep6 && !value) {
|
|
4199
4199
|
if (i === 0 && props.comma)
|
|
4200
4200
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
4201
4201
|
else if (i < fc.items.length - 1)
|
|
@@ -4249,8 +4249,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4249
4249
|
}
|
|
4250
4250
|
}
|
|
4251
4251
|
}
|
|
4252
|
-
if (!isMap && !
|
|
4253
|
-
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end,
|
|
4252
|
+
if (!isMap && !sep6 && !props.found) {
|
|
4253
|
+
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep6, null, props, onError);
|
|
4254
4254
|
coll.items.push(valueNode);
|
|
4255
4255
|
offset = valueNode.range[2];
|
|
4256
4256
|
if (isBlock(value))
|
|
@@ -4262,7 +4262,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4262
4262
|
if (isBlock(key))
|
|
4263
4263
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
4264
4264
|
ctx.atKey = false;
|
|
4265
|
-
const valueProps = resolveProps.resolveProps(
|
|
4265
|
+
const valueProps = resolveProps.resolveProps(sep6 ?? [], {
|
|
4266
4266
|
flow: fcName,
|
|
4267
4267
|
indicator: "map-value-ind",
|
|
4268
4268
|
next: value,
|
|
@@ -4273,8 +4273,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4273
4273
|
});
|
|
4274
4274
|
if (valueProps.found) {
|
|
4275
4275
|
if (!isMap && !props.found && ctx.options.strict) {
|
|
4276
|
-
if (
|
|
4277
|
-
for (const st of
|
|
4276
|
+
if (sep6)
|
|
4277
|
+
for (const st of sep6) {
|
|
4278
4278
|
if (st === valueProps.found)
|
|
4279
4279
|
break;
|
|
4280
4280
|
if (st.type === "newline") {
|
|
@@ -4291,7 +4291,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4291
4291
|
else
|
|
4292
4292
|
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
|
|
4293
4293
|
}
|
|
4294
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end,
|
|
4294
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep6, null, valueProps, onError) : null;
|
|
4295
4295
|
if (valueNode) {
|
|
4296
4296
|
if (isBlock(value))
|
|
4297
4297
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
@@ -4471,7 +4471,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
4471
4471
|
chompStart = i + 1;
|
|
4472
4472
|
}
|
|
4473
4473
|
let value = "";
|
|
4474
|
-
let
|
|
4474
|
+
let sep6 = "";
|
|
4475
4475
|
let prevMoreIndented = false;
|
|
4476
4476
|
for (let i = 0; i < contentStart; ++i)
|
|
4477
4477
|
value += lines[i][0].slice(trimIndent) + "\n";
|
|
@@ -4488,24 +4488,24 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
4488
4488
|
indent = "";
|
|
4489
4489
|
}
|
|
4490
4490
|
if (type === Scalar.Scalar.BLOCK_LITERAL) {
|
|
4491
|
-
value +=
|
|
4492
|
-
|
|
4491
|
+
value += sep6 + indent.slice(trimIndent) + content;
|
|
4492
|
+
sep6 = "\n";
|
|
4493
4493
|
} else if (indent.length > trimIndent || content[0] === " ") {
|
|
4494
|
-
if (
|
|
4495
|
-
|
|
4496
|
-
else if (!prevMoreIndented &&
|
|
4497
|
-
|
|
4498
|
-
value +=
|
|
4499
|
-
|
|
4494
|
+
if (sep6 === " ")
|
|
4495
|
+
sep6 = "\n";
|
|
4496
|
+
else if (!prevMoreIndented && sep6 === "\n")
|
|
4497
|
+
sep6 = "\n\n";
|
|
4498
|
+
value += sep6 + indent.slice(trimIndent) + content;
|
|
4499
|
+
sep6 = "\n";
|
|
4500
4500
|
prevMoreIndented = true;
|
|
4501
4501
|
} else if (content === "") {
|
|
4502
|
-
if (
|
|
4502
|
+
if (sep6 === "\n")
|
|
4503
4503
|
value += "\n";
|
|
4504
4504
|
else
|
|
4505
|
-
|
|
4505
|
+
sep6 = "\n";
|
|
4506
4506
|
} else {
|
|
4507
|
-
value +=
|
|
4508
|
-
|
|
4507
|
+
value += sep6 + content;
|
|
4508
|
+
sep6 = " ";
|
|
4509
4509
|
prevMoreIndented = false;
|
|
4510
4510
|
}
|
|
4511
4511
|
}
|
|
@@ -4687,25 +4687,25 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
4687
4687
|
if (!match)
|
|
4688
4688
|
return source;
|
|
4689
4689
|
let res = match[1];
|
|
4690
|
-
let
|
|
4690
|
+
let sep6 = " ";
|
|
4691
4691
|
let pos = first.lastIndex;
|
|
4692
4692
|
line.lastIndex = pos;
|
|
4693
4693
|
while (match = line.exec(source)) {
|
|
4694
4694
|
if (match[1] === "") {
|
|
4695
|
-
if (
|
|
4696
|
-
res +=
|
|
4695
|
+
if (sep6 === "\n")
|
|
4696
|
+
res += sep6;
|
|
4697
4697
|
else
|
|
4698
|
-
|
|
4698
|
+
sep6 = "\n";
|
|
4699
4699
|
} else {
|
|
4700
|
-
res +=
|
|
4701
|
-
|
|
4700
|
+
res += sep6 + match[1];
|
|
4701
|
+
sep6 = " ";
|
|
4702
4702
|
}
|
|
4703
4703
|
pos = line.lastIndex;
|
|
4704
4704
|
}
|
|
4705
4705
|
const last = /[ \t]*(.*)/sy;
|
|
4706
4706
|
last.lastIndex = pos;
|
|
4707
4707
|
match = last.exec(source);
|
|
4708
|
-
return res +
|
|
4708
|
+
return res + sep6 + (match?.[1] ?? "");
|
|
4709
4709
|
}
|
|
4710
4710
|
function doubleQuotedValue(source, onError) {
|
|
4711
4711
|
let res = "";
|
|
@@ -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": {
|
|
@@ -5508,20 +5508,20 @@ var require_cst_stringify = __commonJS({
|
|
|
5508
5508
|
}
|
|
5509
5509
|
}
|
|
5510
5510
|
}
|
|
5511
|
-
function stringifyItem({ start, key, sep:
|
|
5511
|
+
function stringifyItem({ start, key, sep: sep6, value }) {
|
|
5512
5512
|
let res = "";
|
|
5513
5513
|
for (const st of start)
|
|
5514
5514
|
res += st.source;
|
|
5515
5515
|
if (key)
|
|
5516
5516
|
res += stringifyToken(key);
|
|
5517
|
-
if (
|
|
5518
|
-
for (const st of
|
|
5517
|
+
if (sep6)
|
|
5518
|
+
for (const st of sep6)
|
|
5519
5519
|
res += st.source;
|
|
5520
5520
|
if (value)
|
|
5521
5521
|
res += stringifyToken(value);
|
|
5522
5522
|
return res;
|
|
5523
5523
|
}
|
|
5524
|
-
exports.stringify =
|
|
5524
|
+
exports.stringify = stringify3;
|
|
5525
5525
|
}
|
|
5526
5526
|
});
|
|
5527
5527
|
|
|
@@ -6665,18 +6665,18 @@ var require_parser = __commonJS({
|
|
|
6665
6665
|
if (this.type === "map-value-ind") {
|
|
6666
6666
|
const prev = getPrevProps(this.peek(2));
|
|
6667
6667
|
const start = getFirstKeyStartProps(prev);
|
|
6668
|
-
let
|
|
6668
|
+
let sep6;
|
|
6669
6669
|
if (scalar.end) {
|
|
6670
|
-
|
|
6671
|
-
|
|
6670
|
+
sep6 = scalar.end;
|
|
6671
|
+
sep6.push(this.sourceToken);
|
|
6672
6672
|
delete scalar.end;
|
|
6673
6673
|
} else
|
|
6674
|
-
|
|
6674
|
+
sep6 = [this.sourceToken];
|
|
6675
6675
|
const map = {
|
|
6676
6676
|
type: "block-map",
|
|
6677
6677
|
offset: scalar.offset,
|
|
6678
6678
|
indent: scalar.indent,
|
|
6679
|
-
items: [{ start, key: scalar, sep:
|
|
6679
|
+
items: [{ start, key: scalar, sep: sep6 }]
|
|
6680
6680
|
};
|
|
6681
6681
|
this.onKeyLine = true;
|
|
6682
6682
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -6829,15 +6829,15 @@ var require_parser = __commonJS({
|
|
|
6829
6829
|
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
|
|
6830
6830
|
const start2 = getFirstKeyStartProps(it.start);
|
|
6831
6831
|
const key = it.key;
|
|
6832
|
-
const
|
|
6833
|
-
|
|
6832
|
+
const sep6 = it.sep;
|
|
6833
|
+
sep6.push(this.sourceToken);
|
|
6834
6834
|
delete it.key;
|
|
6835
6835
|
delete it.sep;
|
|
6836
6836
|
this.stack.push({
|
|
6837
6837
|
type: "block-map",
|
|
6838
6838
|
offset: this.offset,
|
|
6839
6839
|
indent: this.indent,
|
|
6840
|
-
items: [{ start: start2, key, sep:
|
|
6840
|
+
items: [{ start: start2, key, sep: sep6 }]
|
|
6841
6841
|
});
|
|
6842
6842
|
} else if (start.length > 0) {
|
|
6843
6843
|
it.sep = it.sep.concat(start, this.sourceToken);
|
|
@@ -7021,13 +7021,13 @@ var require_parser = __commonJS({
|
|
|
7021
7021
|
const prev = getPrevProps(parent);
|
|
7022
7022
|
const start = getFirstKeyStartProps(prev);
|
|
7023
7023
|
fixFlowSeqItems(fc);
|
|
7024
|
-
const
|
|
7025
|
-
|
|
7024
|
+
const sep6 = fc.end.splice(1, fc.end.length);
|
|
7025
|
+
sep6.push(this.sourceToken);
|
|
7026
7026
|
const map = {
|
|
7027
7027
|
type: "block-map",
|
|
7028
7028
|
offset: fc.offset,
|
|
7029
7029
|
indent: fc.indent,
|
|
7030
|
-
items: [{ start, key: fc, sep:
|
|
7030
|
+
items: [{ start, key: fc, sep: sep6 }]
|
|
7031
7031
|
};
|
|
7032
7032
|
this.onKeyLine = true;
|
|
7033
7033
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -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 realpathSync6, writeFileSync as writeFileSync15 } from "node:fs";
|
|
7310
|
+
import { dirname as dirname6, join as join32, resolve as resolve3 } from "node:path";
|
|
7311
7311
|
import { fileURLToPath } from "node:url";
|
|
7312
7312
|
|
|
7313
7313
|
// src/check.ts
|
|
@@ -7335,17 +7335,17 @@ function findCycles(tasks) {
|
|
|
7335
7335
|
const state = /* @__PURE__ */ new Map();
|
|
7336
7336
|
const cycles = [];
|
|
7337
7337
|
const stack = [];
|
|
7338
|
-
const visit = (
|
|
7339
|
-
if (state.get(
|
|
7340
|
-
if (state.get(
|
|
7341
|
-
cycles.push([...stack.slice(stack.indexOf(
|
|
7338
|
+
const visit = (id2) => {
|
|
7339
|
+
if (state.get(id2) === "done") return;
|
|
7340
|
+
if (state.get(id2) === "visiting") {
|
|
7341
|
+
cycles.push([...stack.slice(stack.indexOf(id2)), id2]);
|
|
7342
7342
|
return;
|
|
7343
7343
|
}
|
|
7344
|
-
state.set(
|
|
7345
|
-
stack.push(
|
|
7346
|
-
for (const dep of byId.get(
|
|
7344
|
+
state.set(id2, "visiting");
|
|
7345
|
+
stack.push(id2);
|
|
7346
|
+
for (const dep of byId.get(id2)?.blocked_by ?? []) if (byId.has(dep)) visit(dep);
|
|
7347
7347
|
stack.pop();
|
|
7348
|
-
state.set(
|
|
7348
|
+
state.set(id2, "done");
|
|
7349
7349
|
};
|
|
7350
7350
|
for (const t of [...tasks].sort((a, b) => a.id.localeCompare(b.id))) visit(t.id);
|
|
7351
7351
|
return cycles;
|
|
@@ -7354,12 +7354,12 @@ function computeWaves(tasks, sharedPaths) {
|
|
|
7354
7354
|
if (findCycles(tasks).length) return void 0;
|
|
7355
7355
|
const byId = new Map(tasks.map((t) => [t.id, t]));
|
|
7356
7356
|
const layer = /* @__PURE__ */ new Map();
|
|
7357
|
-
const layerOf = (
|
|
7358
|
-
const known = layer.get(
|
|
7357
|
+
const layerOf = (id2) => {
|
|
7358
|
+
const known = layer.get(id2);
|
|
7359
7359
|
if (known !== void 0) return known;
|
|
7360
|
-
const deps = (byId.get(
|
|
7360
|
+
const deps = (byId.get(id2)?.blocked_by ?? []).filter((d) => byId.has(d));
|
|
7361
7361
|
const l = deps.length ? Math.max(...deps.map(layerOf)) + 1 : 1;
|
|
7362
|
-
layer.set(
|
|
7362
|
+
layer.set(id2, l);
|
|
7363
7363
|
return l;
|
|
7364
7364
|
};
|
|
7365
7365
|
const ordered = [...tasks].sort((a, b) => layerOf(a.id) - layerOf(b.id) || a.id.localeCompare(b.id));
|
|
@@ -7457,10 +7457,10 @@ function runs(root) {
|
|
|
7457
7457
|
return [...new Map(readLog(root, "runs").map((run2) => [run2.id, run2])).values()];
|
|
7458
7458
|
}
|
|
7459
7459
|
function recordRun(root, data) {
|
|
7460
|
-
const
|
|
7461
|
-
const existing = runs(root).find((run3) => run3.id ===
|
|
7460
|
+
const id2 = digest(data);
|
|
7461
|
+
const existing = runs(root).find((run3) => run3.id === id2);
|
|
7462
7462
|
if (existing) return existing;
|
|
7463
|
-
const run2 = { version: 1, id, at: (/* @__PURE__ */ new Date()).toISOString(), ...data };
|
|
7463
|
+
const run2 = { version: 1, id: id2, at: (/* @__PURE__ */ new Date()).toISOString(), ...data };
|
|
7464
7464
|
appendLog(root, "runs", run2);
|
|
7465
7465
|
return run2;
|
|
7466
7466
|
}
|
|
@@ -7534,6 +7534,27 @@ function validateMockupSwarm(root, workDir, input) {
|
|
|
7534
7534
|
return { personas, findings: rows, files: [...files2] };
|
|
7535
7535
|
}
|
|
7536
7536
|
|
|
7537
|
+
// src/templates.gen.ts
|
|
7538
|
+
var TEMPLATES = {
|
|
7539
|
+
"AGENTS.block.md": "<!-- lead:begin -->\n## lead (optional)\n\nThis repo can be worked with lead, a dev-loop kit. It is opt-in: ignore this section unless the person runs `/lead` (Claude Code) or `$lead` (Codex) or asks to use lead.\n\nWhen lead is used:\n- Plans and tasks live in `work/` (or `<project>/work/`); settings in `.lead/config.yml`; repo rules for lead in `.lead/local.md` and `.lead/local/`.\n- A lead task is done only when `node .lead/lead.mjs finish` succeeded.\n- Do not edit lead's own files (`.lead/lead.mjs`, `.agents/skills/lead*`, `.claude/skills/lead*`); an update replaces them.\n- A delegated service lives only in its skill (`\u2026/lead/delegates/<id>/` or `.lead/delegates/<id>/`). How it works, handoff, and check stay there; do not copy them into other lead files.\n- A Cursor `/goal` is not started by lead. When a goal is active here, follow the `lead-goal` skill: a short heartbeat every reply, and append events with `node .lead/lead.mjs activity` into `.lead/activity/` (for later harness analysis).\n<!-- lead:end -->\n",
|
|
7540
|
+
"config.yml": 'version: 1\n# planning: adopted # existing product with an established One Pager and tracker\n# Commands that verify a task. {name} is the project name in a monorepo.\nchecks: {}\nlimits:\n wip: 3 # tasks in progress at once\n rounds: 5 # do-and-check rounds before asking a human\n reviews: 3 # independent reviews before asking a human\n minutes: 60 # wall time on one task before stopping to report\n# projects: # uncomment for a repo with several projects\n# glob: apps/*\n# create: pnpm new {name}\n# work_dir: "{path}/work"\nshared_paths: []\n# worktree_setup: pnpm install --offline --frozen-lockfile # run once in each new task worktree\nreview: task\n# qa: # browser QA in reviews and /lead qa\n# run: pnpm dev {name}\n# url: http://localhost:5173\n# ready: Local:\n# can_show: deployed # one-pager "Can show now" needs `deployed:` on the task, not just a merge\n# sync: # /lead sync to FuseBase and Jira\n# fusebase: {org: <org id>, workspace: <workspace id>, parent_folder: <folder id>}\n# jira: {site: <site>.atlassian.net, project: <KEY>, epic: <KEY-1>}\n# links:\n# repo: https://gitlab.example.com/group/repo # web address; file links and merge requests\n# branch: main\n# app: https://dev.example.com/app # running instance, shown in the one-pager and issues\n',
|
|
7541
|
+
"how.md": 'HOW TO WORK WITH LEAD\n\n /lead say what you want in plain words; lead shows the state and the next step\n /lead how this page /lead help all commands\n /lead enable lead is off by default for each person; this turns on its hooks for you\n\nTHE FLOW YOU (a person)\n 1 plan research or reverse \u2192 flows \u2192 mockups \u25C0\u2500\u2500 confirm the spec (flows, mockups, acceptance)\n \u2192 acceptance \u2192 architecture \u2192 tasks\n 2 build per task: worktree \u2192 code \u2192 checks\n \u2192 independent review with browser QA \u25C0\u2500\u2500 answer questions in "Needs you"\n \u2192 finish (waits for you) \u25C0\u2500\u2500 review and merge the branch\n 3 accept milestone QA in the browser \u25C0\u2500\u2500 decide "good enough": close the milestone,\n move the rest to the next one\n 4 share /lead sync \u2192 FuseBase notes, Jira \u25C0\u2500\u2500 one yes for note updates (if you have access)\n\nSTAGES\n Each bar starts when the previous stage ends. The dates are a reading order, not a plan.\n\n```mermaid\ngantt\n title Project stages\n dateFormat YYYY-MM-DD\n axisFormat %b %d\n\n section Plan\n Research :p1, 2026-01-01, 7d\n Flows :p2, after p1, 7d\n Mockups :p3, after p2, 7d\n Acceptance :p4, after p3, 7d\n Architecture :p5, after p4, 7d\n Tasks :p6, after p5, 7d\n\n section Build\n Build :b1, after p6, 7d\n Review :b2, after b1, 7d\n\n section Accept\n Milestone QA :c1, after b2, 7d\n\n section Share\n Sync :s1, after c1, 7d\n```\n\nWHERE THINGS ARE\n work/one-pager.md for the business: milestones, what can be shown, risks\n work/board.md for the team: ready, in progress, in review, needs you, waves\n work/spec.md the product, assembled from work/spec/ (do not edit spec.md itself)\n work/tasks/ one file per task: criteria, checks, review, questions\n .lead/config.yml checks, projects, sync, QA .lead/local* your rules (kept on update)\n\nRULES THAT MATTER\n \xB7 A task is done only when finish succeeded: checks recorded on the final code, every\n criterion pass, an independent review. "It works" in chat is not done.\n \xB7 A confirmed spec section changes only after you reopen it.\n \xB7 Work stopped midway (limit, computer off)? Run /lead: it offers to continue.\n \xB7 Keep work/ and .lead/config.yml in git: they are the shared state.\n',
|
|
7542
|
+
"local-README.md": "# Project rules for lead skills\n\nFiles here are yours: `lead update` never changes them. Each adds rules on top of one lead skill reference:\n\n- `plan.md` \u2014 planning, spec stages, mockups\n- `task.md` \u2014 doing a task\n- `review.md` / `qa.md` \u2014 review and browser QA\n- `sync.md` \u2014 FuseBase / Jira sync\n- `reverse.md` \u2014 studying a running product\n\nGeneral rules for this repo go to `.lead/local.md`. Do not edit lead's own files (`.lead/lead.mjs`, `.agents/skills/lead*`, `.claude/skills/lead*`): an update replaces them.\n",
|
|
7543
|
+
"local.md": "# Project rules for lead\n\nRules in plain words that lead's skills follow on top of their own. Examples:\n\n- Never edit an existing migration; add the next numbered one.\n- UI tasks are also checked in Safari.\n",
|
|
7544
|
+
"spec-01-research.md": "---\nstage: research\nstatus: draft\n---\n## 1. Research\n\nThe long note before implementation. Product language. No source of another product copied verbatim. Write `unknown` where you did not look. Conclusions are the only part repeated on the one-pager.\n\n### Users and the problem\n\nWho it is for, what they do today, and what is painful.\n\n### What already exists\n\nDocs, a running product, or the code as it is. Name what was read.\n\n### Constraints\n\nLicense, access, data that must not move, and decisions already made.\n\n### Unknown\n\nWhat was not checked, and what would change the plan if it turned out otherwise.\n\n### Conclusions\n\nA few decisions the rest of the spec follows. Not a summary of the sections above.\n\n## Questions to earlier stages\n",
|
|
7545
|
+
"spec-02-flows.md": "---\nstage: flows\nstatus: draft\n---\n## 2. Flows\n\n### 2.1 Roles and what each sees\n\n### 2.2 Journey map\n\n### 2.3 Stages\n\n<!-- For each stage: how a record appears, statuses and their meaning, what is needed to leave, side effects. A state diagram only where transitions are real. -->\n\n### 2.4 Numbers\n\n<!-- For each number or chart: population, time window, aggregation, exceptions. -->\n\n### 2.5 Links between records\n\n## Questions to earlier stages\n",
|
|
7546
|
+
"spec-03-mockups.md": "---\nstage: mockups\nstatus: draft\n---\n## 3. Screens\n\n<!-- One entry per screen: purpose, what is on it, states (empty, loading, error), link to work/mockups/<screen>.html. -->\n\n## Questions to earlier stages\n",
|
|
7547
|
+
"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",
|
|
7548
|
+
"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',
|
|
7549
|
+
"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",
|
|
7550
|
+
"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",
|
|
7551
|
+
"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",
|
|
7552
|
+
"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.2'], 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",
|
|
7553
|
+
"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',
|
|
7554
|
+
"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',
|
|
7555
|
+
"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"
|
|
7556
|
+
};
|
|
7557
|
+
|
|
7537
7558
|
// src/spec.ts
|
|
7538
7559
|
var LOCKS = ".confirmed.json";
|
|
7539
7560
|
var hash = (s) => createHash2("sha256").update(s.trim()).digest("hex").slice(0, 16);
|
|
@@ -7613,6 +7634,15 @@ function setSectionStatus(root, workDir, name, status2, project = ".") {
|
|
|
7613
7634
|
writeLocks(workDir, locks);
|
|
7614
7635
|
return `${s.name}: ${status2}`;
|
|
7615
7636
|
}
|
|
7637
|
+
var TEMPLATE_OF = { research: "spec-01-research.md", flows: "spec-02-flows.md", mockups: "spec-03-mockups.md", acceptance: "spec-04-acceptance.md" };
|
|
7638
|
+
var squash = (text) => text.replace(/<!--[\s\S]*?-->/g, "").replace(/\s+/g, " ").trim();
|
|
7639
|
+
function isUntouchedTemplate(name, body) {
|
|
7640
|
+
const key = TEMPLATE_OF[name];
|
|
7641
|
+
const template = key ? TEMPLATES[key] : void 0;
|
|
7642
|
+
if (!template) return false;
|
|
7643
|
+
const { parsed } = parseFrontmatter(template, key);
|
|
7644
|
+
return !!parsed && squash(parsed.body) === squash(body);
|
|
7645
|
+
}
|
|
7616
7646
|
|
|
7617
7647
|
// src/check.ts
|
|
7618
7648
|
var SECRET_PATTERNS = [
|
|
@@ -8092,7 +8122,8 @@ function parseTask(text, file) {
|
|
|
8092
8122
|
file,
|
|
8093
8123
|
criteria: parseCriteria(parsed.body),
|
|
8094
8124
|
...qa?.length ? { qa_required: qa } : {},
|
|
8095
|
-
...d.sync_jira === false ? { sync_jira: false } : {}
|
|
8125
|
+
...d.sync_jira === false ? { sync_jira: false } : {},
|
|
8126
|
+
...typeof d.repo === "string" && d.repo.trim() ? { repo: d.repo.trim() } : {}
|
|
8096
8127
|
},
|
|
8097
8128
|
issues
|
|
8098
8129
|
};
|
|
@@ -8194,27 +8225,6 @@ import { createHash as createHash3 } from "node:crypto";
|
|
|
8194
8225
|
import { copyFileSync, existsSync as existsSync10, mkdirSync as mkdirSync3, readdirSync as readdirSync6, readFileSync as readFileSync9, statSync as statSync4, writeFileSync as writeFileSync4 } from "node:fs";
|
|
8195
8226
|
import { dirname as dirname2, join as join11, relative as relative7 } from "node:path";
|
|
8196
8227
|
|
|
8197
|
-
// src/templates.gen.ts
|
|
8198
|
-
var TEMPLATES = {
|
|
8199
|
-
"AGENTS.block.md": "<!-- lead:begin -->\n## lead (optional)\n\nThis repo can be worked with lead, a dev-loop kit. It is opt-in: ignore this section unless the person runs `/lead` (Claude Code) or `$lead` (Codex) or asks to use lead.\n\nWhen lead is used:\n- Plans and tasks live in `work/` (or `<project>/work/`); settings in `.lead/config.yml`; repo rules for lead in `.lead/local.md` and `.lead/local/`.\n- A lead task is done only when `node .lead/lead.mjs finish` succeeded.\n- Do not edit lead's own files (`.lead/lead.mjs`, `.agents/skills/lead*`, `.claude/skills/lead*`); an update replaces them.\n- A delegated service lives only in its skill (`\u2026/lead/delegates/<id>/` or `.lead/delegates/<id>/`). How it works, handoff, and check stay there; do not copy them into other lead files.\n- A Cursor `/goal` is not started by lead. When a goal is active here, follow the `lead-goal` skill: a short heartbeat every reply, and append events with `node .lead/lead.mjs activity` into `.lead/activity/` (for later harness analysis).\n<!-- lead:end -->\n",
|
|
8200
|
-
"config.yml": 'version: 1\n# planning: adopted # existing product with an established One Pager and tracker\n# Commands that verify a task. {name} is the project name in a monorepo.\nchecks: {}\nlimits:\n wip: 3 # tasks in progress at once\n rounds: 5 # do-and-check rounds before asking a human\n reviews: 3 # independent reviews before asking a human\n minutes: 60 # wall time on one task before stopping to report\n# projects: # uncomment for a repo with several projects\n# glob: apps/*\n# create: pnpm new {name}\n# work_dir: "{path}/work"\nshared_paths: []\n# worktree_setup: pnpm install --offline --frozen-lockfile # run once in each new task worktree\nreview: task\n# qa: # browser QA in reviews and /lead qa\n# run: pnpm dev {name}\n# url: http://localhost:5173\n# ready: Local:\n# can_show: deployed # one-pager "Can show now" needs `deployed:` on the task, not just a merge\n# sync: # /lead sync to FuseBase and Jira\n# fusebase: {org: <org id>, workspace: <workspace id>, parent_folder: <folder id>}\n# jira: {site: <site>.atlassian.net, project: <KEY>, epic: <KEY-1>}\n# links:\n# repo: https://gitlab.example.com/group/repo # web address; file links and merge requests\n# branch: main\n# app: https://dev.example.com/app # running instance, shown in the one-pager and issues\n',
|
|
8201
|
-
"how.md": 'HOW TO WORK WITH LEAD\n\n /lead say what you want in plain words; lead shows the state and the next step\n /lead how this page /lead help all commands\n /lead enable lead is off by default for each person; this turns on its hooks for you\n\nTHE FLOW YOU (a person)\n 1 plan research or reverse \u2192 flows \u2192 mockups \u25C0\u2500\u2500 confirm the spec (flows, mockups, acceptance)\n \u2192 acceptance \u2192 architecture \u2192 tasks\n 2 build per task: worktree \u2192 code \u2192 checks\n \u2192 independent review with browser QA \u25C0\u2500\u2500 answer questions in "Needs you"\n \u2192 finish (waits for you) \u25C0\u2500\u2500 review and merge the branch\n 3 accept milestone QA in the browser \u25C0\u2500\u2500 decide "good enough": close the milestone,\n move the rest to the next one\n 4 share /lead sync \u2192 FuseBase notes, Jira \u25C0\u2500\u2500 one yes for note updates (if you have access)\n\nSTAGES\n Each bar starts when the previous stage ends. The dates are a reading order, not a plan.\n\n```mermaid\ngantt\n title Project stages\n dateFormat YYYY-MM-DD\n axisFormat %b %d\n\n section Plan\n Research :p1, 2026-01-01, 7d\n Flows :p2, after p1, 7d\n Mockups :p3, after p2, 7d\n Acceptance :p4, after p3, 7d\n Architecture :p5, after p4, 7d\n Tasks :p6, after p5, 7d\n\n section Build\n Build :b1, after p6, 7d\n Review :b2, after b1, 7d\n\n section Accept\n Milestone QA :c1, after b2, 7d\n\n section Share\n Sync :s1, after c1, 7d\n```\n\nWHERE THINGS ARE\n work/one-pager.md for the business: milestones, what can be shown, risks\n work/board.md for the team: ready, in progress, in review, needs you, waves\n work/spec.md the product, assembled from work/spec/ (do not edit spec.md itself)\n work/tasks/ one file per task: criteria, checks, review, questions\n .lead/config.yml checks, projects, sync, QA .lead/local* your rules (kept on update)\n\nRULES THAT MATTER\n \xB7 A task is done only when finish succeeded: checks recorded on the final code, every\n criterion pass, an independent review. "It works" in chat is not done.\n \xB7 A confirmed spec section changes only after you reopen it.\n \xB7 Work stopped midway (limit, computer off)? Run /lead: it offers to continue.\n \xB7 Keep work/ and .lead/config.yml in git: they are the shared state.\n',
|
|
8202
|
-
"local-README.md": "# Project rules for lead skills\n\nFiles here are yours: `lead update` never changes them. Each adds rules on top of one lead skill reference:\n\n- `plan.md` \u2014 planning, spec stages, mockups\n- `task.md` \u2014 doing a task\n- `review.md` / `qa.md` \u2014 review and browser QA\n- `sync.md` \u2014 FuseBase / Jira sync\n- `reverse.md` \u2014 studying a running product\n\nGeneral rules for this repo go to `.lead/local.md`. Do not edit lead's own files (`.lead/lead.mjs`, `.agents/skills/lead*`, `.claude/skills/lead*`): an update replaces them.\n",
|
|
8203
|
-
"local.md": "# Project rules for lead\n\nRules in plain words that lead's skills follow on top of their own. Examples:\n\n- Never edit an existing migration; add the next numbered one.\n- UI tasks are also checked in Safari.\n",
|
|
8204
|
-
"spec-01-research.md": "---\nstage: research\nstatus: draft\n---\n## 1. Research\n\nThe long note before implementation. Product language. No source of another product copied verbatim. Write `unknown` where you did not look. Conclusions are the only part repeated on the one-pager.\n\n### Users and the problem\n\nWho it is for, what they do today, and what is painful.\n\n### What already exists\n\nDocs, a running product, or the code as it is. Name what was read.\n\n### Constraints\n\nLicense, access, data that must not move, and decisions already made.\n\n### Unknown\n\nWhat was not checked, and what would change the plan if it turned out otherwise.\n\n### Conclusions\n\nA few decisions the rest of the spec follows. Not a summary of the sections above.\n\n## Questions to earlier stages\n",
|
|
8205
|
-
"spec-02-flows.md": "---\nstage: flows\nstatus: draft\n---\n## 2. Flows\n\n### 2.1 Roles and what each sees\n\n### 2.2 Journey map\n\n### 2.3 Stages\n\n<!-- For each stage: how a record appears, statuses and their meaning, what is needed to leave, side effects. A state diagram only where transitions are real. -->\n\n### 2.4 Numbers\n\n<!-- For each number or chart: population, time window, aggregation, exceptions. -->\n\n### 2.5 Links between records\n\n## Questions to earlier stages\n",
|
|
8206
|
-
"spec-03-mockups.md": "---\nstage: mockups\nstatus: draft\n---\n## 3. Screens\n\n<!-- One entry per screen: purpose, what is on it, states (empty, loading, error), link to work/mockups/<screen>.html. -->\n\n## Questions to earlier stages\n",
|
|
8207
|
-
"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
|
-
"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
|
-
"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 -->\nFind 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
|
-
"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.2.42'], 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
|
-
"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
|
-
"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
|
-
"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"
|
|
8216
|
-
};
|
|
8217
|
-
|
|
8218
8228
|
// src/settings.ts
|
|
8219
8229
|
import { existsSync as existsSync9, mkdirSync as mkdirSync2, readFileSync as readFileSync8, writeFileSync as writeFileSync3 } from "node:fs";
|
|
8220
8230
|
import { dirname, join as join10 } from "node:path";
|
|
@@ -8287,7 +8297,7 @@ function ensureCodexHooks(root) {
|
|
|
8287
8297
|
}
|
|
8288
8298
|
|
|
8289
8299
|
// src/install.ts
|
|
8290
|
-
var VERSION = true ? "0.2
|
|
8300
|
+
var VERSION = true ? "0.3.2" : "dev";
|
|
8291
8301
|
var LOCK_PATH = ".lead/kit.lock";
|
|
8292
8302
|
var SKILLS = ["lead", "crew-lead", "lead-goal"];
|
|
8293
8303
|
var SKILL_DIRS = [".agents/skills", ".claude/skills"];
|
|
@@ -8526,8 +8536,8 @@ function withRegistryKit(root, out, useKit) {
|
|
|
8526
8536
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
8527
8537
|
import { createHash as createHash4, randomUUID } from "node:crypto";
|
|
8528
8538
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
8529
|
-
import { copyFileSync as copyFileSync2, cpSync, existsSync as
|
|
8530
|
-
import { dirname as dirname3, isAbsolute as isAbsolute2, join as
|
|
8539
|
+
import { copyFileSync as copyFileSync2, cpSync, existsSync as existsSync16, mkdirSync as mkdirSync5, readFileSync as readFileSync14, readdirSync as readdirSync9, realpathSync as realpathSync3, renameSync, rmSync as rmSync2, writeFileSync as writeFileSync6 } from "node:fs";
|
|
8540
|
+
import { dirname as dirname3, isAbsolute as isAbsolute2, join as join17, relative as relative8, resolve as resolve2, sep as sep3 } from "node:path";
|
|
8531
8541
|
|
|
8532
8542
|
// src/board.ts
|
|
8533
8543
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
@@ -8666,9 +8676,309 @@ function renderOnePagerBlocks(tasks, milestones, isMerged, showRule = "merged")
|
|
|
8666
8676
|
};
|
|
8667
8677
|
}
|
|
8668
8678
|
|
|
8669
|
-
// src/
|
|
8670
|
-
import { existsSync as
|
|
8679
|
+
// src/initiative.ts
|
|
8680
|
+
import { existsSync as existsSync14, readdirSync as readdirSync8, readFileSync as readFileSync12 } from "node:fs";
|
|
8681
|
+
import { join as join15 } from "node:path";
|
|
8682
|
+
|
|
8683
|
+
// src/adapter.ts
|
|
8684
|
+
import { existsSync as existsSync12, readdirSync as readdirSync7, readFileSync as readFileSync11 } from "node:fs";
|
|
8671
8685
|
import { join as join13 } from "node:path";
|
|
8686
|
+
var ADAPTERS_DIR = ".lead/adapters";
|
|
8687
|
+
var ID2 = /^[a-z][a-z0-9-]*$/;
|
|
8688
|
+
function listAdapters(root) {
|
|
8689
|
+
const dir = join13(root, ADAPTERS_DIR);
|
|
8690
|
+
const adapters = [];
|
|
8691
|
+
const issues = [];
|
|
8692
|
+
if (!existsSync12(dir)) return { adapters, issues };
|
|
8693
|
+
for (const name of readdirSync7(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort()) {
|
|
8694
|
+
const rel = `${ADAPTERS_DIR}/${name}/SKILL.md`;
|
|
8695
|
+
const abs = join13(root, rel);
|
|
8696
|
+
if (!existsSync12(abs)) {
|
|
8697
|
+
issues.push(`${ADAPTERS_DIR}/${name}: no SKILL.md`);
|
|
8698
|
+
continue;
|
|
8699
|
+
}
|
|
8700
|
+
const { parsed } = parseFrontmatter(readFileSync11(abs, "utf8"), rel);
|
|
8701
|
+
const declared = typeof parsed?.data.name === "string" ? parsed.data.name : name;
|
|
8702
|
+
if (!ID2.test(name)) {
|
|
8703
|
+
issues.push(`${rel}: folder name must look like "private-space"`);
|
|
8704
|
+
} else if (declared !== name) {
|
|
8705
|
+
issues.push(`${rel}: name "${declared}" must match the folder "${name}"`);
|
|
8706
|
+
} else {
|
|
8707
|
+
adapters.push({
|
|
8708
|
+
id: name,
|
|
8709
|
+
title: typeof parsed?.data.title === "string" ? parsed.data.title : name,
|
|
8710
|
+
appliesTo: typeof parsed?.data.applies_to === "string" ? parsed.data.applies_to : "",
|
|
8711
|
+
file: rel
|
|
8712
|
+
});
|
|
8713
|
+
}
|
|
8714
|
+
}
|
|
8715
|
+
return { adapters, issues };
|
|
8716
|
+
}
|
|
8717
|
+
|
|
8718
|
+
// src/initiative-tasks.ts
|
|
8719
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
8720
|
+
import { join as join14 } from "node:path";
|
|
8721
|
+
var REF = /^(?:([a-z][a-z0-9-]*):)?(T-\d{3,})$/;
|
|
8722
|
+
function parseRef(ref) {
|
|
8723
|
+
const m = REF.exec(ref);
|
|
8724
|
+
return m ? { ...m[1] ? { repo: m[1] } : {}, id: m[2] } : void 0;
|
|
8725
|
+
}
|
|
8726
|
+
var homeRepo = (i) => i.repos.find((r) => r.role === "home")?.name;
|
|
8727
|
+
var taskRepo = (t, i) => t.repo ?? homeRepo(i) ?? "";
|
|
8728
|
+
function loadInitiativeTasks(root, i) {
|
|
8729
|
+
return loadTasks(root, join14(root, i.dir));
|
|
8730
|
+
}
|
|
8731
|
+
function externalState(ws, repo, id2) {
|
|
8732
|
+
if (!ws) return { state: "unresolved", reason: "no workspace catalog" };
|
|
8733
|
+
const path = ws.repositories[repo];
|
|
8734
|
+
if (!path) return { state: "unresolved", reason: `${repo} is not in the workspace` };
|
|
8735
|
+
if (!existsSync13(path)) return { state: "unresolved", reason: `checkout of ${repo} is missing` };
|
|
8736
|
+
try {
|
|
8737
|
+
const ctx = loadContext(path);
|
|
8738
|
+
if (!ctx.project) return { state: "unresolved", reason: `${repo} has no single lead project` };
|
|
8739
|
+
const t = ctx.tasks.find((x) => x.id === id2);
|
|
8740
|
+
if (!t) return { state: "unresolved", reason: `${repo} has no task ${id2}` };
|
|
8741
|
+
return { state: t.status === "done" ? "done" : "open" };
|
|
8742
|
+
} catch (error) {
|
|
8743
|
+
return { state: "unresolved", reason: error.message };
|
|
8744
|
+
}
|
|
8745
|
+
}
|
|
8746
|
+
function resolveRef(ref, tasks, ws) {
|
|
8747
|
+
const p = parseRef(ref);
|
|
8748
|
+
if (!p) return { ref, state: "unresolved", reason: "not a task reference" };
|
|
8749
|
+
if (!p.repo) return tasks.some((t) => t.id === p.id) ? { ref, state: "internal" } : { ref, state: "unresolved", reason: "no such task in this initiative" };
|
|
8750
|
+
return { ref, ...externalState(ws, p.repo, p.id) };
|
|
8751
|
+
}
|
|
8752
|
+
function scoped(tasks, i) {
|
|
8753
|
+
const ids = new Set(tasks.map((t) => t.id));
|
|
8754
|
+
return tasks.map((t) => ({
|
|
8755
|
+
...t,
|
|
8756
|
+
touches: t.touches.map((p) => `${taskRepo(t, i)}/${p.replace(/^\.\//, "")}`),
|
|
8757
|
+
blocked_by: t.blocked_by.filter((b) => ids.has(b))
|
|
8758
|
+
}));
|
|
8759
|
+
}
|
|
8760
|
+
function initiativeWaves(tasks, i) {
|
|
8761
|
+
return computeWaves(scoped(tasks, i), []);
|
|
8762
|
+
}
|
|
8763
|
+
function writeInitiativeWaves(root, i) {
|
|
8764
|
+
const { tasks } = loadInitiativeTasks(root, i);
|
|
8765
|
+
const waves = initiativeWaves(tasks, i);
|
|
8766
|
+
if (!waves) throw new Error("dependency cycle: fix blocked_by first (run `lead initiative check`)");
|
|
8767
|
+
const log = [];
|
|
8768
|
+
for (const t of tasks) {
|
|
8769
|
+
const w = waves.get(t.id);
|
|
8770
|
+
if (w === void 0 || w === t.wave || t.status === "done") continue;
|
|
8771
|
+
updateTask(root, t, (d) => {
|
|
8772
|
+
d.wave = w;
|
|
8773
|
+
});
|
|
8774
|
+
log.push(`${t.id}: wave ${t.wave ?? "-"} \u2192 ${w}`);
|
|
8775
|
+
}
|
|
8776
|
+
return log.length ? log : ["waves are up to date"];
|
|
8777
|
+
}
|
|
8778
|
+
function checkInitiative(root, i, ws) {
|
|
8779
|
+
const { tasks, issues } = loadInitiativeTasks(root, i);
|
|
8780
|
+
const out = [...issues];
|
|
8781
|
+
const repos = new Set(i.repos.map((r) => r.name));
|
|
8782
|
+
const home = homeRepo(i);
|
|
8783
|
+
const ms = new Set(loadOnePager(root, join14(root, i.dir)).onePager?.milestones.map((m) => m.id) ?? []);
|
|
8784
|
+
for (const t of tasks) {
|
|
8785
|
+
const e = (message, level = "error") => out.push({ level, file: t.file, message });
|
|
8786
|
+
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`);
|
|
8787
|
+
if (t.milestone && ms.size && !ms.has(t.milestone)) e(`milestone "${t.milestone}" is not defined in the initiative one-pager`);
|
|
8788
|
+
for (const ref of t.blocked_by) {
|
|
8789
|
+
const p = parseRef(ref);
|
|
8790
|
+
if (!p) e(`blocked_by ${ref}: use T-001 or <repo>:T-001`);
|
|
8791
|
+
else if (!p.repo && p.id === t.id) e(`${t.id} is blocked by itself`);
|
|
8792
|
+
else if (p.repo && !repos.has(p.repo)) e(`blocked_by ${ref}: repository ${p.repo} is not listed in ${i.file}`);
|
|
8793
|
+
else {
|
|
8794
|
+
const r = resolveRef(ref, tasks, ws);
|
|
8795
|
+
if (r.state === "unresolved") e(`blocked_by ${ref}: ${r.reason}`, p.repo ? "warning" : "error");
|
|
8796
|
+
}
|
|
8797
|
+
}
|
|
8798
|
+
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");
|
|
8799
|
+
}
|
|
8800
|
+
const sc = scoped(tasks, i);
|
|
8801
|
+
const byId = new Map(tasks.map((t) => [t.id, t]));
|
|
8802
|
+
for (const c of findCycles(sc)) out.push({ level: "error", file: byId.get(c[0]).file, message: `dependency cycle: ${c.join(" \u2192 ")}` });
|
|
8803
|
+
const waves = computeWaves(sc, []);
|
|
8804
|
+
const active = sc.filter((t) => t.status !== "done");
|
|
8805
|
+
for (const t of tasks) {
|
|
8806
|
+
if (t.wave === void 0) {
|
|
8807
|
+
if (t.status !== "done") out.push({ level: "warning", file: t.file, message: "wave not set; run `lead initiative waves <id> --write`" });
|
|
8808
|
+
continue;
|
|
8809
|
+
}
|
|
8810
|
+
for (const dep of t.blocked_by) {
|
|
8811
|
+
const d = byId.get(dep);
|
|
8812
|
+
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}` });
|
|
8813
|
+
}
|
|
8814
|
+
const c = waves?.get(t.id);
|
|
8815
|
+
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\`` });
|
|
8816
|
+
}
|
|
8817
|
+
for (let a = 0; a < active.length; a++) {
|
|
8818
|
+
for (let b = a + 1; b < active.length; b++) {
|
|
8819
|
+
const x = active[a];
|
|
8820
|
+
const y = active[b];
|
|
8821
|
+
if (x.wave === void 0 || x.wave !== y.wave) continue;
|
|
8822
|
+
const hits = touchesOverlap(x.touches, y.touches);
|
|
8823
|
+
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(", ")})` });
|
|
8824
|
+
}
|
|
8825
|
+
}
|
|
8826
|
+
return out;
|
|
8827
|
+
}
|
|
8828
|
+
function initiativeTaskRows(root, i, ws) {
|
|
8829
|
+
const { tasks } = loadInitiativeTasks(root, i);
|
|
8830
|
+
return tasks.map((t) => ({
|
|
8831
|
+
id: t.id,
|
|
8832
|
+
title: t.title,
|
|
8833
|
+
repo: taskRepo(t, i),
|
|
8834
|
+
status: t.status,
|
|
8835
|
+
...t.wave !== void 0 ? { wave: t.wave } : {},
|
|
8836
|
+
...t.milestone ? { milestone: t.milestone } : {},
|
|
8837
|
+
blocked_by: t.blocked_by.map((b) => resolveRef(b, tasks, ws))
|
|
8838
|
+
}));
|
|
8839
|
+
}
|
|
8840
|
+
|
|
8841
|
+
// src/initiative.ts
|
|
8842
|
+
var INITIATIVES_DIR = "work/initiatives";
|
|
8843
|
+
var ID3 = /^[a-z][a-z0-9-]*$/;
|
|
8844
|
+
var ROLES = ["home", "reference"];
|
|
8845
|
+
var RESERVED = ["check", "waves"];
|
|
8846
|
+
var str = (v) => typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
8847
|
+
function loadInitiatives(root) {
|
|
8848
|
+
const base = join15(root, INITIATIVES_DIR);
|
|
8849
|
+
const initiatives = [];
|
|
8850
|
+
const issues = [];
|
|
8851
|
+
if (!existsSync14(base)) return { initiatives, issues };
|
|
8852
|
+
for (const entry of readdirSync8(base, { withFileTypes: true }).filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
8853
|
+
const dir = `${INITIATIVES_DIR}/${entry.name}`;
|
|
8854
|
+
const file = `${dir}/initiative.md`;
|
|
8855
|
+
const err = (message) => issues.push({ level: "error", file, message });
|
|
8856
|
+
const abs = join15(root, file);
|
|
8857
|
+
if (!existsSync14(abs)) {
|
|
8858
|
+
issues.push({ level: "warning", file: dir, message: "no initiative.md" });
|
|
8859
|
+
continue;
|
|
8860
|
+
}
|
|
8861
|
+
const { parsed, issues: parseIssues } = parseFrontmatter(readFileSync12(abs, "utf8"), file);
|
|
8862
|
+
issues.push(...parseIssues);
|
|
8863
|
+
if (!parsed) continue;
|
|
8864
|
+
const d = parsed.data;
|
|
8865
|
+
if (!ID3.test(entry.name) || RESERVED.includes(entry.name)) err('folder name must look like "private-space" and not be "check" or "waves"');
|
|
8866
|
+
if (str(d.id) !== entry.name) err(`id must equal the folder name "${entry.name}"`);
|
|
8867
|
+
const repos = [];
|
|
8868
|
+
if (d.repos !== void 0 && !Array.isArray(d.repos)) err("repos must be a list");
|
|
8869
|
+
for (const [i, r] of (Array.isArray(d.repos) ? d.repos : []).entries()) {
|
|
8870
|
+
const row = r ?? {};
|
|
8871
|
+
const name = str(row.name);
|
|
8872
|
+
const role = row.role === void 0 ? "reference" : row.role;
|
|
8873
|
+
if (!name || !ID3.test(name)) err(`repos[${i}].name must look like "org-service"`);
|
|
8874
|
+
else if (!ROLES.includes(role)) err(`repos[${i}].role must be one of ${ROLES.join(", ")}`);
|
|
8875
|
+
else if (repos.some((x) => x.name === name)) err(`repos[${i}]: "${name}" is listed twice`);
|
|
8876
|
+
else repos.push({ name, role, ...str(row.url) ? { url: str(row.url) } : {} });
|
|
8877
|
+
}
|
|
8878
|
+
if (repos.filter((r) => r.role === "home").length > 1) err("only one repository can be home");
|
|
8879
|
+
const map = {};
|
|
8880
|
+
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");
|
|
8881
|
+
for (const [key, v] of Object.entries(typeof d.map === "object" && d.map && !Array.isArray(d.map) ? d.map : {})) {
|
|
8882
|
+
const o = v ?? {};
|
|
8883
|
+
const bad = (m) => err(`map.${key}: ${m}`);
|
|
8884
|
+
if (!/^[A-Z][A-Z0-9]*-\d+$/.test(key)) bad("the key must look like KEY-123");
|
|
8885
|
+
else if (o.repo !== void 0 && (typeof o.repo !== "string" || !ID3.test(o.repo))) bad('repo must look like "org-service"');
|
|
8886
|
+
else if (typeof o.repo === "string" && !repos.some((r) => r.name === o.repo)) bad(`repo "${o.repo}" is not listed in repos`);
|
|
8887
|
+
else if (o.milestone !== void 0 && typeof o.milestone !== "string") bad("milestone must be a milestone id");
|
|
8888
|
+
else if (o.kind !== void 0 && !["work", "qa", "manual"].includes(o.kind)) bad("kind must be work, qa or manual");
|
|
8889
|
+
else map[key] = { ...o.repo ? { repo: o.repo } : {}, ...o.milestone ? { milestone: o.milestone } : {}, ...o.kind ? { kind: o.kind } : {} };
|
|
8890
|
+
}
|
|
8891
|
+
initiatives.push({
|
|
8892
|
+
id: entry.name,
|
|
8893
|
+
title: str(d.title) ?? entry.name,
|
|
8894
|
+
epic: str(d.epic),
|
|
8895
|
+
site: str(d.site),
|
|
8896
|
+
flag: str(d.flag),
|
|
8897
|
+
adapter: str(d.adapter),
|
|
8898
|
+
repos,
|
|
8899
|
+
map,
|
|
8900
|
+
dir,
|
|
8901
|
+
file
|
|
8902
|
+
});
|
|
8903
|
+
}
|
|
8904
|
+
return { initiatives, issues };
|
|
8905
|
+
}
|
|
8906
|
+
function optionalWorkspace(root) {
|
|
8907
|
+
try {
|
|
8908
|
+
return findWorkspace(root);
|
|
8909
|
+
} catch {
|
|
8910
|
+
return void 0;
|
|
8911
|
+
}
|
|
8912
|
+
}
|
|
8913
|
+
function observedCounts(root, i) {
|
|
8914
|
+
const file = join15(root, i.dir, "sync.json");
|
|
8915
|
+
if (!existsSync14(file)) return [];
|
|
8916
|
+
try {
|
|
8917
|
+
const issues = JSON.parse(readFileSync12(file, "utf8")).issues ?? {};
|
|
8918
|
+
const by = /* @__PURE__ */ new Map();
|
|
8919
|
+
for (const x of Object.values(issues)) {
|
|
8920
|
+
const m = x.milestone ?? "?";
|
|
8921
|
+
const row = by.get(m) ?? { milestone: m, total: 0, states: {} };
|
|
8922
|
+
row.total++;
|
|
8923
|
+
row.states[x.observed ?? "other"] = (row.states[x.observed ?? "other"] ?? 0) + 1;
|
|
8924
|
+
by.set(m, row);
|
|
8925
|
+
}
|
|
8926
|
+
return [...by.values()];
|
|
8927
|
+
} catch {
|
|
8928
|
+
return [];
|
|
8929
|
+
}
|
|
8930
|
+
}
|
|
8931
|
+
function initiativeOverview(root, i) {
|
|
8932
|
+
const ws = optionalWorkspace(root);
|
|
8933
|
+
const catalog = ws ? Object.entries(ws.repositories) : [];
|
|
8934
|
+
const op = loadOnePager(root, join15(root, i.dir));
|
|
8935
|
+
const adapters = i.adapter ? listAdapters(root).adapters : [];
|
|
8936
|
+
return {
|
|
8937
|
+
id: i.id,
|
|
8938
|
+
title: i.title,
|
|
8939
|
+
...i.epic ? { epic: i.epic } : {},
|
|
8940
|
+
...i.epic && i.site ? { epicUrl: `https://${i.site}/browse/${i.epic}` } : {},
|
|
8941
|
+
...i.flag ? { flag: i.flag } : {},
|
|
8942
|
+
...i.adapter ? { adapter: { name: i.adapter, state: adapters.some((a) => a.id === i.adapter) ? "found" : "missing" } } : {},
|
|
8943
|
+
...op.onePager ? { onePager: op.onePager.file } : {},
|
|
8944
|
+
milestones: op.onePager?.milestones ?? [],
|
|
8945
|
+
repos: i.repos.map((r) => {
|
|
8946
|
+
const path = catalog.find(([name]) => name === r.name)?.[1];
|
|
8947
|
+
const local = r.role === "home" ? "here" : !ws ? "no_workspace" : !path ? "not_in_workspace" : existsSync14(path) ? "available" : "missing";
|
|
8948
|
+
return { ...r, local };
|
|
8949
|
+
}),
|
|
8950
|
+
tasks: initiativeTaskRows(root, i, ws),
|
|
8951
|
+
observed: observedCounts(root, i)
|
|
8952
|
+
};
|
|
8953
|
+
}
|
|
8954
|
+
function observedRecords(root, i, repo) {
|
|
8955
|
+
const file = join15(root, i.dir, "sync.json");
|
|
8956
|
+
if (!existsSync14(file)) return [];
|
|
8957
|
+
try {
|
|
8958
|
+
const issues = JSON.parse(readFileSync12(file, "utf8")).issues ?? {};
|
|
8959
|
+
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()));
|
|
8960
|
+
} catch {
|
|
8961
|
+
return [];
|
|
8962
|
+
}
|
|
8963
|
+
}
|
|
8964
|
+
function renderInitiative(o) {
|
|
8965
|
+
const lines = [`${o.id} \u2014 ${o.title}${o.epic ? ` (${o.epic})` : ""}`];
|
|
8966
|
+
if (o.flag) lines.push(` flag: ${o.flag}`);
|
|
8967
|
+
if (o.adapter) lines.push(` adapter: ${o.adapter.name} (${o.adapter.state})`);
|
|
8968
|
+
lines.push(` one-pager: ${o.onePager ?? "none"}`);
|
|
8969
|
+
for (const m of o.milestones) lines.push(` milestone ${m.id} [${m.status}] ${m.title}${m.shows ? ` \u2014 ${m.shows}` : ""}`);
|
|
8970
|
+
for (const x of o.observed) lines.push(` observed ${x.milestone}: ${x.total} (${Object.entries(x.states).map(([k, v]) => `${k} ${v}`).join(", ")})`);
|
|
8971
|
+
for (const r of o.repos) lines.push(` repo ${r.name} (${r.role}) \u2014 ${r.local}`);
|
|
8972
|
+
for (const t of o.tasks) {
|
|
8973
|
+
const deps = t.blocked_by.map((b) => `${b.ref}${b.state === "internal" ? "" : ` ${b.state}`}`).join(", ");
|
|
8974
|
+
lines.push(` task ${t.id} [${t.status}]${t.wave ? ` w${t.wave}` : ""} ${t.repo} \u2014 ${t.title}${deps ? ` (after ${deps})` : ""}`);
|
|
8975
|
+
}
|
|
8976
|
+
return lines;
|
|
8977
|
+
}
|
|
8978
|
+
|
|
8979
|
+
// src/improve.ts
|
|
8980
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync4, readFileSync as readFileSync13, writeFileSync as writeFileSync5 } from "node:fs";
|
|
8981
|
+
import { join as join16 } from "node:path";
|
|
8672
8982
|
var IMPROVE_PATH = ".lead/improve.md";
|
|
8673
8983
|
var KINDS = ["stop", "ask", "avoidable"];
|
|
8674
8984
|
var HEADER = `# Harness improvements
|
|
@@ -8680,8 +8990,8 @@ function isKind(v) {
|
|
|
8680
8990
|
return KINDS.includes(v);
|
|
8681
8991
|
}
|
|
8682
8992
|
function readImprove(root) {
|
|
8683
|
-
const p =
|
|
8684
|
-
return
|
|
8993
|
+
const p = join16(root, IMPROVE_PATH);
|
|
8994
|
+
return existsSync15(p) ? readFileSync13(p, "utf8") : "";
|
|
8685
8995
|
}
|
|
8686
8996
|
function parseImprove(text) {
|
|
8687
8997
|
const entries = [];
|
|
@@ -8722,8 +9032,8 @@ function appendImprove(root, entry) {
|
|
|
8722
9032
|
const body = prev.trim().length ? `${prev.trimEnd()}
|
|
8723
9033
|
|
|
8724
9034
|
${lines.join("\n")}` : `${HEADER}${lines.join("\n")}`;
|
|
8725
|
-
mkdirSync4(
|
|
8726
|
-
writeFileSync5(
|
|
9035
|
+
mkdirSync4(join16(root, ".lead"), { recursive: true });
|
|
9036
|
+
writeFileSync5(join16(root, IMPROVE_PATH), `${body.trimEnd()}
|
|
8727
9037
|
`);
|
|
8728
9038
|
return `${at} \u2014 ${entry.kind}`;
|
|
8729
9039
|
}
|
|
@@ -8734,7 +9044,7 @@ function oneLine(s) {
|
|
|
8734
9044
|
// src/workspace.ts
|
|
8735
9045
|
var CATALOG = ".lead/workspace.yml";
|
|
8736
9046
|
var RUNTIME = ".lead/workspace-kit";
|
|
8737
|
-
var
|
|
9047
|
+
var ID4 = /^[a-z0-9][a-z0-9_-]*$/;
|
|
8738
9048
|
function within(parent, child) {
|
|
8739
9049
|
const rel = relative8(parent, child);
|
|
8740
9050
|
return rel === "" || rel !== ".." && !rel.startsWith(".." + sep3) && !isAbsolute2(rel);
|
|
@@ -8742,36 +9052,43 @@ function within(parent, child) {
|
|
|
8742
9052
|
function findWorkspace(cwd) {
|
|
8743
9053
|
let root = realpathSync3(cwd);
|
|
8744
9054
|
for (; ; ) {
|
|
8745
|
-
const file =
|
|
8746
|
-
if (
|
|
8747
|
-
const { version, repositories } = (0, import_yaml3.parse)(
|
|
9055
|
+
const file = join17(root, CATALOG);
|
|
9056
|
+
if (existsSync16(file)) {
|
|
9057
|
+
const { version, repositories } = (0, import_yaml3.parse)(readFileSync14(file, "utf8")) ?? {};
|
|
8748
9058
|
if (version !== 1 || !repositories || typeof repositories !== "object" || Array.isArray(repositories)) {
|
|
8749
9059
|
throw new Error(`${file}: expected version 1 and a repositories mapping`);
|
|
8750
9060
|
}
|
|
8751
9061
|
const destinations = /* @__PURE__ */ new Set();
|
|
8752
|
-
const
|
|
8753
|
-
|
|
9062
|
+
const labels = {};
|
|
9063
|
+
const entries = Object.entries(repositories).map(([id2, entry]) => {
|
|
9064
|
+
const path = typeof entry === "string" ? entry : entry?.path;
|
|
9065
|
+
if (!ID4.test(id2) || typeof path !== "string" || isAbsolute2(path)) throw new Error(`${file}: invalid repository ${id2}`);
|
|
9066
|
+
if (typeof entry === "object" && entry) {
|
|
9067
|
+
const { title, apps = {} } = entry;
|
|
9068
|
+
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 ${id2}`);
|
|
9069
|
+
labels[id2] = { title, apps };
|
|
9070
|
+
}
|
|
8754
9071
|
const target = resolve2(root, path);
|
|
8755
|
-
if (target === root || !within(root, target) || destinations.has(target)) throw new Error(`${file}: invalid or repeated checkout for ${
|
|
9072
|
+
if (target === root || !within(root, target) || destinations.has(target)) throw new Error(`${file}: invalid or repeated checkout for ${id2}`);
|
|
8756
9073
|
destinations.add(target);
|
|
8757
|
-
return [
|
|
9074
|
+
return [id2, target];
|
|
8758
9075
|
});
|
|
8759
|
-
return { root, repositories: Object.fromEntries(entries) };
|
|
9076
|
+
return { root, repositories: Object.fromEntries(entries), labels };
|
|
8760
9077
|
}
|
|
8761
9078
|
if (dirname3(root) === root) return void 0;
|
|
8762
9079
|
root = dirname3(root);
|
|
8763
9080
|
}
|
|
8764
9081
|
}
|
|
8765
|
-
function repository(ws,
|
|
8766
|
-
const path = Object.hasOwn(ws.repositories,
|
|
8767
|
-
if (!path) throw new Error(`unknown repository "${
|
|
9082
|
+
function repository(ws, id2) {
|
|
9083
|
+
const path = Object.hasOwn(ws.repositories, id2) ? ws.repositories[id2] : void 0;
|
|
9084
|
+
if (!path) throw new Error(`unknown repository "${id2}"; choose ${Object.keys(ws.repositories).join(", ")}`);
|
|
8768
9085
|
try {
|
|
8769
9086
|
const physical = realpathSync3(path);
|
|
8770
9087
|
const top = realpathSync3(execFileSync3("git", ["rev-parse", "--show-toplevel"], { cwd: physical, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim());
|
|
8771
9088
|
if (top !== physical || !within(ws.root, physical)) throw new Error("not a checkout inside the workspace");
|
|
8772
9089
|
return physical;
|
|
8773
9090
|
} catch {
|
|
8774
|
-
throw new Error(`repository "${
|
|
9091
|
+
throw new Error(`repository "${id2}" is unavailable or not a Git checkout: ${path}`);
|
|
8775
9092
|
}
|
|
8776
9093
|
}
|
|
8777
9094
|
function repoAt(ws, cwd) {
|
|
@@ -8785,12 +9102,12 @@ function repoAt(ws, cwd) {
|
|
|
8785
9102
|
})?.[0];
|
|
8786
9103
|
}
|
|
8787
9104
|
function bindingPath(ws, session) {
|
|
8788
|
-
return
|
|
9105
|
+
return join17(ws.root, ".lead/sessions", createHash4("sha256").update(session).digest("hex") + ".json");
|
|
8789
9106
|
}
|
|
8790
9107
|
function readScope(ws, session) {
|
|
8791
9108
|
if (!session) return void 0;
|
|
8792
9109
|
const file = bindingPath(ws, session);
|
|
8793
|
-
return
|
|
9110
|
+
return existsSync16(file) ? JSON.parse(readFileSync14(file, "utf8")) : void 0;
|
|
8794
9111
|
}
|
|
8795
9112
|
function bindScope(ws, cwd, session, scope) {
|
|
8796
9113
|
const local = repoAt(ws, cwd);
|
|
@@ -8820,52 +9137,77 @@ function routeScope(ws, cwd, session, repo, project) {
|
|
|
8820
9137
|
}
|
|
8821
9138
|
if (!chosen) return void 0;
|
|
8822
9139
|
const root = repository(ws, chosen);
|
|
8823
|
-
if (!local && realpathSync3(cwd) !== ws.root &&
|
|
9140
|
+
if (!local && realpathSync3(cwd) !== ws.root && existsSync16(join17(repoRoot(cwd), ".git"))) {
|
|
8824
9141
|
throw new Error("the current checkout is outside the selected scope");
|
|
8825
9142
|
}
|
|
8826
9143
|
return { repo: chosen, cwd: local ? cwd : root, project: project ?? scope?.project, root };
|
|
8827
9144
|
}
|
|
9145
|
+
var readable = (name) => {
|
|
9146
|
+
const words = name.replace(/[-_]+/g, " ").trim();
|
|
9147
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
9148
|
+
};
|
|
8828
9149
|
function workspaceOverview(ws) {
|
|
8829
9150
|
const registered = new Set(Object.values(ws.repositories));
|
|
8830
|
-
const candidates =
|
|
8831
|
-
const repositories = Object.keys(ws.repositories).map((
|
|
9151
|
+
const candidates = readdirSync9(ws.root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && !registered.has(join17(ws.root, entry.name)) && existsSync16(join17(ws.root, entry.name, ".git"))).map((entry) => entry.name).sort();
|
|
9152
|
+
const repositories = Object.keys(ws.repositories).map((id2) => {
|
|
9153
|
+
const labels = ws.labels?.[id2] ?? { apps: {} };
|
|
9154
|
+
const title = labels.title ?? readable(id2);
|
|
8832
9155
|
try {
|
|
8833
|
-
const root = repository(ws,
|
|
9156
|
+
const root = repository(ws, id2);
|
|
8834
9157
|
const base = loadContext(root);
|
|
8835
9158
|
const projects = base.projects.map((p) => {
|
|
8836
9159
|
const ctx = loadContext(root, p.name);
|
|
8837
9160
|
const milestone = currentMilestone(ctx.onePager?.milestones ?? [], ctx.tasks);
|
|
8838
9161
|
return {
|
|
8839
9162
|
name: p.name,
|
|
9163
|
+
path: p.path,
|
|
9164
|
+
title: p.name === "." ? void 0 : labels.apps[p.name] ?? readable(p.name),
|
|
8840
9165
|
milestone: milestone?.title,
|
|
8841
|
-
onePager: ctx.onePager &&
|
|
8842
|
-
active: ctx.tasks.filter((t) => t.status === "in_progress" || t.status === "review").map((t) => ({ title: t.title, file:
|
|
8843
|
-
blocked: ctx.tasks.filter((t) => t.status === "blocked").map((t) => ({ title: t.title, file:
|
|
9166
|
+
onePager: ctx.onePager && join17(root, ctx.onePager.file),
|
|
9167
|
+
active: ctx.tasks.filter((t) => t.status === "in_progress" || t.status === "review").map((t) => ({ title: t.title, file: join17(root, t.file) })),
|
|
9168
|
+
blocked: ctx.tasks.filter((t) => t.status === "blocked").map((t) => ({ title: t.title, file: join17(root, t.file) }))
|
|
9169
|
+
};
|
|
9170
|
+
});
|
|
9171
|
+
const initiatives = loadInitiatives(root).initiatives.map((i) => {
|
|
9172
|
+
const o = initiativeOverview(root, i);
|
|
9173
|
+
const counts = {};
|
|
9174
|
+
for (const t of o.tasks) counts[t.status] = (counts[t.status] ?? 0) + 1;
|
|
9175
|
+
return {
|
|
9176
|
+
id: o.id,
|
|
9177
|
+
title: o.title,
|
|
9178
|
+
epic: o.epic,
|
|
9179
|
+
epicUrl: o.epicUrl,
|
|
9180
|
+
flag: o.flag,
|
|
9181
|
+
onePager: o.onePager && join17(root, o.onePager),
|
|
9182
|
+
milestones: o.milestones,
|
|
9183
|
+
observed: o.observed,
|
|
9184
|
+
tasks: counts,
|
|
9185
|
+
repositories: o.repos.map((r) => ({ name: r.name, role: r.role, url: r.url, local: r.local }))
|
|
8844
9186
|
};
|
|
8845
9187
|
});
|
|
8846
|
-
return { id, root, state: base.configExists ? "ready" : "not_configured", projects };
|
|
9188
|
+
return { id: id2, title, root, state: base.configExists ? "ready" : "not_configured", projects, initiatives };
|
|
8847
9189
|
} catch (error) {
|
|
8848
|
-
return { id, root: ws.repositories[
|
|
9190
|
+
return { id: id2, title, root: ws.repositories[id2], state: "unavailable", reason: error.message, projects: [] };
|
|
8849
9191
|
}
|
|
8850
9192
|
});
|
|
8851
9193
|
return { root: ws.root, repositories, candidates };
|
|
8852
9194
|
}
|
|
8853
9195
|
function workspaceImprove(ws) {
|
|
8854
9196
|
const entries = [];
|
|
8855
|
-
const repositories = Object.keys(ws.repositories).map((
|
|
9197
|
+
const repositories = Object.keys(ws.repositories).map((id2) => {
|
|
8856
9198
|
let root;
|
|
8857
9199
|
try {
|
|
8858
|
-
root = repository(ws,
|
|
9200
|
+
root = repository(ws, id2);
|
|
8859
9201
|
} catch (error) {
|
|
8860
|
-
return { id, state: "unavailable", count: 0, reason: error.message };
|
|
9202
|
+
return { id: id2, state: "unavailable", count: 0, reason: error.message };
|
|
8861
9203
|
}
|
|
8862
|
-
const source =
|
|
9204
|
+
const source = join17(root, IMPROVE_PATH);
|
|
8863
9205
|
try {
|
|
8864
9206
|
if (!within(root, realpathSync3(source))) throw new Error("improvement log points outside its checkout");
|
|
8865
|
-
const parsed = parseImprove(
|
|
8866
|
-
entries.push(...parsed.entries.map((entry) => ({ ...entry, repository:
|
|
9207
|
+
const parsed = parseImprove(readFileSync14(source, "utf8"));
|
|
9208
|
+
entries.push(...parsed.entries.map((entry) => ({ ...entry, repository: id2, source })));
|
|
8867
9209
|
return {
|
|
8868
|
-
id,
|
|
9210
|
+
id: id2,
|
|
8869
9211
|
source,
|
|
8870
9212
|
state: parsed.entries.length || parsed.malformed.length ? "collected" : "empty",
|
|
8871
9213
|
count: parsed.entries.length,
|
|
@@ -8873,29 +9215,29 @@ function workspaceImprove(ws) {
|
|
|
8873
9215
|
};
|
|
8874
9216
|
} catch (error) {
|
|
8875
9217
|
const missing = error.code === "ENOENT";
|
|
8876
|
-
return { id, source, state: missing ? "missing" : "unreadable", count: 0, reason: missing ? void 0 : error.message };
|
|
9218
|
+
return { id: id2, source, state: missing ? "missing" : "unreadable", count: 0, reason: missing ? void 0 : error.message };
|
|
8877
9219
|
}
|
|
8878
9220
|
});
|
|
8879
9221
|
entries.sort((a, b) => Date.parse(b.at) - Date.parse(a.at) || a.repository.localeCompare(b.repository) || b.line - a.line);
|
|
8880
9222
|
return { root: ws.root, repositories, entries };
|
|
8881
9223
|
}
|
|
8882
9224
|
function deployWorkspace(ws, source) {
|
|
8883
|
-
if (!isKitRoot(source) || !
|
|
9225
|
+
if (!isKitRoot(source) || !existsSync16(join17(source, "skills/lead/references/workspace.md"))) {
|
|
8884
9226
|
throw new Error("this kit release has no workspace support; use --from with a workspace-capable kit");
|
|
8885
9227
|
}
|
|
8886
|
-
const runtime =
|
|
9228
|
+
const runtime = join17(ws.root, RUNTIME);
|
|
8887
9229
|
if (realpathSync3(source) === runtime) throw new Error("already using this workspace kit");
|
|
8888
9230
|
const staging = `${runtime}.${randomUUID()}`;
|
|
8889
9231
|
const previous = `${staging}.previous`;
|
|
8890
9232
|
try {
|
|
8891
|
-
mkdirSync5(
|
|
8892
|
-
copyFileSync2(
|
|
8893
|
-
cpSync(
|
|
8894
|
-
if (
|
|
9233
|
+
mkdirSync5(join17(staging, "dist"), { recursive: true });
|
|
9234
|
+
copyFileSync2(join17(source, "dist/lead.mjs"), join17(staging, "dist/lead.mjs"));
|
|
9235
|
+
cpSync(join17(source, "skills"), join17(staging, "skills"), { recursive: true });
|
|
9236
|
+
if (existsSync16(runtime)) renameSync(runtime, previous);
|
|
8895
9237
|
try {
|
|
8896
9238
|
renameSync(staging, runtime);
|
|
8897
9239
|
} catch (error) {
|
|
8898
|
-
if (
|
|
9240
|
+
if (existsSync16(previous)) renameSync(previous, runtime);
|
|
8899
9241
|
throw error;
|
|
8900
9242
|
}
|
|
8901
9243
|
writeEntrypoints(ws.root);
|
|
@@ -8912,13 +9254,13 @@ function writeEntrypoints(root) {
|
|
|
8912
9254
|
files2[`${host}/skills/lead-goal/SKILL.md`] = "workspace-goal.md";
|
|
8913
9255
|
}
|
|
8914
9256
|
for (const file of Object.keys(files2)) {
|
|
8915
|
-
const target =
|
|
8916
|
-
if (!
|
|
8917
|
-
const managed = file === ".lead/lead.mjs" ? isPortableLauncher(root) : /^<!-- evercrew:workspace-entry -->$/m.test(
|
|
9257
|
+
const target = join17(root, file);
|
|
9258
|
+
if (!existsSync16(target)) continue;
|
|
9259
|
+
const managed = file === ".lead/lead.mjs" ? isPortableLauncher(root) : /^<!-- evercrew:workspace-entry -->$/m.test(readFileSync14(target, "utf8"));
|
|
8918
9260
|
if (!managed) throw new Error(`keep existing ${target}; migrate it before attaching`);
|
|
8919
9261
|
}
|
|
8920
9262
|
for (const [file, template] of Object.entries(files2)) {
|
|
8921
|
-
const target =
|
|
9263
|
+
const target = join17(root, file);
|
|
8922
9264
|
mkdirSync5(dirname3(target), { recursive: true });
|
|
8923
9265
|
writeFileSync6(target, TEMPLATES[template]);
|
|
8924
9266
|
}
|
|
@@ -8926,41 +9268,41 @@ function writeEntrypoints(root) {
|
|
|
8926
9268
|
|
|
8927
9269
|
// src/cli.ts
|
|
8928
9270
|
import { execFileSync as execFileSync6, spawnSync as spawnSync3 } from "node:child_process";
|
|
8929
|
-
import { existsSync as
|
|
9271
|
+
import { existsSync as existsSync30, mkdtempSync as mkdtempSync3, rmSync as rmSync6 } from "node:fs";
|
|
8930
9272
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
8931
9273
|
|
|
8932
9274
|
// src/mode.ts
|
|
8933
|
-
import { existsSync as
|
|
8934
|
-
import { join as
|
|
9275
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync6, readFileSync as readFileSync15, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
|
|
9276
|
+
import { join as join18 } from "node:path";
|
|
8935
9277
|
var MODE_PATH = ".lead/mode";
|
|
8936
9278
|
var MODES = ["auto", "approve"];
|
|
8937
9279
|
function isMode(v) {
|
|
8938
9280
|
return MODES.includes(v);
|
|
8939
9281
|
}
|
|
8940
9282
|
function readMode(root) {
|
|
8941
|
-
const p =
|
|
8942
|
-
if (!
|
|
8943
|
-
const v =
|
|
9283
|
+
const p = join18(root, MODE_PATH);
|
|
9284
|
+
if (!existsSync17(p)) return void 0;
|
|
9285
|
+
const v = readFileSync15(p, "utf8").trim().split(/\s+/)[0] ?? "";
|
|
8944
9286
|
return isMode(v) ? v : void 0;
|
|
8945
9287
|
}
|
|
8946
9288
|
function writeMode(root, mode) {
|
|
8947
|
-
mkdirSync6(
|
|
8948
|
-
writeFileSync7(
|
|
9289
|
+
mkdirSync6(join18(root, ".lead"), { recursive: true });
|
|
9290
|
+
writeFileSync7(join18(root, MODE_PATH), `${mode}
|
|
8949
9291
|
`);
|
|
8950
9292
|
}
|
|
8951
9293
|
function clearMode(root) {
|
|
8952
|
-
rmSync3(
|
|
9294
|
+
rmSync3(join18(root, MODE_PATH), { force: true });
|
|
8953
9295
|
}
|
|
8954
9296
|
|
|
8955
9297
|
// src/status.ts
|
|
8956
|
-
import { existsSync as
|
|
8957
|
-
import { join as
|
|
9298
|
+
import { existsSync as existsSync19 } from "node:fs";
|
|
9299
|
+
import { join as join21 } from "node:path";
|
|
8958
9300
|
|
|
8959
9301
|
// src/git.ts
|
|
8960
9302
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
8961
9303
|
import { mkdtempSync as mkdtempSync2, rmSync as rmSync4 } from "node:fs";
|
|
8962
9304
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
8963
|
-
import { join as
|
|
9305
|
+
import { join as join19 } from "node:path";
|
|
8964
9306
|
function git(cwd, args, env = {}) {
|
|
8965
9307
|
return execFileSync4("git", args, {
|
|
8966
9308
|
cwd,
|
|
@@ -8970,8 +9312,8 @@ function git(cwd, args, env = {}) {
|
|
|
8970
9312
|
}).trim();
|
|
8971
9313
|
}
|
|
8972
9314
|
function treeId(cwd) {
|
|
8973
|
-
const dir = mkdtempSync2(
|
|
8974
|
-
const index =
|
|
9315
|
+
const dir = mkdtempSync2(join19(tmpdir2(), "lead-index-"));
|
|
9316
|
+
const index = join19(dir, "index");
|
|
8975
9317
|
try {
|
|
8976
9318
|
const env = { GIT_INDEX_FILE: index };
|
|
8977
9319
|
try {
|
|
@@ -8994,15 +9336,15 @@ function currentBranch(cwd) {
|
|
|
8994
9336
|
|
|
8995
9337
|
// src/lifecycle.ts
|
|
8996
9338
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
8997
|
-
import { cpSync as cpSync2, existsSync as
|
|
8998
|
-
import { dirname as dirname4, join as
|
|
9339
|
+
import { cpSync as cpSync2, existsSync as existsSync18, mkdirSync as mkdirSync7, readFileSync as readFileSync16, realpathSync as realpathSync4, statSync as statSync5, writeFileSync as writeFileSync8 } from "node:fs";
|
|
9340
|
+
import { dirname as dirname4, join as join20, relative as relative9, sep as sep4 } from "node:path";
|
|
8999
9341
|
var slug = (t) => t.title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "task";
|
|
9000
9342
|
var projectPrefix = (ctx) => ctx.project && ctx.project.name !== "." ? `${ctx.project.name}-` : "";
|
|
9001
9343
|
var worktreeRel = (ctx, t) => `.claude/worktrees/${projectPrefix(ctx)}${t.id}`;
|
|
9002
9344
|
var branchName = (ctx, t) => `task/${ctx.project && ctx.project.name !== "." ? `${ctx.project.name}/` : ""}${t.id}-${slug(t)}`;
|
|
9003
9345
|
function taskDir(ctx, t) {
|
|
9004
9346
|
const wt = t.claim?.worktree;
|
|
9005
|
-
return wt &&
|
|
9347
|
+
return wt && existsSync18(join20(ctx.root, wt)) ? join20(ctx.root, wt) : ctx.root;
|
|
9006
9348
|
}
|
|
9007
9349
|
function startTask(ctx, t, opts) {
|
|
9008
9350
|
const byId = new Map(ctx.tasks.map((x) => [x.id, x]));
|
|
@@ -9016,8 +9358,8 @@ function startTask(ctx, t, opts) {
|
|
|
9016
9358
|
const branch = t.branch ?? branchName(ctx, t);
|
|
9017
9359
|
const wtRel = t.claim?.worktree ?? worktreeRel(ctx, t);
|
|
9018
9360
|
let copied = [];
|
|
9019
|
-
const wtAbs =
|
|
9020
|
-
if (!
|
|
9361
|
+
const wtAbs = join20(ctx.root, wtRel);
|
|
9362
|
+
if (!existsSync18(wtAbs)) {
|
|
9021
9363
|
try {
|
|
9022
9364
|
let exists = true;
|
|
9023
9365
|
try {
|
|
@@ -9060,9 +9402,9 @@ function copyUntrackedProject(ctx, wtAbs) {
|
|
|
9060
9402
|
for (const line of porcelain.split("\n")) {
|
|
9061
9403
|
if (!line.startsWith("?? ")) continue;
|
|
9062
9404
|
const file = line.slice(3).replaceAll('"', "");
|
|
9063
|
-
const src =
|
|
9064
|
-
const dst =
|
|
9065
|
-
if (!
|
|
9405
|
+
const src = join20(ctx.root, file);
|
|
9406
|
+
const dst = join20(wtAbs, file);
|
|
9407
|
+
if (!existsSync18(src) || existsSync18(dst)) continue;
|
|
9066
9408
|
mkdirSync7(dirname4(dst), { recursive: true });
|
|
9067
9409
|
cpSync2(src, dst, { recursive: true });
|
|
9068
9410
|
copied.push(file);
|
|
@@ -9082,7 +9424,7 @@ function recordChecks(ctx, t, opts) {
|
|
|
9082
9424
|
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
9083
9425
|
const stamp = now.toISOString().replace(/[:.]/g, "-");
|
|
9084
9426
|
const logRel = `.lead/logs/${t.id}-${stamp}.log`;
|
|
9085
|
-
mkdirSync7(
|
|
9427
|
+
mkdirSync7(join20(ctx.root, ".lead/logs"), { recursive: true });
|
|
9086
9428
|
let log = "";
|
|
9087
9429
|
const commands = [];
|
|
9088
9430
|
const failures = [];
|
|
@@ -9098,7 +9440,7 @@ ${output}
|
|
|
9098
9440
|
if (code !== 0) failures.push(`${name} (exit ${code}):
|
|
9099
9441
|
${tail(output, 40)}`);
|
|
9100
9442
|
}
|
|
9101
|
-
writeFileSync8(
|
|
9443
|
+
writeFileSync8(join20(ctx.root, logRel), log);
|
|
9102
9444
|
const commit = treeId(dir);
|
|
9103
9445
|
const round = t.rounds + 1;
|
|
9104
9446
|
const summary = commands.map((c) => `\`${c.cmd}\` \u2192 ${c.exit_code}`).join(", ");
|
|
@@ -9184,10 +9526,20 @@ function finishTask(ctx, t, opts) {
|
|
|
9184
9526
|
});
|
|
9185
9527
|
let cleanup = "";
|
|
9186
9528
|
const wt = t.claim?.worktree ?? worktreeRel(ctx, t);
|
|
9187
|
-
if (
|
|
9529
|
+
if (existsSync18(join20(ctx.root, wt))) {
|
|
9188
9530
|
try {
|
|
9531
|
+
const abs = join20(ctx.root, wt);
|
|
9532
|
+
const inside = (() => {
|
|
9533
|
+
try {
|
|
9534
|
+
const here = realpathSync4(process.cwd());
|
|
9535
|
+
const target = realpathSync4(abs);
|
|
9536
|
+
return here === target || here.startsWith(target + sep4);
|
|
9537
|
+
} catch {
|
|
9538
|
+
return false;
|
|
9539
|
+
}
|
|
9540
|
+
})();
|
|
9189
9541
|
git(ctx.root, ["worktree", "remove", wt]);
|
|
9190
|
-
cleanup = `; worktree ${wt} removed`;
|
|
9542
|
+
cleanup = `; worktree ${wt} removed${inside ? `; the shell was inside it, so run the next commands from ${ctx.root}` : ""}`;
|
|
9191
9543
|
} catch {
|
|
9192
9544
|
cleanup = `; worktree ${wt} kept (it has local changes)`;
|
|
9193
9545
|
}
|
|
@@ -9199,7 +9551,7 @@ function finishTask(ctx, t, opts) {
|
|
|
9199
9551
|
if (blockers.length) return { ok: false, message: `${t.id} cannot be finished:
|
|
9200
9552
|
- ${blockers.join("\n- ")}` };
|
|
9201
9553
|
const qa = latestQa(ctx, t);
|
|
9202
|
-
const text =
|
|
9554
|
+
const text = readFileSync16(join20(ctx.root, t.file), "utf8");
|
|
9203
9555
|
recordRun(ctx.root, {
|
|
9204
9556
|
kind: "task",
|
|
9205
9557
|
subject: { project: ctx.project.name, task: t.id, tree: t.checks_run.commit },
|
|
@@ -9242,7 +9594,7 @@ function taskActivity(ctx, t) {
|
|
|
9242
9594
|
add(t.claim?.since);
|
|
9243
9595
|
let dirtyFiles = 0;
|
|
9244
9596
|
let commitsAhead = 0;
|
|
9245
|
-
const wt = t.claim?.worktree &&
|
|
9597
|
+
const wt = t.claim?.worktree && existsSync18(join20(ctx.root, t.claim.worktree)) ? join20(ctx.root, t.claim.worktree) : void 0;
|
|
9246
9598
|
if (wt) {
|
|
9247
9599
|
try {
|
|
9248
9600
|
const base = currentBranch(ctx.root);
|
|
@@ -9251,8 +9603,8 @@ function taskActivity(ctx, t) {
|
|
|
9251
9603
|
const lines = git(wt, ["status", "--porcelain", "--untracked-files=all"]).split("\n").filter(Boolean);
|
|
9252
9604
|
dirtyFiles = lines.length;
|
|
9253
9605
|
for (const l of lines.slice(0, 200)) {
|
|
9254
|
-
const f =
|
|
9255
|
-
if (
|
|
9606
|
+
const f = join20(wt, l.slice(3).split(" -> ").pop());
|
|
9607
|
+
if (existsSync18(f)) times.push(statSync5(f).mtimeMs);
|
|
9256
9608
|
}
|
|
9257
9609
|
} catch {
|
|
9258
9610
|
}
|
|
@@ -9264,8 +9616,8 @@ function stopCheck(ctx, input, now = /* @__PURE__ */ new Date()) {
|
|
|
9264
9616
|
const session = input.session_id;
|
|
9265
9617
|
if (!session || !ctx.project) return void 0;
|
|
9266
9618
|
const t = ctx.tasks.find((x) => x.status === "in_progress" && x.claim?.session === session);
|
|
9267
|
-
const counter =
|
|
9268
|
-
const reset = () =>
|
|
9619
|
+
const counter = join20(ctx.root, ".lead/logs", `stop-${session.replace(/[^a-zA-Z0-9-]/g, "")}.json`);
|
|
9620
|
+
const reset = () => existsSync18(counter) && writeFileSync8(counter, '{"count":0}');
|
|
9269
9621
|
if (!t) {
|
|
9270
9622
|
reset();
|
|
9271
9623
|
return void 0;
|
|
@@ -9279,8 +9631,8 @@ function stopCheck(ctx, input, now = /* @__PURE__ */ new Date()) {
|
|
|
9279
9631
|
reset();
|
|
9280
9632
|
return void 0;
|
|
9281
9633
|
}
|
|
9282
|
-
mkdirSync7(
|
|
9283
|
-
const count =
|
|
9634
|
+
mkdirSync7(join20(ctx.root, ".lead/logs"), { recursive: true });
|
|
9635
|
+
const count = existsSync18(counter) ? JSON.parse(readFileSync16(counter, "utf8")).count : 0;
|
|
9284
9636
|
if (count >= MAX_STOP_BLOCKS) {
|
|
9285
9637
|
reset();
|
|
9286
9638
|
updateTask(
|
|
@@ -9406,7 +9758,7 @@ function status(ctx, opts = {}) {
|
|
|
9406
9758
|
const waiting = active.filter((t) => t.status === "blocked" || t.status === "in_progress");
|
|
9407
9759
|
s.independentReady = ready.filter((t) => waiting.every((b) => !touchesOverlap(t.touches, b.touches).length)).map((t) => t.id);
|
|
9408
9760
|
}
|
|
9409
|
-
const hasPlan =
|
|
9761
|
+
const hasPlan = existsSync19(join21(project.workDir, "one-pager.md"));
|
|
9410
9762
|
const merged = tasks.filter((t) => t.status === "review" && t.branch && opts.isMerged?.(t.branch)).map((t) => t.id);
|
|
9411
9763
|
if (s.errors > 0) s.next = { kind: "fix", reason: `${s.errors} errors in work/ or config; run \`lead check\`` };
|
|
9412
9764
|
else if (mine) s.next = { kind: "continue_task", reason: `${mine.id} is in progress in this session`, task: mine.id };
|
|
@@ -9417,7 +9769,7 @@ function status(ctx, opts = {}) {
|
|
|
9417
9769
|
s.next = { kind: "adopted_project", reason: "use the current One Pager and tracker; local lead files do not cover the full roadmap" };
|
|
9418
9770
|
} else if (!hasPlan && tasks.length === 0) s.next = { kind: "plan", reason: "no one-pager and no tasks yet" };
|
|
9419
9771
|
else if (tasks.length === 0) {
|
|
9420
|
-
const drafts = loadSections(ctx.root, project.workDir).sections.filter((x) => x.status === "draft" && x.body.replace(/<!--[\s\S]*?-->/g, "").replace(/^#.*$/gm, "").trim().length > 0);
|
|
9772
|
+
const drafts = loadSections(ctx.root, project.workDir).sections.filter((x) => x.status === "draft" && !isUntouchedTemplate(x.name, x.body) && x.body.replace(/<!--[\s\S]*?-->/g, "").replace(/^#.*$/gm, "").trim().length > 0);
|
|
9421
9773
|
s.next = drafts.length ? { kind: "confirm_spec", reason: "the spec is written and waits for confirmation before tasks", sections: drafts.map((x) => x.name) } : { kind: "plan", reason: "one-pager has no tasks yet" };
|
|
9422
9774
|
} else if (s.blocked.length) s.next = { kind: "answer", reason: "tasks wait for a human decision", tasks: s.blocked };
|
|
9423
9775
|
else if (inWave.length) s.next = { kind: "task", reason: wave === void 0 ? "ready tasks (waves not set)" : `wave ${wave} has ready tasks`, tasks: inWave.map((t) => t.id), wave };
|
|
@@ -9431,23 +9783,23 @@ function status(ctx, opts = {}) {
|
|
|
9431
9783
|
}
|
|
9432
9784
|
|
|
9433
9785
|
// src/write.ts
|
|
9434
|
-
import { readFileSync as
|
|
9435
|
-
import { join as
|
|
9436
|
-
import { existsSync as
|
|
9786
|
+
import { readFileSync as readFileSync18, writeFileSync as writeFileSync10 } from "node:fs";
|
|
9787
|
+
import { join as join23 } from "node:path";
|
|
9788
|
+
import { existsSync as existsSync21 } from "node:fs";
|
|
9437
9789
|
|
|
9438
9790
|
// src/sync.ts
|
|
9439
9791
|
import { createHash as createHash5 } from "node:crypto";
|
|
9440
|
-
import { existsSync as
|
|
9441
|
-
import { basename, join as
|
|
9792
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync8, readdirSync as readdirSync10, readFileSync as readFileSync17, statSync as statSync6, writeFileSync as writeFileSync9 } from "node:fs";
|
|
9793
|
+
import { basename, join as join22, posix, relative as relative10 } from "node:path";
|
|
9442
9794
|
var SYNC_FILE = "sync.json";
|
|
9443
9795
|
var hash2 = (s) => createHash5("sha256").update(s).digest("hex").slice(0, 16);
|
|
9444
9796
|
function readSyncState(workDir) {
|
|
9445
|
-
const p =
|
|
9446
|
-
if (!
|
|
9447
|
-
return JSON.parse(
|
|
9797
|
+
const p = join22(workDir, SYNC_FILE);
|
|
9798
|
+
if (!existsSync20(p)) return { version: 1 };
|
|
9799
|
+
return JSON.parse(readFileSync17(p, "utf8"));
|
|
9448
9800
|
}
|
|
9449
9801
|
function writeSyncState(workDir, s) {
|
|
9450
|
-
writeFileSync9(
|
|
9802
|
+
writeFileSync9(join22(workDir, SYNC_FILE), `${JSON.stringify(s, null, 2)}
|
|
9451
9803
|
`);
|
|
9452
9804
|
}
|
|
9453
9805
|
var projectName = (ctx) => ctx.project.name === "." ? basename(ctx.root) : ctx.project.name;
|
|
@@ -9489,12 +9841,12 @@ function adoptionMapping(ctx) {
|
|
|
9489
9841
|
const story = state.jira?.story;
|
|
9490
9842
|
rows.push(story ? `Jira Story (${story.key}) \u2014 ${story.observeOnly || !story.managed ? "observe-only" : "managed"}` : "Jira Story: unmapped");
|
|
9491
9843
|
const tasks = new Map(ctx.tasks.map((task) => [task.id, task]));
|
|
9492
|
-
for (const [
|
|
9493
|
-
const task = tasks.get(
|
|
9844
|
+
for (const [id2, issue] of Object.entries(state.jira?.tasks ?? {}).sort(([a], [b]) => a.localeCompare(b))) {
|
|
9845
|
+
const task = tasks.get(id2);
|
|
9494
9846
|
const milestone = ctx.onePager?.milestones.find((m) => m.id === task?.milestone);
|
|
9495
9847
|
const access = issue.observeOnly || !issue.managed ? "observe-only" : "managed";
|
|
9496
9848
|
const observed = access === "observe-only" && issue.status ? ` \xB7 source status: ${issue.status}` : "";
|
|
9497
|
-
rows.push(`Jira ${task?.title ??
|
|
9849
|
+
rows.push(`Jira ${task?.title ?? id2} (${issue.key}) \u2014 ${access}${observed} \xB7 ${task ? `milestone: ${milestone?.title ?? task.milestone} \xB7 lead status: ${task.status}` : "no local task"}`);
|
|
9498
9850
|
}
|
|
9499
9851
|
}
|
|
9500
9852
|
return rows;
|
|
@@ -9511,14 +9863,14 @@ function mergeRequestUrl(repo, branch) {
|
|
|
9511
9863
|
}
|
|
9512
9864
|
function remoteMarkdown(text, state, site, notes, links) {
|
|
9513
9865
|
const noteUrl2 = (key) => {
|
|
9514
|
-
const
|
|
9515
|
-
return
|
|
9866
|
+
const id2 = activeNote(state, key)?.id;
|
|
9867
|
+
return id2 && notes ? `https://${notes.host}/space/${notes.workspace}/document/${id2}` : void 0;
|
|
9516
9868
|
};
|
|
9517
|
-
return text.replace(/^---\n[\s\S]*?\n---\n/, "").replace(/<!--[\s\S]*?-->\n?/g, "").replace(/\[(T-\d+)\]\([^)]*\)/g, (_m,
|
|
9518
|
-
const taskNote = noteUrl2(`tasks/${
|
|
9519
|
-
if (taskNote) return `[${
|
|
9520
|
-
const key = state.jira?.tasks[
|
|
9521
|
-
return key && site ? `[${
|
|
9869
|
+
return text.replace(/^---\n[\s\S]*?\n---\n/, "").replace(/<!--[\s\S]*?-->\n?/g, "").replace(/\[(T-\d+)\]\([^)]*\)/g, (_m, id2) => {
|
|
9870
|
+
const taskNote = noteUrl2(`tasks/${id2}`);
|
|
9871
|
+
if (taskNote) return `[${id2}](${taskNote})`;
|
|
9872
|
+
const key = state.jira?.tasks[id2]?.key;
|
|
9873
|
+
return key && site ? `[${id2}](https://${site}/browse/${key})` : id2;
|
|
9522
9874
|
}).replace(/\[([^\]]+)\]\((?!https?:|mailto:|#)([^)\s]+)\)/g, (_m, label, href) => {
|
|
9523
9875
|
const [file, anchor] = href.replace(/^\.\//, "").split("#");
|
|
9524
9876
|
const path = posix.join(links?.dir ?? ".", file);
|
|
@@ -9626,37 +9978,69 @@ function docs(ctx, taskSpecs2 = []) {
|
|
|
9626
9978
|
const w = ctx.project.workDir;
|
|
9627
9979
|
const t = projectTitle(ctx);
|
|
9628
9980
|
const out = [];
|
|
9629
|
-
const add = (key, title, path) =>
|
|
9630
|
-
add("board", `Board (${t})`,
|
|
9631
|
-
add("architecture", `Architecture (${t})`,
|
|
9632
|
-
add("history", `History (${t})`,
|
|
9633
|
-
add("spec-research", `Research (${t})`,
|
|
9634
|
-
const research =
|
|
9635
|
-
if (
|
|
9636
|
-
for (const f of
|
|
9637
|
-
if (f.endsWith(".md")) add(`research/${f}`, `${displayName(f.replace(/\.md$/, ""))} (${t})`,
|
|
9981
|
+
const add = (key, title, path) => existsSync20(path) && out.push({ key, title, text: readFileSync17(path, "utf8"), path: relative10(ctx.root, path) });
|
|
9982
|
+
add("board", `Board (${t})`, join22(w, "board.md"));
|
|
9983
|
+
add("architecture", `Architecture (${t})`, join22(w, "architecture.md"));
|
|
9984
|
+
add("history", `History (${t})`, join22(w, "history.md"));
|
|
9985
|
+
add("spec-research", `Research (${t})`, join22(w, "spec", "01-research.md"));
|
|
9986
|
+
const research = join22(w, "research");
|
|
9987
|
+
if (existsSync20(research)) {
|
|
9988
|
+
for (const f of readdirSync10(research).sort()) {
|
|
9989
|
+
if (f.endsWith(".md")) add(`research/${f}`, `${displayName(f.replace(/\.md$/, ""))} (${t})`, join22(research, f));
|
|
9638
9990
|
}
|
|
9639
9991
|
}
|
|
9640
9992
|
out.push(...taskSpecs2);
|
|
9641
|
-
const candidates =
|
|
9642
|
-
if (
|
|
9643
|
-
for (const file of
|
|
9993
|
+
const candidates = join22(w, "task-notes");
|
|
9994
|
+
if (existsSync20(candidates)) {
|
|
9995
|
+
for (const file of readdirSync10(candidates, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
9644
9996
|
if (!file.isFile() || !file.name.endsWith(".md")) continue;
|
|
9645
|
-
const path =
|
|
9646
|
-
const text =
|
|
9997
|
+
const path = join22(candidates, file.name);
|
|
9998
|
+
const text = readFileSync17(path, "utf8");
|
|
9647
9999
|
const title = /^#\s+([^\n]+)$/m.exec(text)?.[1]?.trim() || displayName(basename(file.name, ".md"));
|
|
9648
10000
|
out.push({ key: `task-notes/${file.name}`, title, text, path: relative10(ctx.root, path) });
|
|
9649
10001
|
}
|
|
9650
10002
|
}
|
|
9651
|
-
const backlog =
|
|
9652
|
-
if (
|
|
9653
|
-
const text = replaceBlocks(
|
|
10003
|
+
const backlog = join22(w, "backlog.md");
|
|
10004
|
+
if (existsSync20(backlog)) {
|
|
10005
|
+
const text = replaceBlocks(readFileSync17(backlog, "utf8"), (kind) => ["tasks", "proposals"].includes(kind) ? renderBacklogItems(w) : void 0);
|
|
9654
10006
|
out.push({ key: "backlog", title: `Backlog (${t})`, text, path: relative10(ctx.root, backlog) });
|
|
9655
10007
|
}
|
|
9656
|
-
add("one-pager", `OnePager (${t})`,
|
|
10008
|
+
add("one-pager", `OnePager (${t})`, join22(w, "one-pager.md"));
|
|
9657
10009
|
return out;
|
|
9658
10010
|
}
|
|
9659
|
-
var noteUrl = (f,
|
|
10011
|
+
var noteUrl = (f, id2) => `https://${f.host}/space/${f.workspace}/document/${id2}`;
|
|
10012
|
+
var DOC_GROUPS = [[/^one-pager$/, "One Pager"], [/^(board|backlog|history|architecture)$/, "Plan"], [/^spec-|^spec\//, "Specification"], [/^research\//, "Research"], [/^tasks\//, "Task specifications"], [/^task-notes\//, "Task notes"]];
|
|
10013
|
+
function docIndex(ctx) {
|
|
10014
|
+
if (!ctx.project) return [];
|
|
10015
|
+
const state = readSyncState(ctx.project.workDir);
|
|
10016
|
+
const f = ctx.config.sync?.fusebase;
|
|
10017
|
+
const listed = docs(ctx, taskSpecs(ctx, state).docs);
|
|
10018
|
+
const specDir2 = join22(ctx.project.workDir, "spec");
|
|
10019
|
+
if (existsSync20(specDir2)) for (const file of readdirSync10(specDir2).sort()) {
|
|
10020
|
+
const path = relative10(ctx.root, join22(specDir2, file));
|
|
10021
|
+
if (file.endsWith(".md") && !listed.some((d) => d.path === path)) listed.push({ key: `spec/${file}`, title: /^#\s+([^\n]+)$/m.exec(readFileSync17(join22(specDir2, file), "utf8"))?.[1]?.trim() || displayName(file.replace(/\.md$/, "")), text: "", path });
|
|
10022
|
+
}
|
|
10023
|
+
const entries = listed.map((d) => {
|
|
10024
|
+
const note = activeNote(state, d.key);
|
|
10025
|
+
return {
|
|
10026
|
+
key: d.key,
|
|
10027
|
+
title: d.title,
|
|
10028
|
+
group: DOC_GROUPS.find(([re]) => re.test(d.key))?.[1] ?? "Other",
|
|
10029
|
+
path: d.path,
|
|
10030
|
+
modified: statSync6(join22(ctx.root, d.path)).mtime.toISOString(),
|
|
10031
|
+
...f && note && { url: noteUrl(f, note.id) }
|
|
10032
|
+
};
|
|
10033
|
+
});
|
|
10034
|
+
const order = DOC_GROUPS.map(([, g]) => g);
|
|
10035
|
+
return entries.sort((a, b) => (order.indexOf(a.group) + 99) % 99 - (order.indexOf(b.group) + 99) % 99 || a.path.localeCompare(b.path));
|
|
10036
|
+
}
|
|
10037
|
+
function docText(ctx, key) {
|
|
10038
|
+
if (!ctx.project) return void 0;
|
|
10039
|
+
const entry = docIndex(ctx).find((d) => d.key === key);
|
|
10040
|
+
if (!entry) return void 0;
|
|
10041
|
+
const rendered = docs(ctx).find((d) => d.key === key)?.text;
|
|
10042
|
+
return rendered || readFileSync17(join22(ctx.root, entry.path), "utf8");
|
|
10043
|
+
}
|
|
9660
10044
|
var SPEC_SECTIONS = ["Goal", "User flow", "Technical design", "Decisions", "Acceptance criteria", "Out of scope"];
|
|
9661
10045
|
var SPEC_LINKS = ["Epic", "Jira Story", "Proposal", "Mockup", "One Pager"];
|
|
9662
10046
|
var EVIDENCE_VIDEO = "Evidence video";
|
|
@@ -9679,9 +10063,9 @@ function taskSpecs(ctx, state) {
|
|
|
9679
10063
|
const key = `tasks/${task.id}`;
|
|
9680
10064
|
const known = state.fusebase?.notes[key];
|
|
9681
10065
|
if (known?.observeOnly || inArchive(known?.path ?? "") || inArchive(task.file)) continue;
|
|
9682
|
-
const spec =
|
|
9683
|
-
const path =
|
|
9684
|
-
const source =
|
|
10066
|
+
const spec = join22(ctx.project.workDir, "task-specs", `${task.id}.md`);
|
|
10067
|
+
const path = existsSync20(spec) ? relative10(ctx.root, spec) : task.file;
|
|
10068
|
+
const source = readFileSync17(join22(ctx.root, path), "utf8");
|
|
9685
10069
|
const missing = [];
|
|
9686
10070
|
const tasksFolder = state.fusebase?.tasksFolder;
|
|
9687
10071
|
if (tasksFolder && inArchive(tasksFolder.path ?? tasksFolder.title)) missing.push("the mapped Tasks folder is archived");
|
|
@@ -9743,10 +10127,10 @@ function taskSyncBlockers(ctx) {
|
|
|
9743
10127
|
return ctx.project ? taskSpecs(ctx, readSyncState(ctx.project.workDir)).blocked : [];
|
|
9744
10128
|
}
|
|
9745
10129
|
function renderBacklogItems(workDir) {
|
|
9746
|
-
const dir =
|
|
9747
|
-
if (!
|
|
9748
|
-
const rows =
|
|
9749
|
-
const title = /^#\s+([^\n]+)$/m.exec(
|
|
10130
|
+
const dir = join22(workDir, "task-notes");
|
|
10131
|
+
if (!existsSync20(dir)) return "No intake proposals recorded.";
|
|
10132
|
+
const rows = readdirSync10(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".md")).sort((a, b) => a.name.localeCompare(b.name)).map(({ name }) => {
|
|
10133
|
+
const title = /^#\s+([^\n]+)$/m.exec(readFileSync17(join22(dir, name), "utf8"))?.[1]?.trim() || basename(name, ".md");
|
|
9750
10134
|
return `- [${esc(title)}](task-notes/${name})`;
|
|
9751
10135
|
});
|
|
9752
10136
|
return rows.join("\n") || "No intake proposals recorded.";
|
|
@@ -9755,7 +10139,7 @@ function remoteOnePager(ctx, d, state, cfg) {
|
|
|
9755
10139
|
if (!ctx.onePager) return d.text;
|
|
9756
10140
|
const blocks = remoteOnePagerBlocks(ctx.tasks, ctx.onePager.milestones, gitMergedChecker(ctx.root), ctx.config.can_show, {
|
|
9757
10141
|
site: cfg.jira?.site,
|
|
9758
|
-
keys: Object.fromEntries(Object.entries(state.jira?.tasks ?? {}).map(([
|
|
10142
|
+
keys: Object.fromEntries(Object.entries(state.jira?.tasks ?? {}).map(([id2, t]) => [id2, t.key]))
|
|
9759
10143
|
}, Object.fromEntries(ctx.tasks.flatMap((task) => {
|
|
9760
10144
|
const note = activeNote(state, `tasks/${task.id}`);
|
|
9761
10145
|
return note && cfg.fusebase ? [[task.id, { url: noteUrl(cfg.fusebase, note.id), evidenceVideo: note.evidenceVideo }]] : [];
|
|
@@ -9889,16 +10273,16 @@ ${open.join("\n")}` : "\u2705 All acceptance criteria pass."
|
|
|
9889
10273
|
return { marker, body };
|
|
9890
10274
|
}
|
|
9891
10275
|
function evidenceFiles(ctx) {
|
|
9892
|
-
const dir =
|
|
9893
|
-
if (!
|
|
10276
|
+
const dir = join22(ctx.root, ".lead/logs/qa");
|
|
10277
|
+
if (!existsSync20(dir)) return [];
|
|
9894
10278
|
const ids = new Set(ctx.tasks.map((t) => t.id));
|
|
9895
10279
|
const out = [];
|
|
9896
|
-
for (const sub of
|
|
9897
|
-
const
|
|
9898
|
-
if (!
|
|
9899
|
-
const p =
|
|
10280
|
+
for (const sub of readdirSync10(dir).sort()) {
|
|
10281
|
+
const id2 = /^(T-\d+)/.exec(sub)?.[1];
|
|
10282
|
+
if (!id2 || !ids.has(id2)) continue;
|
|
10283
|
+
const p = join22(dir, sub);
|
|
9900
10284
|
try {
|
|
9901
|
-
for (const f of
|
|
10285
|
+
for (const f of readdirSync10(p).sort()) if (/\.(png|jpe?g|webp|gif|mp4|webm|mov)$/i.test(f)) out.push(relative10(ctx.root, join22(p, f)));
|
|
9902
10286
|
} catch {
|
|
9903
10287
|
}
|
|
9904
10288
|
}
|
|
@@ -9926,7 +10310,7 @@ function syncPlan(ctx) {
|
|
|
9926
10310
|
for (const t of [...ctx.tasks].sort((a, b) => a.id.localeCompare(b.id))) {
|
|
9927
10311
|
if (t.sync_jira === false) continue;
|
|
9928
10312
|
const tsum = `${t.id} ${t.title}`;
|
|
9929
|
-
const goal = section(
|
|
10313
|
+
const goal = section(readFileSync17(join22(ctx.root, t.file), "utf8"), "Goal");
|
|
9930
10314
|
const tdesc = taskDescription(t, { goal, links: cfg.links, evidence: state.fusebase?.evidence?.files, onePager: onePagerUrl });
|
|
9931
10315
|
const h2 = hash2(tsum + tdesc);
|
|
9932
10316
|
const jiraStatus = j.statuses[t.status] ?? t.status;
|
|
@@ -9992,7 +10376,7 @@ function syncPlan(ctx) {
|
|
|
9992
10376
|
for (const p of files2) {
|
|
9993
10377
|
if (ev.files[p]) continue;
|
|
9994
10378
|
const task = /(T-\d+)/.exec(p)[1];
|
|
9995
|
-
actions.push({ kind: "fusebase.evidence.attach", org: f.org, workspace: f.workspace, noteId: ev.id, task, file:
|
|
10379
|
+
actions.push({ kind: "fusebase.evidence.attach", org: f.org, workspace: f.workspace, noteId: ev.id, task, file: join22(ctx.root, p), path: p });
|
|
9996
10380
|
}
|
|
9997
10381
|
}
|
|
9998
10382
|
}
|
|
@@ -10011,9 +10395,9 @@ function syncRecord(ctx, action, result) {
|
|
|
10011
10395
|
const old = s.fusebase;
|
|
10012
10396
|
if (action.role === "tasks") {
|
|
10013
10397
|
if (!old?.folder || old.folder.id !== action.parentId) throw new Error("the Tasks folder needs a mapped product folder");
|
|
10014
|
-
const
|
|
10015
|
-
if (old.tasksFolder && old.tasksFolder.id !==
|
|
10016
|
-
old.tasksFolder ??= { id, title: action.title };
|
|
10398
|
+
const id2 = need(result.id, "id");
|
|
10399
|
+
if (old.tasksFolder && old.tasksFolder.id !== id2) throw new Error("a different Tasks folder is already mapped");
|
|
10400
|
+
old.tasksFolder ??= { id: id2, title: action.title };
|
|
10017
10401
|
break;
|
|
10018
10402
|
}
|
|
10019
10403
|
s.fusebase = action.replaces ? { notes: {}, folder: { id: need(result.id, "id"), title: action.title }, trash: [...old?.trash ?? [], action.replaces] } : { ...old, notes: old?.notes ?? {}, folder: { id: need(result.id, "id"), title: action.title } };
|
|
@@ -10026,7 +10410,7 @@ function syncRecord(ctx, action, result) {
|
|
|
10026
10410
|
s.fusebase.evidence.files[action.path] = need(result.url, "url");
|
|
10027
10411
|
break;
|
|
10028
10412
|
case "fusebase.trash":
|
|
10029
|
-
s.fusebase.trash = (s.fusebase.trash ?? []).filter((
|
|
10413
|
+
s.fusebase.trash = (s.fusebase.trash ?? []).filter((id2) => !action.itemIds.includes(id2));
|
|
10030
10414
|
break;
|
|
10031
10415
|
case "fusebase.note.create":
|
|
10032
10416
|
case "fusebase.note.update": {
|
|
@@ -10043,8 +10427,8 @@ function syncRecord(ctx, action, result) {
|
|
|
10043
10427
|
...prev?.observeOnly ? { observeOnly: true } : {},
|
|
10044
10428
|
...action.key.startsWith("tasks/") && hasVideoLink(section(action.markdown, EVIDENCE_VIDEO)) ? { evidenceVideo: true } : {}
|
|
10045
10429
|
};
|
|
10046
|
-
mkdirSync8(
|
|
10047
|
-
writeFileSync9(
|
|
10430
|
+
mkdirSync8(join22(ctx.project.workDir, "sync-base"), { recursive: true });
|
|
10431
|
+
writeFileSync9(join22(ctx.project.workDir, "sync-base", `${action.key.replace(/\//g, "__")}.md`), action.markdown);
|
|
10048
10432
|
if (action.kind === "fusebase.note.create") {
|
|
10049
10433
|
if (prev && !action.replaces) throw new Error(`note ${action.key} already recorded`);
|
|
10050
10434
|
if (action.replaces) s.fusebase.trash = [...s.fusebase.trash ?? [], action.replaces];
|
|
@@ -10085,8 +10469,8 @@ function writeWaves(ctx) {
|
|
|
10085
10469
|
for (const t of ctx.tasks) {
|
|
10086
10470
|
const w = waves.get(t.id);
|
|
10087
10471
|
if (w === void 0 || w === t.wave || t.status === "done") continue;
|
|
10088
|
-
const abs =
|
|
10089
|
-
const text =
|
|
10472
|
+
const abs = join23(ctx.root, t.file);
|
|
10473
|
+
const text = readFileSync18(abs, "utf8");
|
|
10090
10474
|
const { parsed } = parseFrontmatter(text, t.file);
|
|
10091
10475
|
if (!parsed) continue;
|
|
10092
10476
|
parsed.data.wave = w;
|
|
@@ -10099,10 +10483,10 @@ function writeBoard(ctx, isMerged = gitMergedChecker(ctx.root)) {
|
|
|
10099
10483
|
if (!ctx.project) throw new Error("no project selected");
|
|
10100
10484
|
const log = [];
|
|
10101
10485
|
const board = renderBoard({ projectName: ctx.project.name, tasks: ctx.tasks, onePager: ctx.onePager, config: ctx.config });
|
|
10102
|
-
const boardPath =
|
|
10486
|
+
const boardPath = join23(ctx.project.workDir, "board.md");
|
|
10103
10487
|
let old = "";
|
|
10104
10488
|
try {
|
|
10105
|
-
old =
|
|
10489
|
+
old = readFileSync18(boardPath, "utf8");
|
|
10106
10490
|
} catch {
|
|
10107
10491
|
}
|
|
10108
10492
|
if (old !== board) {
|
|
@@ -10113,13 +10497,13 @@ function writeBoard(ctx, isMerged = gitMergedChecker(ctx.root)) {
|
|
|
10113
10497
|
const blocks = renderOnePagerBlocks(ctx.tasks, ctx.onePager.milestones, isMerged, ctx.config.can_show);
|
|
10114
10498
|
const next = replaceBlocks(ctx.onePager.text, (k) => blocks[k]);
|
|
10115
10499
|
if (next !== ctx.onePager.text) {
|
|
10116
|
-
writeFileSync10(
|
|
10500
|
+
writeFileSync10(join23(ctx.root, ctx.onePager.file), next);
|
|
10117
10501
|
log.push(`one-pager.md blocks updated: ${blockKinds(next).join(", ")}`);
|
|
10118
10502
|
}
|
|
10119
10503
|
}
|
|
10120
|
-
const backlog =
|
|
10121
|
-
if (
|
|
10122
|
-
const current =
|
|
10504
|
+
const backlog = join23(ctx.project.workDir, "backlog.md");
|
|
10505
|
+
if (existsSync21(backlog)) {
|
|
10506
|
+
const current = readFileSync18(backlog, "utf8");
|
|
10123
10507
|
const next = replaceBlocks(current, (kind) => ["tasks", "proposals"].includes(kind) ? renderBacklogItems(ctx.project.workDir) : void 0);
|
|
10124
10508
|
if (next !== current) {
|
|
10125
10509
|
writeFileSync10(backlog, next);
|
|
@@ -10130,12 +10514,75 @@ function writeBoard(ctx, isMerged = gitMergedChecker(ctx.root)) {
|
|
|
10130
10514
|
}
|
|
10131
10515
|
|
|
10132
10516
|
// src/cli.ts
|
|
10133
|
-
import { readFileSync as
|
|
10517
|
+
import { readFileSync as readFileSync27 } from "node:fs";
|
|
10134
10518
|
|
|
10135
|
-
// src/
|
|
10519
|
+
// src/inbox.ts
|
|
10136
10520
|
import { createHash as createHash6 } from "node:crypto";
|
|
10137
|
-
import { existsSync as
|
|
10138
|
-
import {
|
|
10521
|
+
import { existsSync as existsSync22, readdirSync as readdirSync11, readFileSync as readFileSync19 } from "node:fs";
|
|
10522
|
+
import { basename as basename2, join as join24, relative as relative11 } from "node:path";
|
|
10523
|
+
var id = (...parts) => createHash6("sha256").update(parts.join("\0")).digest("hex").slice(0, 10);
|
|
10524
|
+
var clean = (text) => text.replace(/<!--[\s\S]*?-->/g, "").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/[*_`]/g, "").trim();
|
|
10525
|
+
function bullets(text, heading) {
|
|
10526
|
+
const part = text.split(/^##\s+/m).slice(1).find((p) => heading.test(p.split("\n")[0].trim()));
|
|
10527
|
+
if (!part) return [];
|
|
10528
|
+
return part.replace(/<!--[\s\S]*?-->/g, "").split("\n").map((l) => /^\s*[-*]\s+(?:\[ \]\s+)?(.+)$/.exec(l)?.[1]).filter((l) => !!l && !/^none\.?$/i.test(l.trim())).map(clean);
|
|
10529
|
+
}
|
|
10530
|
+
function inbox(ctx) {
|
|
10531
|
+
if (!ctx.project) return [];
|
|
10532
|
+
const w = ctx.project.workDir;
|
|
10533
|
+
const rel = (path) => relative11(ctx.root, path);
|
|
10534
|
+
const urls = new Map(docIndex(ctx).filter((d) => d.url).map((d) => [d.path, d.url]));
|
|
10535
|
+
const source = (path) => ({ path: rel(path), ...urls.has(rel(path)) && { url: urls.get(rel(path)) } });
|
|
10536
|
+
const items = [];
|
|
10537
|
+
for (const t of ctx.tasks.filter((x) => x.status === "blocked")) {
|
|
10538
|
+
const waits = t.blocked_by.length ? `waits for ${t.blocked_by.join(", ")}` : "blocked, needs a decision";
|
|
10539
|
+
items.push({ id: id("blocker", t.id), kind: "blocker", title: `${t.id} ${t.title}`, detail: waits, source: source(join24(ctx.root, t.file)) });
|
|
10540
|
+
}
|
|
10541
|
+
const onePager = join24(w, "one-pager.md");
|
|
10542
|
+
if (existsSync22(onePager)) {
|
|
10543
|
+
for (const b of bullets(readFileSync19(onePager, "utf8"), /^needs attention$/i)) {
|
|
10544
|
+
items.push({ id: id("question", "one-pager", b), kind: "question", title: b, source: source(onePager) });
|
|
10545
|
+
}
|
|
10546
|
+
}
|
|
10547
|
+
const backlog = join24(w, "backlog.md");
|
|
10548
|
+
if (existsSync22(backlog)) {
|
|
10549
|
+
for (const b of bullets(readFileSync19(backlog, "utf8"), /^needs triage$/i)) {
|
|
10550
|
+
items.push({ id: id("question", "backlog", b), kind: "question", title: b, detail: "needs triage", source: source(backlog) });
|
|
10551
|
+
}
|
|
10552
|
+
}
|
|
10553
|
+
const notes = join24(w, "task-notes");
|
|
10554
|
+
if (existsSync22(notes)) {
|
|
10555
|
+
for (const name of readdirSync11(notes).filter((n) => n.endsWith(".md")).sort()) {
|
|
10556
|
+
const path = join24(notes, name);
|
|
10557
|
+
const title = /^#\s+([^\n]+)$/m.exec(readFileSync19(path, "utf8"))?.[1]?.trim() || basename2(name, ".md");
|
|
10558
|
+
items.push({
|
|
10559
|
+
id: id("approval", "proposal", name),
|
|
10560
|
+
kind: "approval",
|
|
10561
|
+
title: `Proposal: ${clean(title)}`,
|
|
10562
|
+
detail: "accept into the plan?",
|
|
10563
|
+
source: source(path),
|
|
10564
|
+
approve: `Accept the proposal in ${rel(path)} into the plan as a lead task, following the lead intake rules.`
|
|
10565
|
+
});
|
|
10566
|
+
}
|
|
10567
|
+
}
|
|
10568
|
+
const sections = existsSync22(join24(w, "spec")) ? loadSections(ctx.root, w).sections : [];
|
|
10569
|
+
for (const s of sections.filter((x) => x.status !== "confirmed")) {
|
|
10570
|
+
items.push({
|
|
10571
|
+
id: id("approval", "spec", s.name),
|
|
10572
|
+
kind: "approval",
|
|
10573
|
+
title: `Specification: ${s.name}`,
|
|
10574
|
+
detail: "draft, confirm?",
|
|
10575
|
+
source: source(join24(ctx.root, s.file)),
|
|
10576
|
+
approve: `Confirm the specification section "${s.name}" with lead spec --confirm ${s.name}.`
|
|
10577
|
+
});
|
|
10578
|
+
}
|
|
10579
|
+
return items;
|
|
10580
|
+
}
|
|
10581
|
+
|
|
10582
|
+
// src/cleanroom.ts
|
|
10583
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
10584
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync9, readdirSync as readdirSync12, readFileSync as readFileSync20, realpathSync as realpathSync5, statSync as statSync7, writeFileSync as writeFileSync11 } from "node:fs";
|
|
10585
|
+
import { extname, join as join25, relative as relative12 } from "node:path";
|
|
10139
10586
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
10140
10587
|
function packageStores() {
|
|
10141
10588
|
try {
|
|
@@ -10147,9 +10594,9 @@ function packageStores() {
|
|
|
10147
10594
|
}
|
|
10148
10595
|
function gitCommonDir(root) {
|
|
10149
10596
|
try {
|
|
10150
|
-
return
|
|
10597
|
+
return realpathSync5(execFileSync5("git", ["rev-parse", "--path-format=absolute", "--git-common-dir"], { cwd: root, encoding: "utf8" }).trim());
|
|
10151
10598
|
} catch {
|
|
10152
|
-
return
|
|
10599
|
+
return join25(root, ".git");
|
|
10153
10600
|
}
|
|
10154
10601
|
}
|
|
10155
10602
|
var pathRules = (abs) => {
|
|
@@ -10158,12 +10605,12 @@ var pathRules = (abs) => {
|
|
|
10158
10605
|
};
|
|
10159
10606
|
var isUselessRule = (r) => /^(Grep|Glob|Edit)\(\/\//.test(r);
|
|
10160
10607
|
function builderSettings(root, name, source, extra = []) {
|
|
10161
|
-
const abs =
|
|
10608
|
+
const abs = realpathSync5(source);
|
|
10162
10609
|
if (abs === root || abs.startsWith(root + "/")) throw new Error(`the source of ${name} must live outside the repo (found inside ${root})`);
|
|
10163
10610
|
const rel = `.lead/builder-${name.replace(/[^a-zA-Z0-9_-]/g, "_")}.json`;
|
|
10164
|
-
const file =
|
|
10165
|
-
const prev =
|
|
10166
|
-
const paths = [abs,
|
|
10611
|
+
const file = join25(root, rel);
|
|
10612
|
+
const prev = existsSync23(file) ? JSON.parse(readFileSync20(file, "utf8")) : {};
|
|
10613
|
+
const paths = [abs, join25(root, ".lead/logs/reverse"), file, ...extra.map((p) => p.startsWith("/") ? p : join25(root, p))];
|
|
10167
10614
|
const deny = /* @__PURE__ */ new Set([
|
|
10168
10615
|
...(prev.permissions?.deny ?? []).filter((r) => !isUselessRule(r)),
|
|
10169
10616
|
...paths.flatMap(pathRules),
|
|
@@ -10192,7 +10639,7 @@ function builderSettings(root, name, source, extra = []) {
|
|
|
10192
10639
|
SessionStart: [{ hooks: [{ type: "command", command: `${cli} session-start` }] }]
|
|
10193
10640
|
}
|
|
10194
10641
|
};
|
|
10195
|
-
mkdirSync9(
|
|
10642
|
+
mkdirSync9(join25(root, ".lead"), { recursive: true });
|
|
10196
10643
|
writeFileSync11(file, `${JSON.stringify(settings, null, 2)}
|
|
10197
10644
|
`);
|
|
10198
10645
|
return { path: rel, launch: `claude --settings ${rel}` };
|
|
@@ -10200,16 +10647,16 @@ function builderSettings(root, name, source, extra = []) {
|
|
|
10200
10647
|
var TEXT = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte", ".css", ".scss", ".html", ".md", ".json", ".py", ".go", ".rb", ".php", ".java", ".kt", ".rs", ".sql", ".yml", ".yaml", ".txt"]);
|
|
10201
10648
|
var SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", "build", ".next", "coverage", "vendor", ".lead", ".claude"]);
|
|
10202
10649
|
function files(dir, out = []) {
|
|
10203
|
-
if (!
|
|
10204
|
-
const st =
|
|
10650
|
+
if (!existsSync23(dir)) return out;
|
|
10651
|
+
const st = statSync7(dir);
|
|
10205
10652
|
if (st.isFile()) {
|
|
10206
10653
|
out.push(dir);
|
|
10207
10654
|
return out;
|
|
10208
10655
|
}
|
|
10209
|
-
for (const n of
|
|
10656
|
+
for (const n of readdirSync12(dir)) {
|
|
10210
10657
|
if (SKIP.has(n)) continue;
|
|
10211
|
-
const p =
|
|
10212
|
-
const s =
|
|
10658
|
+
const p = join25(dir, n);
|
|
10659
|
+
const s = statSync7(p);
|
|
10213
10660
|
if (s.isDirectory()) files(p, out);
|
|
10214
10661
|
else if (TEXT.has(extname(n)) && s.size < 1e6) out.push(p);
|
|
10215
10662
|
}
|
|
@@ -10218,82 +10665,82 @@ function files(dir, out = []) {
|
|
|
10218
10665
|
function meaningful(text) {
|
|
10219
10666
|
return text.split("\n").map((l, i) => ({ line: i + 1, norm: l.trim().replace(/\s+/g, " ") })).filter((x) => x.norm.length >= 20 && /[a-zA-Z]{3}/.test(x.norm) && !/^(import|export \{|\/\/|#|\*|<\/?\w+>$)/.test(x.norm));
|
|
10220
10667
|
}
|
|
10221
|
-
var h = (s) =>
|
|
10668
|
+
var h = (s) => createHash7("sha1").update(s).digest("hex");
|
|
10222
10669
|
function similarity(source, targets, root, window = 6, longLine = 200) {
|
|
10223
10670
|
const blocks = /* @__PURE__ */ new Map();
|
|
10224
10671
|
const longs = /* @__PURE__ */ new Map();
|
|
10225
10672
|
for (const f of files(source)) {
|
|
10226
|
-
const m = meaningful(
|
|
10673
|
+
const m = meaningful(readFileSync20(f, "utf8"));
|
|
10227
10674
|
for (let i = 0; i + window <= m.length; i++) blocks.set(h(m.slice(i, i + window).map((x) => x.norm).join("\n")), { file: f, line: m[i].line });
|
|
10228
10675
|
for (const x of m) if (x.norm.length >= longLine) longs.set(h(x.norm), { file: f, line: x.line });
|
|
10229
10676
|
}
|
|
10230
10677
|
const matches = [];
|
|
10231
10678
|
for (const t of targets.flatMap((p) => files(p))) {
|
|
10232
|
-
const m = meaningful(
|
|
10679
|
+
const m = meaningful(readFileSync20(t, "utf8"));
|
|
10233
10680
|
let skipUntil = -1;
|
|
10234
10681
|
for (let i = 0; i + window <= m.length; i++) {
|
|
10235
10682
|
if (i < skipUntil) continue;
|
|
10236
10683
|
const hit = blocks.get(h(m.slice(i, i + window).map((x) => x.norm).join("\n")));
|
|
10237
10684
|
if (hit) {
|
|
10238
|
-
matches.push({ file:
|
|
10685
|
+
matches.push({ file: relative12(root, t), line: m[i].line, source: relative12(source, hit.file) || hit.file, sourceLine: hit.line, kind: "block" });
|
|
10239
10686
|
skipUntil = i + window;
|
|
10240
10687
|
}
|
|
10241
10688
|
}
|
|
10242
10689
|
for (const x of m) {
|
|
10243
10690
|
const hit = x.norm.length >= longLine ? longs.get(h(x.norm)) : void 0;
|
|
10244
|
-
if (hit) matches.push({ file:
|
|
10691
|
+
if (hit) matches.push({ file: relative12(root, t), line: x.line, source: relative12(source, hit.file) || hit.file, sourceLine: hit.line, kind: "long-line" });
|
|
10245
10692
|
}
|
|
10246
10693
|
}
|
|
10247
10694
|
return matches;
|
|
10248
10695
|
}
|
|
10249
10696
|
|
|
10250
10697
|
// src/cli.ts
|
|
10251
|
-
import { basename as
|
|
10698
|
+
import { basename as basename3, relative as relative14, sep as sep5 } from "node:path";
|
|
10252
10699
|
|
|
10253
10700
|
// src/delegate.ts
|
|
10254
|
-
import { existsSync as
|
|
10255
|
-
import { join as
|
|
10701
|
+
import { existsSync as existsSync24, readdirSync as readdirSync13, readFileSync as readFileSync21 } from "node:fs";
|
|
10702
|
+
import { join as join26 } from "node:path";
|
|
10256
10703
|
function readDelegate(file, source) {
|
|
10257
|
-
if (!
|
|
10258
|
-
const { parsed } = parseFrontmatter(
|
|
10259
|
-
const
|
|
10260
|
-
if (!/^[a-z][a-z0-9-]*$/.test(
|
|
10704
|
+
if (!existsSync24(file)) return void 0;
|
|
10705
|
+
const { parsed } = parseFrontmatter(readFileSync21(file, "utf8"), file);
|
|
10706
|
+
const id2 = typeof parsed?.data.name === "string" ? parsed.data.name : "";
|
|
10707
|
+
if (!/^[a-z][a-z0-9-]*$/.test(id2)) return void 0;
|
|
10261
10708
|
return {
|
|
10262
|
-
id,
|
|
10263
|
-
title: typeof parsed?.data.title === "string" ? parsed.data.title :
|
|
10709
|
+
id: id2,
|
|
10710
|
+
title: typeof parsed?.data.title === "string" ? parsed.data.title : id2,
|
|
10264
10711
|
file,
|
|
10265
10712
|
source,
|
|
10266
10713
|
available: typeof parsed?.data.available === "string" ? parsed.data.available : ""
|
|
10267
10714
|
};
|
|
10268
10715
|
}
|
|
10269
10716
|
function fromDir(dir, source) {
|
|
10270
|
-
if (!
|
|
10717
|
+
if (!existsSync24(dir)) return [];
|
|
10271
10718
|
const out = [];
|
|
10272
|
-
for (const name of
|
|
10273
|
-
const d = readDelegate(
|
|
10719
|
+
for (const name of readdirSync13(dir).sort()) {
|
|
10720
|
+
const d = readDelegate(join26(dir, name, "SKILL.md"), source);
|
|
10274
10721
|
if (d) out.push(d);
|
|
10275
10722
|
}
|
|
10276
10723
|
return out;
|
|
10277
10724
|
}
|
|
10278
10725
|
function listDelegates(root, kit) {
|
|
10279
10726
|
const byId = /* @__PURE__ */ new Map();
|
|
10280
|
-
for (const d of [...fromDir(
|
|
10727
|
+
for (const d of [...fromDir(join26(root, ".agents/skills/lead/delegates"), "kit"), ...fromDir(join26(root, ".claude/skills/lead/delegates"), "kit")]) {
|
|
10281
10728
|
byId.set(d.id, d);
|
|
10282
10729
|
}
|
|
10283
10730
|
if (kit) {
|
|
10284
|
-
for (const d of fromDir(
|
|
10731
|
+
for (const d of fromDir(join26(kit, "skills/lead/delegates"), "kit")) byId.set(d.id, d);
|
|
10285
10732
|
}
|
|
10286
|
-
for (const d of fromDir(
|
|
10733
|
+
for (const d of fromDir(join26(root, ".lead/delegates"), "project")) byId.set(d.id, d);
|
|
10287
10734
|
return [...byId.values()].sort((a, b) => a.id.localeCompare(b.id));
|
|
10288
10735
|
}
|
|
10289
|
-
function delegatedTasks(tasks,
|
|
10290
|
-
return tasks.filter((t) => t.delegate && (!
|
|
10736
|
+
function delegatedTasks(tasks, id2) {
|
|
10737
|
+
return tasks.filter((t) => t.delegate && (!id2 || t.delegate === id2)).sort((a, b) => a.id.localeCompare(b.id));
|
|
10291
10738
|
}
|
|
10292
10739
|
|
|
10293
10740
|
// src/watch.ts
|
|
10294
10741
|
import { spawn } from "node:child_process";
|
|
10295
|
-
import { existsSync as
|
|
10296
|
-
import { join as
|
|
10742
|
+
import { existsSync as existsSync25, mkdirSync as mkdirSync10, readFileSync as readFileSync22, writeFileSync as writeFileSync12 } from "node:fs";
|
|
10743
|
+
import { join as join27 } from "node:path";
|
|
10297
10744
|
var WATCH_PATH = ".lead/watch.json";
|
|
10298
10745
|
var MIN_INTERVAL_MS = 5 * 60 * 1e3;
|
|
10299
10746
|
var DEFAULT_INTERVAL = "15m";
|
|
@@ -10306,18 +10753,18 @@ function parseInterval(text) {
|
|
|
10306
10753
|
return ms;
|
|
10307
10754
|
}
|
|
10308
10755
|
function readWatch(root) {
|
|
10309
|
-
const p =
|
|
10310
|
-
if (!
|
|
10756
|
+
const p = join27(root, WATCH_PATH);
|
|
10757
|
+
if (!existsSync25(p)) return { interval: DEFAULT_INTERVAL, close: false };
|
|
10311
10758
|
try {
|
|
10312
|
-
const d = JSON.parse(
|
|
10759
|
+
const d = JSON.parse(readFileSync22(p, "utf8"));
|
|
10313
10760
|
return { interval: typeof d.interval === "string" ? d.interval : DEFAULT_INTERVAL, close: d.close === true, pid: d.pid, startedAt: d.startedAt, due: d.due };
|
|
10314
10761
|
} catch {
|
|
10315
10762
|
return { interval: DEFAULT_INTERVAL, close: false };
|
|
10316
10763
|
}
|
|
10317
10764
|
}
|
|
10318
10765
|
function writeWatch(root, state) {
|
|
10319
|
-
mkdirSync10(
|
|
10320
|
-
writeFileSync12(
|
|
10766
|
+
mkdirSync10(join27(root, ".lead"), { recursive: true });
|
|
10767
|
+
writeFileSync12(join27(root, WATCH_PATH), `${JSON.stringify(state, null, 2)}
|
|
10321
10768
|
`);
|
|
10322
10769
|
}
|
|
10323
10770
|
function alive(pid) {
|
|
@@ -10396,15 +10843,15 @@ function runWatchLoop(root, sleep = (ms) => Atomics.wait(new Int32Array(new Shar
|
|
|
10396
10843
|
}
|
|
10397
10844
|
|
|
10398
10845
|
// src/mergehold.ts
|
|
10399
|
-
import { existsSync as
|
|
10400
|
-
import { join as
|
|
10846
|
+
import { existsSync as existsSync26, mkdirSync as mkdirSync11, readFileSync as readFileSync23, rmSync as rmSync5, writeFileSync as writeFileSync13 } from "node:fs";
|
|
10847
|
+
import { join as join28 } from "node:path";
|
|
10401
10848
|
var MERGE_LOCK = ".lead/merge.json";
|
|
10402
10849
|
var HOLD_MS = 15 * 60 * 1e3;
|
|
10403
10850
|
function read2(root) {
|
|
10404
|
-
const p =
|
|
10405
|
-
if (!
|
|
10851
|
+
const p = join28(root, MERGE_LOCK);
|
|
10852
|
+
if (!existsSync26(p)) return void 0;
|
|
10406
10853
|
try {
|
|
10407
|
-
return JSON.parse(
|
|
10854
|
+
return JSON.parse(readFileSync23(p, "utf8"));
|
|
10408
10855
|
} catch {
|
|
10409
10856
|
return void 0;
|
|
10410
10857
|
}
|
|
@@ -10415,9 +10862,9 @@ function holdMerge(root, opts) {
|
|
|
10415
10862
|
if (cur && cur.session !== opts.session && now.getTime() - Date.parse(cur.at) < HOLD_MS) {
|
|
10416
10863
|
return { ok: false, message: `${cur.task} merge is held by session ${cur.session} since ${cur.at}` };
|
|
10417
10864
|
}
|
|
10418
|
-
mkdirSync11(
|
|
10865
|
+
mkdirSync11(join28(root, ".lead"), { recursive: true });
|
|
10419
10866
|
const lock = { task: opts.task, session: opts.session, mr: opts.mr, at: now.toISOString() };
|
|
10420
|
-
writeFileSync13(
|
|
10867
|
+
writeFileSync13(join28(root, MERGE_LOCK), `${JSON.stringify(lock, null, 2)}
|
|
10421
10868
|
`);
|
|
10422
10869
|
return { ok: true, message: `merge ${opts.mr} held for ${opts.task}` };
|
|
10423
10870
|
}
|
|
@@ -10426,13 +10873,13 @@ function releaseMerge(root, opts) {
|
|
|
10426
10873
|
if (!cur) return { ok: true, message: "no merge hold" };
|
|
10427
10874
|
if (cur.task !== opts.task) return { ok: false, message: `merge hold is for ${cur.task}, not ${opts.task}` };
|
|
10428
10875
|
if (cur.session !== opts.session) return { ok: false, message: `merge hold belongs to session ${cur.session}` };
|
|
10429
|
-
rmSync5(
|
|
10876
|
+
rmSync5(join28(root, MERGE_LOCK), { force: true });
|
|
10430
10877
|
return { ok: true, message: `merge hold for ${opts.task} released` };
|
|
10431
10878
|
}
|
|
10432
10879
|
|
|
10433
10880
|
// src/activity.ts
|
|
10434
|
-
import { appendFileSync as appendFileSync2, existsSync as
|
|
10435
|
-
import { join as
|
|
10881
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync27, mkdirSync as mkdirSync12, readdirSync as readdirSync14, readFileSync as readFileSync24 } from "node:fs";
|
|
10882
|
+
import { join as join29 } from "node:path";
|
|
10436
10883
|
var ACTIVITY_DIR = ".lead/activity";
|
|
10437
10884
|
var EVENTS = ["start", "end", "check", "status", "note", "wait", "merge"];
|
|
10438
10885
|
function isEvent(v) {
|
|
@@ -10450,22 +10897,22 @@ function appendActivity(root, entry) {
|
|
|
10450
10897
|
...entry.session ? { session: oneLine2(entry.session) } : {},
|
|
10451
10898
|
...entry.goal ? { goal: oneLine2(entry.goal) } : {}
|
|
10452
10899
|
};
|
|
10453
|
-
const rel =
|
|
10454
|
-
const abs =
|
|
10455
|
-
mkdirSync12(
|
|
10900
|
+
const rel = join29(ACTIVITY_DIR, `${at.slice(0, 10)}.jsonl`);
|
|
10901
|
+
const abs = join29(root, rel);
|
|
10902
|
+
mkdirSync12(join29(root, ACTIVITY_DIR), { recursive: true });
|
|
10456
10903
|
appendFileSync2(abs, `${JSON.stringify(row)}
|
|
10457
10904
|
`);
|
|
10458
10905
|
return rel;
|
|
10459
10906
|
}
|
|
10460
10907
|
function readActivityDay(root, day) {
|
|
10461
|
-
const p =
|
|
10462
|
-
if (!
|
|
10463
|
-
return
|
|
10908
|
+
const p = join29(root, ACTIVITY_DIR, `${day}.jsonl`);
|
|
10909
|
+
if (!existsSync27(p)) return [];
|
|
10910
|
+
return readFileSync24(p, "utf8").split("\n").filter(Boolean).map((line) => JSON.parse(line));
|
|
10464
10911
|
}
|
|
10465
10912
|
function listActivityDays(root) {
|
|
10466
|
-
const dir =
|
|
10467
|
-
if (!
|
|
10468
|
-
return
|
|
10913
|
+
const dir = join29(root, ACTIVITY_DIR);
|
|
10914
|
+
if (!existsSync27(dir)) return [];
|
|
10915
|
+
return readdirSync14(dir).filter((n) => /^\d{4}-\d{2}-\d{2}\.jsonl$/.test(n)).map((n) => n.replace(/\.jsonl$/, "")).sort();
|
|
10469
10916
|
}
|
|
10470
10917
|
function loadActivity(root, opts = {}) {
|
|
10471
10918
|
const days = opts.day ? [opts.day] : listActivityDays(root).filter((d) => !opts.since || d >= opts.since);
|
|
@@ -10535,34 +10982,352 @@ function oneLine2(s) {
|
|
|
10535
10982
|
return s.replace(/\s+/g, " ").trim();
|
|
10536
10983
|
}
|
|
10537
10984
|
|
|
10985
|
+
// src/adopt.ts
|
|
10986
|
+
var import_yaml4 = __toESM(require_dist(), 1);
|
|
10987
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync13, readFileSync as readFileSync25, writeFileSync as writeFileSync14 } from "node:fs";
|
|
10988
|
+
import { dirname as dirname5, join as join30 } from "node:path";
|
|
10989
|
+
var REPO = /^[a-z][a-z0-9-]*$/;
|
|
10990
|
+
var keyNum = (key) => Number(/-(\d+)$/.exec(key)?.[1] ?? 0);
|
|
10991
|
+
function validateInventory(raw) {
|
|
10992
|
+
const errors = [];
|
|
10993
|
+
const r = raw ?? {};
|
|
10994
|
+
const str3 = (v) => typeof v === "string" && v.trim() !== "";
|
|
10995
|
+
if (!str3(r.site)) errors.push("site is required");
|
|
10996
|
+
const epic = r.epic;
|
|
10997
|
+
if (!epic || !str3(epic.key) || !str3(epic.summary)) errors.push("epic needs key and summary");
|
|
10998
|
+
const list = (name, need) => {
|
|
10999
|
+
const v = r[name];
|
|
11000
|
+
if (!Array.isArray(v)) return errors.push(`${name} must be a list`);
|
|
11001
|
+
v.forEach((x, i) => {
|
|
11002
|
+
for (const k of need) if (!str3(x?.[k])) errors.push(`${name}[${i}].${k} is required`);
|
|
11003
|
+
});
|
|
11004
|
+
};
|
|
11005
|
+
list("stories", ["key", "summary", "status"]);
|
|
11006
|
+
list("subtasks", ["key", "summary", "status", "parent"]);
|
|
11007
|
+
if (errors.length) return { errors };
|
|
11008
|
+
const subtasks = r.subtasks;
|
|
11009
|
+
const keys = subtasks.map((s) => s.key);
|
|
11010
|
+
const dup = keys.find((k, i) => keys.indexOf(k) !== i);
|
|
11011
|
+
if (dup) errors.push(`sub-task ${dup} is listed twice`);
|
|
11012
|
+
const storyKeys = new Set(r.stories.map((s) => s.key));
|
|
11013
|
+
for (const s of subtasks) if (!storyKeys.has(s.parent)) errors.push(`${s.key}: parent ${s.parent} is not in stories`);
|
|
11014
|
+
return errors.length ? { errors } : { inventory: r, errors };
|
|
11015
|
+
}
|
|
11016
|
+
function observedState(status2) {
|
|
11017
|
+
const n = status2.toLowerCase();
|
|
11018
|
+
if (/blocked/.test(n)) return "blocked";
|
|
11019
|
+
if (/review/.test(n)) return "review";
|
|
11020
|
+
if (/\b(done|closed|resolved|released)\b/.test(n)) return "done";
|
|
11021
|
+
if (/progress|doing|development/.test(n)) return "in_progress";
|
|
11022
|
+
if (/^(to do|todo|open|backlog|new)$/.test(n)) return "todo";
|
|
11023
|
+
return "other";
|
|
11024
|
+
}
|
|
11025
|
+
var kindOf = (summary) => ANY_QA.test(summary) ? "qa" : PERSON.test(summary) ? "manual" : "work";
|
|
11026
|
+
function parseTitle(summary) {
|
|
11027
|
+
const parts = summary.split(": ").map((p) => p.trim());
|
|
11028
|
+
const seg = parts.length >= 3 ? parts[1] : parts.length === 2 ? parts[0] : "";
|
|
11029
|
+
if (!seg) return { repos: [], reason: 'no "<repo>:" in the title' };
|
|
11030
|
+
const tokens = seg.split(/\s*(?:,|\/|\band\b)\s*/).filter(Boolean);
|
|
11031
|
+
if (!tokens.length || !tokens.every((t) => REPO.test(t))) return { repos: [], reason: `"${seg}" is not a repository name` };
|
|
11032
|
+
return { repos: tokens };
|
|
11033
|
+
}
|
|
11034
|
+
var QA = /\bQA stage (\d+)\b/i;
|
|
11035
|
+
var ANY_QA = /\bQA\b/;
|
|
11036
|
+
var PERSON = /\(person\)/i;
|
|
11037
|
+
function planRange(description) {
|
|
11038
|
+
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 ?? "");
|
|
11039
|
+
return m ? [Number(m[1]), Number(m[2])] : void 0;
|
|
11040
|
+
}
|
|
11041
|
+
function goneRecords(previous, now) {
|
|
11042
|
+
const prev = previous ?? {};
|
|
11043
|
+
const out = {};
|
|
11044
|
+
for (const [key, v] of Object.entries(prev.gone ?? {})) if (!now[key]) out[key] = v;
|
|
11045
|
+
for (const [key, v] of Object.entries(prev.issues ?? {})) if (!now[key]) out[key] = { summary: v.summary ?? "", status: v.status ?? "" };
|
|
11046
|
+
return Object.fromEntries(Object.entries(out).sort(([a], [b]) => keyNum(a) - keyNum(b)));
|
|
11047
|
+
}
|
|
11048
|
+
function propose(inv, o) {
|
|
11049
|
+
const issues = {};
|
|
11050
|
+
const unmapped = [];
|
|
11051
|
+
const milestones = [];
|
|
11052
|
+
const withTasks = new Set(inv.subtasks.map((s) => s.parent));
|
|
11053
|
+
const scoped2 = withTasks.size > 1;
|
|
11054
|
+
for (const story of inv.stories.filter((s) => withTasks.has(s.key))) {
|
|
11055
|
+
const subs = inv.subtasks.filter((s) => s.parent === story.key).sort((a, b) => keyNum(a.key) - keyNum(b.key));
|
|
11056
|
+
const range = planRange(story.description);
|
|
11057
|
+
const prefix = scoped2 ? `${story.key.toLowerCase()}-` : "";
|
|
11058
|
+
const planned = subs.filter((s) => !range || keyNum(s.key) >= range[0] && keyNum(s.key) <= range[1]);
|
|
11059
|
+
const segments = [];
|
|
11060
|
+
let seg = { subs: [] };
|
|
11061
|
+
for (const s of planned) {
|
|
11062
|
+
seg.subs.push(s);
|
|
11063
|
+
const qa = QA.exec(s.summary);
|
|
11064
|
+
if (qa) {
|
|
11065
|
+
seg.qa = { n: Number(qa[1]), key: s.key };
|
|
11066
|
+
segments.push(seg);
|
|
11067
|
+
seg = { subs: [] };
|
|
11068
|
+
}
|
|
11069
|
+
}
|
|
11070
|
+
if (seg.subs.length) segments.push(seg);
|
|
11071
|
+
const lastStage = [...segments].reverse().find((x) => x.qa)?.qa?.n;
|
|
11072
|
+
let boundary;
|
|
11073
|
+
for (const sg of segments) {
|
|
11074
|
+
const [id2, title] = sg.qa ? [`stage-${sg.qa.n}`, `Stage ${sg.qa.n}`] : lastStage !== void 0 ? [`after-stage-${lastStage}`, `After stage ${lastStage}`] : ["stage-1", "Stage 1"];
|
|
11075
|
+
const m = {
|
|
11076
|
+
id: `${prefix}${id2}`,
|
|
11077
|
+
title: scoped2 ? `${story.key} ${title}` : title,
|
|
11078
|
+
shows: sg.qa ? subs.find((x) => x.key === sg.qa.key).summary.replace(/^.*?:\s*/, "") : "",
|
|
11079
|
+
issues: []
|
|
11080
|
+
};
|
|
11081
|
+
milestones.push(m);
|
|
11082
|
+
for (const s of sg.subs) {
|
|
11083
|
+
const kind = kindOf(s.summary);
|
|
11084
|
+
const t = parseTitle(s.summary);
|
|
11085
|
+
if (kind === "work" && !t.repos.length) unmapped.push({ key: s.key, reason: `repository: ${t.reason}` });
|
|
11086
|
+
issues[s.key] = {
|
|
11087
|
+
summary: s.summary,
|
|
11088
|
+
status: s.status,
|
|
11089
|
+
observed: observedState(s.status),
|
|
11090
|
+
story: story.key,
|
|
11091
|
+
kind,
|
|
11092
|
+
...kind !== "qa" && t.repos[0] ? { repo: t.repos[0] } : {},
|
|
11093
|
+
...kind !== "qa" && t.repos.length > 1 ? { also: t.repos.slice(1) } : {},
|
|
11094
|
+
milestone: m.id,
|
|
11095
|
+
...boundary ? { after: boundary } : {},
|
|
11096
|
+
observeOnly: true
|
|
11097
|
+
};
|
|
11098
|
+
m.issues.push(s.key);
|
|
11099
|
+
}
|
|
11100
|
+
if (sg.qa) boundary = sg.qa.key;
|
|
11101
|
+
}
|
|
11102
|
+
const outside = subs.filter((s) => !planned.includes(s));
|
|
11103
|
+
if (outside.length) {
|
|
11104
|
+
const id2 = `${prefix}outside-plan`;
|
|
11105
|
+
milestones.push({ id: id2, 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) });
|
|
11106
|
+
for (const s of outside) {
|
|
11107
|
+
const t = parseTitle(s.summary);
|
|
11108
|
+
if (kindOf(s.summary) === "work" && !t.repos.length) unmapped.push({ key: s.key, reason: `repository: ${t.reason}` });
|
|
11109
|
+
issues[s.key] = {
|
|
11110
|
+
summary: s.summary,
|
|
11111
|
+
status: s.status,
|
|
11112
|
+
observed: observedState(s.status),
|
|
11113
|
+
story: story.key,
|
|
11114
|
+
kind: kindOf(s.summary),
|
|
11115
|
+
...t.repos[0] ? { repo: t.repos[0] } : {},
|
|
11116
|
+
...t.repos.length > 1 ? { also: t.repos.slice(1) } : {},
|
|
11117
|
+
milestone: id2,
|
|
11118
|
+
observeOnly: true
|
|
11119
|
+
};
|
|
11120
|
+
}
|
|
11121
|
+
}
|
|
11122
|
+
}
|
|
11123
|
+
const decided = [];
|
|
11124
|
+
for (const [key, ov] of Object.entries(o.overrides ?? {})) {
|
|
11125
|
+
const it = issues[key];
|
|
11126
|
+
if (!it) continue;
|
|
11127
|
+
if (ov.milestone && ov.milestone !== it.milestone) {
|
|
11128
|
+
const to = milestones.find((m) => m.id === ov.milestone);
|
|
11129
|
+
if (!to) {
|
|
11130
|
+
unmapped.push({ key, reason: `decision: milestone "${ov.milestone}" does not exist` });
|
|
11131
|
+
continue;
|
|
11132
|
+
}
|
|
11133
|
+
const from = milestones.find((m) => m.id === it.milestone);
|
|
11134
|
+
if (from) from.issues = from.issues.filter((k) => k !== key);
|
|
11135
|
+
to.issues.push(key);
|
|
11136
|
+
to.issues.sort((a, b) => keyNum(a) - keyNum(b));
|
|
11137
|
+
it.milestone = to.id;
|
|
11138
|
+
}
|
|
11139
|
+
if (ov.kind) it.kind = ov.kind;
|
|
11140
|
+
if (ov.repo) {
|
|
11141
|
+
it.repo = ov.repo;
|
|
11142
|
+
delete it.also;
|
|
11143
|
+
}
|
|
11144
|
+
if (it.repo || it.kind !== "work") {
|
|
11145
|
+
const at = unmapped.findIndex((u) => u.key === key && u.reason.startsWith("repository:"));
|
|
11146
|
+
if (at >= 0) unmapped.splice(at, 1);
|
|
11147
|
+
}
|
|
11148
|
+
decided.push(key);
|
|
11149
|
+
}
|
|
11150
|
+
const counts = /* @__PURE__ */ new Map();
|
|
11151
|
+
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);
|
|
11152
|
+
const repos = [{ name: o.home, role: "home", count: counts.get(o.home) ?? 0 }];
|
|
11153
|
+
for (const [name, count] of [...counts].sort(([a], [b]) => a.localeCompare(b))) if (name !== o.home) repos.push({ name, role: "reference", count });
|
|
11154
|
+
const statusCounts = /* @__PURE__ */ new Map();
|
|
11155
|
+
for (const i of Object.values(issues)) statusCounts.set(i.status, (statusCounts.get(i.status) ?? 0) + 1);
|
|
11156
|
+
const statuses = [...statusCounts].sort(([a], [b]) => a.localeCompare(b)).map(([name, count]) => ({ name, observed: observedState(name), count }));
|
|
11157
|
+
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" });
|
|
11158
|
+
const mapped = new Set(Object.keys(issues));
|
|
11159
|
+
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" });
|
|
11160
|
+
const flag = o.flag ?? inv.flag;
|
|
11161
|
+
return {
|
|
11162
|
+
id: o.id,
|
|
11163
|
+
title: o.title ?? inv.epic.summary,
|
|
11164
|
+
site: inv.site,
|
|
11165
|
+
epic: inv.epic,
|
|
11166
|
+
home: o.home,
|
|
11167
|
+
...flag ? { flag } : {},
|
|
11168
|
+
repos,
|
|
11169
|
+
milestones,
|
|
11170
|
+
issues,
|
|
11171
|
+
stories: Object.fromEntries(inv.stories.map((s) => [s.key, { summary: s.summary, status: s.status, observed: observedState(s.status), observeOnly: true }])),
|
|
11172
|
+
statuses,
|
|
11173
|
+
unmapped,
|
|
11174
|
+
decided,
|
|
11175
|
+
gone: goneRecords(o.previous, issues)
|
|
11176
|
+
};
|
|
11177
|
+
}
|
|
11178
|
+
function renderProposal(p) {
|
|
11179
|
+
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):"];
|
|
11180
|
+
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)})`);
|
|
11181
|
+
lines.push("", "Repositories:");
|
|
11182
|
+
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" : ""}`);
|
|
11183
|
+
lines.push("", "Observed statuses:");
|
|
11184
|
+
for (const s of p.statuses) lines.push(` ${s.name} \u2192 ${s.observed}: ${s.count}`);
|
|
11185
|
+
const manual = Object.entries(p.issues).filter(([, i]) => i.kind === "manual").map(([k]) => k);
|
|
11186
|
+
if (manual.length) lines.push("", `Need a person: ${manual.join(", ")}`);
|
|
11187
|
+
if (p.decided.length) lines.push("", `Decisions applied from initiative.md: ${p.decided.join(", ")}`);
|
|
11188
|
+
lines.push("", p.unmapped.length ? `Need a decision (${p.unmapped.length}):` : "Nothing unmapped.");
|
|
11189
|
+
for (const u of p.unmapped) lines.push(` ${u.key}: ${u.reason}`);
|
|
11190
|
+
return lines;
|
|
11191
|
+
}
|
|
11192
|
+
function diffObserved(previous, p) {
|
|
11193
|
+
const prev = (previous ?? {}).issues ?? {};
|
|
11194
|
+
const diff = { added: [], removed: [], changed: [] };
|
|
11195
|
+
for (const key of Object.keys(p.issues)) {
|
|
11196
|
+
const was = prev[key];
|
|
11197
|
+
if (!was) {
|
|
11198
|
+
diff.added.push(key);
|
|
11199
|
+
continue;
|
|
11200
|
+
}
|
|
11201
|
+
const now = p.issues[key];
|
|
11202
|
+
const what = ["summary", "status", "repo", "milestone", "kind"].filter((f) => (was[f] ?? void 0) !== (now[f] ?? void 0));
|
|
11203
|
+
if (what.length) diff.changed.push({ key, what: what.map((f) => `${f}: ${String(was[f] ?? "-")} \u2192 ${String(now[f] ?? "-")}`) });
|
|
11204
|
+
}
|
|
11205
|
+
for (const key of Object.keys(prev)) if (!p.issues[key]) diff.removed.push(key);
|
|
11206
|
+
return diff;
|
|
11207
|
+
}
|
|
11208
|
+
function renderDiff(d) {
|
|
11209
|
+
if (!d.added.length && !d.removed.length && !d.changed.length) return ["Since the last run: no changes."];
|
|
11210
|
+
const lines = ["Since the last run:"];
|
|
11211
|
+
if (d.added.length) lines.push(` new: ${d.added.join(", ")}`);
|
|
11212
|
+
if (d.removed.length) lines.push(` gone from the epic: ${d.removed.join(", ")} (kept under "gone" in sync.json)`);
|
|
11213
|
+
for (const c of d.changed) lines.push(` ${c.key}: ${c.what.join("; ")}`);
|
|
11214
|
+
return lines;
|
|
11215
|
+
}
|
|
11216
|
+
function adapterText(p) {
|
|
11217
|
+
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();
|
|
11218
|
+
return `---
|
|
11219
|
+
${fm}
|
|
11220
|
+
---
|
|
11221
|
+
# Adapter: ${p.title}
|
|
11222
|
+
|
|
11223
|
+
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.
|
|
11224
|
+
|
|
11225
|
+
## Source
|
|
11226
|
+
|
|
11227
|
+
- Tracker: https://${p.site}/browse/${p.epic.key}
|
|
11228
|
+
- Initiative: \`${INITIATIVES_DIR}/${p.id}/\`; observed records: \`${INITIATIVES_DIR}/${p.id}/sync.json\`.
|
|
11229
|
+
- Every tracker record here is **observe-only**. A tracker status never sets a lead status or marks a task done. Only \`finish\` does.
|
|
11230
|
+
|
|
11231
|
+
## Reading rules
|
|
11232
|
+
|
|
11233
|
+
- 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.
|
|
11234
|
+
- 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".
|
|
11235
|
+
- 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.
|
|
11236
|
+
- Kinds: "QA stage N" is \`qa\`; a title with "(person)" is \`manual\` and needs a person.
|
|
11237
|
+
- 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).
|
|
11238
|
+
|
|
11239
|
+
## Repositories
|
|
11240
|
+
|
|
11241
|
+
Home: ${p.home}. Other repositories are references: named, not installed.
|
|
11242
|
+
|
|
11243
|
+
${p.repos.map((r) => `- ${r.name} (${r.role})`).join("\n")}
|
|
11244
|
+
`;
|
|
11245
|
+
}
|
|
11246
|
+
function initiativeText(p) {
|
|
11247
|
+
const fm = (0, import_yaml4.stringify)({
|
|
11248
|
+
id: p.id,
|
|
11249
|
+
title: p.title,
|
|
11250
|
+
epic: p.epic.key,
|
|
11251
|
+
site: p.site,
|
|
11252
|
+
...p.flag ? { flag: p.flag } : {},
|
|
11253
|
+
adapter: p.id,
|
|
11254
|
+
repos: p.repos.map((r) => ({ name: r.name, role: r.role }))
|
|
11255
|
+
}).trimEnd();
|
|
11256
|
+
return `---
|
|
11257
|
+
${fm}
|
|
11258
|
+
---
|
|
11259
|
+
# ${p.title}
|
|
11260
|
+
|
|
11261
|
+
Adopted from ${p.epic.key}. Milestones and observed records are in \`one-pager.md\` and \`sync.json\`.
|
|
11262
|
+
|
|
11263
|
+
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\`.
|
|
11264
|
+
`;
|
|
11265
|
+
}
|
|
11266
|
+
function onePagerText(p) {
|
|
11267
|
+
const fm = (0, import_yaml4.stringify)({
|
|
11268
|
+
milestones: p.milestones.map((m, i) => ({ id: m.id, title: m.title, ...m.shows ? { shows: m.shows } : {}, status: i === 0 ? "current" : "next" }))
|
|
11269
|
+
}).trimEnd();
|
|
11270
|
+
return `---
|
|
11271
|
+
${fm}
|
|
11272
|
+
---
|
|
11273
|
+
# ${p.title} \u2014 One Pager
|
|
11274
|
+
|
|
11275
|
+
Human text goes here. Milestone status is lead's own; tracker statuses are in \`sync.json\`.
|
|
11276
|
+
`;
|
|
11277
|
+
}
|
|
11278
|
+
function syncText(p) {
|
|
11279
|
+
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)}
|
|
11280
|
+
`;
|
|
11281
|
+
}
|
|
11282
|
+
function writeProposal(root, p, force = false) {
|
|
11283
|
+
const log = [];
|
|
11284
|
+
const put = (rel, text, regenerate) => {
|
|
11285
|
+
const abs = join30(root, rel);
|
|
11286
|
+
if (existsSync28(abs)) {
|
|
11287
|
+
const prev = readFileSync25(abs, "utf8");
|
|
11288
|
+
if (prev === text) return void log.push(`unchanged ${rel}`);
|
|
11289
|
+
if (!regenerate && !force) return void log.push(`kept ${rel}: it already exists and differs; --force replaces it`);
|
|
11290
|
+
}
|
|
11291
|
+
mkdirSync13(dirname5(abs), { recursive: true });
|
|
11292
|
+
writeFileSync14(abs, text);
|
|
11293
|
+
log.push(`wrote ${rel}`);
|
|
11294
|
+
};
|
|
11295
|
+
const dir = `${INITIATIVES_DIR}/${p.id}`;
|
|
11296
|
+
put(`${dir}/initiative.md`, initiativeText(p), false);
|
|
11297
|
+
put(`${dir}/one-pager.md`, onePagerText(p), false);
|
|
11298
|
+
put(`.lead/adapters/${p.id}/SKILL.md`, adapterText(p), false);
|
|
11299
|
+
put(`${dir}/sync.json`, syncText(p), true);
|
|
11300
|
+
return log;
|
|
11301
|
+
}
|
|
11302
|
+
|
|
10538
11303
|
// src/score.ts
|
|
10539
|
-
import { existsSync as
|
|
10540
|
-
import { join as
|
|
11304
|
+
import { existsSync as existsSync29, readdirSync as readdirSync15, readFileSync as readFileSync26 } from "node:fs";
|
|
11305
|
+
import { join as join31, relative as relative13 } from "node:path";
|
|
10541
11306
|
function rubrics(root, kit) {
|
|
10542
11307
|
const dirs = [
|
|
10543
|
-
|
|
10544
|
-
|
|
10545
|
-
|
|
10546
|
-
|
|
11308
|
+
join31(kit, "skills/lead/scorers"),
|
|
11309
|
+
join31(root, ".claude/skills/lead/scorers"),
|
|
11310
|
+
join31(root, ".agents/skills/lead/scorers"),
|
|
11311
|
+
join31(root, ".lead/local/scorers")
|
|
10547
11312
|
];
|
|
10548
11313
|
const all = /* @__PURE__ */ new Map();
|
|
10549
|
-
for (const dir of dirs.filter(
|
|
10550
|
-
for (const name of
|
|
10551
|
-
const file =
|
|
10552
|
-
if (
|
|
11314
|
+
for (const dir of dirs.filter(existsSync29)) {
|
|
11315
|
+
for (const name of readdirSync15(dir).sort()) {
|
|
11316
|
+
const file = join31(dir, name, "scorer.md");
|
|
11317
|
+
if (existsSync29(file)) all.set(name, file);
|
|
10553
11318
|
}
|
|
10554
11319
|
}
|
|
10555
|
-
return [...all].map(([
|
|
10556
|
-
const text =
|
|
11320
|
+
return [...all].map(([id2, file]) => {
|
|
11321
|
+
const text = readFileSync26(file, "utf8");
|
|
10557
11322
|
const { parsed } = parseFrontmatter(text, file);
|
|
10558
11323
|
const data = parsed?.data;
|
|
10559
|
-
if (!data || !/^[a-z][a-z0-9_-]*$/.test(
|
|
11324
|
+
if (!data || !/^[a-z][a-z0-9_-]*$/.test(id2) || data.id !== id2 || 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)) {
|
|
10560
11325
|
throw new Error(`invalid scorer metadata: ${file}`);
|
|
10561
11326
|
}
|
|
10562
11327
|
const classifications = Object.fromEntries([...parsed.body.matchAll(/^\|\s*([a-z][a-z0-9_]*)\s*\|\s*(-?\d+(?:\.\d+)?)\s*\|/gm)].map((m) => [m[1], Number(m[2])]));
|
|
10563
11328
|
if (!Object.keys(classifications).length) throw new Error(`no classifications: ${file}`);
|
|
10564
11329
|
return {
|
|
10565
|
-
id,
|
|
11330
|
+
id: id2,
|
|
10566
11331
|
file,
|
|
10567
11332
|
text,
|
|
10568
11333
|
version: data.version,
|
|
@@ -10587,7 +11352,7 @@ function scorePlan(ctx, kit, scorer, runId, limit = 10) {
|
|
|
10587
11352
|
const previous = readLog(ctx.root, "scores");
|
|
10588
11353
|
const records = runs(ctx.root).filter((run2) => run2.subject.project === ctx.project?.name);
|
|
10589
11354
|
if (runId && !records.some((run2) => run2.id === runId)) throw new Error(`unknown run in this project: ${runId}`);
|
|
10590
|
-
return records.reverse().filter((run2) => !runId || run2.id === runId).flatMap((run2) => candidates.filter((rubric) => applies(rubric, run2) && (runId || parseInt(digest([run2.id, rubric.id]).slice(0, 8), 16) / 2 ** 32 < rubric.rate) && !previous.some((row) => row.subject.run_id === run2.id && row.scorer === rubric.id && row.rubric_hash === rubric.hash)).map(({ id, version, file, text, hash: hash3 }) => ({ scorer:
|
|
11355
|
+
return records.reverse().filter((run2) => !runId || run2.id === runId).flatMap((run2) => candidates.filter((rubric) => applies(rubric, run2) && (runId || parseInt(digest([run2.id, rubric.id]).slice(0, 8), 16) / 2 ** 32 < rubric.rate) && !previous.some((row) => row.subject.run_id === run2.id && row.scorer === rubric.id && row.rubric_hash === rubric.hash)).map(({ id: id2, version, file, text, hash: hash3 }) => ({ scorer: id2, version, hash: hash3, file: relative13(ctx.root, file), rubric: text, run: run2 }))).slice(0, limit);
|
|
10591
11356
|
}
|
|
10592
11357
|
function recordScore(ctx, kit, scorer, runId, input) {
|
|
10593
11358
|
const rubric = rubrics(ctx.root, kit).find((r) => r.id === scorer);
|
|
@@ -10672,6 +11437,8 @@ Usage: node .lead/lead.mjs <command> [options]
|
|
|
10672
11437
|
spec [--confirm S | --reopen S] assemble work/spec.md from work/spec/; confirm or reopen a section
|
|
10673
11438
|
builder-settings <x> --source DIR [--deny P,Q] clean room: settings that keep the builder away from X
|
|
10674
11439
|
similarity --source DIR [paths...] fragments shared with the source of X (default: the project folder)
|
|
11440
|
+
inbox [--json] blockers, open questions and approvals waiting for a person
|
|
11441
|
+
docs [--json] [--key KEY] the project's documents, One Pager first, with their FuseBase notes
|
|
10675
11442
|
sync-plan JSON list of FuseBase/Jira writes needed to mirror work/
|
|
10676
11443
|
sync-plan --preview summarize recorded, pending, and uncertain writes
|
|
10677
11444
|
sync-one-pager [--input FILE] render the FuseBase One Pager or verify its read-back Markdown
|
|
@@ -10689,6 +11456,13 @@ Usage: node .lead/lead.mjs <command> [options]
|
|
|
10689
11456
|
how how to work with lead: the scheme, where a person is needed
|
|
10690
11457
|
enable | disable | enabled turn lead's hooks on or off for you in this repo (local, not in git)
|
|
10691
11458
|
mode [auto|approve|clear] how lead treats a step inside the plan (local, not in git)
|
|
11459
|
+
adopt --input FILE --id ID --home REPO [--flag KEY] [--write] [--force] [--json]
|
|
11460
|
+
adopt a tracker epic as an initiative: preview the mapping, then write the adapter and observed records
|
|
11461
|
+
initiative [id] [--json] initiatives in work/initiatives/ (read-only: milestones, repositories, tasks, adapter)
|
|
11462
|
+
initiative [id] --in REPO only the tasks and tracker records of one repository
|
|
11463
|
+
initiative check [id] check the tasks of initiatives: repos, references, waves
|
|
11464
|
+
initiative waves <id> [--write] compute (and with --write store) waves across the initiative's repositories
|
|
11465
|
+
adapters [name] [--json] project adapters in .lead/adapters/ (rules for reading this project's existing records)
|
|
10692
11466
|
delegate [id] [check] [--json] services that can take a task, and tasks already handed off
|
|
10693
11467
|
watch [start|stop|interval 15m|ack] local clock for delegated tasks (default 15m; --close on start)
|
|
10694
11468
|
improve print .lead/improve.md (stops, asks, what a kit change would avoid)
|
|
@@ -10720,16 +11494,16 @@ function parseArgs(argv) {
|
|
|
10720
11494
|
}
|
|
10721
11495
|
return { cmd: args.shift(), args, flags };
|
|
10722
11496
|
}
|
|
10723
|
-
var
|
|
11497
|
+
var str2 = (v) => typeof v === "string" ? v : void 0;
|
|
10724
11498
|
function watchLine(root) {
|
|
10725
11499
|
const w = readWatch(root);
|
|
10726
11500
|
if (!alive(w.pid)) return [];
|
|
10727
11501
|
return [`lead: watch is on, every ${w.interval}${w.due ? `, check due since ${w.due}: follow references/watch.md` : ""}.`];
|
|
10728
11502
|
}
|
|
10729
11503
|
function kitRoot() {
|
|
10730
|
-
return resolve3(
|
|
11504
|
+
return resolve3(dirname6(fileURLToPath(import.meta.url)), "..");
|
|
10731
11505
|
}
|
|
10732
|
-
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"]);
|
|
11506
|
+
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", "key"]);
|
|
10733
11507
|
function main(argv, out = (s) => console.log(s)) {
|
|
10734
11508
|
const { cmd, args, flags } = parseArgs(argv);
|
|
10735
11509
|
const unknown = Object.keys(flags).filter((f) => !KNOWN_FLAGS.has(f));
|
|
@@ -10739,24 +11513,24 @@ function main(argv, out = (s) => console.log(s)) {
|
|
|
10739
11513
|
}
|
|
10740
11514
|
const hook = cmd === "session-start" || cmd === "stop-check";
|
|
10741
11515
|
const hookInput = hook ? readStdinJson() : {};
|
|
10742
|
-
const origin = resolve3(hookInput.cwd ??
|
|
11516
|
+
const origin = resolve3(hookInput.cwd ?? str2(flags.cwd) ?? process.cwd());
|
|
10743
11517
|
let cwd = origin;
|
|
10744
|
-
let project =
|
|
10745
|
-
const session = hookInput.session_id ??
|
|
11518
|
+
let project = str2(flags.project);
|
|
11519
|
+
const session = hookInput.session_id ?? str2(flags.session) ?? process.env.LEAD_SESSION;
|
|
10746
11520
|
let scope;
|
|
10747
11521
|
let sharedKit;
|
|
10748
11522
|
if (cmd && !["help", "--help", "version", "how", "install"].includes(cmd)) {
|
|
10749
11523
|
try {
|
|
10750
11524
|
const runningKit = kitRoot();
|
|
10751
|
-
const deployed =
|
|
10752
|
-
const ws = deployed ? findWorkspace(
|
|
11525
|
+
const deployed = basename3(runningKit) === "workspace-kit" && basename3(dirname6(runningKit)) === ".lead";
|
|
11526
|
+
const ws = deployed ? findWorkspace(dirname6(dirname6(runningKit))) : findWorkspace(origin);
|
|
10753
11527
|
if (deployed && !ws) throw new Error("the shared workspace catalog is missing");
|
|
10754
11528
|
if (ws) {
|
|
10755
|
-
const path =
|
|
10756
|
-
if (path === ".." || path.startsWith(".." +
|
|
10757
|
-
sharedKit =
|
|
11529
|
+
const path = relative14(ws.root, realpathSync6(origin));
|
|
11530
|
+
if (path === ".." || path.startsWith(".." + sep5)) throw new Error("the command directory is outside this workspace");
|
|
11531
|
+
sharedKit = join32(ws.root, RUNTIME);
|
|
10758
11532
|
}
|
|
10759
|
-
if (flags.repo && (!ws || !
|
|
11533
|
+
if (flags.repo && (!ws || !str2(flags.repo))) throw new Error("--repo requires a workspace and repository name");
|
|
10760
11534
|
if (cmd === "workspace") {
|
|
10761
11535
|
if (!ws) throw new Error("no workspace catalog (.lead/workspace.yml)");
|
|
10762
11536
|
if (args[0] === "overview") {
|
|
@@ -10797,34 +11571,34 @@ ${entry.source}:${entry.line}
|
|
|
10797
11571
|
}
|
|
10798
11572
|
if (args[0] === "attach" && args[1]) {
|
|
10799
11573
|
const target = routeScope(ws, ws.root, void 0, args[1]).root;
|
|
10800
|
-
if (
|
|
11574
|
+
if (existsSync30(join32(target, ".lead/lead.mjs")) && !isPortableLauncher(target)) throw new Error("a lead entry point already exists; review and migrate it before attaching");
|
|
10801
11575
|
writeEntrypoints(target);
|
|
10802
11576
|
for (const line of [...ensureGitIgnore(target), ...ensureClaudeSettings(target), ...ensureCodexHooks(target)]) out(line);
|
|
10803
11577
|
out(`attached ${args[1]} to the shared lead workspace`);
|
|
10804
11578
|
return 0;
|
|
10805
11579
|
}
|
|
10806
11580
|
if (args[0] === "deploy") {
|
|
10807
|
-
deployWorkspace(ws,
|
|
11581
|
+
deployWorkspace(ws, str2(flags.from) ? resolve3(origin, str2(flags.from)) : kitRoot());
|
|
10808
11582
|
out(`workspace lead deployed in ${ws.root}`);
|
|
10809
11583
|
return 0;
|
|
10810
11584
|
}
|
|
10811
11585
|
throw new Error("usage: workspace overview | improve | use <repo> --session ID [--project NAME] | attach <repo> | deploy [--from PATH]");
|
|
10812
11586
|
}
|
|
10813
|
-
if (ws && cmd === "update" && (origin === ws.root || routeScope(ws, origin, session,
|
|
11587
|
+
if (ws && cmd === "update" && (origin === ws.root || routeScope(ws, origin, session, str2(flags.repo), project))) {
|
|
10814
11588
|
const deploy = (source) => {
|
|
10815
11589
|
deployWorkspace(ws, source);
|
|
10816
11590
|
out(`updated the shared workspace kit in ${ws.root}`);
|
|
10817
11591
|
return 0;
|
|
10818
11592
|
};
|
|
10819
|
-
if (flags.from && !
|
|
10820
|
-
return
|
|
11593
|
+
if (flags.from && !str2(flags.from)) throw new Error("--from requires a local workspace-capable kit");
|
|
11594
|
+
return str2(flags.from) ? deploy(resolve3(origin, str2(flags.from))) : withRegistryKit(ws.root, out, deploy);
|
|
10821
11595
|
}
|
|
10822
11596
|
if (ws) {
|
|
10823
|
-
scope = routeScope(ws, origin, session,
|
|
11597
|
+
scope = routeScope(ws, origin, session, str2(flags.repo), project);
|
|
10824
11598
|
if (scope) {
|
|
10825
11599
|
cwd = scope.cwd;
|
|
10826
11600
|
project = scope.project;
|
|
10827
|
-
} else if (repoRoot(origin) === ws.root || !
|
|
11601
|
+
} else if (repoRoot(origin) === ws.root || !existsSync30(join32(repoRoot(origin), ".git"))) {
|
|
10828
11602
|
if (cmd === "session-start" && session) {
|
|
10829
11603
|
out(JSON.stringify({ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: `lead workspace session: ${session}. Pass --session ${session} to lead commands.` } }));
|
|
10830
11604
|
return 0;
|
|
@@ -10896,7 +11670,7 @@ ${entry.source}:${entry.line}
|
|
|
10896
11670
|
out(log.length ? log.join("\n") : "waves already up to date");
|
|
10897
11671
|
} else {
|
|
10898
11672
|
const groups = /* @__PURE__ */ new Map();
|
|
10899
|
-
for (const [
|
|
11673
|
+
for (const [id2, w] of waves) groups.set(w, [...groups.get(w) ?? [], id2]);
|
|
10900
11674
|
for (const w of [...groups.keys()].sort((a, b) => a - b)) out(`wave ${w}: ${groups.get(w).sort().join(" \u2016 ")}`);
|
|
10901
11675
|
}
|
|
10902
11676
|
return 0;
|
|
@@ -10912,30 +11686,30 @@ ${entry.source}:${entry.line}
|
|
|
10912
11686
|
case "review":
|
|
10913
11687
|
case "finish":
|
|
10914
11688
|
case "block": {
|
|
10915
|
-
const
|
|
10916
|
-
if (!
|
|
11689
|
+
const id2 = args[0];
|
|
11690
|
+
if (!id2 || !session && !(cmd === "finish" && flags.merged)) {
|
|
10917
11691
|
out(`usage: ${cmd} <task> --session ID (or set LEAD_SESSION)`);
|
|
10918
11692
|
return 2;
|
|
10919
11693
|
}
|
|
10920
11694
|
const ctx = loadContext(cwd, project);
|
|
10921
|
-
const task = ctx.tasks.find((t) => t.id ===
|
|
11695
|
+
const task = ctx.tasks.find((t) => t.id === id2);
|
|
10922
11696
|
if (!task) {
|
|
10923
|
-
out(`no task ${
|
|
11697
|
+
out(`no task ${id2}${ctx.project ? "" : " (no project selected: --project NAME)"}`);
|
|
10924
11698
|
return 1;
|
|
10925
11699
|
}
|
|
10926
11700
|
let r;
|
|
10927
|
-
if (cmd === "start") r = startTask(ctx, task, { session, tool:
|
|
10928
|
-
else if (cmd === "record-checks") r = recordChecks(ctx, task, { session, only:
|
|
11701
|
+
if (cmd === "start") r = startTask(ctx, task, { session, tool: str2(flags.tool), force: !!flags.force });
|
|
11702
|
+
else if (cmd === "record-checks") r = recordChecks(ctx, task, { session, only: str2(flags.only)?.split(",") });
|
|
10929
11703
|
else if (cmd === "review") {
|
|
10930
|
-
const verdict =
|
|
11704
|
+
const verdict = str2(flags.verdict);
|
|
10931
11705
|
if (verdict !== "pass" && verdict !== "fail") {
|
|
10932
11706
|
out("--verdict pass|fail is required");
|
|
10933
11707
|
return 2;
|
|
10934
11708
|
}
|
|
10935
|
-
r = reviewTask(ctx, task, { session, verdict, notes:
|
|
11709
|
+
r = reviewTask(ctx, task, { session, verdict, notes: str2(flags.notes) });
|
|
10936
11710
|
} else if (cmd === "finish") r = finishTask(ctx, task, { session: session ?? "", merged: !!flags.merged, isMerged: gitMergedChecker(ctx.root) });
|
|
10937
11711
|
else {
|
|
10938
|
-
const question =
|
|
11712
|
+
const question = str2(flags.question);
|
|
10939
11713
|
if (!question) {
|
|
10940
11714
|
out("--question TEXT is required");
|
|
10941
11715
|
return 2;
|
|
@@ -10948,10 +11722,10 @@ ${entry.source}:${entry.line}
|
|
|
10948
11722
|
case "enable":
|
|
10949
11723
|
case "disable": {
|
|
10950
11724
|
const root = repoRoot(cwd);
|
|
10951
|
-
|
|
10952
|
-
if (cmd === "enable")
|
|
11725
|
+
mkdirSync14(join32(root, ".lead"), { recursive: true });
|
|
11726
|
+
if (cmd === "enable") writeFileSync15(join32(root, ENABLED_PATH), `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
10953
11727
|
`);
|
|
10954
|
-
else rmSync6(
|
|
11728
|
+
else rmSync6(join32(root, ENABLED_PATH), { force: true });
|
|
10955
11729
|
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");
|
|
10956
11730
|
return 0;
|
|
10957
11731
|
}
|
|
@@ -10991,10 +11765,15 @@ ${entry.source}:${entry.line}
|
|
|
10991
11765
|
return 0;
|
|
10992
11766
|
}
|
|
10993
11767
|
case "session-start": {
|
|
10994
|
-
|
|
11768
|
+
const pointer = sharedKit && scope ? [`lead: this project runs with lead, no /lead needed. Launcher: ${join32(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.`] : [];
|
|
11769
|
+
if (!isEnabled(repoRoot(cwd))) {
|
|
11770
|
+
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") } }));
|
|
11771
|
+
return 0;
|
|
11772
|
+
}
|
|
10995
11773
|
const ctx = loadContext(cwd, project);
|
|
10996
11774
|
const s = status(ctx, { session });
|
|
10997
11775
|
const lines = [
|
|
11776
|
+
...pointer,
|
|
10998
11777
|
`lead: this session id is ${session ?? "unknown"}; pass --session ${session ?? "<id>"} to lead.mjs commands.`,
|
|
10999
11778
|
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}.`,
|
|
11000
11779
|
...watchLine(ctx.root)
|
|
@@ -11009,26 +11788,26 @@ ${entry.source}:${entry.line}
|
|
|
11009
11788
|
return 1;
|
|
11010
11789
|
}
|
|
11011
11790
|
try {
|
|
11012
|
-
if (
|
|
11013
|
-
if (
|
|
11791
|
+
if (str2(flags.confirm)) out(setSectionStatus(ctx.root, ctx.project.workDir, str2(flags.confirm), "confirmed", ctx.project.name));
|
|
11792
|
+
if (str2(flags.reopen)) out(setSectionStatus(ctx.root, ctx.project.workDir, str2(flags.reopen), "draft"));
|
|
11014
11793
|
} catch (e) {
|
|
11015
11794
|
out(e.message);
|
|
11016
11795
|
return 1;
|
|
11017
11796
|
}
|
|
11018
|
-
const title = ctx.project.name === "." ?
|
|
11797
|
+
const title = ctx.project.name === "." ? basename3(ctx.root) : ctx.project.name;
|
|
11019
11798
|
const r = assembleSpec(ctx.root, ctx.project.workDir, title);
|
|
11020
11799
|
out(r.changed ? "spec.md updated" : "spec.md is up to date");
|
|
11021
11800
|
return 0;
|
|
11022
11801
|
}
|
|
11023
11802
|
case "builder-settings": {
|
|
11024
11803
|
const name = args[0];
|
|
11025
|
-
const source =
|
|
11804
|
+
const source = str2(flags.source);
|
|
11026
11805
|
if (!name || !source) {
|
|
11027
11806
|
out("usage: builder-settings <x> --source DIR");
|
|
11028
11807
|
return 2;
|
|
11029
11808
|
}
|
|
11030
11809
|
try {
|
|
11031
|
-
const r = builderSettings(repoRoot(cwd), name, source,
|
|
11810
|
+
const r = builderSettings(repoRoot(cwd), name, source, str2(flags.deny)?.split(",") ?? []);
|
|
11032
11811
|
out(`wrote ${r.path}
|
|
11033
11812
|
start the builder with: ${r.launch}`);
|
|
11034
11813
|
return 0;
|
|
@@ -11038,13 +11817,13 @@ start the builder with: ${r.launch}`);
|
|
|
11038
11817
|
}
|
|
11039
11818
|
}
|
|
11040
11819
|
case "similarity": {
|
|
11041
|
-
const source =
|
|
11820
|
+
const source = str2(flags.source);
|
|
11042
11821
|
if (!source) {
|
|
11043
11822
|
out("usage: similarity --source DIR [paths...]");
|
|
11044
11823
|
return 2;
|
|
11045
11824
|
}
|
|
11046
11825
|
const ctx = loadContext(cwd, project);
|
|
11047
|
-
const targets = args.length ? args.map((a) => resolve3(cwd, a)) : [
|
|
11826
|
+
const targets = args.length ? args.map((a) => resolve3(cwd, a)) : [join32(ctx.root, ctx.project?.path ?? ".")];
|
|
11048
11827
|
const matches = similarity(resolve3(cwd, source), targets, ctx.root);
|
|
11049
11828
|
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}`);
|
|
11050
11829
|
out(`${matches.length} shared fragments`);
|
|
@@ -11057,9 +11836,9 @@ start the builder with: ${r.launch}`);
|
|
|
11057
11836
|
out(markdown.trimEnd());
|
|
11058
11837
|
return 0;
|
|
11059
11838
|
}
|
|
11060
|
-
const file =
|
|
11839
|
+
const file = str2(flags.input);
|
|
11061
11840
|
if (!file) throw new Error("--input FILE must point to the read-back Markdown");
|
|
11062
|
-
const mismatches = verifyOnePager(markdown,
|
|
11841
|
+
const mismatches = verifyOnePager(markdown, readFileSync27(resolve3(cwd, file), "utf8"));
|
|
11063
11842
|
out(mismatches.length ? mismatches.join("\n") : "One Pager read-back matches the roadmap, triage, widgets and links");
|
|
11064
11843
|
return mismatches.length ? 1 : 0;
|
|
11065
11844
|
} catch (e) {
|
|
@@ -11067,6 +11846,39 @@ start the builder with: ${r.launch}`);
|
|
|
11067
11846
|
return 1;
|
|
11068
11847
|
}
|
|
11069
11848
|
}
|
|
11849
|
+
case "inbox": {
|
|
11850
|
+
const ctx = loadContext(cwd, project);
|
|
11851
|
+
if (!ctx.project) {
|
|
11852
|
+
out("no project selected: --project NAME");
|
|
11853
|
+
return 1;
|
|
11854
|
+
}
|
|
11855
|
+
const items = inbox(ctx);
|
|
11856
|
+
if (flags.json) out(JSON.stringify({ project: ctx.project.name, items }, null, 2));
|
|
11857
|
+
else if (!items.length) out("Inbox is empty.");
|
|
11858
|
+
else for (const i of items) out(`${i.kind} \xB7 ${i.title}${i.detail ? ` \u2014 ${i.detail}` : ""} \xB7 ${i.source.path}`);
|
|
11859
|
+
return 0;
|
|
11860
|
+
}
|
|
11861
|
+
case "docs": {
|
|
11862
|
+
const ctx = loadContext(cwd, project);
|
|
11863
|
+
if (!ctx.project) {
|
|
11864
|
+
out("no project selected: --project NAME");
|
|
11865
|
+
return 1;
|
|
11866
|
+
}
|
|
11867
|
+
const key = str2(flags.key);
|
|
11868
|
+
if (key) {
|
|
11869
|
+
const text = docText(ctx, key);
|
|
11870
|
+
if (text === void 0) {
|
|
11871
|
+
out(`no document ${key}`);
|
|
11872
|
+
return 1;
|
|
11873
|
+
}
|
|
11874
|
+
out(text);
|
|
11875
|
+
return 0;
|
|
11876
|
+
}
|
|
11877
|
+
const list = docIndex(ctx);
|
|
11878
|
+
if (flags.json) out(JSON.stringify({ project: ctx.project.name, documents: list }, null, 2));
|
|
11879
|
+
else for (const d of list) out(`${d.group} \xB7 ${d.title} \xB7 ${d.path}${d.url ? ` \xB7 ${d.url}` : ""}`);
|
|
11880
|
+
return 0;
|
|
11881
|
+
}
|
|
11070
11882
|
case "sync-plan": {
|
|
11071
11883
|
const ctx = loadContext(cwd, project);
|
|
11072
11884
|
if (!ctx.project) {
|
|
@@ -11102,8 +11914,8 @@ start the builder with: ${r.launch}`);
|
|
|
11102
11914
|
return 0;
|
|
11103
11915
|
}
|
|
11104
11916
|
const actions = syncPlan(ctx).map((a, i) => ({ id: i + 1, ...a }));
|
|
11105
|
-
|
|
11106
|
-
|
|
11917
|
+
mkdirSync14(join32(ctx.root, ".lead/logs"), { recursive: true });
|
|
11918
|
+
writeFileSync15(syncPlanPath(ctx.root, ctx.project.name), JSON.stringify({ project: ctx.project.name, actions }, null, 2));
|
|
11107
11919
|
out(JSON.stringify(actions, null, 2));
|
|
11108
11920
|
return 0;
|
|
11109
11921
|
}
|
|
@@ -11113,7 +11925,7 @@ start the builder with: ${r.launch}`);
|
|
|
11113
11925
|
try {
|
|
11114
11926
|
if (!ctx.project) throw new Error("no project selected: --project NAME");
|
|
11115
11927
|
const journal = readSyncJournal(ctx.root, ctx.project.name);
|
|
11116
|
-
const ref =
|
|
11928
|
+
const ref = str2(flags.action);
|
|
11117
11929
|
if (cmd === "sync-attempt" && flags.discard) {
|
|
11118
11930
|
if (!ref || !Object.hasOwn(journal, ref) || journal[ref]?.done !== false) throw new Error("an uncertain action reference is required");
|
|
11119
11931
|
delete journal[ref];
|
|
@@ -11121,14 +11933,14 @@ start the builder with: ${r.launch}`);
|
|
|
11121
11933
|
out(`cleared verified no-effect action ${ref}`);
|
|
11122
11934
|
return 0;
|
|
11123
11935
|
}
|
|
11124
|
-
const action = cmd === "sync-record" && ref && !
|
|
11936
|
+
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)));
|
|
11125
11937
|
if (!action) throw new Error("action not found in the sync plan or journal");
|
|
11126
11938
|
const key = syncActionKey(action);
|
|
11127
11939
|
if (ref && ref !== key) throw new Error("saved action changed: refresh sync-plan");
|
|
11128
11940
|
if (cmd === "sync-attempt") {
|
|
11129
11941
|
if (!syncPlan(ctx).some((current) => syncActionKey(current) === key)) throw new Error("action is no longer in the current plan");
|
|
11130
11942
|
if (journal[key]?.done === false && !flags.retry) throw new Error("prior outcome is uncertain: check the remote result before retrying with --retry, or record the existing result");
|
|
11131
|
-
if (Object.entries(journal).some(([
|
|
11943
|
+
if (Object.entries(journal).some(([id2, entry]) => id2 !== key && !entry.done && entry.label === syncLabel(action))) {
|
|
11132
11944
|
throw new Error("an earlier action for this item has an uncertain outcome: reconcile it before proceeding");
|
|
11133
11945
|
}
|
|
11134
11946
|
journal[key] = { label: syncLabel(action), done: false, action };
|
|
@@ -11140,7 +11952,7 @@ start the builder with: ${r.launch}`);
|
|
|
11140
11952
|
out(`already recorded ${journal[key].label}`);
|
|
11141
11953
|
return 0;
|
|
11142
11954
|
}
|
|
11143
|
-
const result = JSON.parse(
|
|
11955
|
+
const result = JSON.parse(str2(flags.result) ?? "{}");
|
|
11144
11956
|
out(syncRecord(ctx, action, result));
|
|
11145
11957
|
journal[key] = { label: syncLabel(action), done: true, action };
|
|
11146
11958
|
writeSyncJournal(ctx.root, ctx.project.name, journal);
|
|
@@ -11156,9 +11968,9 @@ start the builder with: ${r.launch}`);
|
|
|
11156
11968
|
try {
|
|
11157
11969
|
if (!ctx.project) throw new Error("no project selected: --project NAME");
|
|
11158
11970
|
const input = () => {
|
|
11159
|
-
const file =
|
|
11971
|
+
const file = str2(flags.input);
|
|
11160
11972
|
if (!file) throw new Error("--input FILE is required");
|
|
11161
|
-
return JSON.parse(
|
|
11973
|
+
return JSON.parse(readFileSync27(resolve3(cwd, file), "utf8"));
|
|
11162
11974
|
};
|
|
11163
11975
|
if (cmd === "qa-record") {
|
|
11164
11976
|
const task = ctx.tasks.find((t) => t.id === args[0]);
|
|
@@ -11166,18 +11978,18 @@ start the builder with: ${r.launch}`);
|
|
|
11166
11978
|
out(JSON.stringify(recordQa(ctx, task, treeId(taskDir(ctx, task)), session, input()), null, 2));
|
|
11167
11979
|
return 0;
|
|
11168
11980
|
}
|
|
11169
|
-
const scorer =
|
|
11170
|
-
const run2 =
|
|
11981
|
+
const scorer = str2(flags.scorer);
|
|
11982
|
+
const run2 = str2(flags.run);
|
|
11171
11983
|
if (args[0] === "record") {
|
|
11172
11984
|
if (!scorer || !run2) throw new Error("score record requires --scorer ID and --run ID");
|
|
11173
11985
|
out(JSON.stringify(recordScore(ctx, kitRoot(), scorer, run2, input()), null, 2));
|
|
11174
11986
|
} else if (args[0] === "analyze") {
|
|
11175
11987
|
out(JSON.stringify(analyzeScores(ctx), null, 2));
|
|
11176
11988
|
} else if (args[0] === "runs") {
|
|
11177
|
-
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));
|
|
11989
|
+
out(JSON.stringify(runs(ctx.root).filter((row) => row.subject.project === ctx.project?.name).map(({ id: id2, at, kind, subject }) => ({ id: id2, at, kind, subject })), null, 2));
|
|
11178
11990
|
} else {
|
|
11179
11991
|
if (args.length) throw new Error("usage: score [runs|record|analyze]");
|
|
11180
|
-
const limit = Number(
|
|
11992
|
+
const limit = Number(str2(flags.limit) ?? 10);
|
|
11181
11993
|
if (!Number.isSafeInteger(limit) || limit < 1) throw new Error("--limit must be a positive integer");
|
|
11182
11994
|
out(JSON.stringify(scorePlan(ctx, kitRoot(), scorer, run2, limit), null, 2));
|
|
11183
11995
|
}
|
|
@@ -11194,21 +12006,21 @@ start the builder with: ${r.launch}`);
|
|
|
11194
12006
|
}
|
|
11195
12007
|
case "claim":
|
|
11196
12008
|
case "release": {
|
|
11197
|
-
const
|
|
11198
|
-
if (!
|
|
12009
|
+
const id2 = args[0];
|
|
12010
|
+
if (!id2 || !session) {
|
|
11199
12011
|
out(`usage: ${cmd} <task> --session ID`);
|
|
11200
12012
|
return 2;
|
|
11201
12013
|
}
|
|
11202
12014
|
const ctx = loadContext(cwd, project);
|
|
11203
|
-
const task = ctx.tasks.find((t) => t.id ===
|
|
12015
|
+
const task = ctx.tasks.find((t) => t.id === id2);
|
|
11204
12016
|
if (!task) {
|
|
11205
|
-
out(`no task ${
|
|
12017
|
+
out(`no task ${id2}`);
|
|
11206
12018
|
return 1;
|
|
11207
12019
|
}
|
|
11208
12020
|
let r;
|
|
11209
|
-
if (cmd === "claim") r = claimTask(ctx.root, task, { session, tool:
|
|
12021
|
+
if (cmd === "claim") r = claimTask(ctx.root, task, { session, tool: str2(flags.tool), worktree: str2(flags.worktree) });
|
|
11210
12022
|
else {
|
|
11211
|
-
const st =
|
|
12023
|
+
const st = str2(flags.status);
|
|
11212
12024
|
if (st && !STATUSES.includes(st)) {
|
|
11213
12025
|
out(`status must be one of ${STATUSES.join(", ")}`);
|
|
11214
12026
|
return 2;
|
|
@@ -11227,8 +12039,8 @@ start the builder with: ${r.launch}`);
|
|
|
11227
12039
|
out(`usage: use <project>; projects: ${projects.map((p) => p.name).join(", ") || "none"}`);
|
|
11228
12040
|
return 2;
|
|
11229
12041
|
}
|
|
11230
|
-
|
|
11231
|
-
|
|
12042
|
+
mkdirSync14(join32(root, ".lead"), { recursive: true });
|
|
12043
|
+
writeFileSync15(join32(root, CURRENT_PATH), `${name}
|
|
11232
12044
|
`);
|
|
11233
12045
|
out(`current project: ${name}`);
|
|
11234
12046
|
return 0;
|
|
@@ -11258,13 +12070,13 @@ start the builder with: ${r.launch}`);
|
|
|
11258
12070
|
out("usage: install <repo>");
|
|
11259
12071
|
return 2;
|
|
11260
12072
|
}
|
|
11261
|
-
const log = install(kitRoot(),
|
|
12073
|
+
const log = install(kitRoot(), realpathSync6(target), fileURLToPath(import.meta.url), { keepModified: !!flags["keep-modified"] });
|
|
11262
12074
|
out(log.join("\n"));
|
|
11263
12075
|
return 0;
|
|
11264
12076
|
}
|
|
11265
12077
|
case "update": {
|
|
11266
12078
|
const root = repoRoot(cwd);
|
|
11267
|
-
const from =
|
|
12079
|
+
const from = str2(flags.from);
|
|
11268
12080
|
if (flags.from && !from) {
|
|
11269
12081
|
out("usage: update --from GIT_URL|PATH");
|
|
11270
12082
|
return 2;
|
|
@@ -11274,7 +12086,7 @@ start the builder with: ${r.launch}`);
|
|
|
11274
12086
|
const before = readLock(root)?.version ?? "none";
|
|
11275
12087
|
const r = spawnSync3(
|
|
11276
12088
|
process.execPath,
|
|
11277
|
-
[
|
|
12089
|
+
[join32(kit, "dist/lead.mjs"), "install", root, ...flags.force ? [] : ["--keep-modified"]],
|
|
11278
12090
|
{ cwd: root, encoding: "utf8" }
|
|
11279
12091
|
);
|
|
11280
12092
|
const output = `${r.stdout ?? ""}${r.stderr ?? ""}`.trim();
|
|
@@ -11288,8 +12100,8 @@ start the builder with: ${r.launch}`);
|
|
|
11288
12100
|
try {
|
|
11289
12101
|
if (!from) return withRegistryKit(root, out, applyKit);
|
|
11290
12102
|
const path = resolve3(cwd, from);
|
|
11291
|
-
if (
|
|
11292
|
-
tmp = mkdtempSync3(
|
|
12103
|
+
if (existsSync30(path)) return applyKit(path);
|
|
12104
|
+
tmp = mkdtempSync3(join32(tmpdir3(), "lead-kit-"));
|
|
11293
12105
|
execFileSync6("git", ["clone", "-q", "--depth", "1", "--", from, tmp], { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
11294
12106
|
return applyKit(tmp);
|
|
11295
12107
|
} catch (e) {
|
|
@@ -11302,17 +12114,147 @@ start the builder with: ${r.launch}`);
|
|
|
11302
12114
|
case "how":
|
|
11303
12115
|
out(TEMPLATES["how.md"].trim());
|
|
11304
12116
|
return 0;
|
|
12117
|
+
case "adopt": {
|
|
12118
|
+
const root = repoRoot(cwd);
|
|
12119
|
+
const input = typeof flags.input === "string" ? flags.input : "";
|
|
12120
|
+
const id2 = typeof flags.id === "string" ? flags.id : "";
|
|
12121
|
+
const home = typeof flags.home === "string" ? flags.home : "";
|
|
12122
|
+
if (!input || !id2 || !home) {
|
|
12123
|
+
out("usage: adopt --input FILE --id ID --home REPO [--flag KEY] [--title TEXT] [--write] [--force]");
|
|
12124
|
+
return 2;
|
|
12125
|
+
}
|
|
12126
|
+
if (!/^[a-z][a-z0-9-]*$/.test(id2) || id2 === "check" || id2 === "waves" || !/^[a-z][a-z0-9-]*$/.test(home)) {
|
|
12127
|
+
out('--id and --home must look like "private-space" (id cannot be check or waves)');
|
|
12128
|
+
return 2;
|
|
12129
|
+
}
|
|
12130
|
+
let raw;
|
|
12131
|
+
try {
|
|
12132
|
+
raw = JSON.parse(readFileSync27(resolve3(cwd, input), "utf8"));
|
|
12133
|
+
} catch (error) {
|
|
12134
|
+
out(`cannot read ${input}: ${error.message}`);
|
|
12135
|
+
return 2;
|
|
12136
|
+
}
|
|
12137
|
+
const { inventory, errors } = validateInventory(raw);
|
|
12138
|
+
if (!inventory) {
|
|
12139
|
+
for (const e of errors) out(`error ${e}`);
|
|
12140
|
+
return 2;
|
|
12141
|
+
}
|
|
12142
|
+
const syncFile = join32(root, "work/initiatives", id2, "sync.json");
|
|
12143
|
+
let previous;
|
|
12144
|
+
try {
|
|
12145
|
+
previous = JSON.parse(readFileSync27(syncFile, "utf8"));
|
|
12146
|
+
} catch {
|
|
12147
|
+
previous = void 0;
|
|
12148
|
+
}
|
|
12149
|
+
const existing = loadInitiatives(root).initiatives.find((i) => i.id === id2);
|
|
12150
|
+
const proposal = propose(inventory, { id: id2, home, previous, ...existing ? { overrides: existing.map } : {}, ...typeof flags.title === "string" ? { title: flags.title } : {}, ...typeof flags.flag === "string" ? { flag: flags.flag } : {} });
|
|
12151
|
+
const diff = previous ? diffObserved(previous, proposal) : void 0;
|
|
12152
|
+
if (flags.json) out(JSON.stringify({ ...proposal, ...diff ? { diff } : {} }, null, 2));
|
|
12153
|
+
else {
|
|
12154
|
+
for (const line of renderProposal(proposal)) out(line);
|
|
12155
|
+
if (diff) for (const line of ["", ...renderDiff(diff)]) out(line);
|
|
12156
|
+
}
|
|
12157
|
+
if (!flags.write) {
|
|
12158
|
+
out(flags.json ? "" : "\n(preview only; nothing written. Add --write after the person agrees.)");
|
|
12159
|
+
return 0;
|
|
12160
|
+
}
|
|
12161
|
+
for (const line of writeProposal(root, proposal, flags.force === true)) out(line);
|
|
12162
|
+
return 0;
|
|
12163
|
+
}
|
|
12164
|
+
case "initiative": {
|
|
12165
|
+
const root = repoRoot(cwd);
|
|
12166
|
+
const { initiatives, issues } = loadInitiatives(root);
|
|
12167
|
+
const errors = issues.filter((i) => i.level === "error");
|
|
12168
|
+
const sub = args[0] === "check" || args[0] === "waves" ? args[0] : void 0;
|
|
12169
|
+
const id2 = sub ? args[1] : args[0];
|
|
12170
|
+
if (sub === "check" || sub === "waves") {
|
|
12171
|
+
if (id2 && !initiatives.some((i) => i.id === id2)) {
|
|
12172
|
+
out(`no initiative "${id2}". Known: ${initiatives.map((i) => i.id).join(", ") || "none"}`);
|
|
12173
|
+
return 1;
|
|
12174
|
+
}
|
|
12175
|
+
if (sub === "waves" && !id2) {
|
|
12176
|
+
out("usage: initiative waves <id> [--write]");
|
|
12177
|
+
return 2;
|
|
12178
|
+
}
|
|
12179
|
+
const chosen = initiatives.filter((i) => !id2 || i.id === id2);
|
|
12180
|
+
if (sub === "waves") {
|
|
12181
|
+
const target = chosen[0];
|
|
12182
|
+
if (flags.write) for (const line of writeInitiativeWaves(root, target)) out(line);
|
|
12183
|
+
else {
|
|
12184
|
+
const o = initiativeOverview(root, target);
|
|
12185
|
+
for (const t of o.tasks) out(`${t.id} ${t.repo} ${t.wave ? `w${t.wave}` : "no wave"}`);
|
|
12186
|
+
out("(not written; add --write)");
|
|
12187
|
+
}
|
|
12188
|
+
return 0;
|
|
12189
|
+
}
|
|
12190
|
+
const ws = optionalWorkspace(root);
|
|
12191
|
+
const all = [...issues, ...chosen.flatMap((i) => checkInitiative(root, i, ws))];
|
|
12192
|
+
out(all.length ? formatIssues(all) : "initiatives: ok");
|
|
12193
|
+
return all.some((i) => i.level === "error") ? 1 : 0;
|
|
12194
|
+
}
|
|
12195
|
+
if (id2 && !initiatives.some((i) => i.id === id2)) {
|
|
12196
|
+
out(`no initiative "${id2}". Known: ${initiatives.map((i) => i.id).join(", ") || "none"}`);
|
|
12197
|
+
return 1;
|
|
12198
|
+
}
|
|
12199
|
+
if (typeof flags.in === "string") {
|
|
12200
|
+
const repo = flags.in;
|
|
12201
|
+
const one = initiatives.filter((i) => !id2 || i.id === id2);
|
|
12202
|
+
const rows = one.map((i) => {
|
|
12203
|
+
const o = initiativeOverview(root, i);
|
|
12204
|
+
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) };
|
|
12205
|
+
});
|
|
12206
|
+
if (flags.json) out(JSON.stringify({ repo, initiatives: rows }, null, 2));
|
|
12207
|
+
else {
|
|
12208
|
+
for (const r of rows) {
|
|
12209
|
+
out(`${r.id} \u2014 repository ${repo}${r.known ? "" : " (not listed in the initiative)"}`);
|
|
12210
|
+
for (const t of r.tasks) out(` task ${t.id} [${t.status}]${t.wave ? ` w${t.wave}` : ""} \u2014 ${t.title}`);
|
|
12211
|
+
for (const x of r.observed) out(` ${x.key} [${x.observed}] ${x.milestone}${x.repo !== repo ? ` (main: ${x.repo})` : ""} \u2014 ${x.summary}`);
|
|
12212
|
+
if (!r.tasks.length && !r.observed.length) out(" nothing for this repository");
|
|
12213
|
+
}
|
|
12214
|
+
}
|
|
12215
|
+
return errors.length ? 1 : 0;
|
|
12216
|
+
}
|
|
12217
|
+
const overview = initiatives.filter((i) => !id2 || i.id === id2).map((i) => initiativeOverview(root, i));
|
|
12218
|
+
if (flags.json) out(JSON.stringify({ initiatives: overview, issues }, null, 2));
|
|
12219
|
+
else {
|
|
12220
|
+
for (const o of overview) for (const line of renderInitiative(o)) out(line);
|
|
12221
|
+
if (!overview.length) out("no initiatives (work/initiatives/<id>/initiative.md)");
|
|
12222
|
+
for (const i of issues) out(`${i.level} ${i.file}: ${i.message}`);
|
|
12223
|
+
}
|
|
12224
|
+
return errors.length ? 1 : 0;
|
|
12225
|
+
}
|
|
12226
|
+
case "adapters": {
|
|
12227
|
+
const root = repoRoot(cwd);
|
|
12228
|
+
const { adapters, issues } = listAdapters(root);
|
|
12229
|
+
const name = args[0];
|
|
12230
|
+
if (name) {
|
|
12231
|
+
const found = adapters.find((a) => a.id === name);
|
|
12232
|
+
if (!found) {
|
|
12233
|
+
out(`no adapter "${name}". Known: ${adapters.map((a) => a.id).join(", ") || "none"}`);
|
|
12234
|
+
return 1;
|
|
12235
|
+
}
|
|
12236
|
+
out(flags.json ? JSON.stringify({ ...found, text: readFileSync27(join32(root, found.file), "utf8") }, null, 2) : readFileSync27(join32(root, found.file), "utf8").trimEnd());
|
|
12237
|
+
return 0;
|
|
12238
|
+
}
|
|
12239
|
+
if (flags.json) out(JSON.stringify({ adapters, issues }, null, 2));
|
|
12240
|
+
else {
|
|
12241
|
+
for (const a of adapters) out(`${a.id} \u2014 ${a.appliesTo || a.title} (${a.file})`);
|
|
12242
|
+
if (!adapters.length) out("no adapters (.lead/adapters/<id>/SKILL.md)");
|
|
12243
|
+
for (const i of issues) out(`warn ${i}`);
|
|
12244
|
+
}
|
|
12245
|
+
return 0;
|
|
12246
|
+
}
|
|
11305
12247
|
case "delegate": {
|
|
11306
12248
|
const ctx = loadContext(cwd, project);
|
|
11307
12249
|
const services = listDelegates(ctx.root, kitRoot());
|
|
11308
|
-
const
|
|
12250
|
+
const id2 = args[0] === "check" ? void 0 : args[0];
|
|
11309
12251
|
const checking = args.includes("check");
|
|
11310
|
-
if (
|
|
11311
|
-
out(`no delegate "${
|
|
12252
|
+
if (id2 && !services.some((d) => d.id === id2)) {
|
|
12253
|
+
out(`no delegate "${id2}". Known: ${services.map((d) => d.id).join(", ") || "none"}`);
|
|
11312
12254
|
return 1;
|
|
11313
12255
|
}
|
|
11314
|
-
const tasks = delegatedTasks(ctx.tasks,
|
|
11315
|
-
const payload = { services:
|
|
12256
|
+
const tasks = delegatedTasks(ctx.tasks, id2).map((t) => ({ id: t.id, title: t.title, delegate: t.delegate, ref: t.delegate_ref, status: t.status }));
|
|
12257
|
+
const payload = { services: id2 ? services.filter((d) => d.id === id2) : services, tasks, check: checking };
|
|
11316
12258
|
if (flags.json) out(JSON.stringify(payload, null, 2));
|
|
11317
12259
|
else {
|
|
11318
12260
|
for (const d of payload.services) out(`${d.id} (${d.source}) \u2014 ${d.available || d.title}`);
|
|
@@ -11349,9 +12291,9 @@ start the builder with: ${r.launch}`);
|
|
|
11349
12291
|
}
|
|
11350
12292
|
case "improve": {
|
|
11351
12293
|
const root = repoRoot(cwd);
|
|
11352
|
-
const kind =
|
|
11353
|
-
const where =
|
|
11354
|
-
const what =
|
|
12294
|
+
const kind = str2(flags.kind);
|
|
12295
|
+
const where = str2(flags.where);
|
|
12296
|
+
const what = str2(flags.what);
|
|
11355
12297
|
if (!kind && !where && !what) {
|
|
11356
12298
|
const text = readImprove(root);
|
|
11357
12299
|
out(text.trim() ? text.trimEnd() : `${IMPROVE_EMPTY}`);
|
|
@@ -11361,22 +12303,22 @@ start the builder with: ${r.launch}`);
|
|
|
11361
12303
|
out("usage: improve --kind stop|ask|avoidable --where TEXT --what TEXT [--avoid TEXT]");
|
|
11362
12304
|
return 2;
|
|
11363
12305
|
}
|
|
11364
|
-
const line = appendImprove(root, { kind, where, what, avoid:
|
|
12306
|
+
const line = appendImprove(root, { kind, where, what, avoid: str2(flags.avoid) });
|
|
11365
12307
|
out(`noted ${line} in ${IMPROVE_PATH}`);
|
|
11366
12308
|
return 0;
|
|
11367
12309
|
}
|
|
11368
12310
|
case "activity": {
|
|
11369
12311
|
const root = repoRoot(cwd);
|
|
11370
12312
|
if (args[0] === "analyze") {
|
|
11371
|
-
const rows = loadActivity(root, { day:
|
|
12313
|
+
const rows = loadActivity(root, { day: str2(flags.day), since: str2(flags.since) });
|
|
11372
12314
|
const report = analyzeActivity(rows);
|
|
11373
12315
|
out(flags.json ? JSON.stringify(report, null, 2) : formatActivityReport(report));
|
|
11374
12316
|
return 0;
|
|
11375
12317
|
}
|
|
11376
|
-
const event =
|
|
11377
|
-
const what =
|
|
12318
|
+
const event = str2(flags.event);
|
|
12319
|
+
const what = str2(flags.what);
|
|
11378
12320
|
if (!event && !what) {
|
|
11379
|
-
const day =
|
|
12321
|
+
const day = str2(flags.day);
|
|
11380
12322
|
if (day) {
|
|
11381
12323
|
const rows = readActivityDay(root, day);
|
|
11382
12324
|
out(rows.length ? rows.map((r) => JSON.stringify(r)).join("\n") : `no activity for ${day}`);
|
|
@@ -11393,11 +12335,11 @@ start the builder with: ${r.launch}`);
|
|
|
11393
12335
|
const rel = appendActivity(root, {
|
|
11394
12336
|
event,
|
|
11395
12337
|
what,
|
|
11396
|
-
where:
|
|
11397
|
-
task:
|
|
11398
|
-
project:
|
|
12338
|
+
where: str2(flags.where),
|
|
12339
|
+
task: str2(flags.task),
|
|
12340
|
+
project: str2(flags.project) ?? project,
|
|
11399
12341
|
session,
|
|
11400
|
-
goal:
|
|
12342
|
+
goal: str2(flags.goal)
|
|
11401
12343
|
});
|
|
11402
12344
|
out(`noted ${event} in ${rel}`);
|
|
11403
12345
|
return 0;
|
|
@@ -11415,7 +12357,7 @@ start the builder with: ${r.launch}`);
|
|
|
11415
12357
|
out(r2.message);
|
|
11416
12358
|
return r2.ok ? 0 : 1;
|
|
11417
12359
|
}
|
|
11418
|
-
const mr =
|
|
12360
|
+
const mr = str2(flags.mr);
|
|
11419
12361
|
if (!mr) {
|
|
11420
12362
|
out("usage: merge-hold <task> --session ID --mr N");
|
|
11421
12363
|
return 2;
|
|
@@ -11432,12 +12374,12 @@ ${HELP}`);
|
|
|
11432
12374
|
}
|
|
11433
12375
|
}
|
|
11434
12376
|
function syncPlanPath(root, project) {
|
|
11435
|
-
return
|
|
12377
|
+
return join32(root, ".lead/logs", `sync-plan-${project === "." ? "root" : project.replace(/[^a-zA-Z0-9_-]/g, "_")}.json`);
|
|
11436
12378
|
}
|
|
11437
|
-
function savedSyncAction(root, project,
|
|
11438
|
-
const saved = JSON.parse(
|
|
12379
|
+
function savedSyncAction(root, project, id2) {
|
|
12380
|
+
const saved = JSON.parse(readFileSync27(syncPlanPath(root, project), "utf8"));
|
|
11439
12381
|
if (saved.project !== project) throw new Error(`the saved plan is for ${saved.project}, not ${project}`);
|
|
11440
|
-
return saved.actions.find((action) => action.id ===
|
|
12382
|
+
return saved.actions.find((action) => action.id === id2);
|
|
11441
12383
|
}
|
|
11442
12384
|
function syncActionKey(action) {
|
|
11443
12385
|
const { id: _id, ...payload } = action;
|
|
@@ -11449,26 +12391,26 @@ function syncLabel(action) {
|
|
|
11449
12391
|
return `${action.kind}${target ? ` \xB7 ${target}` : ""}${transition}`;
|
|
11450
12392
|
}
|
|
11451
12393
|
function syncJournalPath(root, project) {
|
|
11452
|
-
return
|
|
12394
|
+
return join32(root, ".lead/logs", `sync-journal-${digest(project)}.json`);
|
|
11453
12395
|
}
|
|
11454
12396
|
function readSyncJournal(root, project) {
|
|
11455
12397
|
const file = syncJournalPath(root, project);
|
|
11456
|
-
return
|
|
12398
|
+
return existsSync30(file) ? JSON.parse(readFileSync27(file, "utf8")) : {};
|
|
11457
12399
|
}
|
|
11458
12400
|
function writeSyncJournal(root, project, journal) {
|
|
11459
12401
|
const file = syncJournalPath(root, project);
|
|
11460
|
-
|
|
11461
|
-
|
|
12402
|
+
mkdirSync14(dirname6(file), { recursive: true });
|
|
12403
|
+
writeFileSync15(file, JSON.stringify(journal, null, 2));
|
|
11462
12404
|
}
|
|
11463
12405
|
function readStdinJson() {
|
|
11464
12406
|
try {
|
|
11465
|
-
const text =
|
|
12407
|
+
const text = readFileSync27(0, "utf8");
|
|
11466
12408
|
return text.trim() ? JSON.parse(text) : {};
|
|
11467
12409
|
} catch {
|
|
11468
12410
|
return {};
|
|
11469
12411
|
}
|
|
11470
12412
|
}
|
|
11471
|
-
var isMain = process.argv[1] &&
|
|
12413
|
+
var isMain = process.argv[1] && realpathSync6(process.argv[1]) === realpathSync6(fileURLToPath(import.meta.url));
|
|
11472
12414
|
if (isMain) process.exitCode = main(process.argv.slice(2));
|
|
11473
12415
|
export {
|
|
11474
12416
|
main
|