create-pmos 0.797.0 → 0.798.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 +20 -24
- 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/scripts/factory-guardrail.js +65 -4
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +19 -0
- package/workspace/guide/layout.md +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-pop-work.js +14 -15
- package/workspace/public/pm/status-edit.js +30 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.798.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -33,6 +33,25 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.798.0",
|
|
38
|
+
"at": "2026-11-24T23:17:36.353Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1822,
|
|
43
|
+
"t": "The merge station runs the strict guardrail on every merge (A508)",
|
|
44
|
+
"s": "The merge station runs the strict guardrail on every merge (A508)",
|
|
45
|
+
"k": "new"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"n": 1823,
|
|
49
|
+
"t": "Use it in the status editor keeps the whole text in the log (job #1817, A505)",
|
|
50
|
+
"s": "Use it in the status editor keeps the whole text in the log (job #1817, A505)",
|
|
51
|
+
"k": "fix"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
36
55
|
{
|
|
37
56
|
"v": "0.797.0",
|
|
38
57
|
"at": "2026-11-24T23:00:19.305Z",
|
|
@@ -444,29 +463,6 @@
|
|
|
444
463
|
}
|
|
445
464
|
}
|
|
446
465
|
]
|
|
447
|
-
},
|
|
448
|
-
{
|
|
449
|
-
"v": "0.778.0",
|
|
450
|
-
"at": "2026-11-24T14:17:30.065Z",
|
|
451
|
-
"f": 4,
|
|
452
|
-
"prs": [
|
|
453
|
-
{
|
|
454
|
-
"n": 1745,
|
|
455
|
-
"t": "Every live initiative gets an expected outcome and a check date",
|
|
456
|
-
"s": "Every live initiative gets an expected outcome and a check date",
|
|
457
|
-
"k": "new",
|
|
458
|
-
"h": "Every live initiative gets an expected outcome and a check date",
|
|
459
|
-
"try": {
|
|
460
|
-
"steps": [
|
|
461
|
-
"Open Work and open an initiative that had no expected outcome",
|
|
462
|
-
"Press its ✦ and find Expected outcome",
|
|
463
|
-
"Press Undo on it if it is wrong"
|
|
464
|
-
],
|
|
465
|
-
"see": "The initiative shows an expected outcome and a check date that PMOS drafted, with the line it came from, and Undo takes it back",
|
|
466
|
-
"open": "/premium-board.html"
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
]
|
|
470
466
|
}
|
|
471
467
|
]
|
|
472
468
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-24T23:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-24T23:17:32Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-24T23:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-24T23:17:32Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
* [--github --pr <number>] in GitHub Actions only: write verdict to GITHUB_OUTPUT and the step summary; on auto run
|
|
38
38
|
* `gh pr ready` and `gh pr merge --auto --squash` with the workflow's own token; on human turn
|
|
39
39
|
* auto-merge off. The agent never runs this: the Builder has no node, gh or push.
|
|
40
|
+
* node scripts/factory-guardrail.js --line --base origin/main --head <pr head> [--job <id>] [--body-file <f>] [--json]
|
|
41
|
+
* the in-repo factory line's merge station (factory/stations/merge.md): lineVerdict below.
|
|
40
42
|
* Exit 0 for every verdict (the check reports, it does not block). A failure to read anything is `human`, never `auto`.
|
|
41
43
|
*/
|
|
42
44
|
const fs = require('fs');
|
|
@@ -321,7 +323,62 @@ function classify({ cwd = process.cwd(), base, head, branch = '', body = '', led
|
|
|
321
323
|
return { factory: true, item, verdict: uniq.length ? 'human' : 'auto', reasons: uniq, files: files.map((f) => f.path) };
|
|
322
324
|
}
|
|
323
325
|
|
|
326
|
+
/* ---- the in-repo factory line (factory/, A508). Its jobs are GitHub issues and its pull requests carry `Initiative: <id>` or
|
|
327
|
+
* `Factory-Job: <id>`, not a pmos/<item> branch, so classify() answered `none` for every one of them. The merge station runs this
|
|
328
|
+
* on every merge instead. It keeps the irreversible list strict: migrations and data deletion, auth/payments/personal data/secrets,
|
|
329
|
+
* CI and gates, a new dependency, a public API, anything sent outward, a new agent path, agent rules and decision records, and the
|
|
330
|
+
* improvement loop. Any one of them → `human`: the merge waits for Wawan. It leaves out the D108 conditions that only a product
|
|
331
|
+
* repository's work-item ledger can answer (scope, flag, verified, pmos-review): on this line the merge station merges on green CI.
|
|
332
|
+
* It also leaves out changed tests and done tests (every build adds a done test and may fix a test; the Checker grades them) and the
|
|
333
|
+
* D11 history flags (an L2 flag, not an irreversible kind).
|
|
334
|
+
* lineVerdict({ cwd, base, head, body, job }) → { factory: true, item: job, verdict: 'auto'|'human', reasons, files } */
|
|
335
|
+
const LINE_SKIP = new Set(['eval-files']);
|
|
336
|
+
function jobOf(body) {
|
|
337
|
+
const m = /^(?:Factory-Job|Initiative):\s*([a-z0-9][a-z0-9-]*)\s*$/mi.exec(String(body || ''));
|
|
338
|
+
return m ? m[1].toLowerCase() : null;
|
|
339
|
+
}
|
|
340
|
+
function lineVerdict({ cwd = process.cwd(), base, head, body = '', job = null } = {}) {
|
|
341
|
+
const item = job || jobOf(body);
|
|
342
|
+
const reasons = [];
|
|
343
|
+
const human = (rule, detail) => reasons.push({ rule, detail });
|
|
344
|
+
if (/^PMOS-Merge:\s*human\s*$/mi.test(String(body || ''))) human('pmos-merge-human', 'the pull request asks for a person (PMOS-Merge: human)');
|
|
345
|
+
if (!base || !head) { human('unreadable', 'no base or head to compare'); return { factory: true, line: true, item, verdict: 'human', reasons, files: [] }; }
|
|
346
|
+
const d = diffOf(cwd, base, head);
|
|
347
|
+
if (d.error) { human('unreadable', d.error); return { factory: true, line: true, item, verdict: 'human', reasons, files: [] }; }
|
|
348
|
+
const files = d.files, all = [];
|
|
349
|
+
if (!files.length) human('empty', 'the pull request changes nothing');
|
|
350
|
+
for (const f of files) {
|
|
351
|
+
const p = f.path, l = p.toLowerCase(), base_ = path.posix.basename(l);
|
|
352
|
+
all.push(...(d.added.get(p) || []).map((t) => [p, t]));
|
|
353
|
+
if (CI.test(l) || GUARD_NAME.test(l)) human('ci-gates', `${p} is CI, a gate, the guardrail, a PMOS record or branch protection`);
|
|
354
|
+
if (AGENT_FILES.test(l) || segHas(p, AGENT_PATH)) human('agent-path', `${p} is an agent rule, prompt or skill (a new agent path)`);
|
|
355
|
+
if (segHas(p, MIGRATION) || /schema\.prisma$|(^|\/)db\/schema\./.test(l)) human('migration', `${p} is a migration or a schema`);
|
|
356
|
+
if (segHas(p, SENSITIVE) || /(^|\/)\.env(\.|$)|\.(pem|key|p12|pfx|jks)$/.test(l)) human('sensitive', `${p} touches auth, permissions, payments, personal data or secrets`);
|
|
357
|
+
if (segHas(p, API) || /(^|\/)index\.d\.ts$/.test(l)) human('public-api', `${p} is a public API or contract`);
|
|
358
|
+
if (LOCKS.includes(base_)) human('dependency', `${p} changes a lock file (a dependency may be new)`);
|
|
359
|
+
if (MANIFESTS.includes(base_) && (d.added.get(p) || []).some((t) => t.trim())) human('dependency', `${p} changes a dependency manifest`);
|
|
360
|
+
if (base_ === 'package.json') {
|
|
361
|
+
const before = git(cwd, ['show', `${base}:${f.from || p}`]), after = git(cwd, ['show', `${head}:${p}`]);
|
|
362
|
+
const a = before.ok ? depsOf(before.out) : new Set(), b = after.ok ? depsOf(after.out) : null;
|
|
363
|
+
if (!a || !b) human('dependency', `${p} could not be read`);
|
|
364
|
+
else { const added = [...b].filter((x) => !a.has(x)); if (added.length) human('dependency', `${p} adds ${added.map((x) => x.split(':')[1]).join(', ')}`); }
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
for (const r of harnessTriggers(files, { body })) if (!LINE_SKIP.has(r.rule)) human(r.rule, r.detail);
|
|
368
|
+
const code = all.filter(([p]) => !/\.(md|mdx|txt|rst|adoc)$/i.test(p) && !TEST_FILE.test(p.toLowerCase()) && !TEST_NAME.test(p.toLowerCase()));
|
|
369
|
+
for (const t of ADDED) {
|
|
370
|
+
const hit = code.find(([, line]) => t.re.test(line));
|
|
371
|
+
if (hit) human(t.rule, `${hit[0]} ${t.why}: "${one(hit[1], 100)}"`);
|
|
372
|
+
}
|
|
373
|
+
const seen = new Set();
|
|
374
|
+
const uniq = reasons.filter((r) => { const k = r.rule + '|' + r.detail; if (seen.has(k)) return false; seen.add(k); return true; });
|
|
375
|
+
return { factory: true, line: true, item, verdict: uniq.length ? 'human' : 'auto', reasons: uniq, files: files.map((f) => f.path) };
|
|
376
|
+
}
|
|
377
|
+
|
|
324
378
|
function summaryOf(v) {
|
|
379
|
+
if (v.line) return v.verdict === 'auto'
|
|
380
|
+
? `pmos-guardrail (factory line): MERGE ${v.item || 'this pull request'} when required CI is green. Nothing on the irreversible list.`
|
|
381
|
+
: [`pmos-guardrail (factory line): WAIT FOR WAWAN on ${v.item || 'this pull request'}, because:`, ...v.reasons.map((r) => `- ${r.detail}`)].join('\n');
|
|
325
382
|
if (v.verdict === 'none') return 'pmos-guardrail: not a factory pull request. Nothing to do.';
|
|
326
383
|
if (v.verdict === 'auto') return `pmos-guardrail: AUTO for ${v.item}. The pmos-review check passed. Auto-merge is on: GitHub merges when every required check is green. The change reaches users only through its flag.`;
|
|
327
384
|
return [`pmos-guardrail: HUMAN for ${v.item || 'this revert'}. A person merges this pull request, because:`, ...v.reasons.map((r) => `- ${r.detail}`)].join('\n');
|
|
@@ -342,14 +399,18 @@ function actOnGitHub(v, { pr, env = process.env } = {}) {
|
|
|
342
399
|
function cliMain(argv, { say = (s) => console.log(s), env = process.env, cwd = process.cwd() } = {}) {
|
|
343
400
|
const opt = (k) => { const i = argv.indexOf(k); return i !== -1 && argv[i + 1] !== undefined && !argv[i + 1].startsWith('--') ? argv[i + 1] : undefined; };
|
|
344
401
|
const base = opt('--base'), head = opt('--head');
|
|
345
|
-
if (!base || !head) { say('usage: node factory-guardrail.js --base <ref> --head <ref> [--branch <name>] [--body-file <f>] [--review-state <s>] [--json] [--github --pr <n>]'); return 2; }
|
|
402
|
+
if (!base || !head) { say('usage: node factory-guardrail.js --base <ref> --head <ref> [--branch <name>] [--body-file <f>] [--review-state <s>] [--json] [--github --pr <n>] | --line [--job <id>]'); return 2; }
|
|
346
403
|
let body = '';
|
|
347
404
|
if (opt('--body-file')) { try { body = fs.readFileSync(opt('--body-file'), 'utf8'); } catch { body = 'PMOS-Merge: human'; } }
|
|
348
405
|
let v;
|
|
349
406
|
// the CLI always judges the review: an absent --review-state (or an empty one) is "no review", never a pass
|
|
350
407
|
const review = opt('--review-state') || null;
|
|
351
|
-
|
|
352
|
-
|
|
408
|
+
// --line: the in-repo factory line (factory/stations/merge.md), job from --job or the body's Initiative:/Factory-Job: line (A508)
|
|
409
|
+
const line = argv.includes('--line');
|
|
410
|
+
try {
|
|
411
|
+
v = line ? lineVerdict({ cwd, base, head, body, job: opt('--job') || null })
|
|
412
|
+
: classify({ cwd, base, head, branch: opt('--branch') || '', body, headRepo: opt('--head-repo') || null, baseRepo: opt('--base-repo') || null, review });
|
|
413
|
+
} catch (e) { v = { factory: true, line, item: null, verdict: 'human', reasons: [{ rule: 'unreadable', detail: 'the guardrail failed: ' + one(e.message, 200) }], files: [] }; }
|
|
353
414
|
say(argv.includes('--json') ? JSON.stringify(v) : summaryOf(v));
|
|
354
415
|
if (argv.includes('--github')) {
|
|
355
416
|
for (const r of actOnGitHub(v, { pr: opt('--pr'), env })) say(`gh ${r.args.join(' ')} → ${r.status}${r.out ? ' ' + r.out : ''}`);
|
|
@@ -357,5 +418,5 @@ function cliMain(argv, { say = (s) => console.log(s), env = process.env, cwd = p
|
|
|
357
418
|
return 0;
|
|
358
419
|
}
|
|
359
420
|
|
|
360
|
-
module.exports = { classify, harnessTriggers, HARNESS, summaryOf, actOnGitHub, cliMain, REVERT_DAYS, STALE_DAYS, MANIFESTS, LOCKS };
|
|
421
|
+
module.exports = { classify, lineVerdict, jobOf, harnessTriggers, HARNESS, summaryOf, actOnGitHub, cliMain, REVERT_DAYS, STALE_DAYS, MANIFESTS, LOCKS };
|
|
361
422
|
if (require.main === module) process.exitCode = cliMain(process.argv.slice(2));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-24T23:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-24T23:17:32Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.798.0",
|
|
4
|
+
"at": "2026-11-24T23:17:36.353Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1822,
|
|
9
|
+
"t": "The merge station runs the strict guardrail on every merge (A508)",
|
|
10
|
+
"s": "The merge station runs the strict guardrail on every merge (A508)",
|
|
11
|
+
"k": "new"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"n": 1823,
|
|
15
|
+
"t": "Use it in the status editor keeps the whole text in the log (job #1817, A505)",
|
|
16
|
+
"s": "Use it in the status editor keeps the whole text in the log (job #1817, A505)",
|
|
17
|
+
"k": "fix"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
},
|
|
2
21
|
{
|
|
3
22
|
"v": "0.797.0",
|
|
4
23
|
"at": "2026-11-24T23:00:19.305Z",
|
|
@@ -487,7 +487,7 @@ The shape is before the title on Work, Goals and the phone rows, in the Status c
|
|
|
487
487
|
|
|
488
488
|
Where a status shows (a card on Work, the top of an initiative, a row on Home and a row on the phone), you see the state shape, the stage, and one line of at most 12 words. PMOS sets the stage from the work itself, so the line says only what is new.
|
|
489
489
|
|
|
490
|
-
To write a status, press the status line at the top of an initiative. A count shows how many words you have used, for example "9 of 12 words". Past 12 words, the count turns red and PMOS suggests a short line from your text. Select **Use it** to keep that line, or edit it. When you save, the whole text goes to the initiative's log with its date and author, and the short line becomes the status. Nothing is lost.
|
|
490
|
+
To write a status, press the status line at the top of an initiative. A count shows how many words you have used, for example "9 of 12 words". Past 12 words, the count turns red and PMOS suggests a short line from your text. Select **Use it** to keep that line, or edit it. When you save, the whole text goes to the initiative's log with its date and author, and the short line becomes the status. Nothing is lost, also when you edit the line after **Use it**. If you then write past 12 words again, your new text is the whole text.
|
|
491
491
|
|
|
492
492
|
From a terminal or the chat, `pmos initiative status <id>` shows the line and the log, and `pmos initiative status <id> "<text>"` saves a status.
|
|
493
493
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.798.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.798.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -21,6 +21,7 @@ import * as M from './pop-work-model.js';
|
|
|
21
21
|
import * as CB from './cozy-bar.js';
|
|
22
22
|
import { openPop, closePop, undoToast } from './hi-pop.js';
|
|
23
23
|
import { pmGet, pmPost } from './http.js';
|
|
24
|
+
import * as SE from './status-edit.js';
|
|
24
25
|
import * as LE from './live-edit.js'; // an edit shows at once: this popup is drawn again the moment a task write is sent, and after each read
|
|
25
26
|
import * as VW from './cozy-viewer.js';
|
|
26
27
|
import * as ED from './ini-edit.js';
|
|
@@ -785,9 +786,7 @@ async function saveDesc(text, x, h) {
|
|
|
785
786
|
* The editor counts the words ("9 of 12 words"); past 12 the count turns red and PMOS offers a short line from the text (POST
|
|
786
787
|
* /api/initiative/status-suggest, a normal session, else the first 12 words). Use it puts the line in; Save keeps the whole text in the
|
|
787
788
|
* item's log and the line as the status (POST /api/initiative/status). Escape leaves it as it was. */
|
|
788
|
-
const SL_MAX = 12;
|
|
789
789
|
let SLED = null; // the open status editor's Use it and Save
|
|
790
|
-
const slWords = (t) => String(t || '').replace(/\s+/g, ' ').trim().split(' ').filter((w) => /[\p{L}\p{N}]/u.test(w)).length;
|
|
791
790
|
function editStatus(btn, W, x, h) {
|
|
792
791
|
const p = btn.closest('.pw-ostat');
|
|
793
792
|
if (!p || p.querySelector('textarea')) return;
|
|
@@ -796,36 +795,36 @@ function editStatus(btn, W, x, h) {
|
|
|
796
795
|
+ `<span class="pw-swb"><button type="button" class="pw-lk" data-sw-save>Save</button></span>`;
|
|
797
796
|
const ta = p.querySelector('textarea'), wc = p.querySelector('.pw-swc'), sg = p.querySelector('.pw-sws');
|
|
798
797
|
ta.value = was; ta.focus();
|
|
799
|
-
|
|
798
|
+
const st = SE.slState(was); // Use it keeps the whole text, so Save logs it (job #1817)
|
|
799
|
+
let tm = null, asked = '';
|
|
800
800
|
const count = () => {
|
|
801
|
-
const n = slWords(ta.value);
|
|
802
|
-
|
|
803
|
-
|
|
801
|
+
const n = SE.slWords(ta.value);
|
|
802
|
+
st.input(ta.value);
|
|
803
|
+
wc.textContent = n + ' of ' + SE.SL_MAX + ' words'; wc.classList.toggle('over', n > SE.SL_MAX);
|
|
804
|
+
if (n <= SE.SL_MAX) { sg.innerHTML = ''; return; }
|
|
804
805
|
clearTimeout(tm);
|
|
805
806
|
tm = setTimeout(async () => {
|
|
806
807
|
const text = ta.value; if (text === asked) return; asked = text;
|
|
807
808
|
const w = h.where ? h.where() : {};
|
|
808
809
|
const r = await pmPost('/api/initiative/status-suggest', { ws: w.ws, id: x.o().id, text }).catch(() => null);
|
|
809
810
|
if (!r || r.ok === false || ta.value !== text) return;
|
|
810
|
-
|
|
811
|
-
sg.innerHTML = `<i class="pw-spark" aria-hidden="true">✦</i> PMOS keeps the ${slWords(text)} words in the log and suggests: <b>${esc(r.line)}</b> <button type="button" class="pw-lk" data-sw-use>Use it</button>`;
|
|
811
|
+
st.suggest(r.line);
|
|
812
|
+
sg.innerHTML = `<i class="pw-spark" aria-hidden="true">✦</i> PMOS keeps the ${SE.slWords(text)} words in the log and suggests: <b>${esc(r.line)}</b> <button type="button" class="pw-lk" data-sw-use>Use it</button>`;
|
|
812
813
|
}, 600);
|
|
813
814
|
};
|
|
814
815
|
ta.addEventListener('input', count); count();
|
|
815
816
|
let done = false;
|
|
816
817
|
const leave = async (save) => {
|
|
817
818
|
if (done) return; done = true; clearTimeout(tm); SLED = null;
|
|
818
|
-
const
|
|
819
|
-
if (!
|
|
819
|
+
const b = save ? st.save(ta.value) : null;
|
|
820
|
+
if (!b) { if (h.redraw) h.redraw(); return; }
|
|
820
821
|
const w = h.where ? h.where() : {};
|
|
821
|
-
const
|
|
822
|
-
if (slWords(text) > SL_MAX && line) body.line = line;
|
|
823
|
-
const res = await pmPost('/api/initiative/status', body).catch(() => null);
|
|
822
|
+
const res = await pmPost('/api/initiative/status', { ws: w.ws, id: x.o().id, ...b }).catch(() => null);
|
|
824
823
|
if (!res || res.ok === false) { if (h.redraw) h.redraw(); if (h.toast) h.toast((res && res.error) || 'The status was not saved.'); return; }
|
|
825
|
-
if (h.toast) h.toast(
|
|
824
|
+
if (h.toast) h.toast(b.line ? 'Saved. The whole text is in the log.' : 'Saved.');
|
|
826
825
|
if (h.reload) await h.reload(); else if (h.redraw) h.redraw();
|
|
827
826
|
};
|
|
828
|
-
SLED = { use: () => { ta.value =
|
|
827
|
+
SLED = { use: () => { ta.value = st.use(ta.value); count(); ta.focus(); }, save: () => leave(true) }; // the presses come through wire()'s one listener
|
|
829
828
|
ta.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); leave(false); } else if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); leave(true); } });
|
|
830
829
|
}
|
|
831
830
|
const findSug = (W, id) => W.suggests.find((s) => s.id === id) || [...W.rowSuggests.values()].find((s) => s.id === id) || null;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* status-edit.js — the item header's status editor, without the page (status-line, A505; fix job #1817).
|
|
2
|
+
* The editor counts words; past 12 PMOS offers a short line. Use it puts the line in the box and keeps the whole text, so Save logs the
|
|
3
|
+
* whole text and records the line the person sees. Writing past 12 words again makes that new text the whole text.
|
|
4
|
+
*
|
|
5
|
+
* const s = slState(was)
|
|
6
|
+
* s.input(text) on each edit
|
|
7
|
+
* s.suggest(line) PMOS's line for the text now in the box ('' clears it)
|
|
8
|
+
* s.use(text) → line Use it: the box gets the line; the whole text is kept
|
|
9
|
+
* s.save(text) → { text, line? } | null the body for POST /api/initiative/status (null: nothing to save) */
|
|
10
|
+
export const SL_MAX = 12;
|
|
11
|
+
export const slWords = (t) => String(t || '').replace(/\s+/g, ' ').trim().split(' ').filter((w) => /[\p{L}\p{N}]/u.test(w)).length;
|
|
12
|
+
const clean = (t) => String(t || '').replace(/\s+/g, ' ').trim();
|
|
13
|
+
|
|
14
|
+
export function slState(was = '') {
|
|
15
|
+
let line = '', kept = '';
|
|
16
|
+
return {
|
|
17
|
+
get line() { return line; },
|
|
18
|
+
get kept() { return kept; },
|
|
19
|
+
input(text) { if (slWords(text) > SL_MAX) kept = ''; else line = ''; },
|
|
20
|
+
suggest(l) { line = clean(l); },
|
|
21
|
+
use(text) { if (!line) return text; kept = clean(text); const l = line; line = ''; return l; },
|
|
22
|
+
save(text0) {
|
|
23
|
+
const text = clean(text0);
|
|
24
|
+
if (!text) return null;
|
|
25
|
+
if (kept && slWords(text) <= SL_MAX) return { text: kept, line: text };
|
|
26
|
+
if (text === clean(was)) return null;
|
|
27
|
+
return slWords(text) > SL_MAX && line ? { text, line } : { text };
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|