create-pmos 0.830.0 → 0.832.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 +129 -50
- 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/changelog.json +128 -36
- package/workspace/guide/backlog.md +1 -1
- package/workspace/guide/cli.md +27 -1
- package/workspace/guide/layout.md +4 -1
- package/workspace/guide/programs.md +2 -1
- package/workspace/lib/anchor-id.js +226 -0
- package/workspace/lib/artefacts-cli.js +25 -1
- package/workspace/lib/events-place.js +11 -4
- package/workspace/lib/features.json +2 -0
- package/workspace/lib/initiative-cli.js +67 -2
- package/workspace/lib/layouts-cli.js +6 -0
- package/workspace/lib/lessons-draft.js +242 -0
- package/workspace/lib/list-balance.js +18 -3
- package/workspace/lib/pmos-verbs.js +6 -0
- package/workspace/lib/prefs-sync.js +1 -1
- package/workspace/lib/route-modules.js +2 -0
- package/workspace/lib/routes-c3-strategy.js +2 -1
- package/workspace/lib/routes-events-place.js +19 -1
- package/workspace/lib/routes-proposals.js +2 -2
- package/workspace/lib/routes-screen-layouts.js +56 -0
- package/workspace/lib/routes-switches.js +35 -0
- package/workspace/lib/switch-owners.js +152 -0
- package/workspace/lib/switches-cli.js +85 -0
- package/workspace/lib/three-layouts.js +214 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-goal.js +33 -0
- package/workspace/public/pm/bd-pop-ds.css +16 -0
- package/workspace/public/pm/bd-work-ds.css +6 -0
- package/workspace/public/pm/bd-work.js +34 -8
- package/workspace/public/pm/card-fold.js +123 -0
- package/workspace/public/pm/cozy-ev.css +7 -0
- package/workspace/public/pm/cozy-events-view.js +8 -4
- package/workspace/public/pm/cozy-nav.js +2 -0
- package/workspace/public/pm/cozy-pop-work.js +8 -3
- package/workspace/public/pm/cozy-today-app.js +28 -1
- package/workspace/public/pm/cozy-today-model.js +13 -5
- package/workspace/public/pm/cozy-today-view.js +10 -1
- package/workspace/public/pm/list-balance.js +16 -2
- package/workspace/public/pm/premium-board.js +7 -1
- package/workspace/public/pm/readonly.js +2 -0
- package/workspace/public/pm/switch-owners.js +70 -0
- package/workspace/public/pm/three-layouts.js +66 -0
- package/workspace/public/premium-board.html +2 -0
- package/workspace/stage-card-tasks-test.js +1 -0
- package/workspace/test-lists/anchor-id.json +9 -0
- package/workspace/test-lists/card-fold.json +9 -0
- package/workspace/test-lists/lessons-on-close.json +9 -0
- package/workspace/test-lists/switch-owners.json +9 -0
- package/workspace/test-lists/three-layouts.json +9 -0
|
@@ -100,6 +100,8 @@ On a phone, PMOS opens on Today. It is one page with no boxes: **Where it stands
|
|
|
100
100
|
|
|
101
101
|
On a computer, Work is built from the parts of the PMOS design system. The top line shows the path (**Work ›** and the product; press the product to switch it), the tabs **Initiatives**, **Backlog** and **This sprint**, then Ask PMOS, Search, New initiative and More. Ask PMOS (the chat bubble, on a computer) opens a chat about the product shown, in the one popup; with several products it opens Ask PMOS about the page. A program's own chat is the chat bubble in its popup.
|
|
102
102
|
|
|
103
|
+
**Fold a big card.** **Strategy**, **Where it stands** and **North Star** each have a chevron at the right of their head. Press it to fold the card to its head line; **Where it stands** keeps its first sentence. When PMOS has a suggestion in a folded card, a small **✦ 1** shows beside the head; press it to open the card. PMOS keeps each fold for you, per page and per card, on every device you use. Press the chevron again to open the card.
|
|
104
|
+
|
|
103
105
|
**Initiatives** has three blocks:
|
|
104
106
|
|
|
105
107
|
- **Where it stands.** One paragraph that says what is happening and why it matters: an initiative past its milestone, with the cause from the record (a Jira ticket that is blocked, a step that waits on you), an initiative that sat in a stage with no dates and for how long, and the next decision point. Press a name to open the initiative. Under it, PMOS shows one suggestion from its open proposals, with **Why**, **PMOS will** (the exact steps), **What changes** and **Based on** (the sources). The pencil opens the initiative so you can change the proposal first, ✓ does it (with Undo), and ✕ drops it. When nothing needs saying, the block does not show.
|
|
@@ -195,6 +197,7 @@ On a computer the popup is built from the parts of the PMOS design system. The t
|
|
|
195
197
|
Under it, two blocks use the full width of the popup:
|
|
196
198
|
|
|
197
199
|
- **Stages.** Each stage of the workflow, with its dates under its name or "no dates yet", on a month scale with a red line for today. A stage's bar runs from the earliest start to the latest end of its tasks; a task with no start counts from its due date. Only a stage with no dated task uses the days the workflow moved through it. To change a stage's dates, change its tasks' dates. A stage has a bar only when it has real dates. A milestone is a diamond on its stage's row.
|
|
200
|
+
- **Layouts.** Only when the initiative adds a new screen, page or view: three layouts of the same parts side by side, **A List first**, **B Summary first** and **C Action first**, drawn with grey bars in place of data. One ✦ line recommends one and says why. Press ✓ under one to keep it as the layout to build; the other two stay, marked **Kept**, and **Undo** takes the pick back. The ✦ learns from your picks for this product. `pmos layouts` reads and writes the same picks.
|
|
198
201
|
- **Work breakdown.** **List** or **Gantt**; PMOS keeps your choice on this computer. **List** has one box on top: type a task and press Enter. Say its stage ("… in Plan"), or it goes to the stage in progress; start with ◇ to add a milestone. Each stage with tasks is one group that says how much is done, for example "1 of 3 done". Press the group to fold it, and press it again to open it. A stage whose tasks are all done is folded until you open it. In a stage, the tasks are in date order, a late task first. A done task stays in its place, in grey with a check. Stages with no tasks fold into one line at the end. Press the box before a task to mark it done, with **Undo**. Press its name to rename it: Enter saves and Escape cancels. When you point at the row, four icons show: **Who** (You, the people on this initiative, or **PMOS does it**, which gives the task to PMOS), **Due date**, **Stage** (moves the task to another stage) and ⋯ (**Status**, **Make it a milestone** and **Open the task**). Each change has **Undo**. A Jira ticket keeps its owner and stage from Jira. **Gantt** is the table described below, with its bars.
|
|
199
202
|
|
|
200
203
|
Press the rest of a row, or a milestone, to open it as a full popup in place of the work side. Its top line has ←, the path (**Work › product › initiative**), the chat button, ⋯ and ×. ← or the initiative's name goes back to the initiative, where you left it. The chat beside it is about the task or milestone itself: its own conversation, which starts with the item's status, dates, owner and notes, and the line under the chat's title reads **Task in** and the initiative. The chat button shows that chat. ← back to the initiative shows the initiative's chat again, and its sessions stay in the chat's session list. A file or a task that the chat opens itself does not change the chat. × closes the popup. A task shows its status, dates, owner, notes and what changed. A milestone also shows its date and how many days are left, the done test, **Kill if**, and the suggestion from PMOS about it when there is one.
|
|
@@ -251,7 +254,7 @@ Events is one page for everything with a date, from every source PMOS reads: you
|
|
|
251
254
|
- The delivery milestones after that are one line at the bottom of Coming up, for example "Delivery milestones later 6, until 20 Feb". Press it to see them.
|
|
252
255
|
- A milestone is a diamond. A task is a round dot, a report a small square, and a deadline a purple dot. A meeting is a ring, and focus time is a green ring. Orange is late, amber is at risk.
|
|
253
256
|
- Point at a row for its tools: a new date, written in place, and the lock. A locked date is fixed: PMOS never suggests a new date for it.
|
|
254
|
-
- On the right, the small month shows a mark under each day that has a date. Press a day to see only that day; press it again for every day. Press the month name to open the full calendar in the place of the list: **Month** or **Week**, with each day's dates. Press a date to open it, press a day to see that day's rows, and press the back arrow (or Esc) to return to the list.
|
|
257
|
+
- On the right, the small month shows a mark under each day that has a date. Press a day to see only that day; press it again for every day. A day before today shows its **Meetings** by their time, so you can find a meeting you had. A meeting with notes shows the first line of its summary and **Open notes**; a meeting without notes has **Open the meeting**, which opens its card, where you can still take notes. A meeting that has passed is never late, and the list shows it only when you press its day. Press the month name to open the full calendar in the place of the list: **Month** or **Week**, with each day's dates. Press a date to open it, press a day to see that day's rows, and press the back arrow (or Esc) to return to the list.
|
|
255
258
|
- **Show** lists the six types, each with how many dates it has. Every type is on until you press it. Press a type to hide it or show it. It is the key to the marks too. PMOS keeps your choice on this computer. A type whose source PMOS does not read says so, for example "Meetings · calendar not connected". Press it to open Connectors.
|
|
256
259
|
- The chip beside the title filters by **product**, **program** and **project**. You can pick more than one. The products are the same pick as on Work, by the names Work's Product column uses. A work copy or a git worktree of a repository shows as its product, in one row. PMOS's own repository reads PMOS. Each program and project shows how many dates it has. The chip filters the list, the small month and the full calendar. A meeting about no work shows under the product its title names, or only when nothing is picked.
|
|
257
260
|
- When a filter hides dates, one line over the list says so, for example "Showing milestones only · 14 more hidden · Show all". **Show all** turns every type on and clears the chip.
|
|
@@ -19,7 +19,7 @@ A cancelled or archived initiative leaves its program's views: the band, the pro
|
|
|
19
19
|
|
|
20
20
|
On a computer Work place is **Work**: one list of initiatives with the timeline on its right. There are no List, By stage, Track or Timeline views to choose.
|
|
21
21
|
|
|
22
|
-
- **The columns.** Initiative, Product, Stage,
|
|
22
|
+
- **The columns.** Initiative, Product, Stage, Tasks done, Date, Owner and Jira epic, in this order. **Tasks done** reads "3 of 14" from the initiative's own tasks, and is empty when it has none. A row with no owner reads "no one" and one with no epic reads "no epic". **Next milestone**, Status, Program, Goal, Workflow and Raised by can be switched on in **Columns**. **Next milestone** is the name of the milestone. When an initiative has no milestone, the cell is empty and the date is the end of its plan. Only a late or at-risk date has colour, for example "4 Nov · 14 days late". The Product column does not show when you pick one product. A product shows by its display name, for example **IDPF**, in the Product column, the filter and the product chip at the top. A work copy or a worktree shows as its product.
|
|
23
23
|
- **The groups.** The rows are under their goals. An initiative with no goal is under **No goal yet**.
|
|
24
24
|
- **The timeline.** Each bar is the same bar as on Work: dark grey is done, blue is now, light grey is still planned. Every milestone is a diamond at its date; press it to see its card. A thin line shows a gap in the plan, and an orange line goes from a missed date to today. Press a bar to see the stages of its workflow in a card, each with its date when it has one. Press outside the card or press Esc to close it. An initiative with no start and no end has an empty timeline cell. A bar that starts or ends outside the span stops at the timeline's edge, so the columns beside it always show. Closed and completed initiatives fold into one last line, for example **11 closed**; press it to show them. The span chooser at the top left of the timeline has **Quarter**, **Half**, **Year**, **2 yr**, **5 yr** and **Full**. **Full** shows every bar from the earliest start to the latest end. The button beside it hides the timeline. The key is under the list.
|
|
25
25
|
- **The view menu.** Press the tune button. **Filter** comes first: Needs (late, at risk, waits on you, blocked), Stage, Status, Product, Program, Owner and Sprint. Each value shows how many initiatives it holds, and you can pick several at once. A line above the table says what shows, for example "Showing Build and Deliver of IDPF · 14 hidden · Show all", and the tune button shows how many filters are on. **Sort** takes up to three keys: press a column to add it, press it again to turn it round, and press its × to take it out. **PMOS order** puts what needs you first. **View** has **Group by** and the **Timeline** switch. **Columns** opens a switch for each column; drag a column to change the order (or use Alt+↑ and Alt+↓). PMOS remembers the view in this browser, and **Reset** shows when the view is not the usual one. If the sprint in the Jira reading has ended, the menu says so, for example "MAD Sprint 115 has ended, showing MAD Sprint 116". The ⋯ menu has **New asks**, **Sprints and releases**, **Shared with me** and **Read Jira again**.
|
|
@@ -68,6 +68,7 @@ The weekly update on Today follows the same rules. PMOS drafts it only when some
|
|
|
68
68
|
- A program comes first. Its band shows the stage spread of its initiatives, the next milestone and how many initiatives are ready for it. Under the band, the initiatives sit under a small heading for each product. Then each product has its own group.
|
|
69
69
|
- A product's group head works like a program's: press the product's tile or name to open its page in Today's Viewer. Press the chevron to fold the group. This works in every view: the stage track, Kanban, the timeline and List. On a shared board, the product's name is plain text.
|
|
70
70
|
- To group by product only, press the tune button in the top row and choose **By product** under **Group**. A program member then shows a small layers icon and stays under its product in every view, the timeline included.
|
|
71
|
+
- **Grouped by goal, Work's table groups by objective.** Each initiative sits under the objective its key result belongs to, for example **O1 · Sign-in is fast and nobody is locked out**, in your OKR file's order. Health budgets come next, then **No goal yet**. Under each initiative's name a short line says which key result it serves, for example "Serves KR1.1".
|
|
71
72
|
- **By goal** is Work's first grouping, in every view: the stage track, By stage, the timeline and List, and on a shared Work link. Each goal row shows the goal's name, its KR id and its reading ("KR-A1 · no reading yet"), the spread of its initiatives over the steps, and in the Next column its target and where the reading comes from. A health budget is a goal too: its cap is the target, and its share of the open initiatives is its reading. The goals come from your OKR file and your health budgets; nothing is typed here. An initiative whose anchor names no goal sits under **No goal yet**. On By stage each goal is a swimlane, on the timeline and in List a row over its initiatives; each one folds. Choose **Programs first** or **By product** under **Group** for the other groupings.
|
|
72
73
|
- The **Next** column says what PMOS does next, with ✦, for example "PMOS writes the experiment" or "PMOS reads the outcome". It does not ask you to write a document. Only your calls show in blue with a person icon: **Your call** · did it work?, move it to the next stage, send the drafted tickets to Jira, and the release sign-off. Ticket and task counts stay.
|
|
73
74
|
- **Kanban** shows programs as swimlanes, then products. Press a column header to fold the column to a strip with its count. An empty column starts folded. Work remembers each fold.
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* anchor-id.js — an initiative's anchor is one id (factory job anchor-ids, idea A547; done test planning/done-tests/anchor-ids.md).
|
|
3
|
+
*
|
|
4
|
+
* `parent_kr` names a key result, an objective, `health:<id>` or `domain:<id>`. Many records add free text after the id
|
|
5
|
+
* ("q3-2026:o1:kr2 (the loop runs end-to-end)"). The resolver (scripts/anchor-resolve.js) reads past that text, but a reader
|
|
6
|
+
* that compares the raw text counts such a record under a key of its own, so the counts per key result split.
|
|
7
|
+
*
|
|
8
|
+
* split(raw) → { id, note } the leading id, and the text after it as written ('' when none)
|
|
9
|
+
* anchorId(raw) → id the leading id alone; '' for no anchor. PURE: every reader that compares parent_kr uses it
|
|
10
|
+
* nearest(text, values) → value | null the declared value closest to a refused text (for "nearest: …")
|
|
11
|
+
* check(root, raw) → { ok, id, note, value } | { ok: false, error, nearest } is the id declared (OKR files, health budgets)
|
|
12
|
+
* list(root) → [{ value, kind, group, label }] the ids you can pick (lib/initiative-rows.js anchorsOf list)
|
|
13
|
+
* plan(root) → { total, items: [{ id, from, anchor, note }], kept: [{ id, from, why }] } what a fold would move
|
|
14
|
+
* fold(root, { apply, actor, stateDir, now }) → plan(), and with apply the records written and a batch to undo
|
|
15
|
+
* undo(root, batch, { actor, stateDir }) → { ok, restored, kept }
|
|
16
|
+
* readAnchorLine · foldAnchor · unfoldAnchor the record edits the fold and `pmos initiative new|anchor` make (see THE RECORD EDITS)
|
|
17
|
+
*
|
|
18
|
+
* The fold only moves text: `parent_kr: <id>` and `anchor_note: <the rest>`. It folds a record only when the id alone resolves to
|
|
19
|
+
* the same key as the whole text, so no count changes. Its undo ledger is local runtime state (<stateDir>/anchor-folds.jsonl),
|
|
20
|
+
* not a tracked record: the fold is one command the PM runs once, and its Undo is for that same machine.
|
|
21
|
+
*/
|
|
22
|
+
const fs = require('fs');
|
|
23
|
+
const path = require('path');
|
|
24
|
+
|
|
25
|
+
// The legacy "okrs-q3-2026 → O1.KR1" form: the id is the token after the arrow (planning/initiatives/README.md, canonical form).
|
|
26
|
+
const ARROW = /^(\S+)\s*(?:→|->)\s*(\S+)/;
|
|
27
|
+
const TOKEN = /^[^\s(]+/;
|
|
28
|
+
|
|
29
|
+
function split(raw) {
|
|
30
|
+
const text = raw == null ? '' : String(raw).trim();
|
|
31
|
+
if (!text) return { id: '', note: '' };
|
|
32
|
+
const a = ARROW.exec(text);
|
|
33
|
+
if (a) {
|
|
34
|
+
const id = a[2].replace(/[,;]+$/, '');
|
|
35
|
+
return { id, note: `${a[1]} → ${text.slice(a[0].length).trim()}`.trim() }; // every word stays: "okrs-q3-2026 → # or x"
|
|
36
|
+
}
|
|
37
|
+
const m = TOKEN.exec(text);
|
|
38
|
+
if (!m) return { id: '', note: text };
|
|
39
|
+
const id = m[0].replace(/[,;]+$/, '');
|
|
40
|
+
return { id, note: text.slice(id.length).trim() };
|
|
41
|
+
}
|
|
42
|
+
const anchorId = (raw) => split(raw).id;
|
|
43
|
+
|
|
44
|
+
// The comparable form of an anchor: lower case, no period prefix (q3-2026:), '.' and ':' the same, no word "okrs-…".
|
|
45
|
+
const norm = (s) => String(s || '').toLowerCase().replace(/^okrs-[^\s]*\s*(?:→|->)\s*/, '').replace(/^q[1-4]-\d{4}:/, '').replace(/\./g, ':').replace(/[^a-z0-9:_-]/g, '');
|
|
46
|
+
function dist(a, b) {
|
|
47
|
+
const m = a.length, n = b.length;
|
|
48
|
+
if (!m) return n; if (!n) return m;
|
|
49
|
+
let prev = Array.from({ length: n + 1 }, (_, j) => j);
|
|
50
|
+
for (let i = 1; i <= m; i++) {
|
|
51
|
+
const cur = [i];
|
|
52
|
+
for (let j = 1; j <= n; j++) cur[j] = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
53
|
+
prev = cur;
|
|
54
|
+
}
|
|
55
|
+
return prev[n];
|
|
56
|
+
}
|
|
57
|
+
function nearest(text, values) {
|
|
58
|
+
const t = norm(anchorId(text));
|
|
59
|
+
let best = null, bd = Infinity;
|
|
60
|
+
for (const v of values || []) { const d = dist(t, norm(v)); if (d < bd) { bd = d; best = v; } }
|
|
61
|
+
return best;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const rows = () => require('./initiative-rows.js');
|
|
65
|
+
const list = (root) => rows().anchorsOf(root).list();
|
|
66
|
+
|
|
67
|
+
function check(root, raw) {
|
|
68
|
+
const { id, note } = split(raw);
|
|
69
|
+
if (!id) return { ok: false, error: 'an initiative needs an anchor: a key result, or health:<id> from the health budgets (D59)', nearest: null };
|
|
70
|
+
const A = rows().anchorsOf(root);
|
|
71
|
+
const r = A.resolve(id);
|
|
72
|
+
if (r.status === 'resolved') return { ok: true, id, note, value: id, key: r.key };
|
|
73
|
+
const near = nearest(id, A.list().map((x) => x.value));
|
|
74
|
+
return { ok: false, id, note, error: `the anchor "${id}" is not declared in the OKR files or the health budgets (D59)${near ? `; nearest: ${near}` : ''}. pmos initiative anchors lists the ids`, nearest: near };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
// THE RECORD EDITS. They live here, not in lib/initiative-writer.js, so a change to them reaches only the suites that name this file
|
|
79
|
+
// (run-tests.js --changed follows lib/initiative-writer.js to every suite). They edit the front matter lines of one record, like the
|
|
80
|
+
// writer's own setAnchor: the same record file rule (an id inside the engine's initiatives folder) and the same quoting.
|
|
81
|
+
const ONE_LINE = (v, max) => typeof v === 'string' && v.trim().length >= 1 && v.trim().length <= max && !/[\r\n\x00-\x08\x0b-\x1f]/.test(v);
|
|
82
|
+
const refuse = (status, error, field) => ({ ok: false, status, error, field: field || null });
|
|
83
|
+
const PLAIN = (s) => !/: |:$| #|["\\]/.test(s) && !/^[-?:,[\]{}#&*!|>'%@`]/.test(s);
|
|
84
|
+
const q = (s) => '"' + String(s).trim().replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
|
|
85
|
+
const frontOfText = (text) => /^---\r?\n([\s\S]*?)\r?\n---(\r?\n|$)/.exec(text);
|
|
86
|
+
function unquote(v) {
|
|
87
|
+
const t = String(v || '').trim();
|
|
88
|
+
if (/^".*"$/.test(t)) return t.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
|
89
|
+
if (/^'.*'$/.test(t)) return t.slice(1, -1).replace(/''/g, "'");
|
|
90
|
+
return t;
|
|
91
|
+
}
|
|
92
|
+
const actorLib = () => require('./actor.js');
|
|
93
|
+
function recordFile(root, id) {
|
|
94
|
+
const W = require('./initiative-writer.js');
|
|
95
|
+
if (typeof id !== 'string' || !W.ID_RE.test(id) || id.includes('..')) return refuse(400, 'name the initiative by its id', 'id');
|
|
96
|
+
let dir;
|
|
97
|
+
try { dir = fs.realpathSync(require('./console-state').loadEngine().engine.layout(root).initiatives); } catch { return refuse(404, `no initiative ${id}`, 'id'); }
|
|
98
|
+
const file = path.join(dir, `${id}.md`);
|
|
99
|
+
let st;
|
|
100
|
+
try { st = fs.lstatSync(file); } catch { return refuse(404, `no initiative ${id}`, 'id'); }
|
|
101
|
+
if (!st.isFile()) return refuse(409, `the record of ${id} is not a plain file — nothing was saved`, 'id');
|
|
102
|
+
return { ok: true, file };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The `parent_kr:` line of a record as text (anchor-ids, A547): { ok, text, spans, hasNote }. `spans` is true when the value runs on
|
|
106
|
+
* to the next line (an indented continuation), which a one-line edit must not touch. */
|
|
107
|
+
function readAnchorLine(root, id) {
|
|
108
|
+
const f = recordFile(root, id);
|
|
109
|
+
if (!f.ok) return f;
|
|
110
|
+
const m = frontOfText(fs.readFileSync(f.file, 'utf8'));
|
|
111
|
+
if (!m) return { ok: true, text: '', spans: false, hasNote: false };
|
|
112
|
+
const lines = m[1].split(/\r?\n/);
|
|
113
|
+
const at = lines.findIndex((l) => /^parent_kr:/.test(l));
|
|
114
|
+
return { ok: true, text: at >= 0 ? unquote(lines[at].slice(10)) : '', spans: at >= 0 && /^\s+\S/.test(lines[at + 1] || ''), hasNote: lines.some((l) => /^anchor_note:/.test(l)) };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** anchor-ids (A547): `parent_kr: <id>` and `anchor_note: <note>` in place of one anchor with text after its id. Writes only when the
|
|
118
|
+
* line still reads `expect` (lib/anchor-id.js fold checked it), so an edit made since is never overwritten. */
|
|
119
|
+
function foldAnchor(root, id, { anchor, note, expect } = {}, { actor } = {}) {
|
|
120
|
+
if (!actorLib().valid(actor)) return refuse(500, 'initiative-writer: the caller must pass the actor from pm-guard.js or actor.js');
|
|
121
|
+
const a = typeof anchor === 'string' ? anchor.trim() : '', n = typeof note === 'string' ? note.trim() : '';
|
|
122
|
+
if (!a || !ONE_LINE(a, 120) || /\s/.test(a)) return refuse(400, 'the anchor to keep is one id', 'anchor');
|
|
123
|
+
if (!n || /[\r\n]/.test(n)) return refuse(400, 'the note to move is one line', 'anchor');
|
|
124
|
+
return editAnchorLines(root, id, expect, (lines, at) => {
|
|
125
|
+
lines[at] = `parent_kr: ${PLAIN(a) ? a : q(a)}`;
|
|
126
|
+
lines.splice(at + 1, 0, `anchor_note: ${q(n)}`);
|
|
127
|
+
}, { anchor: a, note: n });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** The Undo of a foldAnchor: the one anchor line back, exactly `from`, and no anchor_note, while the record still holds what the fold wrote. */
|
|
131
|
+
function unfoldAnchor(root, id, { from, fromLine, anchor, note } = {}, { actor } = {}) {
|
|
132
|
+
if (!actorLib().valid(actor)) return refuse(500, 'initiative-writer: the caller must pass the actor from pm-guard.js or actor.js');
|
|
133
|
+
const f0 = typeof from === 'string' ? from.trim() : '';
|
|
134
|
+
if (!f0 || /[\r\n]/.test(f0)) return refuse(400, 'the anchor to put back is not one line', 'anchor');
|
|
135
|
+
// the line exactly as it was (its quotes too), when the fold kept it and it still reads as that anchor
|
|
136
|
+
const back = typeof fromLine === 'string' && /^parent_kr:/.test(fromLine) && !/[\r\n]/.test(fromLine) && unquote(fromLine.slice(10)) === f0 ? fromLine : `parent_kr: ${PLAIN(f0) ? f0 : q(f0)}`;
|
|
137
|
+
return editAnchorLines(root, id, anchor, (lines, at) => {
|
|
138
|
+
const na = lines.findIndex((l) => /^anchor_note:/.test(l));
|
|
139
|
+
if (na < 0 || unquote(lines[na].slice(12)) !== String(note || '').trim()) return 'its anchor note was edited since the fold';
|
|
140
|
+
lines[at] = back;
|
|
141
|
+
lines.splice(na, 1);
|
|
142
|
+
return null;
|
|
143
|
+
}, { anchor: f0 });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function editAnchorLines(root, id, expect, edit, out) {
|
|
147
|
+
const f = recordFile(root, id);
|
|
148
|
+
if (!f.ok) return f;
|
|
149
|
+
const text = fs.readFileSync(f.file, 'utf8');
|
|
150
|
+
const m = frontOfText(text);
|
|
151
|
+
if (!m) return refuse(409, `the record of ${id} has no front matter — nothing was saved`, 'id');
|
|
152
|
+
const lines = m[1].split(/\r?\n/);
|
|
153
|
+
const at = lines.findIndex((l) => /^parent_kr:/.test(l));
|
|
154
|
+
if (at < 0 || unquote(lines[at].slice(10)) !== String(expect || '').trim()) return refuse(409, `the anchor of ${id} was edited since — nothing was saved`, 'anchor');
|
|
155
|
+
const fromLine = lines[at];
|
|
156
|
+
const why = edit(lines, at);
|
|
157
|
+
if (why) return refuse(409, `${why} — nothing was saved`, 'anchor');
|
|
158
|
+
try { fs.writeFileSync(f.file, '---\n' + lines.join('\n') + '\n---' + m[2] + text.slice(m[0].length), { flag: 'w' }); } catch { return refuse(500, 'the record could not be written — nothing was saved'); }
|
|
159
|
+
return { ok: true, id, fromLine, ...out };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function recordIds(root) {
|
|
163
|
+
let dir = null;
|
|
164
|
+
try { dir = require('./console-state').loadEngine().engine.layout(root).initiatives; } catch { dir = null; }
|
|
165
|
+
if (!dir) return [];
|
|
166
|
+
let names = [];
|
|
167
|
+
try { names = fs.readdirSync(dir); } catch { return []; }
|
|
168
|
+
const W = require('./initiative-writer.js');
|
|
169
|
+
return names.filter((n) => /\.md$/.test(n) && n !== 'README.md' && W.ID_RE.test(n.slice(0, -3))).map((n) => n.slice(0, -3)).sort();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function plan(root) {
|
|
173
|
+
const A = rows().anchorsOf(root);
|
|
174
|
+
const items = [], kept = [];
|
|
175
|
+
let total = 0;
|
|
176
|
+
for (const id of recordIds(root)) {
|
|
177
|
+
const r = readAnchorLine(root, id);
|
|
178
|
+
if (!r.ok || !r.text) continue;
|
|
179
|
+
total++;
|
|
180
|
+
const s = split(r.text);
|
|
181
|
+
if (!s.note) continue; // one id already: stays silent
|
|
182
|
+
if (r.spans) { kept.push({ id, from: r.text, why: 'the anchor runs over more than one line' }); continue; }
|
|
183
|
+
if (r.hasNote) { kept.push({ id, from: r.text, why: 'it has an anchor_note already' }); continue; }
|
|
184
|
+
const whole = A.resolve(r.text), alone = A.resolve(s.id);
|
|
185
|
+
if (whole.key !== alone.key || alone.status !== 'resolved') { kept.push({ id, from: r.text, why: `the id alone (${s.id}) does not name the same anchor` }); continue; }
|
|
186
|
+
items.push({ id, from: r.text, anchor: s.id, note: s.note });
|
|
187
|
+
}
|
|
188
|
+
return { total, items, kept };
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const ledger = (stateDir) => path.join(stateDir, 'anchor-folds.jsonl');
|
|
192
|
+
function readLedger(stateDir) {
|
|
193
|
+
try { return fs.readFileSync(ledger(stateDir), 'utf8').split('\n').filter(Boolean).map((l) => { try { return JSON.parse(l); } catch { return null; } }).filter(Boolean); } catch { return []; }
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function fold(root, { apply = false, actor, stateDir, now = Date.now() } = {}) {
|
|
197
|
+
const p = plan(root);
|
|
198
|
+
if (!apply) return { ok: true, ...p };
|
|
199
|
+
if (!stateDir) return { ok: false, status: 500, error: 'anchor-id: fold needs the runtime state folder for its Undo' };
|
|
200
|
+
const batch = 'fold-' + new Date(now).toISOString().replace(/[:.]/g, '-');
|
|
201
|
+
const done = [], at = new Date(now).toISOString(), by = (actor && actor.by) || 'unknown';
|
|
202
|
+
for (const it of p.items) {
|
|
203
|
+
const w = foldAnchor(root, it.id, { anchor: it.anchor, note: it.note, expect: it.from }, { actor });
|
|
204
|
+
if (!w.ok) { p.kept.push({ id: it.id, from: it.from, why: w.error }); continue; }
|
|
205
|
+
done.push({ v: 1, kind: 'fold', batch, id: it.id, from: it.from, fromLine: w.fromLine, anchor: it.anchor, note: it.note, at, by });
|
|
206
|
+
}
|
|
207
|
+
if (done.length) { fs.mkdirSync(stateDir, { recursive: true }); fs.appendFileSync(ledger(stateDir), done.map((d) => JSON.stringify(d)).join('\n') + '\n'); }
|
|
208
|
+
return { ok: true, total: p.total, items: done.map(({ id, from, anchor, note }) => ({ id, from, anchor, note })), kept: p.kept, folded: done.length, batch };
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function undo(root, batch, { actor, stateDir, now = Date.now() } = {}) {
|
|
212
|
+
if (!/^fold-[0-9TZ-]+$/.test(String(batch || ''))) return { ok: false, status: 400, error: 'name the fold batch, fold-<time>, from the fold\'s answer' };
|
|
213
|
+
const all = stateDir ? readLedger(stateDir) : [];
|
|
214
|
+
const rowsOf = all.filter((e) => e.kind === 'fold' && e.batch === batch);
|
|
215
|
+
if (!rowsOf.length) return { ok: false, status: 404, error: `no anchor fold ${batch} on this computer` };
|
|
216
|
+
if (all.some((e) => e.kind === 'undo' && e.batch === batch)) return { ok: true, restored: 0, kept: 0, already: true };
|
|
217
|
+
let restored = 0, kept = 0;
|
|
218
|
+
for (const e of rowsOf) {
|
|
219
|
+
const w = unfoldAnchor(root, e.id, { from: e.from, fromLine: e.fromLine, anchor: e.anchor, note: e.note }, { actor });
|
|
220
|
+
if (w.ok) restored++; else kept++;
|
|
221
|
+
}
|
|
222
|
+
fs.appendFileSync(ledger(stateDir), JSON.stringify({ v: 1, kind: 'undo', batch, at: new Date(now).toISOString(), by: (actor && actor.by) || 'unknown' }) + '\n');
|
|
223
|
+
return { ok: true, restored, kept };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
module.exports = { split, anchorId, nearest, check, list, plan, fold, undo, readAnchorLine, foldAnchor, unfoldAnchor };
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* its artefact. Idempotent; it deletes and moves nothing
|
|
8
8
|
* pmos artefacts set <scope> <artefact> [<field>] --text "<…>" [--source label=ref]… one field (PM or agent; Intent is the PM's)
|
|
9
9
|
* pmos artefacts undo <a-id> one set line no longer counts
|
|
10
|
+
* pmos artefacts lessons <id> [--draft] [--json] an initiative's Lessons, with ids for undo; --draft drafts them (lib/lessons-draft.js, lessons-on-close)
|
|
10
11
|
* every command: [--root <dir>]
|
|
11
12
|
* Exit codes: 0 done, 1 refused, 2 usage. */
|
|
12
13
|
const path = require('path');
|
|
@@ -15,7 +16,7 @@ const A = require('./artefacts.js');
|
|
|
15
16
|
const MIRROR = require('./artefact-mirror.js');
|
|
16
17
|
const actorLib = require('./actor.js');
|
|
17
18
|
|
|
18
|
-
const COMMANDS = { artefacts: ['show', 'map', 'migrate', 'set', 'undo'] };
|
|
19
|
+
const COMMANDS = { artefacts: ['show', 'map', 'migrate', 'set', 'undo', 'lessons'] };
|
|
19
20
|
const USAGE = [
|
|
20
21
|
'usage: pmos artefacts show|map|migrate|set|undo — the seven artefacts: Intent, Goal, Narrative, Experiment, Specimens, Done test, Lessons',
|
|
21
22
|
' pmos artefacts show [<scope>] [--json] scope: portfolio (default), board:<id>, goal:<id> or experiment:<id> (an initiative)',
|
|
@@ -24,6 +25,7 @@ const USAGE = [
|
|
|
24
25
|
' pmos artefacts set <scope> <artefact> [<field>] --text "<text>" [--source label=ref]…',
|
|
25
26
|
' an initiative is experiment:<id> (initiative:<id> works too). Its case card: experiment why (Problem), experiment hypothesis (Goal), done-test check (Done when, once per check)',
|
|
26
27
|
' pmos artefacts undo <a-id>',
|
|
28
|
+
' pmos artefacts lessons <initiative> [--draft] [--json] its Lessons lines with their ids; --draft: PMOS drafts them once its experiment closed (never over yours)',
|
|
27
29
|
];
|
|
28
30
|
function parse(args) {
|
|
29
31
|
const pos = []; const flags = { source: [] };
|
|
@@ -37,6 +39,27 @@ function parse(args) {
|
|
|
37
39
|
}
|
|
38
40
|
return { pos, flags };
|
|
39
41
|
}
|
|
42
|
+
/* lessons-on-close (A542): the chat reads an initiative's Lessons and asks PMOS to draft them. The draft is async (a session may answer). */
|
|
43
|
+
function lessonsCmd(pos, flags, { root, dir, f, say, now }) {
|
|
44
|
+
const id = pos[0];
|
|
45
|
+
if (!id || pos.length > 1) { say('usage: pmos artefacts lessons <initiative> [--draft] [--json]'); return 2; }
|
|
46
|
+
const LD = require('./lessons-draft.js');
|
|
47
|
+
const show = () => {
|
|
48
|
+
const h = LD.lessonsHere(A.fold(A.readLines(f)), id), all = [...h.pm, ...h.agent].sort((a, b) => String(a.at).localeCompare(String(b.at)));
|
|
49
|
+
if (flags.json) { say(JSON.stringify({ ok: true, initiative: id, lessons: all.map((l) => ({ id: l.id, text: l.text, by: /^pm:/.test(String(l.by || '')) ? 'you' : 'pmos', sources: l.sources || [], at: l.at })) })); return 0; }
|
|
50
|
+
if (!all.length) { say(`${id} has no lessons yet.`); return 0; }
|
|
51
|
+
for (const l of all) say(`${l.id} ${l.text}${/^pm:/.test(String(l.by || '')) ? '' : ' (PMOS)'}${(l.sources || []).length ? ' ← ' + l.sources.map((x) => x.ref).join(', ') : ''}`);
|
|
52
|
+
say('Undo one: pmos artefacts undo <a-id>');
|
|
53
|
+
return 0;
|
|
54
|
+
};
|
|
55
|
+
if (!('draft' in flags)) return show();
|
|
56
|
+
return LD.draft({}, { root, id, dir, now: now || Date.now() }).then((r) => {
|
|
57
|
+
if (!r.ok) { say('✗ ' + r.error); return 1; }
|
|
58
|
+
if (!r.wrote.length) { say(`Nothing drafted: ${r.why}.`); return 0; }
|
|
59
|
+
say(`✓ PMOS drafted ${r.wrote.length} ${r.wrote.length === 1 ? 'lesson' : 'lessons'} for ${id}, from its experiment and what happened. Nothing was sent.`);
|
|
60
|
+
return show();
|
|
61
|
+
});
|
|
62
|
+
}
|
|
40
63
|
function repoRoot(cwd) { try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; } catch { return cwd; } }
|
|
41
64
|
|
|
42
65
|
function mapRows() {
|
|
@@ -64,6 +87,7 @@ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), env = pro
|
|
|
64
87
|
let dir = dirIn || null;
|
|
65
88
|
if (!dir) { try { dir = A.dirOf(root); } catch (e) { say('✗ ' + String((e && e.message) || e)); return 1; } }
|
|
66
89
|
const f = A.file(dir);
|
|
90
|
+
if (verb === 'lessons') return lessonsCmd(pos, flags, { root, dir, f, say, now });
|
|
67
91
|
if (verb === 'show') {
|
|
68
92
|
const scope = pos[0] || 'portfolio';
|
|
69
93
|
const v = A.viewOf(A.fold(A.readLines(f)), scope);
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
* scope the filter tokens the item is under: 'p:<ws>' (its product, as the saved product pick names it), 'g:<program id>' (each program that holds its work),
|
|
29
29
|
* 'j:<ws>|<initiative>' (its project). A meeting with no work is under the product its title names, else under none: it then
|
|
30
30
|
* shows only when no product, program or project is picked.
|
|
31
|
-
* group late (before today, not done) · today · coming (the next WINDOW_DAYS days; a meeting the next MEET_DAYS) · later
|
|
31
|
+
* group late (before today, not done) · today · coming (the next WINDOW_DAYS days; a meeting the next MEET_DAYS) · later ·
|
|
32
|
+
* past (a meeting before today: never late, shown when the PM picks its day, and a mark on the calendar)
|
|
32
33
|
* tone late · risk (a milestone of an initiative at risk, or whose Jira forecast says it will miss) · ''
|
|
33
34
|
* suggest { op: done | move | drop | met | gone | ask, to?, with?, ask?, text, why, sig } or null. What PMOS suggests; the PM says yes (✓)
|
|
34
35
|
* or no (✕). met and gone are kept by Events (the date is met, or dropped: Events stops listing it); ask adds a task for the PM.
|
|
@@ -130,7 +131,7 @@ function build(input = {}) {
|
|
|
130
131
|
x.date = day10(x.date);
|
|
131
132
|
x.days = daysBetween(today, x.date);
|
|
132
133
|
x.group = groupOf(x.kind, x.date, today);
|
|
133
|
-
if (x.kind === 'meeting' && x.group === 'late')
|
|
134
|
+
if (x.kind === 'meeting' && x.group === 'late') x.group = 'past'; // a meeting that has passed is not late: it is kept for its day
|
|
134
135
|
if (x.kind === 'report' && x.group === 'late' && !x.draft) return;
|
|
135
136
|
x.type = x.type || x.kind;
|
|
136
137
|
x.fixed = !!(x.canFix && fixedSet.has(x.key));
|
|
@@ -264,8 +265,14 @@ function build(input = {}) {
|
|
|
264
265
|
const time = /T(\d{2}:\d{2})/.exec(e.at);
|
|
265
266
|
const until = typeof e.end === 'string' && e.end.slice(0, 10) === e.at.slice(0, 10) ? /T(\d{2}:\d{2})/.exec(e.end) : null;
|
|
266
267
|
const work = e.initiative ? { id: String(e.initiative), title: '', ws: '', board: '' } : null;
|
|
268
|
+
// a meeting that has passed opens its card in the Viewer, which holds its notes (the note linked to it, else Take notes)
|
|
269
|
+
const day = day10(e.at), past = daysBetween(today, day) < 0;
|
|
270
|
+
const note = e.note && e.note.id ? e.note : null;
|
|
271
|
+
const href = !past ? null : note ? '/premium-viewer.html?open=meeting¬e=' + encodeURIComponent(note.id)
|
|
272
|
+
: e.id ? '/premium-viewer.html?open=meeting&event=' + encodeURIComponent(e.id) + '&date=' + day : null;
|
|
267
273
|
put({ key: 'mtg:' + (e.id || e.at + '|' + e.title), kind: 'meeting', type: FOCUS.test(e.title) ? 'focus' : 'meeting', date: e.at, time: time ? time[1] : null, until: until ? until[1] : null, title: clip(e.title, 140),
|
|
268
|
-
line: time ? '' : 'All day', product: '', work, task: null, own: null, jira: false, canFix: false, editable: false, scope: [],
|
|
274
|
+
line: past && note && note.line ? clip(note.line, 120) : time ? '' : 'All day', product: '', work, task: null, own: null, jira: false, canFix: false, editable: false, scope: [],
|
|
275
|
+
act: href ? { label: note ? 'Open notes' : 'Open the meeting', href } : null });
|
|
269
276
|
}
|
|
270
277
|
|
|
271
278
|
// the dates people state in the sources: proven only (lib/events-stated.js), each names its source
|
|
@@ -386,7 +393,7 @@ function build(input = {}) {
|
|
|
386
393
|
delete x.oldDrafts;
|
|
387
394
|
}
|
|
388
395
|
|
|
389
|
-
const ORDER = {
|
|
396
|
+
const ORDER = { past: 0, late: 1, today: 2, coming: 3, later: 4 };
|
|
390
397
|
// Late: the newest first, so the dates you can still save come before the old ones. A day: the dates with no time first, then by time
|
|
391
398
|
items.sort((a, b) => ORDER[a.group] - ORDER[b.group] || (a.group === 'late' ? b.date.localeCompare(a.date) : a.date.localeCompare(b.date)) || String(a.time || '').localeCompare(String(b.time || '')) || a.title.localeCompare(b.title));
|
|
392
399
|
for (const x of items) { delete x.row; delete x.jiraKey; }
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
{"id": "connectors", "audience": "user", "status": "ga", "group": "Your product", "name": "What connectors read and write", "say": "What PMOS reads and writes through each connector, and what leaves this computer.", "cmd": "/connectors", "verb": "connectors", "sub": "data", "since": "0.825.0"},
|
|
21
21
|
{"id": "positioning", "audience": "user", "status": "ga", "group": "Your product", "name": "Positioning and key messages", "say": "A positioning statement and key messages, each citing a strategy line.", "cmd": "/positioning", "verb": "positioning", "sub": "list", "phrases": ["positioning statement", "key messages", "messaging for"], "since": "0.740.0"},
|
|
22
22
|
{"id": "principles", "audience": "user", "status": "ga", "group": "Your product", "name": "Product principles", "say": "Four to six principles drafted from your past decisions, each citing them.", "cmd": "/principles", "verb": "principles", "sub": "list", "phrases": ["product principles", "our principles", "design principles for"], "since": "0.720.0"},
|
|
23
|
+
{"id": "switches", "audience": "user", "status": "ga", "group": "Your product", "name": "Who has which switch", "say": "Each customer's switches, why each is on and who agreed; turning one waits for you.", "cmd": "/switches", "verb": "switches", "sub": "list", "since": "0.830.0"},
|
|
23
24
|
{"id": "glossary", "audience": "user", "status": "ga", "group": "Your product", "name": "Glossary", "say": "The product's own words; every page shows a word's meaning on hover.", "cmd": "/glossary", "verb": "glossary", "sub": "list", "hint": "<word>", "phrases": ["define the word", "glossary", "add to glossary", "meaning of the word"], "since": "0.690.0"},
|
|
24
25
|
{"id": "health", "audience": "user", "status": "ga", "group": "Your product", "name": "Health score", "say": "This product's health from 0 to 100, and the three parts that make it.", "cmd": "/health", "verb": "health", "sub": "score", "phrases": ["health score", "how healthy is", "product health"], "phone": true, "since": "0.737.0", "ask": ["product"]},
|
|
25
26
|
{"id": "outcomes", "audience": "user", "status": "ga", "group": "Your product", "name": "Did it work?", "say": "Each initiative's expected outcome and the date to check it.", "cmd": "/outcomes", "verb": "outcomes", "sub": "list", "phrases": ["did it work", "expected outcome", "outcomes due", "check the outcome"], "since": "0.640.0"},
|
|
@@ -63,6 +64,7 @@
|
|
|
63
64
|
{"id": "goals", "audience": "user", "status": "ga", "group": "Your product", "name": "Starter goals", "say": "Up to three goals drafted from your own product, each with its source; keep one and it becomes a goal.", "cmd": "/goals", "verb": "goals"},
|
|
64
65
|
{"id": "approver", "audience": "user", "status": "ga", "group": "Before you ship", "name": "What an approver asks", "say": "What each approver asked or objected to before, ahead of the next sign-off.", "cmd": "/approver", "verb": "approver", "hint": "<name>"},
|
|
65
66
|
{"id": "balance", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "The mix of a list", "say": "Feature, fix, debt or discovery in one line, with a note when one kind is over your line.", "cmd": "/balance", "verb": "balance"},
|
|
67
|
+
{"id": "layouts", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Three layouts for a new screen", "say": "Three layouts of a new screen side by side, the one that fits your picks, and the one you keep to build.", "cmd": "/layouts", "verb": "layouts"},
|
|
66
68
|
{"id": "declined", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Asks you declined", "say": "Asks closed without being done, each with a kind reply draft PMOS never sends.", "cmd": "/declined", "verb": "declined"},
|
|
67
69
|
{"id": "sprint", "audience": "user", "status": "ga", "group": "Catch up", "name": "Sprint retro", "say": "A closed sprint's retro from its close numbers, and its one tracked change.", "cmd": "/sprint", "verb": "sprint"},
|
|
68
70
|
{"id": "deps", "audience": "user", "status": "beta", "group": "Catch up", "name": "Waiting on other teams", "say": "Each piece of your work that waits on another team, since when, with a Chase draft.", "cmd": "/deps", "verb": "deps"},
|
|
@@ -42,6 +42,7 @@ const rowsLib = require('./initiative-rows.js');
|
|
|
42
42
|
const planRules = require('./plan-rules.js');
|
|
43
43
|
const breakdownExport = require('./breakdown-export.js');
|
|
44
44
|
const triage = require('./triage.js');
|
|
45
|
+
const AID = require('./anchor-id.js');
|
|
45
46
|
const lifecycle = require('./lifecycle-stage.js');
|
|
46
47
|
const { parseArgs } = require('./schedule-cli');
|
|
47
48
|
|
|
@@ -79,11 +80,11 @@ function docNote(docs) {
|
|
|
79
80
|
return `Not on the Roadmap · ${docs.length} on a document lane: ${names}. A document lane does not show on Today or Work. If it is work, set lane: in its record to ${WORK_LANES}.`;
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
const COMMANDS = { initiative: ['new', 'top', 'up', 'down', 'bottom', 'after', 'check-by', 'adopt', 'drop', 'list', 'export', 'describe', 'raised-by', 'kind', 'role', 'status', 'status-migrate', 'status-undo'] };
|
|
83
|
+
const COMMANDS = { initiative: ['new', 'top', 'up', 'down', 'bottom', 'after', 'check-by', 'adopt', 'drop', 'list', 'export', 'describe', 'raised-by', 'kind', 'role', 'status', 'status-migrate', 'status-undo', 'anchor', 'anchors'] };
|
|
83
84
|
/** The horizon verbs D105 retired: they answer with what to use instead. */
|
|
84
85
|
const RETIRED = Object.freeze(['now', 'next', 'later']);
|
|
85
86
|
const USAGE = [
|
|
86
|
-
'usage: pmos initiative new|top|up|down|bottom|after|check-by|adopt|drop|list|export|describe|raised-by|kind|role|status|status-migrate|status-undo — initiatives on the Roadmap',
|
|
87
|
+
'usage: pmos initiative new|top|up|down|bottom|after|check-by|adopt|drop|list|export|describe|raised-by|kind|role|status|status-migrate|status-undo|anchor|anchors — initiatives on the Roadmap',
|
|
87
88
|
' pmos initiative new "<title>" --lane <lane> --anchor <KR|health:id> [--intent "<text>"] [--id <id>] [--kind product|sdlc|project] [--raised-by "<who>"]',
|
|
88
89
|
' pmos initiative new --from capture-YYYY-MM-DD-<n> [--anchor <anchor>] [--lane <lane>] [--title "<title>"]',
|
|
89
90
|
' pmos initiative top|up|down|bottom <id> reorder it on the Roadmap',
|
|
@@ -100,6 +101,10 @@ const USAGE = [
|
|
|
100
101
|
' pmos initiative status <id> ["<text>"] [--line "<12 words>"] its status line and log; with text, save it: the whole text to the log, the line (yours, else its first 12 words) to the record',
|
|
101
102
|
' pmos initiative status-migrate [--apply] every status over 12 words: count them (dry run), or with --apply give each its line and move the whole text to the log',
|
|
102
103
|
' pmos initiative status-undo <batch> undo a status-migrate: each line not edited since gets its whole text back',
|
|
104
|
+
' pmos initiative anchor <id> ["<anchor>"] its anchor; with one, change it (an id the OKR files or health budgets declare, else refused with the nearest)',
|
|
105
|
+
' pmos initiative anchors the anchor ids you can pick: key results, health budgets, domains',
|
|
106
|
+
' pmos initiative anchors fold [--apply] anchors with text after the id: list them (dry run), or with --apply keep the id and move the text to anchor_note',
|
|
107
|
+
' pmos initiative anchors undo <batch> undo a fold: each record not edited since gets its whole anchor back',
|
|
103
108
|
' --lane is a work lane of this repository: new-feature, improvement, bug-fix, discovery or chore in a product repository',
|
|
104
109
|
' (scripts/lane-defs.js; the PMOS repository itself uses feature, discovery, chore, incident, content and prototype)',
|
|
105
110
|
' every command: [--json] [--root <dir>]',
|
|
@@ -175,9 +180,17 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
175
180
|
if (flags.title) input.title = flags.title;
|
|
176
181
|
for (const k of ['lane', 'anchor', 'intent', 'id', 'kind']) if (flags[k]) input[k] = flags[k];
|
|
177
182
|
if (flags['raised-by']) input.raised_by = flags['raised-by'];
|
|
183
|
+
// anchor-ids (A547): the anchor is one declared id; a refused id names the nearest, and text after the id goes to anchor_note
|
|
184
|
+
let anchorNote = '';
|
|
185
|
+
if (input.anchor) {
|
|
186
|
+
const c = AID.check(root, input.anchor);
|
|
187
|
+
if (!c.ok) return fail(c.error);
|
|
188
|
+
input.anchor = c.id; anchorNote = c.note;
|
|
189
|
+
}
|
|
178
190
|
const actor = actorLib.fromCli(who);
|
|
179
191
|
const r = writer.createInitiative(root, input, { actor, now });
|
|
180
192
|
if (!r.ok) return fail(r.error);
|
|
193
|
+
if (anchorNote) AID.foldAnchor(root, r.id, { anchor: input.anchor, note: anchorNote, expect: input.anchor }, { actor });
|
|
181
194
|
startOnDefault(root, r, actor);
|
|
182
195
|
// no initiative without an expected outcome (outcome-for-every-initiative): say what Claude drafts next, or that the PM names it
|
|
183
196
|
return done({ id: r.id, path: r.path }, `✓ ${r.id} added at the end of the Roadmap (${r.path}). Commit the record to keep it.\n`
|
|
@@ -303,6 +316,58 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
303
316
|
return done({ role: pos[0] }, `✓ New work starts as ${WK.LABEL[pos[0]]}. Settings shows it now. Each initiative can still change its own kind.`);
|
|
304
317
|
}
|
|
305
318
|
|
|
319
|
+
if (verb === 'anchors') {
|
|
320
|
+
const stateDir = require('./state-root.js').defaultRoot({ env: who.env });
|
|
321
|
+
const actor = actorLib.fromCli(who);
|
|
322
|
+
if (!pos.length) {
|
|
323
|
+
const all = AID.list(root);
|
|
324
|
+
if (json) { say(JSON.stringify({ ok: true, anchors: all })); return 0; }
|
|
325
|
+
if (!all.length) return fail('no anchor is declared: the OKR files and the health budgets name none');
|
|
326
|
+
let g = null;
|
|
327
|
+
for (const a of all) { if (a.group !== g) { g = a.group; say(g); } say(` ${a.value.padEnd(22)}${a.label}`); }
|
|
328
|
+
return 0;
|
|
329
|
+
}
|
|
330
|
+
if (pos[0] === 'fold') {
|
|
331
|
+
if (pos.length !== 1) { say('usage: pmos initiative anchors fold [--apply]'); return 2; }
|
|
332
|
+
const r = AID.fold(root, { apply: !!flags.apply, actor, stateDir, now: now == null ? Date.now() : now });
|
|
333
|
+
if (!r.ok) return fail(r.error);
|
|
334
|
+
if (json) { say(JSON.stringify(r)); return 0; }
|
|
335
|
+
if (!flags.apply) {
|
|
336
|
+
say(`${r.items.length} of ${r.total} anchors have text after the id.`);
|
|
337
|
+
for (const it of r.items.slice(0, 20)) say(` ${it.id}: ${it.anchor} (note: ${it.note.slice(0, 70)}${it.note.length > 70 ? '…' : ''})`);
|
|
338
|
+
if (r.items.length > 20) say(` … and ${r.items.length - 20} more`);
|
|
339
|
+
for (const k of r.kept) say(` kept ${k.id}: ${k.why}`);
|
|
340
|
+
if (r.items.length) say('Run it again with --apply to keep each id and move its text to anchor_note. Nothing was written.');
|
|
341
|
+
return 0;
|
|
342
|
+
}
|
|
343
|
+
say(`✓ ${r.folded} anchors now hold one id; the text after each is in anchor_note.${r.kept.length ? ` ${r.kept.length} kept as they were.` : ''}${r.folded ? ` Undo: pmos initiative anchors undo ${r.batch}` : ''}`);
|
|
344
|
+
return 0;
|
|
345
|
+
}
|
|
346
|
+
if (pos[0] === 'undo') {
|
|
347
|
+
if (pos.length !== 2) { say('usage: pmos initiative anchors undo <batch>'); return 2; }
|
|
348
|
+
const r = AID.undo(root, pos[1], { actor, stateDir, now: now == null ? Date.now() : now });
|
|
349
|
+
if (!r.ok) return fail(r.error, r.status === 400 ? 2 : 1);
|
|
350
|
+
return done(r, r.already ? `${pos[1]} was undone already.` : `✓ ${r.restored} anchors have their whole text back${r.kept ? `; ${r.kept} edited since keep their edit` : ''}.`);
|
|
351
|
+
}
|
|
352
|
+
say('usage: pmos initiative anchors [fold [--apply] | undo <batch>]'); return 2;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (verb === 'anchor') {
|
|
356
|
+
const id = pos[0];
|
|
357
|
+
if (!id || pos.length > 2) { say('usage: pmos initiative anchor <id> ["<anchor>"]'); return 2; }
|
|
358
|
+
const cur = AID.readAnchorLine(root, id);
|
|
359
|
+
if (!cur.ok) return fail(cur.error);
|
|
360
|
+
if (pos.length === 1) return done({ id, anchor: AID.anchorId(cur.text), note: AID.split(cur.text).note }, cur.text ? `${id}: ${AID.anchorId(cur.text)}` : `${id} has no anchor yet.`);
|
|
361
|
+
const c = AID.check(root, pos[1]);
|
|
362
|
+
if (!c.ok) return fail(c.error);
|
|
363
|
+
if (c.note && cur.hasNote) return fail(`${id} has an anchor_note already: give the id alone, ${c.id}`);
|
|
364
|
+
const actor = actorLib.fromCli(who);
|
|
365
|
+
const r = writer.setAnchor(root, id, c.id, { actor });
|
|
366
|
+
if (!r.ok) return fail(r.error);
|
|
367
|
+
if (c.note) AID.foldAnchor(root, id, { anchor: c.id, note: c.note, expect: c.id }, { actor });
|
|
368
|
+
return done({ id, anchor: c.id, from: r.from }, `✓ ${id} is anchored to ${c.id}${r.from && r.from !== c.id ? ` (was ${r.from})` : ''}. Work shows it now.`);
|
|
369
|
+
}
|
|
370
|
+
|
|
306
371
|
if (verb === 'status' || verb === 'status-migrate' || verb === 'status-undo') {
|
|
307
372
|
// status-line (A505): the record's status in one line of at most 12 words; the whole text stays in the item's log
|
|
308
373
|
const SL = require('./status-line.js');
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* layouts-cli.js — `pmos layouts` (initiative three-layouts, job #1904, idea A317). The verb's module; lib/three-layouts.js holds the store,
|
|
3
|
+
* the rules and the commands, so the Work popup's route and the terminal read and write the same layouts.jsonl.
|
|
4
|
+
* run(argv, { say, root?, cwd?, stateDir?, runtimeDir? }) → exit code · COMMANDS · USAGE */
|
|
5
|
+
const T = require('./three-layouts.js');
|
|
6
|
+
module.exports = { run: (argv, o) => T.run(argv, o), COMMANDS: T.COMMANDS, USAGE: T.USAGE };
|