create-pmos 0.398.0 → 0.399.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.
Files changed (126) hide show
  1. package/package.json +13 -13
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-adddoc-test.js +18 -14
  7. package/workspace/briefing-premium-board-test.js +80 -48
  8. package/workspace/briefing-premium-calendar-2-test.js +36 -36
  9. package/workspace/briefing-premium-calendar-3-test.js +39 -39
  10. package/workspace/briefing-premium-calendar-test.js +23 -24
  11. package/workspace/briefing-premium-doc-edit-test.js +6 -2
  12. package/workspace/briefing-premium-initiative-test.js +38 -16
  13. package/workspace/briefing-premium-insights-test.js +114 -37
  14. package/workspace/briefing-premium-metrics-test.js +6 -4
  15. package/workspace/briefing-premium-products-test.js +10 -7
  16. package/workspace/briefing-premium-sources-test.js +25 -22
  17. package/workspace/briefing-premium-test.js +46 -42
  18. package/workspace/briefing-premium-work-test.js +9 -9
  19. package/workspace/changelog.json +12 -0
  20. package/workspace/ev-everywhere-test.js +210 -0
  21. package/workspace/fixtures/premium-viewer-fixtures.js +11 -6
  22. package/workspace/guide/home.md +39 -18
  23. package/workspace/guide/index.md +1 -1
  24. package/workspace/lib/board-grill.js +63 -0
  25. package/workspace/lib/board-premium.js +36 -5
  26. package/workspace/lib/initiative-layout.js +77 -0
  27. package/workspace/lib/insights-premium.js +3 -2
  28. package/workspace/lib/insights-records.js +21 -7
  29. package/workspace/lib/meeting-points.js +52 -0
  30. package/workspace/lib/news-for-you.js +88 -0
  31. package/workspace/lib/notes-series.js +29 -6
  32. package/workspace/lib/report-confirm.js +48 -0
  33. package/workspace/lib/route-modules.js +8 -0
  34. package/workspace/lib/routes-board-docs.js +46 -0
  35. package/workspace/lib/routes-board-grill.js +90 -0
  36. package/workspace/lib/routes-home-review.js +108 -0
  37. package/workspace/lib/routes-initiative-layout.js +57 -0
  38. package/workspace/lib/routes-insights-premium.js +4 -1
  39. package/workspace/lib/routes-insights-records.js +8 -4
  40. package/workspace/lib/routes-meeting-points.js +37 -0
  41. package/workspace/lib/routes-news.js +57 -0
  42. package/workspace/lib/routes-notes.js +2 -1
  43. package/workspace/lib/routes-report-confirm.js +31 -0
  44. package/workspace/lib/routes-search.js +38 -0
  45. package/workspace/lib/search-index.js +176 -0
  46. package/workspace/package-lock.json +2 -2
  47. package/workspace/package.json +1 -1
  48. package/workspace/premium-board-actions-test.js +86 -50
  49. package/workspace/premium-briefing-depth-test.js +55 -54
  50. package/workspace/premium-chat-chart-tab-test.js +4 -2
  51. package/workspace/premium-chat-report-tab-test.js +16 -2
  52. package/workspace/premium-core-doc-issue-test.js +15 -13
  53. package/workspace/premium-phone-card-test.js +5 -3
  54. package/workspace/premium-report-read-test.js +55 -18
  55. package/workspace/premium-vw-backlog-test.js +2 -2
  56. package/workspace/premium-vw-cal-test.js +50 -35
  57. package/workspace/premium-vw-doc-test.js +9 -3
  58. package/workspace/premium-vw-item-test.js +1 -1
  59. package/workspace/premium-vw-jira-test.js +2 -2
  60. package/workspace/premium-vw-meet-test.js +37 -40
  61. package/workspace/premium-vw-notes-test.js +21 -19
  62. package/workspace/premium-vw-rec-test.js +11 -12
  63. package/workspace/premium-welcome-test.js +3 -3
  64. package/workspace/premium-work-depth-test.js +3 -3
  65. package/workspace/public/pm/bd-acts.js +303 -225
  66. package/workspace/public/pm/bd-asks.js +261 -0
  67. package/workspace/public/pm/bd-pop.js +59 -0
  68. package/workspace/public/pm/bd-span.js +49 -13
  69. package/workspace/public/pm/bd-views.js +169 -0
  70. package/workspace/public/pm/cozy-board.css +301 -0
  71. package/workspace/public/pm/cozy-ev.css +228 -0
  72. package/workspace/public/pm/cozy-evmodel.js +106 -0
  73. package/workspace/public/pm/cozy-evui.js +47 -0
  74. package/workspace/public/pm/cozy-insights.css +148 -10
  75. package/workspace/public/pm/cozy-nav.js +103 -39
  76. package/workspace/public/pm/cozy-news.js +140 -0
  77. package/workspace/public/pm/cozy-search.js +203 -0
  78. package/workspace/public/pm/cozy-settings.js +198 -0
  79. package/workspace/public/pm/cozy-sources.js +89 -0
  80. package/workspace/public/pm/cozy-today.css +217 -0
  81. package/workspace/public/pm/cozy-viewer.js +1 -0
  82. package/workspace/public/pm/cozy-vw-mtg.css +350 -0
  83. package/workspace/public/pm/cozy-vw-rp.css +152 -0
  84. package/workspace/public/pm/home-adddoc.js +5 -5
  85. package/workspace/public/pm/home-app.js +329 -55
  86. package/workspace/public/pm/home-around.js +24 -126
  87. package/workspace/public/pm/home-chat.js +67 -14
  88. package/workspace/public/pm/home-data.js +6 -6
  89. package/workspace/public/pm/home-dictate.js +54 -0
  90. package/workspace/public/pm/home-draft.js +6 -6
  91. package/workspace/public/pm/home-ini-model.js +190 -0
  92. package/workspace/public/pm/home-ini.css +171 -0
  93. package/workspace/public/pm/home-ini.js +456 -0
  94. package/workspace/public/pm/home-list.js +276 -0
  95. package/workspace/public/pm/home-more.js +17 -134
  96. package/workspace/public/pm/home-phone-card.js +4 -4
  97. package/workspace/public/pm/home-review.js +104 -0
  98. package/workspace/public/pm/home-task.js +67 -0
  99. package/workspace/public/pm/home-today.js +144 -0
  100. package/workspace/public/pm/home-work.js +54 -26
  101. package/workspace/public/pm/premium-board.js +163 -39
  102. package/workspace/public/pm/premium-chart-tab.js +4 -5
  103. package/workspace/public/pm/premium-first.js +5 -7
  104. package/workspace/public/pm/premium-insights.js +499 -202
  105. package/workspace/public/pm/premium-mtg-present.js +138 -0
  106. package/workspace/public/pm/premium-mtg-replay.js +142 -0
  107. package/workspace/public/pm/premium-report-read.js +216 -52
  108. package/workspace/public/pm/premium-report-tab.js +44 -19
  109. package/workspace/public/pm/premium-shell.js +7 -7
  110. package/workspace/public/pm/premium-vw-cal.js +150 -60
  111. package/workspace/public/pm/premium-vw-mtg.js +488 -261
  112. package/workspace/public/pm/premium-vw-notes.js +61 -0
  113. package/workspace/public/pm/rp-parts.js +269 -0
  114. package/workspace/public/premium-board.html +4 -3
  115. package/workspace/public/premium-insights.html +10 -10
  116. package/workspace/public/premium.html +3 -1
  117. package/workspace/r/m1.png +0 -0
  118. package/workspace/r/m2.png +0 -0
  119. package/workspace/r/m3.png +0 -0
  120. package/workspace/r/nl.png +0 -0
  121. package/workspace/test-lists/initiative-layout.json +9 -0
  122. package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
  123. package/workspace/test-lists/premium-uncovered-reports.json +9 -0
  124. package/workspace/test-lists/uf-everywhere.json +15 -0
  125. package/workspace/test-lists/uf-home.json +9 -0
  126. package/workspace/test-lists/uncovered-board.json +9 -0
@@ -1,35 +1,56 @@
1
1
  ---
2
2
  type: Guide
3
- title: "Home (/premium.html) and the features that wait for design"
4
- description: "Home in the Agreed design: the list, the Viewer, the place menu, and the plain cards for the features the design does not draw yet."
3
+ title: "Home (/premium.html) and the designed features"
4
+ description: "Home in the Agreed design: the list grouped by product, the Viewer, the place menu, New for you, Search, and the initiative, meeting, report, Board and Insights features designed after it."
5
5
  timestamp: 2026-10-23
6
6
  ---
7
7
 
8
8
  # Home
9
9
 
10
- Home is the page at `/premium.html`. It follows the Agreed design. The left side is one list: what needs you, today's meetings, and the files of an open initiative. The right side is the Viewer. A row opens its item in the Viewer. On a phone the list is a sheet that opens from the top bar.
10
+ Home is the page at `/premium.html`. It follows the Agreed design and the "Uncovered features" canvas (initiative `premium-uncovered-features`). The left side is one list. The middle is the chat. The right side is the Viewer. A row opens its item in the Viewer. On a phone the list is the page, and a row opens its conversation with a back bar.
11
11
 
12
- Some features of the earlier premium pages are not in the Agreed design yet. Home keeps each one usable as a plain card in the Viewer. Each such card shows the label **Waiting for design**. The label means that the card works, but its look is not final. A designed version replaces the card later.
12
+ ## The list
13
+
14
+ - The list is grouped by **product**. The product's header shows its goals, for example "2 of 4 goals on track". Press a header to close or open the product.
15
+ - Each next step sits under its **initiative**. An initiative where the next step is yours comes first and shows **your turn**. The first one is open. Press an initiative to open or close it.
16
+ - **Not in an initiative** holds only the items that have no initiative: loose notes, mentions and meetings.
17
+ - The greeting says how many next steps are yours today, for example "Good morning. 2 next steps are yours today."
18
+ - **Today**, **Waiting**, **Kept** and **Done** are filters on the same list. There is no separate Needs you list and no Your list.
19
+ - On Fridays, **Weekly review** at the top of the list opens four short steps.
20
+ - The microphone in the chat box turns what you say into text. Nothing is sent until you press send.
21
+
22
+ ## An initiative
23
+
24
+ Open an initiative with `?ini=<id>`. Its card at the top of the list shows the stage and the exit items.
25
+
26
+ - **Moves on by itself** is a switch, on by default. When every exit item is done, the stage moves to the next stage and a message shows **Undo**. A stage never moves by itself into a milestone (Deliver or Evaluate). This rule is a proposal that the PM has not confirmed yet.
27
+ - **Move to <next>** with open exit items asks first (**Move anyway**, with a note). **Back** always asks for a reason.
28
+ - **Tasks** in the Viewer can be grouped by stage, by groups that you name, by owner or by status. Drag a task to another group.
29
+ - **Core documents** in the list shows only the documents that need a look. **All documents** opens every document in the Viewer.
30
+
31
+ Some features are still not designed. Home keeps each one usable as a plain card in the Viewer with the label **Waiting for design**. The label means that the card works, but its look is not final.
32
+
33
+ ## New for you, Search, Sources and Settings
34
+
35
+ - **New for you** replaces the Inbox. It holds only items to know about: mentions, tasks given to you and finished work. An item leaves the list when you have seen it. A mention that asks you something becomes the next step of its initiative.
36
+ - **Search** (Ctrl K or ⌘K, or `/`) finds initiatives, documents, sessions and files in the repository and its worktrees.
37
+ - **Sources** shows each source that Home reads and its health. **Settings** holds the theme (light, dark or the system's) and the workspace settings.
38
+
39
+ ## The other pages
40
+
41
+ - **Board.** New initiative takes links and files, starts in Triage and asks only the questions that the material does not answer. **Later** keeps the questions as the next step. The Board also has List, By stage, Documents and spans. On a phone, **Metrics** and **Cancelled and archived** are in every view.
42
+ - **Meetings.** Replay with screen captures and kept points, Focus, a presenter view, Add material, the After view, a Day, Week and Month calendar, and Notes.
43
+ - **Reports.** The Brief, the report states, a document reader and a live page reader.
44
+ - **Insights.** A goal's detail with its chart and readings, targets on each tile, Library flows and a Portfolio view.
13
45
 
14
46
  ## The place menu
15
47
 
16
- Press the round button at the bottom of the page, then **More**. The menu lists these items:
48
+ Press the round button at the bottom of the page (bottom left on a desktop, bottom right on a phone). The menu lists **Home**, **Board** and **Insights**, then **Search** (⌘K), **New for you** with its count, **Sources** with an amber dot when a source is behind, **Settings** and **Theme** (Light, Dark, Auto). On Home, **More** follows Settings:
17
49
 
18
- - **My work.** Your list, in four tabs: **Your list**, **Waiting on others**, **Weekly review** and **Untouched**. Type a line and press **Add** to add an item. Press **Done** to mark an item done. Press a row to open the item in the same card:
19
- - **Edit** opens the fields: **When** (Today, Not yet, Not before a date, Someday), **Waiting on**, **Who does it** (the steps) and **Priority · Due**. **Keep it** and **Drop it** are under the fields.
20
- - **The agent** can draft the item. A draft shows under the item with **Open** and **Copy**. Nothing goes out until you confirm **Post it**. **Send it back with a note** asks for a new draft.
21
- - **Back to My work**, or Escape, returns to the list. Escape closes the fields first.
22
- - **Focus** at the top of Your list opens **Focus and jobs**: accept or skip a suggestion, and add a job ("When …, I want …, so …").
23
- - On a focused row, J and K move between rows. The right and left arrows do what the row says, for example Done and Tomorrow. A drag of a row to the right or left does the same. Most presses show **Undo** for a few seconds.
24
- - **Around you.** The six rows of the earlier Briefing card: agent proposals, mentions, portfolio pulse, horizon scan, report found and data freshness. The card also shows the prep line for your next meeting and today's digests. A row opens its view in the same card. **Back** returns to the six rows. The presses are the same as before. See "Around you" in [the premium Briefing](briefing-premium.md).
25
- - **Agent results.** What the agents finished that waits on you.
50
+ - **My work.** Your own items, in the same card: **Edit** opens When, Waiting on, Who does it and Priority · Due; **Keep it** and **Drop it** are under the fields. The agent can draft an item, and nothing goes out until you confirm **Post it**. Escape closes the fields first, then returns to the list.
26
51
  - **End of the day.** What finished today, the recap, and tomorrow's meetings.
27
- - **Calendar**, **Record a note** and **Settings**.
28
- - **Search.** Find an initiative, a core document or a session by name. Press Ctrl K (⌘K on a Mac) to open it from anywhere on Home.
52
+ - **Calendar** and **Record a note.**
29
53
  - **Products.** The products that Home reads. A switch turns one product on or off. **Back to the default** goes back to the default list. With `?ws=` in the address, **All picked products** goes back to the full list.
30
- - **Sources.** The state of each source that Home reads, with a dot that shows its health. **What Home shows** says which sources give the Today and Needs you lists.
31
-
32
- To open Around you at one row, add `?around=` to the address with one of `prop`, `men`, `pulse`, `scan`, `rep` or `src`.
33
54
 
34
55
  ## A need row in the Viewer
35
56
 
@@ -28,7 +28,7 @@ On a desktop the workspace is one frame. [Layout](layout.md) explains each part.
28
28
  | The sessions of a repository, by initiative | The agent dock. ⌘K → **Branches and sessions** lists the branches. |
29
29
  | The items of an initiative | Board, or Breakdown in the initiative detail |
30
30
  | How the Briefing cards, day part, Portfolio pulse and overdue items work | [Briefing](briefing-cards.md) |
31
- | Home in the Agreed design, and the cards marked Waiting for design | [Home](home.md) |
31
+ | Home in the Agreed design: the list by product, New for you, Search, and the designed features | [Home](home.md) |
32
32
  | The premium Briefing page at /premium.html | [Premium Briefing](briefing-premium.md) |
33
33
  | Run reports | Reports |
34
34
  | Whether a document is the same as its Google Docs or Confluence copy | Docs: ⌘K → **Docs**, or press `g d` |
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+ /* lib/board-grill.js — the first questions of a new initiative (initiative premium-uncovered-features, Board: BdNew, BdGrill).
3
+ *
4
+ * fold(lines, id) → { id, why, material: { links, files }, answers: { [q]: text }, later, at } PURE
5
+ * questionsOf(state) → [{ key, n, of, topic, q, why, chips, answer }] PURE
6
+ * summaryOf(state) → { open, total, later, took: [line] } PURE
7
+ *
8
+ * A new initiative starts in Triage with no lane choice. Right after it is made, the Board shows what PMOS took from the PM's words and
9
+ * material, then asks only what they leave open, one question at a time. The questions are the BRD's four parts (the Triage output:
10
+ * business case, who asked, problem, success measure). A part the Why already answers is not asked. "Later" keeps the open questions as
11
+ * the initiative's next step.
12
+ *
13
+ * FILE MODE ONLY (D64/D66): one append-only file, <state>/triage-answers.jsonl, with lines
14
+ * { kind: 'start', initiative, why, links: [{ url, label }] } the New initiative panel's Why and links
15
+ * { kind: 'file', initiative, name, type, size, path } a file the PM added (its bytes are in <state>/material/<initiative>/)
16
+ * { kind: 'answer', initiative, q, answer } one answer (the last one per question wins)
17
+ * { kind: 'later', initiative } the PM closed the questions with Later
18
+ * Nothing here reads the material for the PM or sends it anywhere: an agent session reads it during Triage. */
19
+
20
+ /** The BRD's parts as questions. `answeredBy` says when the Why already answers one, so it is not asked. */
21
+ const QUESTIONS = [
22
+ { key: 'problem', topic: 'Problem', q: 'What problem does it solve, and who is stuck today?', why: 'The BRD starts from the problem. Your Why did not name it, so PMOS asks.',
23
+ chips: [], answeredBy: (why) => words(why) >= 8 },
24
+ { key: 'who', topic: 'Who asked', q: 'Who asked for it, or who feels the problem most?', why: 'The BRD names who asked, so the right people review it.',
25
+ chips: ['Customers', 'Partners', 'An internal team', 'Not sure yet'] },
26
+ { key: 'case', topic: 'Business case', q: 'What does it win or save if it works?', why: 'The business case decides its rank against the other initiatives.',
27
+ chips: ['Revenue', 'Retention', 'Cost', 'Risk', 'Not sure yet'] },
28
+ { key: 'success', topic: 'Success', q: 'What would show it worked?', why: 'The success measure becomes the target that Monitor reads after the release.',
29
+ chips: ['A metric moves', 'Fewer support tickets', 'A customer renews', 'Not sure yet'] },
30
+ ];
31
+ const KEYS = new Set(QUESTIONS.map((x) => x.key));
32
+ const words = (s) => String(s || '').trim().split(/\s+/).filter((w) => w.length > 1).length;
33
+
34
+ /** The state of one initiative from the file's lines. Pure. */
35
+ function fold(lines, id) {
36
+ const st = { id, why: '', material: { links: [], files: [] }, answers: {}, later: false, at: null };
37
+ for (const l of lines || []) {
38
+ if (!l || l.initiative !== id) continue;
39
+ if (l.kind === 'start') {
40
+ st.why = typeof l.why === 'string' ? l.why : st.why; st.at = st.at || l.at || null;
41
+ for (const k of Array.isArray(l.links) ? l.links : []) if (k && k.url && !st.material.links.some((x) => x.url === k.url)) st.material.links.push({ url: String(k.url), label: String(k.label || k.url) });
42
+ } else if (l.kind === 'file' && l.name) st.material.files.push({ name: String(l.name), type: String(l.type || ''), size: Number(l.size) || 0, path: l.path || null });
43
+ else if (l.kind === 'answer' && KEYS.has(l.q)) { if (String(l.answer || '').trim()) st.answers[l.q] = String(l.answer).trim(); else delete st.answers[l.q]; }
44
+ else if (l.kind === 'later') st.later = true;
45
+ }
46
+ return st;
47
+ }
48
+ /** The questions PMOS asks: the BRD parts the Why does not answer, numbered, each with its answer when there is one. Pure. */
49
+ function questionsOf(st) {
50
+ const ask = QUESTIONS.filter((x) => !(x.answeredBy && x.answeredBy(st.why)));
51
+ return ask.map((x, i) => ({ key: x.key, n: i + 1, of: ask.length, topic: x.topic, q: x.q, why: x.why, chips: x.chips.slice(), answer: st.answers[x.key] || '' }));
52
+ }
53
+ /** How many questions are still open, and what PMOS took from the Why and the material, in plain lines. Pure. */
54
+ function summaryOf(st) {
55
+ const qs = questionsOf(st), open = qs.filter((x) => !x.answer).length, L = st.material.links.length, F = st.material.files.length;
56
+ const took = [];
57
+ if (st.why.trim()) took.push('Your Why: ' + st.why.trim());
58
+ if (QUESTIONS[0].answeredBy(st.why)) took.push('It names the problem, so PMOS does not ask about it.');
59
+ if (L || F) took.push('Material: ' + [L ? L + ' ' + (L === 1 ? 'link' : 'links') : '', F ? F + ' ' + (F === 1 ? 'file' : 'files') : ''].filter(Boolean).join(' and ') + '. An agent reads it in Triage and drafts the BRD from it.');
60
+ return { open, total: qs.length, later: st.later, took };
61
+ }
62
+
63
+ module.exports = { QUESTIONS, fold, questionsOf, summaryOf };
@@ -186,13 +186,35 @@ function actsOf(r, boardNames) {
186
186
  const life = r.status === 'on hold' ? 'hold' : r.status === 'cancelled' ? 'cancelled' : null;
187
187
  return {
188
188
  stages: own, stage: r.stage || null, life, reason: life ? clip(st.reason || '', 300) : '', back: life === 'hold' && st.back ? shortDate(st.back) : '', backDay: life === 'hold' && st.back ? String(st.back).slice(0, 10) : null,
189
- archived: r.archived ? { reason: clip(r.archived.reason || '', 300), into: r.archived.into ? (r.archived.intoTitle || r.archived.into) : null } : null,
189
+ ...(life && st.at ? { since: shortDate(String(st.at).slice(0, 10)) } : {}),
190
+ archived: r.archived ? { reason: clip(r.archived.reason || '', 300), into: r.archived.into ? (r.archived.intoTitle || r.archived.into) : null, ...(r.archived.at ? { at: shortDate(String(r.archived.at).slice(0, 10)) } : {}) } : null,
190
191
  };
191
192
  }
192
- const askOf = (a) => {
193
+ /** The words an ask and an initiative title share (three letters or more, not common words), for "Close to: <initiative>". */
194
+ const STOP = new Set(['the', 'and', 'for', 'with', 'from', 'that', 'this', 'who', 'what', 'when', 'can', 'are', 'was', 'not', 'our', 'your', 'their', 'they', 'keep', 'asking', 'want', 'wants', 'need', 'needs', 'into', 'each', 'all', 'any', 'has', 'have', 'its']);
195
+ const sig = (s) => new Set(String(s || '').toLowerCase().split(/[^a-z0-9]+/).filter((w) => w.length >= 3 && !STOP.has(w)));
196
+ /** The open initiative an ask is closest to: it shares two words with its title, or half of a short title's words. Null when none does. */
197
+ function closeTo(line, rows) {
198
+ const want = sig(line);
199
+ let best = null;
200
+ for (const r of rows || []) {
201
+ const have = sig(r.title), shared = [...have].filter((w) => want.has(w)).length;
202
+ if (!have.size || !(shared >= 2 || (shared >= 1 && shared / have.size >= 0.5))) continue;
203
+ if (!best || shared > best.n) best = { n: shared, id: r.id, key: r.key, title: r.title, stage: (r.track && r.track.label) || r.stage || '' };
204
+ }
205
+ return best ? { id: best.id, key: best.key, title: best.title, stage: best.stage } : null;
206
+ }
207
+ /** One ask as the New asks card draws it (initiative premium-uncovered-features, BdAsks): who and where it came from, the draft, the product it is for
208
+ * and why, the products it could be for when the record names more than one, a prior rejection and the open initiative it is close to. */
209
+ const askOf = (a, board, rows) => {
193
210
  const d = a.draft || {};
211
+ const products = Array.isArray(a.products) ? a.products.filter((x) => x && (x.id || x.name)).slice(0, 4).map((x) => ({ id: String(x.id || x.name), name: String(x.name || x.id), why: clip(x.why || '', 160) })) : [];
194
212
  return { id: a.id, line: clip(a.line, 500), source: a.source || '', by: a.by || '', at: a.at ? shortDate(String(a.at).slice(0, 10)) : '',
195
- draft: { title: clip(d.title || a.line, 120), lane: LANES.includes(d.lane) ? d.lane : null, anchor: d.anchor_suggestion || '' } };
213
+ draft: { title: clip(d.title || a.line, 120), lane: LANES.includes(d.lane) ? d.lane : null, anchor: d.anchor_suggestion || '' },
214
+ product: products.length > 1 ? null : { name: (products[0] && products[0].name) || board.name || '', why: (products[0] && products[0].why) || (a.source ? 'came in through ' + clip(a.source, 80) + ' on this board' : 'came in on this board') },
215
+ products: products.length > 1 ? products : [],
216
+ prior: (Array.isArray(d.prior_rejections) ? d.prior_rejections : []).slice(0, 3).map((x) => ({ file: String(x.file || ''), title: clip(x.title || '', 120) })),
217
+ close: closeTo(a.line, rows) };
196
218
  };
197
219
 
198
220
  function rowOf(r, wf, today) {
@@ -341,9 +363,18 @@ function build(f) {
341
363
  // the Agreed design (premium-agreed-design): the eight steps with the board's own count in each, the Jira read time and the chip counts
342
364
  steps: STEPS.map((st, i) => ({ ...st, count: stages.filter((c) => stepIndex(c.stage, c.cat) === i).reduce((n, c) => n + c.count, 0) })),
343
365
  jira: { source: sp.source || 'none', readAt: sp.readAt || null, release: nr && nr.at ? { name: nr.name || nr.id, at: shortDate(String(nr.at).slice(0, 10)), iso: String(nr.at).slice(0, 10) } : null,
344
- sprint: active ? { name: active.name, start: active.start ? String(active.start).slice(0, 10) : null, end: active.end ? String(active.end).slice(0, 10) : null } : null },
366
+ sprint: active ? { name: active.name, start: active.start ? String(active.start).slice(0, 10) : null, end: active.end ? String(active.end).slice(0, 10) : null } : null,
367
+ // every sprint of the reading, oldest first, with its points where the reading holds them (initiative premium-uncovered-features, BdSprint)
368
+ sprints: sp.source === 'jira' ? sprints.slice().sort((a, b) => String(a.start || '').localeCompare(String(b.start || ''))).map((x) => {
369
+ const iss = x.issues || [], pts = iss.filter((i) => Number.isFinite(i.points)), k = x.counts || {};
370
+ return { name: x.name, state: x.state || '', start: x.start ? String(x.start).slice(0, 10) : null, end: x.end ? String(x.end).slice(0, 10) : null, now: x === active,
371
+ pts: pts.length ? { done: pts.filter((i) => tkStatus(i.status, i.category) === 'Done').reduce((n, i) => n + i.points, 0), total: pts.reduce((n, i) => n + i.points, 0) } : null,
372
+ counts: { done: k.done || 0, doing: k.doing || 0, todo: k.todo || 0 } };
373
+ }) : [],
374
+ // the open tickets that sit in no sprint: the backlog
375
+ backlog: [...tkBy.entries()].flatMap(([ini, list]) => list.filter((t) => !t.sprint && t.status !== 'Done').map((t) => ({ key: t.key, title: t.title, ini, iniTitle: ((rows.find((r) => r.id === ini) || {}).title) || '', points: t.points, status: t.status }))).slice(0, 60) },
345
376
  chips: { late, risk, blocked: rows.filter((r) => r.track && r.track.blocked).length, idle: rows.filter((r) => r.track && r.track.idle != null).length, asks: f.asks == null ? null : f.asks.filter((a) => a && a.state !== 'accepted' && a.state !== 'declined').length },
346
- asks: f.asks == null ? { missing: true, rows: [] } : { rows: f.asks.filter((a) => a && a.state !== 'accepted' && a.state !== 'declined').slice(0, 50).map(askOf) },
377
+ asks: f.asks == null ? { missing: true, rows: [] } : { rows: f.asks.filter((a) => a && a.state !== 'accepted' && a.state !== 'declined').slice(0, 50).map((a) => askOf(a, board, rows)) },
347
378
  dock: { needs: risk + late, label: 'need a look', release: nr && nr.at ? { at: shortDate(String(nr.at).slice(0, 10)), name: nr.name || nr.id } : null, next: (rows.find((r) => r.late) || rows.find((r) => r.bad) || {}).title || null },
348
379
  rows: rows.concat(stageRows.filter((r) => !rows.some((x) => x.key === r.key)), gone.cancelled, gone.archived, [sprintRow, relRow].filter(Boolean)).concat([{ key: 'board:this-board', id: null, title: board.name || 'This board', sub: 'Board', dialog: { eye: 'Board', logTitle: 'Read from the board', log: ['Read the board and its initiatives', 'Counted them by status', 'Changed nothing'], say: (board.name || 'This board') + ' has ' + open + ' open ' + plural(open, 'initiative', 'initiatives') + ': ' + on + ' on track, ' + risk + ' at risk, ' + late + ' late' + (hold ? ', ' + hold + ' on hold' : '') + '.', head: 'Where it stands', facts: [['Open initiatives', String(open)], ['On track', String(on)], ['At risk', String(risk)], ['Late', String(late)], ['On hold', hold ? String(hold) : '']].filter((x) => x[1] !== ''), hold: 'Nothing here changes a board.', pane: { label: 'Board record', file: '', note: 'The board as its records hold it.', rows: [['Open initiatives', String(open)], ['On track', String(on)], ['At risk', String(risk)], ['Late', String(late)], ['On hold', hold ? String(hold) : '']].filter((x) => x[1] !== '') } } }]),
349
380
  };
@@ -0,0 +1,77 @@
1
+ 'use strict';
2
+ /* lib/initiative-layout.js — the PM's own choices about one initiative's layout inside Home (initiative premium-uncovered-features, Initiative;
3
+ * canvas InStage, InTasks, InDocs, InPhone).
4
+ *
5
+ * fold(lines, initiative) → { auto, held, by, names, of, stage } PURE. The last line of each kind for the initiative wins.
6
+ * foldSets(lines) → [{ name, names }] PURE. The saved group sets, for every initiative of the workspace.
7
+ * eventOf(body) → { ok, event } | { ok: false, error } PURE. Checks one press and turns it into the line to append.
8
+ *
9
+ * What it holds:
10
+ * auto "Moves on by itself": true unless the PM turned it off (default on)
11
+ * held the stages the PM undid a move by itself out of: the page does not move out of them by itself again
12
+ * by how the Tasks card groups: 'stage' | 'mine' (the groups the PM names) | 'owner' | 'status' | 'none'
13
+ * names the PM's group names, in order
14
+ * of task key → the PM's group name
15
+ * stage task key → the stage the task belongs to (a task records none of its own)
16
+ * The stage move itself is not here: it is a move of POST /api/boards/move, with its note or reason as the move's why. */
17
+
18
+ const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,80}$/;
19
+ const TASK_RE = /^(task|req):[A-Za-z0-9][A-Za-z0-9._:#/-]{0,120}$/;
20
+ const BY = ['stage', 'mine', 'owner', 'status', 'none'];
21
+ const KINDS = ['auto', 'hold', 'by', 'groups', 'rename', 'place', 'stage', 'set', 'unset'];
22
+ const name = (v, n = 40) => String(v == null ? '' : v).replace(/[\u0000-\u001f]+/g, ' ').replace(/\s+/g, ' ').trim().slice(0, n);
23
+ const names = (v) => { const out = []; for (const x of Array.isArray(v) ? v : []) { const s = name(x); if (s && !out.some((y) => y.toLowerCase() === s.toLowerCase())) out.push(s); } return out.slice(0, 12); };
24
+
25
+ function empty() { return { auto: true, held: [], by: 'stage', names: [], of: {}, stage: {} }; }
26
+
27
+ function fold(lines, initiative) {
28
+ const o = empty();
29
+ for (const l of lines || []) {
30
+ if (!l || l.initiative !== initiative) continue;
31
+ if (l.kind === 'auto') { o.auto = l.on !== false; if (o.auto) o.held = []; }
32
+ else if (l.kind === 'hold' && l.stage && !o.held.includes(l.stage)) o.held.push(l.stage);
33
+ else if (l.kind === 'by' && BY.includes(l.by)) o.by = l.by;
34
+ else if (l.kind === 'groups') {
35
+ o.names = names(l.names);
36
+ for (const k of Object.keys(o.of)) if (!o.names.includes(o.of[k])) delete o.of[k]; // a deleted group lets its tasks go
37
+ } else if (l.kind === 'rename') {
38
+ const i = o.names.indexOf(l.from);
39
+ if (i >= 0 && l.to && !o.names.includes(l.to)) { o.names[i] = l.to; for (const k of Object.keys(o.of)) if (o.of[k] === l.from) o.of[k] = l.to; }
40
+ } else if (l.kind === 'place' && l.task) { if (l.group && o.names.includes(l.group)) o.of[l.task] = l.group; else delete o.of[l.task]; }
41
+ else if (l.kind === 'stage' && l.task) { if (l.stage) o.stage[l.task] = l.stage; else delete o.stage[l.task]; }
42
+ }
43
+ return o;
44
+ }
45
+
46
+ function foldSets(lines) {
47
+ const out = [];
48
+ for (const l of lines || []) {
49
+ if (!l || (l.kind !== 'set' && l.kind !== 'unset') || !l.name) continue;
50
+ const i = out.findIndex((s) => s.name.toLowerCase() === String(l.name).toLowerCase());
51
+ if (i >= 0) out.splice(i, 1);
52
+ if (l.kind === 'set') out.push({ name: l.name, names: names(l.names) });
53
+ }
54
+ return out.slice(-20);
55
+ }
56
+
57
+ function eventOf(b) {
58
+ const o = b || {};
59
+ if (!KINDS.includes(o.kind)) return { ok: false, error: 'kind is one of ' + KINDS.join(', ') };
60
+ if (o.kind !== 'set' && o.kind !== 'unset' && !ID_RE.test(String(o.initiative || ''))) return { ok: false, error: 'initiative must name an initiative' };
61
+ const base = { kind: o.kind };
62
+ if (o.kind !== 'set' && o.kind !== 'unset') base.initiative = o.initiative;
63
+ switch (o.kind) {
64
+ case 'auto': if (typeof o.on !== 'boolean') return { ok: false, error: 'on is true or false' }; return { ok: true, event: { ...base, on: o.on } };
65
+ case 'hold': { const s = name(o.stage); if (!s) return { ok: false, error: 'stage names the stage' }; return { ok: true, event: { ...base, stage: s } }; }
66
+ case 'by': if (!BY.includes(o.by)) return { ok: false, error: 'by is one of ' + BY.join(', ') }; return { ok: true, event: { ...base, by: o.by } };
67
+ case 'groups': if (!Array.isArray(o.names)) return { ok: false, error: 'names is a list of group names' }; return { ok: true, event: { ...base, names: names(o.names) } };
68
+ case 'rename': { const f = name(o.from), t = name(o.to); if (!f || !t) return { ok: false, error: 'from and to name the group' }; return { ok: true, event: { ...base, from: f, to: t } }; }
69
+ case 'place': if (!TASK_RE.test(String(o.task || ''))) return { ok: false, error: 'task names a task' }; return { ok: true, event: { ...base, task: o.task, group: name(o.group) } };
70
+ case 'stage': if (!TASK_RE.test(String(o.task || ''))) return { ok: false, error: 'task names a task' }; return { ok: true, event: { ...base, task: o.task, stage: name(o.stage) } };
71
+ case 'set': { const n = name(o.name, 80); const l = names(o.names); if (!n) return { ok: false, error: 'name the set' }; if (!l.length) return { ok: false, error: 'a set holds at least one group' }; return { ok: true, event: { ...base, name: n, names: l } }; }
72
+ case 'unset': { const n = name(o.name, 80); if (!n) return { ok: false, error: 'name the set' }; return { ok: true, event: { ...base, name: n } }; }
73
+ default: return { ok: false, error: 'unknown kind' };
74
+ }
75
+ }
76
+
77
+ module.exports = { fold, foldSets, eventOf, BY, KINDS };
@@ -193,6 +193,7 @@ function setupsOf(su, now) {
193
193
  id: s.id, name: clip(s.name, 120), purpose: clip(s.purpose, 240), audience: s.audience || '', source: s.source || '', output: s.output || '', label: s.label || '',
194
194
  next: s.next_draft ? shortDate(s.next_draft) : '', lastIssued: s.last_issued ? shortDate(s.last_issued) : '', status: s.status || '', cycles: fin(s.cycles) ? s.cycles : 0,
195
195
  paused: s.status === 'paused', fromWork: s.source === 'work', structured: !!(s.structure && s.structure.saved), drafting: !!(s.draft && s.draft.state === 'drafting'),
196
+ sections: s.structure && Array.isArray(s.structure.sections) ? s.structure.sections.map((x) => (typeof x === 'string' ? x : x && (x.title || x.heading || x.name))).filter((x) => typeof x === 'string' && x.trim()).map((x) => clip(x, 80)).slice(0, 8) : [], // premium-uncovered-features: IsLibrary "Sections"
196
197
  builtFrom: s.structure && Array.isArray(s.structure.charts) ? [...new Set(s.structure.charts.map((c) => (typeof c === 'string' ? c : c && (c.title || c.name || c.chart || c.id))).filter((x) => typeof x === 'string' && x).map((x) => clip(x, 40)))].slice(0, 4) : [], // premium-agreed-design: Library "Built from"
197
198
  }));
198
199
  const found = (su.findings || []).slice(0, 3).map((x) => ({
@@ -388,7 +389,7 @@ function build(facts) {
388
389
  const board = f.board || {};
389
390
  const model = {
390
391
  header: { text: (f.pending ? 'Reading the records · ' : '') + 'Real data' + (missing.length ? ' · not read: ' + missing.join(', ') : ''), missing },
391
- board: { ws: board.ws || null, id: board.id || null, name: board.name || 'Insights', switcher: (f.boards || []).map((b) => ({ ws: b.ws, id: b.id, name: b.name })) },
392
+ board: { ws: board.ws || null, id: board.id || null, name: board.name || 'Insights', switcher: (f.boards || []).map((b) => Object.assign({ ws: b.ws, id: b.id, name: b.name }, fin(b.goals) ? { goals: b.goals } : {})) },
392
393
  charts, mine, mineGone, mineSaved: mineAll, noSeries, dashboards, rows: charts,
393
394
  findings: findings.length ? findings : [{ kind: 'calm', key: null, text: charts.length ? (charts.some((c) => c.target !== null) ? 'Nothing stands out. No measure moved much, and none is far behind its line.' : 'Nothing stands out. No measure here has a target, so the series can only be described.') : '' }],
394
395
  calm: !findings.length && charts.length > 0,
@@ -409,7 +410,7 @@ function build(facts) {
409
410
  model.budgets = budgetsOf(f.initiatives || [], f.budgets || []);
410
411
  model.budgetsRead = Array.isArray(f.budgets);
411
412
  model.lateNow = Array.isArray(f.initiatives) ? f.initiatives.filter((r) => r && r.status === 'late').length : null;
412
- model.trends = Object.assign(IG.trendsOf(Array.isArray(f.initiatives) ? f.initiatives : null, model.today), { targets: ins.targets || {} });
413
+ model.trends = Object.assign(IG.trendsOf(Array.isArray(f.initiatives) ? f.initiatives : null, model.today), { targets: ins.targets || {}, tiles: ins.tiles || {} });
413
414
  model.chartSet = ins.charts[bid] || {}; // { [dashboard]: { [goal]: { form, range, compare, target, forecast, note } } }
414
415
  model.lifecycle = LIFE_LABEL.map((label, i) => ({ key: LIFE[i], label, milestone: i === 5 || i === 7 }));
415
416
  last = model;
@@ -7,12 +7,15 @@
7
7
  * checkChart(input) → { ok, value } | refusal one chart on one dashboard: { board, dash, goal, form, range, compare, target, forecast, note }
8
8
  * checkVerdict(input) → { ok, value } | refusal { board, ini, verdict: Keep | Iterate | Stop, learned, goal }
9
9
  * checkTarget(input) → { ok, value } | refusal a Delivery trends target of the page's own tiles: { key: late | scope, target: number | null }
10
- * fold(lines) → { charts: { [board]: { [dash]: { [goal]: chart } } }, verdicts: { [board]: { [ini]: verdict } }, targets: { [key]: number } } PURE
10
+ * checkTile(input) → { ok, value } | refusal how any Delivery trends target is read (premium-uncovered-features, IsTarget): { key: one of
11
+ * TILE_KEYS, dir: 'at least' | 'at most' | 'none', from: 'YYYY-MM-DD' | '', chip: bool }. The number stays where it was kept.
12
+ * fold(lines) → { charts: { [board]: { [dash]: { [goal]: chart } } }, verdicts: { [board]: { [ini]: verdict } }, targets: { [key]: number },
13
+ * tiles: { [key]: { dir, from, chip, at } } } PURE
11
14
  * read(root) → fold(readLines(ledgerFile(root)))
12
15
  * append(root, ev, value, actor, { now }) → { ok, line } THE SINGLE WRITER. `v`, `ev`, `actor` and `at` are set here.
13
16
  *
14
- * THE LINES. { v: 1, ev: 'chart' | 'verdict' | 'target', ...value, actor, at }. The last line of each key wins: a chart per board, dashboard and goal;
15
- * a verdict per board and initiative; a target per key. A torn line, or one without its key fields, is skipped.
17
+ * THE LINES. { v: 1, ev: 'chart' | 'verdict' | 'target' | 'tile', ...value, actor, at }. The last line of each key wins: a chart per board, dashboard and goal;
18
+ * a verdict per board and initiative; a target per key; a tile setting per key. A torn line, or one without its key fields, is skipped.
16
19
  * A verdict is recorded here only: it does not move the initiative on the Board and does not change its record. */
17
20
  const fs = require('fs');
18
21
  const path = require('path');
@@ -23,6 +26,8 @@ const RANGES = Object.freeze(['8w', 'Quarter', '26w']);
23
26
  const COMPARES = Object.freeze(['', 'lq']);
24
27
  const VERDICTS = Object.freeze(['Keep', 'Iterate', 'Stop']);
25
28
  const TARGET_KEYS = Object.freeze(['late', 'scope']);
29
+ const TILE_KEYS = Object.freeze(['blocked', 'late', 'idle', 'scope', 'merges', 'corrections']);
30
+ const TILE_DIRS = Object.freeze(['at least', 'at most', 'none']);
26
31
  const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$/;
27
32
  const NOTE_MAX = 160, LEARN_MAX = 600;
28
33
 
@@ -74,19 +79,28 @@ function checkTarget(input) {
74
79
  if (t !== null && !(Number.isFinite(t) && t >= 0)) return refuse(400, 'The target is a number of initiatives, 0 or more.');
75
80
  return { ok: true, value: { key: i.key, target: t } };
76
81
  }
82
+ function checkTile(input) {
83
+ const i = isObj(input) ? input : {};
84
+ if (!TILE_KEYS.includes(i.key)) return refuse(400, 'Name the tile: ' + TILE_KEYS.join(', ') + '.');
85
+ if (!TILE_DIRS.includes(i.dir)) return refuse(400, 'Pick At least, At most or No target.');
86
+ const from = typeof i.from === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(i.from) ? i.from : '';
87
+ if (i.from && !from) return refuse(400, 'The start is a date: YYYY-MM-DD.');
88
+ return { ok: true, value: { key: i.key, dir: i.dir, from, chip: i.chip === true } };
89
+ }
77
90
 
78
91
  function fold(lines) {
79
- const charts = {}, verdicts = {}, targets = {};
92
+ const charts = {}, verdicts = {}, targets = {}, tiles = {};
80
93
  for (const l of lines || []) {
81
94
  if (l.ev === 'chart') { const c = checkChart(l); if (!c.ok) continue; const v = c.value; ((charts[v.board] = charts[v.board] || {})[v.dash] = charts[v.board][v.dash] || {})[v.goal] = Object.assign({}, v, { at: l.at || null }); }
82
95
  else if (l.ev === 'verdict') { const c = checkVerdict(l); if (!c.ok) continue; const v = c.value; (verdicts[v.board] = verdicts[v.board] || {})[v.ini] = Object.assign({}, v, { at: l.at || null, by: l.actor && l.actor.by ? l.actor.by : null }); }
83
96
  else if (l.ev === 'target') { const c = checkTarget(l); if (!c.ok) continue; if (c.value.target === null) delete targets[c.value.key]; else targets[c.value.key] = c.value.target; }
97
+ else if (l.ev === 'tile') { const c = checkTile(l); if (!c.ok) continue; tiles[c.value.key] = { dir: c.value.dir, from: c.value.from, chip: c.value.chip, at: l.at ? String(l.at).slice(0, 10) : null }; }
84
98
  }
85
- return { charts, verdicts, targets };
99
+ return { charts, verdicts, targets, tiles };
86
100
  }
87
101
  const read = (root) => fold(readLines(ledgerFile(root)));
88
102
 
89
- const CHECKS = { chart: checkChart, verdict: checkVerdict, target: checkTarget };
103
+ const CHECKS = { chart: checkChart, verdict: checkVerdict, target: checkTarget, tile: checkTile };
90
104
  function append(root, ev, input, actor, { now } = {}) {
91
105
  if (!CHECKS[ev]) return refuse(400, 'unknown record: ' + ev);
92
106
  const c = CHECKS[ev](input);
@@ -98,4 +112,4 @@ function append(root, ev, input, actor, { now } = {}) {
98
112
  return { ok: true, line };
99
113
  }
100
114
 
101
- module.exports = { LEDGER, FORMS, RANGES, VERDICTS, TARGET_KEYS, ledgerFile, readLines, checkChart, checkVerdict, checkTarget, fold, read, append };
115
+ module.exports = { LEDGER, FORMS, RANGES, VERDICTS, TARGET_KEYS, TILE_KEYS, TILE_DIRS, ledgerFile, readLines, checkChart, checkVerdict, checkTarget, checkTile, fold, read, append };
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+ /* meeting-points.js — what the PM said about the key points of a meeting's Replay (initiative premium-uncovered-features, area meetings;
3
+ * MtReplay.dc.html: the bulk bar's Confirm and Not right). The Replay keeps the points that were agreed, owned or left open; the PM ticks
4
+ * some and confirms them, or marks them not right. A point marked not right leaves the kept list and goes to "Left out".
5
+ *
6
+ * pointsOf(dir, note) → { [pointId]: 'confirmed' | 'wrong' } a later line wins; verdict null forgets the point
7
+ * setPoints(dir, { note, ids, verdict }) → { ok, points } | { ok: false, status, error }
8
+ *
9
+ * A point's id is the id lib/meeting-replay.js gives it (d1, a2, q1). One line of <runtime>/meeting-points.jsonl per press, file mode,
10
+ * in the per-user runtime folder beside the notes. Nothing here sends anything. */
11
+ const fs = require('fs');
12
+ const path = require('path');
13
+
14
+ const FILE = 'meeting-points.jsonl';
15
+ const NOTE_ID = /^[A-Za-z0-9_-]{1,80}$/;
16
+ const POINT_ID = /^[A-Za-z0-9_-]{1,40}$/;
17
+ const VERDICTS = ['confirmed', 'wrong'];
18
+
19
+ function readLines(file) {
20
+ let text = '';
21
+ try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
22
+ const out = [];
23
+ for (const l of text.split('\n')) { if (!l.trim()) continue; try { const o = JSON.parse(l); if (o && typeof o === 'object') out.push(o); } catch { /* a torn line is skipped */ } }
24
+ return out;
25
+ }
26
+
27
+ /** The verdict on each point of one note. */
28
+ function pointsOf(dir, note) {
29
+ const out = {};
30
+ if (!dir || !NOTE_ID.test(String(note || ''))) return out;
31
+ for (const l of readLines(path.join(dir, FILE))) {
32
+ if (l.note !== note || !Array.isArray(l.ids)) continue;
33
+ for (const id of l.ids) { if (VERDICTS.includes(l.verdict)) out[id] = l.verdict; else delete out[id]; }
34
+ }
35
+ return out;
36
+ }
37
+
38
+ /** One press: the verdict on the points ticked. verdict null takes the verdict back (Undo). */
39
+ function setPoints(dir, body = {}) {
40
+ if (!dir) return { ok: false, status: 500, error: 'no runtime folder' };
41
+ const note = String(body.note || '');
42
+ if (!NOTE_ID.test(note)) return { ok: false, status: 400, error: 'note is the id of a meeting note' };
43
+ const ids = Array.isArray(body.ids) ? [...new Set(body.ids.map(String))] : [];
44
+ if (!ids.length || ids.length > 200 || !ids.every((x) => POINT_ID.test(x))) return { ok: false, status: 400, error: 'ids are the key points to mark, 1 to 200 of them' };
45
+ const verdict = body.verdict == null ? null : String(body.verdict);
46
+ if (verdict !== null && !VERDICTS.includes(verdict)) return { ok: false, status: 400, error: 'verdict is confirmed, wrong or null' };
47
+ fs.mkdirSync(dir, { recursive: true });
48
+ fs.appendFileSync(path.join(dir, FILE), JSON.stringify({ v: 1, note, ids, verdict, at: new Date().toISOString() }) + '\n');
49
+ return { ok: true, points: pointsOf(dir, note) };
50
+ }
51
+
52
+ module.exports = { pointsOf, setPoints, FILE };
@@ -0,0 +1,88 @@
1
+ 'use strict';
2
+ /* news-for-you.js — New for you, which replaces the Inbox (initiative premium-uncovered-features, E2; canvas EvInbox, HmAround).
3
+ *
4
+ * build({ inbox, mentions, work, seen }) → { count, groups: [{ key, label, items }] } PURE
5
+ * readSeen(runtimeDir) → Set of ids · appendSeen(runtimeDir, ids, now) · badSeen(body) → null | the reason
6
+ *
7
+ * New for you holds items for the PM's information only, in three groups (EvInbox):
8
+ * mentions someone named the PM (today's brief, GET /api/brief-page mentions): unread, and not already a next step (in_needs)
9
+ * given a task given to the PM: an open Work item that came from a source (Jira, the work breakdown), not one the PM typed
10
+ * finished what the agents finished while the PM was away: the new items of the agent inbox (GET /api/inbox items)
11
+ * An item leaves once it is seen: its id is in <runtime>/news-seen.jsonl. A mention that asks something, a passed review or a proposal is
12
+ * its initiative's next step, so it is never only here: the inbox item is the news that it finished, and the next step stays on Home.
13
+ * Every word comes from the record. Nothing here decides, replies or sends anything. */
14
+ const fs = require('fs');
15
+ const path = require('path');
16
+
17
+ const SEEN = 'news-seen.jsonl';
18
+ const ID_RE = /^(men|task|prop|goal|work):[^\s]{1,200}$/;
19
+ const clip = (s, n) => { s = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
20
+ const SRC = { slack: 'Slack', jira: 'Jira', confluence: 'Confluence', mail: 'Mail', wbs: 'Work breakdown', gmail: 'Gmail', figma: 'Figma' };
21
+ const srcName = (s) => SRC[s] || (s ? String(s)[0].toUpperCase() + String(s).slice(1) : '');
22
+ const FIN = { 'work-draft': 'Draft ready', 'work-stopped': 'Agent stopped', proposal: 'Proposal ready', draft: 'Draft ready', 'goal-waiting': 'Goal needs you', 'goal-done': 'Goal finished', 'goal-stopped': 'Goal stopped' };
23
+ const at = (x) => { const t = Date.parse(x || ''); return Number.isFinite(t) ? t : null; };
24
+
25
+ function mentionItems(list, seen) {
26
+ return (Array.isArray(list) ? list : []).filter((m) => m && m.id && !m.read && !m.in_needs && !seen.has('men:' + m.id)).map((m) => ({
27
+ id: 'men:' + m.id, kind: 'mention', mid: m.id, who: clip(m.who || srcName(m.source) || 'Someone', 80), source: m.source || '', where: clip(m.where || '', 80),
28
+ title: clip((m.who || srcName(m.source) || 'Someone') + ' mentioned you' + (m.where ? ' in ' + m.where : ''), 160), text: clip(m.text, 280),
29
+ at: at(m.at), link: m.link || null, initiative: m.initiative || null, asks: !!m.reply,
30
+ }));
31
+ }
32
+ /** The open Work items that came from a source, from GET /api/pm-items' answer (its five lists). */
33
+ function givenItems(v, seen) {
34
+ const w = (v && v.work) || {}, out = [], had = new Set();
35
+ for (const k of ['inbox', 'today', 'upcoming', 'waiting', 'someday']) for (const it of w[k] || []) {
36
+ if (!it || !it.id || it.done || had.has(it.id)) continue;
37
+ const src = it.origin || it.source || 'local';
38
+ if (!(it.assigned === true || (src !== 'local' && src !== 'brief' && src !== 'work'))) continue;
39
+ had.add(it.id);
40
+ if (seen.has('task:' + it.id)) continue;
41
+ out.push({ id: 'task:' + it.id, kind: 'task', tid: it.id, title: clip('New task: ' + (it.title || it.key || it.id), 160), from: srcName(src), key: it.key || '',
42
+ due: it.due || null, initiative: it.initiative || null, link: it.url || it.link || null, at: at(it.created_at) });
43
+ }
44
+ return out;
45
+ }
46
+ function finishedItems(inbox, seen) {
47
+ const items = inbox && inbox.ok !== false && Array.isArray(inbox.items) ? inbox.items : [];
48
+ return items.filter((x) => x && x.id && !seen.has(x.id)).map((x) => ({
49
+ id: x.id, kind: 'finished', what: FIN[x.kind] || 'Finished', title: clip(x.title, 160), product: x.product || '', target: x.target && x.target.title ? x.target.title : '',
50
+ at: Number.isFinite(x.at) ? x.at : null, open: x.open || '', pws: x.pws || '', session: x.session || '', agentKind: x.kind || '',
51
+ }));
52
+ }
53
+
54
+ /** The groups, newest first in each; an empty group is left out. inbox: GET /api/inbox; mentions: the brief page's list (null: no brief today). */
55
+ function build({ inbox = null, mentions = null, work = null, seen = new Set() } = {}) {
56
+ const by = (a, b) => (b.at || 0) - (a.at || 0);
57
+ const groups = [
58
+ { key: 'mentions', label: 'Mentions', items: mentionItems(mentions, seen).sort(by) },
59
+ { key: 'given', label: 'Given to you', items: givenItems(work, seen).sort(by) },
60
+ { key: 'finished', label: 'Finished while you were away', items: finishedItems(inbox, seen).sort(by) },
61
+ ].filter((g) => g.items.length);
62
+ return { count: groups.reduce((n, g) => n + g.items.length, 0), groups, read: { mentions: mentions !== null, inbox: !!(inbox && inbox.ok !== false), work: !!(work && work.ok !== false) } };
63
+ }
64
+
65
+ function readSeen(runtimeDir) {
66
+ const ids = new Set();
67
+ let t; try { t = fs.readFileSync(path.join(runtimeDir, SEEN), 'utf8'); } catch { return ids; }
68
+ for (const l of t.split('\n')) {
69
+ if (!l.trim()) continue;
70
+ let e; try { e = JSON.parse(l); } catch { continue; }
71
+ if (e && Array.isArray(e.ids)) for (const id of e.ids) if (typeof id === 'string') ids.add(id);
72
+ }
73
+ return ids;
74
+ }
75
+ /** The check of a seen body: 1 to 300 item ids. null when it is good, else the reason. Pure. */
76
+ function badSeen(b) {
77
+ if (!b || typeof b !== 'object') return 'a body is required';
78
+ if (!Array.isArray(b.ids) || !b.ids.length || b.ids.length > 300 || !b.ids.every((x) => typeof x === 'string' && ID_RE.test(x))) return 'ids must be 1 to 300 item ids';
79
+ return null;
80
+ }
81
+ function appendSeen(runtimeDir, ids, now = new Date()) {
82
+ fs.mkdirSync(runtimeDir, { recursive: true });
83
+ fs.appendFileSync(path.join(runtimeDir, SEEN), JSON.stringify({ ids, at: now.toISOString() }) + '\n');
84
+ }
85
+ /** The ids the agent inbox knows (its own seen file takes them too, so the inbox's count agrees with New for you). */
86
+ const inboxIds = (ids) => ids.filter((x) => /^(prop|goal|work):/.test(x));
87
+
88
+ module.exports = { SEEN, build, readSeen, badSeen, appendSeen, inboxIds, srcName };
@@ -331,14 +331,16 @@ function openCounts(dir, rows) {
331
331
  * notes, typed notes, summary and transcript. */
332
332
  function search(dir, q) {
333
333
  const ws = norm(q).split(' ').filter(Boolean);
334
- if (!ws.length || norm(q).length < 2) return { ok: true, ids: [] };
334
+ if (!ws.length || norm(q).length < 2) return { ok: true, ids: [], hits: [] };
335
335
  let names = [];
336
- try { names = fs.readdirSync(notes.notesDir(dir)).filter((f) => f.endsWith('.json')); } catch { return { ok: true, ids: [] }; }
337
- const ids = [];
336
+ try { names = fs.readdirSync(notes.notesDir(dir)).filter((f) => f.endsWith('.json')); } catch { return { ok: true, ids: [], hits: [] }; }
337
+ const ids = [], hits = [];
338
338
  for (const f of names) {
339
339
  const n = notes.loadCached(dir, f.slice(0, -5));
340
340
  if (!n || !n.id) continue;
341
341
  let hay = n.title || '';
342
+ /* where the words were said, for the snippet (premium-uncovered-features, MtNotes): an open next step or question first, then what was said */
343
+ const parts = [];
342
344
  if (!n.private) {
343
345
  const fin = n.final_notes || {};
344
346
  const items = (xs) => (Array.isArray(xs) ? xs.map((x) => (x && x.text) || '').join(' ') : '');
@@ -346,12 +348,33 @@ function search(dir, q) {
346
348
  hay += ' ' + [n.overview_pm, fin.overview, fin.purpose, fin.discussion, items(fin.decisions), items(fin.actions), items(fin.questions), n.body,
347
349
  items(sec.overview), items(sec.decisions), items(sec.actions), items(sec.questions), items(n.bullets), items(n.transcript),
348
350
  n.meeting && n.meeting.title].filter(Boolean).join(' ');
351
+ const each = (xs, open) => { for (const x of Array.isArray(xs) ? xs : []) if (x && x.text) parts.push({ text: String(x.text), open }); };
352
+ each(fin.actions, true); each(fin.questions, true); each(sec.actions, true); each(sec.questions, true);
353
+ each(n.transcript, false); each(fin.decisions, false); each(n.bullets, false);
354
+ for (const t of [fin.overview, n.overview_pm, n.body]) if (t) parts.push({ text: String(t), open: false });
349
355
  }
350
356
  const h = ' ' + norm(hay) + ' ';
351
- if (ws.every((w) => h.includes(w))) ids.push(n.id);
357
+ if (!ws.every((w) => h.includes(w))) continue;
358
+ ids.push(n.id);
359
+ hits.push({ id: n.id, ...snipOf(parts, ws) });
352
360
  }
353
- return { ok: true, ids };
361
+ return { ok: true, ids, hits };
362
+ }
363
+ /** The first passage that holds a searched word, about 80 characters around it: { snip, open } (open: it is an open next step or question). */
364
+ function snipOf(parts, ws) {
365
+ for (const p of parts) {
366
+ const low = p.text.toLowerCase();
367
+ let at = -1;
368
+ for (const w of ws) { const i = low.indexOf(w); if (i >= 0 && (at < 0 || i < at)) at = i; }
369
+ if (at < 0) continue;
370
+ let from = Math.max(0, at - 30), to = Math.min(p.text.length, at + 60);
371
+ if (from) { const sp = p.text.indexOf(' ', from); if (sp >= 0 && sp < at) from = sp + 1; } // whole words only
372
+ if (to < p.text.length) { const sp = p.text.lastIndexOf(' ', to); if (sp > at) to = sp; }
373
+ const snip = (from ? '…' : '') + p.text.slice(from, to).replace(/\s+/g, ' ').trim() + (to < p.text.length ? '…' : '');
374
+ return { snip, open: p.open };
375
+ }
376
+ return { snip: '', open: false };
354
377
  }
355
378
 
356
- module.exports = { assign, openCounts, thread, placeOf, search, markDone, bring, unbring, partsOf, topicsOf, carriedOf, nextOf, norm, storeFile,
379
+ module.exports = { assign, openCounts, thread, placeOf, search, snipOf, markDone, bring, unbring, partsOf, topicsOf, carriedOf, nextOf, norm, storeFile,
357
380
  OPEN_WINDOW, TOPIC_WINDOW, TOPIC_MIN, CARRY_WARN };