geneseed 5.0.1 → 5.0.4
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 +92 -0
- package/README.md +4 -4
- package/SHIPPED.md +2 -2
- package/adapters/claude-code/README.md +11 -5
- package/adapters/openclaude/README.md +3 -1
- package/adapters/opencode/HOW-OPENCODE-LOADS.md +3 -0
- package/adapters/opencode/plugins/geneseed-context.js +12 -1
- package/adapters/opencode/plugins/geneseed-guard.js +594 -73
- package/adapters/opencode/plugins/geneseed-learn.js +1 -1
- package/adapters/opencode/plugins/geneseed-workflow.js +1 -1
- package/adapters/opencode/workflows/_runtime.js +1 -1
- package/bin/geneseed-cli.mjs +3 -0
- package/bin/geneseed-hook.mjs +31 -9
- package/docs/PRD.md +1 -1
- package/docs/README.md +4 -1
- package/docs/concepts/enforcement-table.md +23 -4
- package/docs/concepts/exclusions.md +48 -2
- package/docs/concepts/factories.md +151 -0
- 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 +5 -3
- package/docs/concepts/hosts.md +1 -1
- package/docs/concepts/kits.md +18 -0
- package/docs/concepts/loop-gates.md +3 -0
- package/docs/concepts/loops.md +1 -0
- package/docs/concepts/rules.md +1 -1
- package/docs/concepts/shared-tier.md +1 -1
- package/docs/concepts/skills.md +1 -1
- package/docs/extending.md +8 -2
- package/docs/guides/autostart.md +29 -3
- package/docs/guides/choose-your-setup.md +1 -1
- package/docs/guides/migrate.md +1 -1
- package/docs/guides/run-a-factory.md +88 -0
- package/docs/guides/set-up-ownership.md +1 -0
- package/docs/guides/uninstall.md +1 -1
- package/docs/reference/factory-actions.md +22 -0
- package/docs/reference/loop-actions.md +1 -1
- package/docs/reference/plugin-activity.md +1 -1
- 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 +101 -17
- package/harness.config.json +1 -1
- package/js/README.md +21 -3
- package/js/build/args.mjs +14 -2
- package/js/build/emit-claude.mjs +9 -1
- package/js/build/emit-opencode.mjs +2 -1
- package/js/build/source.mjs +28 -3
- package/js/cli-table.json +287 -3
- package/js/factory/cli.mjs +153 -0
- package/js/factory/graph.mjs +245 -0
- package/js/factory/registry.mjs +71 -0
- package/js/factory/state.mjs +429 -0
- package/js/hosts/activity.mjs +3 -3
- package/js/hosts/geneseed-dir.mjs +2 -2
- package/js/hosts/gitref.mjs +21 -0
- package/js/hosts/hooks-context.mjs +71 -15
- package/js/hosts/hooks-done.mjs +3 -1
- package/js/hosts/hooks-learn.mjs +1 -1
- package/js/hosts/hooks-prims.mjs +271 -1
- package/js/hosts/hooks.mjs +409 -151
- package/js/hosts/hosts.mjs +22 -0
- package/js/hosts/installs.mjs +9 -5
- package/js/hosts/settings.mjs +128 -27
- package/js/hosts/shim.mjs +155 -7
- package/js/hosts/store-watch.mjs +36 -11
- package/js/inspect/checks-authoring.mjs +11 -1
- package/js/inspect/cost.mjs +91 -5
- package/js/inspect/diff.mjs +2 -1
- package/js/inspect/doctor.mjs +2 -1
- package/js/inspect/inventory.mjs +2 -1
- package/js/inspect/validate.mjs +1 -1
- package/js/loop/catalog.mjs +24 -12
- package/js/loop/cli.mjs +21 -15
- package/js/loop/graph.mjs +13 -4
- package/js/loop/registry.mjs +65 -28
- package/js/loop/state.mjs +18 -8
- package/js/maintain/migrate.mjs +2 -2
- package/js/maintain/uninstall.mjs +5 -1
- package/js/web/actions.mjs +17 -1
- package/js/web/api.mjs +52 -11
- package/js/web/catalog.mjs +38 -2
- package/js/web/daemon.mjs +136 -6
- package/js/web/handler.mjs +14 -5
- package/js/web/routes.mjs +12 -4
- package/js/web/server.mjs +4 -1
- package/package.json +1 -1
- package/registry.json +35 -0
- package/src/AGENT.md.tmpl +18 -24
- 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/bricks/docs-update.md +5 -0
- package/src/bricks/holdout-write.md +23 -0
- package/src/bricks/holdout.md +25 -0
- package/src/bricks/intake.md +18 -0
- package/src/bricks/merge-gate.md +22 -0
- package/src/bricks/pr-open.md +21 -0
- package/src/bricks/retro.md +17 -0
- package/src/bricks/test.md +4 -1
- package/src/bricks/triage.md +19 -0
- package/src/doctrines/comms.md +29 -41
- package/src/doctrines/craft.md +3 -10
- package/src/doctrines/ops.md +4 -15
- package/src/doctrines/process.md +24 -19
- package/src/doctrines/rigor.md +1 -5
- package/src/factories/analysis-to-build.json +34 -0
- package/src/factories/bug-report-to-fix.json +32 -0
- package/src/factories/issue-to-pr.json +49 -0
- 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/_checkpoints.md +1 -0
- package/src/skills/_self-improvement.md +12 -9
- package/src/skills/adhd.md +1 -1
- package/src/skills/compose-ops.md +58 -0
- package/src/skills/factory-forge.md +97 -0
- package/src/skills/factory.md +126 -0
- package/src/skills/gitlab-ci.md +51 -0
- package/src/skills/jenkins-pipeline.md +56 -0
- package/src/skills/parallel-agents.md +1 -1
- package/src/skills/pipeline.md +2 -2
- package/src/skills/rule.md +24 -18
- package/src/skills/skill-forge.md +24 -6
- package/src/skills/workflow.md +2 -1
- package/themes/_TEMPLATE.json +9 -4
- package/themes/biker.json +9 -4
- package/themes/commentator.json +9 -4
- package/themes/cyberpunk.json +9 -4
- package/themes/gamer.json +9 -4
- package/themes/imperial.json +9 -4
- package/themes/joker.json +9 -4
- package/themes/marvin.json +9 -4
- package/themes/mean.json +9 -4
- package/themes/military.json +9 -4
- package/themes/neutral.json +9 -4
- package/themes/pirate.json +9 -4
- package/themes/sports.json +9 -4
- package/themes/verstappen.json +9 -4
- package/themes/wizard.json +9 -4
- package/web/dist/assets/ActiveLoops-BTHIaRhn.js +1 -0
- package/web/dist/assets/Activity-BaoxwVFH.js +1 -0
- package/web/dist/assets/ActivityDetail-C_bFD0rW.js +1 -0
- package/web/dist/assets/{Bonsai-C1iBAt4v.js → Bonsai-B01lLf0m.js} +1 -1
- package/web/dist/assets/{CopyButton-DJ3a4N88.js → CopyButton-Bc66KPyA.js} +1 -1
- package/web/dist/assets/Dashboard-X7GZzGJp.js +2 -0
- package/web/dist/assets/{Docs-Kffdg5uV.js → Docs-LRYVnGLG.js} +3 -3
- package/web/dist/assets/Factories-ARenKBiP.js +1 -0
- package/web/dist/assets/{GreenhouseView-k56_cBSF.js → GreenhouseView-CfWR2-sX.js} +1 -1
- package/web/dist/assets/{Installs-DtEKLC9h.js → Installs-nfFHnovH.js} +3 -3
- package/web/dist/assets/{JournalView-RQnk5l7I.js → JournalView-lpOHcHKK.js} +1 -1
- package/web/dist/assets/Kits-Bw5EQl_i.js +1 -0
- package/web/dist/assets/Laws-CnZJ0wjZ.js +4 -0
- package/web/dist/assets/LibRows-Hqvf1beK.js +1 -0
- package/web/dist/assets/Library-JaSsp6Yr.js +3 -0
- package/web/dist/assets/Loops-ZaHC5MVl.js +2 -0
- package/web/dist/assets/{OperatorHudView-CM5jNPwL.js → OperatorHudView-CggG0_sK.js} +1 -1
- package/web/dist/assets/Personal-BObvlb70.js +2 -0
- package/web/dist/assets/Settings-BFfPMPc9.js +1 -0
- package/web/dist/assets/Tabs-B594Pad_.js +1 -0
- package/web/dist/assets/api-DLDVY3K-.js +1 -0
- package/web/dist/assets/index-DsLmKHw0.js +6 -0
- package/web/dist/assets/index-DvPjphz0.css +1 -0
- package/web/dist/index.html +3 -3
- package/web/dist/assets/Activity-Ci4PZco3.js +0 -1
- package/web/dist/assets/ActivityDetail-C8hroCND.js +0 -1
- package/web/dist/assets/Dashboard-C_On4KXw.js +0 -2
- package/web/dist/assets/Kits-CXkEBpnf.js +0 -1
- package/web/dist/assets/Laws-DhhIVqmh.js +0 -3
- package/web/dist/assets/Library-CAUiEoJo.js +0 -3
- package/web/dist/assets/Loops-LKD8mF4E.js +0 -2
- package/web/dist/assets/Personal-B6Uoly3C.js +0 -2
- package/web/dist/assets/RailCats-DQxxYBEP.js +0 -1
- package/web/dist/assets/Settings-BTe6-wda.js +0 -1
- package/web/dist/assets/Tabs-CbdDWTp_.js +0 -1
- package/web/dist/assets/api-D_r0Jtla.js +0 -1
- package/web/dist/assets/index-HfGmYXab.js +0 -3
- package/web/dist/assets/index-ao3M-Fhm.css +0 -1
|
@@ -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,
|
|
@@ -29,7 +29,9 @@ import {
|
|
|
29
29
|
} from '../hosts/installs.mjs';
|
|
30
30
|
import { PRESETS } from '../loop/score.mjs';
|
|
31
31
|
import { loadCatalog, catalogProblems } from '../loop/catalog.mjs';
|
|
32
|
-
import { activeLoops } from '../loop/registry.mjs';
|
|
32
|
+
import { activeLoops, runningLoops, sameRoot } from '../loop/registry.mjs';
|
|
33
|
+
import { activeFactories } from '../factory/registry.mjs';
|
|
34
|
+
import { factoryCatalogProblems, loopOf } from '../factory/graph.mjs';
|
|
33
35
|
import { EMIT_OPTIONS, themeOptions } from '../maintain/setup.mjs';
|
|
34
36
|
import { accentFor, keptKitFiles, statusData } from '../inspect/status.mjs';
|
|
35
37
|
import { writeTextAtomic } from '../lib/fs.mjs';
|
|
@@ -329,17 +331,15 @@ function builtAt(dir) {
|
|
|
329
331
|
* What Settings' Server panel says about the process answering it — built FIELD BY FIELD, never from the
|
|
330
332
|
* daemon record, which holds the write token: a GET is readable by anything that passes the Host
|
|
331
333
|
* check, and the token is the only guard on a POST. `started` is the process's own start (the
|
|
332
|
-
* server is the process), in epoch seconds. `autostart` is
|
|
333
|
-
*
|
|
334
|
-
* where
|
|
334
|
+
* server is the process), in epoch seconds. `autostart` is THIS platform's login launcher,
|
|
335
|
+
* `{file, state}` with state `absent`, `ours`, `stale` or `hand` (`autostartState`), so the row
|
|
336
|
+
* can name the file its confirmation writes; null where the platform has none.
|
|
335
337
|
*/
|
|
336
338
|
function serverFacts() {
|
|
337
|
-
const [vbs, plist] = autostartPaths();
|
|
338
|
-
const launcher = { win32: vbs, darwin: plist }[process.platform];
|
|
339
339
|
return {
|
|
340
340
|
pid: process.pid,
|
|
341
341
|
started: Math.floor(Date.now() / 1000 - process.uptime()),
|
|
342
|
-
autostart:
|
|
342
|
+
autostart: autostartState(),
|
|
343
343
|
};
|
|
344
344
|
}
|
|
345
345
|
|
|
@@ -460,8 +460,9 @@ export function apiOverview(state, counts = machineCounts(state, [{ install: nul
|
|
|
460
460
|
for (const [host, scope, root] of installTargets()) {
|
|
461
461
|
try {
|
|
462
462
|
if (samePath(viewCfg(host, scope, root), state.target)) {
|
|
463
|
-
// `deletionGate`/`secretsGate`/`doneGate`/`ownershipGate`: the gate
|
|
464
|
-
// Constitution page's toggles on rows IV, I, III
|
|
463
|
+
// `deletionGate`/`secretsGate`/`doneGate`/`testNote`/`ownershipGate`/`externalGate`: the gate
|
|
464
|
+
// switches, for the Constitution page's toggles on rows IV, I, III, VIII, inside the Credo's
|
|
465
|
+
// Ownership row and inside doctrine rigor 5's row.
|
|
465
466
|
install = { host, scope, path: root, footprint: footprintOfDir(root),
|
|
466
467
|
...gatesOfDir(root, host) };
|
|
467
468
|
break;
|
|
@@ -613,6 +614,46 @@ export function apiLoopsActive() {
|
|
|
613
614
|
return { loops: activeLoops() };
|
|
614
615
|
}
|
|
615
616
|
|
|
617
|
+
/**
|
|
618
|
+
* The Factories page's catalogue: every factory the install ROOT resolves (shipped, global,
|
|
619
|
+
* project, as `geneseed factory check` reads them), with the whole brick list — the graph draws a
|
|
620
|
+
* brick's `gate: human` badge and the mini ring places its ⛨ gate from `effect` — and the graph
|
|
621
|
+
* of every loop template a factory names (a `loop:<t>` stage, a fork's lanes included), so a
|
|
622
|
+
* `loop:` block can draw its ring. Read-only, like `apiLoops`.
|
|
623
|
+
*/
|
|
624
|
+
export function apiFactoriesCatalog(state) {
|
|
625
|
+
const catalog = loadCatalog({ projectRoot: state.root });
|
|
626
|
+
/** @type {(x: [string, any], y: [string, any]) => number} */
|
|
627
|
+
const byName = ([a], [b]) => (a < b ? -1 : 1);
|
|
628
|
+
const factories = [...catalog.factories].sort(byName).map(([name, { origin, ...factory }]) => ({
|
|
629
|
+
name, description: factory.description || '', origin, factory,
|
|
630
|
+
}));
|
|
631
|
+
const named = new Set(factories.flatMap(({ factory: f }) => (Array.isArray(f.stages) ? f.stages : []).map(loopOf).filter(Boolean)));
|
|
632
|
+
return {
|
|
633
|
+
factories,
|
|
634
|
+
bricks: [...catalog.bricks].sort(byName).map(([, b]) => ({ reason: null, ...b })),
|
|
635
|
+
loops: [...catalog.templates].filter(([n]) => named.has(n)).sort(byName)
|
|
636
|
+
.map(([name, { origin, ...graph }]) => ({ name, origin, graph })),
|
|
637
|
+
problems: factoryCatalogProblems(catalog),
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* The Factories › Active read: every run `geneseed factory init` registered (machine-wide, like
|
|
643
|
+
* `apiLoopsActive`), each with the loop running in its worktree as `loop` (the root is the join
|
|
644
|
+
* key, `js/factory/registry.mjs`), or null. `runningLoops`, not `activeLoops`: it is read-only,
|
|
645
|
+
* so this poll never prunes or stamps `loops.json` behind the Loops page's back.
|
|
646
|
+
*/
|
|
647
|
+
export function apiFactoriesActive() {
|
|
648
|
+
const loops = runningLoops();
|
|
649
|
+
return {
|
|
650
|
+
factories: activeFactories().map((run) => {
|
|
651
|
+
const l = loops.find((x) => sameRoot(x.root, run.root));
|
|
652
|
+
return { ...run, loop: l ? { title: l.title, status: l.status, node: l.node, iteration: l.iteration, graph: l.graph } : null };
|
|
653
|
+
}),
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
|
|
616
657
|
/**
|
|
617
658
|
* Is a newer release on npm than the source this console serves, and how would this copy take
|
|
618
659
|
* it? See update-check.mjs.
|
package/js/web/catalog.mjs
CHANGED
|
@@ -16,8 +16,10 @@ import { existsSync, readdirSync } from 'node:fs';
|
|
|
16
16
|
import path from 'node:path';
|
|
17
17
|
|
|
18
18
|
import { GLOBAL_MANIFEST, isGlobalInstall, resolvePath } from '../hosts/hosts.mjs';
|
|
19
|
-
import { doctrinesForBuild, excludedRulesOfDir, readMaybe } from '../hosts/installs.mjs';
|
|
20
|
-
import { frontmatter, readFacts } from '../hosts/memory-files.mjs';
|
|
19
|
+
import { EMIT_HOST_SCOPE, doctrinesForBuild, excludedRulesOfDir, readMaybe } from '../hosts/installs.mjs';
|
|
20
|
+
import { frontmatter, parseRules, readFacts } from '../hosts/memory-files.mjs';
|
|
21
|
+
import { emittedHost, sessionFiles } from '../hosts/hooks-context.mjs';
|
|
22
|
+
import { agentLoadout } from '../inspect/cost.mjs';
|
|
21
23
|
import {
|
|
22
24
|
SKILL_CLASS, entityStatus, loadRegistry, tuiInventory,
|
|
23
25
|
} from '../inspect/inventory.mjs';
|
|
@@ -801,3 +803,37 @@ export function apiItem(state, type, name, fleet = [{ install: null, state }]) {
|
|
|
801
803
|
}
|
|
802
804
|
throw new NotFound(type);
|
|
803
805
|
}
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* `GET /api/loadout` (the primary) and `/api/loadout/<agent>`: what one agent of the named install
|
|
809
|
+
* loads, and the rules it follows (spec 2026-11-08, agent loadout). The blocks are `agentLoadout`'s,
|
|
810
|
+
* the one writer of those figures (js/inspect/cost.mjs); this adds what only the install's
|
|
811
|
+
* inventory knows. `rules`: the Dictates, the doctrine rules built in (pack on, rule not excluded),
|
|
812
|
+
* and each user-rules layer's rules by their `R<n>` ids, as `/api/rules` parses them. An Adept's
|
|
813
|
+
* `citedBySpec` marks a rule its rendered spec cites: the render writes a citation as `*<Principle>*`,
|
|
814
|
+
* matched against this install's own rule names, so an unmatched name marks nothing. `noun` is the
|
|
815
|
+
* theme's name for the primary agent. An agent the install lacks, or no carrier, is a 404.
|
|
816
|
+
*/
|
|
817
|
+
export function apiLoadout(state, agent = 'primary') {
|
|
818
|
+
// The catalogue is the allowlist: the name becomes a path, and this GET carries no token.
|
|
819
|
+
if (agent !== 'primary' && !state.inventory.agents.some((a) => a.name === agent)) throw new NotFound(agent);
|
|
820
|
+
const [host] = EMIT_HOST_SCOPE.get(state.emit || '') ?? ['opencode'];
|
|
821
|
+
const loadout = agentLoadout({ host, root: state.root ?? state.target, dir: state.target, agent });
|
|
822
|
+
if (!loadout) throw new NotFound(agent);
|
|
823
|
+
const inv = state.inventory;
|
|
824
|
+
const body = agent === 'primary' ? '' : (inv.agents.find((a) => a.name === agent)?.body ?? '');
|
|
825
|
+
const cited = (title) => Boolean(body) && body.includes(`*${title.split(' \u00b7 ').pop()}*`);
|
|
826
|
+
const rules = [
|
|
827
|
+
...inv.laws.map((l) => ({ kind: 'dictate', id: l.num, title: l.title, citedBySpec: cited(l.title) })),
|
|
828
|
+
...(inv.doctrines ?? []).filter((p) => p.active).flatMap((p) => p.rules.filter((r) => r.active !== false)
|
|
829
|
+
.map((r) => ({ kind: 'doctrine', id: `${r.pack}.${r.n}`, title: r.title, citedBySpec: cited(r.title) }))),
|
|
830
|
+
];
|
|
831
|
+
let layers = [];
|
|
832
|
+
try { layers = sessionFiles(state.target, emittedHost(host)).filter((s) => s.rel === 'user-rules.md'); } catch { /* none */ }
|
|
833
|
+
for (const s of layers) {
|
|
834
|
+
for (const r of parseRules(s.text)[0]) {
|
|
835
|
+
rules.push({ kind: 'user', id: `R${r.id}`, title: r.title, layer: s.label || 'install', citedBySpec: false });
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
return { ...loadout, rules, noun: loadTheme(makeCfg(), state.theme).PRIMARY_AGENT ?? 'Primary agent' };
|
|
839
|
+
}
|
package/js/web/daemon.mjs
CHANGED
|
@@ -13,8 +13,9 @@ import { printOut, writeText } from '../lib/fs.mjs';
|
|
|
13
13
|
import { isTruthy, jsonDumpsCompact } from '../lib/json.mjs';
|
|
14
14
|
import { webState } from './state.mjs';
|
|
15
15
|
import { spawn } from 'node:child_process';
|
|
16
|
-
import { createHash } from 'node:crypto';
|
|
17
|
-
import { chmodSync, mkdirSync, openSync, readFileSync, unlinkSync } from 'node:fs';
|
|
16
|
+
import { createHash, createHmac, randomBytes } from 'node:crypto';
|
|
17
|
+
import { chmodSync, mkdirSync, openSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
18
|
+
import { createServer } from 'node:net';
|
|
18
19
|
import { join, resolve as pathResolve } from 'node:path';
|
|
19
20
|
|
|
20
21
|
const ROOT = pathResolve(import.meta.dirname, '..', '..');
|
|
@@ -44,6 +45,20 @@ export function daemonStale(record, root = ROOT) {
|
|
|
44
45
|
export const STALE_LINE = '[web] running OLD code (started before the last upgrade) — '
|
|
45
46
|
+ 'geneseed web restart';
|
|
46
47
|
|
|
48
|
+
/** The port a console asks for when none is named. */
|
|
49
|
+
export const DEFAULT_PORT = 4747;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Which install a console belongs to: a hash of this checkout's root, carried in `/api/ping` so a
|
|
53
|
+
* port holder can be told apart from a console of ANOTHER install without exposing a path. A
|
|
54
|
+
* console older than this field answers without one — its install is unknown, never assumed.
|
|
55
|
+
*/
|
|
56
|
+
export function rootId(root = ROOT) {
|
|
57
|
+
const p = pathResolve(root);
|
|
58
|
+
return createHash('sha256').update(process.platform === 'win32' ? p.toLowerCase() : p)
|
|
59
|
+
.digest('hex').slice(0, 12);
|
|
60
|
+
}
|
|
61
|
+
|
|
47
62
|
const statePath = (target) => join(target, '.geneseed-web.json');
|
|
48
63
|
|
|
49
64
|
export function readDaemon(target) {
|
|
@@ -75,7 +90,7 @@ export function clearDaemon(target) {
|
|
|
75
90
|
//
|
|
76
91
|
// `geneseed web start|stop|status|restart`. The running server records pid/port/token/url
|
|
77
92
|
// in a small JSON file and control is over HTTP, so nothing here needs OS process-kill
|
|
78
|
-
// semantics, only a localhost request with the token.
|
|
93
|
+
// semantics, only a localhost request with the token (or, for a console whose record is gone, the install secret).
|
|
79
94
|
//
|
|
80
95
|
// * Every function below that touches the network is `async` (`fetch` has no
|
|
81
96
|
// synchronous equivalent), and `cmdWeb` awaits it.
|
|
@@ -106,12 +121,93 @@ export async function probe(url, timeout = 1.5) {
|
|
|
106
121
|
}
|
|
107
122
|
}
|
|
108
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Is the answer on `port` a Geneseed console, and whose? `null` when nothing answers a console's
|
|
126
|
+
* ping (nothing there, or some other program). Otherwise `{ pid, root }`, `root` null for a
|
|
127
|
+
* console older than the field. The shape is the proof: `ok`, a string `theme` and an integer
|
|
128
|
+
* `pid`, which no foreign server has a reason to send.
|
|
129
|
+
*/
|
|
130
|
+
export async function identify(port, timeout = 0.5) {
|
|
131
|
+
try {
|
|
132
|
+
const res = await fetch(`http://127.0.0.1:${port}/api/ping`, {
|
|
133
|
+
signal: AbortSignal.timeout(Math.round(timeout * 1000)),
|
|
134
|
+
});
|
|
135
|
+
const body = res.status === 200 ? await res.json() : null;
|
|
136
|
+
await res.body?.cancel().catch(() => {});
|
|
137
|
+
if (body?.ok !== true || typeof body.theme !== 'string' || !validPid(body.pid)) return null;
|
|
138
|
+
return { pid: body.pid, root: typeof body.root === 'string' ? body.root : null };
|
|
139
|
+
} catch {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** A pid worth showing: an integer above 1. 0, 1 and negatives are never a console. */
|
|
145
|
+
const validPid = (p) => Number.isInteger(p) && p > 1;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The install's shutdown secret: 32 random bytes in an owner-only file next to the daemon
|
|
149
|
+
* record, created once and never rewritten. It lets a LATER `web start` end a console of this
|
|
150
|
+
* install whose record (and token) is gone. It is never sent: callers send `secretProof`, bound
|
|
151
|
+
* to the port, so a listener that merely claims our root learns nothing it can reuse elsewhere.
|
|
152
|
+
* `null` when the file can be neither read nor created — the feature is then off.
|
|
153
|
+
*/
|
|
154
|
+
export function webSecret(target) {
|
|
155
|
+
const p = join(target, '.geneseed-web-secret');
|
|
156
|
+
const read = () => { try { return readFileSync(p, 'utf-8').trim() || null; } catch { return null; } };
|
|
157
|
+
const have = read();
|
|
158
|
+
if (have) return have;
|
|
159
|
+
try {
|
|
160
|
+
mkdirSync(target, { recursive: true });
|
|
161
|
+
writeFileSync(p, randomBytes(32).toString('base64url'), { flag: 'wx', mode: 0o600 });
|
|
162
|
+
} catch { /* lost a race, or unwritable: read decides */ }
|
|
163
|
+
return read();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** What a caller sends in `X-Geneseed-Secret`: a MAC of the port under the secret, not the secret. */
|
|
167
|
+
export const secretProof = (secret, port) => createHmac('sha256', secret).update(`shutdown:${port}`).digest('hex');
|
|
168
|
+
|
|
169
|
+
/** Can a server bind `port` on loopback right now? `true` means something else holds it. */
|
|
170
|
+
export const portTaken = (port) => new Promise((resolve) => {
|
|
171
|
+
const s = createServer();
|
|
172
|
+
s.once('error', () => resolve(true));
|
|
173
|
+
s.listen(port, '127.0.0.1', () => s.close(() => resolve(false)));
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Free `port` for a new console, or say why not. `null` when it is free (possibly after ending
|
|
178
|
+
* the previous console of THIS install, found by its root id in the ping); otherwise a phrase
|
|
179
|
+
* naming the holder, and nothing touched. Another install's console, a console too old to name
|
|
180
|
+
* its install, and any other program are never ended.
|
|
181
|
+
*
|
|
182
|
+
* "Ends" means asking it to shut down with this install's secret (`secretProof`) and waiting for
|
|
183
|
+
* the port. A listener that only CLAIMS our root cannot honour the request, so nothing is ever
|
|
184
|
+
* ended on a claim, and no pid is ever signalled.
|
|
185
|
+
*/
|
|
186
|
+
export async function clearPort(port, target) {
|
|
187
|
+
if (!await portTaken(port)) return null;
|
|
188
|
+
const c = await identify(port);
|
|
189
|
+
if (c && c.root === rootId()) {
|
|
190
|
+
const secret = webSecret(target);
|
|
191
|
+
const asked = secret !== null && await postShutdown(`http://127.0.0.1:${port}`, '', 3.0,
|
|
192
|
+
{ 'X-Geneseed-Secret': secretProof(secret, port) });
|
|
193
|
+
for (let i = 0; asked && i < 50 && await portTaken(port); i += 1) await sleep(100);
|
|
194
|
+
if (asked && !await portTaken(port)) {
|
|
195
|
+
printOut(`[web] ended the previous console of this install on port ${port} (pid ${c.pid}).\n`);
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
return `held by a console (pid ${c.pid}) that claims this install but did not shut down on request`;
|
|
199
|
+
}
|
|
200
|
+
if (!c) return 'held by another program';
|
|
201
|
+
return `held by a Geneseed console (pid ${c.pid}) of ${c.root ? 'another install'
|
|
202
|
+
: 'an unknown install (older code) — end that pid yourself'}`;
|
|
203
|
+
}
|
|
204
|
+
|
|
109
205
|
/** The token-carrying POST `geneseed web stop` and the in-page Stop button both send. */
|
|
110
|
-
async function postShutdown(url, token, timeout = 3.0) {
|
|
206
|
+
async function postShutdown(url, token, timeout = 3.0, extra = {}) {
|
|
111
207
|
try {
|
|
112
208
|
const res = await fetch(`${url}/api/shutdown`, {
|
|
113
209
|
method: 'POST',
|
|
114
|
-
headers: { 'X-Geneseed-Token': token, 'Content-Type': 'application/json' },
|
|
210
|
+
headers: { 'X-Geneseed-Token': token, 'Content-Type': 'application/json', ...extra },
|
|
115
211
|
body: '{}',
|
|
116
212
|
signal: AbortSignal.timeout(Math.round(timeout * 1000)),
|
|
117
213
|
});
|
|
@@ -198,6 +294,13 @@ export function restartArgs(theme) {
|
|
|
198
294
|
* to stop, started a fresh daemon on 4747 while this process still held it, lost the bind,
|
|
199
295
|
* fell back to a random port, and left a background console nobody had asked for.
|
|
200
296
|
*/
|
|
297
|
+
export function restartRefusal(theme) {
|
|
298
|
+
const rec = readDaemon(webState(theme).target);
|
|
299
|
+
if (!isTruthy(rec) || !validPid(rec.pid)) return 'foreground server: restart it from its terminal';
|
|
300
|
+
return `this console (pid ${process.pid}) is not the recorded daemon — that one is on ${none(rec.url)} `
|
|
301
|
+
+ `(pid ${rec.pid}). Restart it there, or end pid ${process.pid}.`;
|
|
302
|
+
}
|
|
303
|
+
|
|
201
304
|
export function requestRestart(theme) {
|
|
202
305
|
const target = webState(theme).target;
|
|
203
306
|
if (readDaemon(target)?.pid !== process.pid) return false;
|
|
@@ -272,6 +375,9 @@ export async function startDaemon(theme, port, openBrowser = true) {
|
|
|
272
375
|
return 0;
|
|
273
376
|
}
|
|
274
377
|
clearDaemon(target);
|
|
378
|
+
const held = await clearPort(port, target);
|
|
379
|
+
if (held) printOut(`[web] port ${port} is ${held} — not touching it; the console will use another port.
|
|
380
|
+
`);
|
|
275
381
|
const log = join(target, '.geneseed-web.log');
|
|
276
382
|
spawnDetached(daemonArgs(port, theme), log);
|
|
277
383
|
// Twelve seconds for the child to bind and write its record (60 * 200ms). The probe
|
|
@@ -282,6 +388,8 @@ export async function startDaemon(theme, port, openBrowser = true) {
|
|
|
282
388
|
if (rec && isTruthy(rec.url) && await probe(rec.url, 0.5)) {
|
|
283
389
|
printOut(`[web] Geneseed UI on ${rec.url} (theme: ${none(rec.theme)}, `
|
|
284
390
|
+ `pid ${none(rec.pid)})\n`);
|
|
391
|
+
if (rec.port !== port) printOut(`[web] asked for port ${port}, serving on port ${rec.port} instead.
|
|
392
|
+
`);
|
|
285
393
|
printOut('[web] running in the background — `geneseed web stop` to stop it.\n');
|
|
286
394
|
if (openBrowser) openUrl(rec.url);
|
|
287
395
|
return 0;
|
|
@@ -355,19 +463,41 @@ export async function stopDaemon(theme = null, port = null) {
|
|
|
355
463
|
return 0;
|
|
356
464
|
}
|
|
357
465
|
|
|
358
|
-
|
|
466
|
+
/** Every Geneseed console answering on the recorded port or `ports`, each once. */
|
|
467
|
+
export async function findConsoles(target, ports) {
|
|
468
|
+
const rec = readDaemon(target);
|
|
469
|
+
const all = [...new Set([isTruthy(rec) ? Number(rec.port) : null, ...ports].filter(Number.isInteger))];
|
|
470
|
+
const found = [];
|
|
471
|
+
for (const p of all) {
|
|
472
|
+
// eslint-disable-next-line no-await-in-loop
|
|
473
|
+
const c = await identify(p);
|
|
474
|
+
if (c) found.push({ port: p, url: `http://127.0.0.1:${p}`, pid: c.pid, root: c.root,
|
|
475
|
+
recorded: isTruthy(rec) && rec.pid === c.pid && Number(rec.port) === p });
|
|
476
|
+
}
|
|
477
|
+
return found;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
const whose = (c) => (c.root === null ? 'older code, install unknown' : c.root === rootId() ? 'this install' : 'another install');
|
|
481
|
+
|
|
482
|
+
export async function statusDaemon(theme = null, port = null, scan = [DEFAULT_PORT]) {
|
|
359
483
|
const { target } = webState(theme);
|
|
360
484
|
const refused = await portRefusal(readDaemon(target), port, 'status');
|
|
361
485
|
if (refused !== null) return refused;
|
|
362
486
|
const st = await liveDaemon(target);
|
|
487
|
+
// Unnamed port only: `--port` already scoped this call to one daemon (`portRefusal`).
|
|
488
|
+
const others = port === null ? (await findConsoles(target, scan)).filter((c) => !(st && c.recorded)) : [];
|
|
489
|
+
const listOthers = () => others.forEach((c) => printOut(
|
|
490
|
+
`[web] also found a Geneseed console at ${c.url} (pid ${c.pid}, not recorded — ${whose(c)})\n`));
|
|
363
491
|
if (st) {
|
|
364
492
|
printOut(`[web] running on ${st.url} (theme: ${none(st.theme)}, pid ${none(st.pid)})\n`);
|
|
365
493
|
if (daemonStale(st)) printOut(`${STALE_LINE}\n`);
|
|
494
|
+
listOthers();
|
|
366
495
|
return 0;
|
|
367
496
|
}
|
|
368
497
|
// EXIT 1, which is the verb's whole contract for a script. The snapshot's `<exit>`
|
|
369
498
|
// column is what gates it.
|
|
370
499
|
printOut('[web] not running.\n');
|
|
500
|
+
listOthers();
|
|
371
501
|
return 1;
|
|
372
502
|
}
|
|
373
503
|
|
package/js/web/handler.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
rebuildCmds,
|
|
20
20
|
} from './actions.mjs';
|
|
21
21
|
import { BadRequest, NotFound } from './catalog.mjs';
|
|
22
|
-
import { openFolder, requestRestart } from './daemon.mjs';
|
|
22
|
+
import { openFolder, requestRestart, restartRefusal, rootId, secretProof } from './daemon.mjs';
|
|
23
23
|
import { apiDocs, apiDocsPage } from './docs.mjs';
|
|
24
24
|
import { actionCommands, updatePlan } from './jobs.mjs';
|
|
25
25
|
import {
|
|
@@ -71,8 +71,11 @@ export function securityHeaders(nonce) {
|
|
|
71
71
|
* - `/api/*`: a cross-site or same-site fetch, or a foreign `Origin`, is refused even on GET —
|
|
72
72
|
* the reads expose paths and memories. A request with neither header (curl, Node) passes.
|
|
73
73
|
* - Any non-GET: the CSRF token, compared in constant time so its bytes cannot be timed out.
|
|
74
|
+
* `/api/shutdown` alone also takes `X-Geneseed-Secret`: a MAC of this socket's port under the
|
|
75
|
+
* install secret (`secretProof`), so `web start` can end its own unrecorded console. Same Host and
|
|
76
|
+
* Origin guards above, same constant-time compare; a wrong proof falls through to the token check.
|
|
74
77
|
*/
|
|
75
|
-
export function requestGuard(req, token) {
|
|
78
|
+
export function requestGuard(req, token, secret = null) {
|
|
76
79
|
const host = req.headers.host || '';
|
|
77
80
|
// Exact `name:port`, not `localHost` + a suffix test: that pair let `[::1]x.evil:4747` and
|
|
78
81
|
// `localhost:1:4747` through. Lower-cased the way browsers send it.
|
|
@@ -91,6 +94,12 @@ export function requestGuard(req, token) {
|
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
if (req.method !== 'GET') {
|
|
97
|
+
const proof = req.headers['x-geneseed-secret'];
|
|
98
|
+
if (secret && path === '/api/shutdown' && typeof proof === 'string') {
|
|
99
|
+
const have = Buffer.from(proof, 'utf-8');
|
|
100
|
+
const need = Buffer.from(secretProof(secret, req.socket.localPort), 'utf-8');
|
|
101
|
+
if (have.length === need.length && timingSafeEqual(have, need)) return null;
|
|
102
|
+
}
|
|
94
103
|
const got = Buffer.from(String(req.headers['x-geneseed-token'] ?? ''), 'utf-8');
|
|
95
104
|
const want = Buffer.from(token, 'utf-8');
|
|
96
105
|
if (got.length !== want.length || !timingSafeEqual(got, want)) {
|
|
@@ -222,7 +231,7 @@ export function makeHandler(state, jm, token, dist, holder = null) {
|
|
|
222
231
|
// `pid` is what a restarting client waits on: the OLD server keeps answering this ping for
|
|
223
232
|
// a moment after `/api/restart` returns, and a reload onto it fetches the old token.
|
|
224
233
|
if (path === '/api/ping') {
|
|
225
|
-
return sendJson(res, { ok: true, theme: state.theme, pid: process.pid }, 200, ae);
|
|
234
|
+
return sendJson(res, { ok: true, theme: state.theme, pid: process.pid, root: rootId() }, 200, ae);
|
|
226
235
|
}
|
|
227
236
|
for (const [prefix, handler] of PREFIX_ROUTES) {
|
|
228
237
|
if (path.startsWith(prefix)) return sendJson(res, handler(st, path, state), 200, ae);
|
|
@@ -268,7 +277,7 @@ export function makeHandler(state, jm, token, dist, holder = null) {
|
|
|
268
277
|
if (jm.busy) return sendJson(res, BUSY, 409, ae);
|
|
269
278
|
if (!requestRestart(state.theme)) {
|
|
270
279
|
return sendJson(res,
|
|
271
|
-
{ error:
|
|
280
|
+
{ error: restartRefusal(state.theme) }, 409, ae);
|
|
272
281
|
}
|
|
273
282
|
return sendJson(res, { restarting: true }, 200, ae);
|
|
274
283
|
}
|
|
@@ -447,7 +456,7 @@ export function makeHandler(state, jm, token, dist, holder = null) {
|
|
|
447
456
|
const path = (req.url || '').split('?', 1)[0];
|
|
448
457
|
try {
|
|
449
458
|
// GUARD FIRST, BODY SECOND: a refused request is DISCARDED (`resume`, nothing buffered).
|
|
450
|
-
const refused = requestGuard(req, token);
|
|
459
|
+
const refused = requestGuard(req, token, holder?.secret);
|
|
451
460
|
if (refused) {
|
|
452
461
|
sendJson(res, refused.body, refused.code, ae);
|
|
453
462
|
return req.resume();
|
package/js/web/routes.mjs
CHANGED
|
@@ -17,13 +17,13 @@
|
|
|
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
|
-
apiDefaultInstallSet, apiDiff, apiDoctor, apiExcludes, apiFleet, apiInstalls, apiKits, apiLoops, apiLoopsActive, apiOverview, memoCounts,
|
|
23
|
+
apiDefaultInstallSet, apiDiff, apiDoctor, apiExcludes, apiFleet, apiInstalls, apiKits, apiLoops, apiLoopsActive, apiFactoriesCatalog, apiFactoriesActive, apiOverview, memoCounts,
|
|
24
24
|
apiRecent, apiSetup, apiThemes, activeInstalls, apiUpdate,
|
|
25
25
|
} from './api.mjs';
|
|
26
|
-
import { FLEET_SECTIONS, NotFound, apiCatalog, apiItem } from './catalog.mjs';
|
|
26
|
+
import { FLEET_SECTIONS, NotFound, apiCatalog, apiItem, apiLoadout } 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';
|
|
@@ -62,6 +62,7 @@ export const POST_ROUTES = new Map([
|
|
|
62
62
|
// unknown preset) throw `NotFound`, which `doPost`'s catch answers 404 before this column is
|
|
63
63
|
// ever consulted — the same shape as `/api/memory/delete` and `/api/activity` above.
|
|
64
64
|
['/api/loops/preset', [apiLoopsPresetMutate, false]],
|
|
65
|
+
['/api/autostart', [apiAutostart, true]],
|
|
65
66
|
]);
|
|
66
67
|
|
|
67
68
|
/**
|
|
@@ -89,7 +90,7 @@ export const VIEW_POSTS = new Set(['/api/activity', '/api/memory/delete', '/api/
|
|
|
89
90
|
* section, and `/api/item/`, stay install-scoped (`PREFIX_ROUTES`).
|
|
90
91
|
*/
|
|
91
92
|
export const MACHINE_GETS = new Set(['/api/update', '/api/installs', '/api/fleet', '/api/migrate/preview', '/api/kits',
|
|
92
|
-
'/api/usage', '/api/gates', '/api/excludes', '/api/mcp', '/api/loops/active', '/api/activity',
|
|
93
|
+
'/api/usage', '/api/gates', '/api/excludes', '/api/mcp', '/api/loops/active', '/api/factories/active', '/api/activity',
|
|
93
94
|
'/api/catalog/skills', '/api/catalog/agents', '/api/catalog/memory', '/api/catalog/notebook',
|
|
94
95
|
'/api/catalog/wiki', '/api/catalog/config']);
|
|
95
96
|
|
|
@@ -183,6 +184,9 @@ export const PREFIX_ROUTES = [
|
|
|
183
184
|
const fleet = m[1] !== 'law' ? fleetOf(base) : undefined;
|
|
184
185
|
return apiItem(state, m[1], percentDecode(m[2]), fleet);
|
|
185
186
|
}],
|
|
187
|
+
// /api/loadout/<agent> — one Adept's loadout in the named install (`apiLoadout`); the primary
|
|
188
|
+
// is the bare `/api/loadout`, since it is no catalogue item.
|
|
189
|
+
['/api/loadout/', (state, p) => apiLoadout(state, percentDecode(p.slice('/api/loadout/'.length)) || 'primary')],
|
|
186
190
|
// The sid is passed through unquoted — `apiActivityDetail`'s safe-name scheme is what
|
|
187
191
|
// makes the lookup safe, rather than a check out here.
|
|
188
192
|
['/api/activity/', (state, p) => apiActivityDetail(
|
|
@@ -219,7 +223,11 @@ export const STATE_ROUTES = {
|
|
|
219
223
|
// line indices, and the fingerprint every mutation must send back is what this GET
|
|
220
224
|
// answers — a daemon whose POST worked and whose GET 501'd would have no way to obtain one.
|
|
221
225
|
'/api/rules': apiRules,
|
|
226
|
+
'/api/loadout': (state) => apiLoadout(state),
|
|
222
227
|
'/api/mcp': apiMcp,
|
|
223
228
|
'/api/loops': apiLoops,
|
|
224
229
|
'/api/loops/active': apiLoopsActive,
|
|
230
|
+
// The spec's names (C11): the catalogue is install-scoped like `/api/loops`, runs machine-wide.
|
|
231
|
+
'/api/factories/catalog': apiFactoriesCatalog,
|
|
232
|
+
'/api/factories/active': apiFactoriesActive,
|
|
225
233
|
};
|
package/js/web/server.mjs
CHANGED
|
@@ -29,7 +29,7 @@ import { parseIntStrict } from '../lib/text.mjs';
|
|
|
29
29
|
import { promptLine } from '../lib/prompt.mjs';
|
|
30
30
|
import { deployed } from './catalog.mjs';
|
|
31
31
|
import { defaultView, warmDoctor, webState } from './state.mjs';
|
|
32
|
-
import { clearDaemon, codeStamp, openUrl, readDaemon, restartDaemon, startDaemon, statusDaemon, stopDaemon, writeDaemon } from './daemon.mjs';
|
|
32
|
+
import { clearDaemon, codeStamp, openUrl, webSecret, readDaemon, restartDaemon, startDaemon, statusDaemon, stopDaemon, writeDaemon } from './daemon.mjs';
|
|
33
33
|
import { makeHandler } from './handler.mjs';
|
|
34
34
|
import { JobManager } from './jobs.mjs';
|
|
35
35
|
import { spawnSync } from 'node:child_process';
|
|
@@ -165,9 +165,12 @@ export async function serve({ theme = null, port = 4747, openBrowser = true,
|
|
|
165
165
|
srv.requestTimeout = 30_000;
|
|
166
166
|
srv.headersTimeout = 10_000;
|
|
167
167
|
holder.srv = srv;
|
|
168
|
+
// The install's shutdown secret, only when a daemon: a foreground server is not ended by `web start`.
|
|
169
|
+
if (daemon) holder.secret = webSecret(home);
|
|
168
170
|
return new Promise((done) => {
|
|
169
171
|
srv.on('error', () => {
|
|
170
172
|
// On a listen error, retry with port 0 so the OS picks a free one.
|
|
173
|
+
printOut(`[web] port ${port} is taken by another process — using a free port instead.\n`);
|
|
171
174
|
srv.listen(0, '127.0.0.1', () => ready());
|
|
172
175
|
});
|
|
173
176
|
srv.listen(port, '127.0.0.1', () => ready());
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"//": "Every field here is argued and gated in tests/unit/package_manifest.test.mjs. `files`, `bin`, `exports` and `engines` each have a test that fails when reality drifts from this file; `version` mirrors harness.config.json and is gated too. Read that docblock before editing this one.",
|
|
3
3
|
"name": "geneseed",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.4",
|
|
5
5
|
"description": "A portable, theme-able harness you implant once and use everywhere to grow a disciplined AI coding agent.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"ai",
|
package/registry.json
CHANGED
|
@@ -302,6 +302,20 @@
|
|
|
302
302
|
"added": "2026-09-30",
|
|
303
303
|
"last_verified": "2026-10-13"
|
|
304
304
|
},
|
|
305
|
+
"skills/factory": {
|
|
306
|
+
"status": "experimental",
|
|
307
|
+
"version": "0.1.0",
|
|
308
|
+
"owner": "Guillaume Lemer",
|
|
309
|
+
"added": "2026-11-08",
|
|
310
|
+
"last_verified": ""
|
|
311
|
+
},
|
|
312
|
+
"skills/factory-forge": {
|
|
313
|
+
"status": "experimental",
|
|
314
|
+
"version": "0.1.0",
|
|
315
|
+
"owner": "Guillaume Lemer",
|
|
316
|
+
"added": "2026-11-08",
|
|
317
|
+
"last_verified": ""
|
|
318
|
+
},
|
|
305
319
|
"skills/forge-mcp": {
|
|
306
320
|
"status": "approved",
|
|
307
321
|
"version": "1.0.0",
|
|
@@ -574,6 +588,27 @@
|
|
|
574
588
|
"owner": "Guillaume Lemer",
|
|
575
589
|
"added": "2026-09-06",
|
|
576
590
|
"last_verified": "2026-10-13"
|
|
591
|
+
},
|
|
592
|
+
"skills/compose-ops": {
|
|
593
|
+
"status": "experimental",
|
|
594
|
+
"version": "1.0.0",
|
|
595
|
+
"owner": "Guillaume Lemer",
|
|
596
|
+
"added": "2026-11-08",
|
|
597
|
+
"last_verified": ""
|
|
598
|
+
},
|
|
599
|
+
"skills/gitlab-ci": {
|
|
600
|
+
"status": "experimental",
|
|
601
|
+
"version": "1.0.0",
|
|
602
|
+
"owner": "Guillaume Lemer",
|
|
603
|
+
"added": "2026-11-08",
|
|
604
|
+
"last_verified": ""
|
|
605
|
+
},
|
|
606
|
+
"skills/jenkins-pipeline": {
|
|
607
|
+
"status": "experimental",
|
|
608
|
+
"version": "1.0.0",
|
|
609
|
+
"owner": "Guillaume Lemer",
|
|
610
|
+
"added": "2026-11-08",
|
|
611
|
+
"last_verified": ""
|
|
577
612
|
}
|
|
578
613
|
}
|
|
579
614
|
}
|