project-spec 0.9.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -14
- package/bin/project-spec.mjs +129 -15
- package/package.json +2 -1
- package/skills/project-knowledge/SKILL.md +23 -7
- package/skills/project-knowledge/references/agents.md +30 -0
- package/skills/project-knowledge/references/format.md +5 -3
- package/skills/project-knowledge/references/gaps.md +7 -2
- package/skills/project-knowledge/references/sync.md +1 -1
- package/skills/project-knowledge/scripts/coverage.py +7 -3
- package/skills/project-knowledge/scripts/knowledge.py +74 -5
- package/{skills/project-knowledge/assets → viewer}/viewer.html +251 -52
- package/skills/project-knowledge/scripts/test_coverage.py +0 -128
- package/skills/project-knowledge/scripts/test_knowledge.py +0 -1276
- package/skills/project-knowledge/scripts/test_maintain.py +0 -864
- package/skills/project-knowledge/scripts/test_merge.py +0 -165
- package/skills/spec-change/LICENSE +0 -21
- package/skills/spec-change/SKILL.md +0 -63
- package/skills/spec-change/agents/openai.yaml +0 -4
- package/skills/spec-change/references/gaps.md +0 -159
- /package/skills/{spec-change → project-knowledge}/references/plan.md +0 -0
|
@@ -417,6 +417,54 @@
|
|
|
417
417
|
.map-head .pillrow {
|
|
418
418
|
gap: 6px;
|
|
419
419
|
}
|
|
420
|
+
/* The queue's states are tabs, plain words with a count, so the row of filters under them stays quiet. */
|
|
421
|
+
.tabrow {
|
|
422
|
+
display: flex;
|
|
423
|
+
flex-wrap: wrap;
|
|
424
|
+
gap: 0 22px;
|
|
425
|
+
border-bottom: 1px solid var(--line);
|
|
426
|
+
}
|
|
427
|
+
.tab {
|
|
428
|
+
display: inline-flex;
|
|
429
|
+
align-items: baseline;
|
|
430
|
+
gap: 6px;
|
|
431
|
+
min-height: 36px;
|
|
432
|
+
padding: 0 1px;
|
|
433
|
+
margin-bottom: -1px;
|
|
434
|
+
border: 0;
|
|
435
|
+
border-bottom: 2px solid transparent;
|
|
436
|
+
background: none;
|
|
437
|
+
color: var(--muted);
|
|
438
|
+
font: 600 14px/1 var(--sans);
|
|
439
|
+
}
|
|
440
|
+
.tab:hover {
|
|
441
|
+
color: var(--ink);
|
|
442
|
+
}
|
|
443
|
+
.tab[aria-pressed="true"] {
|
|
444
|
+
color: var(--ink);
|
|
445
|
+
border-bottom-color: var(--ink);
|
|
446
|
+
}
|
|
447
|
+
.tab .n {
|
|
448
|
+
font: 12px var(--mono);
|
|
449
|
+
opacity: 0.75;
|
|
450
|
+
}
|
|
451
|
+
.filters {
|
|
452
|
+
display: flex;
|
|
453
|
+
flex-wrap: wrap;
|
|
454
|
+
align-items: center;
|
|
455
|
+
gap: 8px;
|
|
456
|
+
}
|
|
457
|
+
.filters select {
|
|
458
|
+
max-width: 220px;
|
|
459
|
+
}
|
|
460
|
+
.filters .push {
|
|
461
|
+
margin-left: auto;
|
|
462
|
+
}
|
|
463
|
+
@media (pointer: coarse) {
|
|
464
|
+
.tab {
|
|
465
|
+
min-height: 44px;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
420
468
|
.view:has(> .compact) {
|
|
421
469
|
padding-top: 18px;
|
|
422
470
|
}
|
|
@@ -791,6 +839,15 @@
|
|
|
791
839
|
details.fold > :last-child {
|
|
792
840
|
margin-bottom: 20px;
|
|
793
841
|
}
|
|
842
|
+
.fold-rows .row {
|
|
843
|
+
padding-left: 0;
|
|
844
|
+
padding-right: 0;
|
|
845
|
+
}
|
|
846
|
+
.more-row {
|
|
847
|
+
display: flex;
|
|
848
|
+
align-items: center;
|
|
849
|
+
gap: 14px;
|
|
850
|
+
}
|
|
794
851
|
.here-path {
|
|
795
852
|
display: flex;
|
|
796
853
|
flex-direction: column;
|
|
@@ -1286,14 +1343,17 @@
|
|
|
1286
1343
|
padding: 20px;
|
|
1287
1344
|
overflow: hidden;
|
|
1288
1345
|
}
|
|
1346
|
+
/* One size whatever is chosen, so picking another request moves nothing: the list of requests, the
|
|
1347
|
+
fields for the chosen one and the text that gets copied each keep their place and scroll by themselves. */
|
|
1289
1348
|
.copy-card {
|
|
1290
|
-
width: min(
|
|
1291
|
-
|
|
1349
|
+
width: min(1080px, 100%);
|
|
1350
|
+
height: min(640px, calc(100vh - 40px));
|
|
1292
1351
|
padding: 22px 24px 24px;
|
|
1293
1352
|
display: grid;
|
|
1294
|
-
grid-template-columns: minmax(0, 1fr) minmax(0,
|
|
1295
|
-
|
|
1296
|
-
|
|
1353
|
+
grid-template-columns: 188px minmax(0, 1fr) minmax(0, 1.15fr);
|
|
1354
|
+
grid-template-rows: auto minmax(0, 1fr);
|
|
1355
|
+
gap: 16px 24px;
|
|
1356
|
+
overflow: hidden;
|
|
1297
1357
|
}
|
|
1298
1358
|
.copy-card > .stack {
|
|
1299
1359
|
grid-column: 1 / -1;
|
|
@@ -1301,18 +1361,53 @@
|
|
|
1301
1361
|
}
|
|
1302
1362
|
.copy-card > .stack .h2 {
|
|
1303
1363
|
font-size: 18px;
|
|
1364
|
+
overflow: hidden;
|
|
1365
|
+
text-overflow: ellipsis;
|
|
1366
|
+
white-space: nowrap;
|
|
1304
1367
|
}
|
|
1368
|
+
.copy-menu,
|
|
1305
1369
|
.copy-controls,
|
|
1306
1370
|
.copy-side {
|
|
1307
1371
|
display: flex;
|
|
1308
1372
|
flex-direction: column;
|
|
1309
1373
|
gap: 14px;
|
|
1310
1374
|
min-width: 0;
|
|
1375
|
+
min-height: 0;
|
|
1311
1376
|
}
|
|
1312
|
-
.copy-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1377
|
+
.copy-menu,
|
|
1378
|
+
.copy-controls {
|
|
1379
|
+
overflow-y: auto;
|
|
1380
|
+
}
|
|
1381
|
+
.copy-controls {
|
|
1382
|
+
padding: 0 2px 2px;
|
|
1383
|
+
}
|
|
1384
|
+
/* The requests are a list to pick from, one under another. */
|
|
1385
|
+
.copy-card .menu {
|
|
1386
|
+
flex-direction: column;
|
|
1387
|
+
flex-wrap: nowrap;
|
|
1388
|
+
gap: 2px;
|
|
1389
|
+
}
|
|
1390
|
+
.copy-card .menu .pill {
|
|
1391
|
+
width: 100%;
|
|
1392
|
+
height: 36px;
|
|
1393
|
+
justify-content: flex-start;
|
|
1394
|
+
padding: 0 12px;
|
|
1395
|
+
border-color: transparent;
|
|
1396
|
+
border-radius: 12px;
|
|
1397
|
+
background: none;
|
|
1398
|
+
font-size: 14px;
|
|
1399
|
+
text-align: left;
|
|
1400
|
+
}
|
|
1401
|
+
.copy-card .menu .pill:hover {
|
|
1402
|
+
background: var(--soft);
|
|
1403
|
+
}
|
|
1404
|
+
.copy-card .menu .pill[aria-pressed="true"] {
|
|
1405
|
+
background: var(--ink);
|
|
1406
|
+
color: #ffffff;
|
|
1407
|
+
}
|
|
1408
|
+
/* Room for the longest explanation, so a shorter one does not pull the fields up. */
|
|
1409
|
+
#copy-hint {
|
|
1410
|
+
min-height: 5.8em;
|
|
1316
1411
|
}
|
|
1317
1412
|
.copy-card .pillrow {
|
|
1318
1413
|
gap: 6px;
|
|
@@ -1337,12 +1432,43 @@
|
|
|
1337
1432
|
.copy-card .btn {
|
|
1338
1433
|
height: 36px;
|
|
1339
1434
|
}
|
|
1340
|
-
|
|
1435
|
+
.copy-side .night {
|
|
1436
|
+
flex: 1;
|
|
1437
|
+
min-height: 0;
|
|
1438
|
+
}
|
|
1439
|
+
.copy-side .night pre {
|
|
1440
|
+
flex: 1;
|
|
1441
|
+
min-height: 0;
|
|
1442
|
+
max-height: none;
|
|
1443
|
+
}
|
|
1444
|
+
@media (max-width: 880px) {
|
|
1341
1445
|
.copy-card {
|
|
1446
|
+
height: auto;
|
|
1447
|
+
max-height: calc(100vh - 40px);
|
|
1342
1448
|
grid-template-columns: minmax(0, 1fr);
|
|
1449
|
+
grid-template-rows: auto;
|
|
1450
|
+
overflow: auto;
|
|
1343
1451
|
}
|
|
1344
|
-
.copy-
|
|
1345
|
-
|
|
1452
|
+
.copy-menu,
|
|
1453
|
+
.copy-controls {
|
|
1454
|
+
overflow: visible;
|
|
1455
|
+
}
|
|
1456
|
+
.copy-card .menu {
|
|
1457
|
+
flex-direction: row;
|
|
1458
|
+
flex-wrap: wrap;
|
|
1459
|
+
gap: 6px;
|
|
1460
|
+
}
|
|
1461
|
+
.copy-card .menu .pill {
|
|
1462
|
+
width: auto;
|
|
1463
|
+
height: 32px;
|
|
1464
|
+
border-color: var(--line-strong);
|
|
1465
|
+
border-radius: 999px;
|
|
1466
|
+
}
|
|
1467
|
+
#copy-hint {
|
|
1468
|
+
min-height: 0;
|
|
1469
|
+
}
|
|
1470
|
+
.copy-side .night pre {
|
|
1471
|
+
max-height: 40vh;
|
|
1346
1472
|
}
|
|
1347
1473
|
}
|
|
1348
1474
|
.copy-card fieldset {
|
|
@@ -1381,10 +1507,6 @@
|
|
|
1381
1507
|
padding: 16px 18px;
|
|
1382
1508
|
border-radius: 16px;
|
|
1383
1509
|
}
|
|
1384
|
-
/* Tall enough to read, short enough that the dialog itself never needs a second scrollbar. */
|
|
1385
|
-
.copy-card .night pre {
|
|
1386
|
-
max-height: max(160px, calc(100vh - 380px));
|
|
1387
|
-
}
|
|
1388
1510
|
.check {
|
|
1389
1511
|
display: flex;
|
|
1390
1512
|
align-items: center;
|
|
@@ -1697,7 +1819,12 @@
|
|
|
1697
1819
|
"Someone has to confirm that the page's description of the current code is still right.",
|
|
1698
1820
|
"needs-decision":
|
|
1699
1821
|
"Rechecked; waiting for a person to accept, reject or defer.",
|
|
1822
|
+
history:
|
|
1823
|
+
"Closed questions: done, rejected, or a duplicate of another. They are kept for the reason behind a rule.",
|
|
1700
1824
|
};
|
|
1825
|
+
// A closed gap is out of the queue: it is history, read for the reason behind a rule.
|
|
1826
|
+
const CLOSED_STATES = ["done", "rejected", "duplicate"],
|
|
1827
|
+
OPEN_STATES = STATES.filter((s) => !CLOSED_STATES.includes(s));
|
|
1701
1828
|
const recheckLabels = {
|
|
1702
1829
|
"not-checked": "Not checked",
|
|
1703
1830
|
confirmed: "Confirmed (still holds)",
|
|
@@ -1727,6 +1854,13 @@
|
|
|
1727
1854
|
: "needs-recheck";
|
|
1728
1855
|
return STATES.includes(decision) ? decision : "needs-recheck";
|
|
1729
1856
|
};
|
|
1857
|
+
const isClosed = (n) => CLOSED_STATES.includes(stateOf(n));
|
|
1858
|
+
// The day a gap was closed, as far as the page says: the decision, else the recheck that closed it.
|
|
1859
|
+
const closedOn = (n) => str(n.decidedOn) || str(n.recheckedOn) || str(n.updated);
|
|
1860
|
+
const byClosed = (a, b) => closedOn(b).localeCompare(closedOn(a)) || byTitle(a, b);
|
|
1861
|
+
// The day a gap appeared. A gap without one is a page not committed yet, so it is the newest.
|
|
1862
|
+
const addedOn = (n) => str(n.added);
|
|
1863
|
+
const byAdded = (a, b) => (addedOn(b) || "9999").localeCompare(addedOn(a) || "9999") || byGapOrder(a, b);
|
|
1730
1864
|
const recheckOutdated = (n) =>
|
|
1731
1865
|
isGap(n) && (n.recheckOutdated === true || n.recheck === "outdated");
|
|
1732
1866
|
const stateRank = (n) => {
|
|
@@ -2323,6 +2457,7 @@
|
|
|
2323
2457
|
);
|
|
2324
2458
|
if (str(n.priority)) row("Priority", n.priority);
|
|
2325
2459
|
if (str(n.confidence)) row("Confidence", n.confidence);
|
|
2460
|
+
if (addedOn(n)) row("Added", addedOn(n));
|
|
2326
2461
|
box.append(dl);
|
|
2327
2462
|
return box;
|
|
2328
2463
|
}
|
|
@@ -2559,6 +2694,13 @@
|
|
|
2559
2694
|
});
|
|
2560
2695
|
return row;
|
|
2561
2696
|
};
|
|
2697
|
+
// The same choice as pills, drawn as tabs: for the one choice a page is organised by.
|
|
2698
|
+
const tabs = (label, options, current, pick) => {
|
|
2699
|
+
const row = pills(label, options, current, pick);
|
|
2700
|
+
row.className = "tabrow";
|
|
2701
|
+
Array.from(row.children).forEach((b) => (b.className = "tab"));
|
|
2702
|
+
return row;
|
|
2703
|
+
};
|
|
2562
2704
|
function featureList(features) {
|
|
2563
2705
|
const box = el("div");
|
|
2564
2706
|
features.forEach((f) => {
|
|
@@ -2595,7 +2737,7 @@
|
|
|
2595
2737
|
const row = el("div", null, "row"),
|
|
2596
2738
|
grow = el("div", null, "grow");
|
|
2597
2739
|
grow.append(button(g.title, "rowlink", () => openNode(g)));
|
|
2598
|
-
const facts = [kindLabels[g.kind] || str(g.kind), factsLine(g)].filter(Boolean).join(" · ");
|
|
2740
|
+
const facts = [kindLabels[g.kind] || str(g.kind), factsLine(g), addedOn(g) && "Added " + addedOn(g)].filter(Boolean).join(" · ");
|
|
2599
2741
|
if (facts) grow.append(el("span", facts, "muted small"));
|
|
2600
2742
|
row.append(grow, stateBadge(g));
|
|
2601
2743
|
if (recheckOutdated(g)) row.append(outdatedBadge());
|
|
@@ -2784,7 +2926,10 @@
|
|
|
2784
2926
|
// A note is read as written: what the feature is for and its rules. An area is a map of its notes.
|
|
2785
2927
|
if (n.type === "area") main.append(featureList(featuresOf(n)));
|
|
2786
2928
|
else main.append(markdown(bodyOf(n), n));
|
|
2787
|
-
const
|
|
2929
|
+
const asked = gapsAbout(n),
|
|
2930
|
+
about = asked.filter((g) => !isClosed(g)),
|
|
2931
|
+
// a duplicate is answered on the gap it repeats, so it is not a closed question of its own
|
|
2932
|
+
closed = asked.filter((g) => isClosed(g) && stateOf(g) !== "duplicate").sort(byClosed);
|
|
2788
2933
|
if (about.length) {
|
|
2789
2934
|
const card = el("section", null, "card"),
|
|
2790
2935
|
head = el("div", null, "card-head");
|
|
@@ -2795,6 +2940,11 @@
|
|
|
2795
2940
|
}
|
|
2796
2941
|
const folds = el("div");
|
|
2797
2942
|
if (n.type === "area") folds.append(fold("More about this area", markdown(bodyOf(n), n)));
|
|
2943
|
+
if (closed.length) {
|
|
2944
|
+
const list = el("div", null, "fold-rows");
|
|
2945
|
+
closed.forEach((g) => list.append(gapRow(g)));
|
|
2946
|
+
folds.append(fold("Closed questions (" + closed.length + ")", list));
|
|
2947
|
+
}
|
|
2798
2948
|
const sources = (Array.isArray(n.sources) ? n.sources : []).filter(str);
|
|
2799
2949
|
if (sources.length) {
|
|
2800
2950
|
const ul = el("ul", null, "link-list");
|
|
@@ -2815,7 +2965,10 @@
|
|
|
2815
2965
|
view.append(page);
|
|
2816
2966
|
}
|
|
2817
2967
|
|
|
2818
|
-
|
|
2968
|
+
const GAP_PORTION = 40;
|
|
2969
|
+
let gapState = "open", // "open", one of the open states, or "history"
|
|
2970
|
+
gapShown = GAP_PORTION,
|
|
2971
|
+
gapSort = "urgent", // "urgent" (state, then priority) or "newest" (the day the gap appeared)
|
|
2819
2972
|
gapArea = "",
|
|
2820
2973
|
gapKind = "",
|
|
2821
2974
|
gapPriority = ""; // "" for all, "none" for gaps without one, otherwise the value
|
|
@@ -2835,7 +2988,8 @@
|
|
|
2835
2988
|
// The queue is a work list: one row of title and filters, then the gaps.
|
|
2836
2989
|
function viewGaps(view) {
|
|
2837
2990
|
const box = el("div", null, "stack compact"),
|
|
2838
|
-
head = el("div", null, "map-head")
|
|
2991
|
+
head = el("div", null, "map-head"),
|
|
2992
|
+
filters = el("div", null, "filters");
|
|
2839
2993
|
head.append(el("h1", "Gaps"));
|
|
2840
2994
|
head.title = "Questions about what is missing, unverified or could be added. Each one is rechecked and then decided by a person.";
|
|
2841
2995
|
box.append(head);
|
|
@@ -2846,17 +3000,21 @@
|
|
|
2846
3000
|
(!gapKind || n.kind === gapKind) &&
|
|
2847
3001
|
(!gapPriority || (priorityOf(n) || "none") === gapPriority),
|
|
2848
3002
|
),
|
|
2849
|
-
again = () =>
|
|
2850
|
-
|
|
2851
|
-
|
|
3003
|
+
again = () => {
|
|
3004
|
+
gapShown = GAP_PORTION;
|
|
3005
|
+
show();
|
|
3006
|
+
},
|
|
3007
|
+
history = pool.filter(isClosed).length;
|
|
3008
|
+
box.append(
|
|
3009
|
+
tabs(
|
|
2852
3010
|
"State",
|
|
2853
|
-
//
|
|
3011
|
+
// The queue is the open work; what is closed is one step away, under History. A state with
|
|
3012
|
+
// no gaps under the current filters is left out, unless it is the one selected.
|
|
2854
3013
|
[
|
|
2855
|
-
["
|
|
2856
|
-
...
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
],
|
|
3014
|
+
["open", "Open", pool.length - history],
|
|
3015
|
+
...OPEN_STATES.map((s) => [s, stateLabels[s], pool.filter((g) => stateOf(g) === s).length]),
|
|
3016
|
+
["history", "History", history],
|
|
3017
|
+
].filter(([s, , count]) => count || s === gapState || s === "open"),
|
|
2860
3018
|
gapState,
|
|
2861
3019
|
(s) => {
|
|
2862
3020
|
gapState = s;
|
|
@@ -2864,12 +3022,13 @@
|
|
|
2864
3022
|
},
|
|
2865
3023
|
),
|
|
2866
3024
|
);
|
|
3025
|
+
box.append(filters);
|
|
2867
3026
|
if (stateHints[gapState]) box.append(el("p", stateHints[gapState], "muted small"));
|
|
2868
3027
|
const kinds = Object.keys(kindLabels);
|
|
2869
3028
|
nodes.forEach((n) => {
|
|
2870
3029
|
if (isGap(n) && str(n.kind) && !kinds.includes(n.kind)) kinds.push(n.kind);
|
|
2871
3030
|
});
|
|
2872
|
-
|
|
3031
|
+
filters.append(
|
|
2873
3032
|
selectOf("Area", areaOptions(), gapArea, (v) => {
|
|
2874
3033
|
gapArea = v;
|
|
2875
3034
|
again();
|
|
@@ -2884,7 +3043,7 @@
|
|
|
2884
3043
|
(a, b) => priorityRank({ priority: a }) - priorityRank({ priority: b }) || a.localeCompare(b),
|
|
2885
3044
|
);
|
|
2886
3045
|
if (priorities.length || gapPriority)
|
|
2887
|
-
|
|
3046
|
+
filters.append(
|
|
2888
3047
|
selectOf(
|
|
2889
3048
|
"Priority",
|
|
2890
3049
|
[
|
|
@@ -2899,15 +3058,45 @@
|
|
|
2899
3058
|
},
|
|
2900
3059
|
),
|
|
2901
3060
|
);
|
|
3061
|
+
const order = selectOf(
|
|
3062
|
+
"Order",
|
|
3063
|
+
[
|
|
3064
|
+
["urgent", gapState === "history" ? "Last closed first" : "Most urgent first"],
|
|
3065
|
+
["newest", "Newest first"],
|
|
3066
|
+
],
|
|
3067
|
+
gapSort,
|
|
3068
|
+
(v) => {
|
|
3069
|
+
gapSort = v;
|
|
3070
|
+
again();
|
|
3071
|
+
},
|
|
3072
|
+
);
|
|
3073
|
+
order.className = "push";
|
|
3074
|
+
filters.append(order);
|
|
2902
3075
|
const shown = pool
|
|
2903
|
-
.filter((g) => gapState === "
|
|
2904
|
-
.sort(byGapOrder);
|
|
3076
|
+
.filter((g) => (gapState === "open" ? !isClosed(g) : gapState === "history" ? isClosed(g) : stateOf(g) === gapState))
|
|
3077
|
+
.sort(gapSort === "newest" ? byAdded : gapState === "history" ? byClosed : byGapOrder);
|
|
2905
3078
|
if (shown.length) {
|
|
2906
|
-
|
|
3079
|
+
// A long queue comes in portions: the most urgent are in the first one, the rest one press away.
|
|
3080
|
+
const card = el("section", null, "card"),
|
|
3081
|
+
more = el("div", null, "more-row");
|
|
2907
3082
|
card.id = "gap-list";
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
3083
|
+
const fill = () => {
|
|
3084
|
+
const upto = Math.min(gapShown, shown.length);
|
|
3085
|
+
card.replaceChildren(...shown.slice(0, upto).map(gapRow));
|
|
3086
|
+
more.replaceChildren();
|
|
3087
|
+
if (shown.length <= GAP_PORTION) return;
|
|
3088
|
+
if (upto < shown.length)
|
|
3089
|
+
more.append(
|
|
3090
|
+
button("Show " + Math.min(GAP_PORTION, shown.length - upto) + " more", "btn", () => {
|
|
3091
|
+
gapShown += GAP_PORTION;
|
|
3092
|
+
fill();
|
|
3093
|
+
}),
|
|
3094
|
+
);
|
|
3095
|
+
more.append(el("span", upto + " of " + shown.length, "muted small"));
|
|
3096
|
+
};
|
|
3097
|
+
fill();
|
|
3098
|
+
box.append(card, more);
|
|
3099
|
+
} else box.append(el("p", gapState === "history" ? "Nothing is closed yet." : "No gaps match. Try other filters.", "empty"));
|
|
2911
3100
|
view.append(box);
|
|
2912
3101
|
}
|
|
2913
3102
|
|
|
@@ -3148,15 +3337,15 @@
|
|
|
3148
3337
|
hint: "The agent writes a plan for an accepted gap: steps, checks, what must be decided first. No code is changed.",
|
|
3149
3338
|
ask: "Limits or wishes for the plan (optional)",
|
|
3150
3339
|
text: (c) =>
|
|
3151
|
-
"Use the
|
|
3340
|
+
"Use the project-knowledge skill to plan this gap. Plan only, do not build it, and only if its decision is accepted; otherwise tell me what is missing." +
|
|
3152
3341
|
(c.note ? "\n\nKeep in mind: " + c.note : ""),
|
|
3153
3342
|
},
|
|
3154
3343
|
change: {
|
|
3155
3344
|
label: "Change the behavior",
|
|
3156
|
-
hint: "You want the product to work differently. The agent asks its questions first, then
|
|
3345
|
+
hint: "You want the product to work differently. The agent asks its questions first, changes the code, then corrects this page so it says what the code does now.",
|
|
3157
3346
|
ask: "What should be different, and for whom",
|
|
3158
3347
|
text: (c) =>
|
|
3159
|
-
"
|
|
3348
|
+
"I want to change the behavior this page describes. Ask your questions first, then change the code and check it. When the code is done, record the change in the spec as the project-knowledge skill describes (Record a change): correct only the rules that changed, and keep their numbers." +
|
|
3160
3349
|
"\n\nWhat I want: " + (c.note || "[describe the change]"),
|
|
3161
3350
|
},
|
|
3162
3351
|
question: {
|
|
@@ -3256,17 +3445,19 @@
|
|
|
3256
3445
|
meta.append(isGap(n) ? stateBadge(n) : statusBadge(n), el("span", repoPath(n), "path"));
|
|
3257
3446
|
top.append(el("div", "Copy for AI", "eyebrow"), el("h2", n.title, "h2"), meta);
|
|
3258
3447
|
|
|
3259
|
-
const want = el("fieldset")
|
|
3260
|
-
|
|
3261
|
-
el("legend", "What should the agent do?"),
|
|
3262
|
-
pills("What should the agent do?", intentsFor(n).map((k) => [k, INTENTS[k].label]), copyState.intent, (v) => {
|
|
3448
|
+
const want = el("fieldset"),
|
|
3449
|
+
menu = pills("What should the agent do?", intentsFor(n).map((k) => [k, INTENTS[k].label]), copyState.intent, (v) => {
|
|
3263
3450
|
copyState.intent = v;
|
|
3451
|
+
copyState.refocus = true;
|
|
3264
3452
|
renderCopy();
|
|
3265
|
-
})
|
|
3266
|
-
|
|
3267
|
-
|
|
3453
|
+
});
|
|
3454
|
+
menu.className = "pillrow menu";
|
|
3455
|
+
want.append(el("legend", "What should the agent do?"), menu);
|
|
3456
|
+
const hint = el("p", intent.hint, "muted small"),
|
|
3457
|
+
chosen = el("div", null, "stack");
|
|
3268
3458
|
hint.id = "copy-hint";
|
|
3269
|
-
|
|
3459
|
+
chosen.style.gap = "10px";
|
|
3460
|
+
chosen.append(hint);
|
|
3270
3461
|
if (intent.choices) {
|
|
3271
3462
|
const [key, options] = intent.choices,
|
|
3272
3463
|
sub = pills(intent.label, options, copyState[key], (v) => {
|
|
@@ -3274,7 +3465,7 @@
|
|
|
3274
3465
|
renderCopy();
|
|
3275
3466
|
});
|
|
3276
3467
|
sub.id = "copy-choice";
|
|
3277
|
-
|
|
3468
|
+
chosen.append(sub);
|
|
3278
3469
|
}
|
|
3279
3470
|
|
|
3280
3471
|
// Typing updates the preview in place, so the field keeps the cursor.
|
|
@@ -3326,11 +3517,19 @@
|
|
|
3326
3517
|
actions.append(copy, button("Close", "btn", closeCopy), el("span", "Nothing is sent. It goes to your clipboard.", "muted small"));
|
|
3327
3518
|
const preview = el("div", null, "night");
|
|
3328
3519
|
preview.append(el("div", "What gets copied", "eyebrow"), pre);
|
|
3329
|
-
const
|
|
3520
|
+
const list = el("div", null, "copy-menu"),
|
|
3521
|
+
controls = el("div", null, "copy-controls"),
|
|
3330
3522
|
side = el("div", null, "copy-side");
|
|
3331
|
-
|
|
3523
|
+
list.append(want);
|
|
3524
|
+
controls.append(chosen, words, include);
|
|
3332
3525
|
side.append(preview, actions);
|
|
3333
|
-
card.append(top, controls, side);
|
|
3526
|
+
card.append(top, list, controls, side);
|
|
3527
|
+
// The card was drawn again, so hand the keyboard back to the request that was picked.
|
|
3528
|
+
if (copyState.refocus) {
|
|
3529
|
+
copyState.refocus = false;
|
|
3530
|
+
const now = Array.from(menu.children).find((b) => b.getAttribute("aria-pressed") === "true");
|
|
3531
|
+
if (now && now.focus) now.focus();
|
|
3532
|
+
}
|
|
3334
3533
|
}
|
|
3335
3534
|
$("#copydlg").addEventListener("click", (e) => {
|
|
3336
3535
|
if (e.target === $("#copydlg")) closeCopy();
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import subprocess
|
|
3
|
-
import sys
|
|
4
|
-
import tempfile
|
|
5
|
-
import unittest
|
|
6
|
-
from contextlib import redirect_stderr, redirect_stdout
|
|
7
|
-
from io import StringIO
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
|
|
10
|
-
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
11
|
-
import coverage as c # noqa: E402
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class CoverageTests(unittest.TestCase):
|
|
15
|
-
def setUp(self):
|
|
16
|
-
self.temp = tempfile.TemporaryDirectory()
|
|
17
|
-
self.repo = Path(self.temp.name).resolve() / 'repo'
|
|
18
|
-
self.vault = self.repo / 'knowledge/demo'
|
|
19
|
-
(self.vault / 'notes').mkdir(parents=True)
|
|
20
|
-
(self.vault / 'areas').mkdir()
|
|
21
|
-
self.page('00-index.md', 'index', 'index', areas=[], body='[[areas/chat]]')
|
|
22
|
-
self.page('areas/chat.md', 'chat', 'area', areas=[], body='[[notes/chats]]')
|
|
23
|
-
self.page('notes/chats.md', 'chats', sources=['src/chat/send.ts'],
|
|
24
|
-
body='A message is refused with "Message can’t be empty". At most 10 photos (`CHAT_MAX_MEDIA`).\n\n'
|
|
25
|
-
'| ID | Rule |\n| --- | --- |\n| BR-CHAT-01 | Only group chats can be renamed, by a member \\| staff. |')
|
|
26
|
-
self.code('src/chat/send.ts', '''
|
|
27
|
-
export const CHAT_MAX_MEDIA = 10;
|
|
28
|
-
export const COLD_OUTREACH_PER_HOUR: number = 5; // new people
|
|
29
|
-
const RETRY_MS = 60 * 1000
|
|
30
|
-
const queryKey = "chats.list";
|
|
31
|
-
throw new Error("Message can't be empty");
|
|
32
|
-
throw new Error('Only group chats can be renamed');
|
|
33
|
-
throw new Error("You cannot remove yourself");
|
|
34
|
-
console.error("Failed to load the chat list");
|
|
35
|
-
const cls = "flex items-center gap-2 Text here";
|
|
36
|
-
const sql = "SELECT id FROM chats WHERE owner = 1";
|
|
37
|
-
''')
|
|
38
|
-
self.code('src/chat/window/Header.tsx', '<Button>Back to chat list</Button>\n<p>{count} unread</p>\nconst t = `Hello ${name}, welcome back`;')
|
|
39
|
-
self.code('src/chat/window/deep/Picker.tsx', 'const label = "Smileys and people";')
|
|
40
|
-
self.code('src/chat/send.test.ts', 'it("says this in a test only", () => {})')
|
|
41
|
-
self.code('src/chat/__tests__/more.ts', 'const s = "Only in a test folder";')
|
|
42
|
-
self.code('src/orders/pay.py', 'MAX_TOTAL = 5000\nmessage = "The order was already paid"\n')
|
|
43
|
-
self.code('database/migrations/001.sql', "INSERT INTO t VALUES ('A sentence in a migration');")
|
|
44
|
-
self.code('node_modules/x/index.js', 'const s = "A sentence in a dependency";')
|
|
45
|
-
self.code('src/help/article.ts', '\n'.join(f'const p{i} = "This is paragraph number {i} of an article";' for i in range(45)))
|
|
46
|
-
(self.repo / 'README.md').write_text('Not code. "A sentence in the readme file"', encoding='utf-8')
|
|
47
|
-
|
|
48
|
-
def tearDown(self):
|
|
49
|
-
self.temp.cleanup()
|
|
50
|
-
|
|
51
|
-
def page(self, path, ident, ptype='note', areas=None, sources=None, body=''):
|
|
52
|
-
meta = {'id': ident, 'title': 'Page ' + ident, 'type': ptype, 'status': 'current', 'areas': ['chat'] if areas is None else areas,
|
|
53
|
-
'sources': sources or [], 'updated': '2026-11-18'}
|
|
54
|
-
(self.vault / path).write_text('---\n' + ''.join(f'{key}: {json.dumps(value)}\n' for key, value in meta.items()) + '---\n' + body, encoding='utf-8')
|
|
55
|
-
|
|
56
|
-
def code(self, path, text):
|
|
57
|
-
file = self.repo / path
|
|
58
|
-
file.parent.mkdir(parents=True, exist_ok=True)
|
|
59
|
-
file.write_text(text, encoding='utf-8')
|
|
60
|
-
|
|
61
|
-
def run_cli(self, *args):
|
|
62
|
-
out, err = StringIO(), StringIO()
|
|
63
|
-
with redirect_stdout(out), redirect_stderr(err):
|
|
64
|
-
status = c.main(['--repo', str(self.repo), *args])
|
|
65
|
-
return status, out.getvalue(), err.getvalue()
|
|
66
|
-
|
|
67
|
-
def measured(self, *prefixes):
|
|
68
|
-
import knowledge
|
|
69
|
-
notes = knowledge.load_vault(self.repo, self.vault, freshness=False, absent=[])[0]
|
|
70
|
-
return c.measure(self.repo, self.vault, notes, prefixes)
|
|
71
|
-
|
|
72
|
-
def test_reads_only_the_application_code(self):
|
|
73
|
-
self.assertEqual(sorted(self.measured()), ['src/chat/send.ts', 'src/chat/window/Header.tsx', 'src/chat/window/deep/Picker.tsx',
|
|
74
|
-
'src/help/article.ts', 'src/orders/pay.py'])
|
|
75
|
-
# with Git, an ignored folder is left out as well, and an untracked file is still read
|
|
76
|
-
subprocess.run(['git', '-C', str(self.repo), 'init', '-q'], check=True)
|
|
77
|
-
(self.repo / '.gitignore').write_text('src/orders/\n', encoding='utf-8')
|
|
78
|
-
self.assertNotIn('src/orders/pay.py', self.measured())
|
|
79
|
-
self.assertIn('src/chat/send.ts', self.measured())
|
|
80
|
-
|
|
81
|
-
def test_finds_the_sentences_and_numbers_no_page_mentions(self):
|
|
82
|
-
files = self.measured()
|
|
83
|
-
send = files['src/chat/send.ts']
|
|
84
|
-
self.assertEqual((send['cited'], send['sentences'], send['limits']), (True, 3, 3))
|
|
85
|
-
self.assertEqual(send['unquoted'], ['You cannot remove yourself'], 'a curly apostrophe and a table row still match; logs, class lists and queries are not sentences')
|
|
86
|
-
self.assertEqual(send['unnamed'], [('COLD_OUTREACH_PER_HOUR', '5'), ('RETRY_MS', '60 * 1000')])
|
|
87
|
-
self.assertEqual(files['src/chat/window/Header.tsx']['unquoted'], ['Back to chat list'], 'text between tags counts; text with a placeholder does not')
|
|
88
|
-
self.assertEqual(files['src/orders/pay.py']['unnamed'], [('MAX_TOTAL', '5000')])
|
|
89
|
-
article = files['src/help/article.ts']
|
|
90
|
-
self.assertEqual((article['content'], article['sentences'], article['unquoted']), (True, 0, []), 'an article counts as a file only')
|
|
91
|
-
|
|
92
|
-
def test_groups_by_folder_and_keeps_an_uncited_folder_as_one_line(self):
|
|
93
|
-
groups = c.folders(self.measured())
|
|
94
|
-
self.assertEqual(sorted(groups), ['src/chat', 'src/chat/window', 'src/help', 'src/orders'])
|
|
95
|
-
self.assertEqual(groups['src/chat/window'], {'files': 2, 'lines': 4, 'cited': 0, 'sentences': 2, 'unquoted': 2, 'limits': 0, 'unnamed': 0})
|
|
96
|
-
self.assertEqual((groups['src/chat']['files'], groups['src/chat']['cited']), (1, 1))
|
|
97
|
-
# nothing cited anywhere: one line per top folder, and never above the folder that was asked for
|
|
98
|
-
self.page('notes/chats.md', 'chats', sources=['README.md'])
|
|
99
|
-
self.assertEqual(sorted(c.folders(self.measured())), ['src'])
|
|
100
|
-
self.assertEqual(sorted(c.folders(self.measured('src/chat'), ['src/chat'])), ['src/chat'])
|
|
101
|
-
|
|
102
|
-
def test_report_lists_what_to_read(self):
|
|
103
|
-
status, out, err = self.run_cli()
|
|
104
|
-
self.assertEqual((status, err), (0, ''))
|
|
105
|
-
self.assertIn('coverage: 5 code files, ', out)
|
|
106
|
-
self.assertIn('pages cite 1 of them', out)
|
|
107
|
-
self.assertIn('6 sentences a person can see, 4 on no page; 4 named numbers, 3 on no page', out)
|
|
108
|
-
self.assertIn('1 files that are mostly text (articles, templates) count as files only', out)
|
|
109
|
-
self.assertLess(out.index('src/chat/window'), out.index('src/help'), 'the folder with the most to read comes first')
|
|
110
|
-
self.assertNotIn('things under', out)
|
|
111
|
-
status, out, _ = self.run_cli('--path', 'src/chat/')
|
|
112
|
-
self.assertIn('coverage: 3 code files', out)
|
|
113
|
-
self.assertIn('5 things under src/chat that no page mentions:', out)
|
|
114
|
-
self.assertIn(' src/chat/send.ts says: You cannot remove yourself', out)
|
|
115
|
-
self.assertIn(' src/chat/send.ts sets: RETRY_MS = 60 * 1000', out)
|
|
116
|
-
self.assertIn('2 of 3 files there are cited by no page', out)
|
|
117
|
-
self.assertEqual(self.run_cli('--path', 'nowhere')[1].strip(), 'coverage: no code files found under nowhere')
|
|
118
|
-
|
|
119
|
-
def test_a_vault_with_errors_is_reported_and_still_measured(self):
|
|
120
|
-
self.page('notes/bad.md', 'bad', sources=['src/chat/send.ts'], body='[[missing-page]]')
|
|
121
|
-
status, out, err = self.run_cli()
|
|
122
|
-
self.assertEqual(status, 0)
|
|
123
|
-
self.assertIn('the vault has 1 errors', err)
|
|
124
|
-
self.assertIn('coverage: 5 code files', out)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if __name__ == '__main__':
|
|
128
|
-
unittest.main()
|