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/lib/text.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* String primitives — measuring, padding, stripping, decoding and reading an integer.
|
|
3
3
|
*
|
|
4
|
-
* These are definitions, not an adaptation of somebody else's
|
|
5
|
-
*
|
|
6
|
-
* default — the warning the retired `py` prefix used to carry now lives in each docblock.
|
|
4
|
+
* These are definitions, not an adaptation of somebody else's, and NONE of these is the
|
|
5
|
+
* Node default — each docblock says why.
|
|
7
6
|
* Every function here is a place the Node default DIVERGES from the answer this tool needs:
|
|
8
7
|
* `codePointLength` counts code points where `.length` counts units, `WHITESPACE` is a wider
|
|
9
8
|
* set than `String.trim`'s, `parseIntStrict` accepts what `Number()` does not and rejects what
|
|
@@ -52,8 +51,7 @@ export const padEndToWidth = (s, width) => s + ' '.repeat(Math.max(0, width - co
|
|
|
52
51
|
* raw environment value do it — `js/ui/cli.mjs`'s `helpWidth` and `js/web/activity.mjs` wrap
|
|
53
52
|
* the argument in `stripWhitespace` first.
|
|
54
53
|
*
|
|
55
|
-
*
|
|
56
|
-
* a corpus, never a cell (P5c) — so what reaches it now is only its callers' gates:
|
|
54
|
+
* What reaches it is its callers' gates:
|
|
57
55
|
* `tests/unit/wizard.test.mjs`'s choice corpus and `tests/unit/web_daemon.test.mjs`'s
|
|
58
56
|
* non-integer port.
|
|
59
57
|
*/
|
|
@@ -116,9 +114,8 @@ export function stripWhitespace(s) {
|
|
|
116
114
|
/**
|
|
117
115
|
* `str.lstrip()` / `str.rstrip()` — the ONE-SIDED halves, over the same `WHITESPACE`.
|
|
118
116
|
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* `lines[pred].rstrip().endswith(",")`). They are here rather than in `js/build/themes.mjs` for the
|
|
117
|
+
* The theme-key insertion uses all three spellings within four lines. They are here rather
|
|
118
|
+
* than in `js/build/themes.mjs` for the
|
|
122
119
|
* reason this file exists at all: `js/hosts/settings.mjs` already carries a private second copy of
|
|
123
120
|
* the character class, and a THIRD one — in the module that decides where a comma goes in a
|
|
124
121
|
* committed theme file — is how the three drift apart. One owner of the set, three views of it.
|
|
@@ -136,8 +133,8 @@ export function stripWhitespaceEnd(s) {
|
|
|
136
133
|
*
|
|
137
134
|
* The whole difference is what happens to a sequence that is not an escape.
|
|
138
135
|
* `decodeURIComponent('a%ZZ')` throws a `URIError`, and so does a trailing bare `%`; the
|
|
139
|
-
* web shell would answer both as a 500 where
|
|
140
|
-
* literal text. `unquote` leaves them alone: CPython builds a table of every two-hex-digit
|
|
136
|
+
* web shell would answer both as a 500 where a 404 naming the
|
|
137
|
+
* literal text is wanted. `unquote` leaves them alone: CPython builds a table of every two-hex-digit
|
|
141
138
|
* pair in both cases and treats a `KeyError` as "this was not an escape", emitting `%` and
|
|
142
139
|
* the rest of the fragment verbatim.
|
|
143
140
|
*
|
|
@@ -150,8 +147,7 @@ export function stripWhitespaceEnd(s) {
|
|
|
150
147
|
* `Buffer.toString('utf-8')` substitutes U+FFFD for an undecodable sequence, which is
|
|
151
148
|
* `errors='replace'`. The two decoders can disagree on HOW MANY replacement characters a
|
|
152
149
|
* truncated multi-byte sequence yields — Python's maximal-subpart rule against WHATWG's —
|
|
153
|
-
* and
|
|
154
|
-
* measures it now.
|
|
150
|
+
* and nothing measures it.
|
|
155
151
|
*/
|
|
156
152
|
const HEX_PAIR = /^[0-9A-Fa-f]{2}$/;
|
|
157
153
|
|
package/js/lib/udiff.mjs
CHANGED
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
* WHY A HAND-WRITTEN MATCHER RATHER THAN A LIBRARY. The diff is the ENTIRE user-visible
|
|
5
5
|
* payload of `geneseed diff`: the hunks in `--full` and in the exported improvements file
|
|
6
6
|
* are this file's output and nothing else's. A generic JS diff would produce a CORRECT diff
|
|
7
|
-
* and a DIFFERENT one,
|
|
8
|
-
*
|
|
9
|
-
* compares hunks, and only one; see `js/inspect/diff.mjs`). The alignment below IS the
|
|
7
|
+
* and a DIFFERENT one, so "also a valid diff" is not enough (only the `diff/--full-…` CLI
|
|
8
|
+
* cell compares hunks, and only one; see `js/inspect/diff.mjs`). The alignment below IS the
|
|
10
9
|
* specification of what this tool prints, and three of its choices are choices no other
|
|
11
10
|
* algorithm makes:
|
|
12
11
|
*
|
|
@@ -19,13 +18,10 @@
|
|
|
19
18
|
* `floor(len(b) / 100) + 1` times is deleted from the index and stops matching entirely.
|
|
20
19
|
* On this tool's own files — hundreds of lines, many of them blank — that fires
|
|
21
20
|
* constantly and changes the hunks. It is off by construction for anything shorter, so a
|
|
22
|
-
* small fixture cannot see it at all
|
|
23
|
-
* enough to trip it.
|
|
21
|
+
* small fixture cannot see it at all.
|
|
24
22
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* heuristic no one would invent from scratch. That history explains the shape; it does not
|
|
28
|
-
* govern it any more. The recording does, and the recording cannot be re-blessed.
|
|
23
|
+
* The rules above follow `difflib`, which is why the odd ones are odd — `autojunk` in
|
|
24
|
+
* particular is a heuristic no one would invent from scratch.
|
|
29
25
|
*
|
|
30
26
|
* No junk predicate is implemented: every call site is `opcodes(a, b)` with no `isjunk`, so
|
|
31
27
|
* the junk set is empty and its test is constant false. That deletes two of the four
|
|
@@ -38,7 +34,7 @@
|
|
|
38
34
|
* `SequenceMatcher.__chain_b` — b's element index, minus the popular elements.
|
|
39
35
|
*
|
|
40
36
|
* A `Map`, never an object: the elements are LINES, and a file whose first line is `0` would
|
|
41
|
-
* have its index hoisted to the front of an object literal
|
|
37
|
+
* have its index hoisted to the front of an object literal. Nothing here
|
|
42
38
|
* iterates `b2j`, so the hoist would be invisible until the day something did.
|
|
43
39
|
*/
|
|
44
40
|
function chainB(b) {
|
|
@@ -61,7 +57,7 @@ function chainB(b) {
|
|
|
61
57
|
/**
|
|
62
58
|
* `SequenceMatcher.find_longest_match`, with `isbjunk` constant False.
|
|
63
59
|
*
|
|
64
|
-
* `j2len` is a `Map` keyed by INTEGER j
|
|
60
|
+
* `j2len` is a `Map` keyed by INTEGER j. Nothing iterates it
|
|
65
61
|
* either, so the key type is only about lookup; a plain object would coerce every key to a
|
|
66
62
|
* string and work, and a Map says what the keys are.
|
|
67
63
|
*/
|
|
@@ -85,7 +81,7 @@ function findLongestMatch(a, b, b2j, alo, ahi, blo, bhi) {
|
|
|
85
81
|
}
|
|
86
82
|
// The two junk-free extension loops. The popular elements `chainB` dropped are NOT junk —
|
|
87
83
|
// `bjunk` stays empty — so a popular line adjacent to a match is still extended over here
|
|
88
|
-
// even though it could never have started one. That asymmetry is
|
|
84
|
+
// even though it could never have started one. That asymmetry is `difflib`'s.
|
|
89
85
|
while (besti > alo && bestj > blo && a[besti - 1] === b[bestj - 1]) {
|
|
90
86
|
besti -= 1; bestj -= 1; bestsize += 1;
|
|
91
87
|
}
|
|
@@ -103,7 +99,7 @@ function matchingBlocks(a, b, b2j) {
|
|
|
103
99
|
const queue = [[0, la, 0, lb]];
|
|
104
100
|
const blocks = [];
|
|
105
101
|
while (queue.length) {
|
|
106
|
-
// `queue.pop()` — LIFO, as
|
|
102
|
+
// `queue.pop()` — LIFO, as `difflib`. The order reaches the output through the sort
|
|
107
103
|
// below only when two blocks tie, which they cannot, so this is faithfulness rather
|
|
108
104
|
// than necessity.
|
|
109
105
|
const [alo, ahi, blo, bhi] = queue.pop();
|
|
@@ -157,7 +153,7 @@ function opcodes(a, b) {
|
|
|
157
153
|
/**
|
|
158
154
|
* `SequenceMatcher.get_grouped_opcodes` — the hunks, with `n` lines of context.
|
|
159
155
|
*
|
|
160
|
-
* Returns a list rather than a generator: the
|
|
156
|
+
* Returns a list rather than a generator: the caller is a `for` loop that consumes
|
|
161
157
|
* it once, and a lazy JS equivalent would buy nothing but a second shape to reason about.
|
|
162
158
|
*/
|
|
163
159
|
function groupedOpcodes(a, b, n = 3) {
|
|
@@ -203,7 +199,7 @@ function formatRangeUnified(start, stop) {
|
|
|
203
199
|
* `difflib.unified_diff` — the lines, WITHOUT trailing newlines when `lineterm` is `""`.
|
|
204
200
|
*
|
|
205
201
|
* Every call site in this port passes `lineterm=""` and feeds it `splitlines()` output, which
|
|
206
|
-
* is the form
|
|
202
|
+
* is the form `difflib`'s own callers use; the parameter is kept so the shape is the
|
|
207
203
|
* stdlib's rather than a specialisation that would have to be widened later.
|
|
208
204
|
*/
|
|
209
205
|
export function unifiedDiff(a, b, {
|
package/js/loop/catalog.mjs
CHANGED
|
@@ -16,16 +16,15 @@
|
|
|
16
16
|
* user's file, so the int/float distinction `parseJson` preserves has nowhere to matter.
|
|
17
17
|
*/
|
|
18
18
|
import { readdirSync } from 'node:fs';
|
|
19
|
-
import os from 'node:os';
|
|
20
19
|
import path from 'node:path';
|
|
21
20
|
import { readText, isFile, isDir } from '../lib/fs.mjs';
|
|
22
21
|
import { frontmatter } from '../hosts/memory-files.mjs';
|
|
23
22
|
import { SRC, stripAuthorNotes } from '../build/source.mjs';
|
|
24
23
|
import { checkGraph } from './graph.mjs';
|
|
24
|
+
import { machineDir } from '../lib/machine-dir.mjs';
|
|
25
25
|
|
|
26
26
|
export function userLoopsDir() {
|
|
27
|
-
|
|
28
|
-
return path.join(base, 'geneseed');
|
|
27
|
+
return machineDir();
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
const KEBAB = /^[a-z0-9][a-z0-9-]*$/;
|
package/js/loop/state.mjs
CHANGED
|
@@ -352,6 +352,12 @@ export function recordOutcome(state, bricks, outcome, { card = null, porcelain =
|
|
|
352
352
|
if (brick.effect === 'mutate' && !state.validated) {
|
|
353
353
|
throw new Error(`${from} modifies code: run \`geneseed loop score --declared\` before it, then record`);
|
|
354
354
|
}
|
|
355
|
+
// `pass` is mechanical: a check that did not run is not a check that passed, whatever the model
|
|
356
|
+
// concluded. Only `test` writes this list, as `<check>: <status>`, so the word counts only where
|
|
357
|
+
// the status sits: right after a colon, markdown marks allowed, and not as a runner's count
|
|
358
|
+
// (`skipped: 0`, `: skipped 0`).
|
|
359
|
+
const skipped = from === 'test' && outcome === 'pass' ? note.split('\n').find((l) => /:[\s*`_]*skipped\b(?!\s*\d)/i.test(l)) : null;
|
|
360
|
+
if (skipped) throw new Error(`test cannot report pass with a skipped check (${skipped.trim()}): run it, or report fail or error`);
|
|
355
361
|
const filteredPorcelain = porcelain === null ? null : filterPorcelain(porcelain);
|
|
356
362
|
if (brick.effect === 'read' && filteredPorcelain !== null && filteredPorcelain !== state.snapshot) {
|
|
357
363
|
return stop(state, `read-brick-wrote: ${from} changed the working tree`);
|
|
@@ -359,15 +365,19 @@ export function recordOutcome(state, bricks, outcome, { card = null, porcelain =
|
|
|
359
365
|
if (filteredPorcelain !== null) state.snapshot = filteredPorcelain;
|
|
360
366
|
if (card) state.card = card;
|
|
361
367
|
if (from === 'test') state.tests = outcome;
|
|
362
|
-
// A finding a brick needs to survive the unit (the ordered plan `plan` produced
|
|
363
|
-
//
|
|
364
|
-
//
|
|
365
|
-
//
|
|
368
|
+
// A finding a brick needs to survive the unit (the ordered plan `plan` produced) — pushed before
|
|
369
|
+
// the transition below, so it lands in `notes` even when this call closes the unit, re-splits,
|
|
370
|
+
// or stops the loop. `notes` is never reset with the unit (only the two filters below trim it,
|
|
371
|
+
// and only `exhaust`'s own push and `decideAwaiting` add to it otherwise), so it survives
|
|
366
372
|
// `resetUnit`/`finishUnit` — which a card does not: `resetUnit` clears it.
|
|
367
373
|
// A fresh verdict: `test`'s latest report supersedes its earlier ones, so a repair never reads
|
|
368
374
|
// findings about code that has since changed (stale traces broke 34 of 135 correct attempts
|
|
369
|
-
// in arXiv 2607.24604, fresh ones 4).
|
|
375
|
+
// in arXiv 2607.24604, fresh ones 4). `review`'s and `mutation-check`'s findings go once `apply`
|
|
376
|
+
// has acted on them: it reads them through `next`, so they leave when it records, never when it
|
|
377
|
+
// is entered.
|
|
378
|
+
// Every other brick's notes are a record and are kept.
|
|
370
379
|
if (from === 'test') state.notes = state.notes.filter((n) => !/^iteration \d+ \(test\): /.test(n));
|
|
380
|
+
if (from === 'apply') state.notes = state.notes.filter((n) => !/^iteration \d+ \((review|mutation-check)\): /.test(n));
|
|
371
381
|
if (note) state.notes.push(`iteration ${state.iteration} (${from}): ${note}`);
|
|
372
382
|
state.visited.push(from);
|
|
373
383
|
|
package/js/maintain/memory.mjs
CHANGED
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
*
|
|
14
14
|
* * THE STORE IS RESOLVED, NOT CONFIGURED. The endpoint is always `<target>/memory`,
|
|
15
15
|
* because a server has a target. A CLI has a cwd, so this takes the resolver every other
|
|
16
|
-
* terminal-side reader of the store already uses — `$GENESEED_MEMORY`, then
|
|
17
|
-
*
|
|
16
|
+
* terminal-side reader of the store already uses — `$GENESEED_MEMORY`, then
|
|
17
|
+
* `$GENESEED_HARNESS`, then a project install in the cwd, then the shared tier, then the
|
|
18
|
+
* OpenCode config store — with
|
|
19
|
+
* `--memory` as the explicit override, and the only way to a `memory/` no install owns.
|
|
18
20
|
* `status` prints the answer of that same resolver, so the two agree about which store
|
|
19
21
|
* is "the" store.
|
|
20
22
|
* * THE RESERVED-NAME CHECK IS CASE-INSENSITIVE, and the web endpoints use this one. On a
|
|
@@ -34,21 +36,16 @@
|
|
|
34
36
|
import { readdirSync, unlinkSync } from 'node:fs';
|
|
35
37
|
import path from 'node:path';
|
|
36
38
|
|
|
37
|
-
import { archiveFact, memoryDropIndex } from '../hosts/memory-files.mjs';
|
|
39
|
+
import { RESERVED_STEMS, archiveFact, memoryDropIndex } from '../hosts/memory-files.mjs';
|
|
40
|
+
import { recordOwnWrites } from '../hosts/store-watch.mjs';
|
|
38
41
|
import { resolveMemoryDir } from '../hosts/hosts.mjs';
|
|
39
42
|
import { printOut, printErr, isFile } from '../lib/fs.mjs';
|
|
40
43
|
|
|
41
|
-
/**
|
|
42
|
-
* The two names the store owns rather than holds: the index the agent reads at session
|
|
43
|
-
* start, and the file that documents the store. `api_memory_delete` refuses both.
|
|
44
|
-
*/
|
|
45
|
-
const RESERVED = ['memory', 'readme'];
|
|
46
|
-
|
|
47
44
|
/** Whether `name` is a fact this verb may act on — the endpoint's rule, plus the case fold. */
|
|
48
45
|
export function isFactName(name) {
|
|
49
46
|
return Boolean(name) && !name.includes('/') && !name.includes('\\')
|
|
50
47
|
&& ![...name].some((c) => c.charCodeAt(0) < 0x20 || c.charCodeAt(0) === 0x7f)
|
|
51
|
-
&& !
|
|
48
|
+
&& !RESERVED_STEMS.has(name.toLowerCase());
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
/**
|
|
@@ -73,11 +70,13 @@ export function memoryDelete(dir, name, purge = false) {
|
|
|
73
70
|
if (!isFactName(name)) return null;
|
|
74
71
|
const p = path.join(dir, `${name}.md`);
|
|
75
72
|
if (!isFile(p)) return null;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
return recordOwnWrites(path.dirname(dir), () => {
|
|
74
|
+
let dest = '';
|
|
75
|
+
if (purge) unlinkSync(p);
|
|
76
|
+
else dest = archiveFact(dir, name);
|
|
77
|
+
memoryDropIndex(dir, name);
|
|
78
|
+
return dest;
|
|
79
|
+
});
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
/** Unlink `archive/<name>.md`. True when a file went. The archive has no index to update. */
|
|
@@ -95,8 +94,8 @@ export function cmdMemory(args) {
|
|
|
95
94
|
if (dir === null) {
|
|
96
95
|
// The resolver answers null for "no store anywhere on the chain", which is also what an
|
|
97
96
|
// explicit `--memory` that is not a directory gives — so the message names both.
|
|
98
|
-
printErr('[memory] no memory store found. Pass --memory <dir>,
|
|
99
|
-
+ '
|
|
97
|
+
printErr('[memory] no memory store found. Pass --memory <dir>, or run this from a project '
|
|
98
|
+
+ 'install.\n');
|
|
100
99
|
return 1;
|
|
101
100
|
}
|
|
102
101
|
const where = args.archived ? path.join(dir, 'archive') : dir;
|
|
@@ -128,6 +127,7 @@ export function cmdMemory(args) {
|
|
|
128
127
|
printErr(`[memory] no such fact '${args.name}' in ${where}.\n`);
|
|
129
128
|
return 1;
|
|
130
129
|
}
|
|
130
|
+
printOut(`[memory] ${where}\n`);
|
|
131
131
|
printOut(done ? `[memory] archived ${args.name} -> ${done}\n` : `[memory] deleted ${args.name}.\n`);
|
|
132
132
|
return 0;
|
|
133
133
|
}
|
package/js/maintain/migrate.mjs
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `geneseed migrate` — move a machine from the git-checkout install shape to the npm one.
|
|
3
3
|
*
|
|
4
|
-
* P10d, AND IT IS NOT A PORT. Every other module here reproduces a Python original byte for
|
|
5
|
-
* byte; this verb is new behaviour on both sides, written twice in the same change so that
|
|
6
|
-
* the former Python CLI matrix — a CROSS-IMPLEMENTATION gate — had a reference side at all. A
|
|
7
|
-
* Node-only verb would have had nothing to compare against, and that suite's `test_every_entry_
|
|
8
|
-
* verb_is_a_real_harness_subcommand` plus `test_the_matrix_covers_every_verb_it_claims` would
|
|
9
|
-
* both have failed it.
|
|
10
|
-
*
|
|
11
4
|
* WHAT IT IS NOT: `rebuild-all`. That was the first answer and it was checked before being
|
|
12
5
|
* discarded, because the re-emit really is the same engine and is reused rather than rewritten
|
|
13
6
|
* here. Four behaviours differ, and each is a cell:
|
|
@@ -22,32 +15,25 @@
|
|
|
22
15
|
* install must not block the rest — and for a migration it is the half-migrated machine the
|
|
23
16
|
* whole verb exists to prevent.
|
|
24
17
|
*
|
|
25
|
-
* THE
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* was enough: an OpenCode-only machine wires no hooks at all, so its shape is permanently
|
|
29
|
-
* `none` and a shape-only trigger would re-emit it on every run forever; and reinstalling the
|
|
30
|
-
* old build flipped the shape back to `legacy` while the stamp still matched, which had to
|
|
31
|
-
* migrate again. With the old build gone the second case can no longer arise, but the shape
|
|
32
|
-
* read stays: it is what makes the verb idempotent rather than stamp-dependent. The stamp is
|
|
33
|
-
* written only on success.
|
|
18
|
+
* THE ONE TRIGGER IS THE STAMP: work is needed when `<GENESEED_HOME>/.migrated` does not name this
|
|
19
|
+
* ROOT, and the stamp is written only on success. That is what makes the verb idempotent, and it
|
|
20
|
+
* holds for an OpenCode-only machine too, which wires no hooks at all.
|
|
34
21
|
*/
|
|
35
|
-
import { copyFileSync, existsSync, mkdirSync,
|
|
22
|
+
import { copyFileSync, existsSync, mkdirSync, rmSync } from 'node:fs';
|
|
36
23
|
import path from 'node:path';
|
|
37
24
|
|
|
38
25
|
import { main as driverMain } from '../build/driver.mjs';
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
26
|
+
import { foldHost, foldSummary } from '../build/fold.mjs';
|
|
27
|
+
import { RETIRED_SKILL_IDS, ROOT, knownSkillIds, skillAliases } from '../build/source.mjs';
|
|
28
|
+
import { CLAUDE_STYLE, isCanonical, settingsFile } from '../hosts/hosts.mjs';
|
|
41
29
|
import {
|
|
42
30
|
claudeCfg, claudeReadManifest, EMIT_HOST_SCOPE, installState, installTargets,
|
|
43
|
-
|
|
31
|
+
readMaybe,
|
|
44
32
|
} from '../hosts/installs.mjs';
|
|
45
33
|
import { installProfile } from '../build/generate.mjs';
|
|
46
|
-
import {
|
|
47
|
-
autostartPaths, autostartStale, hookShimPath, migrateShape, shimHome,
|
|
48
|
-
} from '../hosts/shim.mjs';
|
|
49
|
-
import { loadJsonObject } from '../hosts/settings.mjs';
|
|
34
|
+
import { autostartPaths, autostartStale, hookShimPath, shimHome } from '../hosts/shim.mjs';
|
|
50
35
|
import { writeText, printOut, printErr } from '../lib/fs.mjs';
|
|
36
|
+
import { sharedPaths } from '../lib/machine-dir.mjs';
|
|
51
37
|
|
|
52
38
|
/** Every emit name the generator answers to — the set an unrecognised marker is NOT in. */
|
|
53
39
|
const KNOWN_EMITS = new Set(EMIT_HOST_SCOPE.keys());
|
|
@@ -57,7 +43,7 @@ const KNOWN_EMITS = new Set(EMIT_HOST_SCOPE.keys());
|
|
|
57
43
|
*
|
|
58
44
|
* Only the Claude-style hosts carry hook commands. OpenCode's hooks are a PLUGIN
|
|
59
45
|
* (`js/hosts/opencode.mjs` emits JS that runs in the host's own process and names neither the
|
|
60
|
-
* shim
|
|
46
|
+
* shim), so it has no settings file here and its whole migration is the re-emit —
|
|
61
47
|
* the same re-emit, in the same change, on every host, which is what the project's
|
|
62
48
|
* host-parity rule asks for.
|
|
63
49
|
*
|
|
@@ -79,29 +65,6 @@ export function hookSettingsFile(root, host, scope) {
|
|
|
79
65
|
return settingsFile(cfg, claudeReadManifest(cfg).managed);
|
|
80
66
|
}
|
|
81
67
|
|
|
82
|
-
/** Every hook command string in a settings file, or [] when it cannot be read or parsed. */
|
|
83
|
-
function hookCommandsOf(file) {
|
|
84
|
-
// `loadJsonObject` (JSONC), NOT `JSON.parse`. A hand-edited settings.json with comments and a
|
|
85
|
-
// trailing comma is the one shape no machine in this project writes, and strict JSON rejects it —
|
|
86
|
-
// which would classify a wired install as `none` and make `migrate` skip the machine
|
|
87
|
-
// silently. `mergeClaudeSettings` already reads through comments for exactly this reason.
|
|
88
|
-
// Found by the JSONC corpus fixture; a generated fixture would have hidden it.
|
|
89
|
-
const { state, data: loaded } = loadJsonObject(file);
|
|
90
|
-
if (state !== 'ok') return [];
|
|
91
|
-
const hooks = loaded.hooks;
|
|
92
|
-
if (!hooks || typeof hooks !== 'object') return [];
|
|
93
|
-
const out = [];
|
|
94
|
-
for (const groups of Object.values(hooks)) {
|
|
95
|
-
if (!Array.isArray(groups)) continue;
|
|
96
|
-
for (const g of groups) {
|
|
97
|
-
for (const h of (g && Array.isArray(g.hooks) ? g.hooks : [])) {
|
|
98
|
-
if (h && typeof h.command === 'string') out.push(h.command);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return out;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
68
|
/** `<GENESEED_HOME>/.migrated` — the ROOT the last successful migration installed from. */
|
|
106
69
|
function stampPath() { return path.join(shimHome(), '.migrated'); }
|
|
107
70
|
|
|
@@ -117,7 +80,6 @@ function stashDir() { return path.join(shimHome(), '.migrate-backup'); }
|
|
|
117
80
|
*/
|
|
118
81
|
function migrateSurvey() {
|
|
119
82
|
const rows = [];
|
|
120
|
-
const commands = [];
|
|
121
83
|
const unrecognised = [];
|
|
122
84
|
for (const [host, scope, root] of installTargets()) {
|
|
123
85
|
if (installState(root, host, scope) !== 'active') continue;
|
|
@@ -128,22 +90,12 @@ function migrateSurvey() {
|
|
|
128
90
|
unrecognised.push({ host, scope, root, marker });
|
|
129
91
|
continue;
|
|
130
92
|
}
|
|
131
|
-
|
|
132
|
-
if (file) commands.push(...hookCommandsOf(file));
|
|
133
|
-
rows.push({ host, scope, root, marker, file });
|
|
93
|
+
rows.push({ host, scope, root, marker, file: hookSettingsFile(root, host, scope) });
|
|
134
94
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// THE TRIGGER IS THE STAMP, AND THE SHAPE IS REPORTED — the first draft had it the other
|
|
140
|
-
// way round and the ref-vs-ref self-check killed it in one run. `shape === 'legacy'` cannot
|
|
141
|
-
// be a trigger, because what "current" MEANS is "the shim body names the .mjs entry", and
|
|
142
|
-
// the Python implementation bakes python + harness.py by design (`_hook_runner_entry`). So
|
|
143
|
-
// a migration run from the reference can never reach `current`, its second run would
|
|
144
|
-
// re-emit forever, and the two implementations would diverge on idempotence by
|
|
145
|
-
// construction. The stamp is a value both sides write and read identically.
|
|
146
|
-
return { rows, unrecognised, shape, stamped, needed: stamped !== ROOT };
|
|
95
|
+
// No home and no GENESEED_HOME: no stamp to read, so nothing says this machine has migrated.
|
|
96
|
+
let stamped = '';
|
|
97
|
+
try { stamped = (readMaybe(stampPath()) || '').trim(); } catch { /* the survey only reads */ }
|
|
98
|
+
return { rows, unrecognised, needed: stamped !== ROOT };
|
|
147
99
|
}
|
|
148
100
|
|
|
149
101
|
/** Hand-written login entries that still name some other checkout. Reported, never rewritten. */
|
|
@@ -156,12 +108,59 @@ function autostartFindings() {
|
|
|
156
108
|
return out;
|
|
157
109
|
}
|
|
158
110
|
|
|
111
|
+
/**
|
|
112
|
+
* What each global install's next emit would fold, stamped machine or not: the fold runs in every
|
|
113
|
+
* emit, so the stamp says nothing about it. Each host reads the tier as it stands, so two hosts
|
|
114
|
+
* holding the same new fact both count it here, and the second finds it a duplicate in the real run.
|
|
115
|
+
*/
|
|
116
|
+
function foldPreview(rows) {
|
|
117
|
+
let shared;
|
|
118
|
+
try { shared = sharedPaths(); } catch { return; } // no home: no tier to fold into
|
|
119
|
+
for (const { host, scope, root } of rows) {
|
|
120
|
+
if (scope !== 'global' || !isCanonical(root, host)) continue;
|
|
121
|
+
const report = foldHost({ host, cfgDir: root, shared, dryRun: true });
|
|
122
|
+
const summary = foldSummary(report);
|
|
123
|
+
printOut(summary ? `[migrate] would fold ${host}: ${summary}\n` : `[migrate] ${host}: nothing to fold\n`);
|
|
124
|
+
for (const f of report.failed) printOut(`[migrate] ${host}: the fold would stop at ${f}\n`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* M5 — files no manifest owns, so no emit will ever prune them: the root `AGENT.md` and the folder
|
|
130
|
+
* of a skill that no longer ships under its own name. An earlier build likely wrote them, but an
|
|
131
|
+
* alias is a plain word and a folder under it may be the user's own, so nothing claims which.
|
|
132
|
+
* REPORTED, never moved: they go aside on the user's word.
|
|
133
|
+
*
|
|
134
|
+
* The candidate names come from what git history already settled and the source still records —
|
|
135
|
+
* `RETIRED_SKILL_IDS` and the `aliases:` markers — because the CLI may not spawn `git`. Each
|
|
136
|
+
* candidate is checked before it is listed: a live skill is never an orphan (`teach` is live,
|
|
137
|
+
* `quiz` is its alias), and a path the manifest owns is not one either — the next emit prunes it.
|
|
138
|
+
*/
|
|
139
|
+
export function orphanFindings(cfg, owned, { live = knownSkillIds(), aliases = skillAliases() } = {}) {
|
|
140
|
+
const owns = (rel) => owned.some((o) => o === rel || o.startsWith(`${rel}/`));
|
|
141
|
+
const names = [...new Set([...aliases.keys(), ...Object.keys(RETIRED_SKILL_IDS)])].filter((n) => !live.includes(n));
|
|
142
|
+
return ['AGENT.md', ...names.map((n) => `skills/${n}`)]
|
|
143
|
+
.filter((rel) => !owns(rel) && existsSync(path.join(cfg, rel)))
|
|
144
|
+
.map((rel) => path.join(cfg, rel));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** The `--dry-run` half of M5: one line per orphan on each global Claude-style install. */
|
|
148
|
+
function orphanPreview(rows) {
|
|
149
|
+
for (const { host, scope, root } of rows) {
|
|
150
|
+
if (scope !== 'global' || !CLAUDE_STYLE.includes(host) || !isCanonical(root, host)) continue;
|
|
151
|
+
const owned = claudeReadManifest(root).owned;
|
|
152
|
+
for (const p of orphanFindings(root, Array.isArray(owned) ? owned : [])) {
|
|
153
|
+
printOut(`[migrate] orphan: ${p} (no manifest owns it; an earlier build may have written it, or it may be yours). Nothing moves it: if it is not yours, move it by hand.\n`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
159
158
|
/** A stash key that cannot collide across drives, and is a legal file name on both platforms. */
|
|
160
159
|
const stashKey = (p) => p.replace(/[\\/:]/g, '_');
|
|
161
160
|
|
|
162
161
|
export function cmdMigrate(args = {}) {
|
|
163
162
|
const dryRun = Boolean(args.dryRun);
|
|
164
|
-
const { rows, unrecognised,
|
|
163
|
+
const { rows, unrecognised, needed } = migrateSurvey();
|
|
165
164
|
|
|
166
165
|
if (unrecognised.length) {
|
|
167
166
|
// Refuse the WHOLE run. A migration that skipped the row it did not understand and
|
|
@@ -180,12 +179,14 @@ export function cmdMigrate(args = {}) {
|
|
|
180
179
|
return 0;
|
|
181
180
|
}
|
|
182
181
|
|
|
182
|
+
if (dryRun) { foldPreview(rows); orphanPreview(rows); }
|
|
183
|
+
|
|
183
184
|
if (!needed) {
|
|
184
185
|
printOut(`[migrate] already on the npm shape (${rows.length} install(s)); nothing to do.\n`);
|
|
185
186
|
return 0;
|
|
186
187
|
}
|
|
187
188
|
|
|
188
|
-
printOut(`[migrate] ${rows.length} install(s)
|
|
189
|
+
printOut(`[migrate] ${rows.length} install(s) to migrate.\n`);
|
|
189
190
|
if (dryRun) {
|
|
190
191
|
for (const r of rows) {
|
|
191
192
|
printOut(`[migrate] would re-emit ${r.host}:${r.scope} (${r.root})\n`);
|
|
@@ -198,7 +199,15 @@ export function cmdMigrate(args = {}) {
|
|
|
198
199
|
}
|
|
199
200
|
|
|
200
201
|
// Step 2 — stash every file the re-emit can touch, so step 4 can put it all back.
|
|
201
|
-
|
|
202
|
+
// Refused before the first write: with no home and no GENESEED_HOME there is nowhere to stage it.
|
|
203
|
+
let stash;
|
|
204
|
+
try {
|
|
205
|
+
stash = stashDir();
|
|
206
|
+
} catch {
|
|
207
|
+
printErr('[migrate] REFUSED — no home directory, so there is nowhere to stage a backup.\n');
|
|
208
|
+
printErr('[migrate] Nothing was changed. Set GENESEED_HOME, then re-run.\n');
|
|
209
|
+
return 3;
|
|
210
|
+
}
|
|
202
211
|
const saved = [];
|
|
203
212
|
try {
|
|
204
213
|
rmSync(stash, { recursive: true, force: true });
|
|
@@ -228,22 +237,8 @@ export function cmdMigrate(args = {}) {
|
|
|
228
237
|
// `process 5` among them) and dropped `--config-dir`, so a global found through
|
|
229
238
|
// `CLAUDE_CONFIG_DIR`/`OPENCODE_CONFIG_DIR` re-emitted into the DEFAULT dir instead.
|
|
230
239
|
//
|
|
231
|
-
// A LEGACY CARRIER IS SKIPPED, NOT ROLLED BACK — the one exception to Step 4's ALL OR
|
|
232
|
-
// NOTHING, same reasoning as `rebuild-all` (`js/build/generate.mjs`): `installProfile` would
|
|
233
|
-
// read a pre-comms carrier exactly as written now (`comms` missing, `process 7`/`process 8`
|
|
234
|
-
// unaddressed) and `driverMain` would write that back PERMANENTLY — the fresh carrier carries
|
|
235
|
-
// no `process 8` text, so nothing could ever catch it again. Rolling back everything else on
|
|
236
|
-
// the machine over an install that merely needs `geneseed setup` would be a worse outcome
|
|
237
|
-
// than leaving it as it was found.
|
|
238
|
-
const skipped = [];
|
|
239
240
|
for (const r of rows) {
|
|
240
241
|
const label = `${r.host}:${r.scope} (${r.root})`;
|
|
241
|
-
if (legacyProcessCarrierOfDir(r.root, r.host)) {
|
|
242
|
-
skipped.push(label);
|
|
243
|
-
printOut(`[migrate] SKIPPED ${label}: pre-comms carrier (names 'process 8') — `
|
|
244
|
-
+ 'run `geneseed setup` for it.\n');
|
|
245
|
-
continue;
|
|
246
|
-
}
|
|
247
242
|
const { emit, theme, argv } = installProfile(r.host, r.scope, r.root,
|
|
248
243
|
(n) => printErr(`[migrate] ${label}: ${n}\n`));
|
|
249
244
|
printOut(`[migrate] re-emitting ${label}: theme=${theme} emit=${emit}\n`);
|
|
@@ -254,7 +249,8 @@ export function cmdMigrate(args = {}) {
|
|
|
254
249
|
// must not, or the machine is left half on each shape.
|
|
255
250
|
printErr(`[migrate] FAILED ${label} (exit ${rc}) — rolling back.\n`);
|
|
256
251
|
restore();
|
|
257
|
-
printErr(`[migrate] rolled back ${saved.length} file(s); the
|
|
252
|
+
printErr(`[migrate] rolled back ${saved.length} file(s); the wiring is as it was. `
|
|
253
|
+
+ 'What an earlier row folded stays in the shared tier.\n');
|
|
258
254
|
return 1;
|
|
259
255
|
}
|
|
260
256
|
}
|
|
@@ -265,13 +261,7 @@ export function cmdMigrate(args = {}) {
|
|
|
265
261
|
writeText(stampPath(), `${ROOT}\n`);
|
|
266
262
|
} catch { /* an unwritable stamp costs a redundant re-emit next run, never correctness */ }
|
|
267
263
|
|
|
268
|
-
|
|
269
|
-
if (skipped.length) {
|
|
270
|
-
printOut(`[migrate] migrated ${migrated} install(s), skipped ${skipped.length}: `
|
|
271
|
-
+ `${skipped.join(', ')}.\n`);
|
|
272
|
-
} else {
|
|
273
|
-
printOut(`[migrate] migrated ${rows.length} install(s).\n`);
|
|
274
|
-
}
|
|
264
|
+
printOut(`[migrate] migrated ${rows.length} install(s).\n`);
|
|
275
265
|
|
|
276
266
|
// Step 5 — what could NOT be fixed automatically. Reported, never rewritten: nothing in
|
|
277
267
|
// this repository has ever written an autostart entry, so migrate does not own the file.
|