create-pmos 0.748.0 → 0.750.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/package.json +51 -40
  2. package/payload/AGENTS.md +1 -0
  3. package/payload/KIT-VERSION +1 -1
  4. package/payload/planning/evals/eval-calibration.md +1 -1
  5. package/payload/planning/okrs/health-budgets.md +1 -1
  6. package/payload/state/discoveries.md +1 -1
  7. package/workspace/changelog.json +50 -0
  8. package/workspace/guide/backlog.md +13 -1
  9. package/workspace/guide/cli.md +13 -1
  10. package/workspace/guide/home.md +1 -1
  11. package/workspace/guide/layout.md +6 -6
  12. package/workspace/guide/programs.md +1 -0
  13. package/workspace/lib/idle-lab.js +16 -6
  14. package/workspace/lib/outcome-props.js +14 -4
  15. package/workspace/lib/outcomes-cli.js +44 -6
  16. package/workspace/lib/pmos-verbs.js +3 -0
  17. package/workspace/lib/proposals.js +12 -2
  18. package/workspace/lib/repeat-requests.js +123 -0
  19. package/workspace/lib/route-modules.js +1 -0
  20. package/workspace/lib/routes-intake.js +45 -2
  21. package/workspace/lib/routes-lab.js +19 -0
  22. package/workspace/lib/routes-proposals.js +13 -0
  23. package/workspace/lib/routes-standing-rules.js +44 -0
  24. package/workspace/lib/routes-your-move.js +7 -1
  25. package/workspace/lib/rules-cli.js +74 -0
  26. package/workspace/lib/smallest-test.js +200 -0
  27. package/workspace/lib/sprint-draft.js +24 -0
  28. package/workspace/lib/standing-rules.js +187 -0
  29. package/workspace/lib/tracker-cli.js +42 -1
  30. package/workspace/package-lock.json +2 -2
  31. package/workspace/package.json +1 -1
  32. package/workspace/premium-board-actions-test.js +2 -1
  33. package/workspace/public/pm/bd-asks.js +19 -5
  34. package/workspace/public/pm/bd-backlog-ds.js +58 -1
  35. package/workspace/public/pm/bd-backlog.js +14 -2
  36. package/workspace/public/pm/cozy-day-pick.js +34 -2
  37. package/workspace/public/pm/cozy-pop-work.js +13 -5
  38. package/workspace/public/pm/cozy-settings.js +6 -2
  39. package/workspace/public/pm/cozy-today-app.js +12 -6
  40. package/workspace/public/pm/cozy-today-model.js +88 -45
  41. package/workspace/public/pm/cozy-today-page.css +6 -0
  42. package/workspace/public/pm/cozy-today-view.js +72 -13
  43. package/workspace/public/pm/range-pick.css +1 -0
  44. package/workspace/public/pm/range-pick.js +21 -4
  45. package/workspace/public/pm/standing-rules-ui.js +100 -0
  46. package/workspace/task-card-test.js +16 -0
  47. package/workspace/test-lists/repeat-requests.json +9 -0
  48. package/workspace/test-lists/smallest-test.json +9 -0
  49. package/workspace/test-lists/sprint-draft.json +9 -0
  50. package/workspace/test-lists/standing-rules-list.json +9 -0
  51. package/workspace/test-lists/your-move-today.json +9 -0
@@ -0,0 +1,200 @@
1
+ 'use strict';
2
+ /* smallest-test.js — ask for the smallest test before building (bet A472, factory job #1662; done test planning/done-tests/smallest-test-first.md).
3
+ *
4
+ * PMOS's factory learned that a cheap check before a build saves builds (proof T113: 14 of 33 gap checks found the idea already built or
5
+ * weaker than thought). This module offers the same step to every product: when a bet is ranked on the Roadmap (D105: ranked by a line), and
6
+ * before a build is offered, PMOS asks for the cheapest test that could kill it, and records the result on the bet.
7
+ *
8
+ * testScan(root, { today }) → lib/outcomes.js scan, each subject with `test` (its smallest test) and `ranked` (the line that ranked it),
9
+ * and `untested`: ranked by a line, not accepted, not stopped, no smallest-test line; newest ranking first
10
+ * testDrafts(S, { only }) → one ✦ draft per untested bet (kind 'test'): the test picked from its own kill line (a number → a data count,
11
+ * a page or button word → a fake door, else a hand-run of 3 cases), every claim cited path:line
12
+ * recordTest(root, {...}) → the one writer of smallest_tests.jsonl: `planned` names the test, holds | fails | unclear is its result
13
+ * undoTest(root, {...}) → takes one line back (the Undo of the ✦)
14
+ * testsOf(root) · testCount(root, { days }) · waitingTests(S) reads: the standing test per bet, the health number, the planned ones
15
+ *
16
+ * The ledger is smallest_tests.jsonl in the runs folder, one line per write:
17
+ * { v: 1, initiative_id, method: data-count | fake-door | concierge | other, test, result: planned | holds | fails | unclear, evidence?, at, by, via }
18
+ * { v: 1, initiative_id, undo: <at>, at, by, via } takes back the line with that `at`
19
+ * Every write logs one TEST_TAG line on stderr (a --json answer on stdout stays one line). Nothing is sent.
20
+ */
21
+ const fs = require('fs');
22
+ const path = require('path');
23
+ const O = require('./outcomes.js');
24
+
25
+ const DAY = 86400000;
26
+ const ID_RE = /^[a-z0-9][a-z0-9._-]*$/;
27
+ const rel = (root, f) => path.relative(root, f).split(path.sep).join('/');
28
+ const cut = (s, n = 400) => { const t = String(s == null ? '' : s).replace(/\s+$/, ''); return t.length > n ? t.slice(0, n) : t; };
29
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); if (t.length <= n) return t; const c = t.slice(0, n - 1); return (c.slice(0, c.lastIndexOf(' ')) || c).replace(/[,;:\s]+$/, '') + '…'; };
30
+ const src = (root, file, n, text, label) => ({ label, ref: rel(root, file) + ':' + n, quote: cut(String(text).trim()) });
31
+ const claim = (text, sources) => ({ text: clip(text, 240), sources: sources.filter(Boolean) });
32
+ function linesOf(file) { try { return fs.readFileSync(file, 'utf8').split('\n'); } catch { return null; } }
33
+ function jsonRows(file) {
34
+ const L = linesOf(file); if (!L) return [];
35
+ const out = [];
36
+ for (const s of L) { if (!s.trim()) continue; try { const o = JSON.parse(s); if (o && typeof o === 'object') out.push(o); } catch { /* torn */ } }
37
+ return out;
38
+ }
39
+ /** The repository's layout (as lib/outcomes.js reads it): the engine's, else the kit or the planning tree. */
40
+ function layoutOf(root) {
41
+ try { const l = require('./console-state').loadEngine(); if (l.ok) return l.engine.layout(root); } catch { /* fall through */ }
42
+ const kit = fs.existsSync(path.join(root, 'pmos', 'state'));
43
+ return { root, runsDir: kit ? path.join(root, 'pmos', 'state') : path.join(root, 'planning', 'runs') };
44
+ }
45
+
46
+ const TESTS = 'smallest_tests.jsonl';
47
+ const TEST_TAG = '[smallest-test]';
48
+ const TEST_METHODS = Object.freeze(['data-count', 'fake-door', 'concierge', 'other']);
49
+ const TEST_RESULTS = Object.freeze(['planned', 'holds', 'fails', 'unclear']);
50
+ const METHOD_WORDS = Object.freeze({ 'data-count': 'a data count', 'fake-door': 'a fake door', concierge: 'a hand-run', other: 'a test' });
51
+ const RESULT_WORDS = Object.freeze({ planned: 'named, no result yet', holds: 'the bet holds', fails: 'the bet fails', unclear: 'unclear' });
52
+
53
+ /** The newest line that ranked each initiative on the Roadmap: a `ranked` line, or an old `placed` line that applied (not a proposal).
54
+ * A `created` line (the end of the Roadmap by default) is not a ranking. → Map id → { file, n, text, at, ev } */
55
+ function rankedLines(root) {
56
+ const out = new Map();
57
+ let file = null; try { file = require('./plan-ledgers.js').ledgerPath(root, 'placements'); } catch { return out; }
58
+ const Ls = linesOf(file); if (!Ls) return out;
59
+ Ls.forEach((l, i) => {
60
+ let o = null; try { o = JSON.parse(l); } catch { return; }
61
+ if (!o || typeof o.initiative !== 'string' || !ID_RE.test(o.initiative)) return;
62
+ if (!(o.ev === 'ranked' || (o.ev === 'placed' && o.proposed !== true))) return;
63
+ const at = String(o.at || '');
64
+ const prev = out.get(o.initiative);
65
+ if (!prev || at >= prev.at) out.set(o.initiative, { file, n: i + 1, text: l, at, ev: o.ev });
66
+ });
67
+ return out;
68
+ }
69
+
70
+ function testRows(root) {
71
+ const L = layoutOf(root);
72
+ const files = [...new Set([path.join(L.runsDir, TESTS), path.join(root, 'pmos', 'state', TESTS), path.join(root, 'planning', 'runs', TESTS)])];
73
+ return files.flatMap(jsonRows).filter((r) => r && typeof r.initiative_id === 'string');
74
+ }
75
+ /** The standing smallest test of each initiative: its newest line that no undo line took back. → Map id → line */
76
+ function testsOf(root) {
77
+ const rows = testRows(root);
78
+ const gone = new Set(rows.filter((r) => typeof r.undo === 'string' && r.undo).map((r) => r.initiative_id + '|' + r.undo));
79
+ const out = new Map();
80
+ for (const r of rows) {
81
+ if (r.undo || !TEST_RESULTS.includes(r.result) || gone.has(r.initiative_id + '|' + r.at)) continue;
82
+ const prev = out.get(r.initiative_id);
83
+ if (!prev || String(r.at || '') >= String(prev.at || '')) out.set(r.initiative_id, r);
84
+ }
85
+ return out;
86
+ }
87
+ /** The health number (bet A472): initiatives whose smallest test has a result (not `planned`) recorded in the last `days` days. */
88
+ function testCount(root, { days = 14, now = Date.now() } = {}) {
89
+ const since = new Date(now - days * DAY).toISOString();
90
+ const T = testsOf(path.resolve(root));
91
+ let results = 0, planned = 0;
92
+ for (const r of T.values()) { if (String(r.at || '') < since) continue; if (r.result === 'planned') planned++; else results++; }
93
+ return { results, planned, days };
94
+ }
95
+
96
+ const NUMBER_WORD = /\d/;
97
+ const SURFACE_WORD = /\b(page|pages|button|screen|view|card|panel|menu|tab|link|form|row|home|banner|signup|sign-up|landing|checkout|popup|modal)\b/i;
98
+ /** The cheapest test for one bet, from its own kill line: a number in it can be counted on today's data, a surface word can be faked
99
+ * with a door, else the work can be done by hand for 3 cases first. */
100
+ function pickTest(it, kill) {
101
+ const k = kill ? clip(kill.text, 160) : '';
102
+ if (k && NUMBER_WORD.test(k)) return { method: 'data-count', test: `Count it on today's data before building: if the number already meets the kill line ("${k}"), stop.` };
103
+ const words = `${k} ${it.title}`;
104
+ if (SURFACE_WORD.test(words)) return { method: 'fake-door', test: `Add only the entry point (a button or a line) that says "coming soon", and count presses for 7 days. Fewer than 3 presses: stop.` };
105
+ return { method: 'concierge', test: `Do it by hand for 3 real cases first. If nobody uses the result, stop before building.` };
106
+ }
107
+
108
+ function smallestTestDraft(S, it) {
109
+ const kill = O.experimentField(S.root, it, 'kill');
110
+ const t = pickTest(it, kill);
111
+ const r = it.ranked;
112
+ const claims = [claim('It is ranked on the Roadmap and not built yet', [src(S.root, r.file, r.n, r.text, 'Ranked')])];
113
+ if (kill) claims.push(claim(`Its kill line: ${clip(kill.text, 160)}`, [kill.source]));
114
+ return {
115
+ id: `outcome-test:${it.id}`, title: `Smallest test before building ${clip(it.title, 70)}`, confidence: kill ? 'medium' : 'low', claims,
116
+ say: `It is ranked, so it may be built soon. Before that, PMOS suggests ${METHOD_WORDS[t.method]}: ${t.test}${kill ? '' : ' It has no kill line yet, so say what result would stop it.'} Tell PMOS what it showed, and it records the result on the bet.`,
117
+ data: { kind: 'test', initiative: it.id, method: t.method, test: t.test },
118
+ };
119
+ }
120
+
121
+ function writeTestLine(root, line, logLine) {
122
+ const L = layoutOf(root), dir = L.runsDir, file = path.join(dir, TESTS);
123
+ try {
124
+ fs.mkdirSync(dir, { recursive: true });
125
+ const st = (() => { try { return fs.lstatSync(file); } catch { return null; } })();
126
+ if (st && !st.isFile()) return { ok: false, error: 'the smallest-test ledger is not a plain file — nothing was saved' };
127
+ fs.appendFileSync(file, JSON.stringify(line) + '\n');
128
+ try { process.stderr.write(`${TEST_TAG} ${logLine}\n`); } catch { /* no log */ } // stderr: a --json answer on stdout stays one line
129
+ return { ok: true, file: rel(root, file), line };
130
+ } catch (e) { return { ok: false, error: 'the smallest-test ledger could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
131
+ }
132
+
133
+ /** Record a bet's smallest test: `planned` names it, holds | fails | unclear is its result (evidence required). → { ok, file, line } | { ok: false, error } */
134
+ function recordTest(root, { initiative, method, test, result = 'planned', evidence, by, via }, { now = Date.now() } = {}) {
135
+ root = path.resolve(root);
136
+ if (typeof initiative !== 'string' || !ID_RE.test(initiative)) return { ok: false, error: 'name the initiative by its id' };
137
+ if (!TEST_RESULTS.includes(result)) return { ok: false, error: `the result is one of ${TEST_RESULTS.join(', ')}` };
138
+ const m = method == null || method === '' ? null : String(method);
139
+ if (m && !TEST_METHODS.includes(m)) return { ok: false, error: `the method is one of ${TEST_METHODS.join(', ')}` };
140
+ const S = testScan(root, { today: O.todayOf(now) });
141
+ const it = S.subjects.find((x) => x.id === initiative);
142
+ if (!it) return { ok: false, error: `no initiative ${initiative} here (or it is stopped)` };
143
+ const prev = it.test || null;
144
+ let t = String(test || '').replace(/\s+/g, ' ').trim();
145
+ if (!t && prev) t = prev.test; // a result for the test already named
146
+ if (t.length < 8) return { ok: false, error: 'say the test in a few words (--test, at least 8 characters)' };
147
+ if (t.length > 500) return { ok: false, error: 'keep the test under 500 characters' };
148
+ const ev = String(evidence || '').replace(/\s+/g, ' ').trim();
149
+ if (result !== 'planned' && ev.length < 12) return { ok: false, error: 'say what the test showed (--evidence, at least 12 characters): a number, a link or what you saw' };
150
+ if (ev.length > 1000) return { ok: false, error: 'keep the evidence under 1000 characters' };
151
+ const line = { v: 1, initiative_id: initiative, method: m || (prev && prev.method) || 'other', test: t, result, ...(ev ? { evidence: ev } : {}), at: new Date(now).toISOString(), by: by || 'agent:unknown', via: via || 'cli' };
152
+ return writeTestLine(root, line, `${initiative} ${result} ${line.method}`);
153
+ }
154
+
155
+ /** Take back one smallest-test line (the Undo of the ✦): an undo line naming its `at`. Nothing is rewritten. */
156
+ function undoTest(root, { initiative, at, by, via }, { now = Date.now() } = {}) {
157
+ root = path.resolve(root);
158
+ if (typeof initiative !== 'string' || !ID_RE.test(initiative)) return { ok: false, error: 'name the initiative by its id' };
159
+ if (typeof at !== 'string' || !at) return { ok: false, error: 'name the line by its time (at)' };
160
+ return writeTestLine(root, { v: 1, initiative_id: initiative, undo: at, at: new Date(now).toISOString(), by: by || 'pm', via: via || 'ui' }, `${initiative} undo ${at}`);
161
+ }
162
+
163
+ /** The outcome scan with each subject's smallest test (`it.test`) and ranking (`it.ranked`), and `untested`: ranked by a line, not accepted,
164
+ * no smallest-test line yet, newest ranking first. */
165
+ function testScan(root, { today = O.todayOf() } = {}) {
166
+ const S = O.scan(root, { today });
167
+ const ranks = rankedLines(S.root), tests = testsOf(S.root);
168
+ const untested = [];
169
+ for (const it of S.subjects) {
170
+ if (tests.has(it.id)) it.test = tests.get(it.id);
171
+ const r = ranks.get(it.id);
172
+ if (!r || it.accepted) continue;
173
+ it.ranked = r;
174
+ if (!it.test) untested.push(it);
175
+ }
176
+ untested.sort((a, b) => (a.ranked.at < b.ranked.at ? 1 : a.ranked.at > b.ranked.at ? -1 : a.id.localeCompare(b.id)));
177
+ return { ...S, untested };
178
+ }
179
+ /** The ✦ drafts that ask for a smallest test, one per untested bet; `only` limits them to one initiative. */
180
+ function testDrafts(S, { only = null } = {}) {
181
+ return (S.untested || []).filter((it) => !only || it.id === only).map((it) => smallestTestDraft(S, it));
182
+ }
183
+
184
+ /** The same list read from the root: the ledger first, and the full scan only when a planned test is there (Your move reads it on every
185
+ * load, so a product with no planned test costs one small file read). */
186
+ function waitingTestsOf(root) {
187
+ const T = testsOf(path.resolve(root));
188
+ if (![...T.values()].some((r) => r.result === 'planned')) return [];
189
+ return waitingTests(testScan(root));
190
+ }
191
+
192
+ /** The planned tests that wait for a result, newest first. → [{ id, title, test, method, at }] */
193
+ function waitingTests(S) {
194
+ return S.subjects.filter((it) => it.test && it.test.result === 'planned')
195
+ .map((it) => ({ id: it.id, title: it.title, test: it.test.test, method: it.test.method, at: it.test.at }))
196
+ .sort((a, b) => (a.at < b.at ? 1 : -1));
197
+ }
198
+
199
+ module.exports = { TESTS, TEST_TAG, TEST_METHODS, TEST_RESULTS, METHOD_WORDS, RESULT_WORDS, rankedLines, testsOf, testCount, pickTest, smallestTestDraft, testScan, testDrafts,
200
+ recordTest, undoTest, waitingTests, waitingTestsOf };
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+ /* sprint-draft.js — the health number of the sprint draft (initiative sprint-draft-capacity, bet A471).
3
+ *
4
+ * The draft itself is pure page code (public/pm/bd-backlog-ds.js capacityOf and draftOf): the Backlog's Suggestion sizes the next sprint
5
+ * from the sprints the team finished, counts the active sprint's open work as carry-over first, and fills the room left with the ranked
6
+ * ready work. Its ✓, pen and ✕ note sprintDraftYes, sprintDraftEdit and sprintDraftNo in the local use log (lib/use-log.js), this
7
+ * computer only, no item names.
8
+ *
9
+ * CLI: node lib/sprint-draft.js count → [sprint-draft] …, then the drafts taken or changed in the last 14 days on its last line */
10
+ const UL = require('./use-log.js');
11
+
12
+ const DAYS = 14;
13
+ /** Drafts the PM took (✓) or changed (pen) in the last `days` days. */
14
+ const taken = (lines, days = DAYS, now = Date.now()) => UL.controlCount(lines, 'sprintDraftYes', days, now) + UL.controlCount(lines, 'sprintDraftEdit', days, now);
15
+
16
+ module.exports = { DAYS, taken };
17
+
18
+ if (require.main === module) {
19
+ if (process.argv[2] !== 'count') { console.error('usage: node lib/sprint-draft.js count (sprint drafts taken or changed in the last 14 days, on the last line)'); process.exit(2); }
20
+ const dir = require('./state-root.js').defaultRoot({ env: process.env });
21
+ const lines = UL.readLines(dir), n = taken(lines);
22
+ console.log(`[sprint-draft] drafts taken or changed in the last ${DAYS} days: ${n} (said no: ${UL.controlCount(lines, 'sprintDraftNo', DAYS)})`);
23
+ console.log(String(n));
24
+ }
@@ -0,0 +1,187 @@
1
+ 'use strict';
2
+ /* standing-rules.js — the standing rules PMOS keeps, as one plain list the PM can read, edit and retire (bet A470, initiative
3
+ * standing-rules-list; done test planning/done-tests/standing-rules-list.md).
4
+ *
5
+ * A standing rule is a memory entry (D72, scripts/pmos-memory.js through lib/memory.js) whose source is `rule:<kind>`: the PM kept it from
6
+ * a Lab ✦ when one kind of correction repeated (lib/correction-kinds.js, bet A464). Every run reads it and it never goes stale, so the
7
+ * set only grows unless the PM can see it and prune it. This module is that view, for any product built with PMOS.
8
+ *
9
+ * PER RULE. Its text, kind, when it was kept, where it came from (corrections of its kind in the 30 days before it was kept, and the PM's
10
+ * latest words), FIRED (corrections of its kind recorded after it was kept: the habit came up again; runs cannot say which rule they
11
+ * used, so a later correction is the only signal on file) and LAST FIRED. A rule kept QUIET_DAYS or more ago with no firing in the last
12
+ * QUIET_DAYS is quiet: the monthly Lab ✦ (type `retire`, lib/idle-lab.js) asks once whether to retire the quiet ones.
13
+ *
14
+ * LEDGER. standing-rules.jsonl in the product's PMOS state folder (the folder corrections.jsonl uses), one line per use:
15
+ * { at, op: view|edit|retire|restore|prompt|keep|drop, id?, text?, source?, by? }
16
+ * `view` is written at most once a day. Retired rules are the retire lines not followed by a restore of the same text. Each use also logs
17
+ * one line with TAG (the health number reads the ledger).
18
+ *
19
+ * listOf(root, { now }) → { rules: [rule], retired: [{ id, text, source, kind, at }], quiet: [id] }
20
+ * edit(root, { id, text, by }) · retire(root, { id, by }) · restore(root, { id, by }) → { ok, rule? } | { ok: false, error }
21
+ * promptOf(list, lines, { now }) PURE → the Lab ✦ to file now (lib/idle-lab.js loose input), or null
22
+ * filePrompt(root, labDir, { now }) → the filed ✦ id, or null. Never throws.
23
+ * use(root, line) · readLines(dir) · count(lines, now, days)
24
+ */
25
+ const fs = require('fs');
26
+ const path = require('path');
27
+ const K = require('./correction-kinds.js');
28
+
29
+ const DAY = 86400000;
30
+ const LEDGER = 'standing-rules.jsonl';
31
+ const TAG = '[standing-rules]';
32
+ const QUIET_DAYS = 30;
33
+ const SOURCE_RE = /^rule:([a-z]*)$/;
34
+ const PROMPT_PREFIX = 'retire-';
35
+ const OPS = new Set(['view', 'edit', 'retire', 'restore', 'prompt', 'keep', 'drop']);
36
+
37
+ const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
38
+ const one = (s, n) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
39
+ const day = (ms) => new Date(ms).toISOString().slice(0, 10);
40
+
41
+ function mem() { const c = require('./memory.js').core(); if (!c.ok) throw new Error(c.error); return c.core; }
42
+ const kindOfSource = (s) => { const m = SOURCE_RE.exec(String(s || '')); return m ? m[1] : null; };
43
+
44
+ /* ── the ledger ── */
45
+ function readLines(dir) {
46
+ if (!dir) return [];
47
+ let text = '';
48
+ try { text = fs.readFileSync(path.join(dir, LEDGER), 'utf8'); } catch { return []; }
49
+ const out = [];
50
+ for (const raw of text.split('\n')) { if (!raw.trim()) continue; try { const l = JSON.parse(raw); if (isObj(l) && OPS.has(l.op) && l.at) out.push(l); } catch { /* a torn line is skipped */ } }
51
+ return out;
52
+ }
53
+ /** One use: a ledger line and a log line. Nothing when the product has no state folder. `view` once a day. */
54
+ function use(root, line, { now = Date.now(), log = console.log } = {}) {
55
+ try {
56
+ const dir = K.stateDir(root);
57
+ if (!dir) return null;
58
+ if (line.op === 'view' && readLines(dir).some((l) => l.op === 'view' && String(l.at).slice(0, 10) === day(now))) return null;
59
+ const l = { at: new Date(now).toISOString(), ...line };
60
+ fs.appendFileSync(path.join(dir, LEDGER), JSON.stringify(l) + '\n');
61
+ try { log(`${TAG} ${l.op}${l.id ? ' ' + l.id : ''}`); } catch { /* the line is written */ }
62
+ return l;
63
+ } catch { return null; }
64
+ }
65
+ /** PURE. Uses in the last `days` days (the health number). */
66
+ function count(lines, now = Date.now(), days = 7) {
67
+ const since = now - days * DAY;
68
+ return (lines || []).filter((l) => { const at = Date.parse(l.at) || 0; return at >= since && at <= now; }).length;
69
+ }
70
+
71
+ /* ── the list ── */
72
+ function rulesIn(root) {
73
+ const cur = mem().load(root);
74
+ return (cur.state.entries || []).filter((e) => e && e.target === 'memory' && kindOfSource(e.source) !== null && !e.staged);
75
+ }
76
+ function shape(e, corr, now) {
77
+ const kind = kindOfSource(e.source) || '', kept = Date.parse(e.at) || 0, W = QUIET_DAYS * DAY;
78
+ const of = kind ? corr.filter((l) => l.kind === kind) : [];
79
+ const before = of.filter((l) => { const a = Date.parse(l.at) || 0; return a < kept && a >= kept - W; }).sort((a, b) => String(a.at).localeCompare(String(b.at)));
80
+ const after = of.filter((l) => { const a = Date.parse(l.at) || 0; return a >= kept && a <= now; }).sort((a, b) => String(a.at).localeCompare(String(b.at)));
81
+ const lastFired = after.length ? after[after.length - 1].at : null;
82
+ const quiet = now - kept >= W && !(lastFired && now - (Date.parse(lastFired) || 0) < W);
83
+ const label = (K.KINDS.find((k) => k.id === kind) || {}).label || '';
84
+ return { id: e.id, text: e.text, kind, label, keptAt: e.at, edited: e.updated_at && e.updated_at !== e.at ? e.updated_at : null,
85
+ from: { n: before.length, latest: before.length ? one(before[before.length - 1].why, 140) : '' }, fired: after.length, lastFired, quiet };
86
+ }
87
+ function retiredOf(lines, active) {
88
+ const texts = new Set(active.map((r) => r.text)), out = new Map();
89
+ for (const l of lines) {
90
+ if (l.op === 'retire' && l.text) out.set(l.text, { id: l.id, text: l.text, source: l.source || '', kind: kindOfSource(l.source) || '', at: l.at });
91
+ else if (l.op === 'restore' && l.text) out.delete(l.text);
92
+ }
93
+ return [...out.values()].filter((r) => !texts.has(r.text)).sort((a, b) => String(b.at).localeCompare(String(a.at)));
94
+ }
95
+ /** The product's list. A product with no memory or no state folder has an empty list, not an error. */
96
+ function listOf(root, { now = Date.now() } = {}) {
97
+ const dir = K.stateDir(root), corr = K.readLines(dir);
98
+ let entries = [];
99
+ try { entries = rulesIn(root); } catch { entries = []; }
100
+ const rules = entries.map((e) => shape(e, corr, now)).sort((a, b) => String(b.keptAt).localeCompare(String(a.keptAt)));
101
+ return { rules, retired: retiredOf(readLines(dir), rules), quiet: rules.filter((r) => r.quiet).map((r) => r.id) };
102
+ }
103
+
104
+ /* ── edit, retire, bring back ── */
105
+ const find = (root, id) => { try { return rulesIn(root).find((e) => e.id === id) || null; } catch { return null; } };
106
+ function edit(root, { id, text, by = 'agent:cli', log, now } = {}) {
107
+ const t = one(text, 600);
108
+ if (!t) return { ok: false, error: 'a rule needs its text' };
109
+ const e = find(root, String(id || ''));
110
+ if (!e) return { ok: false, error: 'no standing rule ' + (id || '') };
111
+ if (t === e.text) return { ok: true, rule: { id: e.id, text: e.text }, same: true };
112
+ const r = mem().write(root, { op: 'replace', target: 'memory', old: e.text, text: t, by });
113
+ if (!r.ok) return { ok: false, error: r.error };
114
+ use(root, { op: 'edit', id: e.id, text: t, by }, { log, now });
115
+ return { ok: true, rule: { id: e.id, text: t }, staged: !!r.staged };
116
+ }
117
+ function retire(root, { id, by = 'agent:cli', log, now } = {}) {
118
+ const e = find(root, String(id || ''));
119
+ if (!e) return { ok: false, error: 'no standing rule ' + (id || '') };
120
+ const r = mem().write(root, { op: 'remove', target: 'memory', old: e.text, by });
121
+ if (!r.ok) return { ok: false, error: r.error };
122
+ use(root, { op: 'retire', id: e.id, text: e.text, source: e.source, by }, { log, now });
123
+ return { ok: true, rule: { id: e.id, text: e.text, source: e.source }, staged: !!r.staged };
124
+ }
125
+ /** Bring a retired rule back: `id` is the retired rule's id (or its exact text). */
126
+ function restore(root, { id, by = 'agent:cli', log, now } = {}) {
127
+ const dir = K.stateDir(root), active = (() => { try { return rulesIn(root); } catch { return []; } })();
128
+ const r0 = retiredOf(readLines(dir), active.map((e) => ({ text: e.text }))).find((x) => x.id === id || x.text === id);
129
+ if (!r0) return { ok: false, error: 'no retired rule ' + (id || '') };
130
+ const r = mem().write(root, { op: 'add', target: 'memory', text: r0.text, by, ...(r0.source ? { source: r0.source } : {}) });
131
+ if (!r.ok) return { ok: false, error: r.error };
132
+ const back = (() => { try { return rulesIn(root).find((e) => e.text === r0.text); } catch { return null; } })();
133
+ use(root, { op: 'restore', id: back ? back.id : r0.id, text: r0.text, source: r0.source, by }, { log, now });
134
+ return { ok: true, rule: { id: back ? back.id : r0.id, text: r0.text, source: r0.source }, staged: !!r.staged };
135
+ }
136
+
137
+ /* ── the monthly prompt ── */
138
+ /** PURE. The Lab ✦ to file now: the quiet rules, when no prompt was filed in the last QUIET_DAYS. null otherwise. */
139
+ function promptOf(list, lines, { now = Date.now() } = {}) {
140
+ const quiet = (list && list.rules || []).filter((r) => r.quiet);
141
+ if (!quiet.length) return null;
142
+ const last = (lines || []).filter((l) => l.op === 'prompt').map((l) => Date.parse(l.at) || 0).sort((a, b) => b - a)[0] || 0;
143
+ if (now - last < QUIET_DAYS * DAY) return null;
144
+ const n = quiet.length;
145
+ return { id: PROMPT_PREFIX + day(now), title: n === 1 ? 'Retire 1 standing rule that has not fired in 30 days' : `Retire ${n} standing rules that have not fired in 30 days`,
146
+ why: one('Not corrected again since: ' + quiet.slice(0, 3).map((r) => '"' + one(r.text, 70) + '"').join(', ') + (n > 3 ? ` and ${n - 3} more` : '') + '. Retiring keeps the list small; Bring back is in Settings.', 300),
147
+ sources: quiet.slice(0, 5).map((r) => ({ label: 'Standing rule kept ' + day(Date.parse(r.keptAt) || now) })),
148
+ data: { ids: quiet.map((r) => r.id).slice(0, 20) } };
149
+ }
150
+ /** File the monthly ✦ in the Lab when it is due. Never throws; → the ✦ id or null. */
151
+ function filePrompt(root, labDir, { now = Date.now(), log = console.log } = {}) {
152
+ try {
153
+ if (!root || !labDir) return null;
154
+ const dir = K.stateDir(root);
155
+ if (!dir) return null;
156
+ const p = promptOf(listOf(root, { now }), readLines(dir), { now });
157
+ if (!p) return null;
158
+ const LAB = require('./idle-lab.js');
159
+ const v = LAB.loose('retire', p);
160
+ if (v.error) return null;
161
+ LAB.append(labDir, { by: 'agent:standing-rules' }, { kind: 'propose', ...v.prop });
162
+ use(root, { op: 'prompt', id: v.prop.id }, { now, log });
163
+ return v.prop.id;
164
+ } catch { return null; }
165
+ }
166
+
167
+ module.exports = { LEDGER, TAG, QUIET_DAYS, PROMPT_PREFIX, kindOfSource, readLines, use, count, listOf, edit, retire, restore, promptOf, filePrompt };
168
+
169
+ /* node standing-rules.js count|list [--root <repo>] [--json] */
170
+ if (require.main === module) {
171
+ const argv = process.argv.slice(2), cmd = argv[0];
172
+ const opt = (k) => { const i = argv.indexOf(k); return i >= 0 ? argv[i + 1] : null; };
173
+ const root = path.resolve(opt('--root') || '.'), dir = K.stateDir(root);
174
+ if (cmd === 'count') {
175
+ const n = count(readLines(dir));
176
+ if (argv.includes('--json')) process.stdout.write(JSON.stringify({ dir, last7: n }) + '\n');
177
+ else process.stdout.write(`${dir ? '' : 'No PMOS state folder here, so no uses are recorded.\n'}${n}\n`);
178
+ } else if (cmd === 'list') {
179
+ const L = listOf(root);
180
+ if (argv.includes('--json')) process.stdout.write(JSON.stringify(L) + '\n');
181
+ else if (!L.rules.length) process.stdout.write('No standing rules yet.\n');
182
+ else for (const r of L.rules) process.stdout.write(`${r.text}\n fired ${r.fired} times${r.lastFired ? ', last ' + String(r.lastFired).slice(0, 10) : ''}${r.quiet ? ' (quiet)' : ''}\n`);
183
+ } else {
184
+ process.stdout.write('usage: node standing-rules.js count|list [--root <repo>] [--json]\n');
185
+ process.exitCode = cmd ? 1 : 0;
186
+ }
187
+ }
@@ -7,6 +7,9 @@
7
7
  * pmos tracker match [--json | --number | --file] the initiatives the Jira read does not cover, and the epic or ticket that most likely
8
8
  * holds each one's work (initiative link-tracker-work, A465; lib/tracker-match.js). --file files them
9
9
  * under each initiative's ✦ for the PM's ✓; `done` files them after every read
10
+ * pmos tracker repeats ["<ask>"] [--json | --number] how many times an ask was asked before, in the stored Jira reads and the boards'
11
+ * earlier asks (initiative repeat-request-count, A264; lib/repeat-requests.js). With no ask: the share
12
+ * of stored tickets that repeat (--number prints it alone, the health read)
10
13
  * The repository is the one this terminal is in. The record is kept in the per-user runtime folder (lib/tracker-read.js),
11
14
  * never in a repository. This command calls no tracker and moves no item.
12
15
  */
@@ -14,7 +17,7 @@ const { execFileSync } = require('child_process');
14
17
  const stateRoot = require('./state-root');
15
18
  const TR = require('./tracker-read.js');
16
19
 
17
- const COMMANDS = { tracker: ['done', 'status', 'sync', 'match'] };
20
+ const COMMANDS = { tracker: ['done', 'status', 'sync', 'match', 'repeats'] };
18
21
  const USAGE = [
19
22
  'usage: pmos tracker done|status — when tracker items were last read for this repository',
20
23
  ' pmos tracker done [--moved N] [--left N] [--not-found N] the tracker-refresh skill runs this as its last step',
@@ -22,6 +25,8 @@ const USAGE = [
22
25
  ' pmos tracker sync [--number] how much of PMOS matches the last Jira read: state, done day, owner',
23
26
  ' pmos tracker match [--number | --file] the initiatives the Jira read does not cover, and the epic or ticket',
24
27
  ' that most likely holds their work; --file proposes it under each ✦',
28
+ ' pmos tracker repeats ["<ask>"] [--number] how many times an ask was asked before (stored Jira reads, earlier asks);',
29
+ ' with no ask, the share of stored tickets that repeat',
25
30
  ' every command: [--json]',
26
31
  'This command never calls a tracker and moves no item. Only the PM\'s ✓ links a proposed match.',
27
32
  ];
@@ -74,6 +79,7 @@ function run(argv, { say = console.log, env = process.env, stateDir, cwd = proce
74
79
  }
75
80
  if (sub === 'sync') return sync(root, a, say);
76
81
  if (sub === 'match') return match(root, a, say);
82
+ if (sub === 'repeats') return repeats(root, a, say);
77
83
  const rec = TR.read(dir, root);
78
84
  out({ ok: true, record: rec }, rec ? `tracker items last read at ${rec.read_at} (moved ${rec.moved ?? '?'}, left ${rec.left ?? '?'}, not found ${rec.not_found ?? '?'})` : 'tracker items not read yet for this repository');
79
85
  return 0;
@@ -123,4 +129,39 @@ function match(root, a, say) {
123
129
  return 0;
124
130
  }
125
131
 
132
+ /** The asks of this repository's boards ledger (<state>/boards.jsonl), any state. [] when there is none. */
133
+ function asksOf(root) {
134
+ try {
135
+ const dir = require('./tracker-match.js').proposalsDir(root);
136
+ if (!dir) return [];
137
+ const lines = require('fs').readFileSync(require('path').join(dir, 'boards.jsonl'), 'utf8').split('\n').filter(Boolean)
138
+ .map((l) => { try { return JSON.parse(l); } catch { return null; } }).filter(Boolean);
139
+ const B = require(require('./repo-script.js').repoScript('boards.js'));
140
+ return [...B.fold(lines).asks.values()];
141
+ } catch { return []; }
142
+ }
143
+ /** `pmos tracker repeats`: how many times an ask was asked before (lib/repeat-requests.js), or, with no ask, the share of stored tickets
144
+ * that repeat. Reads the stored Jira reads and the boards ledger; calls no tracker and writes nothing. */
145
+ function repeats(root, a, say) {
146
+ const RR = require('./repeat-requests.js');
147
+ const line = a._.slice(1).join(' ').trim();
148
+ const tickets = RR.poolOf(root);
149
+ const s = RR.share(tickets);
150
+ if (!line) {
151
+ RR.log({ root, tickets: s.tickets, repeating: s.repeating, pct: s.pct });
152
+ if (a.json) { say(JSON.stringify({ ok: true, root, ...s })); return 0; }
153
+ if (a.number) { say(s.pct === null ? 'none' : String(s.pct)); return 0; }
154
+ if (!s.tickets) { say('No Jira read is stored here yet, so PMOS has nothing to count.'); return 0; }
155
+ say(`${s.pct}% of the stored tickets repeat: ${s.repeating} of ${s.tickets} have 2 or more others that ask for the same thing.`);
156
+ return 0;
157
+ }
158
+ const r = RR.countFor(line, { tickets, asks: RR.askPool(asksOf(root), null, null) });
159
+ RR.log({ root, count: r.count, jira: r.jira, asks: r.asks });
160
+ if (a.json) { say(JSON.stringify({ ok: true, root, line, ...r })); return 0; }
161
+ if (a.number) { say(String(r.count)); return 0; }
162
+ if (!r.count) { say(s.tickets ? 'Not asked before: no stored ticket and no earlier ask is about the same thing.' : 'No Jira read is stored here yet, and no earlier ask is about the same thing.'); return 0; }
163
+ say(r.say);
164
+ return 0;
165
+ }
166
+
126
167
  module.exports = { run, COMMANDS, USAGE };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.748.0",
3
+ "version": "0.750.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.748.0",
9
+ "version": "0.750.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.748.0",
3
+ "version": "0.750.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -297,7 +297,8 @@ const everyPart = async (pg) => { await pg.waitForSelector('#czViewer .pw-ph', {
297
297
  /* P the POST allow-list and the refusals */
298
298
  const all = P.posts.concat(I.posts);
299
299
  const other = all.filter((x) => !ALLOWED.test(x.path) && x.path !== '/api/briefing-premium/seen' // an opened popup's record (popup context slice 11, R1) is not a press
300
- && x.path !== '/api/loose-props/rows'); // what Home shows loose, sent once when it changed so Claude can propose a clean-up (batch 13 item 3); it changes no work
300
+ && x.path !== '/api/loose-props/rows' // what Home shows loose, sent once when it changed so Claude can propose a clean-up (batch 13 item 3); it changes no work
301
+ && x.path !== '/api/ask-repeats'); // New asks reads how many times each ask was asked before (repeat-request-count); it writes nothing
301
302
  ok('P1 the pages post only to the asks, move, lifecycle, archive, initiative-layout and proposals/look routes', all.length > 10 && !other.length, JSON.stringify(other));
302
303
  const noNonce = await post('/api/boards/move', { id: 'fx-bare', to: ready.model.board.stages[1] }, { 'Content-Type': 'application/json', Origin: BASE });
303
304
  const lifeNo = await post('/api/lifecycle', { initiative_id: 'fx-bare', state: 'on-hold' }, { 'Content-Type': 'application/json', Origin: BASE });
@@ -34,7 +34,7 @@ const krShort = (a) => { const s = String(a || ''); if (!s) return ''; if (/^hea
34
34
  const WHY_NOT = ['Out of scope', 'Already planned', 'Not now', 'Other'];
35
35
 
36
36
  /* ── New asks (BdAsks, BdPhone) ─────────────────────────────────────────────────────────────────────────────────── */
37
- let declining = null, expanded = null, picked = {};
37
+ let declining = null, expanded = null, picked = {}, reps = {}; // reps: ask id → its similar earlier requests (POST /api/ask-repeats)
38
38
  const asksOf = () => ((M().asks && M().asks.rows) || []);
39
39
  function askCard(a, i, phone) {
40
40
  if (phone && i > 0 && expanded !== a.id) return `<button type="button" class="bd-acard row" data-askopen="${esc(a.id)}">${avatar(a.by || a.source)}<span class="tx"><b>${esc(a.by || a.source || 'Someone')}</b> · “${esc(a.line)}”</span>${SV(I.next)}</button>`;
@@ -43,6 +43,7 @@ function askCard(a, i, phone) {
43
43
  const product = prod && prod.name ? `<div class="bd-aprod"><span class="bd-chip sm"><b>${esc(prod.name)}</b></span><span class="bd-amut">Why: ${esc(prod.why || '')}</span></div>` : '';
44
44
  const pills = [a.draft.lane ? `<span class="bd-pill">Suggest: ${esc(cap(a.draft.lane))}</span>` : '', a.draft.anchor ? `<span class="bd-pill">${esc(krShort(a.draft.anchor))}</span>` : '', a.close ? `<span class="bd-pill w">Close to: ${esc(a.close.title)}</span>` : ''].join('');
45
45
  const prior = (a.prior || []).length ? `<p class="bd-warn sm">Close to something you declined: “${esc(a.prior[0].title)}”.</p>` : '';
46
+ const rep = repeatsHtml(reps[a.id]);
46
47
  if (declining === a.id) {
47
48
  return `<div class="bd-acard" data-ask="${esc(a.id)}">${who}<p class="bd-aq">“${esc(a.line)}”</p>${product}<p class="bd-lbl">Why not</p><div class="bd-chips" role="radiogroup" aria-label="Why not">${WHY_NOT.map((w, j) => `<button type="button" class="bd-chip${j === 0 ? ' on' : ''}" role="radio" aria-checked="${j === 0}" data-whynot="${esc(w)}">${esc(w)}</button>`).join('')}</div>`
48
49
  + `<input class="bd-inp sm" name="why" maxlength="400" placeholder="Say a little more, optional" aria-label="Why not, in your words"><p class="bd-amsg" role="status"></p>`
@@ -51,8 +52,10 @@ function askCard(a, i, phone) {
51
52
  const btns = phone
52
53
  ? `<button type="button" class="bd-btn solid wide" data-askact="accept" data-id="${esc(a.id)}">Accept to ${esc(firstStage(a))}</button><div class="bd-arow two">${a.close ? `<button type="button" class="bd-btn" data-askact="add" data-id="${esc(a.id)}">Add to existing</button>` : ''}<button type="button" class="bd-btn ghost" data-askact="decline" data-id="${esc(a.id)}">Decline</button></div>`
53
54
  : `<div class="bd-arow"><button type="button" class="bd-btn sm solid" data-askact="accept" data-id="${esc(a.id)}">Accept to ${esc(firstStage(a))}</button>${a.close ? `<button type="button" class="bd-btn sm" data-askact="add" data-id="${esc(a.id)}">Add to ${esc(a.close.title)}</button>` : ''}<button type="button" class="bd-btn sm ghost" data-askact="decline" data-id="${esc(a.id)}">Decline</button></div>`;
54
- return `<div class="bd-acard" data-ask="${esc(a.id)}">${who}<p class="bd-aq">“${esc(a.line)}”</p>${product}${pills ? `<div class="bd-pills">${pills}</div>` : ''}${prior}${btns}<p class="bd-amsg" role="status"></p></div>`;
55
+ return `<div class="bd-acard" data-ask="${esc(a.id)}">${who}<p class="bd-aq">“${esc(a.line)}”</p>${product}${pills ? `<div class="bd-pills">${pills}</div>` : ''}${prior}${rep}${btns}<p class="bd-amsg" role="status"></p></div>`;
55
56
  }
57
+ /** repeat-request-count (A264): how many times the ask was asked before (lib/repeat-requests.js say). Nothing when never. */
58
+ const repeatsHtml = (r) => (r && r.count > 0 && r.say ? `<div class="bd-need" data-repeats="${r.count}">${SV(I.info)}<span>${esc(r.say)}</span></div>` : '');
56
59
  const firstStage = (a) => (a && a.stages && a.stages[0]) || (M().board.stages || [])[0] || 'Triage';
57
60
  function unsureHtml(L) {
58
61
  if (!L.length) return '';
@@ -73,6 +76,15 @@ function asksHtml() {
73
76
  export function openAsks(btn) {
74
77
  declining = null; expanded = null;
75
78
  Pop.open(asksHtml(), btn, { label: 'New asks', width: 520, cls: 'bd-asks' });
79
+ loadRepeats();
80
+ }
81
+ /** repeat-request-count (A264): the open asks' similar earlier requests, one read per workspace; the cards redraw when they come. */
82
+ async function loadRepeats() {
83
+ const L = asksOf(), wss = [...new Set(L.map((a) => boardOfAsk(a).ws).filter(Boolean))];
84
+ const got = await Promise.all(wss.map((ws) => pmPost('/api/ask-repeats', { ws, ...(M().board.all ? {} : { board: M().board.id }) }).catch(() => null)));
85
+ let any = false;
86
+ for (const r of got) if (r && r.ok && r.repeats) for (const [id, x] of Object.entries(r.repeats)) { reps[id] = x; if (x.count > 0) any = true; }
87
+ if (any && Pop.isOpen() && Pop.el().querySelector('#hAsks')) redrawAsks();
76
88
  }
77
89
  const redrawAsks = () => Pop.redraw(asksHtml());
78
90
  async function acceptAsk(a, btn) {
@@ -130,7 +142,7 @@ const kindBox = () => WK.segHtml(N.kind, N.kindBy === 'pmos', !!M().board.factor
130
142
  function hintsHtml() {
131
143
  const p = N.prior && N.prior[0] && !N.ack ? `<div class="bd-warn"><b>Close to something you declined</b><span>“${esc(N.prior[0].title)}” was set aside in ${esc(N.prior[0].file)}.</span><div class="bd-arow"><button type="button" class="bd-btn sm" data-newact="seewhy">See why</button><button type="button" class="bd-btn sm ghost" data-newact="ack">It is different</button></div></div>` : '';
132
144
  const c = N.close ? `<div class="bd-need">${SV(I.info)}<span>Also close to <button type="button" class="bd-dlink" data-newact="close">${esc(N.close.title)}</button> in ${esc(N.close.stage || 'its stage')}. Add to it instead?</span></div>` : '';
133
- return p + c;
145
+ return p + c + repeatsHtml(N.repeats);
134
146
  }
135
147
  /** The open initiative a new name is close to (the model's rule for asks, run on the page as the PM types). */
136
148
  function closeOf(text) {
@@ -188,9 +200,11 @@ function lean(text) {
188
200
  leanT = setTimeout(async () => {
189
201
  if (!N) return;
190
202
  N.close = text.trim().length > 3 ? closeOf(text) : null;
191
- const r = text.trim().length > 3 ? await pmPost('/api/intake/draft', { line: text.trim() }).catch(() => null) : null;
203
+ const ws = (N.ask && N.ask.ws) || M().board.ws || null, board = M().board.all ? null : M().board.id || null;
204
+ const r = text.trim().length > 3 ? await pmPost('/api/intake/draft', { line: text.trim(), ...(ws ? { ws } : {}), ...(board ? { board } : {}), ...(N.ask && N.ask.id ? { ask: N.ask.id } : {}) }).catch(() => null) : null;
192
205
  if (!N) return;
193
- if (r && r.ok && r.draft) { N.lean = r.draft.lane || N.lean; if (!N.ask) N.prior = r.draft.prior_rejections || []; }
206
+ N.repeats = null;
207
+ if (r && r.ok && r.draft) { N.lean = r.draft.lane || N.lean; if (!N.ask) N.prior = r.draft.prior_rejections || []; N.repeats = r.draft.repeats || null; }
194
208
  // PMOS's pre-pick follows the name until the PM taps a kind; a name that tells nothing goes back to the PM's role (Settings › General ›
195
209
  // Your role; the draft's kind then) with no ✦ line
196
210
  if (N.kindBy !== 'you') { const dr = r && r.ok && r.draft, cue = dr && dr.kind_cue && WK.KINDS.includes(dr.kind); N.kind = cue ? dr.kind : dr && WK.KINDS.includes(dr.kind) ? dr.kind : 'product'; N.kindBy = cue ? 'pmos' : null; }