create-pmos 0.561.0 → 0.563.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/cloud-setup.sh +18 -0
- package/package.json +27 -33
- 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 +26 -0
- package/workspace/guide/cli.md +14 -1
- package/workspace/lib/blueprint-cli.js +135 -0
- package/workspace/lib/blueprint.js +319 -0
- package/workspace/lib/kit-update.js +8 -1
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/remote-access.js +14 -1
- package/workspace/lib/state-backup.js +5 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/server.js +3 -0
- package/workspace/test-lists/blueprint.json +9 -0
package/cloud-setup.sh
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
# PMOS_PKG=<spec> the create-pmos release (default: the newest that downloads)
|
|
34
34
|
# PMOS_NO_SYSTEMD=1 write the minute check but do not install the timer (containers, tests)
|
|
35
35
|
# PMOS_NO_FIREWALL=1 leave the firewall alone
|
|
36
|
+
# PMOS_NO_SSH_HARDEN=1 leave the SSH server settings alone (default: keys only, no passwords, root by key only)
|
|
36
37
|
# PMOS_SKIP_CLAUDE=1 do not install Claude Code (tests)
|
|
37
38
|
set -euo pipefail
|
|
38
39
|
|
|
@@ -192,6 +193,21 @@ cmd_setup() {
|
|
|
192
193
|
if [ "${PMOS_NO_FIREWALL:-}" != 1 ] && have ufw; then
|
|
193
194
|
ufw allow OpenSSH >/dev/null && ufw --force enable >/dev/null && ok "firewall on: SSH only (PMOS listens on this server only; Cloudflare reaches it from inside)"
|
|
194
195
|
fi
|
|
196
|
+
# Security updates install themselves (Ubuntu's unattended-upgrades: the security pocket only, no reboots).
|
|
197
|
+
if apt-get install -y -qq unattended-upgrades >/dev/null 2>&1; then
|
|
198
|
+
printf 'APT::Periodic::Update-Package-Lists "1";\nAPT::Periodic::Unattended-Upgrade "1";\n' >/etc/apt/apt.conf.d/20auto-upgrades
|
|
199
|
+
ok "security updates install themselves"
|
|
200
|
+
fi
|
|
201
|
+
# SSH by key only. Only when root already signs in with a key, so this can never lock the PM out. The file sorts before
|
|
202
|
+
# the image's own (50-cloud-init.conf), and sshd takes the first value it reads. root keeps key sign-in: `move` uses it.
|
|
203
|
+
if [ "${PMOS_NO_SSH_HARDEN:-}" != 1 ] && [ -s /root/.ssh/authorized_keys ] && [ -d /etc/ssh/sshd_config.d ]; then
|
|
204
|
+
printf '# Written by PMOS cloud-setup.sh. PMOS_NO_SSH_HARDEN=1 leaves SSH alone; delete this file to undo.\nPasswordAuthentication no\nKbdInteractiveAuthentication no\nPermitRootLogin prohibit-password\nMaxAuthTries 3\n' >/etc/ssh/sshd_config.d/10-pmos.conf
|
|
205
|
+
if sshd -t 2>/dev/null; then
|
|
206
|
+
{ systemctl reload ssh 2>/dev/null || systemctl reload sshd 2>/dev/null; } && ok "SSH: keys only, no passwords"
|
|
207
|
+
else
|
|
208
|
+
rm -f /etc/ssh/sshd_config.d/10-pmos.conf; note "SSH settings left as they were (the check of the new ones failed)"
|
|
209
|
+
fi
|
|
210
|
+
fi
|
|
195
211
|
|
|
196
212
|
# ── 3. The user ──────────────────────────────────────────────────────────────────────────────────────────────
|
|
197
213
|
say "Setting up the user $PM_USER ($PM_HOME)"
|
|
@@ -227,6 +243,8 @@ cmd_setup() {
|
|
|
227
243
|
fi
|
|
228
244
|
chown -R "$PM_USER:$PM_USER" "$PM_HOME"
|
|
229
245
|
rm -rf "$SEED_DIR"
|
|
246
|
+
# The pack holds the state folder, keys included, and the tunnel credentials: once unpacked, no second copy stays behind.
|
|
247
|
+
rm -f "$PMOS_SEED"
|
|
230
248
|
fi
|
|
231
249
|
|
|
232
250
|
# ── 5. Node, Claude Code and PMOS, as the user ───────────────────────────────────────────────────────────────
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.563.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,32 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.563.0",
|
|
38
|
+
"at": "2026-11-11T12:32:19.496Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1294,
|
|
43
|
+
"t": "The feature registry and pmos blueprint, each status derived from evidence",
|
|
44
|
+
"s": "The feature registry and pmos blueprint, each status derived from evidence",
|
|
45
|
+
"k": "new"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"v": "0.562.0",
|
|
51
|
+
"at": "2026-11-11T11:26:34.804Z",
|
|
52
|
+
"f": 4,
|
|
53
|
+
"prs": [
|
|
54
|
+
{
|
|
55
|
+
"n": 1293,
|
|
56
|
+
"t": "Keep keys out of backups, harden pm-os.app headers, cloud SSH and updates",
|
|
57
|
+
"s": "The PM's keys are no longer copied into the backup folder; pm-os.app tells browsers to stay on HTTPS and refuses framing by other sites; a new cloud server signs in by SSH key only and installs security updates itself.",
|
|
58
|
+
"k": "fix"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
36
62
|
{
|
|
37
63
|
"v": "0.561.0",
|
|
38
64
|
"at": "2026-11-11T10:53:52.082Z",
|
|
@@ -278,38 +304,6 @@
|
|
|
278
304
|
"k": "fix"
|
|
279
305
|
}
|
|
280
306
|
]
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
"v": "0.543.0",
|
|
284
|
-
"at": "2026-11-08T10:18:52.684Z",
|
|
285
|
-
"f": 4,
|
|
286
|
-
"prs": [
|
|
287
|
-
{
|
|
288
|
-
"n": 1271,
|
|
289
|
-
"t": "✕ reasons become memory; each team role reads a notebook of its earlier work",
|
|
290
|
-
"s": "✕ reasons become memory; each team role reads a notebook of its earlier work",
|
|
291
|
-
"k": "new"
|
|
292
|
-
}
|
|
293
|
-
]
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
"v": "0.542.0",
|
|
297
|
-
"at": "2026-11-08T06:18:15.279Z",
|
|
298
|
-
"f": 4,
|
|
299
|
-
"prs": [
|
|
300
|
-
{
|
|
301
|
-
"n": 1265,
|
|
302
|
-
"t": "Chief-of-staff chat — one chat, Your move as the only inbox, Done with Undo (C1–C6)",
|
|
303
|
-
"s": "Your move is the one inbox, at most 5 asks with the rest under Can wait, and one chat opens from any page and says where each answer came from.",
|
|
304
|
-
"k": "new"
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
"n": 1270,
|
|
308
|
-
"t": "Curated memory in every background run, lessons across initiatives, the loop on the health line",
|
|
309
|
-
"s": "Curated memory in every background run, lessons across initiatives, the loop on the health line",
|
|
310
|
-
"k": "new"
|
|
311
|
-
}
|
|
312
|
-
]
|
|
313
307
|
}
|
|
314
308
|
]
|
|
315
309
|
}
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-11T12:32:15Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-11T12:32:15Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-11T12:32:15Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.563.0",
|
|
4
|
+
"at": "2026-11-11T12:32:19.496Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1294,
|
|
9
|
+
"t": "The feature registry and pmos blueprint, each status derived from evidence",
|
|
10
|
+
"s": "The feature registry and pmos blueprint, each status derived from evidence",
|
|
11
|
+
"k": "new"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"v": "0.562.0",
|
|
17
|
+
"at": "2026-11-11T11:26:34.804Z",
|
|
18
|
+
"f": 4,
|
|
19
|
+
"prs": [
|
|
20
|
+
{
|
|
21
|
+
"n": 1293,
|
|
22
|
+
"t": "Keep keys out of backups, harden pm-os.app headers, cloud SSH and updates",
|
|
23
|
+
"s": "The PM's keys are no longer copied into the backup folder; pm-os.app tells browsers to stay on HTTPS and refuses framing by other sites; a new cloud server signs in by SSH key only and installs security updates itself.",
|
|
24
|
+
"k": "fix"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
2
28
|
{
|
|
3
29
|
"v": "0.561.0",
|
|
4
30
|
"at": "2026-11-11T10:53:52.082Z",
|
package/workspace/guide/cli.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Guide
|
|
3
3
|
title: "Command reference: every pmos command, by area"
|
|
4
4
|
description: "Every pmos command of the workspace in one page, grouped by area, with its flags, examples and exit codes."
|
|
5
|
-
timestamp: 2026-11-
|
|
5
|
+
timestamp: 2026-11-11
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Command reference
|
|
@@ -596,6 +596,19 @@ The fields of a schedule:
|
|
|
596
596
|
|
|
597
597
|
## Knowledge
|
|
598
598
|
|
|
599
|
+
### pmos blueprint: every feature and its status
|
|
600
|
+
|
|
601
|
+
`pmos blueprint` lists every feature of the product, by surface, with a status. The status is never typed in: the command works it out from the evidence each feature cites in `planning/blueprint/features.json` (its PRs, its files, its experiment record), from git and from the `gitHead` that npm records for each published version. `planning/blueprint/blueprint.md` gives the rules.
|
|
602
|
+
|
|
603
|
+
| Command | What it does |
|
|
604
|
+
|---|---|
|
|
605
|
+
| `pmos blueprint list [--surface <id>] [--status <status>]` | Lists every feature with its status: Idea, Exploring, Agreed, In build, Live <version> or Retired. `pmos blueprint` alone does the same. |
|
|
606
|
+
| `pmos blueprint show <feature-id>` | Prints one feature: its status and why, its PRs, files, record, guide sections and design. |
|
|
607
|
+
| `pmos blueprint unplaced [--all]` | Lists the guide sections and the feature changes since the first release of the range that no feature cites. `--all` also lists the fixes, chores and docs. |
|
|
608
|
+
| `pmos blueprint check` | Checks the registry: no `status` key anywhere, known surfaces, known guide sections, one id each. The exit code is 1 when it finds a problem. |
|
|
609
|
+
|
|
610
|
+
Every command takes `--json`, `--root <dir>` and `--offline`. Live <version> is the first version whose `gitHead` contains the feature. The command reads the versions from npm and saves the read. With `--offline`, or when npm does not answer, it uses the saved read and says so. With no saved read, a merged feature shows `Live ?`.
|
|
611
|
+
|
|
599
612
|
### pmos kg: find knowledge without reading whole files
|
|
600
613
|
|
|
601
614
|
| Command | What it does |
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* blueprint-cli.js — `pmos blueprint`: every feature of the product with its derived status (lib/blueprint.js).
|
|
3
|
+
*
|
|
4
|
+
* pmos blueprint [list] [--surface <id>] [--status <s>] [--json] every feature by surface, with its status
|
|
5
|
+
* pmos blueprint show <id> [--json] one feature: its evidence and why it has its status
|
|
6
|
+
* pmos blueprint unplaced [--all] [--json] guide sections and release changes no feature cites
|
|
7
|
+
* pmos blueprint check [--json] the registry's own rules (no status key, known surfaces, …)
|
|
8
|
+
* every command: [--offline] [--root <dir>]
|
|
9
|
+
* Exit codes: 0 done, 1 refused (no registry, unknown feature, check found problems), 2 usage. Reads only; writes nothing
|
|
10
|
+
* but the saved read of the releases (pmos/state/blueprint-releases.json, gitignored).
|
|
11
|
+
*/
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const { execFileSync } = require('child_process');
|
|
14
|
+
const B = require('./blueprint.js');
|
|
15
|
+
|
|
16
|
+
const COMMANDS = { blueprint: ['list', 'show', 'unplaced', 'check'] };
|
|
17
|
+
const USAGE = [
|
|
18
|
+
'usage: pmos blueprint [list|show|unplaced|check] — every feature of the product, with a status worked out from its evidence',
|
|
19
|
+
' pmos blueprint list [--surface <id>] [--status <status>] [--json] (the default) every feature by surface',
|
|
20
|
+
' pmos blueprint show <feature-id> [--json] one feature: its evidence and why it has its status',
|
|
21
|
+
' pmos blueprint unplaced [--all] [--json] guide sections and release changes that no feature cites',
|
|
22
|
+
' pmos blueprint check [--json] the registry\'s own rules',
|
|
23
|
+
' every command: [--offline] (no npm read; use the saved one) [--root <dir>]',
|
|
24
|
+
'Statuses: Idea, Exploring, Agreed, In build, Live <version>, Retired. The registry is planning/blueprint/features.json.',
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
function parse(args) {
|
|
28
|
+
const pos = []; const flags = {};
|
|
29
|
+
for (let i = 0; i < args.length; i++) {
|
|
30
|
+
const a = args[i];
|
|
31
|
+
if (!a.startsWith('--')) { pos.push(a); continue; }
|
|
32
|
+
const k = a.slice(2);
|
|
33
|
+
if (['json', 'offline', 'all'].includes(k)) { flags[k] = true; continue; }
|
|
34
|
+
flags[k] = args[i + 1] !== undefined && !String(args[i + 1]).startsWith('--') ? args[++i] : '';
|
|
35
|
+
}
|
|
36
|
+
return { pos, flags };
|
|
37
|
+
}
|
|
38
|
+
function repoRoot(cwd) { try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; } catch { return cwd; } }
|
|
39
|
+
|
|
40
|
+
function releaseLine(r) {
|
|
41
|
+
if (r.source === 'registry') return `Releases: ${r.list.length} versions of the package, read from npm now.`;
|
|
42
|
+
if (r.source === 'saved') return `Releases: ${r.offline ? 'offline' : 'npm did not answer'}; using the saved read from ${String(r.at || 'an earlier run').slice(0, 10)} (${r.list.length} versions).`;
|
|
43
|
+
return `Releases: unknown (${r.error}). A merged feature shows "Live ?": its version cannot be worked out.`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), readReleases = B.readReleases, git } = {}) {
|
|
47
|
+
const args = argv[0] === 'blueprint' ? argv.slice(1) : argv.slice();
|
|
48
|
+
if (['help', '--help', '-h'].includes(args[0])) { for (const l of USAGE) say(l); return 0; }
|
|
49
|
+
const verb = args[0] && !args[0].startsWith('--') ? args[0] : 'list';
|
|
50
|
+
if (!COMMANDS.blueprint.includes(verb)) { say(`unknown blueprint command "${verb}" — one of ${COMMANDS.blueprint.join(', ')}`); return 2; }
|
|
51
|
+
const { pos, flags } = parse(args[0] === verb ? args.slice(1) : args);
|
|
52
|
+
const root = flags.root ? path.resolve(cwd, flags.root) : repoRoot(cwd);
|
|
53
|
+
const loaded = B.load(root);
|
|
54
|
+
if (!loaded.ok) { if (flags.json) say(JSON.stringify({ ok: false, error: loaded.error })); else say('✗ ' + loaded.error); return 1; }
|
|
55
|
+
const reg = loaded.registry;
|
|
56
|
+
|
|
57
|
+
if (verb === 'check') {
|
|
58
|
+
const problems = B.check(reg, { root });
|
|
59
|
+
if (flags.json) say(JSON.stringify({ ok: problems.length === 0, problems }));
|
|
60
|
+
else if (!problems.length) say(`✓ ${B.REGISTRY}: ${reg.features.length} features on ${reg.surfaces.length} surfaces, no status written by hand.`);
|
|
61
|
+
else { say(`✗ ${B.REGISTRY}: ${problems.length} problem${problems.length === 1 ? '' : 's'}`); for (const p of problems) say(' ' + p); }
|
|
62
|
+
return problems.length ? 1 : 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const problems = B.check(reg, { root }).filter((p) => /derived, never written|surface ".*" is not in/.test(p));
|
|
66
|
+
if (problems.length) { say('✗ the registry breaks its own rules; run `pmos blueprint check`.'); for (const p of problems) say(' ' + p); return 1; }
|
|
67
|
+
const rels = { ...readReleases({ root, pkg: reg.package, offline: !!flags.offline }), offline: !!flags.offline };
|
|
68
|
+
const opts = { root, releases: rels.list }; if (git) opts.git = git;
|
|
69
|
+
const { features } = B.derive(reg, opts);
|
|
70
|
+
|
|
71
|
+
if (verb === 'show') {
|
|
72
|
+
const f = features.find((x) => x.id === pos[0]);
|
|
73
|
+
if (!f) { say(pos[0] ? `✗ no feature "${pos[0]}" — \`pmos blueprint\` lists them` : 'usage: pmos blueprint show <feature-id>'); return pos[0] ? 1 : 2; }
|
|
74
|
+
if (flags.json) { say(JSON.stringify({ ok: true, releases: rels.source, feature: f })); return 0; }
|
|
75
|
+
const surface = reg.surfaces.find((s) => s.id === f.surface);
|
|
76
|
+
say(`${f.name} (${f.id})`);
|
|
77
|
+
say(` Status: ${B.label(f)} — ${f.why.join('; ')}`);
|
|
78
|
+
say(` Surface: ${surface ? surface.name : f.surface}`);
|
|
79
|
+
if (f.what) say(` What: ${f.what}`);
|
|
80
|
+
if (f.prs && f.prs.length) say(` PRs: ${f.prs.map((n) => '#' + n).join(' ')}`);
|
|
81
|
+
if (f.retired_by && f.retired_by.length) say(` Retired by: ${f.retired_by.map((n) => '#' + n).join(' ')}`);
|
|
82
|
+
if (f.files && f.files.length) say(` Files: ${f.files.join(', ')}`);
|
|
83
|
+
if (f.initiative) say(` Record: planning/initiatives/${f.initiative}.md`);
|
|
84
|
+
for (const g of f.guide || []) say(` Guide: ${(reg.sources && reg.sources.guide) || 'workspace/guide'}/${g}`);
|
|
85
|
+
for (const d of f.design || []) say(` Design: ${d}`);
|
|
86
|
+
if (f.note) say(` Note: ${f.note}`);
|
|
87
|
+
say(' ' + releaseLine(rels));
|
|
88
|
+
return 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (verb === 'unplaced') {
|
|
92
|
+
const u = B.unplaced(reg, opts);
|
|
93
|
+
if (flags.json) { say(JSON.stringify({ ok: true, releases: rels.source, range: u.range, guide: u.guide, changes: u.changes, other: flags.all ? u.other : u.other.length })); return 0; }
|
|
94
|
+
say(`Guide sections no feature cites: ${u.guide.length}`);
|
|
95
|
+
for (const g of u.guide) say(' ' + g);
|
|
96
|
+
if (!u.range) say('Release changes: not checked — no release data, so the first release of the range is unknown.');
|
|
97
|
+
else {
|
|
98
|
+
say(`Feature changes since ${u.range.from} that no feature cites: ${u.changes.length}`);
|
|
99
|
+
for (const c of u.changes) say(` ${c.sha} ${c.subject}`);
|
|
100
|
+
say(`Other changes (fixes, chores, docs, tests) since ${u.range.from}: ${u.other.length}. They change no feature's status${flags.all ? ':' : '; --all lists them.'}`);
|
|
101
|
+
if (flags.all) for (const c of u.other) say(` ${c.sha} ${c.subject}`);
|
|
102
|
+
}
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// list
|
|
107
|
+
let shown = features;
|
|
108
|
+
if (flags.surface) shown = shown.filter((f) => f.surface === flags.surface);
|
|
109
|
+
if (flags.status) shown = shown.filter((f) => f.status.toLowerCase() === String(flags.status).toLowerCase());
|
|
110
|
+
const u = B.unplaced(reg, opts);
|
|
111
|
+
const counts = {}; for (const s of B.STATUSES) counts[s] = features.filter((f) => f.status === s).length;
|
|
112
|
+
if (flags.json) {
|
|
113
|
+
say(JSON.stringify({ ok: true, what: reg.what, releases: { source: rels.source, at: rels.at, count: rels.list.length },
|
|
114
|
+
counts, unplaced: { guide: u.guide.length, changes: u.range ? u.changes.length : null },
|
|
115
|
+
features: shown.map((f) => ({ id: f.id, name: f.name, surface: f.surface, status: f.status, version: f.version, why: f.why })) }));
|
|
116
|
+
return 0;
|
|
117
|
+
}
|
|
118
|
+
say(`${reg.name || 'Product'} blueprint — ${features.length} features`);
|
|
119
|
+
say(' ' + B.STATUSES.filter((s) => counts[s]).map((s) => `${s} ${counts[s]}`).join(' · '));
|
|
120
|
+
for (const s of reg.surfaces) {
|
|
121
|
+
const rows = shown.filter((f) => f.surface === s.id);
|
|
122
|
+
if (!rows.length) continue;
|
|
123
|
+
say('');
|
|
124
|
+
say(s.name);
|
|
125
|
+
for (const f of rows) say(` ${B.label(f).padEnd(15)} ${f.name} (${f.id})`);
|
|
126
|
+
}
|
|
127
|
+
say('');
|
|
128
|
+
say(releaseLine(rels));
|
|
129
|
+
const unp = u.guide.length + (u.range ? u.changes.length : 0);
|
|
130
|
+
say(unp ? `Not placed yet: ${u.guide.length} guide section${u.guide.length === 1 ? '' : 's'}${u.range ? `, ${u.changes.length} release change${u.changes.length === 1 ? '' : 's'}` : ''} — \`pmos blueprint unplaced\` lists them.`
|
|
131
|
+
: `Every guide section${u.range ? ' and every feature change since ' + u.range.from : ''} is placed.`);
|
|
132
|
+
return 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* blueprint.js — the product blueprint: every feature of the product with a status DERIVED from evidence
|
|
3
|
+
* (initiative product-blueprint-registry, batch 30 item 1, proposals P1 and P3).
|
|
4
|
+
*
|
|
5
|
+
* load(root) → { ok, registry, file } | { ok:false, error }
|
|
6
|
+
* check(registry, { root }) → [problem] the registry's own rules (no status key, known surfaces, …)
|
|
7
|
+
* derive(registry, { root, releases }) → { features, releases } every feature with { status, version, why }
|
|
8
|
+
* unplaced(registry, { root, releases }) → { guide, changes, other, range }
|
|
9
|
+
* readReleases({ root, pkg, npmView, offline, now }) → { list, source, at, error } npm `gitHead` per version, cached
|
|
10
|
+
* STATUSES
|
|
11
|
+
*
|
|
12
|
+
* The registry (planning/blueprint/features.json) holds EVIDENCE, never a status: the PRs that built a feature, the PRs that
|
|
13
|
+
* retired it, the files that carry it, its experiment record and the guide sections that explain it. A status typed into the
|
|
14
|
+
* registry by hand would be a board that lies the first week nobody updates it, so check() refuses a `status` or `stage` key
|
|
15
|
+
* anywhere in the file. The rules, strongest first:
|
|
16
|
+
*
|
|
17
|
+
* Retired a `retired_by` PR is merged on the default line, or every cited file is gone now and was in a release
|
|
18
|
+
* Live <v> a cited PR is in a published release (or a cited file is); <v> is the FIRST release whose npm gitHead has it
|
|
19
|
+
* In build a cited PR is merged but in no release yet, or a cited PR is not merged yet
|
|
20
|
+
* Agreed its experiment record has a done test (D107: the done test is the agreed spec)
|
|
21
|
+
* Exploring its experiment record has no done test yet, or a cited prototype/ path exists
|
|
22
|
+
* Idea nothing above: the entry alone
|
|
23
|
+
*
|
|
24
|
+
* "In a release" means: the release's gitHead (from `npm view <pkg> version gitHead`) has the commit as an ancestor, or
|
|
25
|
+
* has the file in its tree. Without release data (no network and no saved read) a merged feature says `Live ?`.
|
|
26
|
+
*/
|
|
27
|
+
const fs = require('fs');
|
|
28
|
+
const path = require('path');
|
|
29
|
+
const cp = require('child_process');
|
|
30
|
+
|
|
31
|
+
const STATUSES = Object.freeze(['Idea', 'Exploring', 'Agreed', 'In build', 'Live', 'Retired']);
|
|
32
|
+
const REGISTRY = path.join('planning', 'blueprint', 'features.json');
|
|
33
|
+
const CACHE = path.join('pmos', 'state', 'blueprint-releases.json');
|
|
34
|
+
const FORBIDDEN_KEYS = ['status', 'stage', 'state'];
|
|
35
|
+
const FEATURE_KEYS = ['id', 'name', 'surface', 'what', 'prs', 'retired_by', 'files', 'initiative', 'guide', 'design', 'note'];
|
|
36
|
+
const ID_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
37
|
+
const FEATURE_CHANGE = /^(feat|perf)(\([^)]*\))?!?:|^Batch \d+\b/;
|
|
38
|
+
|
|
39
|
+
function load(root) {
|
|
40
|
+
const file = path.join(root, REGISTRY);
|
|
41
|
+
let text;
|
|
42
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch { return { ok: false, error: `No registry at ${REGISTRY}. The blueprint reads its features from that file.` }; }
|
|
43
|
+
try { return { ok: true, registry: JSON.parse(text), file }; } catch (e) { return { ok: false, error: `${REGISTRY} is not valid JSON: ${e.message}` }; }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* ---------- git ---------- */
|
|
47
|
+
|
|
48
|
+
/** The PR numbers a commit title names: a squash title's `(#123)`, or a merge commit's `Merge pull request #123`. */
|
|
49
|
+
function prNumbers(subject) {
|
|
50
|
+
const nums = [...String(subject).matchAll(/\(#(\d+)\)/g)].map((m) => +m[1]);
|
|
51
|
+
const merge = /^Merge pull request #(\d+)\b/.exec(String(subject));
|
|
52
|
+
if (merge) nums.push(+merge[1]);
|
|
53
|
+
return nums;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function gitIn(root) {
|
|
57
|
+
const run = (args, input) => {
|
|
58
|
+
try { return cp.execFileSync('git', args, { cwd: root, encoding: 'utf8', input, maxBuffer: 64 * 1024 * 1024, stdio: ['pipe', 'pipe', 'ignore'] }); } catch { return null; }
|
|
59
|
+
};
|
|
60
|
+
let line = null;
|
|
61
|
+
const mainLine = () => {
|
|
62
|
+
if (line) return line;
|
|
63
|
+
const out = run(['log', '--first-parent', '--format=%H%x09%s', 'HEAD']) || '';
|
|
64
|
+
const list = out.split('\n').filter(Boolean).map((l, idx) => { const t = l.indexOf('\t'); return { sha: l.slice(0, t), subject: l.slice(t + 1), idx }; });
|
|
65
|
+
const bySha = new Map(list.map((c) => [c.sha, c]));
|
|
66
|
+
const byPr = new Map();
|
|
67
|
+
for (const c of list) for (const n of prNumbers(c.subject)) if (!byPr.has(n)) byPr.set(n, c);
|
|
68
|
+
line = { list, bySha, byPr };
|
|
69
|
+
return line;
|
|
70
|
+
};
|
|
71
|
+
const reach = new Map();
|
|
72
|
+
/** The commits a ref holds, as a position on the first-parent line when it is on it, else as the set of its
|
|
73
|
+
* ancestors (one `git rev-list` per such ref, never one git call per query). */
|
|
74
|
+
const reachOf = (ref) => {
|
|
75
|
+
if (!reach.has(ref)) {
|
|
76
|
+
const L = mainLine();
|
|
77
|
+
if (L.bySha.has(ref)) reach.set(ref, { idx: L.bySha.get(ref).idx });
|
|
78
|
+
else reach.set(ref, { set: new Set((run(['rev-list', ref]) || '').split('\n').filter(Boolean)) });
|
|
79
|
+
}
|
|
80
|
+
return reach.get(ref);
|
|
81
|
+
};
|
|
82
|
+
/** Does `ref` contain commit `sha`? */
|
|
83
|
+
const contains = (ref, sha) => {
|
|
84
|
+
const r = reachOf(ref);
|
|
85
|
+
if (r.set) return r.set.has(sha);
|
|
86
|
+
const b = mainLine().bySha.get(sha);
|
|
87
|
+
if (b) return r.idx <= b.idx;
|
|
88
|
+
return run(['merge-base', '--is-ancestor', sha, ref]) !== null;
|
|
89
|
+
};
|
|
90
|
+
/** Which of `pairs` ([ref, path]) exist? One `git cat-file --batch-check` for all of them. */
|
|
91
|
+
const present = (pairs) => {
|
|
92
|
+
if (!pairs.length) return [];
|
|
93
|
+
const out = run(['cat-file', '--batch-check'], pairs.map(([r, p]) => `${r}:${p}`).join('\n') + '\n');
|
|
94
|
+
if (out === null) return pairs.map(() => false);
|
|
95
|
+
const lines = out.split('\n');
|
|
96
|
+
return pairs.map((_, i) => !!lines[i] && !/ missing$/.test(lines[i]) && !/ ambiguous$/.test(lines[i]));
|
|
97
|
+
};
|
|
98
|
+
/** Which of `shas` are commits in this clone? One `git cat-file --batch-check`. */
|
|
99
|
+
const knownAll = (shas) => {
|
|
100
|
+
if (!shas.length) return [];
|
|
101
|
+
const out = run(['cat-file', '--batch-check'], shas.map((x) => `${x}^{commit}`).join('\n') + '\n');
|
|
102
|
+
if (out === null) return shas.map(() => false);
|
|
103
|
+
const lines = out.split('\n');
|
|
104
|
+
return shas.map((_, i) => / commit \d+$/.test(lines[i] || ''));
|
|
105
|
+
};
|
|
106
|
+
return { mainLine, contains, present, knownAll };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* ---------- releases (npm gitHead) ---------- */
|
|
110
|
+
|
|
111
|
+
function semverCmp(a, b) {
|
|
112
|
+
const pa = String(a).split(/[.-]/).map((x) => (/^\d+$/.test(x) ? +x : x));
|
|
113
|
+
const pb = String(b).split(/[.-]/).map((x) => (/^\d+$/.test(x) ? +x : x));
|
|
114
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
115
|
+
const x = pa[i]; const y = pb[i];
|
|
116
|
+
if (x === undefined) return -1; if (y === undefined) return 1;
|
|
117
|
+
if (x === y) continue;
|
|
118
|
+
if (typeof x === 'number' && typeof y === 'number') return x - y;
|
|
119
|
+
return String(x) < String(y) ? -1 : 1;
|
|
120
|
+
}
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function cleanReleases(raw) {
|
|
125
|
+
const arr = Array.isArray(raw) ? raw : raw && typeof raw === 'object' ? [raw] : [];
|
|
126
|
+
return arr.filter((r) => r && /^\d+\.\d+\.\d+$/.test(r.version) && /^[0-9a-f]{40}$/.test(r.gitHead || ''))
|
|
127
|
+
.map((r) => ({ version: r.version, gitHead: r.gitHead })).sort((a, b) => semverCmp(a.version, b.version));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Every published version with its gitHead: from npm now, else from the last saved read, else none. Never throws. */
|
|
131
|
+
function readReleases({ root, pkg, npmView = (name) => require('./kit-update.js').releaseHeads(name), offline = false, now = Date.now() } = {}) {
|
|
132
|
+
const cacheFile = path.join(root, CACHE);
|
|
133
|
+
if (!offline && pkg) {
|
|
134
|
+
try {
|
|
135
|
+
const list = cleanReleases(JSON.parse(npmView(pkg)));
|
|
136
|
+
if (list.length) {
|
|
137
|
+
try { fs.mkdirSync(path.dirname(cacheFile), { recursive: true }); fs.writeFileSync(cacheFile, JSON.stringify({ pkg, at: new Date(now).toISOString(), releases: list }) + '\n'); } catch { /* a read-only checkout still answers */ }
|
|
138
|
+
return { list, source: 'registry', at: new Date(now).toISOString() };
|
|
139
|
+
}
|
|
140
|
+
} catch { /* fall back to the saved read */ }
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
const saved = JSON.parse(fs.readFileSync(cacheFile, 'utf8'));
|
|
144
|
+
const list = cleanReleases(saved.releases);
|
|
145
|
+
if (list.length && (!pkg || saved.pkg === pkg)) return { list, source: 'saved', at: saved.at || null };
|
|
146
|
+
} catch { /* none saved */ }
|
|
147
|
+
return { list: [], source: 'none', at: null, error: offline ? 'offline, and no saved read of the releases' : 'npm did not answer, and no saved read of the releases' };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/* ---------- the registry's own rules ---------- */
|
|
151
|
+
|
|
152
|
+
function findKeys(obj, keys, at = '') {
|
|
153
|
+
const hits = [];
|
|
154
|
+
if (Array.isArray(obj)) obj.forEach((v, i) => hits.push(...findKeys(v, keys, `${at}[${i}]`)));
|
|
155
|
+
else if (obj && typeof obj === 'object') for (const [k, v] of Object.entries(obj)) {
|
|
156
|
+
if (keys.includes(k.toLowerCase())) hits.push(`${at}.${k}`.replace(/^\./, ''));
|
|
157
|
+
hits.push(...findKeys(v, keys, `${at}.${k}`));
|
|
158
|
+
}
|
|
159
|
+
return hits;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function guideSections(root, dir) {
|
|
163
|
+
const out = new Map(); // page → [heading]
|
|
164
|
+
let names = [];
|
|
165
|
+
try { names = fs.readdirSync(path.join(root, dir)).filter((n) => n.endsWith('.md') && n !== 'index.md' && n !== 'log.md').sort(); } catch { return out; }
|
|
166
|
+
for (const n of names) {
|
|
167
|
+
const text = fs.readFileSync(path.join(root, dir, n), 'utf8');
|
|
168
|
+
out.set(n, text.split('\n').filter((l) => /^## /.test(l)).map((l) => l.slice(3).trim()));
|
|
169
|
+
}
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function check(registry, { root } = {}) {
|
|
174
|
+
const problems = [];
|
|
175
|
+
const r = registry || {};
|
|
176
|
+
for (const k of findKeys(r, FORBIDDEN_KEYS)) problems.push(`${k}: a status is derived, never written. Remove the key and cite evidence instead.`);
|
|
177
|
+
if (!r.what || typeof r.what !== 'string') problems.push('what: say in one or two sentences what the product is.');
|
|
178
|
+
const surfaces = Array.isArray(r.surfaces) ? r.surfaces : [];
|
|
179
|
+
if (!surfaces.length) problems.push('surfaces: list the product\'s surfaces.');
|
|
180
|
+
const sIds = new Set();
|
|
181
|
+
for (const s of surfaces) { if (!s || !ID_RE.test(s.id || '')) problems.push(`surface ${JSON.stringify(s && s.id)}: an id is lowercase words with hyphens.`); else if (sIds.has(s.id)) problems.push(`surface ${s.id}: listed twice.`); else sIds.add(s.id); }
|
|
182
|
+
const feats = Array.isArray(r.features) ? r.features : [];
|
|
183
|
+
if (!feats.length) problems.push('features: the registry lists no feature.');
|
|
184
|
+
const ids = new Set();
|
|
185
|
+
const guide = root && r.sources && r.sources.guide ? guideSections(root, r.sources.guide) : null;
|
|
186
|
+
for (const f of feats) {
|
|
187
|
+
const id = f && f.id;
|
|
188
|
+
const at = `feature ${id || '(no id)'}`;
|
|
189
|
+
if (!ID_RE.test(id || '')) { problems.push(`${at}: an id is lowercase words with hyphens.`); continue; }
|
|
190
|
+
if (ids.has(id)) problems.push(`${at}: the id is used twice.`); ids.add(id);
|
|
191
|
+
for (const k of Object.keys(f)) if (!FEATURE_KEYS.includes(k)) problems.push(`${at}: unknown key "${k}" (keys: ${FEATURE_KEYS.join(', ')}).`);
|
|
192
|
+
if (!f.name) problems.push(`${at}: give it a name.`);
|
|
193
|
+
if (!sIds.has(f.surface)) problems.push(`${at}: surface "${f.surface}" is not in surfaces.`);
|
|
194
|
+
for (const k of ['prs', 'retired_by']) if (f[k] !== undefined && (!Array.isArray(f[k]) || !f[k].every((n) => Number.isInteger(n) && n > 0))) problems.push(`${at}: ${k} is a list of PR numbers.`);
|
|
195
|
+
for (const k of ['files', 'guide', 'design']) if (f[k] !== undefined && (!Array.isArray(f[k]) || !f[k].every((x) => typeof x === 'string' && x))) problems.push(`${at}: ${k} is a list of strings.`);
|
|
196
|
+
if (f.initiative !== undefined && !/^[a-z0-9][a-z0-9._-]*$/.test(f.initiative)) problems.push(`${at}: initiative is an experiment record id.`);
|
|
197
|
+
if (root && f.initiative && !fs.existsSync(path.join(root, 'planning', 'initiatives', f.initiative + '.md'))) problems.push(`${at}: no record planning/initiatives/${f.initiative}.md.`);
|
|
198
|
+
if (guide) for (const g of f.guide || []) {
|
|
199
|
+
const [page, heading] = g.split('#');
|
|
200
|
+
if (!guide.has(page)) problems.push(`${at}: guide page ${page} is not in ${r.sources.guide}.`);
|
|
201
|
+
else if (heading !== undefined && !guide.get(page).includes(heading)) problems.push(`${at}: ${page} has no section "## ${heading}".`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return problems;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/* ---------- derivation ---------- */
|
|
208
|
+
|
|
209
|
+
function recordOf(root, id) {
|
|
210
|
+
try {
|
|
211
|
+
const text = fs.readFileSync(path.join(root, 'planning', 'initiatives', id + '.md'), 'utf8');
|
|
212
|
+
const fm = (text.match(/^---\n([\s\S]*?)\n---/) || [])[1] || '';
|
|
213
|
+
const dt = (fm.match(/^done_test_path:\s*["']?([^"'\n]+?)["']?\s*$/m) || [])[1];
|
|
214
|
+
return { exists: true, doneTest: !!dt && fs.existsSync(path.join(root, dt.trim())), doneTestPath: dt || null };
|
|
215
|
+
} catch { return { exists: false }; }
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function derive(registry, { root, releases = [], git = gitIn(root) } = {}) {
|
|
219
|
+
const known = git.knownAll(releases.map((r) => r.gitHead));
|
|
220
|
+
const rel = releases.filter((_, i) => known[i]);
|
|
221
|
+
const L = git.mainLine();
|
|
222
|
+
const firstReleaseWith = (sha) => { for (const r of rel) if (git.contains(r.gitHead, sha)) return r.version; return null; };
|
|
223
|
+
const feats = (registry.features || []).map((f) => {
|
|
224
|
+
const why = [];
|
|
225
|
+
const prs = (f.prs || []).map((n) => ({ n, c: L.byPr.get(n) || null }));
|
|
226
|
+
const merged = prs.filter((p) => p.c);
|
|
227
|
+
const open = prs.filter((p) => !p.c);
|
|
228
|
+
const files = (f.files || []).filter((p) => !p.startsWith('prototype/'));
|
|
229
|
+
const protos = (f.files || []).filter((p) => p.startsWith('prototype/'));
|
|
230
|
+
const headHas = git.present(files.map((p) => ['HEAD', p]));
|
|
231
|
+
const out = { ...f, status: 'Idea', version: null, why };
|
|
232
|
+
|
|
233
|
+
// Retired: a retiring PR is merged, or every cited file is gone now and was in a release.
|
|
234
|
+
const retiring = (f.retired_by || []).map((n) => ({ n, c: L.byPr.get(n) || null })).filter((p) => p.c);
|
|
235
|
+
if (retiring.length) {
|
|
236
|
+
const first = retiring.sort((a, b) => b.c.idx - a.c.idx)[0];
|
|
237
|
+
out.status = 'Retired'; out.version = rel.length ? firstReleaseWith(first.c.sha) : null;
|
|
238
|
+
why.push(`#${first.n} retired it${out.version ? `, released in ${out.version}` : rel.length ? ', not released yet' : ''}`);
|
|
239
|
+
return out;
|
|
240
|
+
}
|
|
241
|
+
if (files.length && headHas.every((x) => !x) && rel.length) {
|
|
242
|
+
const inRel = git.present(rel.flatMap((r) => files.map((p) => [r.gitHead, p])));
|
|
243
|
+
let last = -1; inRel.forEach((x, i) => { if (x) last = Math.floor(i / files.length); });
|
|
244
|
+
if (last >= 0) {
|
|
245
|
+
out.status = 'Retired'; out.version = rel[last + 1] ? rel[last + 1].version : null;
|
|
246
|
+
why.push(`its files are gone; last in ${rel[last].version}`);
|
|
247
|
+
return out;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Live / In build: merged PRs and files present now.
|
|
252
|
+
const built = merged.length > 0 || headHas.some(Boolean);
|
|
253
|
+
if (built) {
|
|
254
|
+
if (!rel.length) { out.status = 'Live'; out.version = '?'; why.push('merged; no release data, so the version is unknown'); return out; }
|
|
255
|
+
let best = null;
|
|
256
|
+
for (const p of merged) { const v = firstReleaseWith(p.c.sha); if (v && (!best || semverCmp(v, best.v) < 0)) best = { v, by: `#${p.n}` }; }
|
|
257
|
+
if (files.length) { // a file can predate every cited PR: the feature was live from the first release that had it
|
|
258
|
+
const inRel = git.present(rel.flatMap((r) => files.map((p) => [r.gitHead, p])));
|
|
259
|
+
const i = inRel.findIndex(Boolean);
|
|
260
|
+
if (i >= 0) { const v = rel[Math.floor(i / files.length)].version; if (!best || semverCmp(v, best.v) < 0) best = { v, by: files[i % files.length] }; }
|
|
261
|
+
}
|
|
262
|
+
if (best) {
|
|
263
|
+
out.status = 'Live'; out.version = best.v; why.push(`${best.by} first shipped in ${best.v}`);
|
|
264
|
+
const later = merged.filter((p) => !firstReleaseWith(p.c.sha)).map((p) => '#' + p.n);
|
|
265
|
+
if (later.length) why.push(`${later.join(', ')} merged, not released yet`);
|
|
266
|
+
if (open.length) why.push(`${open.map((p) => '#' + p.n).join(', ')} not merged yet`);
|
|
267
|
+
return out;
|
|
268
|
+
}
|
|
269
|
+
out.status = 'In build'; why.push(`${merged.map((p) => '#' + p.n).join(', ') || 'its files'} merged, in no release yet`);
|
|
270
|
+
return out;
|
|
271
|
+
}
|
|
272
|
+
if (open.length) { out.status = 'In build'; why.push(`${open.map((p) => '#' + p.n).join(', ')} not merged yet`); return out; }
|
|
273
|
+
|
|
274
|
+
// Agreed / Exploring: the experiment record, or a prototype.
|
|
275
|
+
const rec = f.initiative ? recordOf(root, f.initiative) : { exists: false };
|
|
276
|
+
if (rec.exists && rec.doneTest) { out.status = 'Agreed'; why.push(`record ${f.initiative} has its done test`); return out; }
|
|
277
|
+
const protoNow = git.present(protos.map((p) => ['HEAD', p])).some(Boolean);
|
|
278
|
+
if (rec.exists || protoNow) { out.status = 'Exploring'; why.push(rec.exists ? `record ${f.initiative} has no done test yet` : `prototype ${protos[0]}`); return out; }
|
|
279
|
+
why.push('no record, PR or file yet');
|
|
280
|
+
return out;
|
|
281
|
+
});
|
|
282
|
+
return { features: feats, releases: rel };
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function label(f) { return f.status === 'Live' || (f.status === 'Retired' && f.version) ? `${f.status} ${f.version || ''}`.trim() : f.status; }
|
|
286
|
+
|
|
287
|
+
/** What no feature cites: guide sections, and feature changes on the default line since the release before `from`. */
|
|
288
|
+
function unplaced(registry, { root, releases = [], git = gitIn(root) } = {}) {
|
|
289
|
+
const feats = registry.features || [];
|
|
290
|
+
const cites = new Set(feats.flatMap((f) => f.guide || []));
|
|
291
|
+
const guide = [];
|
|
292
|
+
const src = registry.sources || {};
|
|
293
|
+
for (const [page, heads] of guideSections(root, src.guide || 'workspace/guide')) {
|
|
294
|
+
if (cites.has(page)) continue;
|
|
295
|
+
for (const h of heads) if (!cites.has(`${page}#${h}`)) guide.push(`${page}#${h}`);
|
|
296
|
+
}
|
|
297
|
+
const prs = new Set(feats.flatMap((f) => [...(f.prs || []), ...(f.retired_by || [])]));
|
|
298
|
+
const from = src.releases && src.releases.from;
|
|
299
|
+
const changes = []; const other = [];
|
|
300
|
+
let range = null;
|
|
301
|
+
const older = from ? releases.filter((r) => semverCmp(r.version, from) < 0) : [];
|
|
302
|
+
const okOlder = git.knownAll(older.map((r) => r.gitHead));
|
|
303
|
+
const before = older.filter((_, i) => okOlder[i]).pop() || null;
|
|
304
|
+
if (from && before) {
|
|
305
|
+
range = { from, base: before.version };
|
|
306
|
+
const L = git.mainLine();
|
|
307
|
+
const base = L.bySha.get(before.gitHead);
|
|
308
|
+
for (const c of L.list) {
|
|
309
|
+
if (base && c.idx >= base.idx) break;
|
|
310
|
+
if (!base && git.contains(before.gitHead, c.sha)) break;
|
|
311
|
+
const nums = prNumbers(c.subject);
|
|
312
|
+
const row = { sha: c.sha.slice(0, 8), prs: nums, subject: c.subject };
|
|
313
|
+
if (FEATURE_CHANGE.test(c.subject)) { if (!nums.some((n) => prs.has(n))) changes.push(row); } else other.push(row);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return { guide, changes, other, range };
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
module.exports = { STATUSES, REGISTRY, CACHE, FEATURE_KEYS, load, check, derive, unplaced, readReleases, label, gitIn, prNumbers, semverCmp, cleanReleases, guideSections };
|
|
@@ -345,4 +345,11 @@ function upgradeApp(root, { version, logFile, spawn = cp.spawn, env = updateEnv(
|
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
-
|
|
348
|
+
/** Every published version with its gitHead, as npm's JSON text (`pmos blueprint`, lib/blueprint.js). A terminal command
|
|
349
|
+
* the PM runs; read-only; the one other caller of npm besides Settings › Updates, kept here so npm stays in one module. */
|
|
350
|
+
function releaseHeads(pkg = PKG_NAME, { exec = cp.execFileSync } = {}) {
|
|
351
|
+
return String(exec(NPM, ['view', `${pkg}@>=0.0.0`, 'version', 'gitHead', '--json'],
|
|
352
|
+
{ encoding: 'utf8', timeout: 20000, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true, shell: IS_WIN }));
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
module.exports = { PKG_NAME, releaseHeads, windowsHop, appUpdateCommand, cmpVer, readChanges, readLastCheck, writeLastCheck, notServedYet, validVersion, source, npxArgs, readKit, fromCheckout, status, compare, latest, updateKit, updateEnv, upgradeApp, whereFrom };
|
|
@@ -76,6 +76,9 @@ const VERBS = Object.freeze({
|
|
|
76
76
|
task: Object.freeze({ module: 'task-cli.js', run: null, guide: 'cli.md',
|
|
77
77
|
help: 'pmos task add|list|state|set … — an initiative\'s tasks: add one, list them, set their state or group them under a stage when the PM asks (pmos task help)' }),
|
|
78
78
|
// Not a pm-os-absorb verb (run: null): feedback batch 4 item 6 (Claude suggests program milestones) added it through the same table.
|
|
79
|
+
// Not a pm-os-absorb verb (run: null): product-blueprint-registry (batch 30 item 1, round 2) added it through the same table.
|
|
80
|
+
blueprint: Object.freeze({ module: 'blueprint-cli.js', run: null, guide: 'cli.md',
|
|
81
|
+
help: 'pmos blueprint [list|show|unplaced|check] — every feature of the product with a status worked out from its evidence (pmos blueprint help)' }),
|
|
79
82
|
program: Object.freeze({ module: 'program-cli.js', run: null, guide: 'cli.md',
|
|
80
83
|
help: 'pmos program suggest — Claude\'s milestone suggestions for a program, filed by its review run (pmos program help)' }),
|
|
81
84
|
// Not a pm-os-absorb verb (run: null): c3-meet-extension added it through the same table.
|
|
@@ -278,6 +278,19 @@ function edgeAllowed({ headers = {}, publicHost = null } = {}) {
|
|
|
278
278
|
return hasHeader(headers, ACCESS_HEADER);
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
+
// Browser hardening for an answer to the public hostname (security hardening 2026-11-11). Only that hostname gets them:
|
|
282
|
+
// loopback and the tailnet are unchanged, and the meeting-helper extension, which frames the console from its own origin,
|
|
283
|
+
// talks to localhost. HSTS names no subdomains, so the share hostname keeps its own headers (share-server.js).
|
|
284
|
+
const PUBLIC_HEADERS = Object.freeze({
|
|
285
|
+
'Strict-Transport-Security': 'max-age=31536000',
|
|
286
|
+
'X-Frame-Options': 'SAMEORIGIN',
|
|
287
|
+
'X-Content-Type-Options': 'nosniff',
|
|
288
|
+
'Referrer-Policy': 'same-origin',
|
|
289
|
+
});
|
|
290
|
+
function publicHeaders({ headers = {}, publicHost = null } = {}) {
|
|
291
|
+
return publicHost && hostnameOf(headers.host) === publicHost ? PUBLIC_HEADERS : null;
|
|
292
|
+
}
|
|
293
|
+
|
|
281
294
|
// The single authorization decision, PEER-based (what matters is where the request came FROM, not
|
|
282
295
|
// which listener it hit). A loopback peer is exempt unless the request arrived through a proxy;
|
|
283
296
|
// every other request must present a valid bearer token. Fail-closed: with no token configured, a
|
|
@@ -427,7 +440,7 @@ module.exports = {
|
|
|
427
440
|
LOOPBACK, isLoopbackAddr, isTailnetIp, detectTailnetIp, remoteRequested,
|
|
428
441
|
resolveBinds, extractHttpToken, extractWsToken, tokenMatches, authorize, startupLines,
|
|
429
442
|
checkHostOrigin, isAllowedOrigin, hostnameAllowed,
|
|
430
|
-
parsePublicHost, PROXY_HEADERS, ACCESS_HEADER, isProxied, edgeAllowed, hostnameOf,
|
|
443
|
+
parsePublicHost, PROXY_HEADERS, ACCESS_HEADER, isProxied, edgeAllowed, hostnameOf, PUBLIC_HEADERS, publicHeaders,
|
|
431
444
|
COOKIE_NAME, extractCookieToken, presentedToken,
|
|
432
445
|
phoneUrl, isPageNavigation, stripTokenParam, sessionCookie, AUTH_PATH, parseAuthForm, signInPage,
|
|
433
446
|
};
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* WHAT IS COPIED: the small state files (.json .jsonl .md .txt) under `src`, to <dest>/<YYYY-MM-DD>/, with a manifest.json of what was
|
|
11
11
|
* copied. Terminal buffers, sockets, caches and anything whose name looks like a secret (token, secret, key, nonce, credential, password)
|
|
12
|
-
* are left out: a backup that copies the PM's keys to a second place is worse than none. A copy is checked by reading it back (file count and
|
|
12
|
+
* and the named credential files (SECRET_FILES) are left out: a backup that copies the PM's keys to a second place is worse than none. A copy is checked by reading it back (file count and
|
|
13
13
|
* bytes against the manifest) before the run says ok, and only then are days beyond the newest `keep` (default 7) removed.
|
|
14
14
|
* `dest` must be outside `src`. Nothing is sent over a network; the PM chooses the folder. */
|
|
15
15
|
const fs = require('fs');
|
|
@@ -17,6 +17,9 @@ const path = require('path');
|
|
|
17
17
|
|
|
18
18
|
const KEEP_EXT = /\.(jsonl?|md|txt)$/i;
|
|
19
19
|
const SKIP_NAME = /(token|secret|key|nonce|credential|password|\.sock$|buffer|cache|node_modules|\.git$)/i;
|
|
20
|
+
// The credential files whose names the pattern above does not catch (security review 2026-11-03, finding 1): the Anthropic key,
|
|
21
|
+
// the TypeSafe key and the board host admin key. Paths are relative to the state folder. online.json stays: it holds no credential.
|
|
22
|
+
const SECRET_FILES = new Set(['anthropic.json', 'typesafe.json', 'board-publish/state.json']);
|
|
20
23
|
const MAX_FILE = 50 * 1024 * 1024;
|
|
21
24
|
const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
22
25
|
const LOG = 'backup-log.jsonl';
|
|
@@ -30,6 +33,7 @@ function listFiles(root) {
|
|
|
30
33
|
for (const e of ents) {
|
|
31
34
|
if (SKIP_NAME.test(e.name)) continue;
|
|
32
35
|
const p = path.join(d, e.name);
|
|
36
|
+
if (SECRET_FILES.has(path.relative(root, p).split(path.sep).join('/'))) continue;
|
|
33
37
|
if (e.isDirectory()) walk(p);
|
|
34
38
|
else if (e.isFile() && KEEP_EXT.test(e.name)) { try { if (fs.statSync(p).size <= MAX_FILE) out.push(p); } catch { /* vanished */ } }
|
|
35
39
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.563.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.563.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
package/workspace/server.js
CHANGED
|
@@ -10927,6 +10927,9 @@ function httpGuard(req, res) {
|
|
|
10927
10927
|
res.end(JSON.stringify({ ok: false, error: 'the public host is only reachable through Cloudflare Access' }));
|
|
10928
10928
|
return;
|
|
10929
10929
|
}
|
|
10930
|
+
// Browser hardening headers on every answer to the public hostname (HSTS, framing, nosniff, referrer). Routes may still set their own.
|
|
10931
|
+
const hardening = remoteAccess.publicHeaders({ headers: req.headers, publicHost: publicHost() });
|
|
10932
|
+
if (hardening) for (const [k, v] of Object.entries(hardening)) res.setHeader(k, v);
|
|
10930
10933
|
// workspace-online-mode (D89): on the Online switch's hostname the verified Access assertion is the whole check.
|
|
10931
10934
|
// It replaces the token, so neither the sign-in form nor the token cookie is reachable there.
|
|
10932
10935
|
if (viaOnlineHost(req.headers)) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Batch 30 item 1 round 2, the product blueprint (initiative product-blueprint-registry): lib/blueprint.js derives each feature's status from git, the experiment records and npm gitHead; lib/blueprint-cli.js is `pmos blueprint`. A scratch git repository; no network, no server, no browser.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"blueprint.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"blueprint.test.js": 3
|
|
8
|
+
}
|
|
9
|
+
}
|