geneseed 4.32.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 +85 -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 +85 -18
- package/adapters/opencode/plugins/geneseed-guard.js +437 -76
- 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 +5 -5
- package/docs/concepts/footprint.md +1 -1
- package/docs/concepts/foreman-mode.md +2 -2
- package/docs/concepts/hooks.md +22 -8
- package/docs/concepts/host-matrix.md +2 -2
- package/docs/concepts/hosts.md +1 -1
- package/docs/concepts/kits.md +3 -1
- package/docs/concepts/ownership.md +1 -1
- 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/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/opencode-plugins.md +3 -3
- package/docs/reference/plugin-activity.md +1 -1
- package/docs/reference/plugin-context.md +1 -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 +1 -1
- package/docs/understand/machine-bob.md +2 -0
- 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 +126 -68
- 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 +389 -99
- package/js/hosts/hooks-learn.mjs +38 -7
- package/js/hosts/hooks-prims.mjs +4 -2
- package/js/hosts/hooks.mjs +114 -39
- 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/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 +34 -34
- package/js/web/api.mjs +130 -74
- 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 +1 -1
- package/src/agents/advocate.md +1 -1
- package/src/agents/architect.md +1 -1
- package/src/agents/developer.md +1 -1
- 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 +1 -1
- package/src/agents/user-advocate.md +1 -1
- package/src/agents/visionary.md +1 -1
- 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/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/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-C5Li6awl.js → CopyButton-CHQte7Ap.js} +1 -1
- package/web/dist/assets/Dashboard-B8uXeJZ_.js +2 -0
- package/web/dist/assets/Docs-Dgv_MWfT.js +5 -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-CzitjxGV.js → Loops-S85PMQ8m.js} +2 -2
- package/web/dist/assets/{Markdown-C4S4tTA7.js → Markdown-0ORz7tAc.js} +21 -21
- package/web/dist/assets/OperatorHudView-DuGz_sTk.js +1 -0
- package/web/dist/assets/Personal-afJNwvRS.js +2 -0
- package/web/dist/assets/{RailCats-D5weYPCS.js → RailCats-AW92uhsX.js} +1 -1
- 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/{sections-ChwaobfW.js → sections-CtFz7HFH.js} +1 -1
- package/web/dist/index.html +5 -5
- package/src/skills/quiz.md +0 -44
- package/web/dist/assets/Activity-Bjy64wHC.js +0 -1
- package/web/dist/assets/ActivityDetail-B0AaipP8.js +0 -1
- package/web/dist/assets/Bonsai-CJniRqaH.js +0 -1
- package/web/dist/assets/Dashboard-B-6DTmae.js +0 -2
- package/web/dist/assets/Docs-LRc30XL9.js +0 -5
- package/web/dist/assets/GreenhouseView-CcoYlaWo.js +0 -1
- package/web/dist/assets/Installs-dp1epTcE.js +0 -3
- package/web/dist/assets/JournalView-nFP4poCf.js +0 -1
- package/web/dist/assets/KitApply-DwyZUj57.js +0 -1
- package/web/dist/assets/Kits-C0IEdZXe.js +0 -1
- package/web/dist/assets/Laws-CkykmQWu.js +0 -3
- package/web/dist/assets/Library-Guh9HBZU.js +0 -2
- package/web/dist/assets/OperatorHudView-DLGNulIY.js +0 -1
- package/web/dist/assets/Personal-BMtberL8.js +0 -2
- package/web/dist/assets/Tabs-uYJqfuQt.js +0 -1
- package/web/dist/assets/api-BxjLd7Qd.js +0 -1
- package/web/dist/assets/index-DA7BiaE5.js +0 -3
- package/web/dist/assets/index-dbbDGFDq.css +0 -1
- package/web/dist/assets/motion-Bccx3zE8.js +0 -1
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 { existsSync, readdirSync, statSync } from 'node:fs';
|
|
11
|
+
import { existsSync, 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';
|
|
@@ -18,11 +18,13 @@ import { alwaysOnCost } from '../inspect/cost.mjs';
|
|
|
18
18
|
import { installProfile } from '../build/generate.mjs';
|
|
19
19
|
import { diffCollect, renderMemo } from '../inspect/diff.mjs';
|
|
20
20
|
import { excludesSnapshot } from '../inspect/excludes.mjs';
|
|
21
|
-
import {
|
|
21
|
+
import { sessionStartSize } from '../hosts/hooks-context.mjs';
|
|
22
|
+
import { CLAUDE_STYLE, VERSION_MARKER } from '../hosts/hosts.mjs';
|
|
23
|
+
import { factCount } from '../hosts/memory-files.mjs';
|
|
22
24
|
import { autostartPaths } from '../hosts/shim.mjs';
|
|
23
25
|
import {
|
|
24
|
-
footprintOfDir, gatesOfDir, installState, installTargets,
|
|
25
|
-
trustOfDir,
|
|
26
|
+
footprintOfDir, gatesOfDir, installState, installTargets, modeOfDir,
|
|
27
|
+
trustOfDir, sharedTierOfDir,
|
|
26
28
|
postureOfDir, readJsonMaybe, readMaybe, themeOfDir,
|
|
27
29
|
} from '../hosts/installs.mjs';
|
|
28
30
|
import { PRESETS } from '../loop/score.mjs';
|
|
@@ -30,10 +32,11 @@ import { loadCatalog, catalogProblems } from '../loop/catalog.mjs';
|
|
|
30
32
|
import { activeLoops } from '../loop/registry.mjs';
|
|
31
33
|
import { EMIT_OPTIONS, themeOptions } from '../maintain/setup.mjs';
|
|
32
34
|
import { accentFor, keptKitFiles, statusData } from '../inspect/status.mjs';
|
|
33
|
-
import { isFile } from '../lib/fs.mjs';
|
|
35
|
+
import { isFile, writeTextAtomic } from '../lib/fs.mjs';
|
|
36
|
+
import { sharedPaths } from '../lib/machine-dir.mjs';
|
|
34
37
|
import { comparePaths } from '../lib/paths.mjs';
|
|
35
38
|
import {
|
|
36
|
-
configItems, deployed, dget, memoryItems, notebookItems, wikiItems,
|
|
39
|
+
configItems, deployed, dget, fleetCounts, memoryDir, memoryItems, notebookItems, orSkip, tierOf, wikiItems,
|
|
37
40
|
} from './catalog.mjs';
|
|
38
41
|
import { defaultView, samePath, stampMinute, viewCfg } from './state.mjs';
|
|
39
42
|
import { MANUAL_UPDATE, gitBehind, installKind, updateStatus } from './update-check.mjs';
|
|
@@ -89,15 +92,21 @@ const DOCTOR_COOLDOWN_MS = 3_000;
|
|
|
89
92
|
* A fresh ask within `DOCTOR_COOLDOWN_MS` of the last one THIS PATH ran reuses that run, so a
|
|
90
93
|
* page looping on `?fresh=1` cannot pin the event loop. `_doctorFreshAt` is written here only: a
|
|
91
94
|
* verdict planted any other way still re-runs. No single-flight promise — `runDoctor` is
|
|
92
|
-
* synchronous, so two fresh runs cannot overlap
|
|
95
|
+
* synchronous, so two fresh runs cannot overlap; only the warm-up is not (`warmDoctor`).
|
|
96
|
+
*
|
|
97
|
+
* This page needs the groups, so during the warm-up it answers with a promise of the verdict
|
|
98
|
+
* rather than a pending one: the request waits, the event loop does not.
|
|
93
99
|
*/
|
|
94
100
|
export function apiDoctor(state, fresh = false) {
|
|
95
101
|
if (fresh && Date.now() - (state._doctorFreshAt ?? 0) >= DOCTOR_COOLDOWN_MS) {
|
|
96
102
|
state.runDoctor();
|
|
97
103
|
state._doctorFreshAt = Date.now();
|
|
98
104
|
}
|
|
99
|
-
const
|
|
100
|
-
|
|
105
|
+
const answer = () => {
|
|
106
|
+
const { ok, problems, checked_at } = state.doctor;
|
|
107
|
+
return { ...state._doctorRun, ok, problems, checked_at };
|
|
108
|
+
};
|
|
109
|
+
return state._doctorJob === null ? answer() : state._doctorJob.then(answer);
|
|
101
110
|
}
|
|
102
111
|
|
|
103
112
|
/**
|
|
@@ -109,7 +118,7 @@ export function apiDoctor(state, fresh = false) {
|
|
|
109
118
|
*/
|
|
110
119
|
export function apiDiff(state) {
|
|
111
120
|
const { target, theme, files } = diffCollect({
|
|
112
|
-
target: state.target, theme: state.theme, emit: state.emit });
|
|
121
|
+
target: state.target, theme: state.theme, emit: state.emit, memo: memoOf(state) });
|
|
113
122
|
return { deployed: deployed(state), diffable: files !== null, target, theme,
|
|
114
123
|
files: files || [] };
|
|
115
124
|
}
|
|
@@ -153,19 +162,6 @@ const driftCounts = (files) => ({
|
|
|
153
162
|
stale: files.filter((f) => f.status === 'stale').length,
|
|
154
163
|
});
|
|
155
164
|
|
|
156
|
-
/**
|
|
157
|
-
* How many memory facts an install's data dir holds: the `.md` files of `<dir>/memory` (where
|
|
158
|
-
* `memoryItems` reads them), minus its index and README (the console's furniture), any case.
|
|
159
|
-
* No folder is no facts (0); a folder that cannot be listed is null, so a row says "not read"
|
|
160
|
-
* rather than "no facts".
|
|
161
|
-
*/
|
|
162
|
-
export function memoryFactCount(dir) {
|
|
163
|
-
try {
|
|
164
|
-
return readdirSync(path.join(dir, 'memory'))
|
|
165
|
-
.filter((f) => /\.md$/i.test(f) && !/^(memory|readme)\.md$/i.test(f)).length;
|
|
166
|
-
} catch (e) { return e?.code === 'ENOENT' ? 0 : null; }
|
|
167
|
-
}
|
|
168
|
-
|
|
169
165
|
/**
|
|
170
166
|
* The fields every install row opens with, in this order. Theme is narrowed to this row's own
|
|
171
167
|
* host (host-compat B1): a shared repo otherwise answers every row with whichever host's
|
|
@@ -175,8 +171,39 @@ const installRowBase = (host, scope, root, state) => ({
|
|
|
175
171
|
id: `${host}:${scope}:${root}`, host, scope, path: root, state,
|
|
176
172
|
theme: themeOfDir(root, host),
|
|
177
173
|
footprint: footprintOfDir(root),
|
|
174
|
+
// Reads the machine's shared tier: its rules, profile and memory are the same on every row that
|
|
175
|
+
// says so. The one field the console asks; `sharedTier` is only a project install's switch.
|
|
176
|
+
shared: tierOf({ target: viewCfg(host, scope, root) }) !== null,
|
|
178
177
|
});
|
|
179
178
|
|
|
179
|
+
/** Move the daemon's own state to the default install `def`. A pinned view keeps the one it named. */
|
|
180
|
+
function followDefault(state, def) {
|
|
181
|
+
if (def && state?.selectView && !state.pinned && !samePath(def[0], state.target)) state.selectView(...def);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* `POST /api/default-install`: `{host, path}` makes that install the default. Anything else is
|
|
186
|
+
* refused (the 409 arm) and the stored pick stays: there is no clearing body, because
|
|
187
|
+
* `readJsonBody` turns a malformed request into `{}`, and that must not erase a choice. The
|
|
188
|
+
* pair is the VALUE here, so this route is no `VIEW_POSTS` row. It stores the detected root, not
|
|
189
|
+
* the request's spelling of it. The daemon state moves here and not by `refresh`, which would
|
|
190
|
+
* drop every install's cached doctor for a pick that changes none of them.
|
|
191
|
+
*/
|
|
192
|
+
export function apiDefaultInstallSet(state, body) {
|
|
193
|
+
const { host, path: root } = body;
|
|
194
|
+
const hit = typeof root === 'string' && root
|
|
195
|
+
? [...activeInstalls(installTargets())].find(([h, , r]) => h === host && samePath(r, root))
|
|
196
|
+
: undefined;
|
|
197
|
+
if (hit === undefined) return { ok: false, error: 'not an active install (host, path)' };
|
|
198
|
+
const file = sharedPaths().defaultInstall;
|
|
199
|
+
// The folder normally exists already, through the install registry. Created here, it does not
|
|
200
|
+
// read as a tier: `tierOf` tests for the tier's memory store or a tier file, not the folder.
|
|
201
|
+
mkdirSync(path.dirname(file), { recursive: true });
|
|
202
|
+
writeTextAtomic(file, `${JSON.stringify({ host, path: String(hit[2]) }, null, 2)}\n`);
|
|
203
|
+
followDefault(state, defaultView());
|
|
204
|
+
return { ok: true };
|
|
205
|
+
}
|
|
206
|
+
|
|
180
207
|
/**
|
|
181
208
|
* The row `id` carries the ROOT, not only `host:scope`: two project installs of one host (two
|
|
182
209
|
* repos on Bob, say) are both `bob:project`, and the console keys its selection, its React rows
|
|
@@ -190,13 +217,15 @@ export function apiInstalls(state) {
|
|
|
190
217
|
const def = defaultView(targets);
|
|
191
218
|
// The row marked `default` must be the install an unnamed request reads, so the daemon state
|
|
192
219
|
// follows the marker here, where the console reads it, rather than only on a full refresh.
|
|
193
|
-
|
|
220
|
+
followDefault(state, def);
|
|
194
221
|
for (const [host, scope, root] of targets) {
|
|
195
222
|
out.push({
|
|
196
223
|
...installRowBase(host, scope, root, installState(root, host, scope)),
|
|
197
224
|
posture: postureOfDir(root, host),
|
|
198
225
|
mode: modeOfDir(root, host),
|
|
199
226
|
trust: trustOfDir(root, host),
|
|
227
|
+
// A project install's switch for reading the machine tier (a global install owns it).
|
|
228
|
+
sharedTier: scope === 'global' ? false : sharedTierOfDir(root, host),
|
|
200
229
|
// The install a request naming none reads (`defaultView`): the console's pickers start on it.
|
|
201
230
|
default: !!def && samePath(viewCfg(host, scope, root), def[0]),
|
|
202
231
|
});
|
|
@@ -206,6 +235,10 @@ export function apiInstalls(state) {
|
|
|
206
235
|
}
|
|
207
236
|
|
|
208
237
|
|
|
238
|
+
// How long a poll may serve `apiFleet`'s memo: a rule or profile write and a session's memory write
|
|
239
|
+
// call no `refresh`, so this is how late they show.
|
|
240
|
+
const FLEET_READS_MS = 30_000;
|
|
241
|
+
|
|
209
242
|
/**
|
|
210
243
|
* EVERY INSTALLED HARNESS ON THE MACHINE, EACH JUDGED ON ITS OWN — the Overview's fleet table.
|
|
211
244
|
*
|
|
@@ -222,7 +255,23 @@ export function apiInstalls(state) {
|
|
|
222
255
|
* a fixed walk finds, which describes the wrong install as soon as two hosts are deployed.
|
|
223
256
|
* Every unknown stays `null` — `verdict: 'unknown'`, `drift: null` — never a reassuring zero.
|
|
224
257
|
*/
|
|
225
|
-
export function apiFleet(state) {
|
|
258
|
+
export function apiFleet(state, { now = Date.now() } = {}) {
|
|
259
|
+
// Both reads render the session files, and an eager wiki walks a whole vault each time, so a poll
|
|
260
|
+
// serves them from a memo. `refresh` clears it; `FLEET_READS_MS` bounds what no `refresh` reports.
|
|
261
|
+
// `st` is in the key: an install switched off stops being measured at once.
|
|
262
|
+
const reads = (host, scope, st, root, dir) => {
|
|
263
|
+
const memo = (state._fleetReads ??= new Map());
|
|
264
|
+
const key = JSON.stringify([host, scope, st, String(root)]);
|
|
265
|
+
const hit = memo.get(key);
|
|
266
|
+
if (hit && now - hit.at < FLEET_READS_MS) return hit;
|
|
267
|
+
let sessionStart = null;
|
|
268
|
+
if (st === 'active' && scope === 'global' && CLAUDE_STYLE.includes(host)) {
|
|
269
|
+
try { sessionStart = sessionStartSize(dir, host); } catch { /* not measured, this round */ }
|
|
270
|
+
}
|
|
271
|
+
const fresh = { at: now, sessionStart, cost: alwaysOnCost({ host, root, dir, footprint: footprintOfDir(root) }) };
|
|
272
|
+
memo.set(key, fresh);
|
|
273
|
+
return fresh;
|
|
274
|
+
};
|
|
226
275
|
const sourceFp = sourceFingerprint(makeCfg());
|
|
227
276
|
const installs = [];
|
|
228
277
|
for (const [host, scope, root] of installTargets()) {
|
|
@@ -239,6 +288,8 @@ export function apiFleet(state) {
|
|
|
239
288
|
}
|
|
240
289
|
let built = null;
|
|
241
290
|
try { built = Math.floor(statSync(path.join(dir, VERSION_MARKER)).mtimeMs / 1000); } catch { /* never built */ }
|
|
291
|
+
const { cost, sessionStart } = reads(host, scope, st, root, dir);
|
|
292
|
+
const tier = tierOf({ target: dir });
|
|
242
293
|
installs.push({
|
|
243
294
|
...installRowBase(host, scope, root, st),
|
|
244
295
|
installed_fp: fp,
|
|
@@ -251,11 +302,14 @@ export function apiFleet(state) {
|
|
|
251
302
|
// Each install's own settings, on its row: the Overview has no viewed install to read them off.
|
|
252
303
|
posture: postureOfDir(root, host),
|
|
253
304
|
mode: modeOfDir(root, host),
|
|
254
|
-
// Its memory facts:
|
|
255
|
-
facts:
|
|
305
|
+
// Its memory facts: directory listings (`factCount`), no file read.
|
|
306
|
+
facts: factCount(memoryDir({ target: dir }, tier)),
|
|
256
307
|
// What this install injects every session, by part (characters); null when its carrier
|
|
257
308
|
// is missing, so the console says "not measured" rather than drawing an empty bar.
|
|
258
|
-
cost
|
|
309
|
+
cost,
|
|
310
|
+
// Its session-start hook against the budget. Global hook hosts only: the console has no
|
|
311
|
+
// repo to add, a project install's size is that repo's, and OpenCode has no stdout cap.
|
|
312
|
+
session_start: sessionStart,
|
|
259
313
|
});
|
|
260
314
|
}
|
|
261
315
|
// `version` is the source's release label, the "Behind 4.19.0" a behind row names; the same
|
|
@@ -264,7 +318,7 @@ export function apiFleet(state) {
|
|
|
264
318
|
}
|
|
265
319
|
|
|
266
320
|
/**
|
|
267
|
-
* What
|
|
321
|
+
* What Settings' Server panel says about the process answering it — built FIELD BY FIELD, never from the
|
|
268
322
|
* daemon record, which holds the write token: a GET is readable by anything that passes the Host
|
|
269
323
|
* check, and the token is the only guard on a POST. `started` is the process's own start (the
|
|
270
324
|
* server is the process), in epoch seconds. `autostart` is whether the hand-written login
|
|
@@ -307,10 +361,10 @@ function kitCredits(m, rules) {
|
|
|
307
361
|
}
|
|
308
362
|
|
|
309
363
|
/**
|
|
310
|
-
* EVERY INSTALL'S KITS — the Kits
|
|
364
|
+
* EVERY INSTALL'S KITS — the Kits page. Its own route, like `apiFleet`: it re-reads each carrier
|
|
311
365
|
* and the kit manifests, which the sidebar's `/api/installs` refetch must not pay for.
|
|
312
366
|
*
|
|
313
|
-
* `kits` per row is `installProfile(...).kits`, the reader `rebuild-all` uses, so the
|
|
367
|
+
* `kits` per row is `installProfile(...).kits`, the reader `rebuild-all` uses, so the page shows
|
|
314
368
|
* what a rebuild would keep. A malformed manifest answers 200 with `error` and EMPTY lists, never
|
|
315
369
|
* rows without kits (which would read as "no kit on") and never a 500. `editable:false` carries
|
|
316
370
|
* the two refusals `apiInstallCmd` makes, so the page can say why before the click.
|
|
@@ -332,9 +386,7 @@ export function apiKits() {
|
|
|
332
386
|
if (st === 'absent') continue;
|
|
333
387
|
try {
|
|
334
388
|
const p = installProfile(host, scope, root);
|
|
335
|
-
const reason = st === 'disabled' ? 'install is disabled — reactivate it first'
|
|
336
|
-
: legacyProcessCarrierOfDir(root, host) ? 'predates the comms pack — run geneseed setup for it first'
|
|
337
|
-
: null;
|
|
389
|
+
const reason = st === 'disabled' ? 'install is disabled — reactivate it first' : null;
|
|
338
390
|
installs.push({ ...installRowBase(host, scope, root, st), kits: p.kits,
|
|
339
391
|
keptKitFiles: keptKitFiles(host, scope, root, p.kits), editable: reason === null, reason });
|
|
340
392
|
} catch (e) {
|
|
@@ -345,9 +397,37 @@ export function apiKits() {
|
|
|
345
397
|
return { kits, installs };
|
|
346
398
|
}
|
|
347
399
|
|
|
348
|
-
/**
|
|
349
|
-
|
|
350
|
-
|
|
400
|
+
/**
|
|
401
|
+
* Every count the console prints, over `fleet`: `fleetCounts`, plus the rail's Loops badge. That one
|
|
402
|
+
* is templates only (a brick is a part, the template is what a person runs), from the catalogue
|
|
403
|
+
* `/api/loops` reads, and the union across installs, where its page lists the picked install's.
|
|
404
|
+
*/
|
|
405
|
+
export function machineCounts(state, fleet) {
|
|
406
|
+
const templates = (v) => [...loadCatalog({ projectRoot: v.state.root }).templates.keys()];
|
|
407
|
+
return { ...fleetCounts(state, fleet),
|
|
408
|
+
loops: new Set(fleet.flatMap((v) => orSkip(v, () => templates(v)))).size };
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// How long `machineCounts` may serve a read: the overview is asked every 1.5 s while the doctor
|
|
412
|
+
// warms. A mutation drops it (`refreshOwn`); this bounds what a session writes behind the console.
|
|
413
|
+
const COUNTS_MS = 5_000;
|
|
414
|
+
|
|
415
|
+
/** `machineCounts` over `fleet()`, memoised on the daemon's state `base`. */
|
|
416
|
+
export function memoCounts(base, fleet, now = Date.now()) {
|
|
417
|
+
const hit = base._counts;
|
|
418
|
+
if (hit && now - hit.at < COUNTS_MS) return hit.counts;
|
|
419
|
+
const counts = machineCounts(base, fleet());
|
|
420
|
+
base._counts = { at: now, counts };
|
|
421
|
+
return counts;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* The dashboard aggregate. One install's facts, but its `counts` are the machine's (`memoCounts`):
|
|
426
|
+
* every install, deduped, the same answer whichever install asks. They default to `state` alone.
|
|
427
|
+
* A pinned view runs no doctor: its one reader wants its `install`, and a cold run blocks the request
|
|
428
|
+
* for seconds. It serves the verdict it holds, or null.
|
|
429
|
+
*/
|
|
430
|
+
export function apiOverview(state, counts = machineCounts(state, [{ install: null, state }])) {
|
|
351
431
|
let diff = null;
|
|
352
432
|
if (deployed(state)) {
|
|
353
433
|
const { files } = diffCollect({
|
|
@@ -400,37 +480,8 @@ export function apiOverview(state) {
|
|
|
400
480
|
// `serve` installs the comparison; a state built without a server has none and is false.
|
|
401
481
|
daemon_stale: Boolean(state.daemonStale?.()),
|
|
402
482
|
server: serverFacts(),
|
|
403
|
-
counts
|
|
404
|
-
|
|
405
|
-
skills: inv.skills.length,
|
|
406
|
-
// ⚠ `laws` STAYS THE INVARIANT COUNT. The rail badge reads it, `docCounts` mirrors it as
|
|
407
|
-
// `{N_LAWS}`, and the doctor's frozen `proseMirrorProblems` compares README and
|
|
408
|
-
// SHIPPED.md prose against the same number. Widening it to "the whole constitution"
|
|
409
|
-
// would silently move all four at once.
|
|
410
|
-
laws: inv.laws.length,
|
|
411
|
-
ontology: (inv.ontology ?? []).length,
|
|
412
|
-
// The tier's own summary, kept out of the section counts because it is not a section:
|
|
413
|
-
// `active`/`total` is the fraction the dashboard shows, `rules` counts only the packs
|
|
414
|
-
// this install built in — what it is bound by, not what its bundle carries.
|
|
415
|
-
doctrines: {
|
|
416
|
-
active: (inv.doctrines ?? []).filter((p) => p.active).length,
|
|
417
|
-
total: (inv.doctrines ?? []).length,
|
|
418
|
-
// Counted RULE BY RULE, not pack by pack: with the per-rule axis an active pack can
|
|
419
|
-
// carry an inactive rule, so `p.rules.length` over active packs over-counts by
|
|
420
|
-
// exactly what the user switched off — the one number on the dashboard that claims
|
|
421
|
-
// to say how many rules bind this install.
|
|
422
|
-
rules: (inv.doctrines ?? [])
|
|
423
|
-
.reduce((n, p) => n + p.rules.filter((r) => r.active !== false).length, 0),
|
|
424
|
-
},
|
|
425
|
-
memory: memoryItems(state).length,
|
|
426
|
-
notebook: notebookItems(state).length,
|
|
427
|
-
wiki: wikiItems(state).length,
|
|
428
|
-
config: configItems(state).length,
|
|
429
|
-
// The rail's Loops badge: templates only, from the same catalogue `/api/loops` reads —
|
|
430
|
-
// a brick is a part, the template is what a person runs.
|
|
431
|
-
loops: loadCatalog({ projectRoot: state.root }).templates.size,
|
|
432
|
-
},
|
|
433
|
-
doctor: state.doctor,
|
|
483
|
+
counts,
|
|
484
|
+
doctor: state.pinned ? state._doctor : state.doctor,
|
|
434
485
|
diff,
|
|
435
486
|
build_time: buildTime,
|
|
436
487
|
build_epoch: buildEpoch,
|
|
@@ -464,7 +515,7 @@ const RECENT_LIMIT = 8;
|
|
|
464
515
|
/**
|
|
465
516
|
* THE NEWEST FILE-BACKED ENTRIES ACROSS THE HARNESS — the "freshly grown" card's whole payload.
|
|
466
517
|
*
|
|
467
|
-
*
|
|
518
|
+
* It exists
|
|
468
519
|
* because NOTHING else in this API carries a per-entry date: every
|
|
469
520
|
* catalog row is `{name, title, desc, source}` and the only two timestamps on the whole surface are
|
|
470
521
|
* `overview.build_time` and `doctor.checked_at`. A client cannot stat a path, so "what changed
|
|
@@ -561,17 +612,22 @@ export function apiLoopsActive() {
|
|
|
561
612
|
*
|
|
562
613
|
* `install` picks the Update route (`git`, `npm-global`, `other`); `git` is kept beside it for a
|
|
563
614
|
* console bundle older than the field. `behind` is a clone's own "up to date": commits upstream
|
|
564
|
-
* holds that it does not, null when unknown — a clone can always pull, since `main` moves
|
|
565
|
-
* releases and a work proxy can leave the release check unanswered
|
|
566
|
-
*
|
|
615
|
+
* holds that it does not, null when unknown — a clone can always try to pull, since `main` moves
|
|
616
|
+
* between releases and a work proxy can leave the release check unanswered — and false when the
|
|
617
|
+
* update job would refuse: local changes, no upstream, a detached HEAD, a diverged branch.
|
|
618
|
+
* `checking` covers both asks, so a slow fetch reads as "checking…", not as a settled unknown.
|
|
619
|
+
* `command` is what to run by hand when the console cannot update this copy itself.
|
|
567
620
|
*/
|
|
568
621
|
export function apiUpdate(state) {
|
|
569
622
|
const install = installKind();
|
|
623
|
+
const status = updateStatus(state, releaseLabel());
|
|
624
|
+
const behind = install === 'git' ? gitBehind(state, { busy: Boolean(state.jobBusy?.()) }) : null;
|
|
570
625
|
return {
|
|
571
|
-
...
|
|
626
|
+
...status,
|
|
627
|
+
checking: status.checking || Boolean(state._behind?.inflight),
|
|
572
628
|
install,
|
|
573
629
|
git: install === 'git',
|
|
574
|
-
behind
|
|
630
|
+
behind,
|
|
575
631
|
command: install === 'other' ? MANUAL_UPDATE : null,
|
|
576
632
|
};
|
|
577
633
|
}
|