geneseed 5.0.0 → 5.0.3
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 +70 -0
- package/README.md +1 -1
- package/SHIPPED.md +1 -1
- package/adapters/claude-code/README.md +6 -4
- package/adapters/opencode/HOW-OPENCODE-LOADS.md +3 -0
- package/adapters/opencode/plugins/geneseed-context.js +13 -2
- package/adapters/opencode/plugins/geneseed-guard.js +595 -74
- package/adapters/opencode/plugins/geneseed-learn.js +1 -1
- package/bin/geneseed-hook.mjs +21 -7
- package/docs/PRD.md +1 -1
- package/docs/concepts/enforcement-table.md +22 -3
- package/docs/concepts/exclusions.md +48 -2
- package/docs/concepts/foreman-mode.md +19 -4
- package/docs/concepts/hook-gates.md +1 -1
- package/docs/concepts/hooks.md +53 -12
- package/docs/concepts/host-matrix.md +4 -3
- package/docs/concepts/hosts.md +1 -1
- package/docs/concepts/kits.md +18 -0
- package/docs/concepts/shared-tier.md +5 -5
- package/docs/concepts/skills.md +1 -1
- package/docs/extending.md +3 -1
- package/docs/guides/autostart.md +27 -3
- package/docs/guides/choose-your-setup.md +1 -1
- package/docs/guides/migrate.md +5 -3
- package/docs/guides/uninstall.md +1 -1
- package/docs/guides/upgrade-to-5.md +6 -4
- package/docs/reference/plugin-context.md +1 -1
- package/docs/reference/plugin-guard.md +24 -5
- package/docs/reference/troubleshoot-doctor.md +2 -2
- package/docs/understand/a-day.md +9 -5
- package/docs/web-ui.md +78 -20
- package/harness.config.json +1 -1
- package/js/README.md +3 -2
- package/js/build/emit-claude.mjs +9 -1
- package/js/build/emit-opencode.mjs +2 -1
- package/js/build/fold.mjs +7 -7
- package/js/build/rule-decide.mjs +273 -0
- package/js/build/source.mjs +9 -3
- package/js/cli-table.json +122 -2
- package/js/hosts/geneseed-dir.mjs +1 -1
- package/js/hosts/hooks-context.mjs +9 -7
- package/js/hosts/hooks-done.mjs +3 -1
- package/js/hosts/hooks-learn.mjs +1 -1
- package/js/hosts/hooks-prims.mjs +270 -0
- package/js/hosts/hooks.mjs +409 -151
- package/js/hosts/hosts.mjs +22 -0
- package/js/hosts/installs.mjs +13 -9
- package/js/hosts/memory-files.mjs +2 -2
- package/js/hosts/settings.mjs +123 -23
- package/js/hosts/shim.mjs +155 -7
- package/js/hosts/store-watch.mjs +41 -14
- package/js/inspect/diff.mjs +2 -1
- package/js/inspect/inventory.mjs +1 -0
- package/js/inspect/registry.mjs +4 -2
- package/js/inspect/validate.mjs +1 -1
- package/js/lib/paths.mjs +13 -0
- package/js/maintain/migrate.mjs +60 -22
- package/js/maintain/uninstall.mjs +5 -1
- package/js/web/actions.mjs +17 -1
- package/js/web/api.mjs +22 -16
- package/js/web/handler.mjs +2 -0
- package/js/web/routes.mjs +9 -4
- package/js/web/update-check.mjs +2 -2
- package/js/web/user-files.mjs +38 -11
- package/package.json +1 -1
- package/registry.json +21 -0
- package/src/AGENT.md.tmpl +17 -21
- package/src/agents/_self-improvement.md +7 -6
- package/src/agents/developer.md +3 -2
- package/src/agents/docker-expert.md +1 -0
- package/src/agents/memory-curator.md +3 -2
- package/src/doctrines/process.md +24 -19
- package/src/kits/ci-pipelines/rules.md +10 -0
- package/src/kits/ci-pipelines.json +14 -0
- package/src/kits/docker/rules.md +11 -0
- package/src/kits/docker.json +12 -0
- package/src/memory/README.md +5 -4
- package/src/modes/foreman.md +23 -10
- package/src/notebook/README.md +1 -1
- package/src/skills/_self-improvement.md +12 -9
- package/src/skills/compose-ops.md +58 -0
- package/src/skills/gitlab-ci.md +51 -0
- package/src/skills/jenkins-pipeline.md +56 -0
- package/src/skills/pipeline.md +2 -2
- package/src/skills/rule/approve.md +11 -5
- package/src/skills/rule.md +26 -19
- package/src/skills/skill-forge.md +24 -6
- package/themes/_TEMPLATE.json +5 -2
- package/themes/biker.json +5 -2
- package/themes/commentator.json +5 -2
- package/themes/cyberpunk.json +5 -2
- package/themes/gamer.json +5 -2
- package/themes/imperial.json +5 -2
- package/themes/joker.json +5 -2
- package/themes/marvin.json +5 -2
- package/themes/mean.json +5 -2
- package/themes/military.json +5 -2
- package/themes/neutral.json +5 -2
- package/themes/pirate.json +5 -2
- package/themes/sports.json +5 -2
- package/themes/verstappen.json +5 -2
- package/themes/wizard.json +5 -2
- package/web/dist/assets/Activity-Ck_Xffpo.js +1 -0
- package/web/dist/assets/ActivityDetail-CBxVS4mU.js +1 -0
- package/web/dist/assets/{Bonsai-B_y20b3i.js → Bonsai-BlOwsvW6.js} +1 -1
- package/web/dist/assets/{CopyButton-CHQte7Ap.js → CopyButton-DFMOIGbe.js} +1 -1
- package/web/dist/assets/Dashboard-BUdUTjbB.js +2 -0
- package/web/dist/assets/{Docs-Dgv_MWfT.js → Docs-D_2Jt6gU.js} +3 -3
- package/web/dist/assets/{GreenhouseView-CSzTMSl_.js → GreenhouseView-WalcX5bp.js} +1 -1
- package/web/dist/assets/Installs-UGiPDMDt.js +3 -0
- package/web/dist/assets/{JournalView-CvRk1-m5.js → JournalView-CZtXQz-v.js} +1 -1
- package/web/dist/assets/Kits-XQHsazCN.js +1 -0
- package/web/dist/assets/Laws-B6A55S-2.js +4 -0
- package/web/dist/assets/Library-D7L0Wdbh.js +3 -0
- package/web/dist/assets/Loops-C0loS73u.js +2 -0
- package/web/dist/assets/{OperatorHudView-DuGz_sTk.js → OperatorHudView-CeDw5qMB.js} +1 -1
- package/web/dist/assets/Personal-PVmGA2-M.js +2 -0
- package/web/dist/assets/{RailCats-AW92uhsX.js → RailCats-BGZnJ6fa.js} +1 -1
- package/web/dist/assets/Settings-DWuxwh4i.js +1 -0
- package/web/dist/assets/Tabs-d2RIRAKT.js +1 -0
- package/web/dist/assets/api-BMFDSXoB.js +1 -0
- package/web/dist/assets/index-BEI5ugYQ.css +1 -0
- package/web/dist/assets/index-BNttaGQb.js +6 -0
- package/web/dist/index.html +3 -3
- package/web/dist/assets/Activity-D8G4eClY.js +0 -1
- package/web/dist/assets/ActivityDetail-BtOBYk3M.js +0 -1
- package/web/dist/assets/Dashboard-B8uXeJZ_.js +0 -2
- package/web/dist/assets/Installs-BDk9lqBI.js +0 -3
- package/web/dist/assets/Kits-CoITzxWM.js +0 -1
- package/web/dist/assets/Laws-Ctf5r9rE.js +0 -3
- package/web/dist/assets/Library-DNwHYVXt.js +0 -3
- package/web/dist/assets/Loops-S85PMQ8m.js +0 -2
- package/web/dist/assets/Personal-afJNwvRS.js +0 -2
- package/web/dist/assets/Settings-CGDFz-6j.js +0 -1
- package/web/dist/assets/Tabs-1qLrnqmn.js +0 -1
- package/web/dist/assets/api-C46vAuqp.js +0 -1
- package/web/dist/assets/index-COTd4TRZ.js +0 -3
- package/web/dist/assets/index-CtorA7uK.css +0 -1
package/js/hosts/store-watch.mjs
CHANGED
|
@@ -7,16 +7,22 @@
|
|
|
7
7
|
* `context` has answered, once per session, and `learn` compares on Stop. Both are stats, no reads.
|
|
8
8
|
*
|
|
9
9
|
* WHAT COUNTS AS APPROVED, per host. Claude and OpenClaude: a Write, Edit or NotebookEdit the
|
|
10
|
-
* transcript shows ran
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* transcript shows ran: a rule write runs only past the host's prompt, and a memory write is the
|
|
11
|
+
* agent's own to make (owner decision, 2026-11-08). The transcript is read only when a file changed,
|
|
12
|
+
* which keeps the common Stop to the stats. Bob has no transcript, so every change there is
|
|
13
|
+
* reported, a free memory write included. With process 1 excluded (`ruleStore: false`, the hook's
|
|
14
|
+
* `--no-rule-store`) a rule write runs with no prompt, so a rule file is never counted as approved and
|
|
15
|
+
* the report still shows it; memory keeps its excuse. OpenCode has this logic in the guard plugin, with the
|
|
16
|
+
* baseline in memory and approval from `tool.execute.after`. A memory write by shell is reported on
|
|
17
|
+
* every host: that, and the web console, is how the user sees what the agent chose to remember.
|
|
14
18
|
*
|
|
15
19
|
* GENESEED'S OWN WRITES. `learn`, a memory removal and the fold run inside `recordOwnWrites`, which
|
|
16
20
|
* snapshots the store around the run and logs what moved to `memory/.own-writes.json`, as an exact
|
|
17
21
|
* size and mtime. A change matching the log is not reported. Limits: a write by anything else during
|
|
18
|
-
* that window is excused too, and the log is a plain file an agent could edit.
|
|
19
|
-
*
|
|
22
|
+
* that window is excused too, and the log is a plain file an agent could edit. Nothing the web
|
|
23
|
+
* console writes is logged, its decisions on the draft included: its token is readable by anything
|
|
24
|
+
* on the machine, so a POST proves no click, and logging one would let an agent hide a write. So a
|
|
25
|
+
* real click reads as a change, and the line says that may be what it is.
|
|
20
26
|
*
|
|
21
27
|
* WHAT IT CANNOT TELL. Approval is per session, and the tier is shared: another session's approved
|
|
22
28
|
* write reads as a change here, so the line says so rather than call it unapproved. A Claude
|
|
@@ -34,6 +40,7 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, unlinkSync,
|
|
|
34
40
|
import path from 'node:path';
|
|
35
41
|
|
|
36
42
|
import { machineDir } from '../lib/machine-dir.mjs';
|
|
43
|
+
import { gitRootOf } from './gitref.mjs';
|
|
37
44
|
import { normcase } from '../lib/paths.mjs';
|
|
38
45
|
import { sovereignBypass } from './hosts.mjs';
|
|
39
46
|
|
|
@@ -42,13 +49,15 @@ const OWN_LOG = '.own-writes.json';
|
|
|
42
49
|
const OWN_LOG_CAP = 2000;
|
|
43
50
|
const STALE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
44
51
|
const NAMES_SHOWN = 5;
|
|
52
|
+
// The coined rule-file names, at the end of a `normcase`d path (lower case on Windows).
|
|
53
|
+
const RULE_FILE_RE = /[\\/]user-rules(?:\.draft)?\.md$/i;
|
|
45
54
|
|
|
46
55
|
/** The store files under one home, as `path -> "size:mtime"`. The guard's `storeScan` is its twin. */
|
|
47
56
|
export function storeScan(home, found = {}) {
|
|
48
57
|
const stamp = (f) => {
|
|
49
58
|
try { const s = statSync(f); if (s.isFile()) found[f] = `${s.size}:${Math.trunc(s.mtimeMs)}`; } catch { /* absent */ }
|
|
50
59
|
};
|
|
51
|
-
for (const n of ['user-rules.md', 'PROFILE.md', 'geneseed-wiki.jsonc', 'wiki.jsonc', 'wiki.json']) stamp(path.join(home, n));
|
|
60
|
+
for (const n of ['user-rules.md', 'user-rules.draft.md', 'PROFILE.md', 'geneseed-wiki.jsonc', 'wiki.jsonc', 'wiki.json']) stamp(path.join(home, n));
|
|
52
61
|
const walk = (dir) => {
|
|
53
62
|
let items = [];
|
|
54
63
|
try { items = readdirSync(dir, { withFileTypes: true }); } catch { return; }
|
|
@@ -62,7 +71,21 @@ export function storeScan(home, found = {}) {
|
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
const homesOf = (root) => [...new Set([root, machineDir()])];
|
|
65
|
-
const
|
|
74
|
+
const stampOf = (f, found) => {
|
|
75
|
+
try { const s = statSync(f); if (s.isFile()) found[f] = `${s.size}:${Math.trunc(s.mtimeMs)}`; } catch { /* absent */ }
|
|
76
|
+
return found;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* The project layer's rule files, which the context hook loads from the session's repository: its git
|
|
80
|
+
* root, else `cwd`. Only the two rule names: a repo's own `memory/` folder is not a store.
|
|
81
|
+
*/
|
|
82
|
+
function projectRules(cwd, found) {
|
|
83
|
+
if (typeof cwd !== 'string' || !cwd) return found;
|
|
84
|
+
const top = gitRootOf(cwd) ?? path.resolve(cwd);
|
|
85
|
+
for (const n of ['user-rules.md', 'user-rules.draft.md']) stampOf(path.join(top, n), found);
|
|
86
|
+
return found;
|
|
87
|
+
}
|
|
88
|
+
const scanAll = (root, cwd = null) => projectRules(cwd, homesOf(root).reduce((found, h) => storeScan(h, found), {}));
|
|
66
89
|
const stateFile = (root, sid) => path.join(root, STATE_DIR, `${String(sid).replace(/[^\w.-]/g, '_').slice(0, 120)}.json`);
|
|
67
90
|
const readJson = (f) => { try { return JSON.parse(readFileSync(f, 'utf8')); } catch { return null; } };
|
|
68
91
|
|
|
@@ -76,12 +99,12 @@ function saveBaseline(root, sid, stamps) {
|
|
|
76
99
|
* The session's baseline, written once. SessionStart fires again on resume and compact: keeping the
|
|
77
100
|
* first one means those cannot launder a change made before them. Old sessions' files are dropped.
|
|
78
101
|
*/
|
|
79
|
-
export function writeBaseline(root, sid) {
|
|
102
|
+
export function writeBaseline(root, sid, cwd = null) {
|
|
80
103
|
try {
|
|
81
104
|
if (typeof sid !== 'string' || !sid || sovereignBypass(root)) return;
|
|
82
105
|
const f = stateFile(root, sid);
|
|
83
106
|
if (existsSync(f)) return;
|
|
84
|
-
saveBaseline(root, sid, scanAll(root));
|
|
107
|
+
saveBaseline(root, sid, scanAll(root, cwd));
|
|
85
108
|
const dir = path.dirname(f);
|
|
86
109
|
for (const n of readdirSync(dir)) {
|
|
87
110
|
const old = path.join(dir, n);
|
|
@@ -146,7 +169,7 @@ export function storeLine(files) {
|
|
|
146
169
|
const shown = files.slice(0, NAMES_SHOWN).map((f) => f.split(/[\\/]/).slice(-2).join('/')).join(', ');
|
|
147
170
|
const more = files.length > NAMES_SHOWN ? ` (+${files.length - NAMES_SHOWN} more)` : '';
|
|
148
171
|
return `Geneseed change report: ${files.length} rule or memory file${files.length === 1 ? '' : 's'} `
|
|
149
|
-
+ `changed outside this session's approved writes (another session may have made it): ${shown}${more}. `
|
|
172
|
+
+ `changed outside this session's approved writes (another session, or a decision of yours in the web console, may have made it): ${shown}${more}. `
|
|
150
173
|
+ 'This detects a change; it prevented nothing.';
|
|
151
174
|
}
|
|
152
175
|
|
|
@@ -169,18 +192,22 @@ export function lastStoreReport() {
|
|
|
169
192
|
/**
|
|
170
193
|
* Compare at a turn's end: the line to show, or null. Rolls the baseline, so a change is said once,
|
|
171
194
|
* and a session with no baseline (installed mid-session) starts one here. `transcript` is null on Bob.
|
|
195
|
+
* `ruleStore: false`: process 1 is off, so no rule write passed a prompt (the header says why).
|
|
172
196
|
*/
|
|
173
|
-
export function storeReport(root, sid, { transcript = null, cwd = null, host = 'claude' } = {}) {
|
|
197
|
+
export function storeReport(root, sid, { transcript = null, cwd = null, host = 'claude', ruleStore = true } = {}) {
|
|
174
198
|
try {
|
|
175
199
|
if (typeof sid !== 'string' || !sid) return null;
|
|
176
200
|
const before = readJson(stateFile(root, sid));
|
|
177
|
-
if (!before) { writeBaseline(root, sid); return null; }
|
|
178
|
-
|
|
201
|
+
if (!before) { writeBaseline(root, sid, cwd); return null; }
|
|
202
|
+
// Every file the baseline names is stamped again, so a session whose cwd moved still compares
|
|
203
|
+
// the project files it started with.
|
|
204
|
+
const now = Object.keys(before).reduce((found, p) => stampOf(p, found), scanAll(root, cwd));
|
|
179
205
|
const changed = changedFiles(before, now);
|
|
180
206
|
if (!changed.length) return null;
|
|
181
207
|
saveBaseline(root, sid, now);
|
|
182
208
|
const own = homesOf(root).reduce((log, h) => ({ ...log, ...readJson(path.join(h, 'memory', OWN_LOG)) }), {});
|
|
183
209
|
const approved = typeof transcript === 'string' ? approvedInTranscript(transcript, cwd) : new Set();
|
|
210
|
+
if (!ruleStore) for (const f of approved) if (RULE_FILE_RE.test(f)) approved.delete(f);
|
|
184
211
|
const files = changed.filter((f) => own[f] !== (now[f] ?? 'gone') && !approved.has(normcase(f)));
|
|
185
212
|
if (!files.length) return null;
|
|
186
213
|
noteForStatus(files, host);
|
package/js/inspect/diff.mjs
CHANGED
|
@@ -420,7 +420,8 @@ export function improvementsMd(target, theme, allFiles, when, notes = []) {
|
|
|
420
420
|
if (notes.length) {
|
|
421
421
|
lines.push('# Self-improvement notes', '',
|
|
422
422
|
'Corrections the agent recorded against a skill or agent instead of editing it.',
|
|
423
|
-
'
|
|
423
|
+
'Folding one into the matching file under `src/` is the user\'s call: run the skill-forge',
|
|
424
|
+
'probe first (unless it is a trivial wording fix), then clear the note. Judge it by',
|
|
424
425
|
'its `seen:` evidence — a line without one is a claim, not a lesson — and weigh a',
|
|
425
426
|
'`[general]` line as a law, doctrine or memory rather than an edit to that one file.', '');
|
|
426
427
|
for (const n of notes) {
|
package/js/inspect/inventory.mjs
CHANGED
|
@@ -94,6 +94,7 @@ export const SKILL_CLASS = {
|
|
|
94
94
|
'forge-mcp': 'build', bruno: 'build', worktree: 'build', ownership: 'build',
|
|
95
95
|
'spring-boot': 'build', 'spring-data-jpa': 'build', 'spring-testing': 'build',
|
|
96
96
|
react: 'build', 'react-testing': 'build',
|
|
97
|
+
'jenkins-pipeline': 'build', 'gitlab-ci': 'build', 'compose-ops': 'build',
|
|
97
98
|
'geneseed-code-review': 'review', 'fresh-eyes': 'review', 'security-audit': 'review',
|
|
98
99
|
'roast-me': 'review', 'review-response': 'review', ponytail: 'review',
|
|
99
100
|
commit: 'ship', ship: 'ship', release: 'ship', handoff: 'ship',
|
package/js/inspect/registry.mjs
CHANGED
|
@@ -158,8 +158,10 @@ export function registryRecord(dir) {
|
|
|
158
158
|
* different registries. The snapshot is taken once on purpose: comparing `kept` against a SECOND
|
|
159
159
|
* read could clobber a root a concurrent `record()` appended between the two. So the write takes
|
|
160
160
|
* the lock and adds what that second read holds and the snapshot did not.
|
|
161
|
+
*
|
|
162
|
+
* `prune: false` reads the same rows and writes nothing, for a preview that promises as much.
|
|
161
163
|
*/
|
|
162
|
-
export function registryRoots() {
|
|
164
|
+
export function registryRoots({ prune = true } = {}) {
|
|
163
165
|
const original = registryLoad();
|
|
164
166
|
if (!original) return [];
|
|
165
167
|
const file = registryPath();
|
|
@@ -189,7 +191,7 @@ export function registryRoots() {
|
|
|
189
191
|
out.push(root);
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
|
-
if (kept.length !== original.length || kept.some((v, i) => v !== original[i])) {
|
|
194
|
+
if (prune && (kept.length !== original.length || kept.some((v, i) => v !== original[i]))) {
|
|
193
195
|
try {
|
|
194
196
|
withRegistryLock(() => {
|
|
195
197
|
registrySave([...kept, ...(registryLoad() ?? []).filter((r) => !original.includes(r))]);
|
package/js/inspect/validate.mjs
CHANGED
|
@@ -35,7 +35,7 @@ export const VALIDATE_USAGE = [
|
|
|
35
35
|
' [--footprint {lean,full}] [--posture POSTURE] [--mode MODE]',
|
|
36
36
|
' [--trust TRUST] [--doctrines DOCTRINES] [--exclude-rules RULES]',
|
|
37
37
|
' [--exclude-skills SKILLS] [--kits KITS] [--shared-tier on|off] [--no-secrets-gate]',
|
|
38
|
-
' [--no-done-gate] [--no-deletion-gate] [-v]',
|
|
38
|
+
' [--no-done-gate] [--no-deletion-gate] [--no-external-gate] [--no-test-note] [-v]',
|
|
39
39
|
'',
|
|
40
40
|
"Render and emit into a throwaway sandbox, run the doctor's checks, and write nothing real.",
|
|
41
41
|
"Takes the generator's render flags (see geneseed-build --help) except --sync-themes and",
|
package/js/lib/paths.mjs
CHANGED
|
@@ -9,6 +9,19 @@
|
|
|
9
9
|
import { accessSync, constants, statSync } from 'node:fs';
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
|
|
12
|
+
/** Does `root` sit directly in a `node_modules`? Any name: an npm alias installs under its own. */
|
|
13
|
+
export const inNodeModules = (root) => path.basename(path.dirname(root)).toLowerCase() === 'node_modules';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Is `root` a lasting install of the npm package, `…/node_modules/geneseed`? A path rule, so
|
|
17
|
+
* `migrate` can answer under the CLI's spawn ban. An npx cache is not one: npm prunes it, and the
|
|
18
|
+
* shim would die with it.
|
|
19
|
+
* shortcut: a project-local `node_modules` passes too, and only `npm root -g` tells them apart;
|
|
20
|
+
* upgrade if a project-local `migrate` ever proves real.
|
|
21
|
+
*/
|
|
22
|
+
export const isNpmPackageDir = (root) => inNodeModules(root) && path.basename(root).toLowerCase() === 'geneseed'
|
|
23
|
+
&& !root.split(/[\\/]/).includes('_npx');
|
|
24
|
+
|
|
12
25
|
const { X_OK } = constants;
|
|
13
26
|
/**
|
|
14
27
|
* `PurePath._str_normcase` \u2014 Windows compares and sorts paths case-folded, POSIX does
|
package/js/maintain/migrate.mjs
CHANGED
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
* install must not block the rest — and for a migration it is the half-migrated machine the
|
|
16
16
|
* whole verb exists to prevent.
|
|
17
17
|
*
|
|
18
|
+
* IT RUNS FROM THE NPM PACKAGE OR NOT AT ALL. The re-emit bakes the ROOT of whatever Geneseed runs
|
|
19
|
+
* it into the shim, so a run from a clone or a bundle moves nothing and only writes the stamp. That
|
|
20
|
+
* refusal comes before the survey, because the survey's registry read can prune `installs.json`.
|
|
21
|
+
* `--dry-run` writes nothing and answers from anywhere.
|
|
22
|
+
*
|
|
18
23
|
* THE ONE TRIGGER IS THE STAMP: work is needed when `<GENESEED_HOME>/.migrated` does not name this
|
|
19
24
|
* ROOT, and the stamp is written only on success. That is what makes the verb idempotent, and it
|
|
20
25
|
* holds for an OpenCode-only machine too, which wires no hooks at all.
|
|
@@ -34,6 +39,7 @@ import { installProfile } from '../build/generate.mjs';
|
|
|
34
39
|
import { autostartPaths, autostartStale, hookShimPath, shimHome } from '../hosts/shim.mjs';
|
|
35
40
|
import { writeText, printOut, printErr } from '../lib/fs.mjs';
|
|
36
41
|
import { sharedPaths } from '../lib/machine-dir.mjs';
|
|
42
|
+
import { isNpmPackageDir } from '../lib/paths.mjs';
|
|
37
43
|
|
|
38
44
|
/** Every emit name the generator answers to — the set an unrecognised marker is NOT in. */
|
|
39
45
|
const KNOWN_EMITS = new Set(EMIT_HOST_SCOPE.keys());
|
|
@@ -78,10 +84,10 @@ function stashDir() { return path.join(shimHome(), '.migrate-backup'); }
|
|
|
78
84
|
* no rollback. That ordering is the cheapest atomicity there is and it is why the survey is a
|
|
79
85
|
* separate pass rather than a check inside the loop.
|
|
80
86
|
*/
|
|
81
|
-
function migrateSurvey() {
|
|
87
|
+
function migrateSurvey({ prune = true } = {}) {
|
|
82
88
|
const rows = [];
|
|
83
89
|
const unrecognised = [];
|
|
84
|
-
for (const [host, scope, root] of installTargets()) {
|
|
90
|
+
for (const [host, scope, root] of installTargets({ prune })) {
|
|
85
91
|
if (installState(root, host, scope) !== 'active') continue;
|
|
86
92
|
const raw = readMaybe(path.join(root, '.geneseed-emit'));
|
|
87
93
|
const marker = raw === null ? '' : raw.trim();
|
|
@@ -115,14 +121,12 @@ function autostartFindings() {
|
|
|
115
121
|
*/
|
|
116
122
|
function foldPreview(rows) {
|
|
117
123
|
let shared;
|
|
118
|
-
try { shared = sharedPaths(); } catch { return; } // no home: no tier to fold into
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
for (const f of report.failed) printOut(`[migrate] ${host}: the fold would stop at ${f}\n`);
|
|
125
|
-
}
|
|
124
|
+
try { shared = sharedPaths(); } catch { return []; } // no home: no tier to fold into
|
|
125
|
+
return rows.filter(({ host, scope, root }) => scope === 'global' && isCanonical(root, host))
|
|
126
|
+
.map(({ host, root }) => {
|
|
127
|
+
const report = foldHost({ host, cfgDir: root, shared, dryRun: true });
|
|
128
|
+
return { host, summary: foldSummary(report), failed: report.failed };
|
|
129
|
+
});
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
/**
|
|
@@ -144,23 +148,51 @@ export function orphanFindings(cfg, owned, { live = knownSkillIds(), aliases = s
|
|
|
144
148
|
.map((rel) => path.join(cfg, rel));
|
|
145
149
|
}
|
|
146
150
|
|
|
147
|
-
/** The `--dry-run` half of M5:
|
|
151
|
+
/** The `--dry-run` half of M5: the orphans of each global Claude-style install. */
|
|
148
152
|
function orphanPreview(rows) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
return rows.filter(({ host, scope, root }) => scope === 'global' && CLAUDE_STYLE.includes(host) && isCanonical(root, host))
|
|
154
|
+
.flatMap(({ root }) => {
|
|
155
|
+
const owned = claudeReadManifest(root).owned;
|
|
156
|
+
return orphanFindings(root, Array.isArray(owned) ? owned : []);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** The fold and orphan half of `--dry-run`, as the CLI prints it. */
|
|
161
|
+
function printPreview(rows) {
|
|
162
|
+
for (const { host, summary, failed } of foldPreview(rows)) {
|
|
163
|
+
printOut(summary ? `[migrate] would fold ${host}: ${summary}\n` : `[migrate] ${host}: nothing to fold\n`);
|
|
164
|
+
for (const f of failed) printOut(`[migrate] ${host}: the fold would stop at ${f}\n`);
|
|
155
165
|
}
|
|
166
|
+
for (const p of orphanPreview(rows)) {
|
|
167
|
+
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`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* What the next rebuild would do, for the console: `{folds: [{host, summary, failed}], orphans}`.
|
|
173
|
+
* Writes nothing. A marker `migrate` refuses is in here too: `rebuild-all` coerces it, so that
|
|
174
|
+
* install still folds. No `would re-emit` plan: that is this verb's, and a clone has none to run.
|
|
175
|
+
*/
|
|
176
|
+
export function migratePreview() {
|
|
177
|
+
const { rows, unrecognised } = migrateSurvey({ prune: false });
|
|
178
|
+
const all = [...rows, ...unrecognised];
|
|
179
|
+
return { folds: foldPreview(all), orphans: orphanPreview(all) };
|
|
156
180
|
}
|
|
157
181
|
|
|
158
182
|
/** A stash key that cannot collide across drives, and is a legal file name on both platforms. */
|
|
159
183
|
const stashKey = (p) => p.replace(/[\\/:]/g, '_');
|
|
160
184
|
|
|
161
|
-
export function cmdMigrate(args = {}) {
|
|
185
|
+
export function cmdMigrate(args = {}, { root = ROOT } = {}) {
|
|
162
186
|
const dryRun = Boolean(args.dryRun);
|
|
163
|
-
const
|
|
187
|
+
const isClone = existsSync(path.join(root, '.git'));
|
|
188
|
+
const outside = isClone || !isNpmPackageDir(root);
|
|
189
|
+
const shape = isClone ? 'a git clone' : 'a bundle';
|
|
190
|
+
if (!dryRun && outside) {
|
|
191
|
+
printErr(`[migrate] REFUSED — this Geneseed runs from ${shape}, so there is nothing to migrate. Use geneseed update.\n`);
|
|
192
|
+
printErr('[migrate] Nothing was changed.\n');
|
|
193
|
+
return 3;
|
|
194
|
+
}
|
|
195
|
+
const { rows, unrecognised, needed } = migrateSurvey({ prune: !dryRun });
|
|
164
196
|
|
|
165
197
|
if (unrecognised.length) {
|
|
166
198
|
// Refuse the WHOLE run. A migration that skipped the row it did not understand and
|
|
@@ -179,13 +211,19 @@ export function cmdMigrate(args = {}) {
|
|
|
179
211
|
return 0;
|
|
180
212
|
}
|
|
181
213
|
|
|
182
|
-
if (dryRun)
|
|
214
|
+
if (dryRun) printPreview(rows);
|
|
183
215
|
|
|
184
216
|
if (!needed) {
|
|
185
217
|
printOut(`[migrate] already on the npm shape (${rows.length} install(s)); nothing to do.\n`);
|
|
186
218
|
return 0;
|
|
187
219
|
}
|
|
188
220
|
|
|
221
|
+
if (dryRun && outside) {
|
|
222
|
+
printOut(`[migrate] this Geneseed runs from ${shape}, so a real run would refuse. Use geneseed update.\n`);
|
|
223
|
+
printOut('[migrate] --dry-run: nothing was written.\n');
|
|
224
|
+
return 0;
|
|
225
|
+
}
|
|
226
|
+
|
|
189
227
|
printOut(`[migrate] ${rows.length} install(s) to migrate.\n`);
|
|
190
228
|
if (dryRun) {
|
|
191
229
|
for (const r of rows) {
|
|
@@ -263,8 +301,8 @@ export function cmdMigrate(args = {}) {
|
|
|
263
301
|
|
|
264
302
|
printOut(`[migrate] migrated ${rows.length} install(s).\n`);
|
|
265
303
|
|
|
266
|
-
// Step 5 — what could NOT be fixed automatically. Reported, never rewritten:
|
|
267
|
-
//
|
|
304
|
+
// Step 5 — what could NOT be fixed automatically. Reported, never rewritten: the file may be
|
|
305
|
+
// the user's own, and the one Settings writes is updated from Settings, not by migrate.
|
|
268
306
|
// The `start` ACTION is load-bearing, not decoration: bare `web` runs `serve()` in the
|
|
269
307
|
// FOREGROUND with `daemon=false`, which never writes the daemon record, so `web stop`,
|
|
270
308
|
// `web restart` and `web status` stay blind to the server this note just told someone to
|
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
atomicWriteJson, managedBlockRead, managedBlockRemove, managedBlockWrite,
|
|
65
65
|
loadJsonObject, mergeClaudeSettings, opencodeTarget, OPENCODE_SENTINEL, opencodeSentinelWrite,
|
|
66
66
|
settingsIntegrityCheck, wireClaudeExcludes, unwireClaudeExcludes,
|
|
67
|
-
unwireClaudeSettings,
|
|
67
|
+
unwireClaudeSettings, wireClaudeEnv, unwireClaudeEnv,
|
|
68
68
|
} from '../hosts/settings.mjs';
|
|
69
69
|
import { printOut, printErr, readText, writeText, isFile, isDir, isOsError } from '../lib/fs.mjs';
|
|
70
70
|
import { indexOfDeepEqual, isDict, jsonDumps, deepEquals } from '../lib/json.mjs';
|
|
@@ -323,6 +323,7 @@ export function claudeUninstall(cfg, archiveMemory, force = false) {
|
|
|
323
323
|
const sf = settingsFile(cfg, managed);
|
|
324
324
|
const unwired = unwireClaudeSettings(sf, hooks);
|
|
325
325
|
unwireClaudeExcludes(sf, managed.settings_excludes || []);
|
|
326
|
+
unwireClaudeEnv(sf, managed.settings_env);
|
|
326
327
|
// The unwire is VERIFIED, not assumed: a commented settings file is never rewritten, so a
|
|
327
328
|
// supposedly-uninstalled repo could keep firing Geneseed's hooks. Loud, never fatal.
|
|
328
329
|
settingsIntegrityCheck(sf, managed, 'absent');
|
|
@@ -1206,6 +1207,7 @@ function claudeDeactivate(root, scope = 'global', host = 'claude') {
|
|
|
1206
1207
|
}
|
|
1207
1208
|
unwireClaudeSettings(settingsFile(cfg, managed), managed.settings_hooks || []);
|
|
1208
1209
|
unwireClaudeExcludes(settingsFile(cfg, managed), managed.settings_excludes || []);
|
|
1210
|
+
unwireClaudeEnv(settingsFile(cfg, managed), managed.settings_env);
|
|
1209
1211
|
// The same integrity check the uninstall path runs: a deactivate that silently failed to
|
|
1210
1212
|
// unwire would leave hooks firing in a repo the user believes is off.
|
|
1211
1213
|
settingsIntegrityCheck(settingsFile(cfg, managed), managed, 'absent');
|
|
@@ -1262,6 +1264,8 @@ function claudeReactivate(root, scope = 'global', host = 'claude') {
|
|
|
1262
1264
|
}
|
|
1263
1265
|
remergeClaudeHooks(cfg, root, host);
|
|
1264
1266
|
wireClaudeExcludes(settingsFile(cfg, managed), managed.settings_excludes || []);
|
|
1267
|
+
// Only what the manifest records: a reactivate restores this install's own keys, never new ones.
|
|
1268
|
+
if (isDict(managed.settings_env)) wireClaudeEnv(settingsFile(cfg, managed), managed.settings_env);
|
|
1265
1269
|
cleanHostStash(cfg, host);
|
|
1266
1270
|
return { ok: true, kind: host, moved };
|
|
1267
1271
|
}
|
package/js/web/actions.mjs
CHANGED
|
@@ -62,6 +62,7 @@ import { NO_WINDOW } from '../lib/proc.mjs';
|
|
|
62
62
|
import { normcase, which, within } from '../lib/paths.mjs';
|
|
63
63
|
import { stripWhitespace } from '../lib/text.mjs';
|
|
64
64
|
import { memoryDelete } from '../maintain/memory.mjs';
|
|
65
|
+
import { autostartInstall, autostartRemove } from '../hosts/shim.mjs';
|
|
65
66
|
import { installDeactivate, installReactivate, installUninstall } from '../maintain/uninstall.mjs';
|
|
66
67
|
import { emitChoices, themeChoices, viewCfg } from './api.mjs';
|
|
67
68
|
import { actionCommands } from './jobs.mjs';
|
|
@@ -156,7 +157,7 @@ function bodySharedTier(body, root, host) {
|
|
|
156
157
|
|
|
157
158
|
/**
|
|
158
159
|
* The gate switches across the trust boundary (`deletionGate`, `secretsGate`, `doneGate`,
|
|
159
|
-
* `ownershipGate`), each on its own: only a real JSON boolean counts. Anything else — a string
|
|
160
|
+
* `ownershipGate`, `externalGate`, `testNote`), each on its own: only a real JSON boolean counts. Anything else — a string
|
|
160
161
|
* `"false"`, a number, absence — falls back to the install's own answer for THAT gate, so a
|
|
161
162
|
* malformed or partial body can never disarm (or re-arm) a gate it did not name.
|
|
162
163
|
*/
|
|
@@ -421,6 +422,21 @@ export function apiExcludesMutate(state, body) {
|
|
|
421
422
|
return action === 'add' ? excludeAdd(p) : excludeRemove(p);
|
|
422
423
|
}
|
|
423
424
|
|
|
425
|
+
// ---- login launcher -------------------------------------------------------------------------
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Settings' Start at login: `{action: install|remove}` and nothing else. The file is always this
|
|
429
|
+
* platform's `autostartFile`; no field of the body names a path, so a client cannot aim the write.
|
|
430
|
+
* The refusals (a hand-written file, nothing to remove, an OS error) come back as `ok: false`
|
|
431
|
+
* with `error`, which the client shows as the reason (409).
|
|
432
|
+
*/
|
|
433
|
+
export function apiAutostart(state, body) {
|
|
434
|
+
const action = bget(body, 'action');
|
|
435
|
+
if (action === 'install') return autostartInstall();
|
|
436
|
+
if (action === 'remove') return autostartRemove();
|
|
437
|
+
return { ok: false, error: 'body must be {action: install|remove}' };
|
|
438
|
+
}
|
|
439
|
+
|
|
424
440
|
// ---- loop preset picker ---------------------------------------------------------------------
|
|
425
441
|
|
|
426
442
|
/**
|
package/js/web/api.mjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* bind paths to these functions are `routes.mjs`. This file imports none of its route siblings,
|
|
9
9
|
* which is what keeps the old `api ↔ actions` and `api ↔ activity` cycles from coming back.
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import { mkdirSync, readdirSync, statSync } from 'node:fs';
|
|
12
12
|
import path from 'node:path';
|
|
13
13
|
|
|
14
14
|
import { CONFIG, CREDIT_RE, ROOT, SRC, THEMES, discoverNames, loadKits, makeCfg, upstreamOf } from '../build/source.mjs';
|
|
@@ -21,7 +21,7 @@ import { excludesSnapshot } from '../inspect/excludes.mjs';
|
|
|
21
21
|
import { sessionStartSize } from '../hosts/hooks-context.mjs';
|
|
22
22
|
import { CLAUDE_STYLE, VERSION_MARKER } from '../hosts/hosts.mjs';
|
|
23
23
|
import { factCount } from '../hosts/memory-files.mjs';
|
|
24
|
-
import {
|
|
24
|
+
import { autostartState } from '../hosts/shim.mjs';
|
|
25
25
|
import {
|
|
26
26
|
footprintOfDir, gatesOfDir, installState, installTargets, modeOfDir,
|
|
27
27
|
trustOfDir, sharedTierOfDir,
|
|
@@ -32,7 +32,7 @@ import { loadCatalog, catalogProblems } from '../loop/catalog.mjs';
|
|
|
32
32
|
import { activeLoops } from '../loop/registry.mjs';
|
|
33
33
|
import { EMIT_OPTIONS, themeOptions } from '../maintain/setup.mjs';
|
|
34
34
|
import { accentFor, keptKitFiles, statusData } from '../inspect/status.mjs';
|
|
35
|
-
import {
|
|
35
|
+
import { writeTextAtomic } from '../lib/fs.mjs';
|
|
36
36
|
import { sharedPaths } from '../lib/machine-dir.mjs';
|
|
37
37
|
import { comparePaths } from '../lib/paths.mjs';
|
|
38
38
|
import {
|
|
@@ -286,8 +286,8 @@ export function apiFleet(state, { now = Date.now() } = {}) {
|
|
|
286
286
|
if (files !== null) drift = driftCounts(files);
|
|
287
287
|
} catch { /* an install that cannot be re-rendered reports no drift figure, not zero */ }
|
|
288
288
|
}
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
const builtMs = builtAt(dir);
|
|
290
|
+
const built = builtMs === null ? null : Math.floor(builtMs / 1000);
|
|
291
291
|
const { cost, sessionStart } = reads(host, scope, st, root, dir);
|
|
292
292
|
const tier = tierOf({ target: dir });
|
|
293
293
|
installs.push({
|
|
@@ -317,21 +317,27 @@ export function apiFleet(state, { now = Date.now() } = {}) {
|
|
|
317
317
|
return { installs, source_fp: sourceFp, doctor: state.doctor, version: releaseLabel() };
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
+
/**
|
|
321
|
+
* When an install was built: its version marker's mtime in ms, or null. ONE rule for the Overview
|
|
322
|
+
* and the fleet: every emit writes the marker, and a Claude-family install has no root `AGENT.md`.
|
|
323
|
+
*/
|
|
324
|
+
function builtAt(dir) {
|
|
325
|
+
try { return statSync(path.join(dir, VERSION_MARKER)).mtimeMs; } catch { return null; }
|
|
326
|
+
}
|
|
327
|
+
|
|
320
328
|
/**
|
|
321
329
|
* What Settings' Server panel says about the process answering it — built FIELD BY FIELD, never from the
|
|
322
330
|
* daemon record, which holds the write token: a GET is readable by anything that passes the Host
|
|
323
331
|
* check, and the token is the only guard on a POST. `started` is the process's own start (the
|
|
324
|
-
* server is the process), in epoch seconds. `autostart` is
|
|
325
|
-
*
|
|
326
|
-
* where
|
|
332
|
+
* server is the process), in epoch seconds. `autostart` is THIS platform's login launcher,
|
|
333
|
+
* `{file, state}` with state `absent`, `ours`, `stale` or `hand` (`autostartState`), so the row
|
|
334
|
+
* can name the file its confirmation writes; null where the platform has none.
|
|
327
335
|
*/
|
|
328
336
|
function serverFacts() {
|
|
329
|
-
const [vbs, plist] = autostartPaths();
|
|
330
|
-
const launcher = { win32: vbs, darwin: plist }[process.platform];
|
|
331
337
|
return {
|
|
332
338
|
pid: process.pid,
|
|
333
339
|
started: Math.floor(Date.now() / 1000 - process.uptime()),
|
|
334
|
-
autostart:
|
|
340
|
+
autostart: autostartState(),
|
|
335
341
|
};
|
|
336
342
|
}
|
|
337
343
|
|
|
@@ -441,9 +447,8 @@ export function apiOverview(state, counts = machineCounts(state, [{ install: nul
|
|
|
441
447
|
// engine-dependent — a plausible-but-wrong "2h" is the exact failure a second field costs
|
|
442
448
|
// nothing to prevent.
|
|
443
449
|
let buildEpoch = null;
|
|
444
|
-
const
|
|
445
|
-
if (
|
|
446
|
-
const ms = statSync(agentMd).mtimeMs;
|
|
450
|
+
const ms = builtAt(state.target);
|
|
451
|
+
if (ms !== null) {
|
|
447
452
|
buildTime = stampMinute(ms);
|
|
448
453
|
buildEpoch = Math.floor(ms / 1000);
|
|
449
454
|
}
|
|
@@ -453,8 +458,9 @@ export function apiOverview(state, counts = machineCounts(state, [{ install: nul
|
|
|
453
458
|
for (const [host, scope, root] of installTargets()) {
|
|
454
459
|
try {
|
|
455
460
|
if (samePath(viewCfg(host, scope, root), state.target)) {
|
|
456
|
-
// `deletionGate`/`secretsGate`/`doneGate`/`ownershipGate`: the gate
|
|
457
|
-
// Constitution page's toggles on rows IV, I, III
|
|
461
|
+
// `deletionGate`/`secretsGate`/`doneGate`/`testNote`/`ownershipGate`/`externalGate`: the gate
|
|
462
|
+
// switches, for the Constitution page's toggles on rows IV, I, III, VIII, inside the Credo's
|
|
463
|
+
// Ownership row and inside doctrine rigor 5's row.
|
|
458
464
|
install = { host, scope, path: root, footprint: footprintOfDir(root),
|
|
459
465
|
...gatesOfDir(root, host) };
|
|
460
466
|
break;
|
package/js/web/handler.mjs
CHANGED
|
@@ -309,6 +309,8 @@ export function makeHandler(state, jm, token, dist, holder = null) {
|
|
|
309
309
|
apiPickFolder((result) => sendJson(res, result, 200, ae));
|
|
310
310
|
return;
|
|
311
311
|
}
|
|
312
|
+
// A rebuild's fold writes the same draft and ledger, so a decision waits for it.
|
|
313
|
+
if (path === '/api/rules/decide' && jm.busy) return sendJson(res, BUSY, 409, ae);
|
|
312
314
|
// The install a body `{host, path}` names, on the routes that read one (`VIEW_POSTS`).
|
|
313
315
|
// An action is looked up on the SAME segment `doAction` dispatches on (the last), so
|
|
314
316
|
// `/api/actions/x/restore` cannot run a restore on the daemon's install instead.
|
package/js/web/routes.mjs
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { installTargets } from '../hosts/installs.mjs';
|
|
18
18
|
import { formatValue, isTruthy, parseJson } from '../lib/json.mjs';
|
|
19
19
|
import { percentDecode } from '../lib/text.mjs';
|
|
20
|
-
import { apiExcludesMutate, apiInstallToggle, apiLoopsPresetMutate, apiMcp, apiMemoryDelete, targetView } from './actions.mjs';
|
|
20
|
+
import { apiAutostart, apiExcludesMutate, apiInstallToggle, apiLoopsPresetMutate, apiMcp, apiMemoryDelete, targetView } from './actions.mjs';
|
|
21
21
|
import { apiActivity, apiActivityDetail, apiActivityToggle } from './activity.mjs';
|
|
22
22
|
import {
|
|
23
23
|
apiDefaultInstallSet, apiDiff, apiDoctor, apiExcludes, apiFleet, apiInstalls, apiKits, apiLoops, apiLoopsActive, apiOverview, memoCounts,
|
|
@@ -27,7 +27,8 @@ import { FLEET_SECTIONS, NotFound, apiCatalog, apiItem } from './catalog.mjs';
|
|
|
27
27
|
import { apiUsage } from './usage-api.mjs';
|
|
28
28
|
import { fleetSort } from './state.mjs';
|
|
29
29
|
import { apiGates } from './gates-api.mjs';
|
|
30
|
-
import {
|
|
30
|
+
import { migratePreview } from '../maintain/migrate.mjs';
|
|
31
|
+
import { apiProfile, apiProfileSave, apiRules, apiRulesDecide, apiRulesMutate, apiRulesPromote } from './user-files.mjs';
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* The POSTs this daemon answers — and this table IS the dispatch, not a declaration beside
|
|
@@ -55,11 +56,13 @@ export const POST_ROUTES = new Map([
|
|
|
55
56
|
[(state, b) => apiMemoryDelete(state, isTruthy(b.name) ? formatValue(b.name) : ''), false]],
|
|
56
57
|
['/api/rules', [apiRulesMutate, true]],
|
|
57
58
|
['/api/rules/promote', [apiRulesPromote, true]],
|
|
59
|
+
['/api/rules/decide', [apiRulesDecide, true]],
|
|
58
60
|
['/api/profile', [apiProfileSave, true]],
|
|
59
61
|
// No `ok: false` arm: success returns `{ok: true, loop}`, and both refusals (unknown root,
|
|
60
62
|
// unknown preset) throw `NotFound`, which `doPost`'s catch answers 404 before this column is
|
|
61
63
|
// ever consulted — the same shape as `/api/memory/delete` and `/api/activity` above.
|
|
62
64
|
['/api/loops/preset', [apiLoopsPresetMutate, false]],
|
|
65
|
+
['/api/autostart', [apiAutostart, true]],
|
|
63
66
|
]);
|
|
64
67
|
|
|
65
68
|
/**
|
|
@@ -70,7 +73,7 @@ export const POST_ROUTES = new Map([
|
|
|
70
73
|
* are the only actions that read the request's install.
|
|
71
74
|
*/
|
|
72
75
|
export const VIEW_POSTS = new Set(['/api/activity', '/api/memory/delete', '/api/rules',
|
|
73
|
-
'/api/rules/promote', '/api/profile', '/api/actions/restore', '/api/actions/build']);
|
|
76
|
+
'/api/rules/promote', '/api/rules/decide', '/api/profile', '/api/actions/restore', '/api/actions/build']);
|
|
74
77
|
|
|
75
78
|
/**
|
|
76
79
|
* The GETs that answer for the whole machine, not one install: they IGNORE a `?host=&path=`
|
|
@@ -86,7 +89,7 @@ export const VIEW_POSTS = new Set(['/api/activity', '/api/memory/delete', '/api/
|
|
|
86
89
|
* active install (`fleetOf`), which caches one view per install on the daemon state; the laws
|
|
87
90
|
* section, and `/api/item/`, stay install-scoped (`PREFIX_ROUTES`).
|
|
88
91
|
*/
|
|
89
|
-
export const MACHINE_GETS = new Set(['/api/update', '/api/installs', '/api/fleet', '/api/kits',
|
|
92
|
+
export const MACHINE_GETS = new Set(['/api/update', '/api/installs', '/api/fleet', '/api/migrate/preview', '/api/kits',
|
|
90
93
|
'/api/usage', '/api/gates', '/api/excludes', '/api/mcp', '/api/loops/active', '/api/activity',
|
|
91
94
|
'/api/catalog/skills', '/api/catalog/agents', '/api/catalog/memory', '/api/catalog/notebook',
|
|
92
95
|
'/api/catalog/wiki', '/api/catalog/config']);
|
|
@@ -203,6 +206,8 @@ export const STATE_ROUTES = {
|
|
|
203
206
|
new URL(url || '', 'http://x').searchParams.has('fresh')),
|
|
204
207
|
'/api/installs': apiInstalls,
|
|
205
208
|
'/api/fleet': (state) => apiFleet(state),
|
|
209
|
+
// Reads every global install, and writes nothing: the console's view of `migrate --dry-run`.
|
|
210
|
+
'/api/migrate/preview': () => migratePreview(),
|
|
206
211
|
'/api/kits': apiKits,
|
|
207
212
|
'/api/update': apiUpdate,
|
|
208
213
|
'/api/usage': apiUsage,
|
package/js/web/update-check.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import path from 'node:path';
|
|
|
24
24
|
|
|
25
25
|
import { ROOT } from '../build/source.mjs';
|
|
26
26
|
import { measureUpstream, preflight } from '../maintain/update.mjs';
|
|
27
|
-
import { normcase, which } from '../lib/paths.mjs';
|
|
27
|
+
import { inNodeModules, normcase, which } from '../lib/paths.mjs';
|
|
28
28
|
|
|
29
29
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
30
30
|
/** A failed ask is retried sooner than a good answer is refreshed: a proxy hiccup is not a day. */
|
|
@@ -162,7 +162,7 @@ export function installKind({ root = ROOT, npmRoot = npmGlobalRoot } = {}) {
|
|
|
162
162
|
let kind = 'other';
|
|
163
163
|
let unanswered = false;
|
|
164
164
|
if (existsSync(path.join(root, '.git'))) kind = 'git';
|
|
165
|
-
else if (
|
|
165
|
+
else if (inNodeModules(root)) {
|
|
166
166
|
const g = npmRoot();
|
|
167
167
|
unanswered = !g;
|
|
168
168
|
if (g && real(g) === real(path.dirname(root))) kind = 'npm-global';
|