slateboard 0.1.0 → 0.1.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/README.md +33 -192
- package/dist/arch-3JZTL2DJ.js +1842 -0
- package/dist/bin.js +93 -17
- package/dist/{chunk-ONZFKR4I.js → chunk-6CR2V7P7.js} +172 -22
- package/dist/chunk-6YTKJKSG.js +129 -0
- package/dist/{chunk-SQHGMBUM.js → chunk-KA7Z72FC.js} +3 -2
- package/dist/{chunk-WXM4BB4D.js → chunk-OJOVDYIZ.js} +1400 -873
- package/dist/{chunk-BWNUX4FT.js → chunk-WREOGLK6.js} +4 -4
- package/dist/{chunk-FMO5B2KJ.js → chunk-ZCFHR5VG.js} +5 -5
- package/dist/{client-JHI2EG6J.js → client-BFKANUSM.js} +4 -4
- package/dist/{commands-ONES545N.js → commands-IB76RJGP.js} +1 -1
- package/dist/{doctor-H5Y5L2JZ.js → doctor-RPN73UNG.js} +3 -3
- package/dist/{hooks-2TI5OLAU.js → hooks-QJ4XG42C.js} +13 -1
- package/dist/{lifecycle-ZB5HEO5P.js → lifecycle-O7LDC735.js} +4 -4
- package/dist/{service-command-26BPMBK3.js → service-command-WG4TAU2T.js} +5 -5
- package/dist/shipped-7D2LNTAK.js +153 -0
- package/dist/{src-QZIVUACM.js → src-2MHSOXLY.js} +12 -2
- package/dist/{src-YVFB3ZLM.js → src-QB7VJHQH.js} +21 -1
- package/dist/ui/assets/abnfDiagram-XWFEHMT6-DAC8TnbO.js +1 -0
- package/dist/ui/assets/architecture-WOLXFQ4H-X8k0-LVf.js +1 -0
- package/dist/ui/assets/architectureDiagram-CSQXQB3N-CVoxvA0s.js +36 -0
- package/dist/ui/assets/blockDiagram-BEDRHYPZ-DGf5VAwB.js +140 -0
- package/dist/ui/assets/bpmnIcons-APHXDYXF-C0jbCElo.js +1 -0
- package/dist/ui/assets/c4Diagram-M2UUVUY5-PB5quCOl.js +38 -0
- package/dist/ui/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
- package/dist/ui/assets/chunk-3GCGMST5-RRiusQp9.js +1 -0
- package/dist/ui/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
- package/dist/ui/assets/chunk-7U7NFRK5-CSOOpKZT.js +88 -0
- package/dist/ui/assets/chunk-CNRTWJTD-DJuDnaYn.js +1 -0
- package/dist/ui/assets/chunk-D5HYT7QG-imLQxbAy.js +1 -0
- package/dist/ui/assets/chunk-DUW6YSOI-Dgx8z5s3.js +1 -0
- package/dist/ui/assets/chunk-DZSZGQHW-BCXsfFfT.js +1 -0
- package/dist/ui/assets/chunk-EBZ3SEQC-CdDips7b.js +2 -0
- package/dist/ui/assets/chunk-F3AE6A5H-DTVcMSk7.js +1 -0
- package/dist/ui/assets/chunk-FGVZ23HU-BEVs0fgA.js +213 -0
- package/dist/ui/assets/chunk-GZTWQ64R-CKGVWw4I.js +62 -0
- package/dist/ui/assets/chunk-J5ZVWO5B-oDCd-gWO.js +1 -0
- package/dist/ui/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
- package/dist/ui/assets/chunk-KTR4FSNJ-DSr3q0Xy.js +1 -0
- package/dist/ui/assets/chunk-MDAHDJXZ-YMIkXJ0O.js +10 -0
- package/dist/ui/assets/chunk-MPYPSXSE-C-CxVwa7.js +1 -0
- package/dist/ui/assets/chunk-ND7LMLKX-lfusdDHU.js +72 -0
- package/dist/ui/assets/chunk-NGNAAXSQ-DqoPQk1a.js +136 -0
- package/dist/ui/assets/chunk-OWCVCYLK-4-W-ynqW.js +2 -0
- package/dist/ui/assets/chunk-QDWOWVBQ-Du0KmhW4.js +129 -0
- package/dist/ui/assets/chunk-T47YP6PS-CKli33QU.js +1 -0
- package/dist/ui/assets/chunk-XXDRQBXY-DSL17ZTh.js +1 -0
- package/dist/ui/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
- package/dist/ui/assets/classDiagram-v2-KXABOMEV-CYc2BZ2y.js +217 -0
- package/dist/ui/assets/cose-bilkent-JH36ORCC-81nUs0at.js +1 -0
- package/dist/ui/assets/cynefin-EF2NZ3EQ-Clvwy422.js +1 -0
- package/dist/ui/assets/cynefinDiagram-NJNITYFG-CsgTQqAC.js +62 -0
- package/dist/ui/assets/cytoscape.esm-BPveszXl.js +321 -0
- package/dist/ui/assets/d3-scale-lXtN6-Od.js +1 -0
- package/dist/ui/assets/d3-selection-BFzs9NTX.js +1 -0
- package/dist/ui/assets/dagre-KIHZ2IZ3--BpWd3hW.js +4 -0
- package/dist/ui/assets/diagram-7YQZDPLS-Dp_m-C1a.js +41 -0
- package/dist/ui/assets/diagram-QBROCOUO-Bt-Lp7vq.js +200 -0
- package/dist/ui/assets/diagram-RJJCUUZO-DLsG2Tej.js +30 -0
- package/dist/ui/assets/diagram-WERXNKYE-D31SLp70.js +24 -0
- package/dist/ui/assets/diagram-YHHI257C-CVMeUILe.js +3 -0
- package/dist/ui/assets/diagram-YR4HJLHV-Bz9qvIhJ.js +24 -0
- package/dist/ui/assets/dist-YCovsM_S.js +1 -0
- package/dist/ui/assets/ebnfDiagram-N527522P-_FIZSf8P.js +1 -0
- package/dist/ui/assets/elk-O5DQBFGD-BK3qD3UW.js +27 -0
- package/dist/ui/assets/erDiagram-K3K3BIDK-Dmpdi5Ob.js +99 -0
- package/dist/ui/assets/eventmodeling-K75KTNOO-Dt-51L4s.js +1 -0
- package/dist/ui/assets/flowDiagram-Z6JWZHQI-Cn2ZVzvO.js +1 -0
- package/dist/ui/assets/ganttDiagram-3PRQTZWP-BaZof7eT.js +292 -0
- package/dist/ui/assets/gitGraph-VSP46ZUC-ezyaB0jQ.js +1 -0
- package/dist/ui/assets/gitGraphDiagram-VXDFKS5L-DRNdClPw.js +106 -0
- package/dist/ui/assets/graphlib-DS17s2tU.js +1 -0
- package/dist/ui/assets/grid-E2QIVN74--djCUwdI.js +1 -0
- package/dist/ui/assets/index-Bly281F6.css +1 -0
- package/dist/ui/assets/index-CXK8WmR8.js +45 -0
- package/dist/ui/assets/info-OHQRW6UA-DsFXrFWI.js +1 -0
- package/dist/ui/assets/infoDiagram-EZ3ZOAHP-e8qx3eqc.js +2 -0
- package/dist/ui/assets/ishikawaDiagram-S3EKX5GW-CuKExPKN.js +70 -0
- package/dist/ui/assets/journeyDiagram-POQNLL5X-D0GE8iji.js +139 -0
- package/dist/ui/assets/kanban-definition-BH5XI6FM-NL5dOF_0.js +89 -0
- package/dist/ui/assets/katex-BXIx1Jgr.js +257 -0
- package/dist/ui/assets/mermaid-parser.core-0pE4JCc_.js +7 -0
- package/dist/ui/assets/mermaid.core-BVgUieVU.js +44 -0
- package/dist/ui/assets/mindmap-definition-WVAN44T4-BLTtjuVH.js +98 -0
- package/dist/ui/assets/packet-JDAUHWVQ-C-7DeilZ.js +1 -0
- package/dist/ui/assets/pegDiagram-D4NLKWP3-F2SSXiqv.js +1 -0
- package/dist/ui/assets/pie-XZMESJXO-B4BkiWTy.js +1 -0
- package/dist/ui/assets/pieDiagram-36ENHN4W-BB5uEdtB.js +39 -0
- package/dist/ui/assets/quadrantDiagram-ZQUDMS73-B5iPooYO.js +7 -0
- package/dist/ui/assets/radar-ABXABTNO-Dx3jkQdr.js +1 -0
- package/dist/ui/assets/railroad-I3PHUGI6-BSh47OT_.js +1 -0
- package/dist/ui/assets/railroad-abnf-LNEFI6M7-BWFvDxOj.js +1 -0
- package/dist/ui/assets/railroad-ebnf-DWYD2UWJ-GBoLzumA.js +1 -0
- package/dist/ui/assets/railroad-peg-JR7BVNR7-DByw5Orh.js +1 -0
- package/dist/ui/assets/railroadDiagram-JIZHGYPL--ptGd2NR.js +1 -0
- package/dist/ui/assets/render-VIF2ZAQL-CzNp-J42.js +2 -0
- package/dist/ui/assets/requirementDiagram-AXW2TVFA-DBh9Dt63.js +84 -0
- package/dist/ui/assets/rough.esm-Dy-Kn_BL.js +1 -0
- package/dist/ui/assets/sankeyDiagram-FBCJTAIF-CjJtGyu8.js +40 -0
- package/dist/ui/assets/sequenceDiagram-3LA2ROMG-BzeMVuzG.js +169 -0
- package/dist/ui/assets/sizeCapture-2Q2CQKSF-DSY_W0YL.js +1 -0
- package/dist/ui/assets/stateDiagram-v2-ATKHQDJO-DYavre2v.js +291 -0
- package/dist/ui/assets/swimlanes-YQL5WMAO-CUTCsfPM.js +1 -0
- package/dist/ui/assets/swimlanesDiagram-UCCPES4V-B7bXxKVr.js +8 -0
- package/dist/ui/assets/timeline-definition-7Z437IG3-HWrtH0QT.js +120 -0
- package/dist/ui/assets/treeView-D4JQ5SDB-B5lbyI_M.js +1 -0
- package/dist/ui/assets/treemap-SAJKECNS-Ckfi-DGc.js +1 -0
- package/dist/ui/assets/usecaseDiagram-RDK6N6HP-BuKN2NAW.js +328 -0
- package/dist/ui/assets/vennDiagram-SHRQU5PJ-s2gljkjP.js +34 -0
- package/dist/ui/assets/wardley-7MLQ67FV-CjAqYBcP.js +1 -0
- package/dist/ui/assets/wardleyDiagram-F3OXNVQS-Ba_SoMTx.js +78 -0
- package/dist/ui/assets/xychartDiagram-GDYJKCDI-FsxUUoqL.js +7 -0
- package/dist/ui/index.html +2 -2
- package/dist/{upgrade-FND3UBJR.js → upgrade-M6TR3IBW.js} +15 -15
- package/migrations/0006_arch_auto.sql +8 -0
- package/package.json +1 -1
- package/dist/chunk-3ZLMW2RI.js +0 -74
- package/dist/ui/assets/index-4WzXlYHs.css +0 -1
- package/dist/ui/assets/index-ZKfByx7Q.js +0 -42
|
@@ -85,17 +85,17 @@ var require_visit = __commonJS({
|
|
|
85
85
|
visit.BREAK = BREAK;
|
|
86
86
|
visit.SKIP = SKIP;
|
|
87
87
|
visit.REMOVE = REMOVE;
|
|
88
|
-
function visit_(key, node, visitor,
|
|
89
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
88
|
+
function visit_(key, node, visitor, path11) {
|
|
89
|
+
const ctrl = callVisitor(key, node, visitor, path11);
|
|
90
90
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
91
|
-
replaceNode(key,
|
|
92
|
-
return visit_(key, ctrl, visitor,
|
|
91
|
+
replaceNode(key, path11, ctrl);
|
|
92
|
+
return visit_(key, ctrl, visitor, path11);
|
|
93
93
|
}
|
|
94
94
|
if (typeof ctrl !== "symbol") {
|
|
95
95
|
if (identity.isCollection(node)) {
|
|
96
|
-
|
|
96
|
+
path11 = Object.freeze(path11.concat(node));
|
|
97
97
|
for (let i = 0; i < node.items.length; ++i) {
|
|
98
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
98
|
+
const ci = visit_(i, node.items[i], visitor, path11);
|
|
99
99
|
if (typeof ci === "number")
|
|
100
100
|
i = ci - 1;
|
|
101
101
|
else if (ci === BREAK)
|
|
@@ -106,13 +106,13 @@ var require_visit = __commonJS({
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
} else if (identity.isPair(node)) {
|
|
109
|
-
|
|
110
|
-
const ck = visit_("key", node.key, visitor,
|
|
109
|
+
path11 = Object.freeze(path11.concat(node));
|
|
110
|
+
const ck = visit_("key", node.key, visitor, path11);
|
|
111
111
|
if (ck === BREAK)
|
|
112
112
|
return BREAK;
|
|
113
113
|
else if (ck === REMOVE)
|
|
114
114
|
node.key = null;
|
|
115
|
-
const cv = visit_("value", node.value, visitor,
|
|
115
|
+
const cv = visit_("value", node.value, visitor, path11);
|
|
116
116
|
if (cv === BREAK)
|
|
117
117
|
return BREAK;
|
|
118
118
|
else if (cv === REMOVE)
|
|
@@ -133,17 +133,17 @@ var require_visit = __commonJS({
|
|
|
133
133
|
visitAsync.BREAK = BREAK;
|
|
134
134
|
visitAsync.SKIP = SKIP;
|
|
135
135
|
visitAsync.REMOVE = REMOVE;
|
|
136
|
-
async function visitAsync_(key, node, visitor,
|
|
137
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
136
|
+
async function visitAsync_(key, node, visitor, path11) {
|
|
137
|
+
const ctrl = await callVisitor(key, node, visitor, path11);
|
|
138
138
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
139
|
-
replaceNode(key,
|
|
140
|
-
return visitAsync_(key, ctrl, visitor,
|
|
139
|
+
replaceNode(key, path11, ctrl);
|
|
140
|
+
return visitAsync_(key, ctrl, visitor, path11);
|
|
141
141
|
}
|
|
142
142
|
if (typeof ctrl !== "symbol") {
|
|
143
143
|
if (identity.isCollection(node)) {
|
|
144
|
-
|
|
144
|
+
path11 = Object.freeze(path11.concat(node));
|
|
145
145
|
for (let i = 0; i < node.items.length; ++i) {
|
|
146
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
146
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path11);
|
|
147
147
|
if (typeof ci === "number")
|
|
148
148
|
i = ci - 1;
|
|
149
149
|
else if (ci === BREAK)
|
|
@@ -154,13 +154,13 @@ var require_visit = __commonJS({
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
} else if (identity.isPair(node)) {
|
|
157
|
-
|
|
158
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
157
|
+
path11 = Object.freeze(path11.concat(node));
|
|
158
|
+
const ck = await visitAsync_("key", node.key, visitor, path11);
|
|
159
159
|
if (ck === BREAK)
|
|
160
160
|
return BREAK;
|
|
161
161
|
else if (ck === REMOVE)
|
|
162
162
|
node.key = null;
|
|
163
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
163
|
+
const cv = await visitAsync_("value", node.value, visitor, path11);
|
|
164
164
|
if (cv === BREAK)
|
|
165
165
|
return BREAK;
|
|
166
166
|
else if (cv === REMOVE)
|
|
@@ -187,23 +187,23 @@ var require_visit = __commonJS({
|
|
|
187
187
|
}
|
|
188
188
|
return visitor;
|
|
189
189
|
}
|
|
190
|
-
function callVisitor(key, node, visitor,
|
|
190
|
+
function callVisitor(key, node, visitor, path11) {
|
|
191
191
|
if (typeof visitor === "function")
|
|
192
|
-
return visitor(key, node,
|
|
192
|
+
return visitor(key, node, path11);
|
|
193
193
|
if (identity.isMap(node))
|
|
194
|
-
return visitor.Map?.(key, node,
|
|
194
|
+
return visitor.Map?.(key, node, path11);
|
|
195
195
|
if (identity.isSeq(node))
|
|
196
|
-
return visitor.Seq?.(key, node,
|
|
196
|
+
return visitor.Seq?.(key, node, path11);
|
|
197
197
|
if (identity.isPair(node))
|
|
198
|
-
return visitor.Pair?.(key, node,
|
|
198
|
+
return visitor.Pair?.(key, node, path11);
|
|
199
199
|
if (identity.isScalar(node))
|
|
200
|
-
return visitor.Scalar?.(key, node,
|
|
200
|
+
return visitor.Scalar?.(key, node, path11);
|
|
201
201
|
if (identity.isAlias(node))
|
|
202
|
-
return visitor.Alias?.(key, node,
|
|
202
|
+
return visitor.Alias?.(key, node, path11);
|
|
203
203
|
return void 0;
|
|
204
204
|
}
|
|
205
|
-
function replaceNode(key,
|
|
206
|
-
const parent =
|
|
205
|
+
function replaceNode(key, path11, node) {
|
|
206
|
+
const parent = path11[path11.length - 1];
|
|
207
207
|
if (identity.isCollection(parent)) {
|
|
208
208
|
parent.items[key] = node;
|
|
209
209
|
} else if (identity.isPair(parent)) {
|
|
@@ -815,10 +815,10 @@ var require_Collection = __commonJS({
|
|
|
815
815
|
var createNode = require_createNode();
|
|
816
816
|
var identity = require_identity();
|
|
817
817
|
var Node = require_Node();
|
|
818
|
-
function collectionFromPath(schema,
|
|
818
|
+
function collectionFromPath(schema, path11, value) {
|
|
819
819
|
let v = value;
|
|
820
|
-
for (let i =
|
|
821
|
-
const k =
|
|
820
|
+
for (let i = path11.length - 1; i >= 0; --i) {
|
|
821
|
+
const k = path11[i];
|
|
822
822
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
823
823
|
const a = [];
|
|
824
824
|
a[k] = v;
|
|
@@ -837,7 +837,7 @@ var require_Collection = __commonJS({
|
|
|
837
837
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
838
838
|
});
|
|
839
839
|
}
|
|
840
|
-
var isEmptyPath = (
|
|
840
|
+
var isEmptyPath = (path11) => path11 == null || typeof path11 === "object" && !!path11[Symbol.iterator]().next().done;
|
|
841
841
|
var Collection = class extends Node.NodeBase {
|
|
842
842
|
constructor(type, schema) {
|
|
843
843
|
super(type);
|
|
@@ -867,11 +867,11 @@ var require_Collection = __commonJS({
|
|
|
867
867
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
868
868
|
* that already exists in the map.
|
|
869
869
|
*/
|
|
870
|
-
addIn(
|
|
871
|
-
if (isEmptyPath(
|
|
870
|
+
addIn(path11, value) {
|
|
871
|
+
if (isEmptyPath(path11))
|
|
872
872
|
this.add(value);
|
|
873
873
|
else {
|
|
874
|
-
const [key, ...rest] =
|
|
874
|
+
const [key, ...rest] = path11;
|
|
875
875
|
const node = this.get(key, true);
|
|
876
876
|
if (identity.isCollection(node))
|
|
877
877
|
node.addIn(rest, value);
|
|
@@ -885,8 +885,8 @@ var require_Collection = __commonJS({
|
|
|
885
885
|
* Removes a value from the collection.
|
|
886
886
|
* @returns `true` if the item was found and removed.
|
|
887
887
|
*/
|
|
888
|
-
deleteIn(
|
|
889
|
-
const [key, ...rest] =
|
|
888
|
+
deleteIn(path11) {
|
|
889
|
+
const [key, ...rest] = path11;
|
|
890
890
|
if (rest.length === 0)
|
|
891
891
|
return this.delete(key);
|
|
892
892
|
const node = this.get(key, true);
|
|
@@ -900,8 +900,8 @@ var require_Collection = __commonJS({
|
|
|
900
900
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
901
901
|
* `true` (collections are always returned intact).
|
|
902
902
|
*/
|
|
903
|
-
getIn(
|
|
904
|
-
const [key, ...rest] =
|
|
903
|
+
getIn(path11, keepScalar) {
|
|
904
|
+
const [key, ...rest] = path11;
|
|
905
905
|
const node = this.get(key, true);
|
|
906
906
|
if (rest.length === 0)
|
|
907
907
|
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
|
@@ -919,8 +919,8 @@ var require_Collection = __commonJS({
|
|
|
919
919
|
/**
|
|
920
920
|
* Checks if the collection includes a value with the key `key`.
|
|
921
921
|
*/
|
|
922
|
-
hasIn(
|
|
923
|
-
const [key, ...rest] =
|
|
922
|
+
hasIn(path11) {
|
|
923
|
+
const [key, ...rest] = path11;
|
|
924
924
|
if (rest.length === 0)
|
|
925
925
|
return this.has(key);
|
|
926
926
|
const node = this.get(key, true);
|
|
@@ -930,8 +930,8 @@ var require_Collection = __commonJS({
|
|
|
930
930
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
931
931
|
* boolean to add/remove the item from the set.
|
|
932
932
|
*/
|
|
933
|
-
setIn(
|
|
934
|
-
const [key, ...rest] =
|
|
933
|
+
setIn(path11, value) {
|
|
934
|
+
const [key, ...rest] = path11;
|
|
935
935
|
if (rest.length === 0) {
|
|
936
936
|
this.set(key, value);
|
|
937
937
|
} else {
|
|
@@ -3446,9 +3446,9 @@ var require_Document = __commonJS({
|
|
|
3446
3446
|
this.contents.add(value);
|
|
3447
3447
|
}
|
|
3448
3448
|
/** Adds a value to the document. */
|
|
3449
|
-
addIn(
|
|
3449
|
+
addIn(path11, value) {
|
|
3450
3450
|
if (assertCollection(this.contents))
|
|
3451
|
-
this.contents.addIn(
|
|
3451
|
+
this.contents.addIn(path11, value);
|
|
3452
3452
|
}
|
|
3453
3453
|
/**
|
|
3454
3454
|
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
|
|
@@ -3523,14 +3523,14 @@ var require_Document = __commonJS({
|
|
|
3523
3523
|
* Removes a value from the document.
|
|
3524
3524
|
* @returns `true` if the item was found and removed.
|
|
3525
3525
|
*/
|
|
3526
|
-
deleteIn(
|
|
3527
|
-
if (Collection.isEmptyPath(
|
|
3526
|
+
deleteIn(path11) {
|
|
3527
|
+
if (Collection.isEmptyPath(path11)) {
|
|
3528
3528
|
if (this.contents == null)
|
|
3529
3529
|
return false;
|
|
3530
3530
|
this.contents = null;
|
|
3531
3531
|
return true;
|
|
3532
3532
|
}
|
|
3533
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
3533
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path11) : false;
|
|
3534
3534
|
}
|
|
3535
3535
|
/**
|
|
3536
3536
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
@@ -3545,10 +3545,10 @@ var require_Document = __commonJS({
|
|
|
3545
3545
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
3546
3546
|
* `true` (collections are always returned intact).
|
|
3547
3547
|
*/
|
|
3548
|
-
getIn(
|
|
3549
|
-
if (Collection.isEmptyPath(
|
|
3548
|
+
getIn(path11, keepScalar) {
|
|
3549
|
+
if (Collection.isEmptyPath(path11))
|
|
3550
3550
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
3551
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
3551
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path11, keepScalar) : void 0;
|
|
3552
3552
|
}
|
|
3553
3553
|
/**
|
|
3554
3554
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -3559,10 +3559,10 @@ var require_Document = __commonJS({
|
|
|
3559
3559
|
/**
|
|
3560
3560
|
* Checks if the document includes a value at `path`.
|
|
3561
3561
|
*/
|
|
3562
|
-
hasIn(
|
|
3563
|
-
if (Collection.isEmptyPath(
|
|
3562
|
+
hasIn(path11) {
|
|
3563
|
+
if (Collection.isEmptyPath(path11))
|
|
3564
3564
|
return this.contents !== void 0;
|
|
3565
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
3565
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path11) : false;
|
|
3566
3566
|
}
|
|
3567
3567
|
/**
|
|
3568
3568
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -3579,13 +3579,13 @@ var require_Document = __commonJS({
|
|
|
3579
3579
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
3580
3580
|
* boolean to add/remove the item from the set.
|
|
3581
3581
|
*/
|
|
3582
|
-
setIn(
|
|
3583
|
-
if (Collection.isEmptyPath(
|
|
3582
|
+
setIn(path11, value) {
|
|
3583
|
+
if (Collection.isEmptyPath(path11)) {
|
|
3584
3584
|
this.contents = value;
|
|
3585
3585
|
} else if (this.contents == null) {
|
|
3586
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
3586
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path11), value);
|
|
3587
3587
|
} else if (assertCollection(this.contents)) {
|
|
3588
|
-
this.contents.setIn(
|
|
3588
|
+
this.contents.setIn(path11, value);
|
|
3589
3589
|
}
|
|
3590
3590
|
}
|
|
3591
3591
|
/**
|
|
@@ -5546,9 +5546,9 @@ var require_cst_visit = __commonJS({
|
|
|
5546
5546
|
visit.BREAK = BREAK;
|
|
5547
5547
|
visit.SKIP = SKIP;
|
|
5548
5548
|
visit.REMOVE = REMOVE;
|
|
5549
|
-
visit.itemAtPath = (cst,
|
|
5549
|
+
visit.itemAtPath = (cst, path11) => {
|
|
5550
5550
|
let item = cst;
|
|
5551
|
-
for (const [field, index] of
|
|
5551
|
+
for (const [field, index] of path11) {
|
|
5552
5552
|
const tok = item?.[field];
|
|
5553
5553
|
if (tok && "items" in tok) {
|
|
5554
5554
|
item = tok.items[index];
|
|
@@ -5557,23 +5557,23 @@ var require_cst_visit = __commonJS({
|
|
|
5557
5557
|
}
|
|
5558
5558
|
return item;
|
|
5559
5559
|
};
|
|
5560
|
-
visit.parentCollection = (cst,
|
|
5561
|
-
const parent = visit.itemAtPath(cst,
|
|
5562
|
-
const field =
|
|
5560
|
+
visit.parentCollection = (cst, path11) => {
|
|
5561
|
+
const parent = visit.itemAtPath(cst, path11.slice(0, -1));
|
|
5562
|
+
const field = path11[path11.length - 1][0];
|
|
5563
5563
|
const coll = parent?.[field];
|
|
5564
5564
|
if (coll && "items" in coll)
|
|
5565
5565
|
return coll;
|
|
5566
5566
|
throw new Error("Parent collection not found");
|
|
5567
5567
|
};
|
|
5568
|
-
function _visit(
|
|
5569
|
-
let ctrl = visitor(item,
|
|
5568
|
+
function _visit(path11, item, visitor) {
|
|
5569
|
+
let ctrl = visitor(item, path11);
|
|
5570
5570
|
if (typeof ctrl === "symbol")
|
|
5571
5571
|
return ctrl;
|
|
5572
5572
|
for (const field of ["key", "value"]) {
|
|
5573
5573
|
const token = item[field];
|
|
5574
5574
|
if (token && "items" in token) {
|
|
5575
5575
|
for (let i = 0; i < token.items.length; ++i) {
|
|
5576
|
-
const ci = _visit(Object.freeze(
|
|
5576
|
+
const ci = _visit(Object.freeze(path11.concat([[field, i]])), token.items[i], visitor);
|
|
5577
5577
|
if (typeof ci === "number")
|
|
5578
5578
|
i = ci - 1;
|
|
5579
5579
|
else if (ci === BREAK)
|
|
@@ -5584,10 +5584,10 @@ var require_cst_visit = __commonJS({
|
|
|
5584
5584
|
}
|
|
5585
5585
|
}
|
|
5586
5586
|
if (typeof ctrl === "function" && field === "key")
|
|
5587
|
-
ctrl = ctrl(item,
|
|
5587
|
+
ctrl = ctrl(item, path11);
|
|
5588
5588
|
}
|
|
5589
5589
|
}
|
|
5590
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
5590
|
+
return typeof ctrl === "function" ? ctrl(item, path11) : ctrl;
|
|
5591
5591
|
}
|
|
5592
5592
|
exports.visit = visit;
|
|
5593
5593
|
}
|
|
@@ -7480,6 +7480,8 @@ var projectUpdateSchema = external_exports.object({
|
|
|
7480
7480
|
gitTransitions: external_exports.boolean().optional(),
|
|
7481
7481
|
/** A path inside the project for the roadmap file, or null to stop keeping it. */
|
|
7482
7482
|
roadmapFile: external_exports.string().trim().min(1).max(500).nullable().optional(),
|
|
7483
|
+
/** Keep docs/architecture current: regenerate it when HEAD moves (and once when turned on). */
|
|
7484
|
+
archAuto: external_exports.boolean().optional(),
|
|
7483
7485
|
description: external_exports.string().max(1e4).nullable().optional(),
|
|
7484
7486
|
milestones: external_exports.array(milestoneSchema).optional(),
|
|
7485
7487
|
remap: external_exports.record(external_exports.string(), milestoneSchema.nullable()).optional()
|
|
@@ -7769,6 +7771,323 @@ var Store = class _Store {
|
|
|
7769
7771
|
}
|
|
7770
7772
|
};
|
|
7771
7773
|
|
|
7774
|
+
// ../core/src/services/arch-auto.ts
|
|
7775
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
7776
|
+
|
|
7777
|
+
// ../core/src/git.ts
|
|
7778
|
+
import fs from "node:fs";
|
|
7779
|
+
import path3 from "node:path";
|
|
7780
|
+
|
|
7781
|
+
// ../core/src/mentions.ts
|
|
7782
|
+
var TOKEN = /[A-Za-z0-9_-]+/g;
|
|
7783
|
+
var KEY_TOKEN = /^[A-Za-z]{2,5}-\d{1,9}$/;
|
|
7784
|
+
var SLATE_LINE = /^[ \t]*slate[ \t]*:(.*)$/gim;
|
|
7785
|
+
var PART = /([A-Za-z0-9_-]+)[ \t]*\([ \t]*part(?:ial)?(?:[ \t]+[^)\n]*)?[ \t]*\)/gi;
|
|
7786
|
+
function named(token, wanted) {
|
|
7787
|
+
if (wanted.has(token)) return token;
|
|
7788
|
+
return KEY_TOKEN.test(token) && wanted.has(token.toUpperCase()) ? token.toUpperCase() : null;
|
|
7789
|
+
}
|
|
7790
|
+
function mentionsIn(message, wanted) {
|
|
7791
|
+
const out = /* @__PURE__ */ new Map();
|
|
7792
|
+
if (wanted.size === 0) return out;
|
|
7793
|
+
for (const token of message.match(TOKEN) ?? []) {
|
|
7794
|
+
const id = named(token, wanted);
|
|
7795
|
+
if (id && !out.has(id)) out.set(id, { partial: false });
|
|
7796
|
+
}
|
|
7797
|
+
if (out.size === 0) return out;
|
|
7798
|
+
const part = /* @__PURE__ */ new Set();
|
|
7799
|
+
const plain = /* @__PURE__ */ new Set();
|
|
7800
|
+
for (const line of message.matchAll(SLATE_LINE)) {
|
|
7801
|
+
for (const m of line[1].matchAll(PART)) {
|
|
7802
|
+
const id = named(m[1], wanted);
|
|
7803
|
+
if (id) part.add(id);
|
|
7804
|
+
}
|
|
7805
|
+
for (const token of line[1].replace(PART, " ").match(TOKEN) ?? []) {
|
|
7806
|
+
const id = named(token, wanted);
|
|
7807
|
+
if (id) plain.add(id);
|
|
7808
|
+
}
|
|
7809
|
+
}
|
|
7810
|
+
for (const id of part) if (!plain.has(id)) out.set(id, { partial: true });
|
|
7811
|
+
return out;
|
|
7812
|
+
}
|
|
7813
|
+
function saysNoItem(message) {
|
|
7814
|
+
return /^[ \t]*slate[ \t]*:[ \t]*none[ \t]*$/im.test(message);
|
|
7815
|
+
}
|
|
7816
|
+
function keyTokens(message) {
|
|
7817
|
+
const out = /* @__PURE__ */ new Set();
|
|
7818
|
+
for (const token of message.match(TOKEN) ?? []) if (KEY_TOKEN.test(token)) out.add(token.toUpperCase());
|
|
7819
|
+
return [...out];
|
|
7820
|
+
}
|
|
7821
|
+
|
|
7822
|
+
// ../core/src/git.ts
|
|
7823
|
+
var loaded;
|
|
7824
|
+
var lib = () => loaded ??= import("./isomorphic-git-BZUKICXS.js").then((m) => "log" in m ? m : m.default);
|
|
7825
|
+
var GIT_CACHE_TTL_MS = 15e3;
|
|
7826
|
+
var DEFAULT_COMMIT_SCAN = 500;
|
|
7827
|
+
var MAX_COMMIT_SCAN = 5e3;
|
|
7828
|
+
var SHORT = 7;
|
|
7829
|
+
var cache = /* @__PURE__ */ new Map();
|
|
7830
|
+
function clearGitCache() {
|
|
7831
|
+
cache.clear();
|
|
7832
|
+
diffs.clear();
|
|
7833
|
+
}
|
|
7834
|
+
function isDir(p) {
|
|
7835
|
+
try {
|
|
7836
|
+
return fs.statSync(p).isDirectory();
|
|
7837
|
+
} catch {
|
|
7838
|
+
return false;
|
|
7839
|
+
}
|
|
7840
|
+
}
|
|
7841
|
+
function isFile(p) {
|
|
7842
|
+
try {
|
|
7843
|
+
return fs.statSync(p).isFile();
|
|
7844
|
+
} catch {
|
|
7845
|
+
return false;
|
|
7846
|
+
}
|
|
7847
|
+
}
|
|
7848
|
+
function valid(repo) {
|
|
7849
|
+
return isFile(path3.join(repo.headDir, "HEAD")) && isDir(path3.join(repo.gitdir, "objects")) ? repo : null;
|
|
7850
|
+
}
|
|
7851
|
+
function fromGitFile(dotgit) {
|
|
7852
|
+
const match = /^gitdir:\s*(.+?)\s*$/m.exec(fs.readFileSync(dotgit, "utf8"));
|
|
7853
|
+
if (!match?.[1]) return null;
|
|
7854
|
+
const headDir = path3.resolve(path3.dirname(dotgit), match[1]);
|
|
7855
|
+
const commondir = path3.join(headDir, "commondir");
|
|
7856
|
+
const gitdir = isFile(commondir) ? path3.resolve(headDir, fs.readFileSync(commondir, "utf8").trim()) : headDir;
|
|
7857
|
+
return valid({ gitdir, headDir });
|
|
7858
|
+
}
|
|
7859
|
+
function currentBranch(repoPath) {
|
|
7860
|
+
const repo = locateRepo(repoPath);
|
|
7861
|
+
if (!repo) return null;
|
|
7862
|
+
try {
|
|
7863
|
+
const head = fs.readFileSync(path3.join(repo.headDir, "HEAD"), "utf8").trim();
|
|
7864
|
+
return /^ref: refs\/heads\/(.+)$/.exec(head)?.[1] ?? null;
|
|
7865
|
+
} catch {
|
|
7866
|
+
return null;
|
|
7867
|
+
}
|
|
7868
|
+
}
|
|
7869
|
+
async function defaultBranchShas(repoPath, limit = DEFAULT_COMMIT_SCAN) {
|
|
7870
|
+
const repo = locateRepo(repoPath);
|
|
7871
|
+
if (!repo) return /* @__PURE__ */ new Set();
|
|
7872
|
+
const git = await lib();
|
|
7873
|
+
for (const ref of ["refs/remotes/origin/HEAD", "refs/heads/main", "refs/heads/master"]) {
|
|
7874
|
+
try {
|
|
7875
|
+
const oid = await git.resolveRef({ fs, gitdir: repo.gitdir, ref });
|
|
7876
|
+
const log = await git.log({ fs, gitdir: repo.gitdir, ref: oid, depth: Math.min(limit, MAX_COMMIT_SCAN) });
|
|
7877
|
+
return new Set(log.map((c) => c.oid));
|
|
7878
|
+
} catch {
|
|
7879
|
+
}
|
|
7880
|
+
}
|
|
7881
|
+
return /* @__PURE__ */ new Set();
|
|
7882
|
+
}
|
|
7883
|
+
function keyFromBranch(branch) {
|
|
7884
|
+
return branch && /^slate\/([A-Za-z]{2,5}-\d{1,9})(?:-|$)/.exec(branch)?.[1]?.toUpperCase() || null;
|
|
7885
|
+
}
|
|
7886
|
+
function locateRepo(repoPath) {
|
|
7887
|
+
try {
|
|
7888
|
+
const start = path3.resolve(repoPath);
|
|
7889
|
+
if (!isDir(start)) return null;
|
|
7890
|
+
if (isFile(path3.join(start, "HEAD")) && isDir(path3.join(start, "refs"))) {
|
|
7891
|
+
const bare = valid({ gitdir: start, headDir: start });
|
|
7892
|
+
if (bare) return bare;
|
|
7893
|
+
}
|
|
7894
|
+
for (let dir = start; ; dir = path3.dirname(dir)) {
|
|
7895
|
+
const dotgit = path3.join(dir, ".git");
|
|
7896
|
+
let stat;
|
|
7897
|
+
try {
|
|
7898
|
+
stat = fs.statSync(dotgit);
|
|
7899
|
+
} catch {
|
|
7900
|
+
stat = void 0;
|
|
7901
|
+
}
|
|
7902
|
+
if (stat?.isDirectory()) return valid({ gitdir: dotgit, headDir: dotgit });
|
|
7903
|
+
if (stat?.isFile()) return fromGitFile(dotgit);
|
|
7904
|
+
if (path3.dirname(dir) === dir) return null;
|
|
7905
|
+
}
|
|
7906
|
+
} catch {
|
|
7907
|
+
return null;
|
|
7908
|
+
}
|
|
7909
|
+
}
|
|
7910
|
+
async function headOf(repo) {
|
|
7911
|
+
let head;
|
|
7912
|
+
try {
|
|
7913
|
+
head = fs.readFileSync(path3.join(repo.headDir, "HEAD"), "utf8").trim();
|
|
7914
|
+
} catch {
|
|
7915
|
+
return null;
|
|
7916
|
+
}
|
|
7917
|
+
const symbolic = /^ref:\s*(\S+)$/.exec(head);
|
|
7918
|
+
if (!symbolic) return /^[0-9a-f]{40}([0-9a-f]{24})?$/.test(head) ? head : null;
|
|
7919
|
+
const git = await lib();
|
|
7920
|
+
return git.resolveRef({ fs, gitdir: repo.gitdir, ref: symbolic[1] }).catch(() => null);
|
|
7921
|
+
}
|
|
7922
|
+
async function headCommit(repoPath) {
|
|
7923
|
+
const repo = locateRepo(repoPath);
|
|
7924
|
+
return repo ? headOf(repo) : null;
|
|
7925
|
+
}
|
|
7926
|
+
async function entryFor(repo) {
|
|
7927
|
+
const head = await headOf(repo);
|
|
7928
|
+
if (!head) return null;
|
|
7929
|
+
const now = Date.now();
|
|
7930
|
+
const existing = cache.get(repo.gitdir);
|
|
7931
|
+
if (existing && existing.head === head && now - existing.at < GIT_CACHE_TTL_MS) return existing;
|
|
7932
|
+
const entry = { head, at: now, walks: /* @__PURE__ */ new Map(), shas: /* @__PURE__ */ new Map() };
|
|
7933
|
+
cache.set(repo.gitdir, entry);
|
|
7934
|
+
return entry;
|
|
7935
|
+
}
|
|
7936
|
+
function info(sha2, message, author, timestamp) {
|
|
7937
|
+
return {
|
|
7938
|
+
sha: sha2,
|
|
7939
|
+
shortSha: sha2.slice(0, SHORT),
|
|
7940
|
+
subject: message.split("\n", 1)[0].trim(),
|
|
7941
|
+
author,
|
|
7942
|
+
date: new Date(timestamp * 1e3).toISOString()
|
|
7943
|
+
};
|
|
7944
|
+
}
|
|
7945
|
+
async function resolveCommit(repoPath, sha2) {
|
|
7946
|
+
const wanted = sha2.trim().toLowerCase();
|
|
7947
|
+
if (!/^[0-9a-f]{4,64}$/.test(wanted)) return null;
|
|
7948
|
+
const repo = locateRepo(repoPath);
|
|
7949
|
+
if (!repo) return null;
|
|
7950
|
+
const entry = await entryFor(repo);
|
|
7951
|
+
const lookup = async () => {
|
|
7952
|
+
const git = await lib();
|
|
7953
|
+
try {
|
|
7954
|
+
const oid = wanted.length >= 40 ? wanted : await git.expandOid({ fs, gitdir: repo.gitdir, oid: wanted });
|
|
7955
|
+
const { commit } = await git.readCommit({ fs, gitdir: repo.gitdir, oid });
|
|
7956
|
+
return info(oid, commit.message, commit.author.name, commit.author.timestamp);
|
|
7957
|
+
} catch {
|
|
7958
|
+
return null;
|
|
7959
|
+
}
|
|
7960
|
+
};
|
|
7961
|
+
if (!entry) return lookup();
|
|
7962
|
+
let pending = entry.shas.get(wanted);
|
|
7963
|
+
if (!pending) {
|
|
7964
|
+
pending = lookup();
|
|
7965
|
+
entry.shas.set(wanted, pending);
|
|
7966
|
+
}
|
|
7967
|
+
return pending;
|
|
7968
|
+
}
|
|
7969
|
+
async function walk(repo, entry, limit) {
|
|
7970
|
+
let pending = entry.walks.get(limit);
|
|
7971
|
+
if (!pending) {
|
|
7972
|
+
pending = lib().then(
|
|
7973
|
+
(git) => git.log({ fs, gitdir: repo.gitdir, ref: entry.head, depth: limit }).then((log) => log.map((c) => ({ sha: c.oid, message: c.commit.message, author: c.commit.author.name, timestamp: c.commit.author.timestamp }))).catch(() => [])
|
|
7974
|
+
);
|
|
7975
|
+
entry.walks.set(limit, pending);
|
|
7976
|
+
}
|
|
7977
|
+
return pending;
|
|
7978
|
+
}
|
|
7979
|
+
async function ignoreChecker(dir) {
|
|
7980
|
+
const git = await lib();
|
|
7981
|
+
let workTree = path3.resolve(dir);
|
|
7982
|
+
for (let d = workTree; ; d = path3.dirname(d)) {
|
|
7983
|
+
if (fs.existsSync(path3.join(d, ".git"))) {
|
|
7984
|
+
workTree = d;
|
|
7985
|
+
break;
|
|
7986
|
+
}
|
|
7987
|
+
if (path3.dirname(d) === d) break;
|
|
7988
|
+
}
|
|
7989
|
+
const gitdir = locateRepo(workTree)?.gitdir ?? path3.join(workTree, ".git");
|
|
7990
|
+
const prefix = path3.relative(workTree, path3.resolve(dir)).split(path3.sep).join("/");
|
|
7991
|
+
return (rel, isDirectory) => {
|
|
7992
|
+
const filepath = (prefix ? `${prefix}/${rel}` : rel) + (isDirectory ? "/" : "");
|
|
7993
|
+
return git.isIgnored({ fs, dir: workTree, gitdir, filepath }).catch(() => false);
|
|
7994
|
+
};
|
|
7995
|
+
}
|
|
7996
|
+
async function findCommitsMentioning(repoPath, ids, options = {}) {
|
|
7997
|
+
const wanted = new Set(ids.filter((id) => id.length > 0));
|
|
7998
|
+
if (wanted.size === 0) return [];
|
|
7999
|
+
const limit = Math.max(1, Math.min(MAX_COMMIT_SCAN, Math.floor(options.limit ?? DEFAULT_COMMIT_SCAN)));
|
|
8000
|
+
const repo = locateRepo(repoPath);
|
|
8001
|
+
if (!repo) return [];
|
|
8002
|
+
const entry = await entryFor(repo);
|
|
8003
|
+
if (!entry) return [];
|
|
8004
|
+
const out = [];
|
|
8005
|
+
for (const c of await walk(repo, entry, limit)) {
|
|
8006
|
+
for (const [id, { partial }] of mentionsIn(c.message, wanted)) out.push({ itemId: id, partial, ...info(c.sha, c.message, c.author, c.timestamp) });
|
|
8007
|
+
}
|
|
8008
|
+
return out;
|
|
8009
|
+
}
|
|
8010
|
+
var MAX_CHANGED_FILES = 2e3;
|
|
8011
|
+
var MAX_DIFFS = 2e4;
|
|
8012
|
+
var diffs = /* @__PURE__ */ new Map();
|
|
8013
|
+
function workTreeOf(repoPath) {
|
|
8014
|
+
try {
|
|
8015
|
+
for (let dir = path3.resolve(repoPath); ; dir = path3.dirname(dir)) {
|
|
8016
|
+
if (fs.existsSync(path3.join(dir, ".git"))) return dir;
|
|
8017
|
+
if (path3.dirname(dir) === dir) return null;
|
|
8018
|
+
}
|
|
8019
|
+
} catch {
|
|
8020
|
+
return null;
|
|
8021
|
+
}
|
|
8022
|
+
}
|
|
8023
|
+
async function diffCommit(git, gitdir, sha2, max, cache2) {
|
|
8024
|
+
let parent;
|
|
8025
|
+
try {
|
|
8026
|
+
const { commit } = await git.readCommit({ fs, gitdir, oid: sha2, cache: cache2 });
|
|
8027
|
+
parent = commit.parent[0];
|
|
8028
|
+
} catch {
|
|
8029
|
+
return null;
|
|
8030
|
+
}
|
|
8031
|
+
const files = [];
|
|
8032
|
+
let truncated = false;
|
|
8033
|
+
const trees = parent ? [git.TREE({ ref: parent }), git.TREE({ ref: sha2 })] : [git.TREE({ ref: sha2 })];
|
|
8034
|
+
try {
|
|
8035
|
+
await git.walk({
|
|
8036
|
+
fs,
|
|
8037
|
+
gitdir,
|
|
8038
|
+
cache: cache2,
|
|
8039
|
+
trees,
|
|
8040
|
+
// One child at a time, so a commit past the cap stops reading trees at once.
|
|
8041
|
+
iterate: async (walk2, children) => {
|
|
8042
|
+
const out = [];
|
|
8043
|
+
for (const child of children) {
|
|
8044
|
+
if (truncated) break;
|
|
8045
|
+
out.push(await walk2(child));
|
|
8046
|
+
}
|
|
8047
|
+
return out;
|
|
8048
|
+
},
|
|
8049
|
+
map: async (filepath, entries) => {
|
|
8050
|
+
if (filepath === ".") return true;
|
|
8051
|
+
const [a, b] = parent ? entries : [null, entries[0] ?? null];
|
|
8052
|
+
if (a && b && await a.oid() === await b.oid()) return null;
|
|
8053
|
+
const types = await Promise.all([a?.type(), b?.type()]);
|
|
8054
|
+
if (types.some((t) => t === "blob" || t === "commit")) {
|
|
8055
|
+
if (files.length >= max) {
|
|
8056
|
+
truncated = true;
|
|
8057
|
+
return null;
|
|
8058
|
+
}
|
|
8059
|
+
files.push(filepath);
|
|
8060
|
+
}
|
|
8061
|
+
return types.includes("tree") ? true : null;
|
|
8062
|
+
},
|
|
8063
|
+
reduce: async () => void 0
|
|
8064
|
+
});
|
|
8065
|
+
} catch {
|
|
8066
|
+
return null;
|
|
8067
|
+
}
|
|
8068
|
+
return { files: files.sort(), truncated };
|
|
8069
|
+
}
|
|
8070
|
+
async function changedFiles(repoPath, shas, max = MAX_CHANGED_FILES) {
|
|
8071
|
+
const out = /* @__PURE__ */ new Map();
|
|
8072
|
+
const repo = locateRepo(repoPath);
|
|
8073
|
+
if (!repo || shas.length === 0) return out;
|
|
8074
|
+
const git = await lib();
|
|
8075
|
+
const cache2 = {};
|
|
8076
|
+
for (const sha2 of new Set(shas)) {
|
|
8077
|
+
const key = `${repo.gitdir}\0${sha2}\0${max}`;
|
|
8078
|
+
let pending = diffs.get(key);
|
|
8079
|
+
if (!pending) {
|
|
8080
|
+
pending = /^[0-9a-f]{40}([0-9a-f]{24})?$/.test(sha2) ? diffCommit(git, repo.gitdir, sha2, max, cache2) : Promise.resolve(null);
|
|
8081
|
+
diffs.set(key, pending);
|
|
8082
|
+
while (diffs.size > MAX_DIFFS) diffs.delete(diffs.keys().next().value);
|
|
8083
|
+
}
|
|
8084
|
+
const found = await pending;
|
|
8085
|
+
if (found) out.set(sha2, found);
|
|
8086
|
+
else diffs.delete(key);
|
|
8087
|
+
}
|
|
8088
|
+
return out;
|
|
8089
|
+
}
|
|
8090
|
+
|
|
7772
8091
|
// ../../node_modules/.pnpm/fractional-indexing@4.0.0/node_modules/fractional-indexing/src/index.js
|
|
7773
8092
|
var BASE_62_DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
7774
8093
|
var BASE_52_DIGITS = BASE_62_DIGITS.slice(10);
|
|
@@ -8206,867 +8525,882 @@ function isUniqueViolation(err, column) {
|
|
|
8206
8525
|
return err instanceof Error && /UNIQUE constraint failed/.test(err.message) && err.message.includes(column);
|
|
8207
8526
|
}
|
|
8208
8527
|
|
|
8209
|
-
// ../core/src/services/
|
|
8210
|
-
|
|
8211
|
-
var
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
const fence = "`".repeat(longest + 1);
|
|
8222
|
-
const pad = longest > 0 || value.startsWith("`") || value.endsWith("`") ? " " : "";
|
|
8223
|
-
return `${fence}${pad}${value}${pad}${fence}`;
|
|
8224
|
-
}
|
|
8225
|
-
function oneLine(text) {
|
|
8226
|
-
return text.replace(/\s*\n\s*/g, " ");
|
|
8528
|
+
// ../core/src/services/rows.ts
|
|
8529
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
8530
|
+
var ITEM_SELECT = "SELECT i.*, p.key AS project_key FROM items i JOIN projects p ON p.id = i.project_id";
|
|
8531
|
+
function toWorkspace(row) {
|
|
8532
|
+
return {
|
|
8533
|
+
id: row.id,
|
|
8534
|
+
name: row.name,
|
|
8535
|
+
rootPath: row.root_path,
|
|
8536
|
+
createdAt: row.created_at,
|
|
8537
|
+
updatedAt: row.updated_at,
|
|
8538
|
+
missing: !existsSync3(row.root_path)
|
|
8539
|
+
};
|
|
8227
8540
|
}
|
|
8228
|
-
function
|
|
8229
|
-
return
|
|
8541
|
+
function toProject(row) {
|
|
8542
|
+
return {
|
|
8543
|
+
id: row.id,
|
|
8544
|
+
key: row.key,
|
|
8545
|
+
gitTransitions: row.git_transitions === 1,
|
|
8546
|
+
roadmapFile: row.roadmap_file,
|
|
8547
|
+
archAuto: row.arch_auto === 1,
|
|
8548
|
+
archRun: row.arch_head && row.arch_at && row.arch_state ? { state: row.arch_state, head: row.arch_head, at: row.arch_at, reason: row.arch_error } : null,
|
|
8549
|
+
workspaceId: row.workspace_id,
|
|
8550
|
+
name: row.name,
|
|
8551
|
+
path: row.path,
|
|
8552
|
+
description: row.description,
|
|
8553
|
+
milestones: JSON.parse(row.milestones),
|
|
8554
|
+
archived: row.archived === 1,
|
|
8555
|
+
createdAt: row.created_at,
|
|
8556
|
+
updatedAt: row.updated_at,
|
|
8557
|
+
missing: !existsSync3(row.path)
|
|
8558
|
+
};
|
|
8230
8559
|
}
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
if (/^[A-Za-z][A-Za-z0-9 ._/()+-]*$/.test(value) && !value.endsWith(" ") && !YAML_RESERVED.test(value)) return value;
|
|
8234
|
-
return JSON.stringify(value);
|
|
8560
|
+
function toStatus(row) {
|
|
8561
|
+
return { key: row.key, label: row.label, position: row.position, kind: row.kind, isDefault: row.is_default === 1 };
|
|
8235
8562
|
}
|
|
8236
|
-
function
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
|
|
8563
|
+
function toItem(row) {
|
|
8564
|
+
return {
|
|
8565
|
+
id: row.id,
|
|
8566
|
+
key: itemKey(row.project_key ?? null, row.number),
|
|
8567
|
+
projectId: row.project_id,
|
|
8568
|
+
title: row.title,
|
|
8569
|
+
details: row.details,
|
|
8570
|
+
status: row.status,
|
|
8571
|
+
sortKey: row.sort_key,
|
|
8572
|
+
milestone: row.milestone,
|
|
8573
|
+
priority: row.priority,
|
|
8574
|
+
tags: JSON.parse(row.tags),
|
|
8575
|
+
revision: row.revision,
|
|
8576
|
+
createdAt: row.created_at,
|
|
8577
|
+
updatedAt: row.updated_at,
|
|
8578
|
+
completedAt: row.completed_at,
|
|
8579
|
+
claim: claimOf(row)
|
|
8580
|
+
};
|
|
8245
8581
|
}
|
|
8246
|
-
function
|
|
8247
|
-
|
|
8248
|
-
const parts = [];
|
|
8249
|
-
if (item.milestone) parts.push(code(item.milestone));
|
|
8250
|
-
if (item.priority > 0) parts.push(PRIORITY[item.priority]);
|
|
8251
|
-
if (item.tags.length > 0) parts.push(item.tags.map(tag).join(" "));
|
|
8252
|
-
if (item.links.blockedBy.length > 0) parts.push(`blocked by ${byBoardOrder(item.links.blockedBy.map((l) => l.id)).map(code).join(", ")}`);
|
|
8253
|
-
if (item.links.relates.length > 0) parts.push(`relates ${byBoardOrder(item.links.relates.map((l) => l.id)).map(code).join(", ")}`);
|
|
8254
|
-
if (done && item.completedAt) parts.push(`done ${item.completedAt.slice(0, 10)}`);
|
|
8255
|
-
return parts.length > 0 ? parts.join(" \xB7 ") : null;
|
|
8582
|
+
function claimOf(row, now = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
8583
|
+
return row.claimed_by && row.claimed_until && row.claimed_until > now ? { by: row.claimed_by, until: row.claimed_until } : null;
|
|
8256
8584
|
}
|
|
8257
|
-
function
|
|
8258
|
-
|
|
8259
|
-
const meta2 = metaLine(item, order, done);
|
|
8260
|
-
if (meta2) out.push(` - ${meta2}`);
|
|
8261
|
-
for (const ref of item.refs) out.push(` - ${ref.type} ${code(ref.target)}${ref.label ? ` \u2014 ${oneLine(ref.label)}` : ""}`);
|
|
8262
|
-
if (item.details) {
|
|
8263
|
-
out.push(" <details><summary>Details</summary>", "");
|
|
8264
|
-
for (const line of item.details.split("\n")) out.push(line === "" ? "" : ` ${line}`);
|
|
8265
|
-
out.push("", DETAILS_CLOSE);
|
|
8266
|
-
}
|
|
8267
|
-
return out;
|
|
8585
|
+
function toRef(row) {
|
|
8586
|
+
return { id: row.id, itemId: row.item_id, type: row.type, target: row.target, label: row.label, createdAt: row.created_at };
|
|
8268
8587
|
}
|
|
8269
|
-
function
|
|
8270
|
-
const
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
if (board.description) out.push("", ...board.description.trim().split("\n").map((l) => l ? `> ${l}` : ">"));
|
|
8274
|
-
for (const column of board.columns) {
|
|
8275
|
-
out.push("", `## ${column.label}`);
|
|
8276
|
-
for (const item of board.items.get(column.key) ?? []) out.push("", ...itemBlock(item, order, column.kind === "done"));
|
|
8277
|
-
}
|
|
8278
|
-
return `${out.join("\n")}
|
|
8279
|
-
`;
|
|
8588
|
+
function workspaceRow(store, id) {
|
|
8589
|
+
const row = store.db.prepare("SELECT * FROM workspaces WHERE id = ?").get(id);
|
|
8590
|
+
if (!row) throw notFound("workspace", id);
|
|
8591
|
+
return row;
|
|
8280
8592
|
}
|
|
8281
|
-
function
|
|
8282
|
-
|
|
8593
|
+
function projectRow(store, id) {
|
|
8594
|
+
const row = store.db.prepare("SELECT * FROM projects WHERE id = ?").get(id);
|
|
8595
|
+
if (!row) throw notFound("project", id);
|
|
8596
|
+
return row;
|
|
8283
8597
|
}
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
external_exports.object({
|
|
8290
|
-
key: statusKeySchema,
|
|
8291
|
-
label: external_exports.string().trim().min(1).max(100),
|
|
8292
|
-
kind: statusKindSchema,
|
|
8293
|
-
default: external_exports.boolean().optional()
|
|
8294
|
-
})
|
|
8295
|
-
).min(1),
|
|
8296
|
-
milestones: external_exports.array(milestoneSchema).optional()
|
|
8297
|
-
});
|
|
8298
|
-
function readCodeSpan(s, i) {
|
|
8299
|
-
let n = 0;
|
|
8300
|
-
while (s[i + n] === "`") n++;
|
|
8301
|
-
if (n === 0) return null;
|
|
8302
|
-
const fence = "`".repeat(n);
|
|
8303
|
-
let j = i + n;
|
|
8304
|
-
for (; ; ) {
|
|
8305
|
-
const close = s.indexOf(fence, j);
|
|
8306
|
-
if (close < 0) return null;
|
|
8307
|
-
if (s[close + n] === "`" || s[close - 1] === "`") {
|
|
8308
|
-
j = close + n;
|
|
8309
|
-
while (s[j] === "`") j++;
|
|
8310
|
-
continue;
|
|
8311
|
-
}
|
|
8312
|
-
let value = s.slice(i + n, close);
|
|
8313
|
-
if (value.length > 1 && value.startsWith(" ") && value.endsWith(" ") && value.trim() !== "") value = value.slice(1, -1);
|
|
8314
|
-
return { value, end: close + n };
|
|
8315
|
-
}
|
|
8598
|
+
function itemRow(store, ref) {
|
|
8599
|
+
const id = resolveItemId(store, ref);
|
|
8600
|
+
const row = store.db.prepare(`${ITEM_SELECT} WHERE i.id = ?`).get(id);
|
|
8601
|
+
if (!row) throw notFound("item", id);
|
|
8602
|
+
return row;
|
|
8316
8603
|
}
|
|
8317
|
-
function
|
|
8318
|
-
const
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
while (i < s.length) {
|
|
8322
|
-
if (s[i] === "`") {
|
|
8323
|
-
const span = readCodeSpan(s, i);
|
|
8324
|
-
if (span) {
|
|
8325
|
-
i = span.end;
|
|
8326
|
-
continue;
|
|
8327
|
-
}
|
|
8328
|
-
}
|
|
8329
|
-
if (s.startsWith(" \xB7 ", i)) {
|
|
8330
|
-
parts.push(s.slice(start, i));
|
|
8331
|
-
i += 3;
|
|
8332
|
-
start = i;
|
|
8333
|
-
continue;
|
|
8334
|
-
}
|
|
8335
|
-
i++;
|
|
8336
|
-
}
|
|
8337
|
-
parts.push(s.slice(start));
|
|
8338
|
-
return parts.map((p) => p.trim()).filter((p) => p !== "");
|
|
8604
|
+
function refRow(store, id) {
|
|
8605
|
+
const row = store.db.prepare("SELECT * FROM refs WHERE id = ?").get(id);
|
|
8606
|
+
if (!row) throw notFound("ref", id);
|
|
8607
|
+
return row;
|
|
8339
8608
|
}
|
|
8340
|
-
function
|
|
8341
|
-
|
|
8342
|
-
return span && span.end === s.length ? span.value : null;
|
|
8609
|
+
function hasOwnStatuses(store, projectId) {
|
|
8610
|
+
return store.db.prepare("SELECT 1 FROM statuses WHERE scope_type = 'project' AND scope_id = ? LIMIT 1").get(projectId) !== void 0;
|
|
8343
8611
|
}
|
|
8344
|
-
function
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
const id = wholeCodeSpan(raw) ?? raw;
|
|
8348
|
-
if (!/^[A-Za-z0-9_-]+$/.test(id)) fail(line, `'${raw}' is not an item id`);
|
|
8349
|
-
return id;
|
|
8350
|
-
});
|
|
8612
|
+
function scopeStatuses(store, scopeType, scopeId) {
|
|
8613
|
+
const rows = store.db.prepare("SELECT key, label, position, kind, is_default FROM statuses WHERE scope_type = ? AND scope_id = ? ORDER BY position").all(scopeType, scopeId);
|
|
8614
|
+
return rows.map(toStatus);
|
|
8351
8615
|
}
|
|
8352
|
-
function
|
|
8353
|
-
const
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
if (s[i] === " ") {
|
|
8357
|
-
i++;
|
|
8358
|
-
continue;
|
|
8359
|
-
}
|
|
8360
|
-
if (s[i] !== "#") fail(line, `expected a #tag, found '${s.slice(i)}'`);
|
|
8361
|
-
i++;
|
|
8362
|
-
const span = s[i] === "`" ? readCodeSpan(s, i) : null;
|
|
8363
|
-
if (span) {
|
|
8364
|
-
tags.push(span.value);
|
|
8365
|
-
i = span.end;
|
|
8366
|
-
continue;
|
|
8367
|
-
}
|
|
8368
|
-
const end = s.indexOf(" ", i) < 0 ? s.length : s.indexOf(" ", i);
|
|
8369
|
-
const value = s.slice(i, end);
|
|
8370
|
-
if (!value) fail(line, "empty #tag");
|
|
8371
|
-
tags.push(value);
|
|
8372
|
-
i = end;
|
|
8373
|
-
}
|
|
8374
|
-
return tags;
|
|
8616
|
+
function effectiveStatuses(store, projectId) {
|
|
8617
|
+
const own = scopeStatuses(store, "project", projectId);
|
|
8618
|
+
if (own.length > 0) return own;
|
|
8619
|
+
return scopeStatuses(store, "workspace", projectRow(store, projectId).workspace_id);
|
|
8375
8620
|
}
|
|
8376
|
-
function
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
if (item.milestone !== null) fail(line, "an item has one milestone");
|
|
8381
|
-
item.milestone = milestone;
|
|
8382
|
-
} else if (PRIORITY.includes(part) && part !== "") {
|
|
8383
|
-
item.priority = PRIORITY.indexOf(part);
|
|
8384
|
-
} else if (part.startsWith("#")) {
|
|
8385
|
-
item.tags.push(...tagList(part, line));
|
|
8386
|
-
} else if (part.startsWith("blocked by ")) {
|
|
8387
|
-
item.blockedBy.push(...idList(part.slice("blocked by ".length), line));
|
|
8388
|
-
} else if (part.startsWith("relates ")) {
|
|
8389
|
-
item.relates.push(...idList(part.slice("relates ".length), line));
|
|
8390
|
-
} else if (part.startsWith("done ") && DATE.test(part.slice(5))) {
|
|
8391
|
-
item.completedOn = part.slice(5);
|
|
8392
|
-
} else {
|
|
8393
|
-
fail(line, `unknown metadata '${part}'; expected \`milestone\`, low|medium|high, #tags, 'blocked by', 'relates' or 'done YYYY-MM-DD'`);
|
|
8394
|
-
}
|
|
8621
|
+
function requireStatus(statuses, key) {
|
|
8622
|
+
const status = statuses.find((s) => s.key === key);
|
|
8623
|
+
if (!status) {
|
|
8624
|
+
throw new SlateError("invalid_argument", `unknown status '${key}'`, { valid: statuses.map((s) => s.key) });
|
|
8395
8625
|
}
|
|
8626
|
+
return status;
|
|
8396
8627
|
}
|
|
8397
|
-
function
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8628
|
+
function isBlocked(store, itemId) {
|
|
8629
|
+
return store.db.prepare(
|
|
8630
|
+
`SELECT 1 FROM item_links l JOIN items b ON b.id = l.from_id
|
|
8631
|
+
WHERE l.to_id = ? AND l.kind = 'blocks' AND b.completed_at IS NULL LIMIT 1`
|
|
8632
|
+
).get(itemId) !== void 0;
|
|
8402
8633
|
}
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
}
|
|
8411
|
-
|
|
8634
|
+
|
|
8635
|
+
// ../core/src/services/arch-auto.ts
|
|
8636
|
+
function createArchAutoService(ctx) {
|
|
8637
|
+
const { store } = ctx;
|
|
8638
|
+
const db = store.db;
|
|
8639
|
+
function enabled() {
|
|
8640
|
+
return db.prepare("SELECT id FROM projects WHERE arch_auto = 1 AND archived = 0 ORDER BY name").all().map((r) => r.id);
|
|
8641
|
+
}
|
|
8642
|
+
async function due(projectId) {
|
|
8643
|
+
const row = projectRow(store, parse(idSchema, projectId));
|
|
8644
|
+
if (row.arch_auto !== 1 || row.archived === 1 || !existsSync4(row.path)) return null;
|
|
8645
|
+
const head = await headCommit(row.path);
|
|
8646
|
+
return head && head !== row.arch_head ? head : null;
|
|
8647
|
+
}
|
|
8648
|
+
function record(projectId, head, result, since) {
|
|
8649
|
+
const row = projectRow(store, parse(idSchema, projectId));
|
|
8650
|
+
if (row.arch_auto !== 1 || row.arch_head !== since) return false;
|
|
8651
|
+
db.prepare("UPDATE projects SET arch_head = ?, arch_at = ?, arch_state = ?, arch_error = ? WHERE id = ?").run(head, ctx.now(), result.state, result.reason, projectId);
|
|
8652
|
+
ctx.emit("project.updated", { workspaceId: row.workspace_id, projectId, id: projectId });
|
|
8653
|
+
return true;
|
|
8412
8654
|
}
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
const issue = result.error.issues[0];
|
|
8416
|
-
fail(1, `frontmatter ${issue.path.join(".") || "root"}: ${issue.message}`);
|
|
8655
|
+
function lastHead(projectId) {
|
|
8656
|
+
return projectRow(store, parse(idSchema, projectId)).arch_head;
|
|
8417
8657
|
}
|
|
8418
|
-
return {
|
|
8419
|
-
}
|
|
8420
|
-
function parseBoard(text) {
|
|
8421
|
-
const lines = text.replace(/\r\n/g, "\n").split("\n");
|
|
8422
|
-
const { meta: meta2, next } = parseFrontmatter(lines);
|
|
8423
|
-
const columns = meta2.columns.map((c) => ({ key: c.key, label: c.label, kind: c.kind, isDefault: c.default === true }));
|
|
8424
|
-
if (new Set(columns.map((c) => c.key)).size !== columns.length) fail(1, "column keys must be unique");
|
|
8425
|
-
if (new Set(columns.map((c) => c.label)).size !== columns.length) fail(1, "column labels must be unique");
|
|
8426
|
-
if (columns.filter((c) => c.isDefault).length !== 1) fail(1, "exactly one column must be 'default: true'");
|
|
8427
|
-
const byLabel = new Map(columns.map((c) => [c.label, c]));
|
|
8428
|
-
const sections = [];
|
|
8429
|
-
const seenIds = /* @__PURE__ */ new Map();
|
|
8430
|
-
let section = null;
|
|
8431
|
-
let item = null;
|
|
8432
|
-
for (let i = next; i < lines.length; i++) {
|
|
8433
|
-
const text2 = lines[i];
|
|
8434
|
-
const lineNo = i + 1;
|
|
8435
|
-
if (text2.trim() === "") continue;
|
|
8436
|
-
if (text2.startsWith("## ")) {
|
|
8437
|
-
const label = text2.slice(3).trim();
|
|
8438
|
-
const column = byLabel.get(label);
|
|
8439
|
-
if (!column) fail(lineNo, `'${label}' is not a column in the frontmatter (${columns.map((c) => c.label).join(", ")})`);
|
|
8440
|
-
if (sections.some((s) => s.column.key === column.key)) fail(lineNo, `column '${label}' appears twice`);
|
|
8441
|
-
section = { line: lineNo, column, items: [] };
|
|
8442
|
-
sections.push(section);
|
|
8443
|
-
item = null;
|
|
8444
|
-
continue;
|
|
8445
|
-
}
|
|
8446
|
-
const itemMatch = ITEM_LINE.exec(text2);
|
|
8447
|
-
if (itemMatch) {
|
|
8448
|
-
if (!section) fail(lineNo, "an item must be under a '## Column' heading");
|
|
8449
|
-
let rest = itemMatch[2];
|
|
8450
|
-
let id = null;
|
|
8451
|
-
let revision = null;
|
|
8452
|
-
const anchor = ITEM_ANCHOR.exec(rest);
|
|
8453
|
-
if (anchor) {
|
|
8454
|
-
id = anchor[1];
|
|
8455
|
-
revision = Number(anchor[2]);
|
|
8456
|
-
rest = rest.slice(0, anchor.index);
|
|
8457
|
-
if (seenIds.has(id)) fail(lineNo, `item ${id} also appears on line ${seenIds.get(id)}`);
|
|
8458
|
-
seenIds.set(id, lineNo);
|
|
8459
|
-
const shown = `${code(id)} `;
|
|
8460
|
-
if (rest.startsWith(shown)) rest = rest.slice(shown.length);
|
|
8461
|
-
}
|
|
8462
|
-
const title = rest.trim();
|
|
8463
|
-
if (!title) fail(lineNo, "an item needs a title");
|
|
8464
|
-
item = {
|
|
8465
|
-
line: lineNo,
|
|
8466
|
-
id,
|
|
8467
|
-
revision,
|
|
8468
|
-
checked: itemMatch[1] !== " ",
|
|
8469
|
-
title,
|
|
8470
|
-
details: null,
|
|
8471
|
-
milestone: null,
|
|
8472
|
-
priority: 0,
|
|
8473
|
-
tags: [],
|
|
8474
|
-
blockedBy: [],
|
|
8475
|
-
relates: [],
|
|
8476
|
-
refs: [],
|
|
8477
|
-
completedOn: null
|
|
8478
|
-
};
|
|
8479
|
-
section.items.push(item);
|
|
8480
|
-
continue;
|
|
8481
|
-
}
|
|
8482
|
-
if (!text2.startsWith(" ")) {
|
|
8483
|
-
if (/^[-*+] /.test(text2)) fail(lineNo, "not an item line; items look like '- [ ] Title'");
|
|
8484
|
-
continue;
|
|
8485
|
-
}
|
|
8486
|
-
if (!item) fail(lineNo, "indented line outside an item");
|
|
8487
|
-
if (DETAILS_OPEN.test(text2)) {
|
|
8488
|
-
let end = i + 1;
|
|
8489
|
-
while (end < lines.length && (lines[end] === "" || lines[end].startsWith(" "))) end++;
|
|
8490
|
-
let close = -1;
|
|
8491
|
-
for (let j = end - 1; j > i; j--) {
|
|
8492
|
-
if (lines[j] === DETAILS_CLOSE) {
|
|
8493
|
-
close = j;
|
|
8494
|
-
break;
|
|
8495
|
-
}
|
|
8496
|
-
}
|
|
8497
|
-
if (close < 0) fail(lineNo, "<details> is not closed with an indented </details>");
|
|
8498
|
-
let body = lines.slice(i + 1, close);
|
|
8499
|
-
if (body[0] === "") body = body.slice(1);
|
|
8500
|
-
if (body.at(-1) === "") body = body.slice(0, -1);
|
|
8501
|
-
const details = body.map((l) => l.replace(/^ {1,2}/, "")).join("\n");
|
|
8502
|
-
item.details = details === "" ? null : details;
|
|
8503
|
-
for (let j = close + 1; j < end; j++) if (lines[j].trim() !== "") fail(j + 1, "unexpected text after </details>");
|
|
8504
|
-
i = end - 1;
|
|
8505
|
-
continue;
|
|
8506
|
-
}
|
|
8507
|
-
if (!text2.startsWith(" - ")) fail(lineNo, "expected ' - ' metadata, a ref, or <details>");
|
|
8508
|
-
if (item.details !== null) fail(lineNo, "metadata and refs go before <details>");
|
|
8509
|
-
const sub = text2.slice(2);
|
|
8510
|
-
const ref = REF_LINE.exec(sub);
|
|
8511
|
-
if (ref) {
|
|
8512
|
-
item.refs.push(parseRef(ref[1], ref[2], lineNo));
|
|
8513
|
-
continue;
|
|
8514
|
-
}
|
|
8515
|
-
applyMeta(item, sub.slice(2), lineNo);
|
|
8516
|
-
}
|
|
8517
|
-
return {
|
|
8518
|
-
project: meta2.project ?? null,
|
|
8519
|
-
description: meta2.description,
|
|
8520
|
-
columns,
|
|
8521
|
-
milestones: meta2.milestones ?? [],
|
|
8522
|
-
sections
|
|
8523
|
-
};
|
|
8658
|
+
return { enabled, due, record, lastHead };
|
|
8524
8659
|
}
|
|
8525
8660
|
|
|
8526
|
-
// ../core/src/services/
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8661
|
+
// ../core/src/services/architecture.ts
|
|
8662
|
+
import { existsSync as existsSync6, readFileSync as readFileSync3, readdirSync as readdirSync2, realpathSync as realpathSync2, statSync as statSync2, watch } from "node:fs";
|
|
8663
|
+
import path5 from "node:path";
|
|
8664
|
+
|
|
8665
|
+
// ../core/src/services/refs.ts
|
|
8666
|
+
import { existsSync as existsSync5, readFileSync as readFileSync2, statSync } from "node:fs";
|
|
8667
|
+
import path4 from "node:path";
|
|
8668
|
+
var MAX_REF_BYTES = 256 * 1024;
|
|
8669
|
+
var MAX_WORKSPACE_REPOS = 25;
|
|
8670
|
+
function sandboxError(target, root) {
|
|
8671
|
+
return new SlateError("sandbox", `${target} is outside the project root ${root}`, { target, root });
|
|
8530
8672
|
}
|
|
8531
|
-
function
|
|
8532
|
-
|
|
8673
|
+
function resolveInside(root, target) {
|
|
8674
|
+
const abs = path4.resolve(root, expandHome(target));
|
|
8675
|
+
if (!isInside(abs, root)) throw sandboxError(target, root);
|
|
8676
|
+
if (!isInside(normalizePath(abs), normalizePath(root))) throw sandboxError(target, root);
|
|
8677
|
+
return abs;
|
|
8533
8678
|
}
|
|
8534
|
-
|
|
8535
|
-
|
|
8679
|
+
var LINE_SUFFIX = /#L(\d+)(?:-L?(\d+))?$/;
|
|
8680
|
+
var LINE_LIKE = /#L\d[^#/]*$/;
|
|
8681
|
+
function splitFileTarget(target) {
|
|
8682
|
+
const m = LINE_SUFFIX.exec(target);
|
|
8683
|
+
if (!m) {
|
|
8684
|
+
if (LINE_LIKE.test(target)) throw invalid(`not a line range: ${target.slice(target.lastIndexOf("#"))}; use #L40 or #L40-80`);
|
|
8685
|
+
return { path: target, lines: null };
|
|
8686
|
+
}
|
|
8687
|
+
const start = Number(m[1]);
|
|
8688
|
+
const end = m[2] === void 0 ? start : Number(m[2]);
|
|
8689
|
+
if (start < 1) throw invalid(`line numbers start at 1: ${target}`);
|
|
8690
|
+
if (end < start) throw invalid(`a line range ends at or after its start: ${target}`);
|
|
8691
|
+
return { path: target.slice(0, m.index), lines: { start, end } };
|
|
8536
8692
|
}
|
|
8537
|
-
function
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
if (item.priority > 0) parts.push(`priority ${PRIORITY2[item.priority]}`);
|
|
8541
|
-
if (item.tags.length > 0) parts.push(item.tags.map((t) => `#${t}`).join(" "));
|
|
8542
|
-
if (item.blocked) parts.push("**blocked**");
|
|
8543
|
-
if (item.completedAt) parts.push(`completed ${item.completedAt}`);
|
|
8544
|
-
return parts.join(" \xB7 ");
|
|
8693
|
+
function lineSuffix(lines) {
|
|
8694
|
+
if (!lines) return "";
|
|
8695
|
+
return lines.end === lines.start ? `#L${lines.start}` : `#L${lines.start}-${lines.end}`;
|
|
8545
8696
|
}
|
|
8546
|
-
function
|
|
8547
|
-
|
|
8548
|
-
if (item.details) out.push("", item.details.trim());
|
|
8549
|
-
if (item.links.blockedBy.length > 0) out.push("", `Blocked by: ${linked(item.links.blockedBy)}`);
|
|
8550
|
-
if (item.links.blocks.length > 0) out.push("", `Blocks: ${linked(item.links.blocks)}`);
|
|
8551
|
-
if (item.links.relates.length > 0) out.push("", `Related: ${linked(item.links.relates)}`);
|
|
8552
|
-
if (item.refs.length > 0) out.push("", "Refs:", ...item.refs.map(refLine));
|
|
8553
|
-
return out.join("\n");
|
|
8697
|
+
function splitLines(text) {
|
|
8698
|
+
return text === "" ? [] : text.split(/(?<=\n)/);
|
|
8554
8699
|
}
|
|
8555
|
-
function
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8700
|
+
function normalizeTarget(type, target, root) {
|
|
8701
|
+
switch (type) {
|
|
8702
|
+
case "file": {
|
|
8703
|
+
const { path: file, lines } = splitFileTarget(target);
|
|
8704
|
+
const rel = path4.relative(root, resolveInside(root, file));
|
|
8705
|
+
if (rel === "") throw invalid("a file ref must point at a file inside the project, not the project root");
|
|
8706
|
+
return rel.split(path4.sep).join("/") + lineSuffix(lines);
|
|
8707
|
+
}
|
|
8708
|
+
case "url": {
|
|
8709
|
+
let url;
|
|
8710
|
+
try {
|
|
8711
|
+
url = new URL(target);
|
|
8712
|
+
} catch {
|
|
8713
|
+
throw invalid(`not a valid URL: ${target}`);
|
|
8714
|
+
}
|
|
8715
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") throw invalid("url refs must be http or https");
|
|
8716
|
+
return url.toString();
|
|
8717
|
+
}
|
|
8718
|
+
case "commit":
|
|
8719
|
+
if (!/^[0-9a-f]{4,64}$/i.test(target)) throw invalid(`not a commit sha: ${target}`);
|
|
8720
|
+
return target.toLowerCase();
|
|
8721
|
+
case "pr": {
|
|
8722
|
+
const n = /^#?(\d+)$/.exec(target);
|
|
8723
|
+
if (n) return n[1];
|
|
8724
|
+
if (/^https?:\/\//.test(target)) return normalizeTarget("url", target, root);
|
|
8725
|
+
throw invalid(`a pr ref is a number or a URL: ${target}`);
|
|
8565
8726
|
}
|
|
8566
|
-
return out;
|
|
8567
|
-
}
|
|
8568
|
-
function project(projectId) {
|
|
8569
|
-
const detail = projects.get(parse(idSchema, projectId));
|
|
8570
|
-
const board = items.board({ projectId: detail.id, includeDone: true });
|
|
8571
|
-
return renderBoard({
|
|
8572
|
-
name: detail.name,
|
|
8573
|
-
description: detail.description,
|
|
8574
|
-
milestones: detail.milestones,
|
|
8575
|
-
columns: detail.statuses,
|
|
8576
|
-
items: new Map(board.columns.map((c) => [c.key, c.items.map((summary) => items.get(summary.id))]))
|
|
8577
|
-
});
|
|
8578
|
-
}
|
|
8579
|
-
function workspace(workspaceId) {
|
|
8580
|
-
const ws = workspaces.get(parse(idSchema, workspaceId));
|
|
8581
|
-
const out = [heading(1, ws.name), "", `Root: \`${ws.rootPath}\`${ws.missing ? " (missing)" : ""}`];
|
|
8582
|
-
for (const p of projects.list({ workspaceId: ws.id })) out.push("", ...projectBody(p, 2));
|
|
8583
|
-
return `${out.join("\n")}
|
|
8584
|
-
`;
|
|
8585
|
-
}
|
|
8586
|
-
function item(itemId) {
|
|
8587
|
-
return `${itemMarkdown(items.get(itemId))}
|
|
8588
|
-
`;
|
|
8589
8727
|
}
|
|
8590
|
-
return { project, workspace, item };
|
|
8591
|
-
}
|
|
8592
|
-
|
|
8593
|
-
// ../core/src/services/roadmap-file.ts
|
|
8594
|
-
import { createHash } from "node:crypto";
|
|
8595
|
-
import { existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "node:fs";
|
|
8596
|
-
import path5 from "node:path";
|
|
8597
|
-
|
|
8598
|
-
// ../core/src/services/refs.ts
|
|
8599
|
-
import { existsSync as existsSync4, readFileSync as readFileSync2, statSync } from "node:fs";
|
|
8600
|
-
import path4 from "node:path";
|
|
8601
|
-
|
|
8602
|
-
// ../core/src/git.ts
|
|
8603
|
-
import fs from "node:fs";
|
|
8604
|
-
import path3 from "node:path";
|
|
8605
|
-
var loaded;
|
|
8606
|
-
var lib = () => loaded ??= import("./isomorphic-git-BZUKICXS.js").then((m) => "log" in m ? m : m.default);
|
|
8607
|
-
var GIT_CACHE_TTL_MS = 15e3;
|
|
8608
|
-
var DEFAULT_COMMIT_SCAN = 500;
|
|
8609
|
-
var MAX_COMMIT_SCAN = 5e3;
|
|
8610
|
-
var SHORT = 7;
|
|
8611
|
-
var cache = /* @__PURE__ */ new Map();
|
|
8612
|
-
function clearGitCache() {
|
|
8613
|
-
cache.clear();
|
|
8614
8728
|
}
|
|
8615
|
-
function
|
|
8729
|
+
function looksBinary(buf) {
|
|
8730
|
+
if (buf.subarray(0, 8192).includes(0)) return true;
|
|
8616
8731
|
try {
|
|
8617
|
-
|
|
8618
|
-
} catch {
|
|
8732
|
+
new TextDecoder("utf-8", { fatal: true }).decode(buf);
|
|
8619
8733
|
return false;
|
|
8620
|
-
}
|
|
8621
|
-
}
|
|
8622
|
-
function isFile(p) {
|
|
8623
|
-
try {
|
|
8624
|
-
return fs.statSync(p).isFile();
|
|
8625
8734
|
} catch {
|
|
8626
|
-
return
|
|
8735
|
+
return true;
|
|
8627
8736
|
}
|
|
8628
8737
|
}
|
|
8629
|
-
function
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
function
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8738
|
+
function createRefService(ctx) {
|
|
8739
|
+
const { store } = ctx;
|
|
8740
|
+
const db = store.db;
|
|
8741
|
+
function owner(itemId) {
|
|
8742
|
+
const item = itemRow(store, itemId);
|
|
8743
|
+
const project = projectRow(store, item.project_id);
|
|
8744
|
+
return { item, project };
|
|
8745
|
+
}
|
|
8746
|
+
function add(input, createdAt) {
|
|
8747
|
+
const { itemId: ref, type, target, label } = parse(refAddSchema, input);
|
|
8748
|
+
return store.tx(() => {
|
|
8749
|
+
const { item, project } = owner(ref);
|
|
8750
|
+
const itemId = item.id;
|
|
8751
|
+
const id = ctx.newId();
|
|
8752
|
+
db.prepare("INSERT INTO refs (id, item_id, type, target, label, created_at) VALUES (?, ?, ?, ?, ?, ?)").run(
|
|
8753
|
+
id,
|
|
8754
|
+
itemId,
|
|
8755
|
+
type,
|
|
8756
|
+
normalizeTarget(type, target, project.path),
|
|
8757
|
+
label ?? null,
|
|
8758
|
+
createdAt ?? ctx.now()
|
|
8759
|
+
);
|
|
8760
|
+
ctx.emit("ref.added", { workspaceId: project.workspace_id, projectId: project.id, id });
|
|
8761
|
+
return toRef(refRow(store, id));
|
|
8762
|
+
});
|
|
8763
|
+
}
|
|
8764
|
+
function remove(refId) {
|
|
8765
|
+
parse(idSchema, refId);
|
|
8766
|
+
store.tx(() => {
|
|
8767
|
+
const ref = refRow(store, refId);
|
|
8768
|
+
const { project } = owner(ref.item_id);
|
|
8769
|
+
db.prepare("DELETE FROM refs WHERE id = ?").run(refId);
|
|
8770
|
+
ctx.emit("ref.removed", { workspaceId: project.workspace_id, projectId: project.id, id: refId });
|
|
8771
|
+
});
|
|
8772
|
+
}
|
|
8773
|
+
function forItem(itemId) {
|
|
8774
|
+
return db.prepare("SELECT * FROM refs WHERE item_id = ? ORDER BY created_at, id").all(itemId).map(toRef);
|
|
8775
|
+
}
|
|
8776
|
+
function commitSources(project) {
|
|
8777
|
+
const own = { id: project.id, name: project.name, path: project.path };
|
|
8778
|
+
const others = db.prepare("SELECT * FROM projects WHERE workspace_id = ? AND id <> ? ORDER BY name, id").all(project.workspace_id, project.id);
|
|
8779
|
+
if (others.length === 0) return [own];
|
|
8780
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8781
|
+
const ownRepo = locateRepo(project.path);
|
|
8782
|
+
if (ownRepo) seen.add(ownRepo.gitdir);
|
|
8783
|
+
const out = [own];
|
|
8784
|
+
for (const p of others) {
|
|
8785
|
+
if (out.length >= MAX_WORKSPACE_REPOS) break;
|
|
8786
|
+
const repo = locateRepo(p.path);
|
|
8787
|
+
if (!repo || seen.has(repo.gitdir)) continue;
|
|
8788
|
+
seen.add(repo.gitdir);
|
|
8789
|
+
out.push({ id: p.id, name: p.name, path: p.path });
|
|
8790
|
+
}
|
|
8791
|
+
return out;
|
|
8792
|
+
}
|
|
8793
|
+
function sourcesForItem(itemId) {
|
|
8794
|
+
return commitSources(owner(itemId).project);
|
|
8795
|
+
}
|
|
8796
|
+
async function findCommit(sources, sha2) {
|
|
8797
|
+
for (const source of sources) {
|
|
8798
|
+
const found = await resolveCommit(source.path, sha2);
|
|
8799
|
+
if (found) return { ...found, projectId: source.id, projectName: source.name, projectPath: source.path };
|
|
8800
|
+
}
|
|
8647
8801
|
return null;
|
|
8648
8802
|
}
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
}
|
|
8803
|
+
async function resolveForItem(ref) {
|
|
8804
|
+
const itemId = itemRow(store, parse(idSchema, ref)).id;
|
|
8805
|
+
return resolve(sourcesForItem(itemId), forItem(itemId));
|
|
8806
|
+
}
|
|
8807
|
+
async function resolve(sources, list) {
|
|
8808
|
+
return Promise.all(list.map(async (ref) => ref.type === "commit" ? { ...ref, commit: await findCommit(sources, ref.target) } : ref));
|
|
8809
|
+
}
|
|
8810
|
+
function read(refId, options = {}) {
|
|
8811
|
+
const ref = toRef(refRow(store, parse(idSchema, refId)));
|
|
8812
|
+
if (ref.type !== "file") throw invalid(`ref ${refId} is a ${ref.type} ref; only file refs can be read`);
|
|
8813
|
+
const { project } = owner(ref.itemId);
|
|
8814
|
+
const target = splitFileTarget(ref.target);
|
|
8815
|
+
const abs = resolveInside(project.path, target.path);
|
|
8816
|
+
if (!existsSync5(abs)) return { ref, path: abs, state: "missing" };
|
|
8817
|
+
const stat = statSync(abs);
|
|
8818
|
+
if (!stat.isFile()) throw invalid(`${target.path} is not a regular file`);
|
|
8819
|
+
if (stat.size > MAX_REF_BYTES) {
|
|
8820
|
+
throw new SlateError("too_large", `${target.path} is ${stat.size} bytes; the limit is ${MAX_REF_BYTES}`, {
|
|
8821
|
+
size: stat.size,
|
|
8822
|
+
limit: MAX_REF_BYTES
|
|
8823
|
+
});
|
|
8660
8824
|
}
|
|
8825
|
+
const buf = readFileSync2(abs);
|
|
8826
|
+
if (looksBinary(buf)) return { ref, path: abs, state: "binary", size: buf.length };
|
|
8827
|
+
const content = buf.toString("utf8");
|
|
8828
|
+
if (!target.lines) return { ref, path: abs, state: "ok", size: buf.length, content };
|
|
8829
|
+
const all = splitLines(content);
|
|
8830
|
+
const lines = { ...target.lines, total: all.length };
|
|
8831
|
+
if (options.full) return { ref, path: abs, state: "ok", size: buf.length, content, lines };
|
|
8832
|
+
return { ref, path: abs, state: "ok", size: buf.length, content: all.slice(lines.start - 1, lines.end).join(""), lines };
|
|
8661
8833
|
}
|
|
8662
|
-
return
|
|
8834
|
+
return { add, remove, read, forItem, resolveForItem, resolve, commitSources, sourcesForItem, findCommit };
|
|
8663
8835
|
}
|
|
8664
|
-
|
|
8665
|
-
|
|
8836
|
+
|
|
8837
|
+
// ../core/src/services/architecture.ts
|
|
8838
|
+
var ARCHITECTURE_DIR = "docs/architecture";
|
|
8839
|
+
var MAX_ARCHITECTURE_VIEWS = 50;
|
|
8840
|
+
var MAX_ARCHITECTURE_WATCHES = 32;
|
|
8841
|
+
var MAX_MODEL_BYTES = 8 * 1024 * 1024;
|
|
8842
|
+
var ARCHITECTURE_DEBOUNCE_MS = 200;
|
|
8843
|
+
var NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
8844
|
+
var ORDER = ["system", "packages", "components"];
|
|
8845
|
+
var rank = (name) => {
|
|
8846
|
+
const i = ORDER.indexOf(name);
|
|
8847
|
+
return i >= 0 ? i : name.startsWith("flow-") ? ORDER.length : ORDER.length + 1;
|
|
8848
|
+
};
|
|
8849
|
+
function titleOf(markdown, name) {
|
|
8850
|
+
const m = /^#[ \t]+(.+?)[ \t#]*$/m.exec(markdown);
|
|
8851
|
+
return m ? m[1].trim() : name;
|
|
8666
8852
|
}
|
|
8667
|
-
function
|
|
8853
|
+
function directoryOf(root) {
|
|
8854
|
+
const dir = path5.join(root, ARCHITECTURE_DIR);
|
|
8855
|
+
if (!existsSync6(dir)) return null;
|
|
8668
8856
|
try {
|
|
8669
|
-
const
|
|
8670
|
-
if (!
|
|
8671
|
-
|
|
8672
|
-
const bare = valid({ gitdir: start, headDir: start });
|
|
8673
|
-
if (bare) return bare;
|
|
8674
|
-
}
|
|
8675
|
-
for (let dir = start; ; dir = path3.dirname(dir)) {
|
|
8676
|
-
const dotgit = path3.join(dir, ".git");
|
|
8677
|
-
let stat;
|
|
8678
|
-
try {
|
|
8679
|
-
stat = fs.statSync(dotgit);
|
|
8680
|
-
} catch {
|
|
8681
|
-
stat = void 0;
|
|
8682
|
-
}
|
|
8683
|
-
if (stat?.isDirectory()) return valid({ gitdir: dotgit, headDir: dotgit });
|
|
8684
|
-
if (stat?.isFile()) return fromGitFile(dotgit);
|
|
8685
|
-
if (path3.dirname(dir) === dir) return null;
|
|
8686
|
-
}
|
|
8857
|
+
const real = realpathSync2.native(dir);
|
|
8858
|
+
if (!isInside(real, realpathSync2.native(root)) || !statSync2(real).isDirectory()) return null;
|
|
8859
|
+
return real;
|
|
8687
8860
|
} catch {
|
|
8688
8861
|
return null;
|
|
8689
8862
|
}
|
|
8690
8863
|
}
|
|
8691
|
-
|
|
8692
|
-
|
|
8864
|
+
function fileOf(dir, name) {
|
|
8865
|
+
if (!NAME.test(name)) return null;
|
|
8866
|
+
const candidate = path5.join(dir, `${name}.md`);
|
|
8693
8867
|
try {
|
|
8694
|
-
|
|
8868
|
+
const real = realpathSync2.native(candidate);
|
|
8869
|
+
if (path5.dirname(real) !== dir) return null;
|
|
8870
|
+
const stat = statSync2(real);
|
|
8871
|
+
if (!stat.isFile()) return null;
|
|
8872
|
+
return { abs: real, size: stat.size, mtime: stat.mtime };
|
|
8695
8873
|
} catch {
|
|
8696
8874
|
return null;
|
|
8697
8875
|
}
|
|
8698
|
-
const symbolic = /^ref:\s*(\S+)$/.exec(head);
|
|
8699
|
-
if (!symbolic) return /^[0-9a-f]{40}([0-9a-f]{24})?$/.test(head) ? head : null;
|
|
8700
|
-
const git = await lib();
|
|
8701
|
-
return git.resolveRef({ fs, gitdir: repo.gitdir, ref: symbolic[1] }).catch(() => null);
|
|
8702
|
-
}
|
|
8703
|
-
async function entryFor(repo) {
|
|
8704
|
-
const head = await headOf(repo);
|
|
8705
|
-
if (!head) return null;
|
|
8706
|
-
const now = Date.now();
|
|
8707
|
-
const existing = cache.get(repo.gitdir);
|
|
8708
|
-
if (existing && existing.head === head && now - existing.at < GIT_CACHE_TTL_MS) return existing;
|
|
8709
|
-
const entry = { head, at: now, walks: /* @__PURE__ */ new Map(), shas: /* @__PURE__ */ new Map() };
|
|
8710
|
-
cache.set(repo.gitdir, entry);
|
|
8711
|
-
return entry;
|
|
8712
|
-
}
|
|
8713
|
-
function info(sha2, message, author, timestamp) {
|
|
8714
|
-
return {
|
|
8715
|
-
sha: sha2,
|
|
8716
|
-
shortSha: sha2.slice(0, SHORT),
|
|
8717
|
-
subject: message.split("\n", 1)[0].trim(),
|
|
8718
|
-
author,
|
|
8719
|
-
date: new Date(timestamp * 1e3).toISOString()
|
|
8720
|
-
};
|
|
8721
8876
|
}
|
|
8722
|
-
|
|
8723
|
-
const
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
const entry = await entryFor(repo);
|
|
8728
|
-
const lookup = async () => {
|
|
8729
|
-
const git = await lib();
|
|
8730
|
-
try {
|
|
8731
|
-
const oid = wanted.length >= 40 ? wanted : await git.expandOid({ fs, gitdir: repo.gitdir, oid: wanted });
|
|
8732
|
-
const { commit } = await git.readCommit({ fs, gitdir: repo.gitdir, oid });
|
|
8733
|
-
return info(oid, commit.message, commit.author.name, commit.author.timestamp);
|
|
8734
|
-
} catch {
|
|
8735
|
-
return null;
|
|
8736
|
-
}
|
|
8737
|
-
};
|
|
8738
|
-
if (!entry) return lookup();
|
|
8739
|
-
let pending = entry.shas.get(wanted);
|
|
8740
|
-
if (!pending) {
|
|
8741
|
-
pending = lookup();
|
|
8742
|
-
entry.shas.set(wanted, pending);
|
|
8877
|
+
function createArchitectureService(ctx, events) {
|
|
8878
|
+
const { store } = ctx;
|
|
8879
|
+
function locate(projectId) {
|
|
8880
|
+
const project = projectRow(store, parse(idSchema, projectId));
|
|
8881
|
+
return { project, dir: existsSync6(project.path) ? directoryOf(project.path) : null };
|
|
8743
8882
|
}
|
|
8744
|
-
|
|
8745
|
-
}
|
|
8746
|
-
async function walk(repo, entry, limit) {
|
|
8747
|
-
let pending = entry.walks.get(limit);
|
|
8748
|
-
if (!pending) {
|
|
8749
|
-
pending = lib().then(
|
|
8750
|
-
(git) => git.log({ fs, gitdir: repo.gitdir, ref: entry.head, depth: limit }).then((log) => log.map((c) => ({ sha: c.oid, message: c.commit.message, author: c.commit.author.name, timestamp: c.commit.author.timestamp }))).catch(() => [])
|
|
8751
|
-
);
|
|
8752
|
-
entry.walks.set(limit, pending);
|
|
8883
|
+
function view(name, file, markdown) {
|
|
8884
|
+
return { name, title: titleOf(markdown, name), file: `${ARCHITECTURE_DIR}/${name}.md`, mtime: file.mtime.toISOString(), size: file.size };
|
|
8753
8885
|
}
|
|
8754
|
-
|
|
8755
|
-
}
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8886
|
+
function list(projectId) {
|
|
8887
|
+
const { project, dir } = locate(projectId);
|
|
8888
|
+
watchProject(project.id);
|
|
8889
|
+
if (!dir) return [];
|
|
8890
|
+
const out = [];
|
|
8891
|
+
const names = readdirSync2(dir).filter((f) => f.endsWith(".md")).map((f) => f.slice(0, -3)).filter((n) => NAME.test(n));
|
|
8892
|
+
for (const name of names) {
|
|
8893
|
+
const file = fileOf(dir, name);
|
|
8894
|
+
if (!file || file.size > MAX_REF_BYTES) continue;
|
|
8895
|
+
out.push(view(name, file, readFileSync3(file.abs, "utf8")));
|
|
8763
8896
|
}
|
|
8764
|
-
|
|
8897
|
+
out.sort((a, b) => rank(a.name) - rank(b.name) || a.name.localeCompare(b.name));
|
|
8898
|
+
return out.slice(0, MAX_ARCHITECTURE_VIEWS);
|
|
8765
8899
|
}
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
}
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
async function findCommitsMentioning(repoPath, ids, options = {}) {
|
|
8776
|
-
const wanted = new Set(ids.filter((id) => id.length > 0));
|
|
8777
|
-
if (wanted.size === 0) return [];
|
|
8778
|
-
const limit = Math.max(1, Math.min(MAX_COMMIT_SCAN, Math.floor(options.limit ?? DEFAULT_COMMIT_SCAN)));
|
|
8779
|
-
const repo = locateRepo(repoPath);
|
|
8780
|
-
if (!repo) return [];
|
|
8781
|
-
const entry = await entryFor(repo);
|
|
8782
|
-
if (!entry) return [];
|
|
8783
|
-
const out = [];
|
|
8784
|
-
for (const c of await walk(repo, entry, limit)) {
|
|
8785
|
-
const mentioned = new Set(
|
|
8786
|
-
(c.message.match(TOKEN) ?? []).map((token) => wanted.has(token) ? token : KEY_TOKEN.test(token) && wanted.has(token.toUpperCase()) ? token.toUpperCase() : null)
|
|
8787
|
-
);
|
|
8788
|
-
mentioned.delete(null);
|
|
8789
|
-
for (const id of mentioned) out.push({ itemId: id, ...info(c.sha, c.message, c.author, c.timestamp) });
|
|
8900
|
+
function read(projectId, name) {
|
|
8901
|
+
const { dir } = locate(projectId);
|
|
8902
|
+
const file = dir ? fileOf(dir, name) : null;
|
|
8903
|
+
if (!dir || !file) throw notFound("architecture view", name);
|
|
8904
|
+
if (file.size > MAX_REF_BYTES) {
|
|
8905
|
+
throw new SlateError("too_large", `${name}.md is ${file.size} bytes; the limit is ${MAX_REF_BYTES}`, { size: file.size, limit: MAX_REF_BYTES });
|
|
8906
|
+
}
|
|
8907
|
+
const markdown = readFileSync3(file.abs, "utf8");
|
|
8908
|
+
return { ...view(name, file, markdown), markdown };
|
|
8790
8909
|
}
|
|
8791
|
-
|
|
8792
|
-
}
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8910
|
+
function status(projectId) {
|
|
8911
|
+
const { dir } = locate(projectId);
|
|
8912
|
+
if (!dir) return { components: "none" };
|
|
8913
|
+
const json = (name) => {
|
|
8914
|
+
const abs = path5.join(dir, name);
|
|
8915
|
+
try {
|
|
8916
|
+
const stat = statSync2(abs);
|
|
8917
|
+
if (!stat.isFile() || stat.size > MAX_MODEL_BYTES) return null;
|
|
8918
|
+
return { mtime: stat.mtimeMs, data: JSON.parse(readFileSync3(abs, "utf8")) };
|
|
8919
|
+
} catch {
|
|
8920
|
+
return null;
|
|
8921
|
+
}
|
|
8922
|
+
};
|
|
8923
|
+
const components = json("components.json");
|
|
8924
|
+
const facts = components ? json("facts.json") : null;
|
|
8925
|
+
if (!components || !facts) return { components: "none" };
|
|
8926
|
+
const hash = facts.data.sources?.hash;
|
|
8927
|
+
const stamp = components.data.facts;
|
|
8928
|
+
const behind = typeof stamp === "string" && typeof hash === "string" ? stamp !== hash : components.mtime < facts.mtime;
|
|
8929
|
+
return { components: behind ? "behind" : "current" };
|
|
8930
|
+
}
|
|
8931
|
+
const watches = /* @__PURE__ */ new Map();
|
|
8932
|
+
const pathOf = (id) => store.db.prepare("SELECT path FROM projects WHERE id = ?").get(id)?.path;
|
|
8933
|
+
const onEvent = (e) => {
|
|
8934
|
+
if (!e.type.startsWith("project.") && e.type !== "workspace.deleted") return;
|
|
8935
|
+
for (const [id, w] of [...watches]) {
|
|
8936
|
+
const now = pathOf(id);
|
|
8937
|
+
if (now === w.root) continue;
|
|
8938
|
+
unwatch(id);
|
|
8939
|
+
if (now) watchProject(id);
|
|
8940
|
+
}
|
|
8805
8941
|
};
|
|
8942
|
+
let unsubscribe = null;
|
|
8943
|
+
function unwatch(projectId) {
|
|
8944
|
+
watches.get(projectId)?.close();
|
|
8945
|
+
watches.delete(projectId);
|
|
8946
|
+
if (watches.size === 0) {
|
|
8947
|
+
unsubscribe?.();
|
|
8948
|
+
unsubscribe = null;
|
|
8949
|
+
}
|
|
8950
|
+
}
|
|
8951
|
+
function watchProject(projectId) {
|
|
8952
|
+
if (watches.has(projectId)) return;
|
|
8953
|
+
const project = projectRow(store, projectId);
|
|
8954
|
+
if (!existsSync6(project.path)) return;
|
|
8955
|
+
while (watches.size >= MAX_ARCHITECTURE_WATCHES) unwatch(watches.keys().next().value);
|
|
8956
|
+
const root = project.path;
|
|
8957
|
+
const levels = [path5.join(root, ARCHITECTURE_DIR), path5.join(root, "docs"), root];
|
|
8958
|
+
let watcher = null;
|
|
8959
|
+
let watching = -1;
|
|
8960
|
+
let timer = null;
|
|
8961
|
+
let closed = false;
|
|
8962
|
+
const publish = () => {
|
|
8963
|
+
if (timer) clearTimeout(timer);
|
|
8964
|
+
timer = setTimeout(() => {
|
|
8965
|
+
timer = null;
|
|
8966
|
+
if (closed) return;
|
|
8967
|
+
events.publish({ type: "architecture.changed", workspaceId: project.workspace_id, projectId, id: projectId, at: ctx.now() });
|
|
8968
|
+
}, ARCHITECTURE_DEBOUNCE_MS);
|
|
8969
|
+
timer.unref?.();
|
|
8970
|
+
};
|
|
8971
|
+
const deepest = () => levels.findIndex((l) => existsSync6(l));
|
|
8972
|
+
const arm = () => {
|
|
8973
|
+
for (; ; ) {
|
|
8974
|
+
watcher?.close();
|
|
8975
|
+
watcher = null;
|
|
8976
|
+
watching = deepest();
|
|
8977
|
+
if (watching < 0) return;
|
|
8978
|
+
try {
|
|
8979
|
+
watcher = watch(levels[watching], { persistent: false }, onChange);
|
|
8980
|
+
watcher.on("error", () => {
|
|
8981
|
+
if (!closed) arm();
|
|
8982
|
+
});
|
|
8983
|
+
} catch {
|
|
8984
|
+
watcher = null;
|
|
8985
|
+
}
|
|
8986
|
+
if (deepest() === watching) return;
|
|
8987
|
+
}
|
|
8988
|
+
};
|
|
8989
|
+
const onChange = () => {
|
|
8990
|
+
if (closed) return;
|
|
8991
|
+
if (deepest() !== watching) {
|
|
8992
|
+
const had = watching === 0;
|
|
8993
|
+
arm();
|
|
8994
|
+
if (had || watching === 0) publish();
|
|
8995
|
+
return;
|
|
8996
|
+
}
|
|
8997
|
+
if (watching === 0) publish();
|
|
8998
|
+
};
|
|
8999
|
+
arm();
|
|
9000
|
+
unsubscribe ??= events.subscribe(onEvent);
|
|
9001
|
+
watches.set(projectId, {
|
|
9002
|
+
root,
|
|
9003
|
+
close() {
|
|
9004
|
+
closed = true;
|
|
9005
|
+
if (timer) clearTimeout(timer);
|
|
9006
|
+
watcher?.close();
|
|
9007
|
+
}
|
|
9008
|
+
});
|
|
9009
|
+
}
|
|
9010
|
+
function close() {
|
|
9011
|
+
for (const id of [...watches.keys()]) unwatch(id);
|
|
9012
|
+
}
|
|
9013
|
+
return { list, read, status, close, watching: () => [...watches.keys()] };
|
|
8806
9014
|
}
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
}
|
|
8823
|
-
}
|
|
8824
|
-
function toStatus(row) {
|
|
8825
|
-
return { key: row.key, label: row.label, position: row.position, kind: row.kind, isDefault: row.is_default === 1 };
|
|
8826
|
-
}
|
|
8827
|
-
function toItem(row) {
|
|
8828
|
-
return {
|
|
8829
|
-
id: row.id,
|
|
8830
|
-
key: itemKey(row.project_key ?? null, row.number),
|
|
8831
|
-
projectId: row.project_id,
|
|
8832
|
-
title: row.title,
|
|
8833
|
-
details: row.details,
|
|
8834
|
-
status: row.status,
|
|
8835
|
-
sortKey: row.sort_key,
|
|
8836
|
-
milestone: row.milestone,
|
|
8837
|
-
priority: row.priority,
|
|
8838
|
-
tags: JSON.parse(row.tags),
|
|
8839
|
-
revision: row.revision,
|
|
8840
|
-
createdAt: row.created_at,
|
|
8841
|
-
updatedAt: row.updated_at,
|
|
8842
|
-
completedAt: row.completed_at,
|
|
8843
|
-
claim: claimOf(row)
|
|
8844
|
-
};
|
|
9015
|
+
|
|
9016
|
+
// ../core/src/services/board-format.ts
|
|
9017
|
+
var import_yaml = __toESM(require_dist(), 1);
|
|
9018
|
+
var BOARD_FORMAT_VERSION = 1;
|
|
9019
|
+
var PRIORITY = ["", "low", "medium", "high"];
|
|
9020
|
+
var REF_LINE = /^- (file|url|commit|pr) (.*)$/;
|
|
9021
|
+
var ITEM_LINE = /^- \[([ xX])\] (.*)$/;
|
|
9022
|
+
var ITEM_ANCHOR = /\s*<!--\s*slate\s+id:(\S+)\s+rev:(\d+)\s*-->\s*$/;
|
|
9023
|
+
var DETAILS_OPEN = /^ {2}<details>\s*(<summary>.*<\/summary>)?\s*$/;
|
|
9024
|
+
var DETAILS_CLOSE = " </details>";
|
|
9025
|
+
var DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
9026
|
+
function code(value) {
|
|
9027
|
+
const longest = Math.max(0, ...(value.match(/`+/g) ?? []).map((run) => run.length));
|
|
9028
|
+
const fence = "`".repeat(longest + 1);
|
|
9029
|
+
const pad = longest > 0 || value.startsWith("`") || value.endsWith("`") ? " " : "";
|
|
9030
|
+
return `${fence}${pad}${value}${pad}${fence}`;
|
|
8845
9031
|
}
|
|
8846
|
-
function
|
|
8847
|
-
return
|
|
9032
|
+
function oneLine(text) {
|
|
9033
|
+
return text.replace(/\s*\n\s*/g, " ");
|
|
8848
9034
|
}
|
|
8849
|
-
function
|
|
8850
|
-
return
|
|
9035
|
+
function tag(value) {
|
|
9036
|
+
return /^[^\s`#·,]+$/.test(value) ? `#${value}` : `#${code(value)}`;
|
|
8851
9037
|
}
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
if (
|
|
8855
|
-
return
|
|
9038
|
+
var YAML_RESERVED = /^(true|false|null|yes|no|on|off|y|n|~)$/i;
|
|
9039
|
+
function scalar(value) {
|
|
9040
|
+
if (/^[A-Za-z][A-Za-z0-9 ._/()+-]*$/.test(value) && !value.endsWith(" ") && !YAML_RESERVED.test(value)) return value;
|
|
9041
|
+
return JSON.stringify(value);
|
|
8856
9042
|
}
|
|
8857
|
-
function
|
|
8858
|
-
const
|
|
8859
|
-
if (
|
|
8860
|
-
|
|
9043
|
+
function frontmatter(board) {
|
|
9044
|
+
const out = ["---", `slate: ${BOARD_FORMAT_VERSION}`, `project: ${scalar(board.name)}`];
|
|
9045
|
+
if (board.description) out.push(`description: ${scalar(board.description)}`);
|
|
9046
|
+
out.push("columns:");
|
|
9047
|
+
for (const c of board.columns) {
|
|
9048
|
+
out.push(` - { key: ${scalar(c.key)}, label: ${scalar(c.label)}, kind: ${c.kind}${c.isDefault ? ", default: true" : ""} }`);
|
|
9049
|
+
}
|
|
9050
|
+
out.push(`milestones: [${board.milestones.map(scalar).join(", ")}]`, "---");
|
|
9051
|
+
return out;
|
|
8861
9052
|
}
|
|
8862
|
-
function
|
|
8863
|
-
const
|
|
8864
|
-
const
|
|
8865
|
-
if (
|
|
8866
|
-
|
|
9053
|
+
function metaLine(item, order, done) {
|
|
9054
|
+
const byBoardOrder = (ids) => [...ids].sort((a, b) => (order.get(a) ?? Infinity) - (order.get(b) ?? Infinity) || (a < b ? -1 : a > b ? 1 : 0));
|
|
9055
|
+
const parts = [];
|
|
9056
|
+
if (item.milestone) parts.push(code(item.milestone));
|
|
9057
|
+
if (item.priority > 0) parts.push(PRIORITY[item.priority]);
|
|
9058
|
+
if (item.tags.length > 0) parts.push(item.tags.map(tag).join(" "));
|
|
9059
|
+
if (item.links.blockedBy.length > 0) parts.push(`blocked by ${byBoardOrder(item.links.blockedBy.map((l) => l.id)).map(code).join(", ")}`);
|
|
9060
|
+
if (item.links.relates.length > 0) parts.push(`relates ${byBoardOrder(item.links.relates.map((l) => l.id)).map(code).join(", ")}`);
|
|
9061
|
+
if (done && item.completedAt) parts.push(`done ${item.completedAt.slice(0, 10)}`);
|
|
9062
|
+
return parts.length > 0 ? parts.join(" \xB7 ") : null;
|
|
8867
9063
|
}
|
|
8868
|
-
function
|
|
8869
|
-
const
|
|
8870
|
-
|
|
8871
|
-
|
|
9064
|
+
function itemBlock(item, order, done) {
|
|
9065
|
+
const out = [`- [${done ? "x" : " "}] ${code(item.id)} ${oneLine(item.title)} <!-- slate id:${item.id} rev:${item.revision} -->`];
|
|
9066
|
+
const meta2 = metaLine(item, order, done);
|
|
9067
|
+
if (meta2) out.push(` - ${meta2}`);
|
|
9068
|
+
for (const ref of item.refs) out.push(` - ${ref.type} ${code(ref.target)}${ref.label ? ` \u2014 ${oneLine(ref.label)}` : ""}`);
|
|
9069
|
+
if (item.details) {
|
|
9070
|
+
out.push(" <details><summary>Details</summary>", "");
|
|
9071
|
+
for (const line of item.details.split("\n")) out.push(line === "" ? "" : ` ${line}`);
|
|
9072
|
+
out.push("", DETAILS_CLOSE);
|
|
9073
|
+
}
|
|
9074
|
+
return out;
|
|
8872
9075
|
}
|
|
8873
|
-
function
|
|
8874
|
-
|
|
9076
|
+
function renderBoard(board) {
|
|
9077
|
+
const order = /* @__PURE__ */ new Map();
|
|
9078
|
+
for (const column of board.columns) for (const item of board.items.get(column.key) ?? []) order.set(item.id, order.size);
|
|
9079
|
+
const out = [...frontmatter(board), "", `# ${oneLine(board.name)}`];
|
|
9080
|
+
if (board.description) out.push("", ...board.description.trim().split("\n").map((l) => l ? `> ${l}` : ">"));
|
|
9081
|
+
for (const column of board.columns) {
|
|
9082
|
+
out.push("", `## ${column.label}`);
|
|
9083
|
+
for (const item of board.items.get(column.key) ?? []) out.push("", ...itemBlock(item, order, column.kind === "done"));
|
|
9084
|
+
}
|
|
9085
|
+
return `${out.join("\n")}
|
|
9086
|
+
`;
|
|
8875
9087
|
}
|
|
8876
|
-
function
|
|
8877
|
-
|
|
8878
|
-
return rows.map(toStatus);
|
|
9088
|
+
function fail(line, message) {
|
|
9089
|
+
throw invalid(`line ${line}: ${message}`, { line });
|
|
8879
9090
|
}
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
9091
|
+
var frontmatterSchema = external_exports.object({
|
|
9092
|
+
slate: external_exports.literal(BOARD_FORMAT_VERSION, { error: `unsupported board format version; this slate reads version ${BOARD_FORMAT_VERSION}` }),
|
|
9093
|
+
project: external_exports.string().optional(),
|
|
9094
|
+
description: external_exports.string().nullable().optional(),
|
|
9095
|
+
columns: external_exports.array(
|
|
9096
|
+
external_exports.object({
|
|
9097
|
+
key: statusKeySchema,
|
|
9098
|
+
label: external_exports.string().trim().min(1).max(100),
|
|
9099
|
+
kind: statusKindSchema,
|
|
9100
|
+
default: external_exports.boolean().optional()
|
|
9101
|
+
})
|
|
9102
|
+
).min(1),
|
|
9103
|
+
milestones: external_exports.array(milestoneSchema).optional()
|
|
9104
|
+
});
|
|
9105
|
+
function readCodeSpan(s, i) {
|
|
9106
|
+
let n = 0;
|
|
9107
|
+
while (s[i + n] === "`") n++;
|
|
9108
|
+
if (n === 0) return null;
|
|
9109
|
+
const fence = "`".repeat(n);
|
|
9110
|
+
let j = i + n;
|
|
9111
|
+
for (; ; ) {
|
|
9112
|
+
const close = s.indexOf(fence, j);
|
|
9113
|
+
if (close < 0) return null;
|
|
9114
|
+
if (s[close + n] === "`" || s[close - 1] === "`") {
|
|
9115
|
+
j = close + n;
|
|
9116
|
+
while (s[j] === "`") j++;
|
|
9117
|
+
continue;
|
|
9118
|
+
}
|
|
9119
|
+
let value = s.slice(i + n, close);
|
|
9120
|
+
if (value.length > 1 && value.startsWith(" ") && value.endsWith(" ") && value.trim() !== "") value = value.slice(1, -1);
|
|
9121
|
+
return { value, end: close + n };
|
|
9122
|
+
}
|
|
8884
9123
|
}
|
|
8885
|
-
function
|
|
8886
|
-
const
|
|
8887
|
-
|
|
8888
|
-
|
|
9124
|
+
function splitMeta(s) {
|
|
9125
|
+
const parts = [];
|
|
9126
|
+
let start = 0;
|
|
9127
|
+
let i = 0;
|
|
9128
|
+
while (i < s.length) {
|
|
9129
|
+
if (s[i] === "`") {
|
|
9130
|
+
const span = readCodeSpan(s, i);
|
|
9131
|
+
if (span) {
|
|
9132
|
+
i = span.end;
|
|
9133
|
+
continue;
|
|
9134
|
+
}
|
|
9135
|
+
}
|
|
9136
|
+
if (s.startsWith(" \xB7 ", i)) {
|
|
9137
|
+
parts.push(s.slice(start, i));
|
|
9138
|
+
i += 3;
|
|
9139
|
+
start = i;
|
|
9140
|
+
continue;
|
|
9141
|
+
}
|
|
9142
|
+
i++;
|
|
8889
9143
|
}
|
|
8890
|
-
|
|
9144
|
+
parts.push(s.slice(start));
|
|
9145
|
+
return parts.map((p) => p.trim()).filter((p) => p !== "");
|
|
8891
9146
|
}
|
|
8892
|
-
function
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
WHERE l.to_id = ? AND l.kind = 'blocks' AND b.completed_at IS NULL LIMIT 1`
|
|
8896
|
-
).get(itemId) !== void 0;
|
|
9147
|
+
function wholeCodeSpan(s) {
|
|
9148
|
+
const span = readCodeSpan(s, 0);
|
|
9149
|
+
return span && span.end === s.length ? span.value : null;
|
|
8897
9150
|
}
|
|
8898
|
-
|
|
8899
|
-
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
|
|
9151
|
+
function idList(s, line) {
|
|
9152
|
+
return s.split(",").map((part) => {
|
|
9153
|
+
const raw = part.trim();
|
|
9154
|
+
const id = wholeCodeSpan(raw) ?? raw;
|
|
9155
|
+
if (!/^[A-Za-z0-9_-]+$/.test(id)) fail(line, `'${raw}' is not an item id`);
|
|
9156
|
+
return id;
|
|
9157
|
+
});
|
|
8904
9158
|
}
|
|
8905
|
-
function
|
|
8906
|
-
const
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
|
|
9159
|
+
function tagList(s, line) {
|
|
9160
|
+
const tags = [];
|
|
9161
|
+
let i = 0;
|
|
9162
|
+
while (i < s.length) {
|
|
9163
|
+
if (s[i] === " ") {
|
|
9164
|
+
i++;
|
|
9165
|
+
continue;
|
|
9166
|
+
}
|
|
9167
|
+
if (s[i] !== "#") fail(line, `expected a #tag, found '${s.slice(i)}'`);
|
|
9168
|
+
i++;
|
|
9169
|
+
const span = s[i] === "`" ? readCodeSpan(s, i) : null;
|
|
9170
|
+
if (span) {
|
|
9171
|
+
tags.push(span.value);
|
|
9172
|
+
i = span.end;
|
|
9173
|
+
continue;
|
|
9174
|
+
}
|
|
9175
|
+
const end = s.indexOf(" ", i) < 0 ? s.length : s.indexOf(" ", i);
|
|
9176
|
+
const value = s.slice(i, end);
|
|
9177
|
+
if (!value) fail(line, "empty #tag");
|
|
9178
|
+
tags.push(value);
|
|
9179
|
+
i = end;
|
|
9180
|
+
}
|
|
9181
|
+
return tags;
|
|
8910
9182
|
}
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
9183
|
+
function applyMeta(item, text, line) {
|
|
9184
|
+
for (const part of splitMeta(text)) {
|
|
9185
|
+
const milestone = wholeCodeSpan(part);
|
|
9186
|
+
if (milestone !== null) {
|
|
9187
|
+
if (item.milestone !== null) fail(line, "an item has one milestone");
|
|
9188
|
+
item.milestone = milestone;
|
|
9189
|
+
} else if (PRIORITY.includes(part) && part !== "") {
|
|
9190
|
+
item.priority = PRIORITY.indexOf(part);
|
|
9191
|
+
} else if (part.startsWith("#")) {
|
|
9192
|
+
item.tags.push(...tagList(part, line));
|
|
9193
|
+
} else if (part.startsWith("blocked by ")) {
|
|
9194
|
+
item.blockedBy.push(...idList(part.slice("blocked by ".length), line));
|
|
9195
|
+
} else if (part.startsWith("relates ")) {
|
|
9196
|
+
item.relates.push(...idList(part.slice("relates ".length), line));
|
|
9197
|
+
} else if (part.startsWith("done ") && DATE.test(part.slice(5))) {
|
|
9198
|
+
item.completedOn = part.slice(5);
|
|
9199
|
+
} else {
|
|
9200
|
+
fail(line, `unknown metadata '${part}'; expected \`milestone\`, low|medium|high, #tags, 'blocked by', 'relates' or 'done YYYY-MM-DD'`);
|
|
9201
|
+
}
|
|
8918
9202
|
}
|
|
8919
|
-
const start = Number(m[1]);
|
|
8920
|
-
const end = m[2] === void 0 ? start : Number(m[2]);
|
|
8921
|
-
if (start < 1) throw invalid(`line numbers start at 1: ${target}`);
|
|
8922
|
-
if (end < start) throw invalid(`a line range ends at or after its start: ${target}`);
|
|
8923
|
-
return { path: target.slice(0, m.index), lines: { start, end } };
|
|
8924
9203
|
}
|
|
8925
|
-
function
|
|
8926
|
-
|
|
8927
|
-
|
|
9204
|
+
function parseRef(type, rest, line) {
|
|
9205
|
+
const span = readCodeSpan(rest, 0);
|
|
9206
|
+
if (!span) fail(line, `a ${type} ref's target is a code span, for example: - ${type} \`target\``);
|
|
9207
|
+
const label = rest.slice(span.end).trim().replace(/^(—|--|-)\s*/, "").trim();
|
|
9208
|
+
return { type: refTypeSchema.parse(type), target: span.value, label: label || null };
|
|
8928
9209
|
}
|
|
8929
|
-
function
|
|
8930
|
-
|
|
9210
|
+
function parseFrontmatter(lines) {
|
|
9211
|
+
if (lines[0] !== "---") fail(1, "a board file starts with '---' frontmatter");
|
|
9212
|
+
const close = lines.indexOf("---", 1);
|
|
9213
|
+
if (close < 0) fail(1, "the frontmatter is not closed with '---'");
|
|
9214
|
+
let raw;
|
|
9215
|
+
try {
|
|
9216
|
+
raw = (0, import_yaml.parse)(lines.slice(1, close).join("\n"));
|
|
9217
|
+
} catch (err) {
|
|
9218
|
+
fail(2, `frontmatter is not valid YAML: ${err.message.split("\n")[0]}`);
|
|
9219
|
+
}
|
|
9220
|
+
const result = frontmatterSchema.safeParse(raw);
|
|
9221
|
+
if (!result.success) {
|
|
9222
|
+
const issue = result.error.issues[0];
|
|
9223
|
+
fail(1, `frontmatter ${issue.path.join(".") || "root"}: ${issue.message}`);
|
|
9224
|
+
}
|
|
9225
|
+
return { meta: result.data, next: close + 1 };
|
|
8931
9226
|
}
|
|
8932
|
-
function
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
|
|
8938
|
-
|
|
9227
|
+
function parseBoard(text) {
|
|
9228
|
+
const lines = text.replace(/\r\n/g, "\n").split("\n");
|
|
9229
|
+
const { meta: meta2, next } = parseFrontmatter(lines);
|
|
9230
|
+
const columns = meta2.columns.map((c) => ({ key: c.key, label: c.label, kind: c.kind, isDefault: c.default === true }));
|
|
9231
|
+
if (new Set(columns.map((c) => c.key)).size !== columns.length) fail(1, "column keys must be unique");
|
|
9232
|
+
if (new Set(columns.map((c) => c.label)).size !== columns.length) fail(1, "column labels must be unique");
|
|
9233
|
+
if (columns.filter((c) => c.isDefault).length !== 1) fail(1, "exactly one column must be 'default: true'");
|
|
9234
|
+
const byLabel = new Map(columns.map((c) => [c.label, c]));
|
|
9235
|
+
const sections = [];
|
|
9236
|
+
const seenIds = /* @__PURE__ */ new Map();
|
|
9237
|
+
let section = null;
|
|
9238
|
+
let item = null;
|
|
9239
|
+
for (let i = next; i < lines.length; i++) {
|
|
9240
|
+
const text2 = lines[i];
|
|
9241
|
+
const lineNo = i + 1;
|
|
9242
|
+
if (text2.trim() === "") continue;
|
|
9243
|
+
if (text2.startsWith("## ")) {
|
|
9244
|
+
const label = text2.slice(3).trim();
|
|
9245
|
+
const column = byLabel.get(label);
|
|
9246
|
+
if (!column) fail(lineNo, `'${label}' is not a column in the frontmatter (${columns.map((c) => c.label).join(", ")})`);
|
|
9247
|
+
if (sections.some((s) => s.column.key === column.key)) fail(lineNo, `column '${label}' appears twice`);
|
|
9248
|
+
section = { line: lineNo, column, items: [] };
|
|
9249
|
+
sections.push(section);
|
|
9250
|
+
item = null;
|
|
9251
|
+
continue;
|
|
9252
|
+
}
|
|
9253
|
+
const itemMatch = ITEM_LINE.exec(text2);
|
|
9254
|
+
if (itemMatch) {
|
|
9255
|
+
if (!section) fail(lineNo, "an item must be under a '## Column' heading");
|
|
9256
|
+
let rest = itemMatch[2];
|
|
9257
|
+
let id = null;
|
|
9258
|
+
let revision = null;
|
|
9259
|
+
const anchor = ITEM_ANCHOR.exec(rest);
|
|
9260
|
+
if (anchor) {
|
|
9261
|
+
id = anchor[1];
|
|
9262
|
+
revision = Number(anchor[2]);
|
|
9263
|
+
rest = rest.slice(0, anchor.index);
|
|
9264
|
+
if (seenIds.has(id)) fail(lineNo, `item ${id} also appears on line ${seenIds.get(id)}`);
|
|
9265
|
+
seenIds.set(id, lineNo);
|
|
9266
|
+
const shown = `${code(id)} `;
|
|
9267
|
+
if (rest.startsWith(shown)) rest = rest.slice(shown.length);
|
|
9268
|
+
}
|
|
9269
|
+
const title = rest.trim();
|
|
9270
|
+
if (!title) fail(lineNo, "an item needs a title");
|
|
9271
|
+
item = {
|
|
9272
|
+
line: lineNo,
|
|
9273
|
+
id,
|
|
9274
|
+
revision,
|
|
9275
|
+
checked: itemMatch[1] !== " ",
|
|
9276
|
+
title,
|
|
9277
|
+
details: null,
|
|
9278
|
+
milestone: null,
|
|
9279
|
+
priority: 0,
|
|
9280
|
+
tags: [],
|
|
9281
|
+
blockedBy: [],
|
|
9282
|
+
relates: [],
|
|
9283
|
+
refs: [],
|
|
9284
|
+
completedOn: null
|
|
9285
|
+
};
|
|
9286
|
+
section.items.push(item);
|
|
9287
|
+
continue;
|
|
9288
|
+
}
|
|
9289
|
+
if (!text2.startsWith(" ")) {
|
|
9290
|
+
if (/^[-*+] /.test(text2)) fail(lineNo, "not an item line; items look like '- [ ] Title'");
|
|
9291
|
+
continue;
|
|
8939
9292
|
}
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
9293
|
+
if (!item) fail(lineNo, "indented line outside an item");
|
|
9294
|
+
if (DETAILS_OPEN.test(text2)) {
|
|
9295
|
+
let end = i + 1;
|
|
9296
|
+
while (end < lines.length && (lines[end] === "" || lines[end].startsWith(" "))) end++;
|
|
9297
|
+
let close = -1;
|
|
9298
|
+
for (let j = end - 1; j > i; j--) {
|
|
9299
|
+
if (lines[j] === DETAILS_CLOSE) {
|
|
9300
|
+
close = j;
|
|
9301
|
+
break;
|
|
9302
|
+
}
|
|
8946
9303
|
}
|
|
8947
|
-
if (
|
|
8948
|
-
|
|
9304
|
+
if (close < 0) fail(lineNo, "<details> is not closed with an indented </details>");
|
|
9305
|
+
let body = lines.slice(i + 1, close);
|
|
9306
|
+
if (body[0] === "") body = body.slice(1);
|
|
9307
|
+
if (body.at(-1) === "") body = body.slice(0, -1);
|
|
9308
|
+
const details = body.map((l) => l.replace(/^ {1,2}/, "")).join("\n");
|
|
9309
|
+
item.details = details === "" ? null : details;
|
|
9310
|
+
for (let j = close + 1; j < end; j++) if (lines[j].trim() !== "") fail(j + 1, "unexpected text after </details>");
|
|
9311
|
+
i = end - 1;
|
|
9312
|
+
continue;
|
|
8949
9313
|
}
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
throw invalid(`a pr ref is a number or a URL: ${target}`);
|
|
9314
|
+
if (!text2.startsWith(" - ")) fail(lineNo, "expected ' - ' metadata, a ref, or <details>");
|
|
9315
|
+
if (item.details !== null) fail(lineNo, "metadata and refs go before <details>");
|
|
9316
|
+
const sub = text2.slice(2);
|
|
9317
|
+
const ref = REF_LINE.exec(sub);
|
|
9318
|
+
if (ref) {
|
|
9319
|
+
item.refs.push(parseRef(ref[1], ref[2], lineNo));
|
|
9320
|
+
continue;
|
|
8958
9321
|
}
|
|
9322
|
+
applyMeta(item, sub.slice(2), lineNo);
|
|
8959
9323
|
}
|
|
9324
|
+
return {
|
|
9325
|
+
project: meta2.project ?? null,
|
|
9326
|
+
description: meta2.description,
|
|
9327
|
+
columns,
|
|
9328
|
+
milestones: meta2.milestones ?? [],
|
|
9329
|
+
sections
|
|
9330
|
+
};
|
|
8960
9331
|
}
|
|
8961
|
-
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
} catch {
|
|
8967
|
-
return true;
|
|
8968
|
-
}
|
|
9332
|
+
|
|
9333
|
+
// ../core/src/services/export.ts
|
|
9334
|
+
var PRIORITY2 = ["", "low", "medium", "high"];
|
|
9335
|
+
function heading(level, text) {
|
|
9336
|
+
return `${"#".repeat(Math.min(level, 6))} ${text}`;
|
|
8969
9337
|
}
|
|
8970
|
-
function
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
}
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
}
|
|
9005
|
-
function forItem(itemId) {
|
|
9006
|
-
return db.prepare("SELECT * FROM refs WHERE item_id = ? ORDER BY created_at, id").all(itemId).map(toRef);
|
|
9007
|
-
}
|
|
9008
|
-
function commitSources(project) {
|
|
9009
|
-
const own = { id: project.id, name: project.name, path: project.path };
|
|
9010
|
-
const others = db.prepare("SELECT * FROM projects WHERE workspace_id = ? AND id <> ? ORDER BY name, id").all(project.workspace_id, project.id);
|
|
9011
|
-
if (others.length === 0) return [own];
|
|
9012
|
-
const seen = /* @__PURE__ */ new Set();
|
|
9013
|
-
const ownRepo = locateRepo(project.path);
|
|
9014
|
-
if (ownRepo) seen.add(ownRepo.gitdir);
|
|
9015
|
-
const out = [own];
|
|
9016
|
-
for (const p of others) {
|
|
9017
|
-
if (out.length >= MAX_WORKSPACE_REPOS) break;
|
|
9018
|
-
const repo = locateRepo(p.path);
|
|
9019
|
-
if (!repo || seen.has(repo.gitdir)) continue;
|
|
9020
|
-
seen.add(repo.gitdir);
|
|
9021
|
-
out.push({ id: p.id, name: p.name, path: p.path });
|
|
9338
|
+
function refLine(ref) {
|
|
9339
|
+
return `- ${ref.type}: \`${ref.target}\`${ref.label ? ` (${ref.label})` : ""} [ref \`${ref.id}\`]`;
|
|
9340
|
+
}
|
|
9341
|
+
function linked(items) {
|
|
9342
|
+
return items.map((i) => `${i.title} (\`${i.id}\`${i.done ? ", done" : ""})`).join(", ");
|
|
9343
|
+
}
|
|
9344
|
+
function meta(item) {
|
|
9345
|
+
const parts = [`\`${item.id}\``, item.status];
|
|
9346
|
+
if (item.milestone) parts.push(`milestone ${item.milestone}`);
|
|
9347
|
+
if (item.priority > 0) parts.push(`priority ${PRIORITY2[item.priority]}`);
|
|
9348
|
+
if (item.tags.length > 0) parts.push(item.tags.map((t) => `#${t}`).join(" "));
|
|
9349
|
+
if (item.blocked) parts.push("**blocked**");
|
|
9350
|
+
if (item.completedAt) parts.push(`completed ${item.completedAt}`);
|
|
9351
|
+
return parts.join(" \xB7 ");
|
|
9352
|
+
}
|
|
9353
|
+
function itemMarkdown(item, level = 1) {
|
|
9354
|
+
const out = [heading(level, item.title), "", meta(item)];
|
|
9355
|
+
if (item.details) out.push("", item.details.trim());
|
|
9356
|
+
if (item.links.blockedBy.length > 0) out.push("", `Blocked by: ${linked(item.links.blockedBy)}`);
|
|
9357
|
+
if (item.links.blocks.length > 0) out.push("", `Blocks: ${linked(item.links.blocks)}`);
|
|
9358
|
+
if (item.links.relates.length > 0) out.push("", `Related: ${linked(item.links.relates)}`);
|
|
9359
|
+
if (item.refs.length > 0) out.push("", "Refs:", ...item.refs.map(refLine));
|
|
9360
|
+
return out.join("\n");
|
|
9361
|
+
}
|
|
9362
|
+
function createExportService(workspaces, projects, items) {
|
|
9363
|
+
function projectBody(project2, level) {
|
|
9364
|
+
const out = [heading(level, project2.name), "", `Path: \`${project2.path}\`${project2.missing ? " (missing)" : ""}`];
|
|
9365
|
+
if (project2.archived) out.push("", "Archived.");
|
|
9366
|
+
if (project2.description) out.push("", project2.description.trim());
|
|
9367
|
+
if (project2.milestones.length > 0) out.push("", `Milestones: ${project2.milestones.join(", ")}`);
|
|
9368
|
+
const board = items.board({ projectId: project2.id, includeDone: true });
|
|
9369
|
+
for (const column of board.columns) {
|
|
9370
|
+
out.push("", heading(level + 1, `${column.label} (${column.items.length})`));
|
|
9371
|
+
for (const summary of column.items) out.push("", itemMarkdown(items.get(summary.id), level + 2));
|
|
9022
9372
|
}
|
|
9023
9373
|
return out;
|
|
9024
9374
|
}
|
|
9025
|
-
function
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
async function resolveForItem(ref) {
|
|
9036
|
-
const itemId = itemRow(store, parse(idSchema, ref)).id;
|
|
9037
|
-
return resolve(sourcesForItem(itemId), forItem(itemId));
|
|
9375
|
+
function project(projectId) {
|
|
9376
|
+
const detail = projects.get(parse(idSchema, projectId));
|
|
9377
|
+
const board = items.board({ projectId: detail.id, includeDone: true });
|
|
9378
|
+
return renderBoard({
|
|
9379
|
+
name: detail.name,
|
|
9380
|
+
description: detail.description,
|
|
9381
|
+
milestones: detail.milestones,
|
|
9382
|
+
columns: detail.statuses,
|
|
9383
|
+
items: new Map(board.columns.map((c) => [c.key, c.items.map((summary) => items.get(summary.id))]))
|
|
9384
|
+
});
|
|
9038
9385
|
}
|
|
9039
|
-
|
|
9040
|
-
|
|
9386
|
+
function workspace(workspaceId) {
|
|
9387
|
+
const ws = workspaces.get(parse(idSchema, workspaceId));
|
|
9388
|
+
const out = [heading(1, ws.name), "", `Root: \`${ws.rootPath}\`${ws.missing ? " (missing)" : ""}`];
|
|
9389
|
+
for (const p of projects.list({ workspaceId: ws.id })) out.push("", ...projectBody(p, 2));
|
|
9390
|
+
return `${out.join("\n")}
|
|
9391
|
+
`;
|
|
9041
9392
|
}
|
|
9042
|
-
function
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
const { project } = owner(ref.itemId);
|
|
9046
|
-
const target = splitFileTarget(ref.target);
|
|
9047
|
-
const abs = resolveInside(project.path, target.path);
|
|
9048
|
-
if (!existsSync4(abs)) return { ref, path: abs, state: "missing" };
|
|
9049
|
-
const stat = statSync(abs);
|
|
9050
|
-
if (!stat.isFile()) throw invalid(`${target.path} is not a regular file`);
|
|
9051
|
-
if (stat.size > MAX_REF_BYTES) {
|
|
9052
|
-
throw new SlateError("too_large", `${target.path} is ${stat.size} bytes; the limit is ${MAX_REF_BYTES}`, {
|
|
9053
|
-
size: stat.size,
|
|
9054
|
-
limit: MAX_REF_BYTES
|
|
9055
|
-
});
|
|
9056
|
-
}
|
|
9057
|
-
const buf = readFileSync2(abs);
|
|
9058
|
-
if (looksBinary(buf)) return { ref, path: abs, state: "binary", size: buf.length };
|
|
9059
|
-
const content = buf.toString("utf8");
|
|
9060
|
-
if (!target.lines) return { ref, path: abs, state: "ok", size: buf.length, content };
|
|
9061
|
-
const all = splitLines(content);
|
|
9062
|
-
const lines = { ...target.lines, total: all.length };
|
|
9063
|
-
if (options.full) return { ref, path: abs, state: "ok", size: buf.length, content, lines };
|
|
9064
|
-
return { ref, path: abs, state: "ok", size: buf.length, content: all.slice(lines.start - 1, lines.end).join(""), lines };
|
|
9393
|
+
function item(itemId) {
|
|
9394
|
+
return `${itemMarkdown(items.get(itemId))}
|
|
9395
|
+
`;
|
|
9065
9396
|
}
|
|
9066
|
-
return {
|
|
9397
|
+
return { project, workspace, item };
|
|
9067
9398
|
}
|
|
9068
9399
|
|
|
9069
9400
|
// ../core/src/services/roadmap-file.ts
|
|
9401
|
+
import { createHash } from "node:crypto";
|
|
9402
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync } from "node:fs";
|
|
9403
|
+
import path6 from "node:path";
|
|
9070
9404
|
var DEFAULT_ROADMAP_FILE = "docs/ROADMAP.md";
|
|
9071
9405
|
var sha = (text) => createHash("sha256").update(text).digest("hex");
|
|
9072
9406
|
function createRoadmapFileService(ctx, exporter) {
|
|
@@ -9081,8 +9415,8 @@ function createRoadmapFileService(ctx, exporter) {
|
|
|
9081
9415
|
const at = locate(projectId);
|
|
9082
9416
|
if (!at) return { state: "off", file: null, path: null };
|
|
9083
9417
|
const base = { file: at.file, path: at.abs };
|
|
9084
|
-
if (!
|
|
9085
|
-
const content =
|
|
9418
|
+
if (!existsSync7(at.abs)) return { ...base, state: at.project.roadmap_hash ? "missing" : "stale" };
|
|
9419
|
+
const content = readFileSync4(at.abs, "utf8");
|
|
9086
9420
|
if (at.project.roadmap_hash && sha(content) !== at.project.roadmap_hash) {
|
|
9087
9421
|
return { ...base, state: content === exporter.project(projectId) ? "current" : "edited" };
|
|
9088
9422
|
}
|
|
@@ -9092,7 +9426,7 @@ function createRoadmapFileService(ctx, exporter) {
|
|
|
9092
9426
|
const now = status(projectId);
|
|
9093
9427
|
if (now.state !== "stale" && now.state !== "missing") return now;
|
|
9094
9428
|
const md = exporter.project(projectId);
|
|
9095
|
-
mkdirSync2(
|
|
9429
|
+
mkdirSync2(path6.dirname(now.path), { recursive: true });
|
|
9096
9430
|
writeFileSync(now.path, md);
|
|
9097
9431
|
db.prepare("UPDATE projects SET roadmap_hash = ? WHERE id = ?").run(sha(md), projectId);
|
|
9098
9432
|
return { ...now, state: "current" };
|
|
@@ -9450,7 +9784,7 @@ function createItemService(ctx, refs, links) {
|
|
|
9450
9784
|
}
|
|
9451
9785
|
found.forEach((list2, i) => {
|
|
9452
9786
|
const { id: projectId, name: projectName, path: projectPath } = sources[i];
|
|
9453
|
-
for (const { itemId: _, ...c } of list2) {
|
|
9787
|
+
for (const { itemId: _, partial: _part, ...c } of list2) {
|
|
9454
9788
|
if (seen.has(c.sha)) continue;
|
|
9455
9789
|
seen.add(c.sha);
|
|
9456
9790
|
out.push({ ...c, projectId, projectName, projectPath, source: "discovered", refId: null });
|
|
@@ -9458,7 +9792,7 @@ function createItemService(ctx, refs, links) {
|
|
|
9458
9792
|
});
|
|
9459
9793
|
return out.sort((a, b) => a.date < b.date ? 1 : a.date > b.date ? -1 : 0);
|
|
9460
9794
|
}
|
|
9461
|
-
async function relatedCommits(project, limit) {
|
|
9795
|
+
async function relatedCommits(project, limit, partials) {
|
|
9462
9796
|
const owners = /* @__PURE__ */ new Map();
|
|
9463
9797
|
for (const r of db.prepare(`${ITEM_SELECT} WHERE i.project_id = ?`).all(project.id)) {
|
|
9464
9798
|
owners.set(r.id, r.id);
|
|
@@ -9479,10 +9813,23 @@ function createItemService(ctx, refs, links) {
|
|
|
9479
9813
|
if (!known) commits2.set(c.sha, { ...c, itemIds: [itemId] });
|
|
9480
9814
|
else if (!known.itemIds.includes(itemId)) known.itemIds.push(itemId);
|
|
9481
9815
|
};
|
|
9482
|
-
|
|
9816
|
+
const pinned = /* @__PURE__ */ new Set();
|
|
9817
|
+
for (const ref of attached) {
|
|
9818
|
+
if (!ref.commit) continue;
|
|
9819
|
+
add(ref.itemId, ref.commit);
|
|
9820
|
+
pinned.add(`${ref.commit.sha} ${ref.itemId}`);
|
|
9821
|
+
}
|
|
9483
9822
|
found.forEach((list2, i) => {
|
|
9484
9823
|
const { id: projectId, name: projectName, path: projectPath } = sources[i];
|
|
9485
|
-
for (const { itemId, ...c } of list2)
|
|
9824
|
+
for (const { itemId, partial, ...c } of list2) {
|
|
9825
|
+
const owner = owners.get(itemId);
|
|
9826
|
+
add(owner, { ...c, projectId, projectName, projectPath });
|
|
9827
|
+
if (partial && !pinned.has(`${c.sha} ${owner}`)) partials?.add(`${c.sha} ${owner}`);
|
|
9828
|
+
else {
|
|
9829
|
+
pinned.add(`${c.sha} ${owner}`);
|
|
9830
|
+
partials?.delete(`${c.sha} ${owner}`);
|
|
9831
|
+
}
|
|
9832
|
+
}
|
|
9486
9833
|
});
|
|
9487
9834
|
return [...commits2.values()].sort((a, b) => a.date < b.date ? 1 : a.date > b.date ? -1 : 0);
|
|
9488
9835
|
}
|
|
@@ -9502,7 +9849,8 @@ function createItemService(ctx, refs, links) {
|
|
|
9502
9849
|
async function syncFromGit(projectId) {
|
|
9503
9850
|
const project = projectRow(store, projectId);
|
|
9504
9851
|
if (project.git_transitions !== 1) return [];
|
|
9505
|
-
const
|
|
9852
|
+
const partials = /* @__PURE__ */ new Set();
|
|
9853
|
+
const commits2 = await relatedCommits(project, void 0, partials);
|
|
9506
9854
|
if (commits2.length === 0) return [];
|
|
9507
9855
|
const landed = await defaultBranchShas(project.path);
|
|
9508
9856
|
const statuses = effectiveStatuses(store, projectId);
|
|
@@ -9516,7 +9864,7 @@ function createItemService(ctx, refs, links) {
|
|
|
9516
9864
|
const row = db.prepare(`${ITEM_SELECT} WHERE i.id = ?`).get(id);
|
|
9517
9865
|
if (!row) continue;
|
|
9518
9866
|
const kind = statuses.find((s) => s.key === row.status)?.kind;
|
|
9519
|
-
const onDefault = related.some((c) => landed.has(c.sha));
|
|
9867
|
+
const onDefault = related.some((c) => landed.has(c.sha) && !partials.has(`${c.sha} ${id}`));
|
|
9520
9868
|
const to = kind === "backlog" ? onDefault && review ? review : active : kind === "active" && onDefault ? review : null;
|
|
9521
9869
|
if (!to || to.key === row.status) continue;
|
|
9522
9870
|
move({ id, status: to.key });
|
|
@@ -9839,7 +10187,7 @@ function createItemService(ctx, refs, links) {
|
|
|
9839
10187
|
return get(row.id);
|
|
9840
10188
|
});
|
|
9841
10189
|
}
|
|
9842
|
-
return { list, board, get, getResolved, withCommits, commits, projectCommits, syncFromGit, create, createMany, restore, update, move, remove, next, claim, release };
|
|
10190
|
+
return { list, board, get, getResolved, withCommits, commits, relatedCommits, projectCommits, syncFromGit, create, createMany, restore, update, move, remove, next, claim, release };
|
|
9843
10191
|
}
|
|
9844
10192
|
|
|
9845
10193
|
// ../core/src/services/links.ts
|
|
@@ -9989,12 +10337,12 @@ function createOverviewService(ctx) {
|
|
|
9989
10337
|
}
|
|
9990
10338
|
|
|
9991
10339
|
// ../core/src/services/projects.ts
|
|
9992
|
-
import { existsSync as
|
|
9993
|
-
import
|
|
10340
|
+
import { existsSync as existsSync8, lstatSync, readFileSync as readFileSync5 } from "node:fs";
|
|
10341
|
+
import path8 from "node:path";
|
|
9994
10342
|
|
|
9995
10343
|
// ../core/src/services/workspaces.ts
|
|
9996
|
-
import { readdirSync as
|
|
9997
|
-
import
|
|
10344
|
+
import { readdirSync as readdirSync3, statSync as statSync3 } from "node:fs";
|
|
10345
|
+
import path7 from "node:path";
|
|
9998
10346
|
var DEFAULT_STATUSES = [
|
|
9999
10347
|
{ key: "backlog", label: "Backlog", kind: "backlog", isDefault: true },
|
|
10000
10348
|
{ key: "planned", label: "Planned", kind: "backlog", isDefault: false },
|
|
@@ -10006,7 +10354,7 @@ var SCAN_DEPTH = 3;
|
|
|
10006
10354
|
function requireDirectory(p) {
|
|
10007
10355
|
let isDir2 = false;
|
|
10008
10356
|
try {
|
|
10009
|
-
isDir2 =
|
|
10357
|
+
isDir2 = statSync3(p).isDirectory();
|
|
10010
10358
|
} catch {
|
|
10011
10359
|
throw invalid(`path does not exist: ${p}`, { path: p });
|
|
10012
10360
|
}
|
|
@@ -10083,7 +10431,7 @@ function createWorkspaceService(ctx) {
|
|
|
10083
10431
|
const walk2 = (dir, depth) => {
|
|
10084
10432
|
let entries;
|
|
10085
10433
|
try {
|
|
10086
|
-
entries =
|
|
10434
|
+
entries = readdirSync3(dir, { withFileTypes: true });
|
|
10087
10435
|
} catch {
|
|
10088
10436
|
return;
|
|
10089
10437
|
}
|
|
@@ -10091,11 +10439,11 @@ function createWorkspaceService(ctx) {
|
|
|
10091
10439
|
if (depth >= SCAN_DEPTH) return;
|
|
10092
10440
|
for (const e of entries) {
|
|
10093
10441
|
if (!e.isDirectory() || e.name.startsWith(".") || e.name === "node_modules") continue;
|
|
10094
|
-
walk2(
|
|
10442
|
+
walk2(path7.join(dir, e.name), depth + 1);
|
|
10095
10443
|
}
|
|
10096
10444
|
};
|
|
10097
10445
|
walk2(ws.rootPath, 0);
|
|
10098
|
-
return found.sort().map((p) => ({ path: p, name:
|
|
10446
|
+
return found.sort().map((p) => ({ path: p, name: path7.basename(p), registered: registered.has(p) }));
|
|
10099
10447
|
}
|
|
10100
10448
|
return { list, get, create, update, remove, scan };
|
|
10101
10449
|
}
|
|
@@ -10103,7 +10451,7 @@ function createWorkspaceService(ctx) {
|
|
|
10103
10451
|
// ../core/src/services/projects.ts
|
|
10104
10452
|
function worktreeMainRepo(dir) {
|
|
10105
10453
|
for (const candidate of ancestors(dir)) {
|
|
10106
|
-
const gitPath =
|
|
10454
|
+
const gitPath = path8.join(candidate, ".git");
|
|
10107
10455
|
let stat;
|
|
10108
10456
|
try {
|
|
10109
10457
|
stat = lstatSync(gitPath);
|
|
@@ -10111,19 +10459,19 @@ function worktreeMainRepo(dir) {
|
|
|
10111
10459
|
continue;
|
|
10112
10460
|
}
|
|
10113
10461
|
if (!stat.isFile()) return null;
|
|
10114
|
-
const match = /^gitdir:\s*(.+?)\s*$/m.exec(
|
|
10462
|
+
const match = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync5(gitPath, "utf8"));
|
|
10115
10463
|
if (!match?.[1]) return null;
|
|
10116
|
-
const gitdir =
|
|
10464
|
+
const gitdir = path8.resolve(candidate, match[1]);
|
|
10117
10465
|
let common = null;
|
|
10118
|
-
const commondirFile =
|
|
10119
|
-
if (
|
|
10120
|
-
common =
|
|
10466
|
+
const commondirFile = path8.join(gitdir, "commondir");
|
|
10467
|
+
if (existsSync8(commondirFile)) {
|
|
10468
|
+
common = path8.resolve(gitdir, readFileSync5(commondirFile, "utf8").trim());
|
|
10121
10469
|
} else {
|
|
10122
10470
|
const m = /^(.*)[/\\]worktrees[/\\][^/\\]+[/\\]?$/.exec(gitdir);
|
|
10123
10471
|
if (m?.[1]) common = m[1];
|
|
10124
10472
|
}
|
|
10125
10473
|
if (!common) return null;
|
|
10126
|
-
return normalizePath(
|
|
10474
|
+
return normalizePath(path8.basename(common) === ".git" ? path8.dirname(common) : common);
|
|
10127
10475
|
}
|
|
10128
10476
|
return null;
|
|
10129
10477
|
}
|
|
@@ -10201,10 +10549,14 @@ function createProjectService(ctx) {
|
|
|
10201
10549
|
params.push(parsed.key);
|
|
10202
10550
|
}
|
|
10203
10551
|
if (parsed.roadmapFile !== void 0 && parsed.roadmapFile !== row.roadmap_file) {
|
|
10204
|
-
const file = parsed.roadmapFile === null ? null :
|
|
10552
|
+
const file = parsed.roadmapFile === null ? null : path8.relative(row.path, resolveInside(row.path, parsed.roadmapFile));
|
|
10205
10553
|
sets.push("roadmap_file = ?", "roadmap_hash = ?");
|
|
10206
10554
|
params.push(file, null);
|
|
10207
10555
|
}
|
|
10556
|
+
if (parsed.archAuto !== void 0 && parsed.archAuto !== (row.arch_auto === 1)) {
|
|
10557
|
+
sets.push("arch_auto = ?", "arch_head = NULL", "arch_at = NULL", "arch_state = NULL", "arch_error = NULL");
|
|
10558
|
+
params.push(parsed.archAuto ? 1 : 0);
|
|
10559
|
+
}
|
|
10208
10560
|
if (parsed.gitTransitions !== void 0) {
|
|
10209
10561
|
sets.push("git_transitions = ?");
|
|
10210
10562
|
params.push(parsed.gitTransitions ? 1 : 0);
|
|
@@ -10442,8 +10794,8 @@ function createStatusService(ctx) {
|
|
|
10442
10794
|
}
|
|
10443
10795
|
|
|
10444
10796
|
// ../core/src/services/todos.ts
|
|
10445
|
-
import { lstatSync as lstatSync2, readFileSync as
|
|
10446
|
-
import
|
|
10797
|
+
import { lstatSync as lstatSync2, readFileSync as readFileSync6, readdirSync as readdirSync4 } from "node:fs";
|
|
10798
|
+
import path9 from "node:path";
|
|
10447
10799
|
var MAX_TODO_FILE_BYTES = 1024 * 1024;
|
|
10448
10800
|
var MAX_TODO_FILES = 2e4;
|
|
10449
10801
|
var MAX_TODOS = 1e3;
|
|
@@ -10481,7 +10833,7 @@ function createTodoService(ctx, items, statuses) {
|
|
|
10481
10833
|
const visit = async (rel) => {
|
|
10482
10834
|
let entries;
|
|
10483
10835
|
try {
|
|
10484
|
-
entries =
|
|
10836
|
+
entries = readdirSync4(path9.join(root, rel), { withFileTypes: true });
|
|
10485
10837
|
} catch {
|
|
10486
10838
|
return true;
|
|
10487
10839
|
}
|
|
@@ -10494,7 +10846,7 @@ function createTodoService(ctx, items, statuses) {
|
|
|
10494
10846
|
continue;
|
|
10495
10847
|
}
|
|
10496
10848
|
if (!e.isFile() || await ignored(child, false)) continue;
|
|
10497
|
-
const abs =
|
|
10849
|
+
const abs = path9.join(root, child);
|
|
10498
10850
|
try {
|
|
10499
10851
|
if (lstatSync2(abs).size > MAX_TODO_FILE_BYTES) continue;
|
|
10500
10852
|
} catch {
|
|
@@ -10502,7 +10854,7 @@ function createTodoService(ctx, items, statuses) {
|
|
|
10502
10854
|
}
|
|
10503
10855
|
let buf;
|
|
10504
10856
|
try {
|
|
10505
|
-
buf =
|
|
10857
|
+
buf = readFileSync6(abs);
|
|
10506
10858
|
} catch {
|
|
10507
10859
|
continue;
|
|
10508
10860
|
}
|
|
@@ -10599,6 +10951,168 @@ function createTodoService(ctx, items, statuses) {
|
|
|
10599
10951
|
return { scan };
|
|
10600
10952
|
}
|
|
10601
10953
|
|
|
10954
|
+
// ../core/src/services/touch.ts
|
|
10955
|
+
import { readFileSync as readFileSync7, statSync as statSync4 } from "node:fs";
|
|
10956
|
+
import path10 from "node:path";
|
|
10957
|
+
var MAX_MODEL_BYTES2 = 8 * 1024 * 1024;
|
|
10958
|
+
var MAX_TOUCH_PATHS = 20;
|
|
10959
|
+
var OTHER = { id: "other", label: "Other", kind: "other" };
|
|
10960
|
+
function globToRegExp(glob) {
|
|
10961
|
+
let re = "";
|
|
10962
|
+
for (let i = 0; i < glob.length; i++) {
|
|
10963
|
+
const c = glob[i];
|
|
10964
|
+
if (c === "*" && glob[i + 1] === "*") {
|
|
10965
|
+
const slash = glob[i + 2] === "/";
|
|
10966
|
+
re += slash ? "(?:.*/)?" : ".*";
|
|
10967
|
+
i += slash ? 2 : 1;
|
|
10968
|
+
} else if (c === "*") re += "[^/]*";
|
|
10969
|
+
else if (c === "?") re += "[^/]";
|
|
10970
|
+
else re += c.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
10971
|
+
}
|
|
10972
|
+
return new RegExp(`^${re}$`);
|
|
10973
|
+
}
|
|
10974
|
+
var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
10975
|
+
function readJson(file) {
|
|
10976
|
+
try {
|
|
10977
|
+
const stat = statSync4(file);
|
|
10978
|
+
if (!stat.isFile() || stat.size > MAX_MODEL_BYTES2) return null;
|
|
10979
|
+
return JSON.parse(readFileSync7(file, "utf8"));
|
|
10980
|
+
} catch {
|
|
10981
|
+
return null;
|
|
10982
|
+
}
|
|
10983
|
+
}
|
|
10984
|
+
function componentsOf(doc) {
|
|
10985
|
+
if (!isObject(doc) || !Array.isArray(doc.components)) return [];
|
|
10986
|
+
const out = [];
|
|
10987
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10988
|
+
for (const c of doc.components) {
|
|
10989
|
+
if (!isObject(c) || typeof c.id !== "string" || !c.id || c.id === OTHER.id || seen.has(c.id) || !Array.isArray(c.files)) continue;
|
|
10990
|
+
const globs = c.files.filter((g) => typeof g === "string" && g.length > 0).map(globToRegExp);
|
|
10991
|
+
if (globs.length === 0) continue;
|
|
10992
|
+
seen.add(c.id);
|
|
10993
|
+
out.push({ entry: { id: c.id, label: typeof c.label === "string" && c.label ? c.label : c.id, kind: "component" }, globs });
|
|
10994
|
+
}
|
|
10995
|
+
return out;
|
|
10996
|
+
}
|
|
10997
|
+
function packagesOf(doc) {
|
|
10998
|
+
if (!isObject(doc) || !Array.isArray(doc.nodes)) return [];
|
|
10999
|
+
const out = [];
|
|
11000
|
+
for (const n of doc.nodes) {
|
|
11001
|
+
if (!isObject(n) || n.kind !== "package" || typeof n.id !== "string") continue;
|
|
11002
|
+
const attrs = isObject(n.attrs) ? n.attrs : {};
|
|
11003
|
+
const dir = typeof attrs.dir === "string" ? attrs.dir : typeof n.file === "string" ? path10.posix.dirname(n.file) : null;
|
|
11004
|
+
if (dir === null) continue;
|
|
11005
|
+
const clean = dir === "." ? "" : dir.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
11006
|
+
out.push({ entry: { id: n.id, label: typeof n.label === "string" && n.label ? n.label : n.id, kind: "package" }, dir: clean });
|
|
11007
|
+
}
|
|
11008
|
+
return out.sort((a, b) => b.dir.length - a.dir.length);
|
|
11009
|
+
}
|
|
11010
|
+
function classify(model, file) {
|
|
11011
|
+
for (const c of model.components) if (c.globs.some((g) => g.test(file))) return c.entry;
|
|
11012
|
+
for (const p of model.packages) if (p.dir === "" || file === p.dir || file.startsWith(`${p.dir}/`)) return p.entry;
|
|
11013
|
+
return OTHER;
|
|
11014
|
+
}
|
|
11015
|
+
var Tally = class {
|
|
11016
|
+
rows = /* @__PURE__ */ new Map();
|
|
11017
|
+
add(entry, file, sha2, itemIds) {
|
|
11018
|
+
const key = `${entry.kind}:${entry.id}`;
|
|
11019
|
+
let row = this.rows.get(key);
|
|
11020
|
+
if (!row) this.rows.set(key, row = { entry, files: /* @__PURE__ */ new Set(), commits: /* @__PURE__ */ new Set(), items: /* @__PURE__ */ new Set() });
|
|
11021
|
+
row.files.add(file);
|
|
11022
|
+
row.commits.add(sha2);
|
|
11023
|
+
for (const id of itemIds) row.items.add(id);
|
|
11024
|
+
}
|
|
11025
|
+
list() {
|
|
11026
|
+
return [...this.rows.values()].map((r) => ({ ...r.entry, files: r.files.size, commits: r.commits.size, items: r.items.size, paths: [...r.files].sort() }));
|
|
11027
|
+
}
|
|
11028
|
+
};
|
|
11029
|
+
var otherLast = (a, b) => Number(a.kind === "other") - Number(b.kind === "other");
|
|
11030
|
+
function createTouchService(ctx, items) {
|
|
11031
|
+
const { store } = ctx;
|
|
11032
|
+
const models = /* @__PURE__ */ new Map();
|
|
11033
|
+
function stampOf(file) {
|
|
11034
|
+
try {
|
|
11035
|
+
const s = statSync4(file);
|
|
11036
|
+
return `${s.mtimeMs}:${s.size}`;
|
|
11037
|
+
} catch {
|
|
11038
|
+
return "-";
|
|
11039
|
+
}
|
|
11040
|
+
}
|
|
11041
|
+
function modelOf(project) {
|
|
11042
|
+
const dir = path10.join(project.path, ARCHITECTURE_DIR);
|
|
11043
|
+
const componentsFile = path10.join(dir, "components.json");
|
|
11044
|
+
const factsFile = path10.join(dir, "facts.json");
|
|
11045
|
+
const stamp = `${stampOf(componentsFile)}|${stampOf(factsFile)}`;
|
|
11046
|
+
const known = models.get(project.id);
|
|
11047
|
+
if (known && known.stamp === stamp) return known.model;
|
|
11048
|
+
const components = componentsOf(readJson(componentsFile));
|
|
11049
|
+
const packages = packagesOf(readJson(factsFile));
|
|
11050
|
+
const model = components.length || packages.length ? { kind: components.length ? "components" : "packages", components, packages } : null;
|
|
11051
|
+
models.set(project.id, { stamp, model });
|
|
11052
|
+
return model;
|
|
11053
|
+
}
|
|
11054
|
+
async function filesOf(project, commits) {
|
|
11055
|
+
const own = commits.filter((c) => c.projectId === project.id);
|
|
11056
|
+
const diffs2 = await changedFiles(project.path, own.map((c) => c.sha));
|
|
11057
|
+
const root = workTreeOf(project.path);
|
|
11058
|
+
const prefix = root ? path10.relative(root, project.path).split(path10.sep).join("/") : "";
|
|
11059
|
+
const out = /* @__PURE__ */ new Map();
|
|
11060
|
+
for (const [sha2, diff] of diffs2) {
|
|
11061
|
+
const files = diff.files.map((f) => {
|
|
11062
|
+
if (!prefix) return { file: f, inside: true };
|
|
11063
|
+
return f.startsWith(`${prefix}/`) ? { file: f.slice(prefix.length + 1), inside: true } : { file: path10.posix.relative(prefix, f), inside: false };
|
|
11064
|
+
});
|
|
11065
|
+
out.set(sha2, { files, truncated: diff.truncated });
|
|
11066
|
+
}
|
|
11067
|
+
return { own, out };
|
|
11068
|
+
}
|
|
11069
|
+
async function forItem(id) {
|
|
11070
|
+
const row = itemRow(store, parse(idSchema, id));
|
|
11071
|
+
const project = projectRow(store, row.project_id);
|
|
11072
|
+
const model = modelOf(project);
|
|
11073
|
+
const commits = await items.commits(row.id);
|
|
11074
|
+
const { own, out } = await filesOf(project, commits);
|
|
11075
|
+
const tally = new Tally();
|
|
11076
|
+
let truncated = false;
|
|
11077
|
+
if (model) {
|
|
11078
|
+
for (const c of own) {
|
|
11079
|
+
const diff = out.get(c.sha);
|
|
11080
|
+
if (!diff) continue;
|
|
11081
|
+
truncated ||= diff.truncated;
|
|
11082
|
+
for (const f of diff.files) tally.add(f.inside ? classify(model, f.file) : OTHER, f.file, c.sha, [row.id]);
|
|
11083
|
+
}
|
|
11084
|
+
}
|
|
11085
|
+
const components = tally.list().map(({ items: _, paths, ...c }) => ({ ...c, paths: paths.slice(0, MAX_TOUCH_PATHS) })).sort((a, b) => otherLast(a, b) || b.files - a.files || b.commits - a.commits || a.label.localeCompare(b.label));
|
|
11086
|
+
return { itemId: row.id, model: model?.kind ?? null, commits: own.length, components, truncated };
|
|
11087
|
+
}
|
|
11088
|
+
async function forMilestone(projectId, milestone) {
|
|
11089
|
+
const project = projectRow(store, parse(idSchema, projectId));
|
|
11090
|
+
const wanted = milestone === void 0 || milestone === null ? milestone : parse(milestoneSchema, milestone);
|
|
11091
|
+
const all = wanted === void 0;
|
|
11092
|
+
const model = modelOf(project);
|
|
11093
|
+
const scope = new Set(
|
|
11094
|
+
store.db.prepare("SELECT id, milestone FROM items WHERE project_id = ?").all(project.id).filter((r) => all || r.milestone === wanted).map((r) => r.id)
|
|
11095
|
+
);
|
|
11096
|
+
const related = (await items.relatedCommits(project)).map((c) => ({ ...c, itemIds: c.itemIds.filter((id) => scope.has(id)) })).filter((c) => c.itemIds.length > 0);
|
|
11097
|
+
const { own, out } = await filesOf(project, related);
|
|
11098
|
+
const tally = new Tally();
|
|
11099
|
+
const touchedItems = /* @__PURE__ */ new Set();
|
|
11100
|
+
let truncated = false;
|
|
11101
|
+
for (const c of own) for (const id of c.itemIds) touchedItems.add(id);
|
|
11102
|
+
if (model) {
|
|
11103
|
+
for (const c of own) {
|
|
11104
|
+
const diff = out.get(c.sha);
|
|
11105
|
+
if (!diff) continue;
|
|
11106
|
+
truncated ||= diff.truncated;
|
|
11107
|
+
for (const f of diff.files) tally.add(f.inside ? classify(model, f.file) : OTHER, f.file, c.sha, c.itemIds);
|
|
11108
|
+
}
|
|
11109
|
+
}
|
|
11110
|
+
const components = tally.list().map(({ paths: _, ...c }) => c).sort((a, b) => otherLast(a, b) || b.items - a.items || b.files - a.files || a.label.localeCompare(b.label));
|
|
11111
|
+
return { projectId: project.id, milestone: all ? null : wanted, all, model: model?.kind ?? null, items: touchedItems.size, commits: own.length, components, truncated };
|
|
11112
|
+
}
|
|
11113
|
+
return { forItem, forMilestone };
|
|
11114
|
+
}
|
|
11115
|
+
|
|
10602
11116
|
// ../core/src/services/index.ts
|
|
10603
11117
|
function createServices(store, options = {}) {
|
|
10604
11118
|
const ctx = createCtx(store, options);
|
|
@@ -10615,7 +11129,10 @@ function createServices(store, options = {}) {
|
|
|
10615
11129
|
const overview = createOverviewService(ctx);
|
|
10616
11130
|
const todos = createTodoService(ctx, items, statuses);
|
|
10617
11131
|
const roadmapFile = createRoadmapFileService(ctx, exporter);
|
|
10618
|
-
|
|
11132
|
+
const architecture = createArchitectureService(ctx, events);
|
|
11133
|
+
const touch = createTouchService(ctx, items);
|
|
11134
|
+
const archAuto = createArchAutoService(ctx);
|
|
11135
|
+
return { store, events, workspaces, projects, statuses, items, refs, links, export: exporter, import: importer, overview, todos, roadmapFile, architecture, archAuto, touch };
|
|
10619
11136
|
}
|
|
10620
11137
|
|
|
10621
11138
|
export {
|
|
@@ -10680,21 +11197,30 @@ export {
|
|
|
10680
11197
|
resolveItemId,
|
|
10681
11198
|
loadMigrations,
|
|
10682
11199
|
Store,
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
11200
|
+
KEY_TOKEN,
|
|
11201
|
+
mentionsIn,
|
|
11202
|
+
saysNoItem,
|
|
11203
|
+
keyTokens,
|
|
10687
11204
|
GIT_CACHE_TTL_MS,
|
|
10688
11205
|
DEFAULT_COMMIT_SCAN,
|
|
10689
11206
|
clearGitCache,
|
|
10690
11207
|
currentBranch,
|
|
10691
11208
|
keyFromBranch,
|
|
11209
|
+
headCommit,
|
|
10692
11210
|
resolveCommit,
|
|
10693
11211
|
findCommitsMentioning,
|
|
11212
|
+
MAX_CHANGED_FILES,
|
|
11213
|
+
changedFiles,
|
|
10694
11214
|
MAX_REF_BYTES,
|
|
10695
11215
|
MAX_WORKSPACE_REPOS,
|
|
10696
11216
|
splitFileTarget,
|
|
10697
11217
|
lineSuffix,
|
|
11218
|
+
ARCHITECTURE_DIR,
|
|
11219
|
+
MAX_ARCHITECTURE_VIEWS,
|
|
11220
|
+
BOARD_FORMAT_VERSION,
|
|
11221
|
+
renderBoard,
|
|
11222
|
+
parseBoard,
|
|
11223
|
+
itemMarkdown,
|
|
10698
11224
|
DEFAULT_ROADMAP_FILE,
|
|
10699
11225
|
DEFAULT_STATUSES,
|
|
10700
11226
|
worktreeMainRepo,
|
|
@@ -10702,5 +11228,6 @@ export {
|
|
|
10702
11228
|
MAX_TODO_FILES,
|
|
10703
11229
|
MAX_TODOS,
|
|
10704
11230
|
findTodos,
|
|
11231
|
+
MAX_TOUCH_PATHS,
|
|
10705
11232
|
createServices
|
|
10706
11233
|
};
|