yadflow 4.10.0 → 4.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/CHANGELOG.md +97 -0
- package/README.md +12 -3
- package/bin/commands.mjs +5 -1
- package/bin/yad.mjs +109 -15
- package/cli/agent-guard-worker.mjs +13 -0
- package/cli/agent-guard.mjs +1053 -57
- package/cli/agent-rules.mjs +34 -3
- package/cli/argv-flags.mjs +2 -2
- package/cli/brain/vendor/LICENSE-graphology-library.txt +21 -0
- package/cli/brain/vendor/LICENSE-graphology.txt +21 -0
- package/cli/brain/vendor/LICENSE-sigma.txt +12 -0
- package/cli/brain/vendor/graphology-library.min.js +2 -0
- package/cli/brain/vendor/graphology.umd.min.js +2 -0
- package/cli/brain/vendor/sigma.min.js +1369 -0
- package/cli/brain/view/app.js +382 -0
- package/cli/brain/view/index.html +63 -0
- package/cli/brain/view/live.css +228 -0
- package/cli/brain/view/live.html +110 -0
- package/cli/brain/view/live.js +884 -0
- package/cli/brain/view/style.css +141 -0
- package/cli/brain-about.mjs +206 -0
- package/cli/brain-activity.mjs +285 -0
- package/cli/brain-skills.mjs +118 -0
- package/cli/brain-vendor.mjs +71 -0
- package/cli/brain-view.mjs +344 -0
- package/cli/brain.mjs +810 -0
- package/cli/ci-check.mjs +3 -3
- package/cli/doctor.mjs +80 -13
- package/cli/epic-state.mjs +93 -1
- package/cli/epic.mjs +15 -3
- package/cli/errors.mjs +2 -1
- package/cli/find-product.mjs +69 -15
- package/cli/foundation-publish.mjs +256 -0
- package/cli/gate.mjs +29 -3
- package/cli/git-read.mjs +38 -0
- package/cli/guard-stream.mjs +409 -0
- package/cli/hook.mjs +59 -9
- package/cli/issues-act.mjs +57 -13
- package/cli/issues-write.mjs +19 -6
- package/cli/issues.mjs +62 -23
- package/cli/lib.mjs +37 -2
- package/cli/local-page.mjs +138 -0
- package/cli/machine.mjs +1 -1
- package/cli/manifest.mjs +50 -0
- package/cli/map/view/app.js +712 -0
- package/cli/map/view/index.html +50 -0
- package/cli/map/view/style.css +142 -0
- package/cli/map-view.mjs +186 -0
- package/cli/map.mjs +637 -0
- package/cli/members.mjs +9 -15
- package/cli/next.mjs +1 -1
- package/cli/openpr.mjs +2 -2
- package/cli/plan.mjs +125 -0
- package/cli/platform.mjs +5 -5
- package/cli/product-index.mjs +1 -1
- package/cli/protection.mjs +32 -0
- package/cli/reconcile.mjs +8 -2
- package/cli/report.mjs +9 -3
- package/cli/reports-dir.mjs +391 -0
- package/cli/reports.mjs +65 -0
- package/cli/run-checks.mjs +5 -2
- package/cli/scan.mjs +1 -1
- package/cli/setup.mjs +30 -5
- package/cli/standup.mjs +87 -71
- package/cli/status.mjs +6 -5
- package/cli/test-agents-file.mjs +614 -8
- package/cli/test-brain-activity.mjs +753 -0
- package/cli/test-brain-view.mjs +381 -0
- package/cli/test-brain.mjs +795 -0
- package/cli/test-guide.mjs +211 -0
- package/cli/test-machine.mjs +59 -0
- package/cli/test-map.mjs +615 -0
- package/cli/test-reports.mjs +382 -0
- package/cli/test-run-checks.mjs +4 -0
- package/cli/test-worktree.mjs +24 -3
- package/cli/toolbox-connect.mjs +21 -6
- package/cli/toolbox.mjs +59 -4
- package/cli/update-commit.mjs +101 -9
- package/cli/usage.mjs +8 -4
- package/package.json +8 -4
- package/skills/yad-architecture/SKILL.md +22 -4
- package/skills/yad-change/SKILL.md +3 -1
- package/skills/yad-change/references/triage.md +2 -0
- package/skills/yad-checks/SKILL.md +2 -0
- package/skills/yad-checks/references/check-gates.md +8 -5
- package/skills/yad-checks/templates/checks/build-test-lint.sh +7 -0
- package/skills/yad-checks/templates/checks/install-deps.sh +6 -0
- package/skills/yad-checks/templates/checks/package-manager.sh +42 -0
- package/skills/yad-checks/templates/github/yad-checks.yml +3 -2
- package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +3 -2
- package/skills/yad-checks/templates/hooks/yad-activity.mjs +238 -0
- package/skills/yad-connect-repos/SKILL.md +14 -0
- package/skills/yad-discovery/SKILL.md +11 -0
- package/skills/yad-discovery/references/foundation-schema.md +11 -0
- package/skills/yad-docs/templates/app/package-lock.json +18 -10
- package/skills/yad-docs/templates/app/package.json +6 -1
- package/skills/yad-epic/SKILL.md +3 -0
- package/skills/yad-epic/references/state-schema.md +35 -1
- package/skills/yad-guide/SKILL.md +4 -4
- package/skills/yad-implement/SKILL.md +76 -15
- package/skills/yad-issues/SKILL.md +2 -1
- package/skills/yad-pr-template/templates/checks/pr-template.sh +8 -4
- package/skills/yad-pr-template/templates/checks/pr-title.sh +8 -4
- package/skills/yad-spec/SKILL.md +19 -0
- package/skills/yad-stories/SKILL.md +22 -4
- package/skills/yad-stories/references/story-schema.md +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; base-uri 'none'; form-action 'none'">
|
|
7
|
+
<meta name="referrer" content="no-referrer">
|
|
8
|
+
<title>Progress Map</title>
|
|
9
|
+
<link rel="stylesheet" href="style.css?t=__TOKEN__">
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<canvas id="bg" aria-hidden="true"></canvas>
|
|
13
|
+
<canvas id="fx" role="img" aria-label="Animated map of epics, stories, tasks and branches flowing toward Production. Use the List button for a table of the same information."></canvas>
|
|
14
|
+
|
|
15
|
+
<header>
|
|
16
|
+
<div class="brand"><h1 id="title">Road to Production</h1><p id="asof"></p><p id="sub"><span id="live" hidden><i class="dot"></i>Live</span><span id="anon" class="chip" hidden>anonymous</span><button id="moved" class="linkish" type="button" hidden></button></p></div>
|
|
17
|
+
<div class="tiles" id="tiles"></div>
|
|
18
|
+
</header>
|
|
19
|
+
|
|
20
|
+
<footer class="glass">
|
|
21
|
+
<div id="legend" role="group" aria-label="Status. Click one to isolate it."></div>
|
|
22
|
+
<div id="controls">
|
|
23
|
+
<input id="q" type="search" placeholder="Find an epic, branch, person…" aria-label="Find">
|
|
24
|
+
<button id="bPeople" aria-expanded="false" aria-controls="people" title="Who owns, builds, reviews and approves">People</button>
|
|
25
|
+
<button id="bList" title="Show everything as a table">List</button>
|
|
26
|
+
<button id="bPause" aria-pressed="false" title="Pause or resume the motion">Pause</button>
|
|
27
|
+
<button id="bOut" aria-label="Zoom out">−</button>
|
|
28
|
+
<button id="bIn" aria-label="Zoom in">+</button>
|
|
29
|
+
<button id="bFit" title="Fit everything on screen">Fit</button>
|
|
30
|
+
</div>
|
|
31
|
+
</footer>
|
|
32
|
+
|
|
33
|
+
<section id="people" class="glass" aria-label="People" hidden>
|
|
34
|
+
<div class="pbar"><h2>People</h2><button id="pClear" class="x" type="button">Show everyone</button></div>
|
|
35
|
+
<div id="roles" role="group" aria-label="Role"></div>
|
|
36
|
+
<ul id="plist" class="kids"></ul>
|
|
37
|
+
<p class="muted small">Who owns, builds, reviews and approves each part. No counts, no ranking.</p>
|
|
38
|
+
</section>
|
|
39
|
+
|
|
40
|
+
<div id="tip" class="glass" role="status"></div>
|
|
41
|
+
<aside id="panel" class="glass" aria-label="Details"></aside>
|
|
42
|
+
<section id="list" aria-label="List view"></section>
|
|
43
|
+
<div id="nodata"><div><h1>No data yet</h1><p id="nodataText">Run <code>yad map</code> in the Product, then reload this page.</p></div></div>
|
|
44
|
+
|
|
45
|
+
<!--SCRIPTS-->
|
|
46
|
+
<!--SERVED:start-->
|
|
47
|
+
<script src="app.js?t=__TOKEN__"></script>
|
|
48
|
+
<!--SERVED:end-->
|
|
49
|
+
</body>
|
|
50
|
+
</html>
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/* yad map (E181) — the progress map. The look is the progress-map prototype's, kept as it was; the people
|
|
2
|
+
features (badges, the People lens, waiting rings, what moved) are drawn in the same language. */
|
|
3
|
+
:root {
|
|
4
|
+
color-scheme: dark;
|
|
5
|
+
--bg: #040816;
|
|
6
|
+
--ink: #eaf0ff;
|
|
7
|
+
--ink-2: #aab7d6;
|
|
8
|
+
--muted: #7483a6;
|
|
9
|
+
--glass: rgba(8, 15, 36, .78);
|
|
10
|
+
--hair: rgba(140, 170, 255, .18);
|
|
11
|
+
--live: #3987e5;
|
|
12
|
+
--merged: #d55181;
|
|
13
|
+
--active: #c98500;
|
|
14
|
+
--planned: #93a0bf;
|
|
15
|
+
--idle: #5b6680;
|
|
16
|
+
}
|
|
17
|
+
* { box-sizing: border-box; }
|
|
18
|
+
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden;
|
|
19
|
+
font: 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
|
|
20
|
+
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
|
|
21
|
+
#bg { opacity: .6; }
|
|
22
|
+
#fx { cursor: grab; touch-action: none; }
|
|
23
|
+
#fx.drag { cursor: grabbing; }
|
|
24
|
+
#fx.hot { cursor: pointer; }
|
|
25
|
+
[hidden] { display: none !important; }
|
|
26
|
+
|
|
27
|
+
.glass { background: var(--glass); border: 1px solid var(--hair); border-radius: 10px;
|
|
28
|
+
-webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
|
|
29
|
+
|
|
30
|
+
header { position: fixed; top: 0; left: 0; right: 0; padding: 10px 16px 14px; display: flex; gap: 14px 22px;
|
|
31
|
+
align-items: flex-start; flex-wrap: wrap; pointer-events: none;
|
|
32
|
+
background: linear-gradient(#040816 20%, rgba(4, 8, 22, .7) 70%, transparent); }
|
|
33
|
+
header > * { pointer-events: auto; }
|
|
34
|
+
.brand { min-width: 220px; max-width: 320px; }
|
|
35
|
+
.brand h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: .01em; overflow-wrap: anywhere; }
|
|
36
|
+
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
|
|
37
|
+
#sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
|
38
|
+
#sub:empty { display: none; }
|
|
39
|
+
#live { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); }
|
|
40
|
+
#live .dot { width: 7px; height: 7px; border-radius: 50%; background: #5fd38d; box-shadow: 0 0 8px #5fd38d; animation: beat 1.6s ease-in-out infinite; }
|
|
41
|
+
@keyframes beat { 50% { opacity: .35; } }
|
|
42
|
+
.chip { padding: 0 6px; border-radius: 4px; background: rgba(140, 170, 255, .14); color: var(--ink-2); font-size: 11px; }
|
|
43
|
+
.linkish { padding: 0; border: 0; background: none; color: #9cc3ff; font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
|
|
44
|
+
.tiles { display: flex; gap: 10px; flex-wrap: wrap; flex: 1; }
|
|
45
|
+
.tile { padding: 8px 12px 9px; min-width: 180px; flex: 1 1 180px; max-width: 300px; }
|
|
46
|
+
.tile .k { color: var(--ink-2); font-size: 11.5px; }
|
|
47
|
+
.tile .v { font-size: 22px; font-weight: 650; line-height: 1.2; margin-top: 1px; }
|
|
48
|
+
.tile .v small { font-size: 13px; font-weight: 500; color: var(--ink-2); }
|
|
49
|
+
.tile .s { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
|
|
50
|
+
.meter { display: flex; gap: 2px; height: 5px; margin-top: 7px; }
|
|
51
|
+
.meter i { display: block; height: 100%; border-radius: 3px; min-width: 3px; }
|
|
52
|
+
|
|
53
|
+
footer { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center;
|
|
54
|
+
align-items: center; gap: 6px 18px; padding: 6px 8px; max-width: calc(100vw - 24px); width: max-content; }
|
|
55
|
+
#legend, #controls { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
|
|
56
|
+
#legend button { display: flex; align-items: center; gap: 7px; padding: 5px 9px; border: 1px solid transparent; border-radius: 6px;
|
|
57
|
+
background: none; color: var(--ink); font: inherit; cursor: pointer; white-space: nowrap; }
|
|
58
|
+
#legend button:hover { background: rgba(140, 170, 255, .1); }
|
|
59
|
+
#legend button[aria-pressed="true"] { background: rgba(140, 170, 255, .2); border-color: var(--hair); }
|
|
60
|
+
#legend button .n { color: var(--ink-2); font-variant-numeric: tabular-nums; }
|
|
61
|
+
#panel h2, #people h2 { margin: 16px 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
|
|
62
|
+
.mk { flex: none; width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
|
|
63
|
+
.mk.live { background: var(--live); box-shadow: 0 0 8px var(--live); }
|
|
64
|
+
.mk.merged { background: var(--merged); }
|
|
65
|
+
.mk.unver { border: 2px solid var(--merged); position: relative; }
|
|
66
|
+
.mk.unver::after { content: ""; position: absolute; inset: 2px; border-radius: 50%; background: var(--merged); }
|
|
67
|
+
.mk.active { background: var(--active); box-shadow: 0 0 0 3px rgba(201, 133, 0, .28); }
|
|
68
|
+
.mk.planned { border: 2px solid var(--planned); }
|
|
69
|
+
.mk.idle { background: var(--idle); transform: scale(.7); }
|
|
70
|
+
#controls input { width: 190px; padding: 6px 9px; border-radius: 6px; border: 1px solid var(--hair); background: rgba(3, 6, 18, .7);
|
|
71
|
+
color: var(--ink); font: inherit; }
|
|
72
|
+
#controls input::placeholder { color: var(--muted); }
|
|
73
|
+
#controls button, .x { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--hair); background: rgba(140, 170, 255, .06);
|
|
74
|
+
color: var(--ink); font: inherit; cursor: pointer; }
|
|
75
|
+
#controls button:hover, .x:hover { background: rgba(140, 170, 255, .16); }
|
|
76
|
+
#controls button[aria-pressed="true"], #controls button[aria-expanded="true"] { background: rgba(140, 170, 255, .26); }
|
|
77
|
+
:focus-visible { outline: 2px solid #8fb6ff; outline-offset: 1px; }
|
|
78
|
+
|
|
79
|
+
#tip { position: fixed; z-index: 5; max-width: 340px; padding: 10px 12px; pointer-events: none; display: none; }
|
|
80
|
+
.t-kind { color: var(--muted); font-size: 11px; letter-spacing: .07em; text-transform: uppercase; }
|
|
81
|
+
.t-title { font-size: 14px; font-weight: 650; margin: 1px 0 3px; overflow-wrap: anywhere; }
|
|
82
|
+
.t-state { display: flex; align-items: center; gap: 8px; margin: 2px 0 6px; color: var(--ink); }
|
|
83
|
+
.t-desc { color: var(--ink-2); margin: 0 0 6px; }
|
|
84
|
+
.rows { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; }
|
|
85
|
+
.rows dt { color: var(--muted); }
|
|
86
|
+
.rows dd { margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }
|
|
87
|
+
.note { margin: 7px 0 0; padding: 6px 8px; border-radius: 6px; background: rgba(213, 81, 129, .12); color: var(--ink-2); font-size: 12px; }
|
|
88
|
+
.note.wait { background: rgba(201, 133, 0, .14); }
|
|
89
|
+
.note.one { background: rgba(140, 170, 255, .1); }
|
|
90
|
+
|
|
91
|
+
#panel { position: fixed; z-index: 4; top: 0; right: 0; bottom: 0; width: 360px; max-width: 92vw; padding: 14px 14px 70px; overflow: auto;
|
|
92
|
+
border-radius: 0; border-width: 0 0 0 1px; display: none; }
|
|
93
|
+
#panel .x { position: absolute; top: 10px; right: 10px; padding: 3px 9px; }
|
|
94
|
+
#panel a { color: #9cc3ff; }
|
|
95
|
+
.kids { list-style: none; margin: 0; padding: 0; }
|
|
96
|
+
.kids button { display: flex; gap: 8px; align-items: center; width: 100%; padding: 4px 6px; border: 0; border-radius: 6px; background: none;
|
|
97
|
+
color: var(--ink-2); font: inherit; text-align: left; cursor: pointer; }
|
|
98
|
+
.kids button:hover { background: rgba(140, 170, 255, .1); color: var(--ink); }
|
|
99
|
+
.kids button[aria-pressed="true"] { background: rgba(140, 170, 255, .2); color: var(--ink); }
|
|
100
|
+
.kids span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
101
|
+
|
|
102
|
+
/* A person's badge in HTML: the same circle the canvas draws. */
|
|
103
|
+
.av { flex: none; width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff;
|
|
104
|
+
font-size: 9px; font-weight: 700; letter-spacing: .02em; }
|
|
105
|
+
.av.h0 { background: #3f6fd8; } .av.h1 { background: #2f9e8f; } .av.h2 { background: #8a5cd6; } .av.h3 { background: #c0567d; }
|
|
106
|
+
.av.h4 { background: #b9852b; } .av.h5 { background: #4b9bd1; } .av.h6 { background: #6e9a3c; } .av.h7 { background: #c76a3b; }
|
|
107
|
+
.who { display: inline-flex; align-items: center; gap: 6px; margin: 0 8px 2px 0; }
|
|
108
|
+
.who .av { width: 16px; height: 16px; font-size: 7.5px; }
|
|
109
|
+
.role { color: var(--muted); font-size: 11px; }
|
|
110
|
+
|
|
111
|
+
#people { position: fixed; z-index: 6; left: 50%; bottom: 70px; transform: translateX(-50%); width: 340px; max-width: calc(100vw - 24px);
|
|
112
|
+
max-height: min(60vh, 520px); overflow: auto; padding: 10px 12px 12px; }
|
|
113
|
+
#people .pbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
|
114
|
+
#people .pbar h2 { margin: 2px 0; }
|
|
115
|
+
#roles { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 8px; }
|
|
116
|
+
#roles button { padding: 3px 9px; border-radius: 999px; border: 1px solid var(--hair); background: none; color: var(--ink-2); font: inherit; font-size: 12px; cursor: pointer; }
|
|
117
|
+
#roles button[aria-pressed="true"] { background: rgba(140, 170, 255, .22); color: var(--ink); }
|
|
118
|
+
.muted { color: var(--muted); }
|
|
119
|
+
.small { font-size: 11.5px; margin: 8px 0 0; }
|
|
120
|
+
|
|
121
|
+
#list { position: fixed; z-index: 6; inset: 0; background: rgba(3, 6, 18, .93); display: none; padding: 16px 20px; overflow: auto; }
|
|
122
|
+
#list .bar { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
|
|
123
|
+
#list h2 { margin: 0; font-size: 16px; }
|
|
124
|
+
#list .bar span { color: var(--muted); }
|
|
125
|
+
table { border-collapse: collapse; width: 100%; max-width: 1280px; }
|
|
126
|
+
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; padding: 6px 10px; position: sticky; top: -16px; background: #050a1a; }
|
|
127
|
+
td { padding: 4px 10px; border-top: 1px solid rgba(140, 170, 255, .09); color: var(--ink-2); vertical-align: top; }
|
|
128
|
+
td:first-child { color: var(--ink); overflow-wrap: anywhere; }
|
|
129
|
+
td .mk { vertical-align: -1px; margin-right: 7px; }
|
|
130
|
+
tr.cluster td { padding-top: 14px; font-weight: 650; color: var(--ink); border-top: 0; }
|
|
131
|
+
|
|
132
|
+
#nodata { display: none; position: fixed; inset: 0; place-items: center; text-align: center; padding: 24px; }
|
|
133
|
+
body.nodata #nodata { display: grid; }
|
|
134
|
+
body.nodata header, body.nodata footer { display: none; }
|
|
135
|
+
code { background: rgba(140, 170, 255, .12); padding: 1px 6px; border-radius: 4px; }
|
|
136
|
+
|
|
137
|
+
@media (max-width: 640px) {
|
|
138
|
+
.tile { min-width: 140px; flex-basis: 140px; padding: 6px 10px 7px; }
|
|
139
|
+
.tile .v { font-size: 18px; }
|
|
140
|
+
#controls input { width: 140px; }
|
|
141
|
+
#panel { width: 100vw; max-width: 100vw; }
|
|
142
|
+
}
|
package/cli/map-view.mjs
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// `yad map` — the command (E181). The data is cli/map.mjs; the page is cli/map/view/; the locked-down
|
|
2
|
+
// server and the self-contained file are cli/local-page.mjs (shared with `yad brain view`).
|
|
3
|
+
//
|
|
4
|
+
// yad map [--open] a local page on 127.0.0.1 with a one-time key, until Ctrl-C
|
|
5
|
+
// yad map --html [<file>] [--open] one self-contained file, saved in the local reports folder (E180)
|
|
6
|
+
// yad map --live [--open] the local page, drawn again whenever the ledger or a repo's refs change
|
|
7
|
+
// yad map --anonymous every person as "Person A…": for sharing outside the team
|
|
8
|
+
// yad map --fetch `git fetch origin` first in the Product and each code repo (download only)
|
|
9
|
+
// yad map --json the model (or, with --html, what was written)
|
|
10
|
+
//
|
|
11
|
+
// WHAT MOVED: each map saved into the reports folder keeps a digest beside it (`<file>.digest.json`: each
|
|
12
|
+
// item's state, by id). The next map compares itself with the newest earlier one — named, never anonymous,
|
|
13
|
+
// so its ids are the real ones — and lights what changed.
|
|
14
|
+
import fs from 'node:fs';
|
|
15
|
+
import { setInterval, clearInterval, setTimeout, clearTimeout } from 'node:timers';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import { fileURLToPath } from 'node:url';
|
|
18
|
+
import { spawnSync } from 'node:child_process';
|
|
19
|
+
import { c, emitJSON, forTerminal, info, log, ok, refuse, warn } from './lib.mjs';
|
|
20
|
+
import { gatherMap, mapModel, digestOf } from './map.mjs';
|
|
21
|
+
import { TYPES, startPageServer, inlineSnapshot, writeOwnFile, trackedRisk } from './local-page.mjs';
|
|
22
|
+
import { saveReport, listReports, SIDE_SUFFIX } from './reports-dir.mjs';
|
|
23
|
+
import { openUrl } from './report.mjs';
|
|
24
|
+
|
|
25
|
+
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
26
|
+
const VIEW_DIR = path.join(HERE, 'map', 'view');
|
|
27
|
+
const readView = (name) => fs.readFileSync(path.join(VIEW_DIR, name), 'utf8');
|
|
28
|
+
export const MAP_USAGE = 'usage: yad map [--open] [--live] [--anonymous] [--fetch] [--json] | yad map --html [<file>] [--anonymous] [--open]';
|
|
29
|
+
|
|
30
|
+
// The newest saved, named progress map's digest, or null.
|
|
31
|
+
export function previousDigest(root, { env = process.env, runner = spawnSync } = {}) {
|
|
32
|
+
const r = listReports(root, { env, runner });
|
|
33
|
+
if (r.problem) return null;
|
|
34
|
+
for (const e of r.entries) {
|
|
35
|
+
if (e.kind !== 'progress-map' || e.anonymous || !e.present) continue;
|
|
36
|
+
try {
|
|
37
|
+
const d = JSON.parse(fs.readFileSync(path.join(r.dir, `${e.file}${SIDE_SUFFIX}`), 'utf8'));
|
|
38
|
+
if (d && typeof d.states === 'object' && d.states) return d;
|
|
39
|
+
} catch { /* no digest beside it */ }
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function buildMap(root, { anonymous = false, fetch = false, env = process.env, runner = spawnSync, now = Date.now(), log: say = () => {} } = {}) {
|
|
45
|
+
const g = gatherMap(root, { fetch, runner, now, log: say });
|
|
46
|
+
const model = mapModel(g.inputs, { anonymous, previous: previousDigest(root, { env, runner }), now });
|
|
47
|
+
return { model, problems: g.problems };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function mapSnapshot(model) {
|
|
51
|
+
return inlineSnapshot({ shell: readView('index.html'), scripts: [readView('app.js')], css: readView('style.css'), dataId: 'yad-map-data', data: model });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// The live stream: the Product's epics/ and .sdlc/, and each code repo's refs, watched while a page is open.
|
|
55
|
+
function mapStream(root, { heartbeat = 15000, debounce = 500, runner = spawnSync } = {}) {
|
|
56
|
+
const clients = new Set();
|
|
57
|
+
let watchers = [], timer = null;
|
|
58
|
+
const frame = (event, data) => `event: ${event}\ndata: ${JSON.stringify(data)}\n\n`;
|
|
59
|
+
const send = (res, chunk) => { if (res.writableLength > 8 * 1024 * 1024) { res.destroy(); clients.delete(res); return; } res.write(chunk); };
|
|
60
|
+
const changed = () => { clearTimeout(timer); timer = setTimeout(() => { for (const res of clients) send(res, frame('rebuilt', {})); }, debounce); timer.unref?.(); };
|
|
61
|
+
// What to watch: the Product's record, and each code repo's refs (in its shared git folder, so a repo that
|
|
62
|
+
// is a worktree — a `.git` FILE — is watched too).
|
|
63
|
+
const watchPaths = () => {
|
|
64
|
+
const out = [path.join(root, 'epics'), path.join(root, '.sdlc')];
|
|
65
|
+
let reg = null;
|
|
66
|
+
try { reg = JSON.parse(fs.readFileSync(path.join(root, '.sdlc', 'repos.json'), 'utf8')); } catch { /* none */ }
|
|
67
|
+
for (const r of Array.isArray(reg?.repos) ? reg.repos : []) {
|
|
68
|
+
if (!r || typeof r.path !== 'string') continue;
|
|
69
|
+
const g = runner('git', ['-C', path.resolve(root, r.path), 'rev-parse', '--path-format=absolute', '--git-common-dir'], { encoding: 'utf8' });
|
|
70
|
+
if (g.status !== 0) continue;
|
|
71
|
+
const common = String(g.stdout).trim();
|
|
72
|
+
out.push(path.join(common, 'refs'), path.join(common, 'packed-refs'), path.join(common, 'FETCH_HEAD'));
|
|
73
|
+
}
|
|
74
|
+
return out.filter((p) => fs.existsSync(p));
|
|
75
|
+
};
|
|
76
|
+
// A recursive watch where the system has one (macOS, Windows, Linux on Node 20+); elsewhere each folder of
|
|
77
|
+
// the record is watched on its own, three levels deep — enough for epics/<id>/{.sdlc,stories}/.
|
|
78
|
+
const watchOne = (p) => {
|
|
79
|
+
try { watchers.push(fs.watch(p, { persistent: false }, changed)); } catch { /* left out */ }
|
|
80
|
+
};
|
|
81
|
+
const watchTree = (p, depth) => {
|
|
82
|
+
watchOne(p);
|
|
83
|
+
if (depth <= 0) return;
|
|
84
|
+
let kids = [];
|
|
85
|
+
try { kids = fs.readdirSync(p, { withFileTypes: true }).filter((d) => d.isDirectory()); } catch { /* none */ }
|
|
86
|
+
for (const d of kids) watchTree(path.join(p, d.name), depth - 1);
|
|
87
|
+
};
|
|
88
|
+
const start = () => {
|
|
89
|
+
if (watchers.length) return;
|
|
90
|
+
for (const p of watchPaths()) {
|
|
91
|
+
let dir;
|
|
92
|
+
try { dir = fs.statSync(p).isDirectory(); } catch { continue; }
|
|
93
|
+
if (!dir) { watchOne(p); continue; }
|
|
94
|
+
try { watchers.push(fs.watch(p, { recursive: true, persistent: false }, changed)); } catch { watchTree(p, 3); }
|
|
95
|
+
}
|
|
96
|
+
return watchers.length;
|
|
97
|
+
};
|
|
98
|
+
const stop = () => { for (const w of watchers) { try { w.close(); } catch { /* closed */ } } watchers = []; };
|
|
99
|
+
const ping = setInterval(() => { for (const res of clients) send(res, ': ping\n\n'); }, heartbeat);
|
|
100
|
+
ping.unref?.();
|
|
101
|
+
return {
|
|
102
|
+
path: '/events',
|
|
103
|
+
attach(req, res, headers) {
|
|
104
|
+
res.writeHead(200, { ...headers, 'Content-Type': 'text/event-stream; charset=utf-8', Connection: 'keep-alive', 'X-Accel-Buffering': 'no' });
|
|
105
|
+
const watching = start() ?? watchers.length;
|
|
106
|
+
clients.add(res);
|
|
107
|
+
res.write(frame('status', { live: watching > 0, watching }));
|
|
108
|
+
req.on('close', () => { clients.delete(res); if (!clients.size) stop(); });
|
|
109
|
+
},
|
|
110
|
+
close() { clearInterval(ping); clearTimeout(timer); stop(); for (const res of clients) res.end(); clients.clear(); },
|
|
111
|
+
// How much would be watched (for the person's line): a count, before any page has opened.
|
|
112
|
+
canWatch: () => watchPaths().length,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function startMapServer(root, { anonymous = false, live = false, env = process.env, runner = spawnSync, host = '127.0.0.1', port = 0, heartbeat, debounce } = {}) {
|
|
117
|
+
const stream = live ? mapStream(root, { heartbeat, debounce, runner }) : null;
|
|
118
|
+
const routes = (token) => new Map([
|
|
119
|
+
['/', () => ({ type: TYPES.html, body: readView('index.html').replaceAll('__TOKEN__', token) })],
|
|
120
|
+
['/app.js', () => ({ type: TYPES.js, body: readView('app.js') })],
|
|
121
|
+
['/style.css', () => ({ type: TYPES.css, body: readView('style.css') })],
|
|
122
|
+
['/map.json', () => ({ type: TYPES.json, body: JSON.stringify(buildMap(root, { anonymous, env, runner }).model) })],
|
|
123
|
+
]);
|
|
124
|
+
return startPageServer({ routes, stream, host, port, failText: 'the map could not be read' }).then((srv) => ({ ...srv, watchable: stream ? stream.canWatch() : null }));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const storiesState = (m) => `${m.summary.stories.shipped} of ${m.summary.stories.total} stories shipped`;
|
|
128
|
+
|
|
129
|
+
export async function runMap(root, { args = [], html = false, open = false, live = false, anonymous = false, fetch = false, json = false, env = process.env, runner = spawnSync, opener = openUrl, gitRunner = spawnSync, wait = true, now = Date.now() } = {}) {
|
|
130
|
+
if (args.length > (html ? 1 : 0) || args.some((a) => String(a).startsWith('-'))) return refuse(`unexpected argument(s): ${args.map(forTerminal).join(' ')}`, MAP_USAGE, { json });
|
|
131
|
+
if (html && live) return refuse('--html writes one file and --live keeps a page up to date — pick one', MAP_USAGE, { json });
|
|
132
|
+
const say = json ? () => {} : (s) => info(s);
|
|
133
|
+
let built;
|
|
134
|
+
try { built = buildMap(root, { anonymous, fetch, env, runner, now, log: say }); } catch (e) { return refuse(`cannot read the map: ${forTerminal(String(e.message || e).split('\n')[0])}`, null, { json }); }
|
|
135
|
+
const { model, problems } = built;
|
|
136
|
+
for (const p of problems) warn(forTerminal(p));
|
|
137
|
+
|
|
138
|
+
if (html) {
|
|
139
|
+
const own = args.length === 1;
|
|
140
|
+
let page;
|
|
141
|
+
try { page = mapSnapshot(model); } catch (e) { return refuse(`cannot build the page: ${e.message}`, null, { json }); }
|
|
142
|
+
let file, riskLine = null;
|
|
143
|
+
if (own) {
|
|
144
|
+
file = path.resolve(args[0]);
|
|
145
|
+
const problem = writeOwnFile(file, page);
|
|
146
|
+
if (problem) return refuse(problem, null, { json });
|
|
147
|
+
if (trackedRisk(file, gitRunner)) riskLine = `${forTerminal(file)} is in a git work tree and not ignored: ${anonymous ? 'it is a picture of the work at one moment' : 'it holds the team\'s names'} — do not commit it`;
|
|
148
|
+
} else {
|
|
149
|
+
const saved = saveReport(root, { kind: 'progress-map', scope: 'all epics', state: anonymous ? `${storiesState(model)} anonymous` : storiesState(model), ext: 'html', content: page, command: `map --html${anonymous ? ' --anonymous' : ''}`, anonymous, env, runner, at: new Date(now) });
|
|
150
|
+
if (saved.problem) return refuse(saved.problem, null, { json });
|
|
151
|
+
file = saved.file;
|
|
152
|
+
for (const w of saved.warnings) warn(w);
|
|
153
|
+
// The digest beside a NAMED map, for the next one's "what moved".
|
|
154
|
+
if (!anonymous) { try { fs.writeFileSync(`${file}${SIDE_SUFFIX}`, `${JSON.stringify(digestOf(model))}\n`, { flag: 'wx' }); } catch { /* the next map just shows nothing moved */ } }
|
|
155
|
+
}
|
|
156
|
+
if (riskLine) warn(riskLine);
|
|
157
|
+
const opened = open ? opener(file) : null;
|
|
158
|
+
if (json) return emitJSON({ file, epics: model.epics.length, stories: model.summary.stories.total, people: model.people.length, moved: model.moved.length, anonymous, ...(open ? { opened } : {}) });
|
|
159
|
+
ok(`wrote ${forTerminal(file)} — ${model.epics.length} epics, ${storiesState(model)}, ${model.people.length} people${model.moved.length ? `, ${model.moved.length} moved since ${String(model.since).slice(0, 10)}` : ''}; it needs no server and no network`);
|
|
160
|
+
if (!anonymous && model.people.length) info('it holds the team\'s names — pass --anonymous for a copy to share outside the team');
|
|
161
|
+
if (opened === false) info('no browser opener was found here (open, xdg-open or explorer) — open the file yourself');
|
|
162
|
+
return { file };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (json && !open && !live) return emitJSON({ model });
|
|
166
|
+
|
|
167
|
+
const s = await startMapServer(root, { anonymous, live, env, runner });
|
|
168
|
+
const opened = open ? opener(s.url) : null;
|
|
169
|
+
if (json) emitJSON({ url: s.url, port: s.port, live, anonymous, ...(open ? { opened } : {}) });
|
|
170
|
+
else {
|
|
171
|
+
log(c.bold(live ? '\nyad map --live' : '\nyad map'));
|
|
172
|
+
ok(`the map is at ${s.url}`);
|
|
173
|
+
info('only this machine can reach it, and only with that address (it holds a one-time key). Ctrl-C stops it.');
|
|
174
|
+
info(live ? 'the page draws itself again when the ledger or a repo changes' : 'reload the page to read the record again');
|
|
175
|
+
if (live && !s.watchable) warn('nothing here can be watched (no epics/, .sdlc/ or repo refs found), so the page will not change by itself — reload it instead');
|
|
176
|
+
if (opened === false) info('no browser opener was found here (open, xdg-open or explorer) — copy the address into your browser');
|
|
177
|
+
}
|
|
178
|
+
if (!wait) return s;
|
|
179
|
+
await new Promise((resolve) => {
|
|
180
|
+
const stop = () => { process.off('SIGINT', stop); process.off('SIGTERM', stop); s.close().then(resolve); };
|
|
181
|
+
process.on('SIGINT', stop);
|
|
182
|
+
process.on('SIGTERM', stop);
|
|
183
|
+
});
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
|