create-pmos 0.327.0 → 0.328.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/guide/briefing-premium.md +4 -0
- package/workspace/guide/docs.md +3 -0
- package/workspace/lib/doc-reads-store.js +90 -0
- package/workspace/lib/doc-reads.js +128 -0
- package/workspace/lib/doc-sync-store.js +1 -1
- package/workspace/lib/docs-cli.js +48 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-vw-copy-test.js +133 -0
- package/workspace/public/pm/premium-doc-sheet.js +3 -1
- package/workspace/public/pm/premium-meeting.js +3 -2
- package/workspace/public/pm/premium-vw-copies.js +133 -0
- package/workspace/public/pm/premium-vw-copy.css +27 -0
- package/workspace/server.js +42 -0
- package/workspace/skills/doc-read.skill +32 -0
- package/workspace/test-lists/doc-reads.json +5 -0
- package/workspace/test-lists/premium-vw-copy.json +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.328.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-19T23:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T23:26:25Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-19T23:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T23:26:25Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-19T23:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T23:26:25Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -191,6 +191,10 @@ Every markdown document opens as one page in a tab: a report, a PRD, a new docum
|
|
|
191
191
|
- **Health**, **Links** and **Copies** under the toolbar show the document's checks, the documents it links to, and its linked copies. The checks only read the file.
|
|
192
192
|
- A report also shows **Present**, **Print** and **Download** on the same toolbar.
|
|
193
193
|
|
|
194
|
+
### Confluence pages and Google Docs
|
|
195
|
+
|
|
196
|
+
A Confluence page or Google Doc opens as a tab too. From a document's **Copies**, press **Preview** on a copy. If the last check found the same text in both, the PMOS file is shown as the page, with **Same as PMOS** and the check time. If the copy changed, the tab says so and shows the PMOS version dimmed. **Use the … version** writes the copy's text into the PMOS file after five seconds; press **Undo** to stop it. From a meeting's **Material**, press the page icon on a Google Doc or Confluence link. PMOS holds only the address of such a page, so the tab says so. **Read it now** starts one session that reads the page with your connector and keeps the text in PMOS; it changes nothing in Google Docs or Confluence. The tab then shows the text with when it was read. Press **Read again** for later edits.
|
|
197
|
+
|
|
194
198
|
A decision opens with no option chosen, because no recommendation is on record. Choose one and the draft entry on the right changes. Nothing is written. The main button, "Not yet" and "Return this run to the agent" are off in this version, and each says why.
|
|
195
199
|
|
|
196
200
|
## The conversation
|
package/workspace/guide/docs.md
CHANGED
|
@@ -147,5 +147,8 @@ A link that you add in an initiative's artifacts is the same link and shows here
|
|
|
147
147
|
| `pmos docs sync-start <file> confluence --use pmos` | Used by the sync session: opens a sync of one copy (`--use copy` for the other direction). |
|
|
148
148
|
| `pmos docs sync-finish <sync> --version <v>` | Used by the sync session: closes the sync. The two sides are now the same. |
|
|
149
149
|
| `pmos docs sync-fail <sync> --reason "…"` | Used by the sync session: closes the sync. Nothing was written. |
|
|
150
|
+
| `pmos docs read-start <address>` | Used by the read session: opens a read of one Google Doc or Confluence page. |
|
|
151
|
+
| `pmos docs read-finish <read> --file <text.md>` | Used by the read session: records the text it read (from stdin without `--file`). |
|
|
152
|
+
| `pmos docs read-fail <read> --reason "…"` | Used by the read session: closes the read. Nothing was read. |
|
|
150
153
|
|
|
151
154
|
The session commands must name who read or wrote. In a workspace session that is the session. Outside the workspace, add `--by <profile>`.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* doc-reads-store.js — the file side of "Read it now". lib/doc-reads.js decides; this module reads and appends.
|
|
3
|
+
*
|
|
4
|
+
* The ledger is doc-reads.jsonl, in the same state directory as doc-checks.jsonl (lib/doc-sync-store.js#stateDir).
|
|
5
|
+
* Every write goes through doc-reads.js#checkRow, so a refused row is never on disk. Nothing here reads a page.
|
|
6
|
+
*
|
|
7
|
+
* latest(root, url, { now }) → { ok, kind, read, open, failed }
|
|
8
|
+
* readStart(root, { url, by, now }) → { ok, run, url, kind, remote_id } | { ok:false, code, error }
|
|
9
|
+
* readFinish(root, { run, by, text, title, revision, modified_at, now }) → { ok, truncated }
|
|
10
|
+
* readFail(root, { run, by, reason, now }) → { ok }
|
|
11
|
+
*
|
|
12
|
+
* Refusal codes: 'kind' (not a Google Doc or Confluence page), 'open' (a read of that page is open), 'run' (no such
|
|
13
|
+
* open read), 'state' (no state directory), 'row' (checkRow refused).
|
|
14
|
+
*/
|
|
15
|
+
const crypto = require('crypto');
|
|
16
|
+
const fourPanel = require('./four-panel');
|
|
17
|
+
const DS = require('./doc-sync');
|
|
18
|
+
const R = require('./doc-reads');
|
|
19
|
+
const { stateDir } = require('./doc-sync-store');
|
|
20
|
+
|
|
21
|
+
const LEDGER = 'doc-reads.jsonl';
|
|
22
|
+
|
|
23
|
+
function readRows(root) {
|
|
24
|
+
const s = stateDir(root);
|
|
25
|
+
if (!s.ok) return { ok: false, code: 'state', error: s.error, rows: [] };
|
|
26
|
+
return fourPanel.readDeclarations(s.dir, LEDGER);
|
|
27
|
+
}
|
|
28
|
+
function append(root, row) {
|
|
29
|
+
const c = R.checkRow(row);
|
|
30
|
+
if (!c.ok) return { ok: false, code: 'row', error: c.error };
|
|
31
|
+
const s = stateDir(root);
|
|
32
|
+
if (!s.ok) return { ok: false, code: 'state', error: s.error };
|
|
33
|
+
return fourPanel.appendDeclaration(s.dir, LEDGER, c.row);
|
|
34
|
+
}
|
|
35
|
+
const t = (now) => (now instanceof Date ? now : new Date(now == null ? Date.now() : now));
|
|
36
|
+
const newRunId = () => 'r-' + crypto.randomBytes(6).toString('hex');
|
|
37
|
+
const KIND_ERROR = 'give the address of a Google Doc or a Confluence page (Slides and Sheets are not read yet)';
|
|
38
|
+
|
|
39
|
+
function latest(root, url, { now = Date.now() } = {}) {
|
|
40
|
+
const kind = R.kindOf(url);
|
|
41
|
+
if (!kind) return { ok: false, code: 'kind', error: KIND_ERROR };
|
|
42
|
+
const rows = readRows(root);
|
|
43
|
+
if (!rows.ok) return rows;
|
|
44
|
+
return { ok: true, kind, ...R.latestFor(rows.rows, url, { now: t(now).getTime() }) };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Open a read of one page. Refused while another read of that page is open. */
|
|
48
|
+
function readStart(root, { url, by, now } = {}) {
|
|
49
|
+
const u = String(url || '').trim();
|
|
50
|
+
const kind = R.kindOf(u);
|
|
51
|
+
if (!kind) return { ok: false, code: 'kind', error: KIND_ERROR };
|
|
52
|
+
if (!by) return { ok: false, code: 'row', error: 'a read must name the session or profile that runs it' };
|
|
53
|
+
const at = t(now);
|
|
54
|
+
const rows = readRows(root);
|
|
55
|
+
if (!rows.ok) return rows;
|
|
56
|
+
const cur = R.latestFor(rows.rows, u, { now: at.getTime() });
|
|
57
|
+
if (cur.open) return { ok: false, code: 'open', error: `that page is already being read (${cur.open.run}, started ${cur.open.started_at})`, open: cur.open };
|
|
58
|
+
const run = newRunId();
|
|
59
|
+
const w = append(root, { v: 1, ev: 'start', run, url: u, kind, by, at: at.toISOString() });
|
|
60
|
+
if (!w.ok) return w;
|
|
61
|
+
return { ok: true, run, url: u, kind, label: DS.KIND_LABEL[kind], remote_id: DS.remoteIdOf(kind, u) };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function openRun(root, run) {
|
|
65
|
+
const rows = readRows(root);
|
|
66
|
+
if (!rows.ok) return rows;
|
|
67
|
+
const x = R.runsOf(rows.rows).find((r) => r.run === run);
|
|
68
|
+
if (!x) return { ok: false, code: 'run', error: `${run || 'that'} is not a read that was started — run pmos docs read-start first` };
|
|
69
|
+
if (x.state !== 'open') return { ok: false, code: 'run', error: `${run} is already ${x.state}` };
|
|
70
|
+
return { ok: true, run: x };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Close a read with what the session read. The address and kind come from the start row, not the caller. */
|
|
74
|
+
function readFinish(root, { run, by, text, title, revision, modified_at, now } = {}) {
|
|
75
|
+
const o = openRun(root, run);
|
|
76
|
+
if (!o.ok) return o;
|
|
77
|
+
const w = append(root, { v: 1, ev: 'finish', run, url: o.run.url, kind: o.run.kind, by, at: t(now).toISOString(),
|
|
78
|
+
title: title || null, revision: revision == null ? null : String(revision), modified_at: modified_at || null, text });
|
|
79
|
+
if (!w.ok) return w;
|
|
80
|
+
return { ok: true, run, url: o.run.url, kind: o.run.kind, truncated: !!w.recorded.truncated, chars: w.recorded.text.length };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function readFail(root, { run, by, reason, now } = {}) {
|
|
84
|
+
const o = openRun(root, run);
|
|
85
|
+
if (!o.ok) return o;
|
|
86
|
+
const w = append(root, { v: 1, ev: 'fail', run, url: o.run.url, kind: o.run.kind, by, at: t(now).toISOString(), reason });
|
|
87
|
+
return w.ok ? { ok: true, run } : w;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
module.exports = { LEDGER, readRows, latest, readStart, readFinish, readFail };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* doc-reads.js — "Read it now": a read-only snapshot of one Google Doc or Confluence page, by address.
|
|
3
|
+
*
|
|
4
|
+
* No route reads Google or Confluence (D53). The PM presses Read it now; a doc-read session reads the page with the
|
|
5
|
+
* PM's own connector and records it through `pmos docs read-finish`. This module decides which rows are valid and
|
|
6
|
+
* what the latest read of an address is. lib/doc-reads-store.js reads and appends the ledger.
|
|
7
|
+
*
|
|
8
|
+
* PURE: no file, no network, no clock. The caller passes `now`.
|
|
9
|
+
*
|
|
10
|
+
* checkRow(row) → { ok:true, row } | { ok:false, error } the gate every ledger line passes
|
|
11
|
+
* kindOf(url) → 'google' | 'confluence' | null Slides and Sheets are refused for now
|
|
12
|
+
* keyOf(url) → '<kind>:<remote id>' | null one page pasted in two shapes is one key
|
|
13
|
+
* latestFor(rows, url, { now }) → { read, open, failed }
|
|
14
|
+
*
|
|
15
|
+
* Row: { v:1, ev:'start'|'finish'|'fail', run:'r-…', url, kind, by, at, title?, revision?, modified_at?, text?, reason? }
|
|
16
|
+
* A finish names who read and the run it belongs to, and carries the text (markdown). A fail says why.
|
|
17
|
+
*/
|
|
18
|
+
const DS = require('./doc-sync');
|
|
19
|
+
|
|
20
|
+
const KINDS = Object.freeze(['google', 'confluence']);
|
|
21
|
+
const EVENTS = Object.freeze(['start', 'finish', 'fail']);
|
|
22
|
+
const RUN_ID = DS.RUN_ID;
|
|
23
|
+
// The text a finish may carry. Longer text is cut here and the row says `truncated: true`.
|
|
24
|
+
const MAX_TEXT = 200 * 1024;
|
|
25
|
+
// A read left open this long has ended without saying so (the session closed). The page may be read again.
|
|
26
|
+
const OPEN_READ_MS = 10 * 60 * 1000;
|
|
27
|
+
|
|
28
|
+
const str = (v, n = 300) => (v == null || v === '' ? null : String(v).slice(0, n));
|
|
29
|
+
const isObj = (v) => v && typeof v === 'object' && !Array.isArray(v);
|
|
30
|
+
const isTime = (s) => !Number.isNaN(Date.parse(s));
|
|
31
|
+
|
|
32
|
+
/** The kind of a pasted address: a Google Doc or a Confluence page. Slides, Sheets and anything else: null. */
|
|
33
|
+
function kindOf(url) {
|
|
34
|
+
const k = DS.kindOfTarget(url);
|
|
35
|
+
return KINDS.includes(k) ? k : null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** One key per page, so the same page pasted with /edit or ?pageId= is the same read. */
|
|
39
|
+
function keyOf(url) {
|
|
40
|
+
const kind = kindOf(url);
|
|
41
|
+
if (!kind) return null;
|
|
42
|
+
const id = DS.remoteIdOf(kind, String(url).trim());
|
|
43
|
+
return id ? `${kind}:${id}` : null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The one gate every ledger line passes. A refused row is never written, and the readers skip it. */
|
|
47
|
+
function checkRow(input) {
|
|
48
|
+
if (!isObj(input)) return { ok: false, error: 'a ledger row is an object' };
|
|
49
|
+
if (input.v !== 1) return { ok: false, error: 'v must be 1' };
|
|
50
|
+
const ev = String(input.ev || '');
|
|
51
|
+
if (!EVENTS.includes(ev)) return { ok: false, error: `ev must be one of: ${EVENTS.join(', ')}` };
|
|
52
|
+
const at = str(input.at, 40);
|
|
53
|
+
if (!at || !isTime(at)) return { ok: false, error: 'at must be an ISO time' };
|
|
54
|
+
if (!RUN_ID.test(String(input.run || ''))) return { ok: false, error: 'run must name the read it belongs to (r-…)' };
|
|
55
|
+
const by = str(input.by, 120);
|
|
56
|
+
if (!by) return { ok: false, error: 'a read row must name the session or profile that made it' };
|
|
57
|
+
const url = str(input.url, 2000);
|
|
58
|
+
const kind = url ? kindOf(url) : null;
|
|
59
|
+
if (!kind) return { ok: false, error: `url must be the address of a ${KINDS.map((k) => DS.KIND_LABEL[k]).join(' or ')} page` };
|
|
60
|
+
if (input.kind != null && input.kind !== kind) return { ok: false, error: `kind ${input.kind} does not match the address (${kind})` };
|
|
61
|
+
const row = { v: 1, ev, run: input.run, url, kind, by, at };
|
|
62
|
+
|
|
63
|
+
if (ev === 'finish') {
|
|
64
|
+
if (typeof input.text !== 'string' || !input.text.trim()) return { ok: false, error: 'a finished read carries the text it read' };
|
|
65
|
+
const modified_at = str(input.modified_at, 40);
|
|
66
|
+
if (modified_at && !isTime(modified_at)) return { ok: false, error: 'modified_at must be an ISO time' };
|
|
67
|
+
row.title = str(input.title, 300);
|
|
68
|
+
row.revision = str(input.revision, 120);
|
|
69
|
+
row.modified_at = modified_at;
|
|
70
|
+
row.text = input.text.slice(0, MAX_TEXT);
|
|
71
|
+
if (input.text.length > MAX_TEXT || input.truncated === true) row.truncated = true;
|
|
72
|
+
}
|
|
73
|
+
if (ev === 'fail') {
|
|
74
|
+
const reason = str(input.reason, 400);
|
|
75
|
+
if (!reason) return { ok: false, error: 'a failed read says why' };
|
|
76
|
+
row.reason = reason;
|
|
77
|
+
}
|
|
78
|
+
return { ok: true, row };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Every read of every page, by key: { run, key, url, kind, started_at, start_by, ended_at, state, row }. */
|
|
82
|
+
function runsOf(rows) {
|
|
83
|
+
const runs = new Map();
|
|
84
|
+
for (const raw of Array.isArray(rows) ? rows : []) {
|
|
85
|
+
const c = checkRow(raw);
|
|
86
|
+
if (!c.ok) continue;
|
|
87
|
+
const r = c.row;
|
|
88
|
+
const key = keyOf(r.url);
|
|
89
|
+
if (r.ev === 'start') {
|
|
90
|
+
if (!runs.has(r.run)) runs.set(r.run, { run: r.run, key, url: r.url, kind: r.kind, started_at: r.at, start_by: r.by, state: 'open', ended_at: null, row: null });
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
// A finish or fail counts only for a run that was started, for the same page, and only once.
|
|
94
|
+
const cur = runs.get(r.run);
|
|
95
|
+
if (!cur || cur.key !== key || cur.state !== 'open') continue;
|
|
96
|
+
cur.state = r.ev === 'finish' ? 'finished' : 'failed';
|
|
97
|
+
cur.ended_at = r.at;
|
|
98
|
+
cur.row = r;
|
|
99
|
+
}
|
|
100
|
+
return [...runs.values()];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The latest read of one address, the read still open, and the last failure after the last read.
|
|
105
|
+
* `now` (ms) ages an open read out after OPEN_READ_MS; without it an open read stays open.
|
|
106
|
+
*/
|
|
107
|
+
function latestFor(rows, url, { now } = {}) {
|
|
108
|
+
const key = keyOf(url);
|
|
109
|
+
const none = { read: null, open: null, failed: null };
|
|
110
|
+
if (!key) return none;
|
|
111
|
+
const mine = runsOf(rows).filter((x) => x.key === key);
|
|
112
|
+
const done = mine.filter((x) => x.state === 'finished').sort((a, b) => a.ended_at.localeCompare(b.ended_at)).pop() || null;
|
|
113
|
+
const read = done ? {
|
|
114
|
+
title: done.row.title, revision: done.row.revision, modified_at: done.row.modified_at, read_at: done.ended_at,
|
|
115
|
+
by: done.row.by, text: done.row.text, ...(done.row.truncated ? { truncated: true } : {}), run: done.run,
|
|
116
|
+
} : null;
|
|
117
|
+
const live = (x) => x.state === 'open' && (now == null || now - Date.parse(x.started_at) < OPEN_READ_MS);
|
|
118
|
+
const o = mine.filter(live).sort((a, b) => a.started_at.localeCompare(b.started_at)).pop() || null;
|
|
119
|
+
const lastFail = mine.filter((x) => x.state === 'failed' && (!done || x.ended_at > done.ended_at))
|
|
120
|
+
.sort((a, b) => a.ended_at.localeCompare(b.ended_at)).pop() || null;
|
|
121
|
+
return {
|
|
122
|
+
read,
|
|
123
|
+
open: o ? { run: o.run, started_at: o.started_at } : null,
|
|
124
|
+
failed: !o && lastFail ? { run: lastFail.run, reason: lastFail.row.reason, at: lastFail.ended_at } : null,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
module.exports = { KINDS, EVENTS, RUN_ID, MAX_TEXT, OPEN_READ_MS, checkRow, kindOf, keyOf, runsOf, latestFor };
|
|
@@ -319,4 +319,4 @@ function findFiles(root, q, { limit = 20 } = {}) {
|
|
|
319
319
|
});
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
-
module.exports = { LEDGER, OPEN_RUN_MS, OPEN_SYNC_MS, syncStart, syncFinish, syncFail, findFiles, view, addLink, removeLink, checkStart, record, checkFinish, repoInfo, bodyHash, bodyOf, titleOf, links };
|
|
322
|
+
module.exports = { LEDGER, OPEN_RUN_MS, OPEN_SYNC_MS, stateDir, syncStart, syncFinish, syncFail, findFiles, view, addLink, removeLink, checkStart, record, checkFinish, repoInfo, bodyHash, bodyOf, titleOf, links };
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
* pmos docs sync-start <file> google|google-slides|google-sheets|confluence --use pmos|copy [--json] open a sync of one copy (the sync session)
|
|
13
13
|
* pmos docs sync-finish <sync> --version <v> [--modified-at <t>] [--url <u>] close it: both sides now the same
|
|
14
14
|
* pmos docs sync-fail <sync> --reason "…" close it: nothing was written, and why
|
|
15
|
+
* pmos docs read-start <address> [--json] open a read of one Google Doc or Confluence page (the read session)
|
|
16
|
+
* pmos docs read-finish <read> [--file <text.md>|-] [--title t] [--revision r] [--modified-at t] record what was read (stdin without --file)
|
|
17
|
+
* pmos docs read-fail <read> --reason "…" close a read: nothing was read, and why
|
|
15
18
|
*
|
|
16
19
|
* The same module the Docs place reads (lib/doc-sync-store.js), so a terminal line and a row cannot disagree.
|
|
17
20
|
* No command writes a document. A check reads; a sync (amended 2026-10-06: the PM presses Use … version for one copy) is
|
|
@@ -26,11 +29,12 @@ const path = require('path');
|
|
|
26
29
|
const { execFileSync } = require('child_process');
|
|
27
30
|
const D = require('./doc-sync');
|
|
28
31
|
const store = require('./doc-sync-store');
|
|
32
|
+
const reads = require('./doc-reads-store');
|
|
29
33
|
const { parseArgs } = require('./schedule-cli');
|
|
30
34
|
|
|
31
|
-
const COMMANDS = { docs: ['list', 'link', 'unlink', 'check-start', 'record', 'check-finish', 'find', 'sync-start', 'sync-finish', 'sync-fail'] };
|
|
35
|
+
const COMMANDS = { docs: ['list', 'link', 'unlink', 'check-start', 'record', 'check-finish', 'find', 'sync-start', 'sync-finish', 'sync-fail', 'read-start', 'read-finish', 'read-fail'] };
|
|
32
36
|
const USAGE = [
|
|
33
|
-
'usage: pmos docs [list|link|unlink|find|check-start|record|check-finish|sync-start|sync-finish|sync-fail] — is each linked document the same as its Google Docs and Confluence copy',
|
|
37
|
+
'usage: pmos docs [list|link|unlink|find|check-start|record|check-finish|sync-start|sync-finish|sync-fail|read-start|read-finish|read-fail] — is each linked document the same as its Google Docs and Confluence copy',
|
|
34
38
|
' pmos docs [list] [--attention] [--json] each linked document and its signal: same, ahead, behind, edited in both',
|
|
35
39
|
' pmos docs link <file> <link> link a repository file to a Google Doc or a Confluence page',
|
|
36
40
|
' pmos docs unlink <file> google|google-slides|google-sheets|confluence remove that link; the copy is not touched',
|
|
@@ -41,6 +45,9 @@ const USAGE = [
|
|
|
41
45
|
' pmos docs sync-start <file> google|google-slides|google-sheets|confluence --use pmos|copy (sync session) open a sync of one copy',
|
|
42
46
|
' pmos docs sync-finish <sync> --version <v> [--modified-at <t>] [--url <u>] (sync session) both sides are now the same',
|
|
43
47
|
' pmos docs sync-fail <sync> --reason "…" (sync session) nothing was written, and why',
|
|
48
|
+
' pmos docs read-start <address> (read session) open a read of one Google Doc or Confluence page',
|
|
49
|
+
' pmos docs read-finish <read> [--file <text.md>|-] [--title t] [--revision r] [--modified-at t] (read session) record the text read (stdin without --file)',
|
|
50
|
+
' pmos docs read-fail <read> --reason "…" (read session) nothing was read, and why',
|
|
44
51
|
'Nothing here writes a document. Press Check now, or Use … version on one copy, in Docs.',
|
|
45
52
|
];
|
|
46
53
|
const BOOL = new Set(['json', 'attention', 'help']);
|
|
@@ -76,7 +83,12 @@ const ago = (iso, now) => {
|
|
|
76
83
|
return `${Math.round(m / 1440)} days ago`;
|
|
77
84
|
};
|
|
78
85
|
|
|
79
|
-
|
|
86
|
+
const readStdin = () => {
|
|
87
|
+
if (process.stdin.isTTY) throw new Error('give --file <text.md>, or pipe the text on stdin');
|
|
88
|
+
return fs.readFileSync(0, 'utf8');
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
async function run(argv, { say = console.log, cwd = process.cwd(), env = process.env, now = Date.now(), stdin = readStdin } = {}) {
|
|
80
92
|
const { pos, flags } = parse(argv.slice(1));
|
|
81
93
|
const sub = pos[0] || 'list';
|
|
82
94
|
if (flags.help || sub === 'help') { USAGE.forEach((l) => say(l)); return 0; }
|
|
@@ -211,6 +223,39 @@ async function run(argv, { say = console.log, cwd = process.cwd(), env = process
|
|
|
211
223
|
if (json) say(JSON.stringify({ ok: true })); else say('✓ Sync closed as failed. Nothing was written.');
|
|
212
224
|
return 0;
|
|
213
225
|
}
|
|
226
|
+
if (sub === 'read-start') {
|
|
227
|
+
const address = pos[1];
|
|
228
|
+
if (!address) return fail('usage: pmos docs read-start <address>', 2);
|
|
229
|
+
if (!by) return fail('a read must name who reads: run it in a workspace session, or add --by <profile>');
|
|
230
|
+
const s = reads.readStart(root, { url: address, by, now: new Date(now) });
|
|
231
|
+
if (!s.ok) return fail(s.error);
|
|
232
|
+
if (json) { say(JSON.stringify(s)); return 0; }
|
|
233
|
+
say(`Read ${s.run} · ${s.label} · ${s.url}`);
|
|
234
|
+
return 0;
|
|
235
|
+
}
|
|
236
|
+
if (sub === 'read-finish') {
|
|
237
|
+
const runId = pos[1];
|
|
238
|
+
if (!runId) return fail('usage: pmos docs read-finish <read> [--file <text.md>|-] [--title t] [--revision r] [--modified-at t]', 2);
|
|
239
|
+
if (!by) return fail('a read must name who read: run it in a workspace session, or add --by <profile>');
|
|
240
|
+
let text;
|
|
241
|
+
try { text = flags.file && flags.file !== '-' ? fs.readFileSync(path.resolve(cwd, flags.file), 'utf8') : stdin(); }
|
|
242
|
+
catch (e) { return fail(`could not read the text: ${String((e && e.message) || e).slice(0, 160)}`); }
|
|
243
|
+
const r = reads.readFinish(root, { run: runId, by, text, title: flags.title || null, revision: flags.revision || null,
|
|
244
|
+
modified_at: flags['modified-at'] || null, now: new Date(now) });
|
|
245
|
+
if (!r.ok) return fail(r.error);
|
|
246
|
+
if (json) say(JSON.stringify(r));
|
|
247
|
+
else say(`✓ Read recorded · ${r.chars} characters${r.truncated ? ' (cut to the limit)' : ''}.`);
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
250
|
+
if (sub === 'read-fail') {
|
|
251
|
+
const runId = pos[1];
|
|
252
|
+
if (!runId || !flags.reason) return fail('usage: pmos docs read-fail <read> --reason "…"', 2);
|
|
253
|
+
if (!by) return fail('a read must name who ran it: run it in a workspace session, or add --by <profile>');
|
|
254
|
+
const r = reads.readFail(root, { run: runId, by, reason: String(flags.reason), now: new Date(now) });
|
|
255
|
+
if (!r.ok) return fail(r.error);
|
|
256
|
+
if (json) say(JSON.stringify({ ok: true })); else say('✓ Read closed as failed.');
|
|
257
|
+
return 0;
|
|
258
|
+
}
|
|
214
259
|
return fail(`pmos docs ${sub} is not a command. ${USAGE[0]}`, 2);
|
|
215
260
|
}
|
|
216
261
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.328.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.328.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-vw-copy-test.js — a Confluence page or Google Doc in the premium viewer (initiative premium-viewer, R11; planning/prd/premium-viewer-prd.md).
|
|
4
|
+
* Serves the real Briefing page, opens a row's dialog, then opens the copy view with the /api/docs, /api/doc and /api/docs/read routes answered by stand-ins.
|
|
5
|
+
* R11 a linked copy that matches · a copy that changed (dimmed, Use with Undo) · a link-only page (Read it now, then the read text) · R7 floors at 390px, dark
|
|
6
|
+
* Every wait polls the page; no fixed sleep stands in for a state. */
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const { spawn } = require('child_process');
|
|
9
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
10
|
+
const T = require('./test-run').configure({ name: 'premium-vw-copy' });
|
|
11
|
+
const B = require('./lib/briefing-premium.js');
|
|
12
|
+
const F = require('./fixtures/briefing-premium-facts.js');
|
|
13
|
+
|
|
14
|
+
const BASE = T.BASE;
|
|
15
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
16
|
+
const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
17
|
+
const results = [];
|
|
18
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
|
|
19
|
+
let srv = null; let browser = null;
|
|
20
|
+
const finish = async (code) => {
|
|
21
|
+
if (browser) await browser.close().catch(() => {});
|
|
22
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
23
|
+
T.killTmux();
|
|
24
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
25
|
+
console.log(`\n${results.length - bad}/${results.length} premium-vw-copy assertions passed`);
|
|
26
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
27
|
+
};
|
|
28
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
29
|
+
|
|
30
|
+
(async () => {
|
|
31
|
+
const exe = findBrowser();
|
|
32
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
33
|
+
let chromium;
|
|
34
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
35
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
36
|
+
await T.waitForServer(BASE);
|
|
37
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
38
|
+
|
|
39
|
+
const open = async ({ w = 1280, h = 900, theme = 'light' } = {}) => {
|
|
40
|
+
const ctx = await browser.newContext({ viewport: { width: w, height: h } });
|
|
41
|
+
const page = await ctx.newPage();
|
|
42
|
+
const S = { errors: [] };
|
|
43
|
+
page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
|
|
44
|
+
await page.route('**/api/briefing-premium*', (r) => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: B.build(F.facts()), as_of: Date.now() }) }));
|
|
45
|
+
await page.goto(BASE + '/premium.html?theme=' + theme);
|
|
46
|
+
S.up = await until(() => page.evaluate(() => document.querySelectorAll('#rank .rr .rhd').length > 0 && !!window.__premiumViewer), 20000);
|
|
47
|
+
return { page, ctx, S };
|
|
48
|
+
};
|
|
49
|
+
/* opens the first row that opens a dialog on this page (a row with its own page would navigate away) */
|
|
50
|
+
const openDialog = async (page) => {
|
|
51
|
+
const n = await page.evaluate(() => document.querySelectorAll('#rank .rr .rhd').length);
|
|
52
|
+
for (let i = 0; i < n; i++) {
|
|
53
|
+
const url = page.url();
|
|
54
|
+
await page.evaluate((k) => document.querySelectorAll('#rank .rr .rhd')[k].click(), i);
|
|
55
|
+
if (await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on')), 3000)) return true;
|
|
56
|
+
if (page.url() !== url) { await page.goBack(); await until(() => page.evaluate(() => document.querySelectorAll('#rank .rr .rhd').length > 0 && !!window.__premiumViewer), 20000); }
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
};
|
|
60
|
+
const st = (page) => page.evaluate(() => {
|
|
61
|
+
const t = document.querySelector('#vTabs'), m = document.querySelector('#oMain'), lab = document.querySelector('#oLab');
|
|
62
|
+
const vis = (e) => !!e && !e.hidden && getComputedStyle(e).display !== 'none';
|
|
63
|
+
return { ...window.__premiumViewer.vwState(), strip: vis(t), lab: vis(lab), main: vis(m), tabs: t ? [...t.querySelectorAll('.vtab')].map((x) => x.dataset.vw) : [],
|
|
64
|
+
sel: t ? [...t.querySelectorAll('.vtab[aria-selected="true"]')].map((x) => x.dataset.vw) : [], panes: [...document.querySelectorAll('#dOut .obody.vw')].map((p) => [p.dataset.vw, vis(p)]) };
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const URL_C = 'https://acme.atlassian.net/wiki/spaces/P/pages/1/Launch+plan', URL_G = 'https://docs.google.com/document/d/1abc/edit', URL_M = 'https://docs.google.com/document/d/9memo/edit';
|
|
68
|
+
const stand = async (page, S) => {
|
|
69
|
+
S.sig = 'same'; S.posts = []; S.read = { ok: true, read: null, open: null };
|
|
70
|
+
await page.route('**/api/docs?*', (r) => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ok: true, session: null, open: null, docs: [{ path: 'planning/launch.md', links: [
|
|
71
|
+
{ kind: 'confluence', signal: S.sig, words: 'x', checked_at: new Date().toISOString(), title: 'Launch plan', url: URL_C, target: URL_C },
|
|
72
|
+
{ kind: 'google', signal: 'behind', words: 'x', checked_at: new Date().toISOString(), remote_modified_at: new Date().toISOString(), title: 'Launch plan (Doc)', url: URL_G, target: URL_G }] }] }) }));
|
|
73
|
+
await page.route('**/api/doc?*', (r) => r.fulfill({ status: 200, contentType: 'text/markdown', body: '---\ntitle: Launch plan\n---\n\n## Goal\n\nOpen the beta to 40 accounts.\n' }));
|
|
74
|
+
await page.route('**/api/docs/read*', (r) => {
|
|
75
|
+
if (r.request().method() === 'POST') { S.posts.push(['read', JSON.parse(r.request().postData() || '{}')]); S.read = { ok: true, read: null, open: { run: 'r-abcdef', started_at: new Date().toISOString() } }; return r.fulfill({ status: 200, contentType: 'application/json', body: '{"ok":true,"session":"s1","run":"r-abcdef"}' }); }
|
|
76
|
+
return r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(S.read) });
|
|
77
|
+
});
|
|
78
|
+
await page.route('**/api/docs/sync', (r) => { S.posts.push(['sync', JSON.parse(r.request().postData() || '{}')]); return r.fulfill({ status: 200, contentType: 'application/json', body: '{"ok":true,"session":"s2"}' }); });
|
|
79
|
+
await page.route('**/api/docs/check', (r) => { S.posts.push(['check', {}]); return r.fulfill({ status: 200, contentType: 'application/json', body: '{"ok":true,"session":"s3"}' }); });
|
|
80
|
+
};
|
|
81
|
+
const openCopy = (page, o) => page.evaluate((x) => import('/pm/premium-vw-copies.js').then((m) => { m.openCopy(x); }), o);
|
|
82
|
+
const shown = (page) => page.evaluate(() => { const p = document.querySelector('#dOut .obody.vw:not([hidden])'); return p ? p.innerText : ''; });
|
|
83
|
+
|
|
84
|
+
/* R11 desktop */
|
|
85
|
+
{
|
|
86
|
+
const { page, ctx, S } = await open();
|
|
87
|
+
await stand(page, S);
|
|
88
|
+
ok('R11 a row opens the dialog', await openDialog(page));
|
|
89
|
+
await openCopy(page, { ws: '', path: 'planning/launch.md', kind: 'confluence', url: URL_C, title: 'Launch plan' });
|
|
90
|
+
ok('R11 a matching copy shows "Same as PMOS" and the PMOS file as the page', await until(async () => { const t = await shown(page); return /Same as PMOS/.test(t) && /Open the beta to 40 accounts/.test(t); }), await shown(page));
|
|
91
|
+
ok('R11 a matching copy offers no write, only Check again and Open', await page.evaluate(() => { const p = document.querySelector('#dOut .obody.vw:not([hidden])'); return !p.querySelector('[data-cp="use"]') && !!p.querySelector('[data-cp="check"]') && !!p.querySelector('a[href*="atlassian"]'); }));
|
|
92
|
+
ok('R11 the stylesheet loads once', await until(() => page.evaluate(() => document.querySelectorAll('link[data-vw-css="copy"]').length === 1)));
|
|
93
|
+
await page.click('#dOut .obody.vw:not([hidden]) [data-cp="check"]');
|
|
94
|
+
ok('R11 Check again posts one check', await until(() => S.posts.some((p) => p[0] === 'check')));
|
|
95
|
+
await openCopy(page, { ws: '', path: 'planning/launch.md', kind: 'google', url: URL_G, title: 'Launch plan (Doc)' });
|
|
96
|
+
ok('R11 a changed copy says so and labels the text as the PMOS version, dimmed', await until(async () => { const t = await shown(page); return /changed after it last matched PMOS/.test(t) && /PMOS version/.test(t) && (await page.$('#dOut .obody.vw:not([hidden]) .cpv-page.dim')); }), await shown(page));
|
|
97
|
+
await page.click('#dOut .obody.vw:not([hidden]) [data-cp="use"]');
|
|
98
|
+
ok('R11 Use waits behind Undo', await until(async () => /five seconds/.test(await shown(page))));
|
|
99
|
+
await page.click('#dOut .obody.vw:not([hidden]) [data-cp="undo"]');
|
|
100
|
+
await sleep(5600);
|
|
101
|
+
ok('R11 Undo within five seconds posts no sync', !S.posts.some((p) => p[0] === 'sync'), JSON.stringify(S.posts));
|
|
102
|
+
await page.click('#dOut .obody.vw:not([hidden]) [data-cp="use"]');
|
|
103
|
+
ok('R11 without Undo the sync posts once, with use=copy, after five seconds', await until(() => S.posts.filter((p) => p[0] === 'sync').length === 1, 8000) && S.posts.find((p) => p[0] === 'sync')[1].use === 'copy', JSON.stringify(S.posts));
|
|
104
|
+
await openCopy(page, { ws: '', url: URL_M, kind: 'google', title: 'Pricing memo', where: 'material for Weekly sync' });
|
|
105
|
+
ok('R11 a link-only page says PMOS has only the address, with Read it now', await until(async () => { const t = await shown(page); return /PMOS has only the address/.test(t) && /Read it now/.test(t); }), await shown(page));
|
|
106
|
+
await page.click('#dOut .obody.vw:not([hidden]) [data-cp="read"]');
|
|
107
|
+
ok('R11 Read it now posts the page address once and shows that a session is reading', await until(async () => S.posts.filter((p) => p[0] === 'read').length === 1 && /is reading the page/.test(await shown(page))) && S.posts.find((p) => p[0] === 'read')[1].url === URL_M, JSON.stringify(S.posts));
|
|
108
|
+
S.read = { ok: true, open: null, read: { title: 'Pricing memo', text: '## Recommendation\n\nKeep the Pro tier.', read_at: new Date().toISOString(), by: 'doc-read', revision: '212' } };
|
|
109
|
+
ok('R11 when the read lands the text shows, with when and who read it', await until(async () => { const t = await shown(page); return /Keep the Pro tier/.test(t) && /Read today/.test(t) && /revision 212/.test(t); }, 12000), await shown(page));
|
|
110
|
+
ok('R11 four tabs at most: three copy tabs are open beside the main one', (await page.evaluate(() => window.__premiumViewer.vwState().ids.length)) === 3);
|
|
111
|
+
ok('R11 no page error', S.errors.length === 0, S.errors.join(' | '));
|
|
112
|
+
await ctx.close();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* R7 phone and dark theme */
|
|
116
|
+
{
|
|
117
|
+
const { page, ctx, S } = await open({ w: 390, h: 844, theme: 'dark' });
|
|
118
|
+
await stand(page, S);
|
|
119
|
+
ok('R7 a row opens the dialog at 390px', await openDialog(page));
|
|
120
|
+
await openCopy(page, { ws: '', path: 'planning/launch.md', kind: 'google', url: URL_G, title: 'Launch plan (Doc)' });
|
|
121
|
+
await until(() => page.$('#dOut .obody.vw:not([hidden]) [data-cp="use"]'));
|
|
122
|
+
const m = await page.evaluate(() => {
|
|
123
|
+
const p = document.querySelector('#dOut .obody.vw:not([hidden])'), bs = [...p.querySelectorAll('.cpv-acts .dmcta')].filter((b) => b.offsetParent);
|
|
124
|
+
return { minH: Math.min(...bs.map((b) => b.getBoundingClientRect().height)), n: bs.length, over: document.documentElement.scrollWidth > window.innerWidth, bg: getComputedStyle(p.querySelector('.cpv-page')).backgroundColor };
|
|
125
|
+
});
|
|
126
|
+
ok('R7 the view\'s buttons are at least 44px tall at 390px', m.n >= 2 && m.minH >= 44, JSON.stringify(m));
|
|
127
|
+
ok('R7 the page does not scroll sideways', !m.over, JSON.stringify(m));
|
|
128
|
+
ok('R7 in the dark theme the page is not a light card', (() => { const c = (m.bg.match(/\d+/g) || []).slice(0, 3).map(Number); return c.length === 3 && c[0] + c[1] + c[2] < 3 * 160; })(), m.bg);
|
|
129
|
+
ok('R7 no page error', S.errors.length === 0, S.errors.join(' | '));
|
|
130
|
+
await ctx.close();
|
|
131
|
+
}
|
|
132
|
+
finish();
|
|
133
|
+
})();
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* /api/doc-sheet routes and POST /api/doc-health/check. A draft has Issue it (POST /api/core-docs/issue) and, where the page asks for it, Draft it again.
|
|
4
4
|
* The caller gives the page's own facts: { ws(), scope(), rows(), reload(), noteKey(d), sub(), again }. */
|
|
5
5
|
import { pmPost } from './http.js';
|
|
6
|
+
import { openCopy } from './premium-vw-copies.js';
|
|
6
7
|
import { proposalsModel, relationsOf, copyKindOf, copyView, editBody, acceptBody, rejectBody, askBody, askLine, issueBody, mdHtml, sectionAttribution, revDiffHtml } from './premium-doc-edit.js';
|
|
7
8
|
import { $, $$, esc, openDlg, closeDlg, toast, loadThread, logHtml, turnA, ptx, kv, CHECK, CHEV, AI } from './premium-shell.js';
|
|
8
9
|
import { openDocPage } from './premium-vw-doc.js';
|
|
@@ -100,7 +101,7 @@ export function mountDocSheet(ctx) {
|
|
|
100
101
|
}
|
|
101
102
|
/** Copies in other tools: each linked copy with its state, a link to open it, Check now, and a box to link another. The sheet never writes to the copy; updating one stays in the console. */
|
|
102
103
|
function copiesHtml(s, cps) {
|
|
103
|
-
const rows = cps.map((c) => `<div class="dscr"><div><b>${esc(c.title)}</b><span class="chp ${c.tone}">${esc(c.state)}</span></div><small>${esc([c.tool, c.target].filter(Boolean).join(' · '))}</small><p class="note" style="margin:4px 0 0">${esc(c.words)}${c.checked ? ' Last checked ' + esc(when(c.checked)) + '.' : ' Not checked yet.'}</p
|
|
104
|
+
const rows = cps.map((c, i) => `<div class="dscr"><div><b>${esc(c.title)}</b><span class="chp ${c.tone}">${esc(c.state)}</span></div><small>${esc([c.tool, c.target].filter(Boolean).join(' · '))}</small><p class="note" style="margin:4px 0 0">${esc(c.words)}${c.checked ? ' Last checked ' + esc(when(c.checked)) + '.' : ' Not checked yet.'}</p><button type="button" class="lk" data-ds="cpview:${i}">Preview</button> ${c.url ? `<a class="lk" href="${esc(c.url)}" target="_blank" rel="noopener">Open in ${esc(c.tool)}</a>` : ''}</div>`).join('');
|
|
104
105
|
return `<div class="dscp" data-copies><p class="label">Copies in other tools</p>${rows || '<p class="note">This document has no copy in Confluence or Google Docs yet. Link one to see whether it is in step.</p>'}`
|
|
105
106
|
+ `<div class="dsrow"><input id="dsCpUrl" class="dsy" type="text" placeholder="Paste a Confluence page or Google Doc link" aria-label="Address of the copy" value="${esc(s.cpUrl || '')}"><button class="dmcta dark" data-ds="cplink">Link</button>${cps.length ? `<button class="dmcta alt" data-ds="cpcheck"${s.checkRun ? ' disabled' : ''}>${s.checkRun ? 'Checking' : 'Check now'}</button>` : ''}</div>`
|
|
106
107
|
+ `${s.cpMsg ? `<p class="note" role="alert" style="margin:6px 0 0;color:var(--ember-ink)">${esc(s.cpMsg)}</p>` : ''}<p class="note" style="margin:8px 0 0">PMOS never writes to a copy from this sheet. Check now starts one agent session that reads the copies with your connectors. Updating a copy is in the console.</p></div>`;
|
|
@@ -224,6 +225,7 @@ export function mountDocSheet(ctx) {
|
|
|
224
225
|
if (act === 'meta') { s.meta = !s.meta; drawSheet(); return; }
|
|
225
226
|
if (act === 'page') { openPage({ path: s.d.path, title: s.d.title, iniName: s.d.iniName }); return; }
|
|
226
227
|
if (act === 'cp') { s.cp = !s.cp; s.cpMsg = ''; drawSheet(); return; }
|
|
228
|
+
if (act.startsWith('cpview:')) { const l = (s.copies || [])[+act.slice(7)]; if (l) openCopy({ ws: ctx.ws(), path: s.d.path, kind: l.kind, url: l.url || l.target, title: l.title || s.d.title }); return; }
|
|
227
229
|
if (act === 'cplink') {
|
|
228
230
|
const t = String(s.cpUrl || '').trim(), kind = copyKindOf(t);
|
|
229
231
|
if (!kind) { s.cpMsg = 'Paste a Confluence page or Google Doc link.'; drawSheet(); const f = $('#dsCpUrl'); if (f) f.focus(); return; }
|
|
@@ -123,7 +123,7 @@ export function meetingView(row, replay, material, extra) {
|
|
|
123
123
|
notesLine: S ? '' : !replay ? 'Reading the notes.' : replay.state === 'error' ? 'The notes could not be read: ' + clip(replay.error, 120) : replay.state === 'none' ? 'No notes for this meeting.' : '',
|
|
124
124
|
brief: (extra && extra.brief) || null,
|
|
125
125
|
replay: rep && (rep.audio || heard) ? { minutes: heard, keyPoints: keys.length, lines: Array.isArray(rep.lines) ? rep.lines.length : 0 } : null,
|
|
126
|
-
material: material && material.state === 'ok' ? (material.items || []).map((i, n) => ({ n, title: clip(i.title || i.ref || i.url, 120), kind: i.kind || '', topic: clip(i.topic, 80), scope: i.scope === 'series' ? 'every meeting of this series' : 'this meeting', removable: i.from === 'you' && (i.scope === 'series' || i.scope === 'meeting'), line: removeLine(i) })) : null,
|
|
126
|
+
material: material && material.state === 'ok' ? (material.items || []).map((i, n) => ({ n, title: clip(i.title || i.ref || i.url, 120), kind: i.kind || '', topic: clip(i.topic, 80), scope: i.scope === 'series' ? 'every meeting of this series' : 'this meeting', removable: i.from === 'you' && (i.scope === 'series' || i.scope === 'meeting'), line: removeLine(i), preview: (i.kind === 'gdoc' || i.kind === 'conf') && /^https:\/\//.test(i.url || '') ? { url: i.url, kind: i.kind === 'conf' ? 'confluence' : 'google' } : null })) : null,
|
|
127
127
|
...prepOf(row, people, material, extra, aboutOf(row.level)),
|
|
128
128
|
materialLine: !material ? 'Reading the material.' : material.state === 'error' ? 'The material could not be read: ' + clip(material.error, 120) : (material.items || []).length ? '' : 'No material is linked to this meeting.',
|
|
129
129
|
row,
|
|
@@ -511,7 +511,7 @@ export function mountMeeting(d) {
|
|
|
511
511
|
const prow = (x) => `<div class="prow"><span class="pi${x.ok ? '' : ' w'}">${ic(x.ic)}</span><div><b>${esc(x.l)}</b><div class="pv">${x.about && aboutNow ? '<span>It is about <b>' + esc(aboutNow) + '</b>.</span>' : x.people ? x.people.map(person).join('') : x.chips && x.chips.length ? x.chips.map((c) => `<span class="chp sm">${ic('doc')}${esc(c)}</span>`).join('') : '<span>' + esc(x.text) + '</span>'}</div></div>${x.ok ? '<span class="chp ok sm"><i></i>Ready</span>' : '<span class="chp warn sm"><i></i>Not yet</span>'}</div>`;
|
|
512
512
|
const ready = v.prepReady;
|
|
513
513
|
const prep = secH('Prepared for you', ready === v.prep.length ? 'all ready' : ready + ' of ' + v.prep.length + ' ready') + `<div class="prows">${v.prep.map(prow).join('')}</div>`;
|
|
514
|
-
const mats = v.materialLine ? `<p class="mut">${esc(v.materialLine)}</p>` : `<div class="mats">${v.material.map((m) => `<div class="mat"><span class="kd">${esc(m.kind || 'link')}</span><div><b>${esc(m.title)}</b><small>${esc([m.topic, 'for ' + m.scope].filter(Boolean).join(' · '))}</small></div><span class="mb">${m.removable ? `<button class="ib2 mtg-rm" data-rm="${m.n}" aria-label="Remove ${esc(m.title)}" title="${esc(m.line)}">${ic('x')}</button>` : ''}</span></div>`).join('')}</div>`;
|
|
514
|
+
const mats = v.materialLine ? `<p class="mut">${esc(v.materialLine)}</p>` : `<div class="mats">${v.material.map((m) => `<div class="mat"><span class="kd">${esc(m.kind || 'link')}</span><div><b>${esc(m.title)}</b><small>${esc([m.topic, 'for ' + m.scope].filter(Boolean).join(' · '))}</small></div><span class="mb">${m.preview ? `<button class="ib2 mtg-pv" data-mpv="${m.n}" aria-label="Preview ${esc(m.title)}" title="Preview in the viewer">${ic('doc')}</button>` : ''}${m.removable ? `<button class="ib2 mtg-rm" data-rm="${m.n}" aria-label="Remove ${esc(m.title)}" title="${esc(m.line)}">${ic('x')}</button>` : ''}</span></div>`).join('')}</div>`;
|
|
515
515
|
const mat = secH('Material', v.material && v.material.length ? v.material.length + ' linked' : '', `<button class="addb" id="mmAdd" title="Your calendar invite is not changed.">${ic('plus')}Add material</button>`) + mats;
|
|
516
516
|
const prev = secH('Previous meetings', v.prev.length ? v.prev.length + ' before this' : '') + (v.prev.length ? `<div class="prevs">${v.prev.map((p) => `<div class="pvx"><div class="pvh"><time>${esc(p.date)}</time><span>${p.decided} decided</span><span>${p.steps} new next ${p.steps === 1 ? 'step' : 'steps'}</span></div></div>`).join('')}</div>` : '<p class="mut">No earlier notes of this meeting are kept.</p>');
|
|
517
517
|
const tops = secH('Topics', v.planned.length ? 'planned' : '') + (v.planned.length ? `<div class="tops">${v.planned.map((t, i) => `<div class="tp plan"><i>${i + 1}</i><span>${esc(clip(t.text, 120))}</span><small>planned</small></div>`).join('')}</div>` : '<p class="mut">The meeting has no topics yet.</p>');
|
|
@@ -831,6 +831,7 @@ export function mountMeeting(d) {
|
|
|
831
831
|
if ($('#mmAdd')) $('#mmAdd').focus();
|
|
832
832
|
return;
|
|
833
833
|
}
|
|
834
|
+
if (t.dataset.mpv !== undefined) { const m = (meetingView(row, replay, material, extra).material || [])[+t.dataset.mpv]; if (m && m.preview) import('./premium-vw-copies.js').then((V) => V.openCopy({ ws: d.ws(), url: m.preview.url, kind: m.preview.kind, title: m.title, where: 'material for ' + row.title })); return; }
|
|
834
835
|
if (t.dataset.rm !== undefined) { const it = ((material && material.items) || [])[+t.dataset.rm]; if (it) await removeItem(it); return; }
|
|
835
836
|
if (t.dataset.task !== undefined) { t.disabled = true; await makeTask(+t.dataset.task); if (!ui.tasked.has(+t.dataset.task)) paint(); return; }
|
|
836
837
|
if (t.id === 'mtgUndo') { const fn = undoFn; undoFn = null; if (fn) await fn(); return; }
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/* pm/premium-vw-copies.js — a Confluence page or Google Doc in the premium viewer (initiative premium-viewer, R11).
|
|
2
|
+
* PMOS never reads either tool from a route (D53), so the view shows only what a record holds:
|
|
3
|
+
* a copy linked to a PMOS file → GET /api/docs (the link and its signal) + GET /api/doc (the file). When the last check found the same text,
|
|
4
|
+
* the file is the page's text. When the copy changed, the file is shown dimmed and labelled as the PMOS version,
|
|
5
|
+
* with Use the copy's version (POST /api/docs/sync use=copy, held five seconds behind Undo) and Check again.
|
|
6
|
+
* a page PMOS only links to → GET /api/docs/read (the last read, if any). Read it now (POST /api/docs/read) starts one read-only session
|
|
7
|
+
* that reads the page with the PM's connector and keeps the text; nothing is written to the tool.
|
|
8
|
+
* openCopy({ ws, url, kind?, title?, path?, where? }) opens or refreshes the tab
|
|
9
|
+
* copyModel(link, text) · readModel(answer) the pure models (premium-vw-copy.test.js) */
|
|
10
|
+
import { vwOpen, vwStyle } from './premium-viewer.js';
|
|
11
|
+
import { pmGet, pmPost } from './http.js';
|
|
12
|
+
import { mdHtml, copyKindOf } from './premium-doc-edit.js';
|
|
13
|
+
|
|
14
|
+
const TOOL = { google: 'Google Docs', confluence: 'Confluence', 'google-slides': 'Google Slides', 'google-sheets': 'Google Sheets' };
|
|
15
|
+
const COPY = { google: 'the Google Doc', confluence: 'the Confluence page', 'google-slides': 'the slides', 'google-sheets': 'the sheet' };
|
|
16
|
+
const UNDO_MS = 5000;
|
|
17
|
+
const POLL_MS = 4000;
|
|
18
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
19
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
20
|
+
/** "today 14:02", or "12 Oct 14:02". Local time, as the rest of the premium pages show it. */
|
|
21
|
+
export function when(iso, now = Date.now()) {
|
|
22
|
+
const t = Date.parse(iso || ''); if (Number.isNaN(t)) return '';
|
|
23
|
+
const d = new Date(t), n = new Date(now), hm = String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0');
|
|
24
|
+
return d.toDateString() === n.toDateString() ? 'today ' + hm : d.getDate() + ' ' + MON[d.getMonth()] + ' ' + hm;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A linked copy as the view draws it. `link` is one link of GET /api/docs; `text` is the PMOS file or null. */
|
|
28
|
+
export function copyModel(link, text, now) {
|
|
29
|
+
const kind = link && link.kind, tool = TOOL[kind] || 'the other tool', it = COPY[kind] || 'the copy', sig = (link && link.signal) || 'unchecked';
|
|
30
|
+
const checked = link && link.checked_at ? when(link.checked_at, now) : '';
|
|
31
|
+
const base = { kind, tool, title: (link && link.title) || tool, url: (link && link.url) || '', checked, syncing: !!(link && link.syncing), text: text == null ? null : String(text) };
|
|
32
|
+
const meta = [tool, link && link.remote_modified_at ? 'edited there ' + when(link.remote_modified_at, now) : '', checked ? 'checked ' + checked : 'not checked yet'].filter(Boolean).join(' · ');
|
|
33
|
+
if (sig === 'same') return { ...base, sig, tone: 'ok', chip: 'Same as PMOS', head: 'Same as PMOS', meta, why: `The last check found the same text in PMOS and in ${it}, so this is the page's text.`, dim: false, use: false };
|
|
34
|
+
if (sig === 'behind' || sig === 'diverged') {
|
|
35
|
+
return { ...base, sig, tone: 'warn', chip: sig === 'behind' ? 'Changed in ' + tool : 'Changed in both', meta, dim: true, use: true,
|
|
36
|
+
head: sig === 'behind' ? `${it[0].toUpperCase() + it.slice(1)} changed after it last matched PMOS.` : `Both ${it} and PMOS changed after they last matched.`,
|
|
37
|
+
why: `Below is the PMOS version, not the text of ${it}. Use its version to write that text into the PMOS file.` };
|
|
38
|
+
}
|
|
39
|
+
if (sig === 'ahead') return { ...base, sig, tone: 'warn', chip: 'PMOS is ahead', head: 'PMOS has changes the copy does not have.', meta, why: `Below is the PMOS version. ${it[0].toUpperCase() + it.slice(1)} still has the older text.`, dim: false, use: false };
|
|
40
|
+
const words = { unchecked: 'No check has read this copy yet.', unreadable: 'The last check could not open the copy.', 'missing-remote': `${it[0].toUpperCase() + it.slice(1)} is not there any more.`, 'missing-repo': 'The PMOS file is not in the repository any more.' };
|
|
41
|
+
return { ...base, sig, tone: '', chip: (link && link.words) || 'Not checked', head: words[sig] || (link && link.words) || 'Not compared yet.', meta, why: 'Below is the PMOS version. It is not known whether the copy has the same text.', dim: false, use: false };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The answer of GET /api/docs/read as the view draws it: the last read, a read in progress, or nothing yet. */
|
|
45
|
+
export function readModel(a, now) {
|
|
46
|
+
if (!a || a.ok === false) return { state: 'error', error: (a && a.error) || 'The last read could not be loaded.' };
|
|
47
|
+
if (a.open) return { state: 'reading', since: when(a.open.started_at, now) };
|
|
48
|
+
const r = a.read;
|
|
49
|
+
if (!r || r.text == null) return a.failed ? { state: 'none', failed: a.failed.reason || 'no reason was given' } : { state: 'none' };
|
|
50
|
+
return { state: 'read', title: r.title || '', text: String(r.text), at: when(r.read_at, now), by: r.by || 'a session', revision: r.revision || '' };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const ICON = (k) => `<span class="cpv-lg" aria-hidden="true">${k === 'confluence' ? 'C' : 'G'}</span>`;
|
|
54
|
+
const ext = (url, tool) => (url ? `<a class="dmcta alt" href="${esc(url)}" target="_blank" rel="noopener noreferrer">Open in ${esc(tool)}</a>` : '');
|
|
55
|
+
const page = (text, dim) => { const m = mdHtml(text); return `<div class="cpv-page dsbody${dim ? ' dim' : ''}">${m.html}</div>`; };
|
|
56
|
+
|
|
57
|
+
/** Open one page in the viewer. With `path`, it is a copy linked to that PMOS file; without, a page PMOS only has the address of. */
|
|
58
|
+
export function openCopy(o) {
|
|
59
|
+
if (!o || !o.url) return null;
|
|
60
|
+
vwStyle('copy');
|
|
61
|
+
const kind = o.kind || copyKindOf(o.url) || 'google';
|
|
62
|
+
const id = 'copy:' + (o.path ? o.path + '|' + kind : o.url);
|
|
63
|
+
const S = { o: { ...o, kind }, model: null, read: null, err: '', wait: null, poll: null, busy: false };
|
|
64
|
+
const wsq = () => (o.ws ? 'ws=' + encodeURIComponent(o.ws) + '&' : '');
|
|
65
|
+
let pane = null;
|
|
66
|
+
const tok = String(Date.now()) + Math.random();
|
|
67
|
+
const live = () => !!(pane && pane.isConnected && pane.dataset.cpTok === tok);
|
|
68
|
+
const draw = () => { if (live()) pane.innerHTML = html(); };
|
|
69
|
+
function html() {
|
|
70
|
+
const tool = TOOL[kind] || 'the tool', t = esc(o.title || S.model && S.model.title || tool);
|
|
71
|
+
if (S.err) return `<div class="cpv"><div class="cpv-bar">${ICON(kind)}<div><b>${t}</b><small>${esc(tool)}</small></div></div><p class="note">${esc(S.err)}</p><div class="cpv-acts">${ext(o.url, tool)}</div></div>`;
|
|
72
|
+
if (o.path) {
|
|
73
|
+
const m = S.model; if (!m) return `<div class="cpv"><p class="note">Reading the copy and the PMOS file.</p></div>`;
|
|
74
|
+
const acts = S.wait ? `<button type="button" class="dmcta alt" data-cp="undo">Undo</button><span class="note">Using the version in ${esc(TOOL[kind])} in five seconds.</span>`
|
|
75
|
+
: `${m.use && !m.syncing ? `<button type="button" class="dmcta" data-cp="use">Use the ${esc(TOOL[kind])} version</button>` : ''}<button type="button" class="dmcta alt" data-cp="check"${S.busy ? ' disabled' : ''}>${S.busy ? 'Checking' : 'Check again'}</button>${ext(m.url || o.url, m.tool)}`;
|
|
76
|
+
return `<div class="cpv"><div class="cpv-bar ${m.tone}">${ICON(kind)}<div><b>${esc(m.head)}</b><small>${esc(m.meta)}</small></div><span class="chp ${m.tone}"><i></i>${esc(m.syncing ? 'Updating' : m.chip)}</span></div>`
|
|
77
|
+
+ `<p class="note cpv-why">${esc(m.syncing ? 'A session is writing the copy\'s text into the PMOS file.' : m.why)} File: <code>${esc(o.path)}</code></p><div class="cpv-acts">${acts}</div>`
|
|
78
|
+
+ (m.text == null ? '<p class="note">The PMOS file could not be read.</p>' : page(m.text, m.dim)) + '</div>';
|
|
79
|
+
}
|
|
80
|
+
const r = S.read || { state: 'loading' }, where = o.where ? ' · ' + esc(o.where) : '';
|
|
81
|
+
if (r.state === 'loading') return `<div class="cpv"><p class="note">Reading what PMOS holds for this page.</p></div>`;
|
|
82
|
+
if (r.state === 'read') {
|
|
83
|
+
return `<div class="cpv"><div class="cpv-bar">${ICON(kind)}<div><b>Read ${esc(r.at)} by ${esc(r.by)}</b><small>${esc(tool)}${r.revision ? ' · revision ' + esc(r.revision) : ''} · view only${where}</small></div><span class="chp"><i></i>Read</span></div>`
|
|
84
|
+
+ `<p class="note cpv-why">This is the text as it was when it was read. Edits made in ${esc(tool)} after that show after you read it again.</p>`
|
|
85
|
+
+ `<div class="cpv-acts"><button type="button" class="dmcta alt" data-cp="read"${S.busy ? ' disabled' : ''}>Read again</button>${ext(o.url, tool)}</div>${page(r.text, false)}</div>`;
|
|
86
|
+
}
|
|
87
|
+
const head = `<div class="cpv-bar">${ICON(kind)}<div><b>${t}</b><small>${esc(tool)}${where}</small></div><span class="chp"><i></i>${r.state === 'reading' ? 'Reading' : 'Link only'}</span></div>`;
|
|
88
|
+
if (r.state === 'reading') return `<div class="cpv">${head}<p class="note">A session is reading the page with your ${esc(tool)} connector${r.since ? ' (started ' + esc(r.since) + ')' : ''}. The text shows here when it is done.</p><div class="cpv-acts">${ext(o.url, tool)}</div></div>`;
|
|
89
|
+
return `<div class="cpv">${head}<div class="cpv-empty"><b>PMOS has only the address of this page.</b><p>It was added as a link, so PMOS holds no text to show here.</p>`
|
|
90
|
+
+ `<div class="cpv-acts">${r.state === 'none' ? `<button type="button" class="dmcta" data-cp="read"${S.busy ? ' disabled' : ''}>Read it now</button>` : ''}${ext(o.url, tool)}</div>`
|
|
91
|
+
+ `<p class="note">${r.state === 'error' ? esc(r.error) : r.failed ? 'The last read did not finish: ' + esc(r.failed) + '. Press Read it now to try again.' : `Read it now starts one session that reads the page with your ${esc(tool)} connector and keeps the text in PMOS. It changes nothing in ${esc(tool)}.`}</p></div></div>`;
|
|
92
|
+
}
|
|
93
|
+
async function load() {
|
|
94
|
+
S.err = '';
|
|
95
|
+
if (o.path) {
|
|
96
|
+
const [d, f] = await Promise.all([pmGet('/api/docs?' + wsq()).catch(() => null), fetch('/api/doc?' + wsq() + 'path=' + encodeURIComponent(o.path), { credentials: 'same-origin' }).then((r) => (r.ok ? r.text() : null)).catch(() => null)]);
|
|
97
|
+
const doc = d && d.ok !== false ? (d.docs || []).find((x) => x.path === o.path) : null, link = doc ? (doc.links || []).find((l) => l.kind === kind) : null;
|
|
98
|
+
if (!link) S.err = d && d.ok !== false ? 'This copy is no longer linked to ' + o.path + '.' : 'The copies could not be read.';
|
|
99
|
+
else S.model = copyModel(link, f);
|
|
100
|
+
S.busy = !!(d && (d.session || d.open));
|
|
101
|
+
} else {
|
|
102
|
+
S.read = readModel(await pmGet('/api/docs/read?' + wsq() + 'url=' + encodeURIComponent(o.url)).catch(() => null));
|
|
103
|
+
clearTimeout(S.poll);
|
|
104
|
+
if (S.read.state === 'reading') S.poll = setTimeout(() => { if (live()) load(); }, POLL_MS);
|
|
105
|
+
}
|
|
106
|
+
draw();
|
|
107
|
+
}
|
|
108
|
+
async function press(a) {
|
|
109
|
+
if (a === 'undo') { clearTimeout(S.wait); S.wait = null; draw(); return; }
|
|
110
|
+
if (a === 'use') {
|
|
111
|
+
S.wait = setTimeout(async () => {
|
|
112
|
+
S.wait = null; draw();
|
|
113
|
+
const r = await pmPost('/api/docs/sync', { ws: o.ws, path: o.path, kind, use: 'copy' }).catch(() => null);
|
|
114
|
+
if (!r || !r.ok) S.err = (r && r.error) || 'The sync did not start.';
|
|
115
|
+
load();
|
|
116
|
+
}, UNDO_MS);
|
|
117
|
+
draw(); return;
|
|
118
|
+
}
|
|
119
|
+
if (a === 'check') { S.busy = true; draw(); const r = await pmPost('/api/docs/check', { ws: o.ws }).catch(() => null); if (r && !r.ok && !/already running/.test(r.error || '')) S.err = r.error || 'The check did not start.'; load(); return; }
|
|
120
|
+
if (a === 'read') {
|
|
121
|
+
S.busy = true; draw();
|
|
122
|
+
const r = await pmPost('/api/docs/read', { ws: o.ws, url: o.url }).catch(() => null);
|
|
123
|
+
S.busy = false;
|
|
124
|
+
if (!r || !r.ok) { S.read = { state: 'error', error: (r && r.error) || 'The read did not start.' }; draw(); return; }
|
|
125
|
+
S.read = { state: 'reading', since: '' }; draw(); clearTimeout(S.poll); S.poll = setTimeout(() => { if (live()) load(); }, POLL_MS);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
pane = vwOpen({ id, title: o.title || TOOL[kind] || 'Page', icon: 'doc', html: html(),
|
|
129
|
+
wire: (el) => { el.onclick = (e) => { const b = e.target.closest('[data-cp]'); if (b) press(b.dataset.cp); }; } }); // delegated to the view's buttons
|
|
130
|
+
if (pane) pane.dataset.cpTok = tok;
|
|
131
|
+
load();
|
|
132
|
+
return pane;
|
|
133
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@font-face{font-family:"Space Grotesk";src:url(/vendor/space-grotesk-var.woff2) format("woff2");font-weight:300 700;font-display:swap}
|
|
2
|
+
@font-face{font-family:"IBM Plex Mono";src:url(/vendor/ibm-plex-mono-400.woff2) format("woff2");font-weight:400;font-display:swap}
|
|
3
|
+
@font-face{font-family:"IBM Plex Mono";src:url(/vendor/ibm-plex-mono-500.woff2) format("woff2");font-weight:500;font-display:swap}
|
|
4
|
+
@font-face{font-family:"IBM Plex Mono";src:url(/vendor/ibm-plex-mono-700.woff2) format("woff2");font-weight:600 700;font-display:swap}
|
|
5
|
+
:root{--fs-1:11px;--fs-2:12px;--fs-3:14px;--fs-4:16px;--fs-5:20px;--fs-6:28px}
|
|
6
|
+
/* pm/premium-vw-copy.css — a Confluence page or Google Doc in the premium viewer (premium-vw-copies.js, premium-viewer R11). Loaded by vwStyle('copy'). */
|
|
7
|
+
.cpv{display:grid;gap:12px;max-width:760px}
|
|
8
|
+
.cpv-bar{display:flex;align-items:center;gap:12px;padding:12px 14px;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid);box-shadow:var(--card-shadow)}
|
|
9
|
+
.cpv-bar.warn{background:color-mix(in oklab,var(--ember) 12%,var(--card-solid))}
|
|
10
|
+
.cpv-bar>div{flex:1;min-width:0;display:grid;gap:2px}
|
|
11
|
+
.cpv-bar b{font-size:var(--fs-3);font-weight:600;color:var(--ink)}
|
|
12
|
+
.cpv-bar small{font-size:var(--fs-2);color:var(--ink-3)}
|
|
13
|
+
.cpv-lg{width:28px;height:28px;flex:none;display:grid;place-items:center;border-radius:6px;background:var(--well);color:var(--ink);font-size:var(--fs-2);font-weight:600}
|
|
14
|
+
.cpv-why{margin:0}
|
|
15
|
+
.cpv-why code{font-size:var(--fs-2)}
|
|
16
|
+
.cpv-acts{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
|
|
17
|
+
.cpv-acts .dmcta{border-radius:6px;text-decoration:none}
|
|
18
|
+
.cpv-empty{display:grid;gap:8px;padding:18px 20px;border:1px dashed var(--ink-3);border-radius:8px;color:var(--ink-2)}
|
|
19
|
+
.cpv-empty b{font-size:var(--fs-4);font-weight:600;color:var(--ink)}
|
|
20
|
+
.cpv-empty p{margin:0;font-size:var(--fs-3)}
|
|
21
|
+
.cpv-page{padding:18px 22px;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid)}
|
|
22
|
+
.cpv-page.dim{opacity:.62}
|
|
23
|
+
@media (max-width:700px){
|
|
24
|
+
.cpv-bar{flex-wrap:wrap}
|
|
25
|
+
.cpv-acts .dmcta{min-height:44px}
|
|
26
|
+
.cpv-page{padding:14px}
|
|
27
|
+
}
|
package/workspace/server.js
CHANGED
|
@@ -153,6 +153,9 @@ const docCheckSessions = new Map();
|
|
|
153
153
|
// The session each Use … version press started (workspace id|path|kind → { session, use }), so the line says "Updating…"
|
|
154
154
|
// before the session has opened its sync, and a second press on the same copy refuses.
|
|
155
155
|
const docSyncSessions = new Map();
|
|
156
|
+
// The session each Read it now press started (workspace id|<kind>:<page id> → { session, run }): one read per page.
|
|
157
|
+
const docReadSessions = new Map();
|
|
158
|
+
const docReadsStore = require('./lib/doc-reads-store'); // Read it now: doc-reads.jsonl, the read-only snapshot of one page
|
|
156
159
|
const docGraphs = new Map(); // root -> { at, graph }: the document tab's Connections, held 15 s
|
|
157
160
|
const jiraTickets = require('./lib/jira-tickets.js'); // jira-wbs — the ticket draft, the PM's selection, the push plan
|
|
158
161
|
const jiraStatus = require('./lib/jira-status.js'); // …and the status snapshot an agent's read writes
|
|
@@ -7658,6 +7661,45 @@ async function handleRequest(req, res) {
|
|
|
7658
7661
|
const linked = new Set(v.ok ? v.docs.map((d) => d.path) : []);
|
|
7659
7662
|
return json(res, { ok: true, files: found.filter((f) => !linked.has(f.path)) });
|
|
7660
7663
|
}
|
|
7664
|
+
// Read it now: a read-only snapshot of one Google Doc or Confluence page, by address. GET answers the latest read
|
|
7665
|
+
// from doc-reads.jsonl. POST (a page press only) starts one `doc-read` session that reads the page with the PM's own
|
|
7666
|
+
// connector and records it through `pmos docs read-finish` (D53). No route reads the page.
|
|
7667
|
+
if (p === '/api/docs/read' && req.method === 'GET') {
|
|
7668
|
+
const w = getWs(url.searchParams.get('ws'));
|
|
7669
|
+
const root = w ? w.root : SELF_ROOT;
|
|
7670
|
+
const r = docReadsStore.latest(root, String(url.searchParams.get('url') || '').slice(0, 2000));
|
|
7671
|
+
if (!r.ok) return json(res, { ok: false, error: r.error }, r.code === 'kind' ? 400 : 500);
|
|
7672
|
+
const live = docReadSessions.get(`${w ? w.id : ''}|${require('./lib/doc-reads').keyOf(url.searchParams.get('url'))}`);
|
|
7673
|
+
const open = r.open && live && live.run === r.open.run ? { ...r.open, session: live.session } : r.open;
|
|
7674
|
+
return json(res, { ok: true, kind: r.kind, read: r.read, open, failed: r.failed });
|
|
7675
|
+
}
|
|
7676
|
+
if (p === '/api/docs/read' && req.method === 'POST') {
|
|
7677
|
+
let body = {}; try { body = JSON.parse((await readBody(req)) || '{}'); } catch { return json(res, { ok: false, error: 'invalid JSON body' }, 400); }
|
|
7678
|
+
const g = pmGuard.requirePagePress(req, body);
|
|
7679
|
+
if (!g.ok) return json(res, { ok: false, error: g.error }, g.status);
|
|
7680
|
+
// It uses the PM's connectors, so an agent session never presses it (the same 403 as create-copy).
|
|
7681
|
+
if (req.headers['x-pmos-session']) return json(res, { ok: false, error: 'an agent session cannot start a read. Only a press on the page does' }, 403);
|
|
7682
|
+
const w = body.ws ? workspaces.get(String(body.ws)) : getWs(null);
|
|
7683
|
+
if (!w) return json(res, { ok: false, error: 'no such workspace' }, 404);
|
|
7684
|
+
const address = String(body.url || '').trim().slice(0, 2000);
|
|
7685
|
+
const docReads = require('./lib/doc-reads');
|
|
7686
|
+
const kind = docReads.kindOf(address);
|
|
7687
|
+
if (!kind) return json(res, { ok: false, error: 'give the address of a Google Doc or a Confluence page (Slides and Sheets are not read yet)' }, 400);
|
|
7688
|
+
const key = `${w.id}|${docReads.keyOf(address)}`;
|
|
7689
|
+
const prev = docReadSessions.get(key);
|
|
7690
|
+
if (prev && sessions.get(prev.session) && sessions.get(prev.session).state !== 'exited') return json(res, { ok: false, error: 'that page is already being read', session: prev.session }, 409);
|
|
7691
|
+
const task = taskById('doc-read', w.root);
|
|
7692
|
+
if (!task || !task.prompt) return json(res, { ok: false, error: 'the doc-read skill is not installed' }, 500);
|
|
7693
|
+
const st = docReadsStore.readStart(w.root, { url: address, by: 'page:pm' });
|
|
7694
|
+
if (!st.ok) return json(res, { ok: false, error: st.error }, st.code === 'open' ? 409 : st.code === 'kind' ? 400 : 500);
|
|
7695
|
+
const ask = `\n\nThis read:\n- address: ${address}\n- kind: ${kind}\n- read: ${st.run}`;
|
|
7696
|
+
const s = spawnSession({ name: 'Doc read', agent: task.agent || 'claude', ws: w.id, origin: 'docs:read',
|
|
7697
|
+
initialInput: task.prompt + ask + '\r', modelAsk: { skillTier: task.tier || null, skill: task.skill } });
|
|
7698
|
+
const started = s.state !== 'exited';
|
|
7699
|
+
if (started) docReadSessions.set(key, { session: s.id, run: st.run, at: new Date().toISOString() });
|
|
7700
|
+
else docReadsStore.readFail(w.root, { run: st.run, by: 'page:pm', reason: s.note || 'could not start the session' });
|
|
7701
|
+
return json(res, { ok: started, session: s.id, run: st.run, error: started ? undefined : (s.note || 'could not start the session') }, started ? 200 : 500);
|
|
7702
|
+
}
|
|
7661
7703
|
if ((p === '/api/docs/link' || p === '/api/docs/unlink' || p === '/api/docs/check' || p === '/api/docs/sync' || p === '/api/docs/create-copy') && req.method === 'POST') {
|
|
7662
7704
|
let body = {}; try { body = JSON.parse((await readBody(req)) || '{}'); } catch { return json(res, { ok: false, error: 'invalid JSON body' }, 400); }
|
|
7663
7705
|
const g = pmGuard.requirePagePress(req, body);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: doc-read
|
|
3
|
+
label: "Read one Google Doc or Confluence page now"
|
|
4
|
+
description: "Read one Google Doc or Confluence page with the PM's connector, convert it to markdown and record it. Read-only: it writes no document, page, comment or file."
|
|
5
|
+
run: agent
|
|
6
|
+
agent: claude
|
|
7
|
+
output:
|
|
8
|
+
- Read
|
|
9
|
+
- Not read
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
/doc-read — the PM pressed "Read it now" for ONE page. Read that page, record its text, and stop. The lines after this procedure give the address, the kind and the read id.
|
|
13
|
+
|
|
14
|
+
A page is one of two kinds: `google` (a Google Doc) or `confluence` (a Confluence page).
|
|
15
|
+
|
|
16
|
+
Rules that always hold:
|
|
17
|
+
1. READ-ONLY EVERYWHERE. Never create, update, move, rename, comment on, share or delete a Google Doc, a Drive file or a Confluence page. Never edit, create or delete a file in this repository. Never commit or push.
|
|
18
|
+
2. ONE PAGE. Read only the page at the address below. Do not read its child pages, its comments or the pages it links to.
|
|
19
|
+
3. THE ONLY RECORDS are `pmos docs read-start`, `pmos docs read-finish` and `pmos docs read-fail`. Never write a `*.jsonl` file by hand.
|
|
20
|
+
4. USE THE PM'S CONNECTORS. Google Docs: the Google Drive tools (`read_file_content`, and the file metadata). Confluence: the Atlassian tools (`getConfluencePage`, with its version). If the connector is missing or refuses, record the read as failed with the error.
|
|
21
|
+
5. KEEP THE DOCUMENT. Convert the page to markdown faithfully: the same headings, paragraphs, lists, tables and links, in the same order. Do not add a summary, a note or a heading of your own.
|
|
22
|
+
|
|
23
|
+
Procedure:
|
|
24
|
+
1. If the lines below give a `read` id, use it. If not, run `pmos docs read-start "<address>" --json` and keep `run`. If it is refused (for example, the page is already being read), stop and say why.
|
|
25
|
+
2. Read the page with the connector of its kind. Take its title, its revision or version number and its last-modified time.
|
|
26
|
+
3. Convert the content to markdown. Write it to a temporary file outside this repository (for example, under `/tmp`).
|
|
27
|
+
4. Run `pmos docs read-finish <read> --file <the temporary file> --title "<title>" --revision "<revision>" --modified-at "<ISO time>"`. Leave out a flag whose value you did not read. Then delete the temporary file.
|
|
28
|
+
5. If any step failed, run `pmos docs read-fail <read> --reason "<the error, in one line>"` instead of step 4.
|
|
29
|
+
|
|
30
|
+
Output contract — produce EXACTLY these sections, one short line each:
|
|
31
|
+
- Read
|
|
32
|
+
- Not read
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Initiative premium-viewer R11: a Confluence page or Google Doc in the premium viewer (a checked copy, or a read on the PM's press).",
|
|
3
|
+
"modules": [
|
|
4
|
+
"premium-vw-copy.test.js"
|
|
5
|
+
],
|
|
6
|
+
"panels": [
|
|
7
|
+
"premium-vw-copy-test.js"
|
|
8
|
+
],
|
|
9
|
+
"seconds": {
|
|
10
|
+
"premium-vw-copy-test.js": 40
|
|
11
|
+
}
|
|
12
|
+
}
|