create-pmos 0.747.0 → 0.749.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 +51 -34
- package/payload/AGENTS.md +1 -0
- 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 +50 -0
- package/workspace/guide/backlog.md +13 -1
- package/workspace/guide/cli.md +12 -1
- package/workspace/guide/home.md +1 -1
- package/workspace/guide/layout.md +6 -6
- package/workspace/lib/idle-lab.js +16 -6
- package/workspace/lib/outcome-props.js +14 -4
- package/workspace/lib/outcomes-cli.js +44 -6
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/proposals.js +12 -2
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-lab.js +19 -0
- package/workspace/lib/routes-proposals.js +13 -0
- package/workspace/lib/routes-standing-rules.js +44 -0
- package/workspace/lib/routes-your-move.js +7 -1
- package/workspace/lib/rules-cli.js +74 -0
- package/workspace/lib/smallest-test.js +200 -0
- package/workspace/lib/sprint-draft.js +24 -0
- package/workspace/lib/standing-rules.js +187 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-backlog-ds.js +58 -1
- package/workspace/public/pm/bd-backlog.js +14 -2
- package/workspace/public/pm/cozy-day-pick.js +34 -2
- package/workspace/public/pm/cozy-pop-work.js +14 -5
- package/workspace/public/pm/cozy-settings.js +6 -2
- package/workspace/public/pm/cozy-today-app.js +12 -6
- package/workspace/public/pm/cozy-today-model.js +88 -45
- package/workspace/public/pm/cozy-today-page.css +6 -0
- package/workspace/public/pm/cozy-today-view.js +72 -13
- package/workspace/public/pm/range-pick.css +1 -0
- package/workspace/public/pm/range-pick.js +21 -4
- package/workspace/public/pm/standing-rules-ui.js +100 -0
- package/workspace/stage-card-tasks-test.js +24 -2
- package/workspace/task-card-test.js +16 -0
- package/workspace/test-lists/smallest-test.json +9 -0
- package/workspace/test-lists/sprint-draft.json +9 -0
- package/workspace/test-lists/standing-rules-list.json +9 -0
- package/workspace/test-lists/your-move-today.json +9 -0
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
* outcome the expected outcome and its check date (D57; lib/outcomes.js, filed by lib/outcome-props.js): type new (no outcome yet) or date
|
|
19
19
|
* (an outcome with no date). Type refuted (launch simulation W2): the check said it did not work, and PMOS recommends the next
|
|
20
20
|
* step, data { next: kill | iterate | new, check, evidence, horizon (iterate) }; class C, so only the PM's ✓ does it. data { metric, horizon }; one item { id: 'outcome', title: the metric, due: the date }. Always section
|
|
21
|
-
* 'check': its own ✓, never Keep all. ✓ writes the record's outcome_metric and outcome_horizon lines (lib/initiative-writer.js)
|
|
21
|
+
* 'check': its own ✓, never Keep all. ✓ writes the record's outcome_metric and outcome_horizon lines (lib/initiative-writer.js).
|
|
22
|
+
* Type test (bet A472): the smallest test that could kill a ranked bet, data { test, method }; ✓ records it as planned
|
|
23
|
+
* (lib/smallest-test.js recordTest), Undo takes it back.
|
|
22
24
|
* description the record's own description (initiative-description-field; filed by lib/description-props.js): type new (none yet) or
|
|
23
25
|
* enrich (the PRD says more). data { text, from? }; one item { id: 'description', title: the text cut }. Always section 'check'.
|
|
24
26
|
* ✓ writes the record's description line (lib/initiative-writer.js setDescription)
|
|
@@ -86,7 +88,7 @@ const KINDS = new Set(['epoch', 'look', 'src', 'end', 'propose', 'drop', 'keep',
|
|
|
86
88
|
const EXPIRE_DAYS = 14;
|
|
87
89
|
const EXPIRE_WHY = 'No answer in 14 days, so I left it as it was.';
|
|
88
90
|
const GROUPS = ['found', 'dates', 'status', 'names', 'outcome', 'description', 'build'];
|
|
89
|
-
const TYPES = { found: ['stage', 'docs', 'tasks', 'link', 'maybe', 'unplaced'], dates: ['stage', 'task'], status: ['done'], names: ['tidy'], outcome: ['new', 'date', 'refuted', 'verdict', 'source'], description: ['new', 'enrich'], build: ['pr'] };
|
|
91
|
+
const TYPES = { found: ['stage', 'docs', 'tasks', 'link', 'maybe', 'unplaced'], dates: ['stage', 'task'], status: ['done'], names: ['tidy'], outcome: ['new', 'date', 'refuted', 'verdict', 'source', 'test'], description: ['new', 'enrich'], build: ['pr'] };
|
|
90
92
|
const SOURCES = ['drive', 'docs', 'sheets', 'slides', 'jira', 'calendar', 'notes', 'mail', 'slack', 'confluence', 'chat', 'repo'];
|
|
91
93
|
const SOURCE_NAMES = { drive: 'Drive and Slides', docs: 'Docs', sheets: 'Sheets', slides: 'Slides', jira: 'Jira', calendar: 'Calendar and meeting notes', notes: 'Meeting notes',
|
|
92
94
|
mail: 'Gmail', slack: 'Slack', confluence: 'Confluence', chat: 'Chat', repo: 'This repository' };
|
|
@@ -195,6 +197,14 @@ function clean(group, type, input) {
|
|
|
195
197
|
if (evidence.length < 12) return { error: 'data.evidence says what shows it, at least 12 characters' };
|
|
196
198
|
if (!DAY_RE.test(str(d.horizon))) return { error: 'data.horizon is the check date it answers, YYYY-MM-DD' };
|
|
197
199
|
Object.assign(data, { disposition: d.disposition, evidence, horizon: str(d.horizon) });
|
|
200
|
+
} else if (group === 'outcome' && type === 'test') {
|
|
201
|
+
// the smallest test that could kill a ranked bet before it is built (bet A472; lib/smallest-test.js). Class B: ✓ records it
|
|
202
|
+
// as planned in smallest_tests.jsonl (lib/smallest-test.js recordTest), Undo takes the line back (undoTest)
|
|
203
|
+
const d = isObj(input.data) ? input.data : {};
|
|
204
|
+
const test = one(d.test, 500);
|
|
205
|
+
if (test.length < 8) return { error: 'data.test says the test in a few words' };
|
|
206
|
+
if (!['data-count', 'fake-door', 'concierge', 'other'].includes(d.method)) return { error: 'data.method is data-count, fake-door, concierge or other' };
|
|
207
|
+
Object.assign(data, { test, method: d.method });
|
|
198
208
|
} else if (group === 'outcome' && type === 'source') {
|
|
199
209
|
// the one ask for a goal PMOS cannot read (lib/outcome-judge.js): class C, ✓ adds a task for the PM
|
|
200
210
|
const d = isObj(input.data) ? input.data : {};
|
|
@@ -98,6 +98,7 @@ const MODULES = Object.freeze([
|
|
|
98
98
|
'routes-proposals', // batch 12 items 2, 3 and 4: everything Claude proposes on an initiative, under its one ✦ (proposals.jsonl; page-press POST)
|
|
99
99
|
'routes-autonomy', // D106: what agents did by themselves (the Done group, 14 days), its Undo, and the demotions Home says once (autonomy.jsonl)
|
|
100
100
|
'routes-your-move', // workspace grill W3: Your move's overdue outcome verdicts (drafted from Jira) and the first key result with no reading (GET)
|
|
101
|
+
'routes-standing-rules', // standing-rules-list (A470): the standing rules PMOS keeps, with edit, retire and bring back (memory + standing-rules.jsonl)
|
|
101
102
|
'routes-lab', // idle lab (build U): Intelligence › Lab, the compare view, the specimen files and the Lab's own ✦ (idle-lab.jsonl; page-press POST)
|
|
102
103
|
'routes-loose', // batch 13 item 3: Claude's clean-up of Home's "Not in an initiative" under the group's ✦ (loose-props/; page-press POST)
|
|
103
104
|
'routes-workflows', // workflows-per-initiative (D99): the workflow library, save, copy, archive and the chat's draft (workflows.jsonl; page-press POST)
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* POST /api/lab/keep { ws, id } → { ok, batch, said } ✓ on a Lab ✦: start keeps it and starts the initiative on its board
|
|
14
14
|
* POST /api/lab/drop { ws, id, why? } → { ok, batch } ✕, with the PM's reason when given
|
|
15
15
|
* POST /api/lab/undo { ws, batch } → { ok } Undo of a keep or a drop (a started initiative stays: close it on the Board)
|
|
16
|
+
* A `retire` ✦ (lib/standing-rules.js, bet A470) is filed on GET /api/lab once a month when standing rules have not fired in 30 days;
|
|
17
|
+
* its ✓ retires them (each memory entry leaves) and its Undo brings them back.
|
|
16
18
|
* POST /api/lab/round { ws?, board?, ini, brief, base?, dirs?, propose? } → the live round (lib/live-round.js): `pmos lab round` starts one,
|
|
17
19
|
* or with propose: true files its ✦ ask. No page press needed (D98); it writes no record.
|
|
18
20
|
* Prototype by chatting (initiative live-round-iterative): the compare view of a live round carries its version's companions as data
|
|
@@ -120,6 +122,8 @@ const READS = {
|
|
|
120
122
|
const w = wsOf(ctx, url.searchParams.get('ws')); if (!w) return fail(ctx, res, 404, 'no such workspace');
|
|
121
123
|
const dir = dirOf(ctx, w); if (!dir) { ctx.json(res, { ok: true, lab: null }); return true; }
|
|
122
124
|
const now = Date.now(), T = titles(w);
|
|
125
|
+
// the monthly ask on standing rules that have not fired in 30 days (lib/standing-rules.js): filed here, at most once in 30 days
|
|
126
|
+
require('./standing-rules.js').filePrompt(w.root, dir, { now });
|
|
123
127
|
const lab = LAB.labOf({ P: PR.read(dir), L: LAB.read(dir), extra: others(ctx, w, dir, T, now), now, titleOf: (ini) => (T.get(ini) || {}).title || '' });
|
|
124
128
|
ctx.json(res, { ok: true, lab });
|
|
125
129
|
return true;
|
|
@@ -198,6 +202,15 @@ const WRITES = {
|
|
|
198
202
|
if (!r.ok) return fail(ctx, res, 409, 'The rule was not saved: ' + r.error);
|
|
199
203
|
wrote.push({ op: 'memory', text: p.title }); said = 'PMOS will follow this from now on.';
|
|
200
204
|
}
|
|
205
|
+
if (p.type === 'retire') {
|
|
206
|
+
// the monthly ask on quiet standing rules (lib/standing-rules.js, bet A470): each named rule leaves memory; Undo brings it back
|
|
207
|
+
const by = humanOf(g.actor);
|
|
208
|
+
if (!by) return fail(ctx, res, 403, 'Only the PM retires a standing rule');
|
|
209
|
+
const SR = require('./standing-rules.js');
|
|
210
|
+
for (const id of (p.data && p.data.ids) || []) { const r = SR.retire(w.root, { id, by }); if (r.ok) wrote.push({ op: 'retire', id, text: r.rule.text }); }
|
|
211
|
+
SR.use(w.root, { op: 'keep', id: p.id, by });
|
|
212
|
+
said = wrote.length === 1 ? 'Retired 1 standing rule. Bring it back in Settings.' : 'Retired ' + wrote.length + ' standing rules. Bring them back in Settings.';
|
|
213
|
+
}
|
|
201
214
|
const batch = PR.newBatch();
|
|
202
215
|
LAB.append(dir, g.actor, { kind: 'keep', id: p.id, batch, wrote });
|
|
203
216
|
ctx.json(res, { ok: true, batch, said });
|
|
@@ -210,6 +223,7 @@ const WRITES = {
|
|
|
210
223
|
const batch = PR.newBatch();
|
|
211
224
|
LAB.append(dir, g.actor, { kind: 'drop', id: p.id, batch, ...(why ? { why } : {}) });
|
|
212
225
|
if (why) require('./corrections-memory.js').remember(w.root, { what: 'an idle-lab result', why, source: 'lab:' + p.id });
|
|
226
|
+
if (p.type === 'retire') require('./standing-rules.js').use(w.root, { op: 'drop', id: p.id, by: humanOf(g.actor) || undefined });
|
|
213
227
|
ctx.json(res, { ok: true, batch });
|
|
214
228
|
return true;
|
|
215
229
|
},
|
|
@@ -222,6 +236,11 @@ const WRITES = {
|
|
|
222
236
|
const r = ruleWrite(w.root, { op: 'remove', old: x.text, by: humanOf(g.actor) || 'agent:corrections' });
|
|
223
237
|
if (!r.ok && !/no (?:entry|match)|not found/i.test(String(r.error))) return fail(ctx, res, 409, 'The rule was not removed: ' + r.error);
|
|
224
238
|
}
|
|
239
|
+
// retired standing rules (the monthly ask): bring each back
|
|
240
|
+
for (const k of F.kept) if (k.batch === b) for (const x of k.wrote) if (x.op === 'retire' && x.text) {
|
|
241
|
+
const r = require('./standing-rules.js').restore(w.root, { id: x.text, by: humanOf(g.actor) || 'agent:standing-rules' });
|
|
242
|
+
if (!r.ok && !/no retired rule/.test(String(r.error))) return fail(ctx, res, 409, 'The rule was not brought back: ' + r.error);
|
|
243
|
+
}
|
|
225
244
|
LAB.append(dir, g.actor, { kind: 'undo', batch: b });
|
|
226
245
|
ctx.json(res, { ok: true });
|
|
227
246
|
return true;
|
|
@@ -145,6 +145,7 @@ function undoCore(ctx, p, g, id) {
|
|
|
145
145
|
for (const pid of k.ids) { const pp = F.props.get(pid); if (pp && pp.group === 'outcome' && pp.type === 'verdict') PR.append(dir, { by: 'pmos:outcomes' }, { kind: 'drop', ini: k.ini, sig: PR.sigOf(pp), id: pid, group: 'outcome', type: 'verdict' }); }
|
|
146
146
|
continue;
|
|
147
147
|
}
|
|
148
|
+
else if (w.op === 'test') { const r2 = require('./smallest-test.js').undoTest(p.w.root, { initiative: k.ini, at: w.at, by: (g.actor && g.actor.by) || 'pm', via: 'ui' }); if (r2.ok) back++; else kept++; continue; } // the smallest test (bet A472)
|
|
148
149
|
else if (w.op === 'outcome') { const r2 = require('./initiative-writer.js').restoreOutcome(p.w.root, k.ini, w.from || {}, w.to || {}, { actor: g.actor }); if (r2.ok && !r2.kept) back++; else kept++; continue; } // a record edited since keeps its edit
|
|
149
150
|
if (r && r.body && r.body.ok) back++; else kept++;
|
|
150
151
|
}
|
|
@@ -368,6 +369,18 @@ function applyOne(ctx, p, g, f, ini, x, choices, outbox) {
|
|
|
368
369
|
if (r.ok) add({ op: 'verdict', at: r.line.at, disposition: d.disposition, horizon: d.horizon });
|
|
369
370
|
else x.failed = r.error;
|
|
370
371
|
}
|
|
372
|
+
} else if (x.group === 'outcome' && x.type === 'test') {
|
|
373
|
+
// the smallest test before a build (bet A472; lib/smallest-test.js recordTest). Class B: ✓ records it as planned, Undo takes the line back.
|
|
374
|
+
// A bet that has a test already (recorded another way) keeps it: nothing is written.
|
|
375
|
+
const ST = require('./smallest-test.js'), d = x.data || {};
|
|
376
|
+
const S = ST.testScan(p.w.root), it = S.subjects.find((y) => y.id === ini);
|
|
377
|
+
if (!it) x.failed = 'This initiative is not here any more, or it is stopped.';
|
|
378
|
+
else if (!it.test) {
|
|
379
|
+
const by = g.actor && g.actor.by && g.actor.by !== 'agent:auto' ? g.actor.by : 'agent:outcomes';
|
|
380
|
+
const r = ST.recordTest(p.w.root, { initiative: ini, method: d.method, test: d.test, result: 'planned', by, via: (g.actor && g.actor.via) || 'ui' });
|
|
381
|
+
if (r.ok) add({ op: 'test', at: r.line.at });
|
|
382
|
+
else x.failed = r.error;
|
|
383
|
+
}
|
|
371
384
|
} else if (x.group === 'outcome' && x.type === 'source') {
|
|
372
385
|
// the one ask for a goal PMOS cannot read (lib/outcome-judge.js). Class C: only the PM's ✓ reaches here. It adds a task for the PM.
|
|
373
386
|
const d = x.data || {}, title = `Connect the source of "${String(d.goal || 'the goal').slice(0, 80)}", or pick another number`.slice(0, 200);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-standing-rules.js — the standing rules PMOS keeps for a product, read, edited and retired (bet A470; lib/standing-rules.js).
|
|
3
|
+
*
|
|
4
|
+
* GET /api/standing-rules?ws=<id> → { ok, rules, retired, quiet } Settings › How PMOS decides › Standing rules
|
|
5
|
+
* POST /api/standing-rules { ws, op: edit, id, text } → { ok, rule } new words for a rule (its source stays)
|
|
6
|
+
* POST /api/standing-rules { ws, op: retire | restore, id } → { ok, rule } take a rule out of every run, or bring a retired one back
|
|
7
|
+
*
|
|
8
|
+
* A POST from a page passes pm-guard requirePagePress; one with no Origin is the chat's agent (`pmos rules`, D98), which keeps its own name
|
|
9
|
+
* on the memory line. A product with no memory answers an empty list. Each use is one line in standing-rules.jsonl (the health number). */
|
|
10
|
+
const guard = require('./pm-guard.js');
|
|
11
|
+
const SR = require('./standing-rules.js');
|
|
12
|
+
|
|
13
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
14
|
+
const fail = (ctx, res, status, error) => { ctx.json(res, { ok: false, error }, status); return true; };
|
|
15
|
+
function wsOf(ctx, id) { let w = null; try { w = ctx.getWs(id || null); } catch { w = null; } return w && (!id || w.id === id) ? w : null; }
|
|
16
|
+
const humanOf = (actor) => { const by = String((actor && actor.by) || ''); return /^pm:[A-Za-z0-9_-]{1,40}$/.test(by) ? 'human:' + by.slice(3) : /^human:/.test(by) ? by : null; };
|
|
17
|
+
|
|
18
|
+
module.exports = {
|
|
19
|
+
prefixes: ['/api/standing-rules'],
|
|
20
|
+
handle: async (req, res, url, ctx) => {
|
|
21
|
+
if (url.pathname !== '/api/standing-rules') return fail(ctx, res, 404, 'not found');
|
|
22
|
+
if (req.method === 'GET') {
|
|
23
|
+
const w = wsOf(ctx, url.searchParams.get('ws')); if (!w) return fail(ctx, res, 404, 'no such workspace');
|
|
24
|
+
const L = SR.listOf(w.root);
|
|
25
|
+
if (url.searchParams.get('view') === '1') SR.use(w.root, { op: 'view' });
|
|
26
|
+
ctx.json(res, { ok: true, ...L });
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (req.method !== 'POST') return fail(ctx, res, 405, 'GET or POST only');
|
|
30
|
+
const got = await ctx.readJson(req);
|
|
31
|
+
if (!got.ok || !isObj(got.body)) return fail(ctx, res, 400, 'the body must be a JSON object');
|
|
32
|
+
const b = got.body;
|
|
33
|
+
let by;
|
|
34
|
+
if (req.headers.origin) { const g = guard.requirePagePress(req, b); if (!g.ok) return fail(ctx, res, g.status, g.error); by = humanOf(g.actor) || 'pm:page'; }
|
|
35
|
+
else by = /^(pm|agent):[\w.:-]{1,80}$/.test(String(b.by || '')) ? b.by : 'agent:cli';
|
|
36
|
+
const w = wsOf(ctx, typeof b.ws === 'string' && b.ws ? b.ws : null); if (!w) return fail(ctx, res, 404, 'no such workspace');
|
|
37
|
+
const id = typeof b.id === 'string' ? b.id : '';
|
|
38
|
+
const r = b.op === 'edit' ? SR.edit(w.root, { id, text: b.text, by }) : b.op === 'retire' ? SR.retire(w.root, { id, by })
|
|
39
|
+
: b.op === 'restore' ? SR.restore(w.root, { id, by }) : { ok: false, error: 'op is edit, retire or restore' };
|
|
40
|
+
if (!r.ok) return fail(ctx, res, /^op is/.test(r.error) || /needs its text/.test(r.error) ? 400 : 409, r.error);
|
|
41
|
+
ctx.json(res, r);
|
|
42
|
+
return true;
|
|
43
|
+
},
|
|
44
|
+
};
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* DONE (C2, board CsD): what an agent kept by itself in the last 14 days, one line per batch with its Undo (lib/done-feed.js).
|
|
17
17
|
* QUESTIONS (act-alone-only-with-a-source): { day, questions: [lib/question-batch.js question], later } — the changes PMOS holds for want
|
|
18
18
|
* of a source, one question per owner and initiative, the PM's first; the list is fixed for the day (one line in question-days.jsonl).
|
|
19
|
-
* On the same card (dry-run-tickets-before-build): the dry-run gaps of drafted tickets and the outside sign-offs with no answer
|
|
19
|
+
* On the same card (dry-run-tickets-before-build): the dry-run gaps of drafted tickets and the outside sign-offs with no answer, and (bet A472)
|
|
20
|
+
* each smallest test that was named and has no result yet.
|
|
20
21
|
* DEFAULTS (default-decisions-with-a-deadline, lib/default-decisions.js): each question carries `default` ({ choice, due, n, say } | null),
|
|
21
22
|
* `waits` (why it has no default | null), `waiting` (days on the list) and `cost` (A27: what the wait holds up | null). The read takes the
|
|
22
23
|
* defaults due today (one batch each, with Undo in "PMOS did"), and `taken` lists them. A dry-run gap or a sign-off never defaults. */
|
|
@@ -103,6 +104,11 @@ function asksOf(root, now = Date.now()) {
|
|
|
103
104
|
const title = (JT.recordFm(root, ini) || {}).title || ini;
|
|
104
105
|
for (const g of JT.dryRunGaps(root, ini)) out.push({ ini, title, id: `dry:${ini}:${g.ticket}:${g.n}`, text: `Ticket ${g.ticket}: ${/[?.]$/.test(g.q) ? g.q : g.q + '?'}` });
|
|
105
106
|
}
|
|
107
|
+
// smallest test first (bet A472): a ranked bet's test that was named and has no result yet; the chat records it (pmos outcomes test)
|
|
108
|
+
try {
|
|
109
|
+
const ST = require('./smallest-test.js');
|
|
110
|
+
for (const t of ST.waitingTestsOf(root)) out.push({ ini: t.id, title: t.title, id: `test:${t.id}:${t.at}`, text: `What did its smallest test show? ${t.test}` });
|
|
111
|
+
} catch { /* no tests to ask about */ }
|
|
106
112
|
for (const p of SO.partsOf(SO.list(SO.fileOf(JT.stateDirOf(root)), { open: true }), now)) {
|
|
107
113
|
out.push({ ini: p.ini, title: (JT.recordFm(root, p.ini) || {}).title || p.ini, id: p.id, text: p.text });
|
|
108
114
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* rules-cli.js — `pmos rules`: the standing rules PMOS keeps for this product, from the chat or a terminal (bet A470; lib/standing-rules.js).
|
|
3
|
+
*
|
|
4
|
+
* pmos rules [list] [--json] [--root <dir>] every standing rule, numbered: where it came from, times fired, last fired; then Retired
|
|
5
|
+
* pmos rules edit <n> --text "…" new words for rule n (its source stays)
|
|
6
|
+
* pmos rules retire <n> take rule n out of every run (Settings › How PMOS decides › Standing rules has Bring back)
|
|
7
|
+
* pmos rules restore <n> bring back retired rule n (the number in the Retired list)
|
|
8
|
+
* pmos rules count [--root <dir>] uses of the list in the last 7 days (the health number; last line)
|
|
9
|
+
*
|
|
10
|
+
* It writes the product's memory and standing-rules.jsonl directly, the same writer the page's route uses, so the page shows the change
|
|
11
|
+
* on its next read. The line it writes names the agent (D98). Exit codes: 0 done, 1 refused, 2 usage. */
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const { execFileSync } = require('child_process');
|
|
14
|
+
const SR = require('./standing-rules.js');
|
|
15
|
+
const K = require('./correction-kinds.js');
|
|
16
|
+
|
|
17
|
+
const USAGE = [
|
|
18
|
+
'pmos rules [list] [--json] the standing rules PMOS keeps for this product, numbered, then Retired',
|
|
19
|
+
'pmos rules edit <n> --text "…" new words for rule n',
|
|
20
|
+
'pmos rules retire <n> take rule n out of every run',
|
|
21
|
+
'pmos rules restore <n> bring back retired rule n',
|
|
22
|
+
'pmos rules count uses of the list in the last 7 days (last line)',
|
|
23
|
+
' every command: [--root <dir>]',
|
|
24
|
+
];
|
|
25
|
+
function repoRoot(cwd) {
|
|
26
|
+
try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; }
|
|
27
|
+
catch { return cwd; }
|
|
28
|
+
}
|
|
29
|
+
const day = (at) => String(at || '').slice(0, 10);
|
|
30
|
+
|
|
31
|
+
function run(argv, o = {}) {
|
|
32
|
+
const say = o.say || ((l) => process.stdout.write(l + '\n'));
|
|
33
|
+
const args = argv.slice(1), flags = {}, pos = [];
|
|
34
|
+
for (let i = 0; i < args.length; i++) {
|
|
35
|
+
const a = args[i];
|
|
36
|
+
if (a === '--root' || a === '--text' || a === '--by') flags[a.slice(2)] = args[++i];
|
|
37
|
+
else if (a === '--json') flags.json = true;
|
|
38
|
+
else pos.push(a);
|
|
39
|
+
}
|
|
40
|
+
const cmd = pos[0] || 'list';
|
|
41
|
+
if (cmd === 'help' || cmd === '--help') { USAGE.forEach((l) => say(l)); return 0; }
|
|
42
|
+
const root = path.resolve(flags.root || repoRoot(o.cwd || process.cwd()));
|
|
43
|
+
const by = /^(pm|agent):[\w.:-]{1,80}$/.test(String(flags.by || '')) ? flags.by : 'agent:cli';
|
|
44
|
+
const L = SR.listOf(root);
|
|
45
|
+
if (cmd === 'list') {
|
|
46
|
+
if (flags.json) { say(JSON.stringify(L)); return 0; }
|
|
47
|
+
if (!L.rules.length && !L.retired.length) { say('No standing rules yet. When you correct the same kind of thing 3 times, PMOS offers one in the Lab.'); return 0; }
|
|
48
|
+
L.rules.forEach((r, i) => {
|
|
49
|
+
say(`${i + 1}. ${r.text}`);
|
|
50
|
+
say(` from ${r.from.n} of your corrections${r.from.latest ? ', latest "' + r.from.latest + '"' : ''} · kept ${day(r.keptAt)} · fired ${r.fired} ${r.fired === 1 ? 'time' : 'times'}${r.lastFired ? ', last ' + day(r.lastFired) : ''}${r.quiet ? ' · not fired in 30 days' : ''}`);
|
|
51
|
+
});
|
|
52
|
+
if (L.retired.length) { say('Retired:'); L.retired.forEach((r, i) => say(` R${i + 1}. ${r.text} (retired ${day(r.at)})`)); }
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
if (cmd === 'count') {
|
|
56
|
+
const n = SR.count(SR.readLines(K.stateDir(root)));
|
|
57
|
+
if (flags.json) say(JSON.stringify({ last7: n })); else say(String(n));
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
if (!['edit', 'retire', 'restore'].includes(cmd)) { say(`✗ ${cmd} is not a command of pmos rules`); USAGE.forEach((l) => say(l)); return 2; }
|
|
61
|
+
const raw = String(pos[1] || '').replace(/^R/i, ''), n = Number(raw);
|
|
62
|
+
const pool = cmd === 'restore' ? L.retired : L.rules;
|
|
63
|
+
if (!Number.isInteger(n) || n < 1 || n > pool.length) { say(`✗ say which rule by its number in \`pmos rules\`${cmd === 'restore' ? ' (the R number under Retired)' : ''}`); return 2; }
|
|
64
|
+
const x = pool[n - 1];
|
|
65
|
+
if (cmd === 'edit' && !String(flags.text || '').trim()) { say('✗ pmos rules edit <n> --text "the new words"'); return 2; }
|
|
66
|
+
const r = cmd === 'edit' ? SR.edit(root, { id: x.id, text: flags.text, by }) : cmd === 'retire' ? SR.retire(root, { id: x.id, by }) : SR.restore(root, { id: x.text, by });
|
|
67
|
+
if (!r.ok) { say('✗ ' + r.error); return 1; }
|
|
68
|
+
const staged = r.staged ? ' It waits for your approval first.' : '';
|
|
69
|
+
say(cmd === 'edit' ? `✓ rule ${n} now reads: ${r.rule.text}.${staged}` : cmd === 'retire' ? `✓ retired: ${r.rule.text}. Bring it back with \`pmos rules restore\` or in Settings › How PMOS decides.${staged}`
|
|
70
|
+
: `✓ back: ${r.rule.text}. Every run reads it again.${staged}`);
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = { run, USAGE, COMMANDS: { rules: ['list', 'edit', 'retire', 'restore', 'count'] } };
|
|
@@ -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
|
+
}
|