geneseed 4.31.0 → 5.0.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/CHANGELOG.md +107 -0
- package/DESIGN.md +2 -2
- package/README.md +6 -5
- package/SHIPPED.md +4 -3
- package/adapters/bob/README.md +6 -5
- package/adapters/claude-code/README.md +4 -3
- package/adapters/claude-code/skills/geneseed/SKILL.md +1 -1
- package/adapters/openclaude/README.md +4 -3
- package/adapters/opencode/GLOBAL-HARNESS-SPEC.md +3 -1
- package/adapters/opencode/HOW-OPENCODE-LOADS.md +2 -1
- package/adapters/opencode/README.md +18 -18
- package/adapters/opencode/plugins/geneseed-activity.js +57 -1
- package/adapters/opencode/plugins/geneseed-context.js +220 -18
- package/adapters/opencode/plugins/geneseed-guard.js +578 -74
- package/adapters/opencode/plugins/geneseed-learn.js +97 -23
- package/bin/geneseed-cli.mjs +17 -25
- package/bin/geneseed-hook.mjs +23 -8
- package/docs/DESIGN.md +175 -0
- package/docs/PRD.md +111 -0
- package/docs/README.md +3 -2
- package/docs/architecture.md +145 -0
- package/docs/concepts/agents.md +1 -1
- package/docs/concepts/collaboration.md +1 -1
- package/docs/concepts/enforcement-table.md +1 -1
- package/docs/concepts/exclusions.md +6 -6
- package/docs/concepts/footprint.md +1 -1
- package/docs/concepts/foreman-mode.md +2 -2
- package/docs/concepts/hook-gates.md +1 -1
- package/docs/concepts/hooks.md +27 -11
- package/docs/concepts/host-matrix.md +3 -3
- package/docs/concepts/hosts.md +1 -1
- package/docs/concepts/kits.md +3 -1
- package/docs/concepts/loop-bricks.md +1 -1
- package/docs/concepts/loop-notes.md +4 -2
- package/docs/concepts/loop-templates.md +7 -4
- package/docs/concepts/loops.md +3 -0
- package/docs/concepts/ownership.md +2 -2
- package/docs/concepts/rules.md +15 -2
- package/docs/concepts/shared-tier.md +73 -0
- package/docs/concepts/skills.md +2 -2
- package/docs/concepts/themes.md +1 -1
- package/docs/extending.md +13 -12
- package/docs/guides/install-claude-code.md +1 -1
- package/docs/guides/install-opencode.md +1 -1
- package/docs/guides/migrate.md +4 -2
- package/docs/guides/project-context.md +2 -2
- package/docs/guides/run-a-loop.md +1 -1
- package/docs/guides/set-up-ownership.md +1 -1
- package/docs/guides/setup-footprint.md +1 -1
- package/docs/guides/uninstall.md +2 -1
- package/docs/guides/upgrade-to-5.md +116 -0
- package/docs/guides/upgrade.md +21 -9
- package/docs/guides/wiki.md +3 -3
- package/docs/reference/env-context.md +5 -3
- package/docs/reference/environment.md +1 -1
- package/docs/reference/glossary.md +2 -0
- package/docs/reference/loop-actions.md +1 -1
- package/docs/reference/opencode-plugins.md +3 -3
- package/docs/reference/plugin-activity.md +1 -1
- package/docs/reference/plugin-context.md +5 -0
- package/docs/reference/plugin-guard.md +14 -6
- package/docs/reference/plugin-learn.md +13 -6
- package/docs/reference/troubleshoot-hooks.md +3 -3
- package/docs/reference/troubleshoot-update.md +14 -0
- package/docs/token-footprint.md +4 -3
- package/docs/understand/a-day.md +2 -2
- package/docs/understand/design-choices-install.md +2 -1
- package/docs/understand/enforced-vs-asked.md +4 -3
- package/docs/understand/machine-bob.md +3 -1
- package/docs/understand/machine-claude.md +7 -5
- package/docs/understand/machine-opencode.md +7 -5
- package/docs/understand/on-your-machine.md +4 -0
- package/docs/understand/take-it-out.md +1 -1
- package/docs/web-ui.md +141 -73
- package/harness.config.json +1 -1
- package/js/README.md +10 -6
- package/js/build/args.mjs +10 -8
- package/js/build/bundle.mjs +11 -13
- package/js/build/driver.mjs +66 -65
- package/js/build/emit-claude.mjs +22 -16
- package/js/build/emit-common.mjs +4 -5
- package/js/build/emit-opencode.mjs +22 -22
- package/js/build/fold.mjs +515 -0
- package/js/build/generate.mjs +41 -52
- package/js/build/render.mjs +115 -29
- package/js/build/source.mjs +4 -1
- package/js/build/stubs.mjs +70 -9
- package/js/build/version.mjs +10 -10
- package/js/cli-table.json +23 -83
- package/js/hosts/activity.mjs +2 -2
- package/js/hosts/geneseed-dir.mjs +1 -1
- package/js/hosts/hooks-context.mjs +410 -99
- package/js/hosts/hooks-done.mjs +97 -31
- package/js/hosts/hooks-learn.mjs +38 -7
- package/js/hosts/hooks-prims.mjs +69 -2
- package/js/hosts/hooks.mjs +300 -64
- package/js/hosts/hosts.mjs +150 -51
- package/js/hosts/installs.mjs +55 -167
- package/js/hosts/link.mjs +3 -5
- package/js/hosts/mcp.mjs +1 -1
- package/js/hosts/memory-files.mjs +219 -17
- package/js/hosts/ownership-gate.mjs +1 -1
- package/js/hosts/settings.mjs +18 -13
- package/js/hosts/shim.mjs +4 -33
- package/js/hosts/store-watch.mjs +189 -0
- package/js/inspect/checks-authoring.mjs +3 -3
- package/js/inspect/checks-build.mjs +45 -18
- package/js/inspect/checks-counts.mjs +4 -4
- package/js/inspect/checks-repo.mjs +13 -14
- package/js/inspect/cost.mjs +24 -2
- package/js/inspect/diff.mjs +123 -123
- package/js/inspect/doctor.mjs +22 -27
- package/js/inspect/excludes.mjs +181 -62
- package/js/inspect/inventory.mjs +22 -27
- package/js/inspect/registry.mjs +106 -30
- package/js/inspect/scan.mjs +5 -5
- package/js/inspect/status.mjs +141 -119
- package/js/inspect/validate.mjs +22 -24
- package/js/lib/fs.mjs +47 -50
- package/js/lib/json.mjs +10 -17
- package/js/lib/machine-dir.mjs +73 -0
- package/js/lib/paths.mjs +22 -33
- package/js/lib/proc.mjs +1 -1
- package/js/lib/prompt.mjs +19 -27
- package/js/lib/text.mjs +8 -12
- package/js/lib/udiff.mjs +11 -15
- package/js/loop/catalog.mjs +2 -3
- package/js/loop/state.mjs +15 -5
- package/js/maintain/memory.mjs +17 -17
- package/js/maintain/migrate.mjs +79 -89
- package/js/maintain/setup.mjs +43 -32
- package/js/maintain/uninstall.mjs +43 -61
- package/js/maintain/update.mjs +200 -93
- package/js/ui/anim.mjs +21 -35
- package/js/ui/cli.mjs +36 -58
- package/js/ui/menu.mjs +22 -45
- package/js/ui/tui.mjs +27 -67
- package/js/web/actions.mjs +38 -38
- package/js/web/api.mjs +132 -76
- package/js/web/catalog.mjs +175 -46
- package/js/web/docs.mjs +33 -12
- package/js/web/doctor-worker.mjs +14 -0
- package/js/web/handler.mjs +14 -5
- package/js/web/routes.mjs +17 -19
- package/js/web/state.mjs +78 -19
- package/js/web/update-check.mjs +25 -10
- package/js/web/user-files.mjs +50 -105
- package/package.json +7 -4
- package/registry.json +48 -55
- package/src/AGENT.md.tmpl +13 -14
- package/src/agents/_self-improvement.md +1 -1
- package/src/agents/_template.md +4 -1
- package/src/agents/advocate.md +1 -1
- package/src/agents/architect.md +1 -1
- package/src/agents/developer.md +6 -3
- package/src/agents/devops-engineer.md +1 -1
- package/src/agents/docker-expert.md +1 -1
- package/src/agents/docs.md +1 -1
- package/src/agents/empiricist.md +1 -1
- package/src/agents/explorer.md +1 -1
- package/src/agents/framer.md +1 -1
- package/src/agents/historian.md +1 -1
- package/src/agents/kubernetes-specialist.md +1 -1
- package/src/agents/memory-curator.md +2 -2
- package/src/agents/operator.md +1 -1
- package/src/agents/performance.md +1 -1
- package/src/agents/pragmatist.md +1 -1
- package/src/agents/react-engineer.md +1 -1
- package/src/agents/react-reviewer.md +1 -1
- package/src/agents/researcher.md +1 -1
- package/src/agents/reviewer.md +1 -1
- package/src/agents/security.md +1 -1
- package/src/agents/skeptic.md +1 -1
- package/src/agents/spring-boot-engineer.md +1 -1
- package/src/agents/spring-reviewer.md +1 -1
- package/src/agents/spring-security.md +1 -1
- package/src/agents/steward.md +1 -1
- package/src/agents/tester.md +5 -2
- package/src/agents/user-advocate.md +1 -1
- package/src/agents/visionary.md +1 -1
- package/src/bricks/apply.md +3 -0
- package/src/bricks/test.md +6 -4
- package/src/loops/bugfix.json +11 -5
- package/src/loops/feature.json +7 -4
- package/src/memory/README.md +1 -1
- package/src/skills/_self-improvement.md +2 -2
- package/src/skills/daydream/SKILL.md +2 -2
- package/src/skills/daydream/instructions.md +1 -1
- package/src/skills/geneseed.md +1 -1
- package/src/skills/learn-mode.md +1 -2
- package/src/skills/loop.md +1 -0
- package/src/skills/profile.md +2 -2
- package/src/skills/rule/approve.md +69 -0
- package/src/skills/rule/consolidate.md +3 -3
- package/src/skills/rule.md +13 -5
- package/src/skills/ship.md +9 -1
- package/src/skills/skill-forge.md +1 -1
- package/src/skills/teach.md +29 -12
- package/src/skills/wiki.md +1 -1
- package/themes/_TEMPLATE.json +1 -2
- package/themes/biker.json +1 -2
- package/themes/commentator.json +1 -2
- package/themes/cyberpunk.json +1 -2
- package/themes/gamer.json +1 -2
- package/themes/imperial.json +1 -2
- package/themes/joker.json +1 -2
- package/themes/marvin.json +1 -2
- package/themes/mean.json +1 -2
- package/themes/military.json +1 -2
- package/themes/neutral.json +1 -2
- package/themes/pirate.json +1 -2
- package/themes/sports.json +1 -2
- package/themes/verstappen.json +1 -2
- package/themes/wizard.json +1 -2
- package/web/dist/assets/Activity-D8G4eClY.js +1 -0
- package/web/dist/assets/ActivityDetail-BtOBYk3M.js +1 -0
- package/web/dist/assets/AgentGlyph-k6o3gCM1.js +1 -0
- package/web/dist/assets/Bonsai-B_y20b3i.js +1 -0
- package/web/dist/assets/{CopyButton-IXnXzH4Y.js → CopyButton-CHQte7Ap.js} +1 -1
- package/web/dist/assets/Dashboard-B8uXeJZ_.js +2 -0
- package/web/dist/assets/{DataTable-BWbUx4bY.js → DataTable-b9zTShqJ.js} +1 -1
- package/web/dist/assets/Docs-Dgv_MWfT.js +5 -0
- package/web/dist/assets/{EmptyState-1sPNleqv.js → EmptyState-CY5Pm2xy.js} +1 -1
- package/web/dist/assets/FilterInput-qGKNSlxv.js +1 -0
- package/web/dist/assets/GreenhouseView-CSzTMSl_.js +1 -0
- package/web/dist/assets/Installs-BDk9lqBI.js +3 -0
- package/web/dist/assets/JournalView-CvRk1-m5.js +1 -0
- package/web/dist/assets/Kits-CoITzxWM.js +1 -0
- package/web/dist/assets/Laws-Ctf5r9rE.js +3 -0
- package/web/dist/assets/Library-DNwHYVXt.js +3 -0
- package/web/dist/assets/{Loops-C5u7fQOR.js → Loops-S85PMQ8m.js} +2 -2
- package/web/dist/assets/Markdown-0ORz7tAc.js +69 -0
- package/web/dist/assets/OperatorHudView-DuGz_sTk.js +1 -0
- package/web/dist/assets/Personal-afJNwvRS.js +2 -0
- package/web/dist/assets/RailCats-AW92uhsX.js +1 -0
- package/web/dist/assets/Settings-CGDFz-6j.js +1 -0
- package/web/dist/assets/Tabs-1qLrnqmn.js +1 -0
- package/web/dist/assets/api-C46vAuqp.js +1 -0
- package/web/dist/assets/controls-D4wmg_pl.js +1 -0
- package/web/dist/assets/index-COTd4TRZ.js +3 -0
- package/web/dist/assets/index-CtorA7uK.css +1 -0
- package/web/dist/assets/motion-RlUl1osO.js +1 -0
- package/web/dist/assets/react-C1iE8mnY.js +9 -0
- package/web/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/web/dist/assets/{sections-ChwaobfW.js → sections-CtFz7HFH.js} +1 -1
- package/web/dist/assets/{usePoll-bDFN-Hr6.js → usePoll-o8ul-Sog.js} +1 -1
- package/web/dist/index.html +7 -7
- package/src/skills/quiz.md +0 -44
- package/web/dist/assets/Activity-B7cFtS00.js +0 -1
- package/web/dist/assets/ActivityDetail-C-GbMmuW.js +0 -1
- package/web/dist/assets/Bonsai-_YyexVC5.js +0 -1
- package/web/dist/assets/Dashboard-sCfEjowQ.js +0 -2
- package/web/dist/assets/Docs-w3Y7M5Ts.js +0 -5
- package/web/dist/assets/FilterInput-CZREvrjX.js +0 -1
- package/web/dist/assets/GreenhouseView-BWWbMKmg.js +0 -1
- package/web/dist/assets/Installs-CnkdJ-VA.js +0 -3
- package/web/dist/assets/JournalView-C7bPD3fZ.js +0 -1
- package/web/dist/assets/KitApply-CQQbnThf.js +0 -1
- package/web/dist/assets/Kits-aj07N7mT.js +0 -1
- package/web/dist/assets/Laws-DZ38nl_H.js +0 -3
- package/web/dist/assets/Library-QCGXPV5h.js +0 -2
- package/web/dist/assets/Markdown-DpmmtW2Y.js +0 -65
- package/web/dist/assets/OperatorHudView-Blu1lqiZ.js +0 -1
- package/web/dist/assets/Personal-ox_MktWO.js +0 -2
- package/web/dist/assets/RailCats-BuJD4Jou.js +0 -1
- package/web/dist/assets/Tabs-CIPyMAX-.js +0 -1
- package/web/dist/assets/api-BxjLd7Qd.js +0 -1
- package/web/dist/assets/index-0GCxkY7m.css +0 -1
- package/web/dist/assets/index-CzDi9JpF.js +0 -3
- package/web/dist/assets/motion-CXaUMNkg.js +0 -1
- package/web/dist/assets/react-DlYQp10C.js +0 -9
- package/web/dist/assets/rolldown-runtime-hePW80VL.js +0 -1
package/js/inspect/registry.mjs
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The persistent list of folders a harness was deployed into.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* a module boundary in this port (P5c took the host resolvers, P5d the checkout paths). The
|
|
4
|
+
* IT LIVES HERE, NOT IN `bin/build-driver.mjs`. The
|
|
6
5
|
* driver WRITES the registry, one row per per-repo emit; `harness rebuild-all` READS it to
|
|
7
6
|
* find every install it must re-emit, and `bin/geneseed-cli.mjs` may not reach into a driver
|
|
8
7
|
* for a reader. `js/build/generate.mjs` importing `main` from `bin/build-driver.mjs` is not a
|
|
9
8
|
* precedent for it either: `harness build` IS the driver, and a registry reader is not.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
* `bin/build-driver.mjs` over
|
|
10
|
+
* `tests/golden.mjs` drives
|
|
11
|
+
* `bin/build-driver.mjs` over many cells with `$XDG_CONFIG_HOME` redirected into the sandbox and
|
|
13
12
|
* compares `installs.json` byte-for-byte, so a changed path or a dropped prune fails cells
|
|
14
13
|
* rather than passing quietly.
|
|
15
14
|
*/
|
|
16
|
-
import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync } from 'node:fs';
|
|
15
|
+
import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync } from 'node:fs';
|
|
17
16
|
import path from 'node:path';
|
|
18
17
|
import os from 'node:os';
|
|
19
18
|
|
|
@@ -21,11 +20,11 @@ import { expanduser, resolvePath } from '../hosts/hosts.mjs';
|
|
|
21
20
|
import { writeText, isFile, isDir } from '../lib/fs.mjs';
|
|
22
21
|
import { parseJson, jsonDumpsIndent } from '../lib/json.mjs';
|
|
23
22
|
import { toPlatformPath, within } from '../lib/paths.mjs';
|
|
23
|
+
import { machineDir } from '../lib/machine-dir.mjs';
|
|
24
24
|
|
|
25
25
|
/** `_install_registry._path()` — `$XDG_CONFIG_HOME/geneseed/installs.json`. */
|
|
26
26
|
function registryPath() {
|
|
27
|
-
|
|
28
|
-
return path.join(base, 'geneseed', 'installs.json');
|
|
27
|
+
return path.join(machineDir(), 'installs.json');
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
/**
|
|
@@ -43,29 +42,97 @@ export function isScratchRoot(root, registryFile) {
|
|
|
43
42
|
return within(resolvePath(root), tmp) && !within(resolvePath(registryFile), tmp);
|
|
44
43
|
}
|
|
45
44
|
|
|
45
|
+
/**
|
|
46
|
+
* The rows, or `null` when the file exists and cannot be trusted. Only a missing file is an empty
|
|
47
|
+
* registry: read as `[]`, a refused read made the next save write one root over every install.
|
|
48
|
+
*/
|
|
46
49
|
function registryLoad() {
|
|
50
|
+
let file;
|
|
51
|
+
try { file = registryPath(); } catch { return null; } // no home dir: nothing to read or to save over
|
|
47
52
|
try {
|
|
48
|
-
const data = parseJson(readFileSync(
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
const data = parseJson(readFileSync(file, 'utf8'));
|
|
54
|
+
if (Array.isArray(data)) return data.map(String);
|
|
55
|
+
throw new Error('not a list');
|
|
56
|
+
} catch (e) {
|
|
57
|
+
if (e.code === 'ENOENT') return [];
|
|
58
|
+
process.stderr.write(`[geneseed] could not read the install registry ${file}: ${e.message}\n`);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The rename, waited out while Windows refuses it. A process holding the just-written target (real-time
|
|
65
|
+
* scanning, by every sign) fails the replace with EPERM: measured at about 1 rename in 500 under
|
|
66
|
+
* load, gone within moments. Writing in place instead would give up the atomicity: a reader could
|
|
67
|
+
* see a torn file, load `[]`, and save only its own root over every other install. Bounded at about
|
|
68
|
+
* 400 ms. Not gated on the platform: elsewhere these codes are rare and the bound is the same.
|
|
69
|
+
*/
|
|
70
|
+
const RENAME_WAITS_MS = [10, 30, 90, 270];
|
|
71
|
+
const SHARING_ERRORS = new Set(['EPERM', 'EACCES', 'EBUSY']);
|
|
72
|
+
function renameOver(tmp, file) {
|
|
73
|
+
for (const wait of RENAME_WAITS_MS) {
|
|
74
|
+
try {
|
|
75
|
+
renameSync(tmp, file);
|
|
76
|
+
return;
|
|
77
|
+
} catch (e) {
|
|
78
|
+
if (!SHARING_ERRORS.has(e.code)) throw e;
|
|
79
|
+
pause(wait);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
renameSync(tmp, file);
|
|
51
83
|
}
|
|
52
84
|
|
|
85
|
+
/** A failed write must never break a deploy, and is never silent: stderr, since hooks speak on stdout. */
|
|
53
86
|
export function registrySave(items) {
|
|
87
|
+
const file = registryPath();
|
|
88
|
+
const tmp = `${file}.tmp`;
|
|
54
89
|
try {
|
|
55
|
-
const file = registryPath();
|
|
56
90
|
mkdirSync(path.dirname(file), { recursive: true });
|
|
57
|
-
const tmp = `${file}.tmp`;
|
|
58
91
|
// `jsonDumpsIndent` for the same reason as the manifest: these are absolute paths, and
|
|
59
92
|
// a machine whose username carries an accent writes one here.
|
|
60
93
|
writeText(tmp, `${jsonDumpsIndent(items)}\n`);
|
|
61
|
-
|
|
62
|
-
} catch {
|
|
94
|
+
renameOver(tmp, file);
|
|
95
|
+
} catch (e) {
|
|
96
|
+
try { rmSync(tmp, { force: true }); } catch { /* the report below is the one that matters */ }
|
|
97
|
+
process.stderr.write(`[geneseed] could not update the install registry ${file}: ${e.message}\n`);
|
|
98
|
+
}
|
|
63
99
|
}
|
|
64
100
|
|
|
101
|
+
const pause = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
102
|
+
const LOCK_WAITS_MS = [10, 30, 90, 270, 500, 1000];
|
|
103
|
+
const LOCK_STALE_MS = 10_000;
|
|
104
|
+
|
|
65
105
|
/**
|
|
66
|
-
* `
|
|
106
|
+
* `fn` under a directory lock, or without it after about 2 s. An atomic rename stops a torn file,
|
|
107
|
+
* not a lost update: two records both load the list, and the later rename drops the other's root,
|
|
108
|
+
* which `rebuild-all` then never reaches. A crashed holder is outwaited by age. Past the bound
|
|
109
|
+
* `fn` runs anyway, reported, because a registry hiccup must never fail a build.
|
|
110
|
+
*/
|
|
111
|
+
function withRegistryLock(fn) {
|
|
112
|
+
const lock = `${registryPath()}.lock`;
|
|
113
|
+
mkdirSync(path.dirname(lock), { recursive: true });
|
|
114
|
+
let held = false;
|
|
115
|
+
for (const wait of LOCK_WAITS_MS) {
|
|
116
|
+
try {
|
|
117
|
+
mkdirSync(lock);
|
|
118
|
+
held = true;
|
|
119
|
+
break;
|
|
120
|
+
} catch (e) {
|
|
121
|
+
if (e.code !== 'EEXIST' && !SHARING_ERRORS.has(e.code)) throw e;
|
|
122
|
+
try {
|
|
123
|
+
if (Date.now() - statSync(lock).mtimeMs > LOCK_STALE_MS) rmSync(lock, { recursive: true, force: true });
|
|
124
|
+
} catch { /* the holder just let go */ }
|
|
125
|
+
pause(wait);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (!held) process.stderr.write(`[geneseed] the install registry stayed locked: ${lock}\n`);
|
|
129
|
+
try { return fn(); } finally { if (held) rmSync(lock, { recursive: true, force: true }); }
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Idempotent, best-effort, and it must NEVER raise into a build.
|
|
67
134
|
*
|
|
68
|
-
* `realpathSync` rather than `path.resolve`, because
|
|
135
|
+
* `realpathSync` rather than `path.resolve`, because it returns the
|
|
69
136
|
* filesystem's own casing and follows links; `path.resolve` only makes a path absolute. The
|
|
70
137
|
* registry is compared byte-for-byte by `tests/golden.mjs` (XDG is redirected into the
|
|
71
138
|
* sandbox), so a differently-cased entry is a failing cell.
|
|
@@ -75,8 +142,11 @@ export function registryRecord(dir) {
|
|
|
75
142
|
let root;
|
|
76
143
|
try { root = realpathSync.native(dir); } catch { root = path.resolve(dir); }
|
|
77
144
|
if (isScratchRoot(root, registryPath())) return;
|
|
78
|
-
|
|
79
|
-
|
|
145
|
+
if (registryLoad()?.includes(root)) return; // the usual case takes no lock
|
|
146
|
+
withRegistryLock(() => {
|
|
147
|
+
const cur = registryLoad();
|
|
148
|
+
if (cur && !cur.includes(root)) registrySave([...cur, root]);
|
|
149
|
+
});
|
|
80
150
|
} catch { /* a registry hiccup must never fail a build */ }
|
|
81
151
|
}
|
|
82
152
|
|
|
@@ -85,24 +155,24 @@ export function registryRecord(dir) {
|
|
|
85
155
|
*
|
|
86
156
|
* The prune is a WRITE, and reproducing it matters: `installs.json` is compared byte-for-byte,
|
|
87
157
|
* so a read that failed to drop a dead row would leave the two implementations holding
|
|
88
|
-
* different registries. The snapshot is taken once on purpose
|
|
89
|
-
*
|
|
90
|
-
*
|
|
158
|
+
* different registries. The snapshot is taken once on purpose: comparing `kept` against a SECOND
|
|
159
|
+
* read could clobber a root a concurrent `record()` appended between the two. So the write takes
|
|
160
|
+
* the lock and adds what that second read holds and the snapshot did not.
|
|
91
161
|
*/
|
|
92
162
|
export function registryRoots() {
|
|
93
163
|
const original = registryLoad();
|
|
164
|
+
if (!original) return [];
|
|
94
165
|
const file = registryPath();
|
|
95
166
|
const out = [];
|
|
96
167
|
const kept = [];
|
|
97
168
|
const seen = new Set();
|
|
98
169
|
for (const s of original) {
|
|
99
|
-
// `
|
|
100
|
-
//
|
|
101
|
-
//
|
|
102
|
-
//
|
|
103
|
-
//
|
|
104
|
-
//
|
|
105
|
-
// registry cells seed native spellings; `uninstall`'s inventory prints the root.
|
|
170
|
+
// `toPlatformPath` around `expanduser` is where the NORMALISATION happens. `C:/x/other`
|
|
171
|
+
// becomes `C:\x\other` before it is compared, kept, returned and printed, so a registry
|
|
172
|
+
// entry spelled with forward slashes (routine: every tool that writes one from Git Bash)
|
|
173
|
+
// makes the file be rewritten and a backslash path printed, where a raw `expanduser`
|
|
174
|
+
// prints the entry verbatim and leaves installs.json alone. `rebuild-all`'s registry
|
|
175
|
+
// cells seed native spellings; `uninstall`'s inventory prints the root.
|
|
106
176
|
// `expanduser` now REFUSES a `~user` entry (js/hosts/hosts.mjs's docblock) instead of passing
|
|
107
177
|
// it through. This loop scans STORED registry rows, not a fresh CLI argument — a single
|
|
108
178
|
// bad row (hand-edited, or written before this refusal existed) must not abort the scan
|
|
@@ -120,7 +190,13 @@ export function registryRoots() {
|
|
|
120
190
|
}
|
|
121
191
|
}
|
|
122
192
|
if (kept.length !== original.length || kept.some((v, i) => v !== original[i])) {
|
|
123
|
-
|
|
193
|
+
try {
|
|
194
|
+
withRegistryLock(() => {
|
|
195
|
+
registrySave([...kept, ...(registryLoad() ?? []).filter((r) => !original.includes(r))]);
|
|
196
|
+
});
|
|
197
|
+
} catch (e) { // a lock that cannot be made must not fail the read; the next one prunes
|
|
198
|
+
process.stderr.write(`[geneseed] could not update the install registry ${file}: ${e.message}\n`);
|
|
199
|
+
}
|
|
124
200
|
}
|
|
125
201
|
return out;
|
|
126
202
|
}
|
package/js/inspect/scan.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The scanning primitives — what every doctor check reads the tree with.
|
|
3
3
|
*
|
|
4
4
|
* Split out of `doctor.mjs` because all three check modules need them and none of the three
|
|
5
5
|
* owns them. Nothing here decides anything: these walk, sort, strip and test, and the
|
|
@@ -23,10 +23,10 @@ import { mkdtempSync, readdirSync, rmSync } from 'node:fs';
|
|
|
23
23
|
export { isDir, isFile, has };
|
|
24
24
|
|
|
25
25
|
// --------------------------------------------------------------------------------------
|
|
26
|
-
//
|
|
26
|
+
// scanning primitives
|
|
27
27
|
// --------------------------------------------------------------------------------------
|
|
28
28
|
|
|
29
|
-
/** `
|
|
29
|
+
/** `TOKEN_RE` / `LINK_RE` / `ABS_LINK_RE`. `g` where every match is collected. */
|
|
30
30
|
// Must stay in step with `js/build/render.mjs`'s TOKEN_RE: a token the renderer substitutes but this
|
|
31
31
|
// scan cannot see is an unresolved-token gate that silently stops gating. Digits are legal after
|
|
32
32
|
// the first character for `DOC_<PACK>_<n>`; a leading digit is still not a token.
|
|
@@ -35,7 +35,7 @@ export const LINK_RE = /\]\((?!https?:\/\/|#)([^)]+)\)/g;
|
|
|
35
35
|
export const ABS_LINK_RE = /^([A-Za-z]:[\\/]|\/|~)/;
|
|
36
36
|
const COMMENT_RE = /<!--[\s\S]*?-->/g;
|
|
37
37
|
|
|
38
|
-
/**
|
|
38
|
+
/** Fenced blocks, then HTML comments, then inline code, in that order. */
|
|
39
39
|
export function stripCode(text) {
|
|
40
40
|
return text.replace(FENCE_RE, '').replace(COMMENT_RE, '').replace(INLINE_CODE_RE, '');
|
|
41
41
|
}
|
|
@@ -79,7 +79,7 @@ export const sortedUnique = (xs) => [...new Set(xs)].sort((a, b) => (a < b ? -1
|
|
|
79
79
|
/** `sorted(probs)` — SORTED, not deduped, which is what `_ran` fills a group with. */
|
|
80
80
|
export const sortedProblems = (xs) => [...xs].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
81
81
|
|
|
82
|
-
/**
|
|
82
|
+
/** Spec stems under `src/<folder>`, minus `_`-scaffolds. */
|
|
83
83
|
export function srcStems(folder) {
|
|
84
84
|
const d = path.join(SRC, folder);
|
|
85
85
|
if (!isDir(d)) return new Set();
|