agent-manifesto-kit 1.7.0 → 1.8.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 CHANGED
@@ -131,6 +131,17 @@ generation, key-pose error gates, frame sheets and residual easing, and Blender
131
131
  Mixamo-named rig's pose into a key pose and bake takes back onto the rig. kimodo.cpp, its models and
132
132
  Blender are installed separately; `KIMODO_ROOT` and `BLENDER` point at them.
133
133
 
134
+ Give any project a roadmap page from its TaskPilot items and git history:
135
+
136
+ ```bash
137
+ agentkit sync roadmap --provider claude,codex
138
+ ```
139
+
140
+ The [Roadmap skill](collection/skills/roadmap/SKILL.md) installs `scripts/roadmap.py` (`init`, `build`,
141
+ `check`, `path`), one shared template (English and Russian), a post-commit hook and the format
142
+ reference. The generated page is self-contained and carries its template id and data, so tools such as
143
+ Astro Preview can list it, and `check --template-from` reports a project whose template drifted.
144
+
134
145
  Adopt a single skill for Codex:
135
146
 
136
147
  ```bash
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: roadmap
3
+ description: Create, build, check and keep consistent a project's roadmap, a Gantt page generated from the TaskPilot items, the git history and a small plan file, one shared template for every project. Use when a project needs a roadmap, when items or plan phases change, when the roadmap looks stale.
4
+ ---
5
+
6
+ # Roadmap
7
+
8
+ A roadmap is one self-contained HTML page (no network) built by `scripts/roadmap.py` from three read-only sources: the
9
+ TaskPilot items (`.taskpilot/items/*.yaml`), the git history of those files and of commits naming item ids, and an
10
+ optional hand-edited plan file (`docs/roadmap_plan.json`: phases, estimates, milestones). Every project uses the same
11
+ template (`assets/template.html`), so all roadmaps look and behave the same. Format and plan keys:
12
+ [references/format.md](references/format.md).
13
+
14
+ ## Commands
15
+
16
+ Run from the project (or pass `--project DIR`); `python3`, standard library only.
17
+
18
+ ```sh
19
+ python3 .claude/skills/roadmap/scripts/roadmap.py init --title "My game" [--lang en|ru] # skeleton plan, never overwrites
20
+ python3 .claude/skills/roadmap/scripts/roadmap.py build [--open] # writes docs/roadmap.html
21
+ python3 .claude/skills/roadmap/scripts/roadmap.py check [--json] [--template-from PATH] # exit 1 on any problem
22
+ python3 .claude/skills/roadmap/scripts/roadmap.py path # output path, relative
23
+ ```
24
+
25
+ Tests of the tool itself: `python3 -m unittest discover -s .claude/skills/roadmap/scripts`.
26
+
27
+ ## Rules that keep it consistent
28
+
29
+ - Never hand-edit the generated `roadmap.html` or the template copy in a project: change the plan file or the items,
30
+ then rebuild. Template changes are made in this skill (the kit's `roadmap`, `assets/template.html`) and copied over.
31
+ - After items or the plan change: `build`, then `check` (it fails on an invalid plan, unknown or cancelled ids, an id in
32
+ two blocks, bad dates, a missing or stale page, a page built from another template). Commit the rebuilt page.
33
+ - `assets/post-commit.sh` rebuilds the page after commits on `main` that touch items or name an id and makes a commit of
34
+ that page by itself (install it as `.git/hooks/post-commit`, or call it from the project's hook; it finds the script
35
+ in either tool's skills directory; `ROADMAP_PY`, `ROADMAP_PYTHON` and `ROADMAP_BRANCH` override the script, the interpreter
36
+ and the branch). It does not run after a fast-forward merge: run `build` and commit the page then. `check` on a
37
+ feature branch can report `output-stale` (commits naming ids on other branches count), so rebuild and commit the page
38
+ on `main`, not on every branch.
39
+ - Keep ids in commit messages (`AV-12: ...`): they become ticks and rework bars in the chart.
40
+ - Plan blocks list item ids (leaves count) or an estimated `size`; do not list an id twice. Dates are ISO date-times.
41
+
42
+ ## Adopting it in another project
43
+
44
+ 1. Prerequisite: TaskPilot items (`.taskpilot/items/*.yaml`, skill `taskpilot`) or files with the same keys; without items the page is empty. Install the skill with the kit sync (it places it in each tool's own skills directory) or copy this folder to the project's skills directory. On Windows use `python` or `py -3` for `python3`.
45
+ 2. `init`, edit `docs/roadmap_plan.json` (phases, milestones), `build`, `check`, commit the page.
46
+ 3. Optionally install the hook. To detect drift from the canonical template run
47
+ `check --template-from <kit copy>/assets/template.html`.
48
+ 4. Optional integration, Astro Preview: register it in the sidebar **Roadmaps** tab, **Add roadmap**, pick the project and the page
49
+ (`docs/roadmap.html`). Astro keeps only the link; the roadmap stays in the project and is never written by Astro.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Roadmap"
3
+ short_description: "One shared Gantt roadmap page per project from TaskPilot items and git history"
4
+ default_prompt: "Use $roadmap to give this project a roadmap, rebuild it after item changes and check that it is consistent."
@@ -0,0 +1,33 @@
1
+ #!/bin/sh
2
+ # Roadmap upkeep (roadmap.py): after a commit on main in the main checkout that touches TaskPilot items or names an
3
+ # item id, rebuild the roadmap page and commit that file alone when it changed (`git commit -- path` leaves other
4
+ # sessions' staged work alone). Skipped in worktrees, on other branches, during rebases and merges.
5
+ # Install: copy to .git/hooks/post-commit (or call it from your hooks directory). The script is found in
6
+ # .claude/skills/roadmap or .agents/skills/roadmap (the kit's sync does not rewrite this file); overrides:
7
+ # ROADMAP_PY (script path), ROADMAP_PYTHON (interpreter, default python3 then python), ROADMAP_BRANCH (default main).
8
+ # It makes a commit on that branch by itself: the rebuilt page, alone.
9
+ [ -n "$ROADMAP_HOOK" ] && exit 0
10
+ root="$(git rev-parse --show-toplevel)" || exit 0
11
+ gd="$(git rev-parse --path-format=absolute --git-dir)"
12
+ [ "$gd" = "$(git rev-parse --path-format=absolute --git-common-dir)" ] || exit 0
13
+ [ "$(git symbolic-ref --quiet --short HEAD)" = "${ROADMAP_BRANCH:-main}" ] || exit 0
14
+ [ -d "$gd/rebase-merge" ] || [ -d "$gd/rebase-apply" ] || [ -f "$gd/MERGE_HEAD" ] && exit 0
15
+ script="$ROADMAP_PY"
16
+ if [ -z "$script" ]; then
17
+ for d in .claude .agents; do
18
+ [ -f "$root/$d/skills/roadmap/scripts/roadmap.py" ] && script="$root/$d/skills/roadmap/scripts/roadmap.py" && break
19
+ done
20
+ fi
21
+ [ -f "$script" ] || { echo "post-commit: roadmap.py not found (set ROADMAP_PY)" >&2; exit 0; }
22
+ py="${ROADMAP_PYTHON:-}"
23
+ if [ -z "$py" ]; then if command -v python3 >/dev/null 2>&1; then py=python3; else py=python; fi; fi
24
+ # Only commits that touch items or name an id (<LETTERS>-<digits>) matter.
25
+ git diff-tree --no-commit-id --name-only -r -m HEAD | grep -q '^\.taskpilot/items/' \
26
+ || git log -1 --format=%B HEAD | grep -Eq '[A-Z][A-Z0-9]*-[0-9]+' || exit 0
27
+ out="$("$py" "$script" path --project "$root")" || { echo "post-commit: roadmap path failed" >&2; exit 0; }
28
+ "$py" "$script" build --project "$root" >/dev/null || { echo "post-commit: roadmap build failed" >&2; exit 0; }
29
+ git -C "$root" add -- "$out" 2>/dev/null
30
+ git -C "$root" diff --cached --quiet HEAD -- "$out" && exit 0
31
+ ROADMAP_HOOK=1 git -C "$root" commit --no-verify -q -m "Roadmap: rebuild $out" -- "$out" \
32
+ || echo "post-commit: roadmap commit skipped" >&2
33
+ exit 0
@@ -0,0 +1,470 @@
1
+ <!doctype html>
2
+ <html lang="/*LANG*/">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>/*TITLE*/</title>
7
+ <meta name="roadmap-template" content="/*TEMPLATE*/">
8
+ <!-- Generated by roadmap.py from TaskPilot items and git history; edit the template, not the output. -->
9
+ <style>
10
+ :root {
11
+ --bg: #f7f7f5; --panel: #ffffff; --ink: #1f2328; --muted: #6b7280; --line: #e3e3df; --line2: #d0d0ca;
12
+ --done: #2f9e5b; --progress: #2f6fdb; --ready: #12a1a1; --backlog: #9aa0a6; --cancelled: #b9bcc0;
13
+ --rework: #e8820c; --stalled: #8fa9d9; --link: #7c8591; --reworklink: #9b4fd1; --today: #d6336c; --mile: #8a6d3b;
14
+ --summary: #3b4250; --rowalt: #f0f0ec; --hover: #fff6d6;
15
+ }
16
+ @media (prefers-color-scheme: dark) {
17
+ :root:not([data-theme="light"]) {
18
+ --bg: #15171a; --panel: #1d2024; --ink: #e6e8eb; --muted: #9aa1aa; --line: #2b2f35; --line2: #3a3f46;
19
+ --done: #3fb872; --progress: #4f8af0; --ready: #22b8b8; --backlog: #6f767e; --cancelled: #50555c;
20
+ --rework: #f0962e; --stalled: #4d6694; --link: #8a939e; --reworklink: #b87ae6; --today: #f0568c; --mile: #c9a86a;
21
+ --summary: #c4cad3; --rowalt: #1a1d21; --hover: #3a3420;
22
+ }
23
+ }
24
+ :root[data-theme="dark"] {
25
+ --bg: #15171a; --panel: #1d2024; --ink: #e6e8eb; --muted: #9aa1aa; --line: #2b2f35; --line2: #3a3f46;
26
+ --done: #3fb872; --progress: #4f8af0; --ready: #22b8b8; --backlog: #6f767e; --cancelled: #50555c;
27
+ --rework: #f0962e; --stalled: #4d6694; --link: #8a939e; --reworklink: #b87ae6; --today: #f0568c; --mile: #c9a86a;
28
+ --summary: #c4cad3; --rowalt: #1a1d21; --hover: #3a3420;
29
+ }
30
+ * { box-sizing: border-box; }
31
+ html, body { margin: 0; height: 100%; }
32
+ body { background: var(--bg); color: var(--ink); font: 13px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; display: flex; flex-direction: column; }
33
+ header { padding: 10px 16px 8px; border-bottom: 1px solid var(--line); background: var(--panel); display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
34
+ header h1 { font-size: 16px; margin: 0; font-weight: 650; }
35
+ header .meta { color: var(--muted); font-size: 12px; }
36
+ .controls { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
37
+ .controls button, .controls input[type=search] { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line2); border-radius: 6px; padding: 3px 9px; }
38
+ .controls button { cursor: pointer; }
39
+ .controls button:hover { border-color: var(--muted); }
40
+ .controls label { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; user-select: none; }
41
+ .legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); align-items: center; }
42
+ .legend svg { vertical-align: -3px; }
43
+ .summarybar { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; }
44
+ .summarybar b { font-weight: 650; }
45
+ #scroller { flex: 1; overflow: auto; position: relative; }
46
+ #grid { position: relative; width: max-content; min-width: 100%; }
47
+ #axissvg, #chart, #labels, #axis .corner { flex: none; }
48
+ #axis { position: sticky; top: 0; z-index: 3; display: flex; background: var(--panel); border-bottom: 1px solid var(--line2); }
49
+ #axis .corner { position: sticky; left: 0; z-index: 4; background: var(--panel); border-right: 1px solid var(--line2); padding: 6px 10px; color: var(--muted); font-size: 12px; display: flex; align-items: flex-end; }
50
+ #body { display: flex; position: relative; }
51
+ #labels { position: sticky; left: 0; z-index: 2; background: var(--panel); border-right: 1px solid var(--line2); }
52
+ .row { height: var(--rowh); display: flex; align-items: center; gap: 6px; padding-right: 8px; white-space: nowrap; overflow: hidden; cursor: pointer; border-bottom: 1px solid transparent; }
53
+ .row.alt { background: var(--rowalt); }
54
+ .row.hl, .row:hover { background: var(--hover); }
55
+ .row .caret { width: 14px; flex: none; text-align: center; color: var(--muted); font-size: 10px; }
56
+ .row .rid { font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); flex: none; }
57
+ .row .title { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
58
+ .row.d0 .title { font-weight: 650; }
59
+ .row.d1 .title { font-weight: 550; }
60
+ .row .chip { flex: none; font-size: 10.5px; padding: 0 6px; border-radius: 9px; color: #fff; line-height: 16px; }
61
+ .row .cnt { flex: none; font-size: 11px; color: var(--muted); }
62
+ .row .rw { flex: none; color: var(--rework); font-weight: 700; }
63
+ .row.closed .title { color: var(--muted); }
64
+ #chart { display: block; }
65
+ #tip { position: fixed; z-index: 10; max-width: 420px; background: var(--panel); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; box-shadow: 0 6px 24px rgba(0,0,0,.18); pointer-events: none; display: none; font-size: 12px; }
66
+ #tip b { font-weight: 650; }
67
+ #tip .k { color: var(--muted); }
68
+ #detail { position: fixed; right: 12px; bottom: 12px; z-index: 9; width: min(480px, calc(100vw - 24px)); max-height: 55vh; overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; padding: 12px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.22); display: none; }
69
+ #detail h2 { font-size: 14px; margin: 0 24px 6px 0; }
70
+ #detail .close { position: absolute; right: 10px; top: 8px; cursor: pointer; border: 0; background: none; font-size: 18px; color: var(--muted); }
71
+ #detail p { margin: 6px 0; white-space: pre-wrap; }
72
+ #detail ul { margin: 4px 0; padding-left: 18px; }
73
+ #detail .k { color: var(--muted); }
74
+ #detail a { color: var(--progress); cursor: pointer; }
75
+ #phases { padding: 8px 16px 10px; background: var(--panel); border-bottom: 1px solid var(--line2); display: grid; grid-template-columns: minmax(150px, 210px) 1fr; gap: 6px 14px; align-items: center; }
76
+ #phases .ph-h { grid-column: 1 / -1; display: flex; gap: 10px; align-items: baseline; font-size: 12px; color: var(--muted); }
77
+ #phases .ph-h b { color: var(--ink); font-size: 13px; }
78
+ #phases .ph-name { font-weight: 650; cursor: pointer; display: flex; gap: 6px; align-items: flex-start; }
79
+ #phases .ph-name input { margin: 3px 0 0; }
80
+ #phases .ph-h label { cursor: pointer; display: inline-flex; gap: 4px; align-items: center; color: var(--ink); }
81
+ #phases .ph-name small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; }
82
+ .sausage { display: flex; gap: 3px; height: 34px; min-width: 0; }
83
+ .seg { position: relative; flex: 1 1 0; min-width: 6px; border-radius: 7px; overflow: hidden; background: var(--rowalt); border: 1px solid var(--line2); cursor: pointer; }
84
+ .seg.est { border-style: dashed; }
85
+ .seg:hover, .seg.on { border-color: var(--ink); }
86
+ .seg .fill { position: absolute; inset: 0 auto 0 0; background: var(--done); opacity: .85; }
87
+ .seg .lab { position: absolute; inset: 0; padding: 2px 6px; font-size: 11px; line-height: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
88
+ .seg .lab i { font-style: normal; color: var(--muted); display: block; }
89
+ .focus { display: none; align-items: center; gap: 4px; background: var(--hover); border: 1px solid var(--line2); border-radius: 12px; padding: 1px 4px 1px 9px; font-size: 12px; }
90
+ .focus button { border: 0 !important; background: none !important; padding: 0 4px !important; }
91
+ @media (max-width: 700px) { header { padding: 8px 16px; } #phases { grid-template-columns: 1fr; } }
92
+ </style>
93
+ </head>
94
+ <body>
95
+ <header>
96
+ <h1 id="h1"></h1>
97
+ <span class="meta" id="meta"></span>
98
+ <div class="summarybar" id="totals"></div>
99
+ <div class="controls">
100
+ <button id="zout">−</button><button id="zin">+</button>
101
+ <button id="today"></button>
102
+ <label><input type="checkbox" id="foldDone" checked> <span id="foldLabel"></span></label>
103
+ <label id="sinceBox" style="display:none"><input type="checkbox" id="isoOnly"> <span id="sinceLabel"></span></label>
104
+ <label><input type="checkbox" id="showRel"> <span id="relLabel"></span></label>
105
+ <input type="search" id="q" size="16">
106
+ <span class="focus" id="focus"><span id="focusLabel"></span><button id="focusX">×</button></span>
107
+ </div>
108
+ <div class="legend" id="legend"></div>
109
+ </header>
110
+ <section id="phases"></section>
111
+ <div id="scroller"><div id="grid">
112
+ <div id="axis"><div class="corner" id="corner"></div><svg id="axissvg"></svg></div>
113
+ <div id="body"><div id="labels"></div><svg id="chart"></svg></div>
114
+ </div></div>
115
+ <div id="tip"></div>
116
+ <div id="detail"><button class="close" id="dclose">×</button><div id="dbody"></div></div>
117
+ <script type="application/json" id="roadmap-data">/*DATA*/null</script>
118
+ <script>
119
+ const DATA = JSON.parse(document.getElementById("roadmap-data").textContent);
120
+ const H = 3600e3, DAY = 24 * H, ROWH = 24, LABELW = 440;
121
+ const I18N = {
122
+ ru: {
123
+ locale: "ru-RU", roadmap: "роадмап", zoomOut: "Мельче", zoomIn: "Крупнее", today: "К сегодня",
124
+ foldDone: "свернуть завершённое", since: l => `только с «${l}»`, showRel: "связи relates",
125
+ search: id => `${id}, название…`, clearFilter: "Снять фильтр", corner: "Эпик / фича / задача",
126
+ status: { done: "готово", in_progress: "в работе", ready: "готово к старту", backlog: "бэклог", cancelled: "отменено" },
127
+ type: { epic: "эпик", feature: "фича", task: "задача", bug: "баг", group: "группа" },
128
+ kind: { work: "работа", rework: "переделка", ongoing: "в работе", stalled: "в работе, без движения", cancelled: "отменено", estimate: "оценка (нет плана)", plan: "план" },
129
+ meta: t => `данные на ${t} (последнее событие по задачам) · roadmap.py`, withRework: "с переделкой",
130
+ lgDone: "готово", lgProgress: "в работе", lgStalled: "в работе, без движения 3+ дня", lgRework: "переделка / доработка",
131
+ lgEstimate: "оценка (бэклог, без плана)", lgPlan: "план (файл плана)", lgBlocks: "блокирует", lgReworkOf: "переделка чего",
132
+ lgCommit: p => `коммит с ${p}`,
133
+ plan: "План", planHint: "крупными мазками: ширина блока = число задач (пунктир: ещё не нарезано на задачи, размер оценён), заливка = сделано; клик — задачи блока в ганте; галочки — какие релизы показывать",
134
+ outside: "вне плана", outsideTip: "Задачи, не входящие ни в один блок плана: история до плана, старые эпики",
135
+ ofTasks: (d, t) => `${d} из ${t} задач`, remaining: "осталось", doneNoItems: "(сделано, без задач в TaskPilot)",
136
+ estNoItems: "(оценка, задачи ещё не заведены)", items: "элементы TaskPilot", block: "блок: ",
137
+ hasRework: "есть переделка", week: n => `нед. ${n}`, dataAsOf: "данные на", span: "охват", inside: "внутри",
138
+ reworkLbl: "переделка", blocksLbl: "блокирует", parent: "родитель", related: "связано",
139
+ created: (c, u) => `создано ${c}, обновлено ${u}`, bars: "полосы", gitStatuses: "статусы в git", commits: "коммиты",
140
+ byCommits: "(по коммитам после закрытия)",
141
+ },
142
+ en: {
143
+ locale: "en-GB", roadmap: "roadmap", zoomOut: "Zoom out", zoomIn: "Zoom in", today: "To today",
144
+ foldDone: "fold finished", since: l => `only since "${l}"`, showRel: "relates links",
145
+ search: id => `${id}, title…`, clearFilter: "Clear filter", corner: "Epic / feature / task",
146
+ status: { done: "done", in_progress: "in progress", ready: "ready", backlog: "backlog", cancelled: "cancelled" },
147
+ type: { epic: "epic", feature: "feature", task: "task", bug: "bug", group: "group" },
148
+ kind: { work: "work", rework: "rework", ongoing: "in progress", stalled: "in progress, no movement", cancelled: "cancelled", estimate: "estimate (no plan)", plan: "plan" },
149
+ meta: t => `data as of ${t} (latest item event) · roadmap.py`, withRework: "with rework",
150
+ lgDone: "done", lgProgress: "in progress", lgStalled: "in progress, no movement for 3+ days", lgRework: "rework / follow-up",
151
+ lgEstimate: "estimate (backlog, no plan)", lgPlan: "plan (plan file)", lgBlocks: "blocks", lgReworkOf: "rework of",
152
+ lgCommit: p => `commit naming ${p}`,
153
+ plan: "Plan", planHint: "big strokes: block width = number of tasks (dashed: not yet split into tasks, size estimated), fill = done; click: the block's tasks in the chart; ticks: which releases to show",
154
+ outside: "outside the plan", outsideTip: "Tasks in no plan block: history before the plan, old epics",
155
+ ofTasks: (d, t) => `${d} of ${t} tasks`, remaining: "remaining", doneNoItems: "(done, no items in TaskPilot)",
156
+ estNoItems: "(estimate, items not created yet)", items: "TaskPilot items", block: "block: ",
157
+ hasRework: "has rework", week: n => `wk ${n}`, dataAsOf: "data as of", span: "span", inside: "inside",
158
+ reworkLbl: "rework", blocksLbl: "blocks", parent: "parent", related: "related",
159
+ created: (c, u) => `created ${c}, updated ${u}`, bars: "bars", gitStatuses: "statuses in git", commits: "commits",
160
+ byCommits: "(from commits after closing)",
161
+ },
162
+ };
163
+ const L = I18N[DATA.lang] || I18N.en;
164
+ const STATUS = L.status, TYPE = L.type, KIND = L.kind;
165
+ const css = n => getComputedStyle(document.documentElement).getPropertyValue(n).trim();
166
+ const statusVar = s => ({ done: "--done", in_progress: "--progress", ready: "--ready", backlog: "--backlog", cancelled: "--cancelled" })[s] || "--summary";
167
+ const T = s => s ? Date.parse(s) : null;
168
+ const esc = s => String(s ?? "").replace(/[&<>"]/g, c => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
169
+ const fmt = t => new Date(t).toLocaleString(L.locale, { day: "2-digit", month: "2-digit", hour: "2-digit", minute: "2-digit" });
170
+ const store = { get(k, d) { try { const v = localStorage.getItem("roadmap." + k); return v == null ? d : JSON.parse(v); } catch (e) { return d; } },
171
+ set(k, v) { try { localStorage.setItem("roadmap." + k, JSON.stringify(v)); } catch (e) {} } };
172
+
173
+ const rows = DATA.rows, byId = Object.fromEntries(rows.map(r => [r.id, r]));
174
+ const NOW = T(DATA.now), SINCE_M = DATA.milestones.find(m => m.since), FORK = SINCE_M ? T(SINCE_M.date) : NOW - 2 * DAY;
175
+ rows.forEach(r => { r.bars.forEach(b => { b.S = T(b.s); b.E = Math.max(T(b.e), T(b.s)); b.I = T(b.idle_from); });
176
+ if (r.summary) { r.summary.S = T(r.summary.s); r.summary.E = T(r.summary.e); r.summary.A = T(r.summary.actual_e); }
177
+ r.span = r.summary ? [r.summary.S, r.summary.E] : [Math.min(...r.bars.map(b => b.S)), Math.max(...r.bars.map(b => b.E))];
178
+ r.leafClosed = !r.children.length ? ["done", "cancelled"].includes(r.status) : null; });
179
+ const allClosed = r => r.children.length ? r.children.every(c => allClosed(byId[c])) : r.leafClosed;
180
+ rows.forEach(r => r.closedAll = allClosed(r));
181
+
182
+ let pxh = store.get("pxh2", 1.25), focus = null, phaseOn = store.get("phaseOn", {}), collapsed = new Set(store.get("collapsed", [])), opened = new Set(store.get("opened", []));
183
+ const el = id => document.getElementById(id);
184
+ document.documentElement.lang = DATA.lang;
185
+ document.title = `${DATA.title}: ${L.roadmap}`;
186
+ el("h1").textContent = document.title;
187
+ el("meta").textContent = L.meta(fmt(NOW));
188
+ el("zout").title = L.zoomOut; el("zin").title = L.zoomIn; el("today").textContent = L.today;
189
+ el("foldLabel").textContent = L.foldDone; el("relLabel").textContent = L.showRel;
190
+ el("q").placeholder = L.search((rows.find(r => r.type !== "group") || { id: "ID-1" }).id);
191
+ el("focusX").title = L.clearFilter; el("corner").textContent = L.corner;
192
+ if (SINCE_M) { el("sinceBox").style.display = ""; el("sinceLabel").textContent = L.since(SINCE_M.label); }
193
+
194
+ // Totals over leaves.
195
+ (() => { const c = {}; rows.filter(r => !r.children.length).forEach(r => c[r.status] = (c[r.status] || 0) + 1);
196
+ const rw = rows.filter(r => r.bars.some(b => b.kind === "rework")).length;
197
+ el("totals").innerHTML = ["done", "in_progress", "ready", "backlog", "cancelled"].filter(s => c[s]).map(s =>
198
+ `<span><b style="color:var(${statusVar(s)})">${c[s]}</b> ${STATUS[s]}</span>`).join("") + (rw ? `<span><b style="color:var(--rework)">${rw}</b> ${L.withRework}</span>` : ""); })();
199
+
200
+ function legend() {
201
+ const sw = (fill, extra = "") => `<svg width="22" height="12"><rect x="1" y="2" width="20" height="9" rx="2" ${fill} ${extra}/></svg>`;
202
+ el("legend").innerHTML = [
203
+ [sw(`fill="var(--done)"`), L.lgDone], [sw(`fill="var(--progress)"`), L.lgProgress],
204
+ [sw(`fill="var(--stalled)"`), L.lgStalled], [sw(`fill="url(#rwp)"`), L.lgRework],
205
+ [sw(`fill="none" stroke="var(--backlog)" stroke-dasharray="3 2"`), L.lgEstimate],
206
+ [sw(`fill="none" stroke="var(--progress)" stroke-width="2" stroke-dasharray="5 2"`), L.lgPlan],
207
+ [`<svg width="22" height="12"><path d="M1 6H17" stroke="var(--link)" fill="none"/><path d="M15 3l4 3-4 3" fill="var(--link)"/></svg>`, L.lgBlocks],
208
+ [`<svg width="22" height="12"><path d="M1 6H17" stroke="var(--reworklink)" stroke-dasharray="3 2" fill="none"/><path d="M15 3l4 3-4 3" fill="var(--reworklink)"/></svg>`, L.lgReworkOf],
209
+ [`<svg width="10" height="12"><circle cx="5" cy="7" r="2.5" fill="var(--muted)"/></svg>`, L.lgCommit((DATA.id_prefixes.join("/") || "ID") + "-id")],
210
+ ].map(([i, t]) => `<span>${i} ${t}</span>`).join("");
211
+ }
212
+
213
+ function isoWeek(d) {
214
+ const t = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate())), day = t.getUTCDay() || 7;
215
+ t.setUTCDate(t.getUTCDate() + 4 - day);
216
+ return Math.ceil(((t - Date.UTC(t.getUTCFullYear(), 0, 1)) / DAY + 1) / 7);
217
+ }
218
+
219
+ // Plan: one "sausage" per phase, a segment per block sized by its tasks and filled by the done share.
220
+ function phases() {
221
+ const P = DATA.phases || [];
222
+ if (!P.length) { el("phases").style.display = "none"; return; }
223
+ const pct = (d, t) => t ? Math.round(100 * d / t) : 0;
224
+ el("phases").innerHTML = `<div class="ph-h"><b>${L.plan}</b><span>${L.planHint}</span>
225
+ <label title="${esc(L.outsideTip)}"><input type="checkbox" data-ph=""${phaseOn[""] === false ? "" : " checked"}> ${L.outside}</label></div>` +
226
+ P.map((ph, pi) => `<label class="ph-name" title="${esc(ph.goal)}"><input type="checkbox" data-ph="${esc(ph.id)}"${phaseOn[ph.id] === false ? "" : " checked"}><span>${esc(ph.title)}<small>${pct(ph.done, ph.total)}% · ${L.ofTasks(ph.done, ph.total)}</small></span></label>
227
+ <div class="sausage">${ph.blocks.map((b, bi) => `<div class="seg ${b.items.length ? "" : "est"}" data-p="${pi}" data-b="${bi}" style="flex-grow:${b.total}"
228
+ title="${esc(`${b.title}: ${L.ofTasks(b.done, b.total)}${b.note ? "\n" + b.note : ""}${b.open.length ? "\n" + L.remaining + ": " + b.open.join(", ") : ""}`)}">
229
+ <div class="fill" style="width:${pct(b.done, b.total)}%"></div><div class="lab">${esc(b.title)}<i>${b.done}/${b.total}</i></div></div>`).join("")}</div>`).join("");
230
+ // Release filter: an unchecked phase hides its epics, features and tasks (a row's phase: roadmap.py phase_of).
231
+ el("phases").addEventListener("change", e => { const c = e.target.closest("input[data-ph]"); if (!c) return;
232
+ phaseOn[c.dataset.ph] = c.checked; store.set("phaseOn", phaseOn); render(); });
233
+ el("phases").addEventListener("click", e => {
234
+ const sg = e.target.closest(".seg"); if (!sg) return;
235
+ const b = P[+sg.dataset.p].blocks[+sg.dataset.b];
236
+ document.querySelectorAll(".seg.on").forEach(x => x.classList.remove("on"));
237
+ // Every click replaces the filter; a block without items has nothing to show in the chart.
238
+ if (b.items.length) { sg.classList.add("on"); setFocus({ ids: new Set(b.items), label: b.title }); } else setFocus(null);
239
+ const chip = id => byId[id] ? `<li><a data-go="${id}">${id}</a> ${esc(byId[id].title)} <span class="k">· ${STATUS[byId[id].status] || byId[id].status}</span></li>` : "";
240
+ el("dbody").innerHTML = `<h2>${esc(P[+sg.dataset.p].title)} · ${esc(b.title)}</h2><div class="k">${L.ofTasks(b.done, b.total)}${b.items.length ? "" : b.total && b.done === b.total ? " " + L.doneNoItems : " " + L.estNoItems}</div>
241
+ ${b.note ? `<p>${esc(b.note)}</p>` : ""}${b.items.length ? `<div class="k">${L.items}</div><ul>${b.items.map(chip).join("")}</ul>` : ""}
242
+ ${b.open.length ? `<div class="k">${L.remaining}</div><ul>${b.open.map(chip).join("")}</ul>` : ""}`;
243
+ el("detail").style.display = "block";
244
+ });
245
+ }
246
+ function setFocus(f) {
247
+ focus = f;
248
+ el("focus").style.display = f ? "inline-flex" : "none";
249
+ el("focusLabel").textContent = f ? L.block + f.label : "";
250
+ if (!f) document.querySelectorAll(".seg.on").forEach(x => x.classList.remove("on"));
251
+ render(); toToday();
252
+ }
253
+
254
+ function visibleRows() {
255
+ const out = [], q = el("q").value.trim().toLowerCase(), iso = !!SINCE_M && el("isoOnly").checked, fold = el("foldDone").checked;
256
+ const inFocus = r => { for (let p = r; p; p = byId[p.parent]) if (focus.ids.has(p.id)) return true; return false; };
257
+ const phaseOk = r => phaseOn[r.phase || ""] !== false;
258
+ const match = r => (!q || r.id.toLowerCase().includes(q) || r.title.toLowerCase().includes(q)) && (!focus || inFocus(r)) && phaseOk(r) || (r.children || []).some(c => match(byId[c]));
259
+ // A search or a block filter opens auto-folded groups; a group the user folded stays folded.
260
+ const isClosed = r => r.children.length && (collapsed.has(r.id) || (fold && !q && !focus && r.closedAll && !opened.has(r.id)));
261
+ const walk = (r) => {
262
+ if (!match(r)) return;
263
+ if (iso && r.span[1] < FORK && r.closedAll) return;
264
+ out.push(r);
265
+ if (!isClosed(r)) r.children.forEach(c => walk(byId[c]));
266
+ };
267
+ rows.filter(r => !r.parent).forEach(walk);
268
+ return { list: out, isClosed, match };
269
+ }
270
+
271
+ function render() {
272
+ const { list, isClosed, match } = visibleRows();
273
+ const iso = !!SINCE_M && el("isoOnly").checked;
274
+ let t0 = Math.min(...list.map(r => r.span[0]).filter(isFinite)), t1 = Math.max(NOW, ...list.map(r => r.span[1]).filter(isFinite));
275
+ if (!isFinite(t0)) t0 = NOW - DAY; // nothing visible (a search with no match)
276
+ if (iso) t0 = Math.max(t0, FORK - 6 * H);
277
+ t0 = new Date(t0).setHours(0, 0, 0, 0); t1 = new Date(t1 + DAY).setHours(0, 0, 0, 0);
278
+ const weekMode = DAY / H * pxh < 60;
279
+ if (weekMode) { const d = new Date(t0); d.setDate(d.getDate() - (d.getDay() + 6) % 7); t0 = d.getTime();
280
+ const e = new Date(t1); e.setDate(e.getDate() + (8 - e.getDay()) % 7); t1 = e.getTime(); }
281
+ const W = Math.ceil((t1 - t0) / H * pxh), X = t => Math.round((Math.max(t, t0) - t0) / H * pxh * 10) / 10;
282
+ const HGT = list.length * ROWH;
283
+ document.documentElement.style.setProperty("--rowh", ROWH + "px");
284
+
285
+ // Labels.
286
+ el("corner").style.width = el("labels").style.width = LABELW + "px";
287
+ el("labels").innerHTML = list.map((r, i) => {
288
+ const caret = r.children.length ? (isClosed(r) ? "▶" : "▼") : "";
289
+ const cnt = r.counts && Object.keys(r.counts).length ? `<span class="cnt">${r.counts.done || 0}/${Object.values(r.counts).reduce((a, b) => a + b, 0)}</span>` : "";
290
+ const rw = r.bars.some(b => b.kind === "rework") || r.rework_of.length ? `<span class="rw" title="${esc(L.hasRework)}">↻</span>` : "";
291
+ const chip = r.status ? `<span class="chip" style="background:var(${statusVar(r.status)})">${STATUS[r.status] || r.status}</span>` : "";
292
+ return `<div class="row d${r.depth} ${i % 2 ? "alt" : ""} ${r.closedAll ? "closed" : ""}" data-id="${r.id}" style="padding-left:${6 + r.depth * 16}px">
293
+ <span class="caret">${caret}</span>${r.type !== "group" ? `<span class="rid">${r.id}</span>` : ""}<span class="title" title="${esc(r.title)}">${esc(r.title)}</span>${rw}${cnt}${chip}</div>`;
294
+ }).join("");
295
+
296
+ // Axis.
297
+ const ax = el("axissvg"), AH = 58; // lanes: week or day labels 15, milestones 29, "data as of" 42, day numbers or hours 53
298
+ ax.setAttribute("width", W); ax.setAttribute("height", AH);
299
+ let a = "";
300
+ const weekW = 7 * DAY / H * pxh, every = Math.ceil(60 / weekW);
301
+ // The label fits the week's width: full range, the week number, or a date on every n-th week.
302
+ const weekLabel = (dd, end, f) => { const n = isoWeek(dd);
303
+ const txt = weekW >= 160 ? `${L.week(n)} · ${f(dd)} – ${f(end)}` : weekW >= 60 ? L.week(n) : n % every ? "" : f(dd);
304
+ return txt ? `<text x="${X(dd.getTime()) + 5}" y="15" font-size="11.5" fill="var(--ink)" font-weight="600">${txt}</text>` : ""; };
305
+ const dayW = DAY / H * pxh, step = pxh >= 16 ? 3 : pxh >= 8 ? 6 : pxh >= 4 ? 12 : 0;
306
+ for (let d = t0; d < t1; d = new Date(d + DAY + 2 * H).setHours(0, 0, 0, 0)) {
307
+ const x = X(d), dd = new Date(d), we = [0, 6].includes(dd.getDay());
308
+ if (weekMode) { // week labels on Mondays, day numbers below when there is room
309
+ if (dd.getDay() === 1) { const end = new Date(d + 6 * DAY + 2 * H), f = o => o.toLocaleDateString(L.locale, { day: "numeric", month: "short" }).replace(".", "");
310
+ a += `<line x1="${x}" y1="0" x2="${x}" y2="${AH}" stroke="var(--line2)"/>${weekLabel(dd, end, f)}`; }
311
+ else a += `<line x1="${x}" y1="${AH - 4}" x2="${x}" y2="${AH}" stroke="var(--line2)"/>`;
312
+ if (dayW >= 16) a += `<text x="${x + 2}" y="${AH - 5}" font-size="9.5" fill="var(${we ? "--muted" : "--ink"})" opacity=".7">${dd.getDate()}</text>`;
313
+ continue;
314
+ }
315
+ a += `<line x1="${x}" y1="0" x2="${x}" y2="${AH}" stroke="var(--line2)"/>`;
316
+ const lab = dd.toLocaleDateString(L.locale, dayW > 70 ? { weekday: "short", day: "2-digit", month: "2-digit" } : { day: "2-digit", month: "2-digit" });
317
+ a += `<text x="${x + 4}" y="15" font-size="11.5" fill="var(${we ? "--muted" : "--ink"})" font-weight="600">${lab}</text>`;
318
+ if (step) for (let h = step; h < 24; h += step) { const xh = X(d + h * H);
319
+ a += `<line x1="${xh}" y1="${AH - 4}" x2="${xh}" y2="${AH}" stroke="var(--line2)"/><text x="${xh + 2}" y="${AH - 5}" font-size="10" fill="var(--muted)">${h}</text>`; }
320
+ }
321
+ let freeX = -1e9; // milestone labels only where they do not run into the previous one; all keep a tooltip
322
+ DATA.milestones.forEach(m => { const x = X(T(m.date)); if (T(m.date) < t0) return;
323
+ a += `<path d="M${x} 20 l4 5 -4 5 -4 -5z" fill="var(--mile)"><title>${esc(m.label)}</title></path>`;
324
+ if (x > freeX) { a += `<text x="${x + 6}" y="30" font-size="10.5" fill="var(--mile)">${esc(m.label)}</text>`; freeX = x + 12 + m.label.length * 6; } });
325
+ a += `<line x1="${X(NOW)}" y1="0" x2="${X(NOW)}" y2="${AH}" stroke="var(--today)" stroke-width="2"/><text x="${X(NOW) + 4}" y="42" font-size="10.5" fill="var(--today)" font-weight="600">${esc(L.dataAsOf)}</text>`;
326
+ ax.innerHTML = a;
327
+
328
+ // Chart.
329
+ const ch = el("chart"); ch.setAttribute("width", W); ch.setAttribute("height", HGT);
330
+ const yc = i => i * ROWH + ROWH / 2, pos = {};
331
+ list.forEach((r, i) => pos[r.id] = i);
332
+ let s = `<defs>
333
+ <pattern id="rwp" width="6" height="6" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"><rect width="6" height="6" fill="var(--rework)"/><rect width="2.5" height="6" fill="rgba(255,255,255,.35)"/></pattern>
334
+ <pattern id="cxp" width="5" height="5" patternUnits="userSpaceOnUse" patternTransform="rotate(-45)"><rect width="5" height="5" fill="var(--cancelled)"/><rect width="1.5" height="5" fill="rgba(0,0,0,.18)"/></pattern>
335
+ <marker id="ah" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="7" markerHeight="7" orient="auto"><path d="M0 0L8 4L0 8z" fill="var(--link)"/></marker>
336
+ <marker id="ahr" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="7" markerHeight="7" orient="auto"><path d="M0 0L8 4L0 8z" fill="var(--reworklink)"/></marker>
337
+ </defs>`;
338
+ list.forEach((r, i) => { if (i % 2) s += `<rect x="0" y="${i * ROWH}" width="${W}" height="${ROWH}" fill="var(--rowalt)"/>`; });
339
+ for (let d = t0; d < t1; d = new Date(d + DAY + 2 * H).setHours(0, 0, 0, 0)) {
340
+ const mon = new Date(d).getDay() === 1;
341
+ if (!weekMode || mon || dayW >= 12) s += `<line x1="${X(d)}" y1="0" x2="${X(d)}" y2="${HGT}" stroke="var(${weekMode && mon ? "--line2" : "--line"})" ${weekMode && !mon ? `opacity=".5"` : ""}/>`;
342
+ }
343
+ DATA.milestones.forEach(m => { if (T(m.date) >= t0) s += `<line x1="${X(T(m.date))}" y1="0" x2="${X(T(m.date))}" y2="${HGT}" stroke="var(--mile)" stroke-dasharray="4 4" opacity=".7"/>`; });
344
+
345
+ const MINW = 5;
346
+ const barRect = (r, b, i) => {
347
+ const x = X(b.S), w = Math.max(MINW, X(b.E) - x), y = yc(i) - 7, h = 14, c = `var(${statusVar(r.status)})`;
348
+ const tag = `data-id="${r.id}" data-k="${b.kind}" data-s="${b.S}" data-e="${b.E}"`;
349
+ if (b.kind === "estimate") return `<rect ${tag} x="${x}" y="${y + 1}" width="${w}" height="${h - 2}" rx="3" fill="${c}" fill-opacity=".08" stroke="${c}" stroke-dasharray="4 3"/>`;
350
+ if (b.kind === "plan") return `<rect ${tag} x="${x}" y="${y}" width="${w}" height="${h}" rx="3" fill="${c}" fill-opacity=".12" stroke="${c}" stroke-width="2" stroke-dasharray="6 3"/>`;
351
+ if (b.kind === "rework") return `<rect ${tag} x="${x}" y="${y}" width="${w}" height="${h}" rx="3" fill="url(#rwp)"/>`;
352
+ if (b.kind === "cancelled") return `<rect ${tag} x="${x}" y="${y}" width="${w}" height="${h}" rx="3" fill="url(#cxp)"/>`;
353
+ if (b.kind === "stalled") { const xi = Math.max(x + MINW, X(b.I));
354
+ return `<rect ${tag} x="${x}" y="${y}" width="${xi - x}" height="${h}" rx="3" fill="var(--stalled)"/><line ${tag} x1="${xi}" y1="${yc(i)}" x2="${X(b.E)}" y2="${yc(i)}" stroke="var(--stalled)" stroke-width="2" stroke-dasharray="1 4" stroke-linecap="round"/>`; }
355
+ if (b.kind === "ongoing") return `<rect ${tag} x="${x}" y="${y}" width="${w}" height="${h}" rx="3" fill="var(--progress)"/><path d="M${x + w} ${y} l6 7 -6 7z" fill="var(--progress)"/>`;
356
+ return `<rect ${tag} x="${x}" y="${y}" width="${w}" height="${h}" rx="3" fill="${c}"/>`;
357
+ };
358
+ list.forEach((r, i) => {
359
+ if (r.summary) {
360
+ const x0 = X(r.summary.S), x1 = Math.max(x0 + MINW, X(r.summary.E)), xa = r.summary.A ? Math.max(x0, X(r.summary.A)) : x0, y = yc(i) - (isClosed(r) ? 5 : 9);
361
+ s += `<g data-id="${r.id}" data-k="summary" data-s="${r.summary.S}" data-e="${r.summary.E}">`;
362
+ if (x1 > xa) s += `<rect x="${xa}" y="${y}" width="${x1 - xa}" height="5" fill="var(--summary)" opacity=".28"/>`;
363
+ if (xa > x0) s += `<rect x="${x0}" y="${y}" width="${xa - x0}" height="5" fill="var(--summary)"/>`;
364
+ s += `<path d="M${x0} ${y}v9l4 -4z M${x1} ${y}v9l-4 -4z" fill="var(--summary)"/><rect x="${x0}" y="${y - 3}" width="${x1 - x0}" height="12" fill="transparent"/></g>`;
365
+ if (isClosed(r)) { // folded: also draw children's leaf bars faintly in this row
366
+ const leaves = []; const coll = c => { const k = byId[c]; k.children.length ? k.children.forEach(coll) : match(k) && leaves.push(k); }; r.children.forEach(coll); // leaves the filters keep
367
+ leaves.forEach(k => k.bars.forEach(b => { if (b.kind !== "estimate") s += `<rect x="${X(b.S)}" y="${yc(i) + 2}" width="${Math.max(2, X(b.E) - X(b.S))}" height="5" fill="${b.kind === "rework" ? "var(--rework)" : `var(${statusVar(k.status)})`}" opacity=".75"/>`; }));
368
+ }
369
+ }
370
+ // Parents show the summary bracket; of their own bars only rework and cancellation add information.
371
+ r.bars.forEach(b => { if (!r.children.length || ["rework", "cancelled"].includes(b.kind)) s += barRect(r, b, i); });
372
+ r.ticks.forEach(([t, h, subj]) => { if (T(t) >= t0) s += `<circle cx="${X(T(t))}" cy="${yc(i) + 9.5}" r="1.8" fill="var(--muted)"><title>${esc(h + " " + subj)}</title></circle>`; });
373
+ });
374
+
375
+ // Dependency arrows (blocks), rework links, optional relates.
376
+ const anchor = id => { let r = byId[id]; while (r && pos[r.id] == null) r = byId[r.parent]; return r; };
377
+ const firstS = r => r.summary ? r.summary.S : Math.min(...r.bars.map(b => b.S));
378
+ const lastE = r => r.summary ? r.summary.E : Math.max(...r.bars.map(b => b.E));
379
+ const actualE = r => { const a = r.bars.filter(b => !["estimate", "plan"].includes(b.kind)); return a.length ? Math.max(...a.map(b => b.E)) : lastE(r); };
380
+ const seen = new Set();
381
+ const sel = render.sel;
382
+ const arrow = (from, to, cls) => {
383
+ const A = anchor(from), B = anchor(to); if (!A || !B || A === B) return "";
384
+ // Finished history keeps its arrows for the selected row only; anything unfinished always shows them.
385
+ if (byId[from].closedAll && byId[to].closedAll && ![from, to, A.id, B.id].includes(sel)) return "";
386
+ const key = A.id + ">" + B.id + cls; if (seen.has(key)) return ""; seen.add(key);
387
+ const ia = pos[A.id], ib = pos[B.id];
388
+ const xa = X(cls === "rw" ? actualE(A) : lastE(A)), ya = yc(ia), xb = X(firstS(B)), yb = yc(ib);
389
+ const col = cls === "rw" ? "var(--reworklink)" : "var(--link)", mk = cls === "rw" ? "ahr" : "ah";
390
+ const dash = cls === "rel" ? `stroke-dasharray="2 3"` : cls === "rw" ? `stroke-dasharray="5 3"` : "";
391
+ let d;
392
+ if (xb - xa > 14) { const mx = xa + 8; d = `M${xa} ${ya}H${mx}V${yb}H${xb - 1}`; }
393
+ else { const my = yb + (yb > ya ? -ROWH / 2 : ROWH / 2); d = `M${xa} ${ya}h8V${my}H${xb - 10}V${yb}H${xb - 1}`; }
394
+ return `<path class="arr" data-a="${A.id}" data-b="${B.id}" d="${d}" fill="none" stroke="${col}" stroke-width="1.2" ${dash} marker-end="${cls === "rel" ? "" : `url(#${mk})`}" opacity=".75"/>`;
395
+ };
396
+ rows.forEach(r => { r.blocks.forEach(t => s += arrow(r.id, t, "blk")); r.rework_of.forEach(o => s += arrow(o, r.id, "rw"));
397
+ if (el("showRel").checked) r.relates.forEach(t => s += arrow(r.id, t, "rel")); });
398
+ s += `<line x1="${X(NOW)}" y1="0" x2="${X(NOW)}" y2="${HGT}" stroke="var(--today)" stroke-width="2" opacity=".85"/>`;
399
+ ch.innerHTML = s;
400
+ render.X = X; render.t0 = t0; render.W = W;
401
+ }
402
+
403
+ // Interaction.
404
+ const tip = el("tip");
405
+ function describe(r, k, S, E) {
406
+ const kids = r.counts && Object.keys(r.counts).length ? Object.entries(r.counts).map(([s, n]) => `${n} ${STATUS[s] || s}`).join(", ") : "";
407
+ return `<b>${r.type !== "group" ? r.id + " · " : ""}${esc(r.title)}</b><br>
408
+ <span class="k">${TYPE[r.type] || r.type}${r.status ? " · " + (STATUS[r.status] || r.status) : ""}</span>
409
+ ${k ? `<br><span class="k">${k === "summary" ? L.span : KIND[k] || k}:</span> ${fmt(S)} → ${fmt(E)}` : ""}
410
+ ${kids ? `<br><span class="k">${L.inside}:</span> ${kids}` : ""}
411
+ ${r.rework_of.length ? `<br><span class="k">${L.reworkLbl}:</span> ${r.rework_of.join(", ")}` : ""}
412
+ ${r.blocks.length ? `<br><span class="k">${L.blocksLbl}:</span> ${r.blocks.join(", ")}` : ""}`;
413
+ }
414
+ document.addEventListener("mousemove", e => {
415
+ const t = e.target.closest("[data-k]");
416
+ if (!t) { tip.style.display = "none"; return; }
417
+ const r = byId[t.dataset.id];
418
+ tip.innerHTML = describe(r, t.dataset.k, +t.dataset.s, +t.dataset.e);
419
+ tip.style.display = "block";
420
+ const w = tip.offsetWidth, h = tip.offsetHeight;
421
+ tip.style.left = Math.min(e.clientX + 14, innerWidth - w - 8) + "px";
422
+ tip.style.top = (e.clientY + 16 + h > innerHeight ? e.clientY - h - 10 : e.clientY + 16) + "px";
423
+ });
424
+ function showDetail(id) {
425
+ const r = byId[id]; if (!r) return;
426
+ const hist = r.history.map(([t, s]) => `<li>${fmt(T(t))}: ${STATUS[s] || s}</li>`).join("");
427
+ const ticks = r.ticks.map(([t, h, subj]) => `<li>${fmt(T(t))} <code>${h}</code> ${esc(subj)}</li>`).join("");
428
+ const bars = r.bars.map(b => `<li>${KIND[b.kind] || b.kind}: ${fmt(b.S)} → ${fmt(b.E)}${b.from === "commits" ? " " + L.byCommits : ""}</li>`).join("");
429
+ const lk = ids => ids.map(i => `<a data-go="${i}">${i}</a>`).join(", ");
430
+ el("dbody").innerHTML = `<h2>${r.type !== "group" ? r.id + " · " : ""}${esc(r.title)}</h2>
431
+ <div class="k">${TYPE[r.type] || r.type}${r.status ? " · " + (STATUS[r.status] || r.status) : ""}${r.priority ? " · " + r.priority : ""}${r.created ? ` · ${L.created(fmt(T(r.created)), fmt(T(r.updated)))}` : ""}</div>
432
+ ${r.parent && byId[r.parent].type !== "group" ? `<div><span class="k">${L.parent}:</span> ${lk([r.parent])}</div>` : ""}
433
+ ${r.blocks.length ? `<div><span class="k">${L.blocksLbl}:</span> ${lk(r.blocks)}</div>` : ""}
434
+ ${r.relates.length ? `<div><span class="k">${L.related}:</span> ${lk(r.relates)}</div>` : ""}
435
+ ${r.rework_of.length ? `<div><span class="k">${L.reworkLbl}:</span> ${lk(r.rework_of)}</div>` : ""}
436
+ ${r.desc ? `<p>${esc(r.desc)}</p>` : ""}
437
+ ${bars ? `<div class="k">${L.bars}</div><ul>${bars}</ul>` : ""}
438
+ ${hist ? `<div class="k">${L.gitStatuses}</div><ul>${hist}</ul>` : ""}
439
+ ${ticks ? `<div class="k">${L.commits}</div><ul>${ticks}</ul>` : ""}`;
440
+ el("detail").style.display = "block";
441
+ if (render.sel !== id) { render.sel = id; const sc = el("scroller"), l = sc.scrollLeft, tp = sc.scrollTop; render(); sc.scrollLeft = l; sc.scrollTop = tp; }
442
+ document.querySelectorAll(".row.hl").forEach(x => x.classList.remove("hl"));
443
+ const row = document.querySelector(`.row[data-id="${id}"]`); if (row) row.classList.add("hl");
444
+ }
445
+ el("dclose").onclick = () => { el("detail").style.display = "none"; render.sel = null; const sc = el("scroller"), l = sc.scrollLeft; render(); sc.scrollLeft = l; };
446
+ el("dbody").addEventListener("click", e => { const a = e.target.closest("[data-go]"); if (!a) return;
447
+ let p = byId[a.dataset.go].parent; while (p) { collapsed.delete(p); opened.add(p); p = byId[p].parent; }
448
+ render(); showDetail(a.dataset.go); const row = document.querySelector(`.row[data-id="${a.dataset.go}"]`); if (row) row.scrollIntoView({ block: "center" }); });
449
+ el("labels").addEventListener("click", e => {
450
+ const row = e.target.closest(".row"); if (!row) return; const r = byId[row.dataset.id];
451
+ if (r.children.length && (e.target.classList.contains("caret") || e.target.closest(".caret") || r.type === "group" || r.depth === 0 && e.detail === 2)) {
452
+ const { isClosed } = visibleRows();
453
+ if (isClosed(r)) { collapsed.delete(r.id); opened.add(r.id); } else { collapsed.add(r.id); opened.delete(r.id); }
454
+ store.set("collapsed", [...collapsed]); store.set("opened", [...opened]); render(); return;
455
+ }
456
+ showDetail(r.id);
457
+ });
458
+ el("chart").addEventListener("click", e => { const t = e.target.closest("[data-id]"); if (t) showDetail(t.dataset.id); });
459
+ const keepCenter = f => { const sc = el("scroller"), c = sc.scrollLeft + (sc.clientWidth - LABELW) / 2, t = render.t0 + c / pxh * H; f(); render(); sc.scrollLeft = (t - render.t0) / H * pxh - (sc.clientWidth - LABELW) / 2; };
460
+ el("zin").onclick = () => keepCenter(() => { pxh = Math.min(48, pxh * 1.5); store.set("pxh2", pxh); });
461
+ el("zout").onclick = () => keepCenter(() => { pxh = Math.max(0.3, pxh / 1.5); store.set("pxh2", pxh); });
462
+ const toToday = () => { const sc = el("scroller"); sc.scrollLeft = Math.max(0, render.X(NOW) - (sc.clientWidth - LABELW) * 0.7); };
463
+ el("today").onclick = toToday;
464
+ ["foldDone", "isoOnly", "showRel"].forEach(id => { el(id).checked = store.get(id, el(id).checked); el(id).onchange = () => { store.set(id, el(id).checked); render(); }; });
465
+ el("q").oninput = render;
466
+ el("focusX").onclick = () => setFocus(null);
467
+ legend(); phases(); render(); toToday();
468
+ </script>
469
+ </body>
470
+ </html>