create-pmos 0.568.0 → 0.570.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 +27 -27
- package/payload/AGENTS.md +11 -0
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/planning/work-items.jsonl +0 -0
- package/payload/scripts/gate-initiative.sh +29 -0
- package/payload/scripts/lib/sink.js +321 -0
- package/payload/scripts/verify-work.js +149 -0
- package/payload/scripts/work-item.js +1460 -0
- package/payload/scripts/workflow-state.js +16 -0
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/changelog.json +26 -0
- package/workspace/guide/cli.md +27 -2
- package/workspace/guide/settings-and-switches.md +1 -0
- package/workspace/lib/agent-team.js +19 -4
- package/workspace/lib/artefact-mirror.js +121 -0
- package/workspace/lib/artefacts-cli.js +15 -1
- package/workspace/lib/autonomy.js +2 -1
- package/workspace/lib/build-cli.js +93 -0
- package/workspace/lib/build-engine.js +197 -0
- package/workspace/lib/driver-decide.js +2 -0
- package/workspace/lib/engine/workflow-state.js +16 -0
- package/workspace/lib/headless.js +3 -1
- package/workspace/lib/outcome-props.js +21 -1
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/proposals.js +15 -4
- package/workspace/lib/rehearse-read.js +4 -2
- package/workspace/lib/routes-artefacts.js +4 -1
- package/workspace/lib/routes-boards.js +6 -0
- package/workspace/lib/routes-proposals.js +14 -3
- package/workspace/lib/team-cli.js +3 -1
- package/workspace/lib/team-runs.js +4 -0
- package/workspace/lib/today-cli.js +19 -0
- package/workspace/lib/vendor/scripts/workflow-state.js +16 -0
- package/workspace/lib/verify-work-cli.js +4 -2
- package/workspace/lib/work-kind.js +12 -6
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/ini-props.js +3 -1
- package/workspace/run-tests.js +9 -0
- package/workspace/test-lists/build-engine.json +9 -0
- package/workspace/test-lists/launch-rerun-gaps.json +4 -0
|
@@ -1599,7 +1599,21 @@ function pmLadder({ id, fm, lane, effLane, knownLane, legacy, steps, root, L, re
|
|
|
1599
1599
|
: briefPath ? firstAppearance(root, range, briefPath) : null;
|
|
1600
1600
|
const docIdx = docPath ? firstAppearance(root, range, docPath) : null;
|
|
1601
1601
|
|
|
1602
|
+
// W6 (launch simulation rerun, 2026-11-15): the kind of work sets this ladder too, as it sets the product-code gate (W5) and the kit gate.
|
|
1603
|
+
// Full SDLC: a done test and a kill condition, never a brief. Project: a dated plan (plan_path), never a brief. A brief already on the
|
|
1604
|
+
// record still passes (a gate passed stays passed). Their deliverable is not a document: the pull requests, or the plan's milestones.
|
|
1605
|
+
const workKind = (() => { const k = String(fm.kind || '').trim().replace(/^["']|["']$/g, ''); return k === 'sdlc' || k === 'project' ? k : 'product'; })();
|
|
1606
|
+
const planPath = String(fm.plan_path || '').trim();
|
|
1607
|
+
const kindSpec = !doneTest && !exists(briefPath) && !foundBrief && (workKind === 'sdlc' || (workKind === 'project'));
|
|
1602
1608
|
if (doneTest && dtPresent && killCond) steps.push(step('brief', def.brief_label, 'done', `done test ${doneTest} + kill condition (D107)`));
|
|
1609
|
+
else if (kindSpec && workKind === 'sdlc') steps.push(step('brief', 'done test', legacy ? 'pending' : 'blocked',
|
|
1610
|
+
'Full SDLC needs a done test and a kill condition before the first pull request — never a brief or a PRD',
|
|
1611
|
+
`write the done test, set done_test_path and kill: in ${recRel} (pmos artefacts set experiment:${id} done-test check --text "…" writes both)`, { blocking: !legacy, rule: 'R2' }));
|
|
1612
|
+
else if (kindSpec && exists(planPath)) steps.push(step('brief', 'dated plan', 'done', `plan ${planPath} present`));
|
|
1613
|
+
else if (kindSpec) steps.push(step('brief', 'dated plan', legacy ? 'pending' : 'blocked',
|
|
1614
|
+
planPath ? `plan_path '${planPath}' does not exist in the repo` : 'Project needs a dated plan before Execute — never a brief or a PRD',
|
|
1615
|
+
planPath ? 'create the plan the record points at, or correct plan_path' : `write the plan (milestones with dates and owners, go-live matching the KR date) and set plan_path in ${recRel}, or a done test`,
|
|
1616
|
+
{ blocking: !legacy, rule: 'R2' }));
|
|
1603
1617
|
else if (doneTest && dtPresent) steps.push(step('brief', def.brief_label, 'blocked', 'no kill condition — an experiment states what would stop it (D107)',
|
|
1604
1618
|
`write kill: "<the result that would make us stop>" in ${recRel}`, { blocking: !legacy, rule: 'R2' }));
|
|
1605
1619
|
else if (doneTest) steps.push(step('brief', def.brief_label, 'blocked', `done_test_path '${doneTest}' does not exist in the repo`,
|
|
@@ -1613,6 +1627,8 @@ function pmLadder({ id, fm, lane, effLane, knownLane, legacy, steps, root, L, re
|
|
|
1613
1627
|
{ blocking: enforce, rule: 'P1' }));
|
|
1614
1628
|
|
|
1615
1629
|
if (!flows('draft')) steps.push(skipped('draft', def.draft_label));
|
|
1630
|
+
else if (workKind !== 'product' && !exists(docPath) && !foundDraft) steps.push(step('draft', 'deliverable', 'na',
|
|
1631
|
+
workKind === 'sdlc' ? 'Full SDLC — the pull requests are the deliverable, not a document' : 'Project — the plan\'s milestones are the deliverable, not a document'));
|
|
1616
1632
|
else if (foundDraft) steps.push(step('draft', def.draft_label, 'done', `${foundDraft} — found by the repository scan`));
|
|
1617
1633
|
else if (exists(docPath)) {
|
|
1618
1634
|
const inOrder = briefIdx == null || docIdx == null ? null : docIdx >= briefIdx;
|
|
@@ -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-15T17:32:16Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/payload/state/log.md
CHANGED
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.570.0",
|
|
4
|
+
"at": "2026-11-15T17:32:20.370Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1302,
|
|
9
|
+
"t": "The real build engine for Full SDLC (launch simulation W7)",
|
|
10
|
+
"s": "The real build engine for Full SDLC (launch simulation W7)",
|
|
11
|
+
"k": "new"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"v": "0.569.0",
|
|
17
|
+
"at": "2026-11-15T17:07:37.237Z",
|
|
18
|
+
"f": 4,
|
|
19
|
+
"prs": [
|
|
20
|
+
{
|
|
21
|
+
"n": 1301,
|
|
22
|
+
"t": "Close the five gaps the launch rerun found (launch simulation W6)",
|
|
23
|
+
"s": "Close the five gaps the launch rerun found (launch simulation W6)",
|
|
24
|
+
"k": "new"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
2
28
|
{
|
|
3
29
|
"v": "0.568.0",
|
|
4
30
|
"at": "2026-11-12T05:06:58.936Z",
|
package/workspace/guide/cli.md
CHANGED
|
@@ -393,7 +393,7 @@ The ledger is `driver.jsonl` in the state folder of the repository (`pmos/state`
|
|
|
393
393
|
|
|
394
394
|
### pmos artefacts: the seven artefacts
|
|
395
395
|
|
|
396
|
-
`pmos artefacts show [<scope>]` lists the seven artefacts of a scope: Intent, Goal, Narrative, Experiment, Specimens, Done test and Lessons. The scope is `portfolio` (the default), `board:<id>`, `goal:<id>` or `experiment:<id>`. `pmos artefacts map` lists what each older core document, driver proposal kind, report cadence and lane becomes. `pmos artefacts migrate` puts every older record under its artefact as a pointer: issued and draft core documents, kept driver proposals and report drafts. It deletes and moves nothing, and a second run carries nothing new. `pmos artefacts set <scope> <artefact> [<field>] --text "<text>"` writes one field, and `pmos artefacts undo <id>` takes it back. Intent is yours: an agent proposes a change to it and waits for you. Goal is read from the OKRs, health budgets and readings, so you cannot type it.
|
|
396
|
+
`pmos artefacts show [<scope>]` lists the seven artefacts of a scope: Intent, Goal, Narrative, Experiment, Specimens, Done test and Lessons. The scope is `portfolio` (the default), `board:<id>`, `goal:<id>` or `experiment:<id>`. `pmos artefacts map` lists what each older core document, driver proposal kind, report cadence and lane becomes. `pmos artefacts migrate` puts every older record under its artefact as a pointer: issued and draft core documents, kept driver proposals and report drafts. It deletes and moves nothing, and a second run carries nothing new. `pmos artefacts set <scope> <artefact> [<field>] --text "<text>"` writes one field, and `pmos artefacts undo <id>` takes it back. A Done test check on `experiment:<id>` is also written to the experiment's done test file (`planning/done-tests/<id>.md`, or the file the record names), and the record gets `done_test_path:`; an Experiment kill condition becomes the record's `kill:`. So the ladder, the gates and `pmos jira draft` count it. A done test file you wrote by hand is left alone. Intent is yours: an agent proposes a change to it and waits for you. Goal is read from the OKRs, health budgets and readings, so you cannot type it.
|
|
397
397
|
|
|
398
398
|
### pmos coredoc: core documents
|
|
399
399
|
|
|
@@ -428,7 +428,7 @@ Options:
|
|
|
428
428
|
- `--json` prints the result as JSON.
|
|
429
429
|
- `--root <dir>` runs in a different repository.
|
|
430
430
|
|
|
431
|
-
The command runs the repository's own copy of `scripts/verify-work.js`. A repository with no factory writer has no work items, and the command tells you so.
|
|
431
|
+
The command runs the repository's own copy of `scripts/verify-work.js`. In a repository made by `create-pmos`, that copy is `pmos/scripts/verify-work.js`. A repository with no factory writer has no work items, and the command tells you so.
|
|
432
432
|
|
|
433
433
|
The command reports these cases and writes nothing for them:
|
|
434
434
|
|
|
@@ -437,6 +437,31 @@ The command reports these cases and writes nothing for them:
|
|
|
437
437
|
|
|
438
438
|
A commit that is only on another branch is not read.
|
|
439
439
|
|
|
440
|
+
### pmos build: PMOS builds a work item as a draft pull request
|
|
441
|
+
|
|
442
|
+
In a repository with a factory, PMOS can build a declared work item. A repository made by `create-pmos` has a factory: `pmos/scripts/work-item.js`, `pmos/scripts/verify-work.js` and `pmos/planning/work-items.jsonl`. Elsewhere the command says that PMOS does not build there.
|
|
443
|
+
|
|
444
|
+
The Builder does these steps:
|
|
445
|
+
|
|
446
|
+
1. `pmos build next [<initiative>]` lists the declared work items that no Builder has taken.
|
|
447
|
+
2. `pmos build claim <item>` claims one item. PMOS makes the branch `pmos/<item>` from the default branch, in a worktree outside your folder. Your own checkout does not change.
|
|
448
|
+
3. The Builder changes files in that worktree only, and runs the item's check.
|
|
449
|
+
4. `pmos build propose <item> "<what it does>" --evidence "<the check that passed>"` commits the change with the line `Work-Item: <item>`, marks the item verified, and puts "Open a draft pull request" under the initiative's ✦. Nothing is pushed yet.
|
|
450
|
+
5. Your ✓ on that proposal runs `pmos build open <item>`. It pushes only `pmos/<item>` and opens a draft pull request with `gh`. You can also run `pmos build open <item>` yourself.
|
|
451
|
+
6. You merge the pull request after the product's checks pass. Then `pmos verify-work` marks the item integrated.
|
|
452
|
+
|
|
453
|
+
`pmos build status` lists every work item, its branch and whether its worktree is on this computer.
|
|
454
|
+
|
|
455
|
+
The command refuses these cases:
|
|
456
|
+
|
|
457
|
+
- The repository has no git identity of its own. Set it once with `pmos git-identity set`. PMOS never guesses who commits.
|
|
458
|
+
- The change touches a PMOS record, CI or the agent rules: `pmos/`, `.github/`, `planning/initiatives/`, `CLAUDE.md`, `AGENTS.md`.
|
|
459
|
+
- `propose` without `--evidence`. The check comes before the pull request.
|
|
460
|
+
- `open` inside a role run. Only you open a pull request.
|
|
461
|
+
- `open` without `gh`. The branch is pushed, and the command tells you to open the pull request on your Git host.
|
|
462
|
+
|
|
463
|
+
PMOS never pushes to the default branch and merges nothing. Every command takes `--json` and `--root <dir>`.
|
|
464
|
+
|
|
440
465
|
### pmos jira
|
|
441
466
|
|
|
442
467
|
[Jira tickets](jira.md) explains each step with its examples.
|
|
@@ -257,6 +257,7 @@ PMOS sets these in the environment of a terminal session or a background run. Do
|
|
|
257
257
|
| `PMOS_SHARE_PARENT` | The process id of the workspace server, so the share server stops with it. | none | — |
|
|
258
258
|
| `PMOS_AI_RUN` | Set inside an AI run, so the run cannot change its own switch. | none | — |
|
|
259
259
|
| `PMOS_VERIFY_RUN` | Set inside a verifier run: the one run its verdict may be recorded for, never the builder's own session. | none | — |
|
|
260
|
+
| `PMOS_BUILD_DIR` | The folder where `pmos build claim` makes each work item's worktree, outside the repository. | `~/.pmos/build` | — |
|
|
260
261
|
| `PMOS_TEAM_FILE`, `PMOS_TEAM_ROOT`, `PMOS_TEAM_WS`, `PMOS_TEAM_ROLE`, `PMOS_TEAM_RUN`, `PMOS_TEAM_INI`, `PMOS_TEAM_MODE` | Set inside a role agent's run: its ledger, product folder, workspace, role, run, initiative, and whether it proposes or applies (`auto`). | none | — |
|
|
261
262
|
| `PMOS_GRILL_FILE`, `PMOS_GRILL_LOG`, `PMOS_GRILL_ROOT`, `PMOS_GRILL_BOARD`, `PMOS_GRILL_INI`, `PMOS_GRILL_RUN`, `PMOS_GRILL_BUDGET`, `PMOS_GRILL_WS` | Pin a grill run to its ledger, log, repository, board, initiative, run id and budget. No command reads `PMOS_GRILL_WS`. | none | — |
|
|
262
263
|
| `PMOS_PROPOSE_FILE`, `PMOS_PROPOSE_BOARD`, `PMOS_PROPOSE_INI`, `PMOS_PROPOSE_RUN`, `PMOS_PROPOSE_WS` | Pin a proposal run to its ledger, board, initiative and run id. No command reads `PMOS_PROPOSE_WS`. | none | — |
|
|
@@ -101,12 +101,18 @@ const TEAM = Object.freeze({
|
|
|
101
101
|
comms: role('comms', { cls: 'B', runs: true, skills: ['stakeholder-update', 'weekly-update'], budget: 2,
|
|
102
102
|
owns: { paths: ['planning/reports/'], verbs: ['pmos report draft'] }, reads: ['planning/', 'the reports'], triggers: [{ on: 'asked' }],
|
|
103
103
|
connectors: ['docs'], what: 'reports and drafts; sending is class C' }),
|
|
104
|
-
|
|
104
|
+
/* The Builder (launch simulation W7, kit-factory-builder). It runs only where a factory runs (lib/work-kind.js factoryRuns; team-cli refuses
|
|
105
|
+
* a dispatch elsewhere) and only when dispatched. Class C: it claims a declared work item, builds it in a worktree of its own, commits and
|
|
106
|
+
* FILES "Open a draft pull request" under the ✦ (lib/build-engine.js). The push and the PR wait for the PM's ✓; it holds no push, no gh and
|
|
107
|
+
* no merge (the lethal-trifecta audit in kit/AGENTS.md). It writes no repository path of the PM's checkout: its Write and Edit reach its
|
|
108
|
+
* worktrees only (toolsOf). */
|
|
109
|
+
build: role('build', { cls: 'C', runs: true, skills: ['builder'], budget: 2,
|
|
110
|
+
owns: { paths: [], verbs: ['pmos build next', 'pmos build claim', 'pmos build propose', 'pmos build status'] }, reads: ['planning/prd/', 'planning/evals/', 'the work items'],
|
|
105
111
|
triggers: [{ on: 'asked' }], connectors: [],
|
|
106
|
-
what: 'pull requests (the factory,
|
|
112
|
+
what: 'draft pull requests for declared work items (the factory, D65: it files them for your ✓ and never merges)' }),
|
|
107
113
|
});
|
|
108
114
|
/* The order roles hand off in. A dispatch keeps this order whatever roles it picks. */
|
|
109
|
-
const ORDER = Object.freeze(['strategy', 'research', 'spec', 'design', 'eval', 'delivery', 'comms']);
|
|
115
|
+
const ORDER = Object.freeze(['strategy', 'research', 'spec', 'design', 'eval', 'delivery', 'comms', 'build']);
|
|
110
116
|
|
|
111
117
|
const roleOf = (key) => TEAM[String(key || '')] || null;
|
|
112
118
|
|
|
@@ -224,7 +230,8 @@ function planDispatch({ kind = 'initiative', facts = {}, roles = null } = {}) {
|
|
|
224
230
|
let pick;
|
|
225
231
|
if (Array.isArray(roles) && roles.length) {
|
|
226
232
|
pick = roles.map(String).filter((k) => TEAM[k] && TEAM[k].runs);
|
|
227
|
-
|
|
233
|
+
// the Builder's work is checked by the product's own CI on its draft PR, not by the Evaluator (W7)
|
|
234
|
+
if (pick.length && !pick.includes('eval') && pick.some((k) => k !== 'eval' && k !== 'build')) pick.push('eval');
|
|
228
235
|
} else if (kind === 'goal') {
|
|
229
236
|
pick = ['strategy', 'research', 'eval'];
|
|
230
237
|
} else {
|
|
@@ -245,6 +252,14 @@ function toolsOf(r, { root = null, mode = 'propose' } = {}) {
|
|
|
245
252
|
const writePaths = [];
|
|
246
253
|
if (!ro) return { tools, writePaths };
|
|
247
254
|
if (ro.key === 'eval') tools.push('Bash(pmos team verdict *)');
|
|
255
|
+
if (ro.key === 'build') {
|
|
256
|
+
// W7: its verbs and read-only git in any mode, and Write/Edit in its worktrees only. No git push, no gh, no merge: the outward step
|
|
257
|
+
// (pmos build open) is the PM's ✓, and it refuses a role run anyway.
|
|
258
|
+
for (const v of ro.owns.verbs) tools.push(`Bash(${v} *)`);
|
|
259
|
+
tools.push('Bash(git status *)', 'Bash(git diff *)');
|
|
260
|
+
writePaths.push(path.join(process.env.PMOS_BUILD_DIR || path.join(require('os').homedir(), '.pmos', 'build')) + '/');
|
|
261
|
+
return { tools, writePaths };
|
|
262
|
+
}
|
|
248
263
|
if (mode === 'auto') {
|
|
249
264
|
tools.push('Bash(pmos team wrote *)');
|
|
250
265
|
for (const v of ro.owns.verbs) if (v !== 'pmos team verdict') tools.push(`Bash(${v} *)`);
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* artefact-mirror.js — a Done test written with `pmos artefacts` counts everywhere a done test counts (launch simulation W6, gap 1).
|
|
3
|
+
*
|
|
4
|
+
* sync(root, scope, { actor, ledger }) → { ok, id, wrote: [what], note } | { ok: true, skipped: why } | refusal
|
|
5
|
+
*
|
|
6
|
+
* D107 lets an agent write an experiment's Done test checks and its kill condition into the artefact ledger (lib/artefacts.js). The ladder
|
|
7
|
+
* (scripts/workflow-state.js), the two gates (.github/scripts/initiative-gate.sh, kit/scripts/gate-initiative.sh), `pmos jira draft` and the
|
|
8
|
+
* Viewer gate read the record's `done_test_path:` and `kill:` instead, and the order rule (done test before the build) reads the git history of
|
|
9
|
+
* the done test FILE. So the ledger is mirrored onto the record, and no reader needs a second done-test source:
|
|
10
|
+
*
|
|
11
|
+
* - the checks (done-test.check, and done-test.result) go to a done test file, `planning/done-tests/<id>.md` (`pmos/planning/…` in a kit
|
|
12
|
+
* repository), or the file the record already names. The file carries MARK: a file without it was written by hand and is never touched.
|
|
13
|
+
* - the record gets `done_test_path:` when it has none, and `kill:` from the newest experiment.kill line. An undo writes back the kill the
|
|
14
|
+
* ledger holds then; when none is left the record keeps its line (it may have been written by hand).
|
|
15
|
+
*
|
|
16
|
+
* Nothing here runs a model, and nothing is committed: the CLI says to commit the two files, like every record write.
|
|
17
|
+
*/
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
const path = require('path');
|
|
20
|
+
|
|
21
|
+
const MARK = '<!-- written by PMOS from the Done test artefact (pmos artefacts set). Edit the checks with pmos artefacts; a file without this line is left alone. -->';
|
|
22
|
+
const ID_RE = /^[a-z0-9][a-z0-9._-]*$/;
|
|
23
|
+
const refuse = (status, error) => ({ ok: false, status, error });
|
|
24
|
+
const q = (s) => '"' + String(s).replace(/\s+/g, ' ').trim().replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
|
|
25
|
+
const unquote = (v) => { const t = String(v || '').trim(); return /^".*"$/.test(t) ? t.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\') : /^'.*'$/.test(t) ? t.slice(1, -1).replace(/''/g, "'") : t; };
|
|
26
|
+
const cell = (s) => String(s).replace(/\s+/g, ' ').trim().replace(/\|/g, '\\|');
|
|
27
|
+
|
|
28
|
+
/** True for a set or undo the mirror cares about: an experiment's done test lines or its kill condition. */
|
|
29
|
+
function touches(line) {
|
|
30
|
+
if (!line || typeof line.scope !== 'string' || !/^experiment:/.test(line.scope)) return false;
|
|
31
|
+
return line.artefact === 'done-test' || (line.artefact === 'experiment' && (line.field === 'kill' || line.ev === 'undo'));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The done test file's text: front matter (D63), the mark, and one row per check. */
|
|
35
|
+
function fileText(id, title, checks, result, today) {
|
|
36
|
+
const out = ['---', 'type: Rubric', `title: ${q('Done test — ' + (title || id))}`, `timestamp: ${today}`, `initiative: ${id}`, '---', '', MARK, '',
|
|
37
|
+
`# Done test: ${id}`, '', 'Every check must pass. PMOS keeps this file in step with the Done test artefact.', ''];
|
|
38
|
+
if (checks.length) {
|
|
39
|
+
out.push('| # | Check |', '|---|---|');
|
|
40
|
+
checks.forEach((c, i) => out.push(`| ${i + 1} | ${cell(c)} |`));
|
|
41
|
+
} else out.push('No checks yet.');
|
|
42
|
+
if (result) out.push('', `Result: ${String(result).replace(/\s+/g, ' ').trim()}`);
|
|
43
|
+
return out.join('\n') + '\n';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function sync(root, scope, { ledger } = {}) {
|
|
47
|
+
const m = /^experiment:(.+)$/.exec(String(scope || ''));
|
|
48
|
+
if (!m || !ID_RE.test(m[1])) return { ok: true, skipped: 'not an experiment' };
|
|
49
|
+
const id = m[1];
|
|
50
|
+
const A = require('./artefacts.js');
|
|
51
|
+
const loaded = require('./console-state').loadEngine();
|
|
52
|
+
if (!loaded.ok) return refuse(500, loaded.error);
|
|
53
|
+
const L = loaded.engine.layout(root);
|
|
54
|
+
const rec = path.join(L.initiatives, `${id}.md`);
|
|
55
|
+
let text;
|
|
56
|
+
try { if (!fs.lstatSync(rec).isFile()) return { ok: true, skipped: 'the record is not a plain file' }; text = fs.readFileSync(rec, 'utf8'); }
|
|
57
|
+
catch { return { ok: true, skipped: `no initiative record ${id}` }; }
|
|
58
|
+
const fm = /^---\r?\n([\s\S]*?)\r?\n---(\r?\n|$)/.exec(text);
|
|
59
|
+
if (!fm) return { ok: true, skipped: 'the record has no front matter' };
|
|
60
|
+
const lines = fm[1].split(/\r?\n/);
|
|
61
|
+
const val = (key) => { const l = lines.find((x) => x.startsWith(key + ':')); return l ? unquote(l.slice(key.length + 1)) : ''; };
|
|
62
|
+
|
|
63
|
+
const v = A.viewOf(A.fold(A.readLines(ledger)), `experiment:${id}`);
|
|
64
|
+
const art = (k) => (v && v.artefacts.find((a) => a.key === k)) || { fields: {} };
|
|
65
|
+
const dt = art('done-test').fields, ex = art('experiment').fields;
|
|
66
|
+
// a list field holds one line per set; a set may hold several lines (withLine), each one check
|
|
67
|
+
const checks = (dt.check || []).flatMap((x) => String(x.text || '').split(/\n+/)).map((s) => s.trim()).filter(Boolean);
|
|
68
|
+
const result = dt.result && dt.result.text ? dt.result.text : '';
|
|
69
|
+
const kill = ex.kill && ex.kill.text ? String(ex.kill.text).replace(/\s+/g, ' ').trim() : '';
|
|
70
|
+
|
|
71
|
+
const wrote = [];
|
|
72
|
+
let note = '';
|
|
73
|
+
// the done test file
|
|
74
|
+
const named = val('done_test_path');
|
|
75
|
+
const relDefault = (L.kit ? 'pmos/planning/done-tests/' : 'planning/done-tests/') + id + '.md';
|
|
76
|
+
const rel = named || relDefault;
|
|
77
|
+
const abs = path.resolve(root, rel);
|
|
78
|
+
const inside = !path.relative(path.resolve(root), abs).startsWith('..');
|
|
79
|
+
let setPath = false;
|
|
80
|
+
if (!inside) note = `done_test_path '${rel}' is outside the repository: PMOS left it`;
|
|
81
|
+
else if (checks.length || result || fs.existsSync(abs)) {
|
|
82
|
+
let cur = null;
|
|
83
|
+
try { cur = fs.readFileSync(abs, 'utf8'); } catch { cur = null; }
|
|
84
|
+
if (cur != null && !cur.includes(MARK)) note = `the done test ${rel} was written by hand: PMOS left it as it is`;
|
|
85
|
+
else if (cur == null && !checks.length && !result) { /* nothing to write yet */ }
|
|
86
|
+
else {
|
|
87
|
+
const title = val('title');
|
|
88
|
+
const day = new Date().toISOString().slice(0, 10);
|
|
89
|
+
const next = fileText(id, title, checks, result, day);
|
|
90
|
+
// the timestamp alone never rewrites the file
|
|
91
|
+
const same = cur != null && cur.replace(/^timestamp: .*$/m, '') === next.replace(/^timestamp: .*$/m, '');
|
|
92
|
+
if (!same) {
|
|
93
|
+
try { fs.mkdirSync(path.dirname(abs), { recursive: true }); fs.writeFileSync(abs, next); } catch { return refuse(500, `the done test ${rel} could not be written`); }
|
|
94
|
+
wrote.push(rel);
|
|
95
|
+
}
|
|
96
|
+
if (!named) setPath = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// the record's two lines
|
|
100
|
+
let changed = false;
|
|
101
|
+
if (setPath) { lines.push(`done_test_path: ${rel}`); changed = true; }
|
|
102
|
+
if (kill && val('kill') !== kill) {
|
|
103
|
+
const at = lines.findIndex((l) => l.startsWith('kill:'));
|
|
104
|
+
if (at >= 0) lines[at] = 'kill: ' + q(kill); else lines.push('kill: ' + q(kill));
|
|
105
|
+
changed = true;
|
|
106
|
+
}
|
|
107
|
+
if (changed) {
|
|
108
|
+
try { fs.writeFileSync(rec, '---\n' + lines.join('\n') + '\n---' + fm[2] + text.slice(fm[0].length)); } catch { return refuse(500, 'the record could not be written'); }
|
|
109
|
+
wrote.push(path.relative(root, rec).split(path.sep).join('/'));
|
|
110
|
+
}
|
|
111
|
+
return { ok: true, id, wrote, note };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** After a set or undo through lib/artefacts.js (called by its three writers: the CLI, POST /api/artefacts/set and the driver's Keep and
|
|
115
|
+
* Undo): mirror it when it touches a done test or a kill condition. Never throws. → the sync answer, or null when it touches neither. */
|
|
116
|
+
function after(root, line, ledger) {
|
|
117
|
+
if (!root || !touches(line)) return null;
|
|
118
|
+
try { return sync(root, line.scope, { ledger }); } catch (e) { return refuse(500, String((e && e.message) || e)); }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
module.exports = { MARK, touches, sync, after, fileText };
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
const path = require('path');
|
|
13
13
|
const { execFileSync } = require('child_process');
|
|
14
14
|
const A = require('./artefacts.js');
|
|
15
|
+
const MIRROR = require('./artefact-mirror.js');
|
|
15
16
|
const actorLib = require('./actor.js');
|
|
16
17
|
|
|
17
18
|
const COMMANDS = { artefacts: ['show', 'map', 'migrate', 'set', 'undo'] };
|
|
@@ -92,14 +93,27 @@ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), env = pro
|
|
|
92
93
|
for (const s of flags.source) { const i = s.indexOf('='); if (i < 1) { say('✗ --source is label=ref'); return 2; } sources.push({ label: s.slice(0, i), ref: s.slice(i + 1) }); }
|
|
93
94
|
const r = A.set(f, { scope: pos[0], artefact: pos[1], field: pos[2], text: flags.text, sources }, actor, { now });
|
|
94
95
|
if (!r.ok) { say('✗ ' + r.error); return 1; }
|
|
95
|
-
|
|
96
|
+
r.mirror = MIRROR.after(root, r.line, f); // a done test or kill condition lands on the record too (launch simulation W6)
|
|
97
|
+
if (flags.json) { say(JSON.stringify({ ok: true, id: r.line.id, ...(r.mirror ? { mirror: r.mirror } : {}) })); return 0; }
|
|
98
|
+
say(`✓ ${r.line.artefact}.${r.line.field} on ${r.line.scope} (${r.line.id}; pmos artefacts undo ${r.line.id})`);
|
|
99
|
+
mirrorSay(say, r.mirror);
|
|
96
100
|
return 0;
|
|
97
101
|
}
|
|
98
102
|
if (!pos[0]) { say(USAGE[5]); return 2; }
|
|
99
103
|
const r = A.undo(f, { ref: pos[0] }, actor, { now });
|
|
100
104
|
if (!r.ok) { say('✗ ' + r.error); return 1; }
|
|
105
|
+
r.mirror = MIRROR.after(root, r.line, f);
|
|
101
106
|
say(`✓ ${pos[0]} undone`);
|
|
107
|
+
mirrorSay(say, r.mirror);
|
|
102
108
|
return 0;
|
|
103
109
|
}
|
|
104
110
|
|
|
111
|
+
/** What the mirror wrote (lib/artefact-mirror.js): the done test file and the record, so the ladder and the gates count it. */
|
|
112
|
+
function mirrorSay(say, m) {
|
|
113
|
+
if (!m) return;
|
|
114
|
+
if (!m.ok) { say(' ! the record was not updated: ' + m.error); return; }
|
|
115
|
+
if (m.wrote && m.wrote.length) say(` ✓ wrote ${m.wrote.join(' and ')}: the ladder, the gates and pmos jira draft count it. Commit them to keep them.`);
|
|
116
|
+
if (m.note) say(' ' + m.note);
|
|
117
|
+
}
|
|
118
|
+
|
|
105
119
|
module.exports = { run, COMMANDS, USAGE, mapRows };
|
|
@@ -119,7 +119,8 @@ function classOfProposal(p) {
|
|
|
119
119
|
if (!isObj(p)) return 'C';
|
|
120
120
|
const c = PROPOSAL_CLASS[p.group] || 'C';
|
|
121
121
|
if (p.group === 'status' && (p.items || []).some((x) => x && x.jira)) return 'C';
|
|
122
|
-
if (p.group === 'outcome' && p.type === 'refuted') return 'C';
|
|
122
|
+
if (p.group === 'outcome' && p.type === 'refuted') return 'C';
|
|
123
|
+
if (p.group === 'build') return 'C'; // a pull request is seen by the team (launch simulation W7): only the PM's ✓ opens it // stopping or replacing an experiment is the PM's call (launch simulation W2)
|
|
123
124
|
// a maybe, or a duplicate already in another initiative (type link, or an item with `other`), is a question for the PM, not a change
|
|
124
125
|
// found type stage moves the initiative's stage: a stage move is C (as the Driver's `move`)
|
|
125
126
|
if (p.group === 'found' && (p.type === 'stage' || p.type === 'maybe' || p.type === 'link' || (p.items || []).some((x) => x && x.other))) return 'C';
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* build-cli.js — `pmos build`: the factory's Builder in this repository (launch simulation W7, initiative kit-factory-builder).
|
|
3
|
+
* The engine is lib/build-engine.js; this file parses and prints. Guide page: guide/cli.md.
|
|
4
|
+
*
|
|
5
|
+
* pmos build next [<initiative>] [--json] the declared work items no Builder has taken
|
|
6
|
+
* pmos build claim <item> [--json] claim one, on a new branch pmos/<item> in a worktree of its own
|
|
7
|
+
* pmos build propose <item> "<what it does>" --evidence "<the check that passed>" [--json]
|
|
8
|
+
* commit, mark verified, and file "Open a draft pull request" under the ✦
|
|
9
|
+
* pmos build open <item> [--json] the PM only: push the branch and open the DRAFT pull request
|
|
10
|
+
* pmos build status [--json] every work item, its branch and whether its worktree is here
|
|
11
|
+
* common: [--root <dir>]
|
|
12
|
+
*
|
|
13
|
+
* `open` is what the ✓ on the proposal runs. A role run (PMOS_TEAM_RUN set) cannot run it: opening a pull request is seen by the team,
|
|
14
|
+
* so it is class C and waits for the PM. Nothing here merges; when a pull request may merge is lib/build-engine.js mergePolicy.
|
|
15
|
+
* Exit codes: 0 done, 1 refused, 2 usage.
|
|
16
|
+
*/
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const { execFileSync } = require('child_process');
|
|
19
|
+
const BE = require('./build-engine.js');
|
|
20
|
+
|
|
21
|
+
const COMMANDS = { build: ['next', 'claim', 'propose', 'open', 'status'] };
|
|
22
|
+
const USAGE = [
|
|
23
|
+
'usage: pmos build next|claim|propose|open|status — the Builder: PMOS builds a declared work item as a draft pull request you merge',
|
|
24
|
+
' pmos build next [<initiative>] the declared work items no Builder has taken',
|
|
25
|
+
' pmos build claim <item> claim one; PMOS makes the branch pmos/<item> in a worktree outside this folder',
|
|
26
|
+
' pmos build propose <item> "<what it does>" --evidence "<the check that passed>"',
|
|
27
|
+
' commit it and file "Open a draft pull request" under the initiative\'s ✦',
|
|
28
|
+
' pmos build open <item> you only (the ✓ runs it): push pmos/<item> and open the draft pull request',
|
|
29
|
+
' pmos build status every work item and its branch',
|
|
30
|
+
'every command: [--json] [--root <dir>]. Nothing here merges: you merge, after the product\'s own checks.',
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
function parse(argv) {
|
|
34
|
+
const pos = [], flags = {};
|
|
35
|
+
for (let i = 0; i < argv.length; i++) {
|
|
36
|
+
const a = argv[i];
|
|
37
|
+
if (!a.startsWith('--')) { pos.push(a); continue; }
|
|
38
|
+
const k = a.slice(2);
|
|
39
|
+
if (k === 'json') { flags.json = true; continue; }
|
|
40
|
+
const v = argv[i + 1];
|
|
41
|
+
if (v === undefined || v.startsWith('--')) flags[k] = ''; else { flags[k] = v; i++; }
|
|
42
|
+
}
|
|
43
|
+
return { pos, flags };
|
|
44
|
+
}
|
|
45
|
+
function repoRoot(cwd) {
|
|
46
|
+
try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; }
|
|
47
|
+
catch { return cwd; }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function run(argv, { say = (s) => console.log(s), env = process.env, cwd = process.cwd() } = {}) {
|
|
51
|
+
const args = argv[0] === 'build' ? argv.slice(1) : argv.slice();
|
|
52
|
+
const verb = args[0];
|
|
53
|
+
if (!verb || ['help', '--help', '-h'].includes(verb)) { for (const l of USAGE) say(l); return verb ? 0 : 1; }
|
|
54
|
+
if (!COMMANDS.build.includes(verb)) { say(`unknown build command "${verb}" — one of ${COMMANDS.build.join(', ')}`); return 2; }
|
|
55
|
+
const { pos, flags } = parse(args.slice(1));
|
|
56
|
+
const json = !!flags.json;
|
|
57
|
+
// a role run works in its worktree, so the repository is the one the server pinned (PMOS_TEAM_ROOT), not the worktree
|
|
58
|
+
const root = flags.root ? path.resolve(cwd, flags.root) : env.PMOS_TEAM_ROOT || repoRoot(cwd);
|
|
59
|
+
const fail = (error, code = 1) => { say(json ? JSON.stringify({ ok: false, error }) : `✗ ${error}`); return code; };
|
|
60
|
+
const ok = (obj, text) => { say(json ? JSON.stringify({ ok: true, ...obj }) : text); return 0; };
|
|
61
|
+
if (!require('./work-kind.js').factoryRuns(root)) return fail('no factory runs in this repository (no work-item ledger and verify-work script), so PMOS does not build here. The team\'s agents build from the done test and the pull request plan');
|
|
62
|
+
|
|
63
|
+
if (verb === 'next' || verb === 'status') {
|
|
64
|
+
const list = verb === 'next' ? BE.next(root, pos[0]) : BE.status(root);
|
|
65
|
+
if (json) return ok({ items: list });
|
|
66
|
+
if (!list.length) { say(verb === 'next' ? 'No declared work item waits for a Builder.' : 'No work items.'); return 0; }
|
|
67
|
+
for (const x of list) say(verb === 'next' ? `${x.item_id} ${x.type || ''} ${(x.criterion && x.criterion.text) || ''}` : `${x.item} ${x.state} ${x.branch}${x.here ? ' (worktree here)' : ''}`);
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
const item = pos[0];
|
|
71
|
+
if (!item) return fail(`usage: pmos build ${verb} <item>`, 2);
|
|
72
|
+
if (verb === 'claim') {
|
|
73
|
+
const agent = env.PMOS_TEAM_RUN ? `pmos:builder:${env.PMOS_TEAM_RUN}` : 'pmos:builder';
|
|
74
|
+
const r = BE.claim(root, item, { agent });
|
|
75
|
+
if (!r.ok) return fail(r.error);
|
|
76
|
+
return ok(r, `✓ claimed ${item} on ${r.branch} (from ${r.base}). Work only in ${r.worktree}. When its check passes: pmos build propose ${item} "<what it does>" --evidence "<the check>"`);
|
|
77
|
+
}
|
|
78
|
+
if (verb === 'propose') {
|
|
79
|
+
const summary = pos.slice(1).join(' ');
|
|
80
|
+
if (!summary) return fail(`usage: pmos build propose ${item} "<what it does>" --evidence "<the check that passed>"`, 2);
|
|
81
|
+
const r = BE.propose(root, item, { summary, evidence: flags.evidence || '', run: env.PMOS_TEAM_RUN || null });
|
|
82
|
+
if (!r.ok) return fail(r.error);
|
|
83
|
+
return ok(r, `✓ committed ${r.commit.slice(0, 8)} (${r.files.length} ${r.files.length === 1 ? 'file' : 'files'}) and filed "Open a draft pull request" under the ✦. It waits for your ✓; nothing is pushed yet.`);
|
|
84
|
+
}
|
|
85
|
+
if (verb === 'open') {
|
|
86
|
+
const r = BE.open(root, item, { env });
|
|
87
|
+
if (!r.ok) return fail(r.error);
|
|
88
|
+
return ok(r, `✓ opened a draft pull request from ${r.branch} into ${r.base}${r.url ? ': ' + r.url : ''}. ${r.policy.why}`);
|
|
89
|
+
}
|
|
90
|
+
return fail('unknown command', 2);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
module.exports = { run, COMMANDS, USAGE };
|