create-pmos 0.462.0 → 0.463.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 +14 -14
- 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 +13 -0
- package/workspace/guide/layout.md +2 -2
- package/workspace/lib/auto-sync.js +56 -10
- package/workspace/lib/folder-repair.js +150 -0
- package/workspace/lib/sync.js +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/test-files.json +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.463.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": {
|
|
@@ -32,6 +32,19 @@
|
|
|
32
32
|
"audit"
|
|
33
33
|
],
|
|
34
34
|
"pmosChanges": [
|
|
35
|
+
{
|
|
36
|
+
"v": "0.463.0",
|
|
37
|
+
"at": "2026-10-31T02:36:24.736Z",
|
|
38
|
+
"f": 3,
|
|
39
|
+
"prs": [
|
|
40
|
+
{
|
|
41
|
+
"n": 1114,
|
|
42
|
+
"t": "Records are saved on the default branch only, and a document folder is put back on it by itself (D70)",
|
|
43
|
+
"s": "Records are saved on the default branch only, and a document folder is put back on it by itself",
|
|
44
|
+
"k": "fix"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
35
48
|
{
|
|
36
49
|
"v": "0.462.0",
|
|
37
50
|
"at": "2026-10-31T02:08:48.803Z",
|
|
@@ -284,19 +297,6 @@
|
|
|
284
297
|
"k": "new"
|
|
285
298
|
}
|
|
286
299
|
]
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
"v": "0.443.0",
|
|
290
|
-
"at": "2026-10-28T14:25:24.275Z",
|
|
291
|
-
"f": 3,
|
|
292
|
-
"prs": [
|
|
293
|
-
{
|
|
294
|
-
"n": 1087,
|
|
295
|
-
"t": "0.442.0 hotfix, goals made clear, folded list card, task ticket linking (batch 18)",
|
|
296
|
-
"s": "0.442.0 hotfix, goals made clear, folded list card, task ticket linking (batch 18)",
|
|
297
|
-
"k": "new"
|
|
298
|
-
}
|
|
299
|
-
]
|
|
300
300
|
}
|
|
301
301
|
]
|
|
302
302
|
}
|
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-10-31T02:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-31T02:36:21Z"}
|
|
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-10-31T02:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-31T02:36:21Z"}
|
|
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-10-31T02:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-31T02:36:21Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.463.0",
|
|
4
|
+
"at": "2026-10-31T02:36:24.736Z",
|
|
5
|
+
"f": 3,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1114,
|
|
9
|
+
"t": "Records are saved on the default branch only, and a document folder is put back on it by itself (D70)",
|
|
10
|
+
"s": "Records are saved on the default branch only, and a document folder is put back on it by itself",
|
|
11
|
+
"k": "fix"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
2
15
|
{
|
|
3
16
|
"v": "0.462.0",
|
|
4
17
|
"at": "2026-10-31T02:08:48.803Z",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Guide
|
|
3
3
|
title: "Guide: layout"
|
|
4
4
|
description: "The frame: one top bar, the place on screen, the detail and the agent dock; the phone tabs and lists; the keys; and the older layout."
|
|
5
|
-
timestamp: 2026-10-
|
|
5
|
+
timestamp: 2026-10-31
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Guide: layout
|
|
@@ -22,7 +22,7 @@ The top bar has these parts, from left to right:
|
|
|
22
22
|
- **Agenda, My work, Initiatives, Board, Reports, Docs and People** are the places. Each has an icon before its name, the same icon as on the phone. Press one to show it. The Agenda count shows how many items need you. Docs shows whether each document is the same as its Google Docs and Confluence copy. People shows the people you work with in the repository ([People](people.md)).
|
|
23
23
|
- **Search or capture ⌘K** opens the command palette. Type to find an initiative, a repository, an open tab or a command.
|
|
24
24
|
- **Sync** shows only when the current repository is not in sync with its remote. Press it to fetch, bring in the work of the other machine, record your changes and push. If the repository has not fetched in the last 10 minutes, Sync also shows, because a push from another machine is not visible until a fetch. When the repository fetched recently and is in sync, Sync is not shown. When two machines add lines to the same ledger (a `.jsonl` file under `pmos/` or `planning/`), Sync keeps the lines from both machines. If Sync stops, the message names the step that stopped. If both machines changed the same lines of another file, Sync changes nothing and names the files. Then choose **Push this machine’s version** or **Pull the other machine’s version**. Sync keeps that version of those files, keeps all other changes from both machines, and finishes. It never overwrites the remote history.
|
|
25
|
-
- **Sync on its own.** If you forget to press Sync, the workspace syncs for you. It syncs each repository once when the workspace starts. It also syncs a repository that has records not yet pushed when no record changed for 5 minutes. In a document repository it syncs every changed file
|
|
25
|
+
- **Sync on its own.** If you forget to press Sync, the workspace syncs for you. It syncs each repository once when the workspace starts. It also syncs a repository that has records not yet pushed when no record changed for 5 minutes. It syncs only on the default branch (for example `main`). In a document repository it syncs every changed file. In a code repository it also needs every commit not yet pushed to change records and no code. If a document folder has been left on another branch, the workspace puts it back on the default branch for you, with your records saved, when that loses nothing. It tells you only when it cannot do this safely, for example when two saved versions of one page do not match. If you close the tab while records are not yet pushed, the browser asks you first. To turn automatic sync off, start the workspace with `PMOS_AUTO_SYNC=0`.
|
|
26
26
|
- **Settings** opens the settings of the workspace.
|
|
27
27
|
|
|
28
28
|
Each place is drawn when its run is built. Until then the place says which run brings it, for example "Board arrives in Run 4."
|
|
@@ -8,16 +8,21 @@
|
|
|
8
8
|
* Before either, a repository must pass every rule below. A rule that cannot be read is a no.
|
|
9
9
|
* - auto-sync is on for this server (see enabledFor);
|
|
10
10
|
* - the branch has an upstream;
|
|
11
|
-
* -
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* - the branch is the remote's default branch, in every repository (D70 as amended 2026-10-31: a record committed on a
|
|
12
|
+
* feature branch never reaches the default branch, so the PM's records seemed to vanish from the product they belong to);
|
|
13
|
+
* - in a CODE repository only (profile product-code, D68): every commit not yet pushed touches record paths only, so
|
|
14
|
+
* code is never auto-pushed. A DOCUMENT repository (profile pm-artifacts) holds only the PM's documents: every file;
|
|
14
15
|
* - no record file changed in the last QUIET_MS: a document being written is left alone;
|
|
15
16
|
* - no sync is running for the repository, and the last auto-sync did not fail within RETRY_MS.
|
|
16
17
|
*/
|
|
17
18
|
const syncLib = require('./sync');
|
|
19
|
+
const folderRepair = require('./folder-repair');
|
|
18
20
|
|
|
21
|
+
const BRANCH_WHY = /not the default branch|cannot tell the default branch/;
|
|
19
22
|
const QUIET_MS = 5 * 60 * 1000;
|
|
20
23
|
const RETRY_MS = 30 * 60 * 1000;
|
|
24
|
+
const ASK_AGAIN_MS = 30 * 60 * 1000; // a repair that needs the PM is not tried again for this long
|
|
25
|
+
const WAIT_AGAIN_MS = 10 * 60 * 1000; // one that only waited (no network, a refused push) is tried again sooner
|
|
21
26
|
|
|
22
27
|
// On for a real server start. A server given its own state directory (every suite does, through test-run.js) is a
|
|
23
28
|
// scratch server and does not auto-sync unless asked. PMOS_AUTO_SYNC=0 turns it off; =1 turns it on.
|
|
@@ -37,8 +42,9 @@ async function blocker(root, moment, { now = Date.now(), lastFail = 0 } = {}) {
|
|
|
37
42
|
if (st.state === 'mid-operation') return 'a merge, rebase or cherry-pick is in progress';
|
|
38
43
|
const docs = syncLib.profileOf(root) === 'pm-artifacts';
|
|
39
44
|
const remote = st.upstream.split('/')[0];
|
|
40
|
-
const def =
|
|
41
|
-
if (!
|
|
45
|
+
const def = await syncLib.defaultBranchOf(root, remote);
|
|
46
|
+
if (!def) return `PMOS cannot tell the default branch of ${remote}, so it does not save your records on its own`;
|
|
47
|
+
if (st.branch !== def) return `'${st.branch}' is not the default branch of ${remote}, so PMOS is not saving your records. Switch this folder back to '${def}'`;
|
|
42
48
|
if (st.ahead && !docs) {
|
|
43
49
|
const paths = await syncLib.unpushedPaths(root, st.upstream);
|
|
44
50
|
if (!paths) return 'the unpushed commits cannot be read';
|
|
@@ -57,17 +63,57 @@ async function blocker(root, moment, { now = Date.now(), lastFail = 0 } = {}) {
|
|
|
57
63
|
* roots() the repository roots the server holds
|
|
58
64
|
* busy a Set of roots with a sync running (shared with the press route)
|
|
59
65
|
* onDone(root, result) called after each auto-sync that ran (to refresh caches) */
|
|
60
|
-
function createAutoSync({ roots, busy, onDone = () => {}, env = process.env, label = 'auto-sync' } = {}) {
|
|
61
|
-
const last = new Map(); // root -> { at, moment, ok, message, skipped? }
|
|
66
|
+
function createAutoSync({ roots, busy, onDone = () => {}, env = process.env, label = 'auto-sync', repair = folderRepair.repair } = {}) {
|
|
67
|
+
const last = new Map(); // root -> { at, moment, ok, message, skipped?, blocked?, needs?, repaired? }
|
|
68
|
+
const tried = new Map(); // root -> { at, result } the last repair attempt
|
|
69
|
+
const repairOn = String(env.PMOS_AUTO_REPAIR || '').trim() !== '0';
|
|
70
|
+
|
|
71
|
+
// A document repository whose folder is off its default branch is put back by itself (lib/folder-repair.js). It is tried again
|
|
72
|
+
// after a pause, so a state that needs the PM does not run git on every tick.
|
|
73
|
+
async function tryRepair(root) {
|
|
74
|
+
const prev = tried.get(root);
|
|
75
|
+
const pause = prev && prev.result && (prev.result.action === 'ask' ? ASK_AGAIN_MS : WAIT_AGAIN_MS);
|
|
76
|
+
if (prev && prev.result && prev.result.action !== 'repaired' && Date.now() - prev.at < pause) return prev.result;
|
|
77
|
+
busy.add(root);
|
|
78
|
+
try {
|
|
79
|
+
const result = await repair(root, { label });
|
|
80
|
+
tried.set(root, { at: Date.now(), result });
|
|
81
|
+
return result;
|
|
82
|
+
} catch (e) {
|
|
83
|
+
const result = { action: 'wait', why: String((e && e.message) || e).slice(0, 160) };
|
|
84
|
+
tried.set(root, { at: Date.now(), result });
|
|
85
|
+
return result;
|
|
86
|
+
} finally { busy.delete(root); }
|
|
87
|
+
}
|
|
88
|
+
|
|
62
89
|
async function runFor(root, moment) {
|
|
63
90
|
if (!enabledFor(env) || busy.has(root)) return null;
|
|
64
91
|
const prev = last.get(root);
|
|
65
|
-
const
|
|
66
|
-
|
|
92
|
+
const opts = () => ({ lastFail: prev && prev.ok === false ? prev.at : 0 });
|
|
93
|
+
let why = await blocker(root, moment, opts());
|
|
94
|
+
let repaired = null;
|
|
95
|
+
if (why && BRANCH_WHY.test(why)) {
|
|
96
|
+
// only a document repository is repaired and only one is the PM's to be told about: a developer on a feature branch is normal
|
|
97
|
+
if (syncLib.profileOf(root) !== 'pm-artifacts') return null;
|
|
98
|
+
const r = repairOn ? await tryRepair(root) : null;
|
|
99
|
+
if (r && r.action === 'repaired') { repaired = { from: r.from, to: r.to, at: Date.now() }; why = await blocker(root, moment, opts()); }
|
|
100
|
+
else {
|
|
101
|
+
// the technical reason stays in `detail`; `message` is the plain sentence, and only when the PM has to decide something
|
|
102
|
+
last.set(root, { at: Date.now(), moment, ok: null, skipped: true, blocked: 'branch', needs: r && r.action === 'ask' ? 'choice' : 'wait',
|
|
103
|
+
message: r && r.action === 'ask' ? folderRepair.plain(r) : '', detail: why, files: (r && r.files) || [] });
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (why) {
|
|
108
|
+
// repaired, and nothing is left to send: the status still says it happened, so the PM's screen can say it once
|
|
109
|
+
if (repaired) last.set(root, { at: Date.now(), moment, ok: true, message: '', repaired });
|
|
110
|
+
else if (prev && prev.blocked === 'branch') last.delete(root);
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
67
113
|
busy.add(root);
|
|
68
114
|
try {
|
|
69
115
|
const out = await syncLib.sync(root, { label });
|
|
70
|
-
last.set(root, { at: Date.now(), moment, ok: !!out.ok, message: out.message, stopped_at: out.stopped_at || null });
|
|
116
|
+
last.set(root, { at: Date.now(), moment, ok: !!out.ok, message: out.message, stopped_at: out.stopped_at || null, ...(repaired ? { repaired } : {}) });
|
|
71
117
|
try { onDone(root, out); } catch { /* a cache refresh is not the sync's business */ }
|
|
72
118
|
return out;
|
|
73
119
|
} finally { busy.delete(root); }
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* lib/folder-repair.js — put a document repository's folder back on its default branch, by itself, when that loses nothing
|
|
3
|
+
* (D70 as amended 2026-10-31). The PM: "if PMOS can fix it, it should just do it".
|
|
4
|
+
*
|
|
5
|
+
* WHY. A product folder left on a feature branch collects every record there, and the product looks empty on its default
|
|
6
|
+
* branch: Project Ascent's program and initiatives could not be found. The PM should not have to know what a branch is.
|
|
7
|
+
*
|
|
8
|
+
* WHAT. In a DOCUMENT repository (profile pm-artifacts: every file is a record) whose own folder is not on the remote's
|
|
9
|
+
* default branch, repair() does, in this order, and stops at the first step that cannot be made safe:
|
|
10
|
+
* 1. fetch;
|
|
11
|
+
* 2. commit the records pending in the folder, on the branch it is on (the same staging Sync uses);
|
|
12
|
+
* 3. check, without touching anything, that the branch merges into the default branch with no conflict;
|
|
13
|
+
* 4. merge the branch into the default branch (in the folder that already holds it, or in this one after switching);
|
|
14
|
+
* 5. push the default branch (no force);
|
|
15
|
+
* 6. free the default branch if another clean folder held it, and switch this folder onto it.
|
|
16
|
+
* The feature branch is never deleted, never rewritten and never force-pushed. A code repository is never touched: a developer
|
|
17
|
+
* on a feature branch is normal there. A linked worktree is never touched: only a repository's own folder is a product.
|
|
18
|
+
*
|
|
19
|
+
* ANSWERS. { action, from, to, why, files? }
|
|
20
|
+
* none nothing to do (already on the default branch, a code repository, a linked worktree)
|
|
21
|
+
* repaired the folder is on the default branch and its records are merged into it
|
|
22
|
+
* ask it cannot be made safe alone: 'conflict' (two versions of one file, `files` names them), 'work' (another copy of the
|
|
23
|
+
* folder holds work that is not saved), 'diverged' (the default branch differs from the remote's)
|
|
24
|
+
* wait try again later: no network, a push the remote refused, a git too old for the check, an operation in progress
|
|
25
|
+
* Every step that fails after a change is undone first (a merge is aborted, the folder is switched back), so `ask` and `wait`
|
|
26
|
+
* leave the folder as it was found, plus the records committed in step 2. Running it again after `repaired` answers `none`. */
|
|
27
|
+
const os = require('os');
|
|
28
|
+
const path = require('path');
|
|
29
|
+
const syncLib = require('./sync');
|
|
30
|
+
|
|
31
|
+
const { run } = syncLib;
|
|
32
|
+
const same = (a, b) => path.resolve(String(a)) === path.resolve(String(b));
|
|
33
|
+
|
|
34
|
+
/** The working trees of the repository: [{ dir, branch|null }], the main one first. */
|
|
35
|
+
async function worktrees(root) {
|
|
36
|
+
const r = await run(root, ['worktree', 'list', '--porcelain']);
|
|
37
|
+
if (!r.ok || !r.out) return [];
|
|
38
|
+
const out = []; let cur = null;
|
|
39
|
+
for (const line of r.out.split('\n')) {
|
|
40
|
+
if (line.startsWith('worktree ')) { cur = { dir: line.slice(9).trim(), branch: null }; out.push(cur); }
|
|
41
|
+
else if (cur && line.startsWith('branch ')) cur.branch = line.slice(7).trim().replace(/^refs\/heads\//, '');
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Is `root` a repository's own folder (not a linked worktree)? */
|
|
47
|
+
async function isMainTree(root) {
|
|
48
|
+
const r = await run(root, ['rev-parse', '--path-format=absolute', '--git-dir', '--git-common-dir']);
|
|
49
|
+
if (!r.ok) return false;
|
|
50
|
+
const [dir, common] = r.out.split('\n').map((x) => x.trim());
|
|
51
|
+
return !!dir && !!common && same(dir, common);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function repair(root, { label } = {}) {
|
|
55
|
+
const none = (why) => ({ action: 'none', why });
|
|
56
|
+
if (syncLib.profileOf(root) !== 'pm-artifacts') return none('a code repository');
|
|
57
|
+
if (!(await isMainTree(root))) return none('a linked worktree');
|
|
58
|
+
const s0 = await syncLib.status(root);
|
|
59
|
+
if (!s0.ok || !s0.branch) return none('no branch');
|
|
60
|
+
if (s0.state === 'mid-operation') return { action: 'wait', why: 'a merge, rebase or cherry-pick is in progress here' };
|
|
61
|
+
const remote = s0.upstream ? s0.upstream.split('/')[0] : 'origin';
|
|
62
|
+
if (!(await run(root, ['remote', 'get-url', remote])).ok) return none('no remote');
|
|
63
|
+
const def = await syncLib.defaultBranchOf(root, remote);
|
|
64
|
+
if (!def) return none('the default branch is not known');
|
|
65
|
+
const from = s0.branch;
|
|
66
|
+
if (from === def) return none('already on the default branch');
|
|
67
|
+
const out = (action, why, extra) => ({ action, from, to: def, why, ...(extra || {}) });
|
|
68
|
+
|
|
69
|
+
// 1. fetch
|
|
70
|
+
if (!(await run(root, ['fetch', '--quiet', remote], { net: true })).ok) return out('wait', 'the remote could not be reached');
|
|
71
|
+
|
|
72
|
+
// 2. the records pending in this folder are committed on the branch it is on, so nothing the PM wrote can be lost by what follows
|
|
73
|
+
const added = syncLib.ensureUnionAttribute(root);
|
|
74
|
+
const s1 = await syncLib.status(root);
|
|
75
|
+
if (s1.dirty_records || s1.dirty_other || added) {
|
|
76
|
+
if (!(await run(root, ['add', '-A'])).ok) return out('wait', 'the records could not be staged');
|
|
77
|
+
const staged = await run(root, ['diff', '--cached', '--name-only']);
|
|
78
|
+
if (staged.out) {
|
|
79
|
+
const c = await run(root, ['commit', '-m', `chore(pmos): sync records from ${label || os.hostname()}`, '--no-verify']);
|
|
80
|
+
if (!c.ok) return out('wait', /identity unknown|empty ident/i.test(c.err) ? 'git has no author name or email on this machine' : 'the records could not be committed');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// the default branch here must be the remote's, or ahead of it: a local default branch behind it moves up, a diverged one is not ours to fix
|
|
85
|
+
const trees = await worktrees(root);
|
|
86
|
+
const holder = trees.find((t) => t.branch === def && !same(t.dir, root)) || null;
|
|
87
|
+
const haveLocal = (await run(root, ['rev-parse', '--verify', '--quiet', `refs/heads/${def}`])).ok;
|
|
88
|
+
const remoteDef = `refs/remotes/${remote}/${def}`;
|
|
89
|
+
if (!(await run(root, ['rev-parse', '--verify', '--quiet', remoteDef])).ok) return out('wait', 'the remote has no default branch yet');
|
|
90
|
+
if (haveLocal) {
|
|
91
|
+
const behind = (await run(root, ['merge-base', '--is-ancestor', `refs/heads/${def}`, remoteDef])).ok;
|
|
92
|
+
const ahead = (await run(root, ['merge-base', '--is-ancestor', remoteDef, `refs/heads/${def}`])).ok;
|
|
93
|
+
if (!behind && !ahead) return out('ask', 'diverged');
|
|
94
|
+
if (behind && !holder) { if (!(await run(root, ['branch', '-f', def, remoteDef])).ok) return out('wait', 'the default branch could not be updated'); }
|
|
95
|
+
} else if (!(await run(root, ['branch', def, remoteDef])).ok) return out('wait', 'the default branch could not be created');
|
|
96
|
+
|
|
97
|
+
// another folder holds the default branch: it must hold no unsaved work, and is brought up to date
|
|
98
|
+
if (holder) {
|
|
99
|
+
const dirty = await run(holder.dir, ['status', '--porcelain', '--untracked-files=all']);
|
|
100
|
+
if (!dirty.ok || dirty.out) return out('ask', 'work', { where: holder.dir });
|
|
101
|
+
if (haveLocal && !(await run(holder.dir, ['merge', '--ff-only', remoteDef])).ok) {
|
|
102
|
+
const ahead = (await run(root, ['merge-base', '--is-ancestor', remoteDef, `refs/heads/${def}`])).ok;
|
|
103
|
+
if (!ahead) return out('wait', 'the default branch could not be brought up to date');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 3. a merge that conflicts is not made: the dry run touches no file and no branch
|
|
108
|
+
const attrs = syncLib.unionAttributesFor(root);
|
|
109
|
+
const cfg = attrs ? ['-c', `core.attributesFile=${attrs}`] : [];
|
|
110
|
+
const probe = await run(root, [...cfg, 'merge-tree', '--write-tree', '--name-only', def, from]);
|
|
111
|
+
if (!probe.ok) {
|
|
112
|
+
// `--name-only` prints the tree id and the conflicted files, then a blank line, then git's notes about each
|
|
113
|
+
const files = probe.out.split(/\n\s*\n/)[0].split('\n').slice(1).map((l) => l.trim()).filter(Boolean).slice(0, 8);
|
|
114
|
+
if (/conflict/i.test(probe.out) || files.length) return out('ask', 'conflict', { files });
|
|
115
|
+
return out('wait', 'this git cannot check a merge first');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 4. the merge, where the default branch already is, or here after switching onto it
|
|
119
|
+
let cwd = holder ? holder.dir : root;
|
|
120
|
+
let switched = false;
|
|
121
|
+
if (!holder) {
|
|
122
|
+
if (!(await run(root, ['switch', '--quiet', def])).ok) return out('wait', 'the folder could not be switched');
|
|
123
|
+
switched = true;
|
|
124
|
+
}
|
|
125
|
+
const back = async () => { if (switched) await run(root, ['switch', '--quiet', from]); };
|
|
126
|
+
const m = await run(cwd, [...cfg, 'merge', '--no-ff', '-m', `chore(pmos): bring the records from ${from} onto ${def}`, '--no-verify', from]);
|
|
127
|
+
if (!m.ok) { await run(cwd, ['merge', '--abort']); await back(); return out('ask', 'conflict'); }
|
|
128
|
+
|
|
129
|
+
// 5. push, never forced; a refusal keeps the local merge. Folder still on the branch: the next run pushes it. Folder already on the
|
|
130
|
+
// default branch: Sync pushes it, being then an ordinary unpushed record commit
|
|
131
|
+
if (!(await run(cwd, ['push', '--quiet', remote, def], { net: true })).ok) return out('wait', 'the remote did not take the push');
|
|
132
|
+
|
|
133
|
+
// 6. free the default branch and switch this folder onto it
|
|
134
|
+
if (holder) {
|
|
135
|
+
if (!(await run(root, ['worktree', 'remove', holder.dir])).ok) return out('wait', 'the other folder could not be removed');
|
|
136
|
+
if (!(await run(root, ['switch', '--quiet', def])).ok) return out('wait', 'the folder could not be switched');
|
|
137
|
+
}
|
|
138
|
+
return out('repaired', 'the records are merged and the folder is back on the default branch');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** The sentence a person reads when repair cannot be made safe alone. Plain words: no branch, merge or worktree. */
|
|
142
|
+
function plain(r) {
|
|
143
|
+
if (!r) return '';
|
|
144
|
+
if (r.action === 'ask' && r.why === 'conflict') return 'Two saved versions of the same page do not match, and PMOS cannot tell which one is newer.';
|
|
145
|
+
if (r.action === 'ask' && r.why === 'work') return 'Another copy of this folder holds work that is not saved yet, so PMOS has not moved your records.';
|
|
146
|
+
if (r.action === 'ask') return 'Your records are in two versions that do not match, so PMOS has not moved them.';
|
|
147
|
+
return '';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
module.exports = { repair, plain, worktrees, isMainTree };
|
package/workspace/lib/sync.js
CHANGED
|
@@ -246,5 +246,5 @@ async function defaultBranchOf(root, remote) {
|
|
|
246
246
|
return null;
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
module.exports = { status, sync, ensureUnionAttribute, unionAttributesFor, RECORD_PATHS, isRecord, REMOTE_FRESH_MS,
|
|
249
|
+
module.exports = { run, status, sync, ensureUnionAttribute, unionAttributesFor, RECORD_PATHS, isRecord, REMOTE_FRESH_MS,
|
|
250
250
|
unpushedPaths, newestDirtyRecordMs, defaultBranchOf, profileOf };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.463.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.463.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"state-isolation.test.js",
|
|
80
80
|
"sync.test.js",
|
|
81
81
|
"auto-sync.test.js",
|
|
82
|
+
"folder-repair.test.js",
|
|
82
83
|
"schedule-cli.test.js",
|
|
83
84
|
"initiative-surface.test.js",
|
|
84
85
|
"guide.test.js",
|
|
@@ -191,6 +192,7 @@
|
|
|
191
192
|
"state-isolation.test.js": 4,
|
|
192
193
|
"sync.test.js": 4,
|
|
193
194
|
"auto-sync.test.js": 4,
|
|
195
|
+
"folder-repair.test.js": 4,
|
|
194
196
|
"schedule-cli.test.js": 3,
|
|
195
197
|
"initiative-surface.test.js": 3,
|
|
196
198
|
"guide.test.js": 1,
|