create-pmos 0.396.0 → 0.398.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 (177) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/scripts/nine-stages.js +49 -20
  6. package/payload/state/discoveries.md +1 -1
  7. package/payload/state/log.md +1 -1
  8. package/workspace/briefing-premium-adddoc-test.js +103 -74
  9. package/workspace/briefing-premium-board-test.js +316 -154
  10. package/workspace/briefing-premium-calendar-2-test.js +135 -195
  11. package/workspace/briefing-premium-calendar-3-test.js +143 -413
  12. package/workspace/briefing-premium-calendar-test.js +86 -185
  13. package/workspace/briefing-premium-doc-edit-test.js +95 -83
  14. package/workspace/briefing-premium-initiative-test.js +166 -294
  15. package/workspace/briefing-premium-insights-test.js +351 -214
  16. package/workspace/briefing-premium-metrics-test.js +53 -118
  17. package/workspace/briefing-premium-products-test.js +40 -27
  18. package/workspace/briefing-premium-sources-test.js +91 -52
  19. package/workspace/briefing-premium-test.js +150 -633
  20. package/workspace/briefing-premium-work-test.js +88 -269
  21. package/workspace/changelog.json +24 -0
  22. package/workspace/fixtures/board-premium-facts.js +2 -1
  23. package/workspace/fixtures/board-premium-jira.js +28 -0
  24. package/workspace/fixtures/board-premium-trail.js +32 -0
  25. package/workspace/fixtures/initiative-premium-facts.js +2 -1
  26. package/workspace/fixtures/initiatives-api/list.json +30 -42
  27. package/workspace/fixtures/initiatives-api/roadmap.json +40 -56
  28. package/workspace/fixtures/initiatives-api/sheet.json +10 -14
  29. package/workspace/fixtures/insights-premium-facts.js +11 -2
  30. package/workspace/fixtures/premium-viewer-fixtures.js +182 -0
  31. package/workspace/guide/briefing-premium.md +3 -1
  32. package/workspace/guide/home.md +47 -0
  33. package/workspace/guide/index.md +2 -0
  34. package/workspace/guide/lifecycle.md +51 -0
  35. package/workspace/home-shot.js +38 -0
  36. package/workspace/lib/agent-roles.js +71 -0
  37. package/workspace/lib/board-premium.js +160 -3
  38. package/workspace/lib/board-trail.js +223 -0
  39. package/workspace/lib/engine/boards.js +15 -14
  40. package/workspace/lib/engine/nine-stages.js +49 -20
  41. package/workspace/lib/engine/signals/detectors.js +13 -11
  42. package/workspace/lib/home-work-item.js +58 -0
  43. package/workspace/lib/insights-goals.js +196 -0
  44. package/workspace/lib/insights-premium.js +126 -1
  45. package/workspace/lib/insights-records.js +101 -0
  46. package/workspace/lib/jira-tickets.js +1 -1
  47. package/workspace/lib/route-modules.js +4 -0
  48. package/workspace/lib/routes-board-premium.js +3 -2
  49. package/workspace/lib/routes-board-trail.js +33 -0
  50. package/workspace/lib/routes-home-desk.js +176 -0
  51. package/workspace/lib/routes-initiatives.js +1 -1
  52. package/workspace/lib/routes-insights-premium.js +19 -3
  53. package/workspace/lib/routes-insights-records.js +129 -0
  54. package/workspace/lib/routes-notes.js +1 -0
  55. package/workspace/lib/routes-viewer.js +108 -0
  56. package/workspace/lib/transcript-steps.js +123 -0
  57. package/workspace/lib/vendor/scripts/nine-stages.js +49 -20
  58. package/workspace/lib/viewer-meeting.js +205 -0
  59. package/workspace/lib/viewer-report.js +89 -0
  60. package/workspace/package-lock.json +2 -2
  61. package/workspace/package.json +1 -1
  62. package/workspace/premium-agreed-viewer-shots.js +76 -0
  63. package/workspace/premium-board-actions-test.js +85 -73
  64. package/workspace/premium-briefing-depth-test.js +66 -53
  65. package/workspace/premium-chat-attach-test.js +54 -63
  66. package/workspace/premium-chat-chart-tab-test.js +35 -36
  67. package/workspace/premium-chat-context-test.js +22 -19
  68. package/workspace/premium-chat-goal-view-test.js +28 -26
  69. package/workspace/premium-chat-notes-test.js +29 -33
  70. package/workspace/premium-chat-report-tab-test.js +35 -25
  71. package/workspace/premium-chat-term-test.js +16 -14
  72. package/workspace/premium-chat-viewer-test.js +60 -53
  73. package/workspace/premium-core-doc-issue-test.js +50 -41
  74. package/workspace/premium-html-viewer-test.js +17 -18
  75. package/workspace/premium-phone-card-test.js +8 -2
  76. package/workspace/premium-phone-room-test.js +42 -31
  77. package/workspace/premium-report-read-test.js +115 -197
  78. package/workspace/premium-viewer-download-test.js +19 -22
  79. package/workspace/premium-viewer-flicker-test.js +11 -16
  80. package/workspace/premium-viewer-share-test.js +6 -9
  81. package/workspace/premium-viewer-test.js +41 -60
  82. package/workspace/premium-vw-backlog-test.js +53 -31
  83. package/workspace/premium-vw-cal-test.js +82 -123
  84. package/workspace/premium-vw-copy-test.js +17 -33
  85. package/workspace/premium-vw-doc-test.js +12 -11
  86. package/workspace/premium-vw-item-test.js +50 -48
  87. package/workspace/premium-vw-jira-test.js +55 -26
  88. package/workspace/premium-vw-meet-test.js +118 -187
  89. package/workspace/premium-vw-notes-test.js +85 -107
  90. package/workspace/premium-vw-rec-test.js +72 -193
  91. package/workspace/premium-vw-slides-test.js +46 -50
  92. package/workspace/premium-welcome-test.js +3 -2
  93. package/workspace/premium-work-depth-test.js +63 -51
  94. package/workspace/public/pm/bd-acts.js +305 -0
  95. package/workspace/public/pm/bd-span.js +224 -0
  96. package/workspace/public/pm/bd-stages.js +47 -0
  97. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  98. package/workspace/public/pm/c3-md.js +3 -395
  99. package/workspace/public/pm/c3-phone-detail.js +1 -1
  100. package/workspace/public/pm/c3-phone-model.js +3 -68
  101. package/workspace/public/pm/chat-term.js +3 -3
  102. package/workspace/public/pm/cozy-board.css +640 -0
  103. package/workspace/public/pm/cozy-home.css +580 -0
  104. package/workspace/public/pm/cozy-home.js +172 -0
  105. package/workspace/public/pm/cozy-initiative.css +138 -0
  106. package/workspace/public/pm/cozy-insights.css +421 -0
  107. package/workspace/public/pm/cozy-md.js +396 -0
  108. package/workspace/public/pm/cozy-nav.js +65 -0
  109. package/workspace/public/pm/cozy-placeholder.js +26 -0
  110. package/workspace/public/pm/cozy-viewer.css +143 -0
  111. package/workspace/public/pm/cozy-viewer.js +144 -0
  112. package/workspace/public/pm/cozy-vw.css +485 -0
  113. package/workspace/public/pm/cozy.css +254 -0
  114. package/workspace/public/pm/home-adddoc.js +48 -0
  115. package/workspace/public/pm/home-app.js +905 -0
  116. package/workspace/public/pm/home-around.js +515 -0
  117. package/workspace/public/pm/home-chat.js +459 -0
  118. package/workspace/public/pm/home-data.js +312 -0
  119. package/workspace/public/pm/home-draft.js +68 -0
  120. package/workspace/public/pm/home-more.js +249 -0
  121. package/workspace/public/pm/home-phone-card.js +109 -0
  122. package/workspace/public/pm/home-work.js +519 -0
  123. package/workspace/public/pm/lifecycle-lens-model.js +45 -27
  124. package/workspace/public/pm/lifecycle-lens.js +22 -11
  125. package/workspace/public/pm/phone-moment.js +69 -0
  126. package/workspace/public/pm/pm-work-view.js +1 -1
  127. package/workspace/public/pm/premium-attach.js +4 -0
  128. package/workspace/public/pm/premium-board.js +544 -253
  129. package/workspace/public/pm/premium-brief.js +1 -1
  130. package/workspace/public/pm/premium-chart-tab.js +110 -62
  131. package/workspace/public/pm/premium-chat.js +17 -10
  132. package/workspace/public/pm/premium-deck.js +3 -3
  133. package/workspace/public/pm/premium-first.js +25 -21
  134. package/workspace/public/pm/premium-initiative-head.js +138 -0
  135. package/workspace/public/pm/premium-initiative.js +28 -4
  136. package/workspace/public/pm/premium-insights.js +950 -440
  137. package/workspace/public/pm/premium-meeting.js +61 -549
  138. package/workspace/public/pm/premium-notes.js +1 -1
  139. package/workspace/public/pm/premium-report-frame.css +20 -0
  140. package/workspace/public/pm/premium-report-read.js +509 -480
  141. package/workspace/public/pm/premium-report-tab.js +87 -63
  142. package/workspace/public/pm/premium-shell.js +107 -124
  143. package/workspace/public/pm/premium-viewer.js +27 -1
  144. package/workspace/public/pm/premium-vw-cal.js +187 -48
  145. package/workspace/public/pm/premium-vw-doc.css +6 -0
  146. package/workspace/public/pm/premium-vw-doc.js +40 -2
  147. package/workspace/public/pm/premium-vw-file.js +2 -2
  148. package/workspace/public/pm/premium-vw-jira-model.js +22 -5
  149. package/workspace/public/pm/premium-vw-jira.css +11 -0
  150. package/workspace/public/pm/premium-vw-jira.js +11 -4
  151. package/workspace/public/pm/premium-vw-meet.js +6 -83
  152. package/workspace/public/pm/premium-vw-mtg.js +731 -0
  153. package/workspace/public/pm/premium-vw-notes.js +56 -69
  154. package/workspace/public/pm/premium-vw-open.js +35 -0
  155. package/workspace/public/pm/premium-vw-page.js +16 -0
  156. package/workspace/public/pm/premium-vw-rec.js +11 -215
  157. package/workspace/public/pm/premium-vw-slides.css +5 -0
  158. package/workspace/public/pm/premium-vw-slides.js +44 -8
  159. package/workspace/public/pm/term-view.js +22 -0
  160. package/workspace/public/premium-board.html +57 -64
  161. package/workspace/public/premium-chat.html +7 -33
  162. package/workspace/public/premium-initiative.html +8 -41
  163. package/workspace/public/premium-insights.html +63 -62
  164. package/workspace/public/premium-viewer.html +20 -0
  165. package/workspace/public/premium-work.html +6 -72
  166. package/workspace/public/premium.html +21 -66
  167. package/workspace/public/vendor/nunito-var.woff2 +0 -0
  168. package/workspace/server.js +25 -3
  169. package/workspace/test-files.json +1 -0
  170. package/workspace/test-lists/home-libs.json +9 -0
  171. package/workspace/test-lists/premium-agreed-viewer.json +9 -0
  172. package/workspace/test-lists/premium-report-read.json +1 -1
  173. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  174. package/workspace/test-lists/premium-vw-notes.json +1 -1
  175. package/workspace/third-party/README.md +1 -0
  176. package/workspace/public/pm/premium-work.js +0 -719
  177. package/workspace/public/pm/premium.js +0 -1133
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
- /* briefing-premium-doc-edit-test.js — the premium sheet's Edit and Proposals tabs (initiative briefing-premium-doc-edit; planning/prd/briefing-premium-doc-edit-prd.md E1 to E8).
3
+ /* briefing-premium-doc-edit-test.js — editing a document and its proposals (initiative briefing-premium-doc-edit; planning/prd/briefing-premium-doc-edit-prd.md E1 to E8),
4
+ * re-pointed to the Agreed design (initiative premium-agreed-design): the document opens as a page in the Home Viewer (pm/premium-vw-doc.js) from the
5
+ * initiative's Files row. Edit is the page's Markdown mode and save row; the Edit log and the Proposals list are a plain section under the page marked
6
+ * "Waiting for design" until the design draws them. The page-level Keep and Undo all are in premium-vw-doc-test.js.
4
7
  * Serves the real page from the real server. The initiative model and the /api/doc-sheet routes are answered by a small stateful stand-in, so each press can be
5
8
  * read off the request the page sent. The routes' own behaviour (the file, the log, stale, 403) is in briefing-premium-doc-edit.test.js, on a scratch repository.
6
9
  * E1 tabs · E2 edit · E3 ask · E4 proposals · E5 after a write · E6 held · E7 honesty · E8 fidelity and floors */
@@ -28,11 +31,10 @@ const finish = async (code) => {
28
31
  };
29
32
  process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
30
33
 
31
- const MOCKUP = require('./lib/premium-console-type').transform(fs.readFileSync(path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'briefing-artifact.html'), 'utf8'), { faces: false }); // read with the console's type (PM, 2026-10-19), as premium.css is
32
- const CSS = fs.readFileSync(path.join(__dirname, 'public', 'pm', 'premium.css'), 'utf8');
33
34
  const PATH = 'planning/prd/self-serve-v2-prd.md';
34
35
  const TEXT = '---\ntype: PRD\ntitle: "Self-serve onboarding v2"\n---\n\n# PRD: Self-serve onboarding v2\n\n## Problem\n\nA partner waits for a person.\n\n## Goal\n\n- a first call without help\n\n## Requirements\n\nR1 a first call\n';
35
- const prop = (o) => Object.assign({ id: 'prop-a', state: 'proposed', prompt: 'add a one-paragraph summary', at: '2026-10-18T01:00:00Z', hash: 'ha', by: 'agent', why: null, sections: [
36
+ const AFTER = TEXT.replace('## Goal', '## Summary\n\nPartners reach a first call without help.\n\n## Goal');
37
+ const prop = (o) => Object.assign({ id: 'prop-a', state: 'proposed', prompt: 'add a one-paragraph summary', at: '2026-10-18T01:00:00Z', hash: 'ha', by: 'agent', why: null, after: AFTER, sections: [
36
38
  { name: 'Summary', kind: 'added', before: '', after: 'Partners reach a first call without help.', current: null, stale: false },
37
39
  { name: 'Goal', kind: 'changed', before: 'x', after: 'y', current: 'z', stale: true }] }, o || {});
38
40
 
@@ -71,105 +73,115 @@ const prop = (o) => Object.assign({ id: 'prop-a', state: 'proposed', prompt: 'ad
71
73
  if (route === 'ask') { S.ask = { ok: true, id: 'ask-1', state: 'working' }; return send({ ok: true, id: 'ask-1', state: 'working' }); }
72
74
  return send({ ok: false, error: 'not in this test' }, 404);
73
75
  });
74
- await page.goto(BASE + '/premium-initiative.html?id=self-serve-v2&ws=w1&board=w1&theme=' + theme);
75
- await until(() => page.evaluate(() => document.querySelector('#cIniDoc')));
76
- await page.locator('#dmList .dmo[data-doc="prd"]').click();
77
- await until(() => page.evaluate(() => document.querySelector('#oMain .dsbody')));
76
+ await page.route('**/api/docs/library*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, kinds: [], files: [{ path: PATH, title: 'Self-serve PRD' }], edges: [] }) }));
77
+ await page.route('**/api/docs?*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, docs: [{ path: PATH, links: [] }] }) }));
78
+ await page.goto(BASE + '/premium.html?ini=self-serve-v2&ws=w1&theme=' + theme);
79
+ await until(() => page.evaluate(() => !!document.querySelector('.hm-r[data-id="f:planning/prd/self-serve-v2-prd.md"]')), 15000);
80
+ if (w < 761) await page.click('#hmNeeds'); // a phone: the list is the top bar's sheet
81
+ await page.click('.hm-r[data-id="f:planning/prd/self-serve-v2-prd.md"] .hm-rm'); // the initiative's Files group: the PRD opens as a page
82
+ await until(() => page.evaluate(() => document.querySelector('.vwdoc .cf') && document.querySelector('.vwdoc .vwside')));
78
83
  return { ctx, page, S };
79
84
  };
80
- const txt = (p, q) => p.evaluate((s) => (document.querySelector(s) || {}).textContent || '', q);
81
- const tab = async (p, k) => { if (!(await p.$('#shT [data-sh]'))) await p.click('#shV'); await p.click(`#shT [data-sh="${k}"]`); await sleep(150); };
85
+ const V = '.obody.vw:not([hidden]) .vwdoc';
86
+ const txt = (p, q) => p.evaluate((s) => ((document.querySelector(s) || {}).textContent || '').replace(/\s+/g, ' '), q);
87
+ const side = async (p, k) => { if ((await p.getAttribute(`${V} [data-vd="side:${k}"]`, 'aria-expanded')) !== 'true') await p.click(`${V} [data-vd="side:${k}"]`); await sleep(150); };
82
88
 
83
89
  const A = await open(); const p = A.page;
84
- ok('0 the sheet opens', !!(await p.evaluate(() => document.querySelector('#shT'))));
85
- /* E1 tabs */
86
- await p.click('#shV'); ok('E1 the sheet has a view menu with Read, Edit, Proposals, Edit log, Health and Relations, and the open count on Proposals', await p.evaluate(() => [...document.querySelectorAll('#shT [data-sh]')].map((b) => b.textContent.replace(/\s+/g, ' ').trim()).join('|') === 'Read|Edit|Proposals 1|Edit log|Health|Relations'));
87
- ok('E1 the Read outline marks only a heading an open proposal names', await p.evaluate(() => { const b = [...document.querySelectorAll('.dso button')]; return b.length === 0 || b.every((x) => !x.querySelector('i') === !/Goal|Summary/.test(x.textContent)); }));
88
- ok('E7 the footnote no longer says read-only', !/Read-only/.test(await txt(p, '#oMain .xn')) && /only when you press Save or Accept/.test(await txt(p, '#oMain .xn')));
90
+ ok('0 the document opens as a page in the Viewer', !!(await p.evaluate(() => document.querySelector('#czViewer:not([hidden]) .obody.vw[data-vw="doc:planning/prd/self-serve-v2-prd.md"]'))));
91
+ /* E1 the page's modes and the section under it */
92
+ ok('E1 the page offers Page, Edit and Markdown', await p.evaluate((v) => [...document.querySelectorAll(v + ' .vwseg')].map((b) => b.textContent.trim()).join('|') === 'Page|Edit|Markdown', V));
93
+ ok('E1 under the page are Edit log and Proposals with the open count, marked Waiting for design', await p.evaluate((v) => { const s = document.querySelector(v + ' .vwside'); return !!s && /Waiting for design/.test(s.querySelector('.hx-wait').textContent) && [...s.querySelectorAll('[data-vd^="side:"]')].map((b) => b.textContent.replace(/\s+/g, ' ').trim()).join('|') === 'Edit log|Proposals 1'; }, V));
94
+ ok('E7 the page never says it is read-only', !/Read-only/i.test(await txt(p, V)));
89
95
 
90
- /* E2 edit */
91
- await tab(p, 'edit');
92
- ok('E2 the Edit tab holds the file as text, Save is off, and the note says no changes', await p.evaluate((t) => document.querySelector('#dsEd').value === t && document.querySelector('#dsSave').disabled && /No changes yet/.test(document.querySelector('#dsNote').textContent), TEXT));
93
- await p.fill('#dsEd', TEXT + '\nMore.\n');
94
- ok('E2 a change turns Save on and the note says changed', await p.evaluate(() => !document.querySelector('#dsSave').disabled && /Changed/.test(document.querySelector('#dsNote').textContent)));
95
- await p.click('#dsSave');
96
- ok('E2 Save with no reason posts nothing and says why', await p.evaluate(() => /Say why the document changes/.test(document.querySelector('#dsErr').textContent)) && A.S.posts.length === 0);
97
- ok('E2 the text typed is still there after the refusal', (await p.inputValue('#dsEd')) === TEXT + '\nMore.\n');
98
- await tab(p, 'read'); await tab(p, 'edit');
99
- ok('E2 the draft survives a tab switch', (await p.inputValue('#dsEd')) === TEXT + '\nMore.\n');
100
- await p.fill('#dsWhy', 'add the missing line'); await p.click('#dsSave');
101
- await until(() => A.S.posts.length);
102
- const e1 = A.S.posts[0];
103
- ok('E2 Save posts path, text and why to /api/doc-sheet/edit with the launch headers and the workspace', e1 && e1.route === 'edit' && Object.keys(e1.body).sort().join() === 'path,text,why' && e1.body.path === PATH && e1.body.why === 'add the missing line' && e1.body.text.endsWith('More.\n') && /ws=w1/.test(e1.query) && e1.headers.origin === BASE, JSON.stringify(e1 && { r: e1.route, q: e1.query }));
104
- /* E5 after a write */
105
- await until(() => p.evaluate(() => /No changes yet/.test((document.querySelector('#dsNote') || {}).textContent || '')));
106
- ok('E5 after Save the text is read again from the route and the note says no changes', (await p.inputValue('#dsEd')).endsWith('More.\n') && await p.evaluate(() => document.querySelector('#dsSave').disabled));
107
- await tab(p, 'log');
108
- ok('E5 the Edit log shows the new revision with its reason', await until(() => p.evaluate(() => /v2 add the missing line/.test((document.querySelector('#oMain .evl') || {}).textContent || ''))));
109
-
110
- /* E3 + E4 proposals */
111
- await tab(p, 'props');
112
- const pv = await until(() => p.evaluate(() => document.querySelector('.dsp') && { n: document.querySelectorAll('.dsp').length, t: document.querySelector('.dsp').textContent.replace(/\s+/g, ' '), acc: !!document.querySelector('[data-ds^="acc:"]'), rej: !!document.querySelector('[data-ds^="rej:"]'), stale: /Changed since this was proposed/.test(document.querySelector('.dsp').textContent), head: document.querySelector('#oMain .label:nth-of-type(2)') ? '' : '' }));
113
- ok('E4 an open proposal names who, the request, the added text, and a stale section says so', pv && /The agent/.test(pv.t) && /add a one-paragraph summary/.test(pv.t) && /\+ Partners reach a first call/.test(pv.t) && pv.stale && pv.acc && pv.rej, JSON.stringify(pv));
114
- ok('E4 the lists say how many are open and closed', await p.evaluate(() => /Open proposals · 1/.test(document.querySelector('#oMain').textContent) && !/Closed ·/.test(document.querySelector('#oMain').textContent)));
115
- const nAcc = A.S.posts.length;
116
- await p.click('[data-ds^="acc:"]');
117
- await until(() => A.S.posts.length > nAcc);
118
- const ac = A.S.posts[A.S.posts.length - 1];
119
- ok('E4 Accept posts path, id, hash and only the sections still current', ac.route === 'accept' && Object.keys(ac.body).sort().join() === 'hash,id,path,sections' && ac.body.hash === 'ha' && ac.body.sections.join() === 'Summary', JSON.stringify(ac.body));
120
- await until(() => p.evaluate(() => /Closed · 1/.test(document.querySelector('#oMain').textContent)));
121
- ok('E5 after Accept the proposal is listed as closed and accepted, and none is open', await p.evaluate(() => /Open proposals · 0/.test(document.querySelector('#oMain').textContent) && /Accepted/.test(document.querySelector('.dsp.accepted').textContent) && /No open proposals/.test(document.querySelector('#oMain').textContent)));
122
- if (!(await p.$('#shT [data-sh]'))) await p.click('#shV'); ok('E5 the Proposals count is gone from the menu once none is open', await p.evaluate(() => document.querySelector('#shT [data-sh="props"]').textContent.trim() === 'Proposals'));
96
+ /* E2 edit (the file as Markdown; editing in place is in premium-vw-doc-test.js) */
97
+ ok('E2 while a proposal is open, Edit and Markdown are locked until it is kept or undone', await p.evaluate((v) => [...document.querySelectorAll(v + ' .vwseg')].filter((b) => b.disabled).length === 2, V));
98
+ A.S.posts.length = 0;
123
99
  await A.ctx.close();
124
100
 
125
- /* E4 stale-all, reject, ask */
126
101
  {
127
- const B = await open({ props: [prop({ sections: [{ name: 'Goal', kind: 'changed', before: 'x', after: 'y', current: 'z', stale: true }] }), prop({ id: 'prop-b', hash: 'hb', prompt: 'drop the code block', sections: [{ name: 'Requirements', kind: 'removed', before: 'R1', after: '', current: 'R1', stale: false }] })] });
128
- const q = B.page; await tab(q, 'props');
129
- ok('E4 a proposal whose every section is stale has no Accept and says so', await q.evaluate(() => { const d = [...document.querySelectorAll('.dsp')].find((x) => /add a one-paragraph summary/.test(x.textContent)); return d && !d.querySelector('[data-ds^="acc:"]') && !!d.querySelector('[data-ds^="rej:"]') && /cannot be accepted/.test(d.textContent); }));
130
- ok('E4 a removed section says it removes', await q.evaluate(() => /Removes this section/.test(document.querySelector('#oMain').textContent)));
131
- await q.click('[data-ds="rej:prop-b"]');
132
- ok('E4 Reject asks for a reason first and posts nothing yet', await q.evaluate(() => !!document.querySelector('#dsRj')) && B.S.posts.length === 0);
133
- await q.click('[data-ds="rejgo:prop-b"]');
134
- ok('E4 Reject with no reason is refused with no post', await q.evaluate(() => /Say why you are rejecting it/.test(document.querySelector('#dsErr').textContent)) && B.S.posts.length === 0);
135
- await q.fill('#dsRj', 'not needed'); await q.click('[data-ds="rejgo:prop-b"]'); await until(() => B.S.posts.length);
136
- ok('E4 Reject posts path, id and why only', B.S.posts[0].route === 'reject' && Object.keys(B.S.posts[0].body).sort().join() === 'id,path,why' && B.S.posts[0].body.why === 'not needed');
137
- await until(() => q.evaluate(() => /Closed · 1/.test(document.querySelector('#oMain').textContent)));
138
- ok('E5 the rejected proposal is closed with its reason', await q.evaluate(() => /Rejected/.test(document.querySelector('.dsp.rejected').textContent) && /not needed/.test(document.querySelector('.dsp.rejected').textContent)));
139
- /* ask */
140
- await q.fill('#dsAsk', 'tighten the goal'); await q.click('[data-ds="ask"]'); await until(() => B.S.posts.length > 1);
141
- const ak = B.S.posts[1];
102
+ const E = await open({ props: [] }); const q = E.page;
103
+ ok('E1 with no open proposal the count is gone from Proposals', await q.evaluate((v) => document.querySelector(v + ' [data-vd="side:props"]').textContent.trim() === 'Proposals', V));
104
+ ok('E7 the save row says the reason is kept in the Edit log', await (async () => { await q.click(`${V} [data-vd="mode:md"]`); return /Kept in the Edit log/.test(await q.getAttribute(`${V} #vwWhy`, 'placeholder')); })());
105
+ ok('E2 Markdown holds the file as text, with a reason box and Save', (await q.inputValue(`${V} #vwMd`)) === TEXT && !!(await q.$(`${V} #vwWhy`)) && /Save as v2/.test(await txt(q, `${V} .vwsave`)));
106
+ await q.fill(`${V} #vwWhy`, 'add the missing line'); await q.click(`${V} [data-vd="save"]`);
107
+ ok('E2 Save with no change posts nothing and says so', /Nothing has changed yet/.test(await txt(q, `${V} #vwErr`)) && E.S.posts.length === 0);
108
+ await q.fill(`${V} #vwMd`, TEXT + '\nMore.\n'); await q.fill(`${V} #vwWhy`, ''); await q.click(`${V} [data-vd="save"]`);
109
+ ok('E2 Save with no reason posts nothing and says why', /Say why the document changes/.test(await txt(q, `${V} #vwErr`)) && E.S.posts.length === 0);
110
+ ok('E2 the text typed is still there after the refusal', (await q.inputValue(`${V} #vwMd`)) === TEXT + '\nMore.\n');
111
+ await q.click(`${V} [data-vd="mode:read"]`);
112
+ ok('E2 the page says there are changes not saved yet', /not saved yet/.test(await txt(q, V)));
113
+ await q.click(`${V} [data-vd="mode:md"]`);
114
+ ok('E2 the draft survives a mode switch', (await q.inputValue(`${V} #vwMd`)) === TEXT + '\nMore.\n');
115
+ await q.fill(`${V} #vwWhy`, 'add the missing line'); await q.click(`${V} [data-vd="save"]`);
116
+ await until(() => E.S.posts.length);
117
+ const e1 = E.S.posts[0];
118
+ ok('E2 Save posts path, text and why to /api/doc-sheet/edit with the launch headers and the workspace', e1 && e1.route === 'edit' && Object.keys(e1.body).sort().join() === 'path,text,why' && e1.body.path === PATH && e1.body.why === 'add the missing line' && e1.body.text.endsWith('More.\n') && /ws=w1/.test(e1.query) && e1.headers.origin === BASE, JSON.stringify(e1 && { r: e1.route, q: e1.query }));
119
+ /* E5 after a write */
120
+ await until(() => q.evaluate((v) => !document.querySelector(v + ' #vwMd') && /v2/.test((document.querySelector(v + ' .cff') || {}).textContent || ''), V));
121
+ ok('E5 after Save the page is read again from the route and shows v2', /v2/.test(await txt(q, `${V} .cff`)) && /More\./.test(await txt(q, `${V} .cfb`)));
122
+ await side(q, 'log');
123
+ ok('E5 the Edit log shows the new revision with its reason', await until(() => q.evaluate((v) => /v2 add the missing line/.test((document.querySelector(v + ' .vwside .evl') || {}).textContent || ''), V)));
124
+ /* E3 ask */
125
+ await q.click(`${V} [data-vd="askt"]`); await q.fill(`${V} #vwAsk`, 'tighten the goal'); const nA = E.S.posts.length; await q.click(`${V} [data-vd="ask"]`); await until(() => E.S.posts.length > nA);
126
+ const ak = E.S.posts[E.S.posts.length - 1];
142
127
  ok('E3 Ask posts path and prompt to /api/doc-sheet/ask', ak.route === 'ask' && Object.keys(ak.body).sort().join() === 'path,prompt' && ak.body.prompt === 'tighten the goal' && /ws=w1/.test(ak.query));
143
- ok('E3 while it works the tab says the agent can only read, and the button is off', await until(() => q.evaluate(() => /The agent is reading the document/.test(document.querySelector('#oMain').textContent) && document.querySelector('[data-ds="ask"]').disabled)));
144
- ok('E3 the page polls the ask by id', await until(() => B.S.gets.some((g) => g.route === 'ask' && /id=ask-1/.test(g.query)), 8000));
145
- B.S.ask = { ok: true, id: 'ask-1', state: 'failed', error: 'The run ended without an answer. Ask again.' };
146
- ok('E3 a failed ask shows the route\'s own error', await until(() => q.evaluate(() => /The run ended without an answer/.test(document.querySelector('#oMain').textContent)), 8000));
128
+ ok('E3 while it works the page says the agent can only read', await until(() => q.evaluate((v) => /The agent is reading the document/.test(document.querySelector(v).textContent), V)));
129
+ ok('E3 the page polls the ask by id', await until(() => E.S.gets.some((g) => g.route === 'ask' && /id=ask-1/.test(g.query)), 8000));
130
+ E.S.ask = { ok: true, id: 'ask-1', state: 'failed', error: 'The run ended without an answer. Ask again.' };
131
+ ok('E3 a failed ask shows the route\'s own error', await until(() => q.evaluate((v) => /The run ended without an answer/.test(document.querySelector(v).textContent), V), 8000));
132
+ ok('0 no page error', E.S.errors.length === 0, E.S.errors.join(' | '));
133
+ await E.ctx.close();
134
+ }
135
+
136
+ /* E4 proposals: accept */
137
+ {
138
+ const B = await open(); const q = B.page;
139
+ await side(q, 'props');
140
+ const pv = await q.evaluate((v) => { const d = document.querySelector(v + ' .vwprop'); return d && { t: d.textContent.replace(/\s+/g, ' '), acc: !!d.querySelector('[data-vd^="pacc:"]'), rej: !!d.querySelector('[data-vd^="prej:"]') }; }, V);
141
+ ok('E4 an open proposal names who, the request, the added text, and a stale section says so', pv && /The agent/.test(pv.t) && /add a one-paragraph summary/.test(pv.t) && /\+ Partners reach a first call/.test(pv.t) && /Changed since this was proposed/.test(pv.t) && pv.acc && pv.rej, JSON.stringify(pv));
142
+ ok('E4 the lists say how many are open and closed', /Open proposals · 1/.test(await txt(q, `${V} .vwside`)) && !/Closed ·/.test(await txt(q, `${V} .vwside`)));
143
+ await q.click(`${V} [data-vd^="pacc:"]`);
144
+ await until(() => B.S.posts.length);
145
+ const ac = B.S.posts[B.S.posts.length - 1];
146
+ ok('E4 Accept posts path, id, hash and only the sections still current', ac.route === 'accept' && Object.keys(ac.body).sort().join() === 'hash,id,path,sections' && ac.body.hash === 'ha' && ac.body.sections.join() === 'Summary', JSON.stringify(ac.body));
147
+ await until(() => q.evaluate((v) => /Closed · 1/.test((document.querySelector(v + ' .vwside') || {}).textContent || ''), V));
148
+ ok('E5 after Accept the proposal is listed as closed and accepted, and none is open', await q.evaluate((v) => { const t = document.querySelector(v + ' .vwside').textContent; return /Open proposals · 0/.test(t) && /Accepted/.test(document.querySelector(v + ' .vwprop.accepted').textContent) && /No open proposals/.test(t); }, V));
149
+ ok('E5 the Proposals count is gone once none is open', await q.evaluate((v) => document.querySelector(v + ' [data-vd="side:props"]').textContent.trim() === 'Proposals', V));
150
+ await B.ctx.close();
151
+ }
152
+ /* E4 stale-all, removed, reject */
153
+ {
154
+ const B = await open({ props: [prop({ sections: [{ name: 'Goal', kind: 'changed', before: 'x', after: 'y', current: 'z', stale: true }] }), prop({ id: 'prop-b', hash: 'hb', prompt: 'drop the requirements', after: TEXT.replace(/## Requirements[\s\S]*$/, ''), sections: [{ name: 'Requirements', kind: 'removed', before: 'R1', after: '', current: 'R1', stale: false }] })] });
155
+ const q = B.page; await side(q, 'props');
156
+ ok('E4 a proposal whose every section is stale has no Accept and says so', await q.evaluate((v) => { const d = document.querySelector(v + ' .vwprop[data-prop="prop-a"]'); return d && !d.querySelector('[data-vd^="pacc:"]') && !!d.querySelector('[data-vd^="prej:"]') && /cannot be accepted/.test(d.textContent); }, V));
157
+ ok('E4 a removed section says it removes', /Removes this section/.test(await txt(q, `${V} .vwside`)));
158
+ await q.click(`${V} [data-vd="prej:prop-b"]`);
159
+ ok('E4 Reject asks for a reason first and posts nothing yet', !!(await q.$(`${V} #vwRj`)) && B.S.posts.length === 0);
160
+ await q.click(`${V} [data-vd="prejgo:prop-b"]`);
161
+ ok('E4 Reject with no reason is refused with no post', /Say why you are rejecting it/.test(await txt(q, `${V} #vwSideErr`)) && B.S.posts.length === 0);
162
+ await q.fill(`${V} #vwRj`, 'not needed'); await q.click(`${V} [data-vd="prejgo:prop-b"]`); await until(() => B.S.posts.length);
163
+ ok('E4 Reject posts path, id and why only', B.S.posts[0].route === 'reject' && Object.keys(B.S.posts[0].body).sort().join() === 'id,path,why' && B.S.posts[0].body.why === 'not needed');
164
+ await until(() => q.evaluate((v) => /Closed · 1/.test((document.querySelector(v + ' .vwside') || {}).textContent || ''), V));
165
+ ok('E5 the rejected proposal is closed with its reason', await q.evaluate((v) => { const d = document.querySelector(v + ' .vwprop.rejected'); return !!d && /Rejected/.test(d.textContent) && /not needed/.test(d.textContent); }, V));
147
166
  ok('0 no page error', B.S.errors.length === 0, B.S.errors.join(' | '));
148
167
  await B.ctx.close();
149
168
  }
150
169
  /* E5/E4 a refused accept shows the route's reason and reads again */
151
170
  {
152
171
  const C = await open({ post: (route) => (route === 'accept' ? { status: 409, body: { ok: false, error: 'stale: Summary changed since this proposal was made', reason: 'stale' } } : null) });
153
- await tab(C.page, 'props'); await C.page.click('[data-ds^="acc:"]');
154
- ok('E4 a refused Accept shows the route\'s reason and the proposal stays open', await until(() => C.page.evaluate(() => /stale: Summary changed since this proposal was made/.test((document.querySelector('#dsErr') || {}).textContent || '') && /Open proposals · 1/.test(document.querySelector('#oMain').textContent))));
172
+ await side(C.page, 'props'); await C.page.click(`${V} [data-vd^="pacc:"]`);
173
+ ok('E4 a refused Accept shows the route\'s reason and the proposal stays open', await until(() => C.page.evaluate((v) => /stale: Summary changed since this proposal was made/.test((document.querySelector(v + ' #vwSideErr') || {}).textContent || '') && /Open proposals · 1/.test(document.querySelector(v + ' .vwside').textContent), V)));
155
174
  await C.ctx.close();
156
175
  }
157
- /* the mockup's .dsed carries a toolbar above it (radius 0 0 14px 14px); this build leaves the toolbar out, so the box keeps the full 14px radius */
158
- /* E8 fidelity: the page's rules for the new elements equal the mockup's last rule for each class */
159
- const rule = (src, sel) => { const m = [...src.matchAll(new RegExp('(?:^|[}\\n])\\s*' + sel.replace(/[.#]/g, (c) => '\\' + c) + '\\{([^}]*)\\}', 'g'))].filter((x) => sel !== '.dsfoot' || /justify-content/.test(x[1])); return m.length ? m[m.length - 1][1].replace('border-radius:0 0 14px 14px', 'border-radius:14px').replace(/#6d3fd1/g, 'rgb(109,63,209)').replace(/\s+/g, '') : null; };
160
- for (const sel of ['.dsed', '.dsy', '.dsfoot', '.dsdf', '#dsAsk']) {
161
- const a = rule(MOCKUP, sel), b = rule(CSS, sel);
162
- ok(`E8 ${sel} has the mockup's declarations`, a && b && b.replace(/;$/, '') === a.replace(/;$/, ''), JSON.stringify({ a, b }));
163
- }
176
+ /* E8 the Agreed design's tokens and the floors: the section uses the cozy marker and the viewer's own controls, at desktop and phone, light and dark */
164
177
  for (const [w, h, theme] of [[1280, 900, 'light'], [1280, 900, 'dark'], [390, 844, 'light'], [390, 844, 'dark']]) {
165
178
  const R = await open({ w, h, theme });
166
- for (const t of ['edit', 'props']) {
167
- await tab(R.page, t);
168
- const f = await R.page.evaluate(() => { const bad = []; for (const e of document.querySelectorAll('#oMain button,#oMain input:not([type=checkbox]),#oMain textarea')) { const r = e.getBoundingClientRect(); if (r.width && r.height && r.height < 32) bad.push(e.textContent.trim() || e.id); } return { sx: document.documentElement.scrollWidth - innerWidth, bad, out: [...document.querySelectorAll('#oMain textarea,#oMain .dsp,#oMain .dsask2')].filter((e) => e.getBoundingClientRect().right > innerWidth + 1).length }; });
169
- ok(`E8 ${t} tab at ${w} px ${theme}: no sideways scroll, no tiny target, nothing past the edge`, f.sx <= 0 && f.bad.length === 0 && f.out === 0, JSON.stringify(f));
179
+ for (const t of ['log', 'props']) {
180
+ await side(R.page, t);
181
+ if (t === 'props') await R.page.click(`${V} [data-vd="prej:prop-a"]`);
182
+ const f = await R.page.evaluate(([v, phone]) => { const bad = []; const root = document.querySelector(v + ' .vwside'); for (const e of root.querySelectorAll('button,input,textarea')) { const r = e.getBoundingClientRect(); if (r.width && r.height && r.height < (phone ? 44 : 32)) bad.push(e.textContent.trim() || e.id); } return { sx: document.documentElement.scrollWidth - innerWidth, bad, out: [...root.querySelectorAll('.vwprop,input,button')].filter((e) => e.getBoundingClientRect().right > innerWidth + 1).length, wait: getComputedStyle(root.querySelector('.hx-wait')).borderRadius }; }, [V, w < 761]);
183
+ ok(`E8 ${t} at ${w} px ${theme}: no sideways scroll, no small target, nothing past the edge, the cozy marker`, f.sx <= 0 && f.bad.length === 0 && f.out === 0 && f.wait !== '0px', JSON.stringify(f));
170
184
  }
171
- const cs = await R.page.evaluate(() => { const e = document.querySelector('#dsAsk'); const c = getComputedStyle(e); return { r: c.borderRadius, fs: c.fontSize }; });
172
- ok(`E8 the ask box is 14px rounded, 14px type (the console's body size) at ${w} px ${theme}`, cs.r === '14px' && cs.fs === '14px', JSON.stringify(cs));
173
185
  await R.ctx.close();
174
186
  }
175
187
  finish();