geneseed 5.0.4 → 5.1.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 +45 -0
- package/SHIPPED.md +1 -1
- package/docs/concepts/exclusions.md +1 -1
- package/docs/concepts/factories.md +67 -15
- package/docs/concepts/loop-gates.md +5 -2
- package/docs/concepts/shared-tier.md +14 -0
- package/docs/extending.md +1 -1
- package/docs/guides/migrate.md +1 -1
- package/docs/guides/run-a-factory.md +41 -13
- package/docs/guides/upgrade-to-5.md +2 -2
- package/docs/reference/factory-actions.md +7 -7
- package/docs/web-ui.md +18 -6
- package/harness.config.json +1 -1
- package/js/README.md +2 -1
- package/js/build/args.mjs +34 -14
- package/js/build/emit-claude.mjs +3 -0
- package/js/build/emit-opencode.mjs +4 -0
- package/js/build/retired-skills.mjs +158 -0
- package/js/build/source.mjs +31 -11
- package/js/cli-table.json +29 -3
- package/js/factory/cli.mjs +49 -8
- package/js/factory/graph.mjs +72 -8
- package/js/factory/state.mjs +109 -27
- package/js/hosts/done-checks.mjs +3 -2
- package/js/hosts/memory-files.mjs +4 -2
- package/js/loop/catalog.mjs +16 -10
- package/js/loop/cli.mjs +16 -10
- package/js/maintain/migrate.mjs +39 -25
- package/js/web/daemon.mjs +69 -14
- package/js/web/handler.mjs +22 -9
- package/package.json +1 -1
- package/src/bricks/checks.md +62 -0
- package/src/bricks/intake.md +15 -6
- package/src/bricks/merge-gate.md +17 -8
- package/src/bricks/retro.md +8 -3
- package/src/bricks/review-panel.md +43 -0
- package/src/bricks/spec.md +20 -6
- package/src/factories/analysis-to-build.json +25 -7
- package/src/factories/bug-report-to-fix.json +25 -7
- package/src/factories/issue-to-pr.json +29 -11
- package/src/skills/factory-forge.md +23 -5
- package/src/skills/factory.md +95 -25
- package/src/skills/loop.md +3 -2
- package/themes/_TEMPLATE.json +1 -1
- package/web/dist/assets/{Activity-BaoxwVFH.js → Activity-CpkBwpu7.js} +1 -1
- package/web/dist/assets/{ActivityDetail-C_bFD0rW.js → ActivityDetail-DTPziZWM.js} +1 -1
- package/web/dist/assets/{Bonsai-B01lLf0m.js → Bonsai-hiG_gGNU.js} +1 -1
- package/web/dist/assets/{CopyButton-Bc66KPyA.js → CopyButton-DUIUfNp6.js} +1 -1
- package/web/dist/assets/{Dashboard-X7GZzGJp.js → Dashboard-Dnw6EyX7.js} +2 -2
- package/web/dist/assets/{Docs-LRYVnGLG.js → Docs-BEET_l16.js} +1 -1
- package/web/dist/assets/Factories-D6KXkfWw.js +1 -0
- package/web/dist/assets/{GreenhouseView-CfWR2-sX.js → GreenhouseView-BKxy5apE.js} +1 -1
- package/web/dist/assets/{Installs-nfFHnovH.js → Installs-CnFVlVD0.js} +1 -1
- package/web/dist/assets/{JournalView-lpOHcHKK.js → JournalView-ChFitHjo.js} +1 -1
- package/web/dist/assets/{Kits-Bw5EQl_i.js → Kits-CcR-OlwQ.js} +1 -1
- package/web/dist/assets/{Laws-CnZJ0wjZ.js → Laws-B1s5idOg.js} +1 -1
- package/web/dist/assets/LibRows-BZgdbI1l.js +1 -0
- package/web/dist/assets/Library-x6TkkEVF.js +3 -0
- package/web/dist/assets/{Loops-ZaHC5MVl.js → Loops-BH93KKxn.js} +1 -1
- package/web/dist/assets/{OperatorHudView-CggG0_sK.js → OperatorHudView-BO0aIKPL.js} +1 -1
- package/web/dist/assets/{Personal-BObvlb70.js → Personal-CE_0Vhh0.js} +1 -1
- package/web/dist/assets/{Settings-BFfPMPc9.js → Settings-CbpZvVN_.js} +1 -1
- package/web/dist/assets/{Tabs-B594Pad_.js → Tabs-C2oW7oEj.js} +1 -1
- package/web/dist/assets/{index-DsLmKHw0.js → index-BQwOmbor.js} +2 -2
- package/web/dist/assets/{index-DvPjphz0.css → index-CuIop_pO.css} +1 -1
- package/web/dist/index.html +2 -2
- package/web/dist/assets/Factories-ARenKBiP.js +0 -1
- package/web/dist/assets/LibRows-Hqvf1beK.js +0 -1
- package/web/dist/assets/Library-JaSsp6Yr.js +0 -3
package/js/build/args.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { withPlatformNewlines } from '../lib/fs.mjs';
|
|
|
12
12
|
import path from 'node:path';
|
|
13
13
|
import {
|
|
14
14
|
CONFIG, discoverNames, GATE_SWITCHES, PACK_ORDER, SRC, knownRuleIds, knownSkillIds, linkedSkillIds, loadKits,
|
|
15
|
-
resolveSkillNames, retiredRuleAddresses, skillAliases,
|
|
15
|
+
resolveSkillNames, retiredRuleAddresses, reusedRuleAddresses, ruleCanon, skillAliases,
|
|
16
16
|
} from './source.mjs';
|
|
17
17
|
// The loop engine's trust presets — the `--trust` choices. `score.mjs` imports nothing, which is
|
|
18
18
|
// what lets it sit inside this module's `child_process` ban.
|
|
@@ -30,14 +30,14 @@ const EMITS = ['files', 'opencode', 'opencode-global', 'claude', 'claude-global'
|
|
|
30
30
|
* stays as it was: stderr was once compared byte-for-byte across the two CLIs, and nothing
|
|
31
31
|
* pins it now.
|
|
32
32
|
*/
|
|
33
|
-
export function configDefaults() {
|
|
33
|
+
export function configDefaults(config = CONFIG, rules = ruleCanon(SRC).rules) {
|
|
34
34
|
const d = {
|
|
35
35
|
theme: 'neutral', posture: 'peer', mode: 'direct', trust: DEFAULT_PRESET,
|
|
36
36
|
doctrines: [...PACK_ORDER], excludeRules: [], excludeSkills: [], kits: [],
|
|
37
37
|
};
|
|
38
|
-
if (!existsSync(
|
|
38
|
+
if (!existsSync(config)) return d;
|
|
39
39
|
try {
|
|
40
|
-
const data = JSON.parse(readFileSync(
|
|
40
|
+
const data = JSON.parse(readFileSync(config, 'utf8'));
|
|
41
41
|
if (data && typeof data === 'object' && !Array.isArray(data)) {
|
|
42
42
|
if (data.theme !== undefined) d.theme = data.theme;
|
|
43
43
|
if (data.posture !== undefined) d.posture = data.posture;
|
|
@@ -52,7 +52,7 @@ export function configDefaults() {
|
|
|
52
52
|
if (Array.isArray(data.doctrines) && data.doctrines.every((x) => known.includes(x))) {
|
|
53
53
|
d.doctrines = PACK_ORDER.filter((p) => data.doctrines.includes(p));
|
|
54
54
|
} else {
|
|
55
|
-
process.stderr.write(`[geneseed] WARN: ${path.basename(
|
|
55
|
+
process.stderr.write(`[geneseed] WARN: ${path.basename(config)} "doctrines" is not a `
|
|
56
56
|
+ 'list of known pack names — using all packs.\n');
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -66,27 +66,28 @@ export function configDefaults() {
|
|
|
66
66
|
// passed through lands in the `Excluded rules:` marker, `rebuild-all` hands it back
|
|
67
67
|
// as a flag, and `parseExcludeRules` dies on it — every rebuild of that install,
|
|
68
68
|
// forever. Unknown ids are dropped with a WARN; the known ones still bind.
|
|
69
|
-
const known = knownRuleIds();
|
|
69
|
+
const known = knownRuleIds(rules);
|
|
70
70
|
const retired = retiredRuleAddresses(known);
|
|
71
71
|
const ids = data.excludeRules.map((x) => x.trim().replace(/[ \t]+/, '.'));
|
|
72
72
|
for (const id of ids.filter((x) => retired.has(x))) {
|
|
73
|
-
warnRetiredRule(id, retired, `${path.basename(
|
|
73
|
+
warnRetiredRule(id, retired, `${path.basename(config)} "excludeRules"`);
|
|
74
74
|
}
|
|
75
75
|
const unknown = ids.filter((id) => !known.includes(id) && !retired.has(id));
|
|
76
76
|
if (unknown.length) {
|
|
77
|
-
process.stderr.write(`[geneseed] WARN: ${path.basename(
|
|
77
|
+
process.stderr.write(`[geneseed] WARN: ${path.basename(config)} "excludeRules" names `
|
|
78
78
|
+ `unknown rule(s) ${unknown.map((id) => `'${id.replace('.', ' ')}'`).join(', ')}`
|
|
79
79
|
+ ' — ignoring them.\n');
|
|
80
80
|
}
|
|
81
81
|
d.excludeRules = [...new Set(ids.filter((id) => known.includes(id)))].sort();
|
|
82
|
+
warnReusedRules(d.excludeRules, `${path.basename(config)} "excludeRules"`, reusedRuleAddresses(rules));
|
|
82
83
|
} else {
|
|
83
|
-
process.stderr.write(`[geneseed] WARN: ${path.basename(
|
|
84
|
+
process.stderr.write(`[geneseed] WARN: ${path.basename(config)} "excludeRules" is `
|
|
84
85
|
+ 'not a list of rule addresses — excluding nothing.\n');
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
} catch {
|
|
89
|
-
process.stderr.write(`[geneseed] WARN: ${path.basename(
|
|
90
|
+
process.stderr.write(`[geneseed] WARN: ${path.basename(config)} is unreadable — `
|
|
90
91
|
+ "using theme 'neutral'.\n");
|
|
91
92
|
}
|
|
92
93
|
return d;
|
|
@@ -174,10 +175,10 @@ function choicesFor() {
|
|
|
174
175
|
* can least afford: the user asked for a rule to STOP binding and it would keep binding.
|
|
175
176
|
* Sorted, deduped, for the same marker-stability reason `--doctrines` is.
|
|
176
177
|
*/
|
|
177
|
-
function parseExcludeRules(value) {
|
|
178
|
+
export function parseExcludeRules(value, rules = ruleCanon(SRC).rules) {
|
|
178
179
|
const s = value.trim();
|
|
179
180
|
if (s === 'none' || s === '') return [];
|
|
180
|
-
const known = knownRuleIds();
|
|
181
|
+
const known = knownRuleIds(rules);
|
|
181
182
|
const retired = retiredRuleAddresses(known);
|
|
182
183
|
const out = [];
|
|
183
184
|
for (const raw of s.split(',').map((x) => x.trim()).filter(Boolean)) {
|
|
@@ -189,13 +190,32 @@ function parseExcludeRules(value) {
|
|
|
189
190
|
}
|
|
190
191
|
out.push(id);
|
|
191
192
|
}
|
|
193
|
+
warnReusedRules(out, '--exclude-rules', reusedRuleAddresses(rules));
|
|
192
194
|
return [...new Set(out)].sort();
|
|
193
195
|
}
|
|
194
196
|
|
|
195
|
-
/**
|
|
197
|
+
/**
|
|
198
|
+
* One stderr line for a retired address: it excludes nothing now, and the build goes on. The
|
|
199
|
+
* entry's `effect`, when set, says what the old exclusion no longer does.
|
|
200
|
+
*/
|
|
196
201
|
function warnRetiredRule(id, retired, where) {
|
|
202
|
+
const { note, effect } = retired.get(id);
|
|
197
203
|
process.stderr.write(`[geneseed] WARN: ${where}: '${id.replace('.', ' ')}' was retired `
|
|
198
|
-
+ `(${
|
|
204
|
+
+ `(${note})${effect ? `: ${effect}` : ''} — ignoring it.\n`);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* A loud stderr line for each id in `ids` whose address a retired rule held and a different live
|
|
209
|
+
* rule holds now (`reusedRuleAddresses`): the exclusion binds the NEW rule, which an entry written
|
|
210
|
+
* for the old one never meant. It still binds — the line names both rules so a human decides.
|
|
211
|
+
*/
|
|
212
|
+
export function warnReusedRules(ids, where, reused = reusedRuleAddresses()) {
|
|
213
|
+
for (const id of ids.filter((x) => reused.has(x))) {
|
|
214
|
+
const { old, note, now } = reused.get(id);
|
|
215
|
+
process.stderr.write(`[geneseed] WARN: ${where}: '${id.replace('.', ' ')}' NOW EXCLUDES `
|
|
216
|
+
+ `${now.name} (${now.id}), NOT the retired ${old} (${note}) that held this address before. `
|
|
217
|
+
+ `If this exclusion was written for ${old}, remove it.\n`);
|
|
218
|
+
}
|
|
199
219
|
}
|
|
200
220
|
|
|
201
221
|
/**
|
package/js/build/emit-claude.mjs
CHANGED
|
@@ -17,6 +17,7 @@ import { get, isDict, isTruthy } from '../lib/json.mjs';
|
|
|
17
17
|
import { relPosix } from '../lib/text.mjs';
|
|
18
18
|
import { assertSourceComplete, phaseLog, ensureMemoryStore } from './bundle.mjs';
|
|
19
19
|
import { foldOnEmit } from './fold.mjs';
|
|
20
|
+
import { pruneRetiredSkills } from './retired-skills.mjs';
|
|
20
21
|
import {
|
|
21
22
|
claimAndWrite, globalMemory, globalNotebook, shipLeanLaws, stripCapabilityLinks,
|
|
22
23
|
} from './emit-common.mjs';
|
|
@@ -124,6 +125,8 @@ export function emitClaudeRender(cfg, job) {
|
|
|
124
125
|
// One shared `claim` (see `claimer`): the skills/agents writer and the Bob command writer
|
|
125
126
|
// below both push into the same `owned` list, so a pre-manifest-install warning still
|
|
126
127
|
// prints once across the whole emit rather than once per writer.
|
|
128
|
+
// Before the claim: a retired folder freed here lets this emit write the alias that replaces it.
|
|
129
|
+
if (sharedRoot !== null) pruneRetiredSkills(host, cfgDir, oldOwned);
|
|
127
130
|
const claim = claimer(oldOwned, cfgDir, true, oldHashes);
|
|
128
131
|
const { nAgents, nSkills, written } = writeNativeLayer(
|
|
129
132
|
items, path.join(cfgDir, 'agents'), path.join(cfgDir, 'skills'),
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
claimAndWrite, globalMemory, globalNotebook, shipLeanLaws, stripCapabilityLinks,
|
|
22
22
|
} from './emit-common.mjs';
|
|
23
23
|
import { foldOnEmit } from './fold.mjs';
|
|
24
|
+
import { pruneRetiredSkills } from './retired-skills.mjs';
|
|
24
25
|
import { renderAll } from './render.mjs';
|
|
25
26
|
import {
|
|
26
27
|
ensureExcludesStub, ensureNotebookIndex, ensureProfileStub, ensureRulesStub,
|
|
@@ -220,6 +221,9 @@ export function emitOpencodeGlobalRender(cfg, job) {
|
|
|
220
221
|
// Co-owned, so never in `owned` — see `opencodeSentinelWrite`.
|
|
221
222
|
opencodeSentinelWrite(cfgDir);
|
|
222
223
|
|
|
224
|
+
// As in `emitClaudeRender`: before the skill layer claims anything.
|
|
225
|
+
if (sharedRoot !== null) pruneRetiredSkills('opencode', cfgDir, oldOwned);
|
|
226
|
+
|
|
223
227
|
// `manifestExisted` is deliberately not passed, so
|
|
224
228
|
// the pre-manifest header line is unreachable from this emit.
|
|
225
229
|
const {
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retired skill folders — `skills/<name>` that an earlier build rendered under a name this one no
|
|
3
|
+
* longer ships (an `aliases:` marker or a `RETIRED_SKILL_IDS` entry), that no manifest owns, and
|
|
4
|
+
* that no emit would therefore ever prune. The user decided (2026-11-09) that such a folder is
|
|
5
|
+
* Geneseed's leftover, not their change: every canonical global emit moves it aside.
|
|
6
|
+
*
|
|
7
|
+
* An alias is a plain word, so a folder under one may be the user's own (`grill-me` on this very
|
|
8
|
+
* machine is a user skill, and a link). A folder moves only when ALL of these hold:
|
|
9
|
+
* (a) its name is retired and not a live skill;
|
|
10
|
+
* (b) no manifest owns a path under it — an owned one is the ordinary prune's;
|
|
11
|
+
* (c) it, the `skills/` root, and everything inside it are real entries, never a link;
|
|
12
|
+
* (d) its SKILL.md carries the render's fingerprint (`isRendered`).
|
|
13
|
+
* Anything else stays where it is and `migrate --dry-run` keeps calling it an orphan.
|
|
14
|
+
*
|
|
15
|
+
* Moved, not deleted: to `<cfg>/archived-skills/<name>/<stamp>/`, outside the `skills/` root a
|
|
16
|
+
* host scans (`archiveStore`'s sibling would sit inside it and load again).
|
|
17
|
+
*/
|
|
18
|
+
import { lstatSync, readdirSync, readFileSync, renameSync } from 'node:fs';
|
|
19
|
+
import path from 'node:path';
|
|
20
|
+
|
|
21
|
+
import { RETIRED_SKILL_IDS, THEMES, knownSkillIds, skillAliases } from './source.mjs';
|
|
22
|
+
import { isCanonical } from '../hosts/hosts.mjs';
|
|
23
|
+
import { archiveStore } from '../hosts/memory-files.mjs';
|
|
24
|
+
|
|
25
|
+
/** Every name an earlier build shipped a skill folder under and this one does not. */
|
|
26
|
+
export function retiredSkillNames({ live = knownSkillIds(), aliases = skillAliases() } = {}) {
|
|
27
|
+
return [...new Set([...aliases.keys(), ...Object.keys(RETIRED_SKILL_IDS)])].filter((n) => !live.includes(n));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Whether a manifest `owned` list holds `rel` or a path under it. */
|
|
31
|
+
export const ownsRel = (owned, rel) => owned.some((o) => o === rel || o.startsWith(`${rel}/`));
|
|
32
|
+
|
|
33
|
+
const lstat = (p) => { try { return lstatSync(p); } catch { return null; } };
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* (c): `dir` is a real directory and nothing under it is a link. lstat only: a link is never
|
|
37
|
+
* followed. A folder it cannot list is not plain: its reason goes into `unreadable`.
|
|
38
|
+
*/
|
|
39
|
+
function plainTree(dir, readdir, unreadable) {
|
|
40
|
+
const st = lstat(dir);
|
|
41
|
+
if (!st || st.isSymbolicLink() || !st.isDirectory()) return false;
|
|
42
|
+
let names;
|
|
43
|
+
try { names = readdir(dir); } catch (e) { unreadable.push(`${dir} (${e.message})`); return false; }
|
|
44
|
+
for (const name of names) {
|
|
45
|
+
const p = path.join(dir, name);
|
|
46
|
+
const s = lstat(p);
|
|
47
|
+
if (!s || s.isSymbolicLink()) return false;
|
|
48
|
+
if (s.isDirectory() && !plainTree(p, readdir, unreadable)) return false;
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
54
|
+
|
|
55
|
+
/** Every theme's `SKILL` label — the `{{SKILL}}` of a rendered heading — read off `themes/*.json`. */
|
|
56
|
+
let labelsCache = null;
|
|
57
|
+
export function skillLabels(themes = THEMES) {
|
|
58
|
+
if (themes === THEMES && labelsCache) return labelsCache;
|
|
59
|
+
const labels = new Set();
|
|
60
|
+
for (const f of readdirSync(themes).filter((n) => n.endsWith('.json') && !n.startsWith('_'))) {
|
|
61
|
+
try {
|
|
62
|
+
const v = JSON.parse(readFileSync(path.join(themes, f), 'utf8')).SKILL;
|
|
63
|
+
if (typeof v === 'string' && v) labels.add(v);
|
|
64
|
+
} catch { /* a broken theme labels nothing */ }
|
|
65
|
+
}
|
|
66
|
+
if (themes === THEMES) labelsCache = labels;
|
|
67
|
+
return labels;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* (d): the fingerprint every native skill writer has produced since the first one (Python
|
|
72
|
+
* `build.py`, 2026-06-04, through `js/hosts/native.mjs` today):
|
|
73
|
+
* - the file opens `---` / `name: <folder>` / `description: <json.dumps of it>`, and the value
|
|
74
|
+
* parses as a JSON string — a hand-written skill almost always writes plain YAML;
|
|
75
|
+
* - outside any code fence, the body holds the `# {{SKILL}}: <id>` heading every first-party
|
|
76
|
+
* source opens with, where the label is some theme's `SKILL` value and the id is the folder's
|
|
77
|
+
* own name, or the skill it aliases (an alias render carries its target's body). Anywhere in
|
|
78
|
+
* the body, because an authoring comment may precede it, as `herdr`'s did.
|
|
79
|
+
* A "Step 1: …" or "Grill Me: …" heading in a user's skill matches neither half of that.
|
|
80
|
+
*/
|
|
81
|
+
export function isRendered(dir, name, { aliases = skillAliases(), labels = skillLabels() } = {}) {
|
|
82
|
+
let text;
|
|
83
|
+
try { text = readFileSync(path.join(dir, 'SKILL.md'), 'utf8'); } catch { return false; }
|
|
84
|
+
const m = new RegExp(`^---\\r?\\nname: ${escapeRe(name)}\\r?\\ndescription: (".*")\\r?\\n`).exec(text);
|
|
85
|
+
if (!m) return false;
|
|
86
|
+
try { if (typeof JSON.parse(m[1]) !== 'string') return false; } catch { return false; }
|
|
87
|
+
// From the description line's own `\n`, so a frontmatter with no further key closes too.
|
|
88
|
+
const from = m[0].length - 1;
|
|
89
|
+
const close = /\n---\r?\n/.exec(text.slice(from));
|
|
90
|
+
if (!close) return false;
|
|
91
|
+
const ids = new Set([name, aliases.get(name)].filter(Boolean));
|
|
92
|
+
let fenced = false;
|
|
93
|
+
for (const line of text.slice(from + close.index + close[0].length).split(/\r?\n/)) {
|
|
94
|
+
if (/^\s*(```|~~~)/.test(line)) { fenced = !fenced; continue; }
|
|
95
|
+
if (fenced) continue;
|
|
96
|
+
const h = /^# (.+?): (\S+)\s*$/.exec(line);
|
|
97
|
+
if (h && labels.has(h[1]) && ids.has(h[2])) return true;
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The retired folders of `cfg` split by what the next canonical emit does with them:
|
|
104
|
+
* `prune` (a-d all hold) and `keep` (unowned, present, but failing c or d). Paths are absolute.
|
|
105
|
+
* `unreadable` names each folder kept because it could not be listed, with the reason.
|
|
106
|
+
* `opts.readdir` is the listing call, injectable so a test can make a folder unreadable.
|
|
107
|
+
*/
|
|
108
|
+
export function retiredSkillFolders(cfg, owned, opts = {}) {
|
|
109
|
+
const { readdir = readdirSync } = opts;
|
|
110
|
+
const prune = [];
|
|
111
|
+
const keep = [];
|
|
112
|
+
const unreadable = [];
|
|
113
|
+
const root = path.join(cfg, 'skills');
|
|
114
|
+
const rootStat = lstat(root);
|
|
115
|
+
if (!rootStat) return { prune, keep, unreadable };
|
|
116
|
+
// A linked `skills/` root (a dotfiles setup) is the user's whole tree: nothing in it moves.
|
|
117
|
+
const linkedRoot = rootStat.isSymbolicLink();
|
|
118
|
+
const aliases = opts.aliases ?? skillAliases();
|
|
119
|
+
for (const name of retiredSkillNames({ ...opts, aliases })) {
|
|
120
|
+
if (ownsRel(owned, `skills/${name}`)) continue;
|
|
121
|
+
const dir = path.join(root, name);
|
|
122
|
+
if (!lstat(dir)) continue;
|
|
123
|
+
(!linkedRoot && plainTree(dir, readdir, unreadable) && isRendered(dir, name, { aliases }) ? prune : keep).push(dir);
|
|
124
|
+
}
|
|
125
|
+
return { prune, keep, unreadable };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Where `pruneRetiredSkills` moves `skills/<name>`: the stamp folder goes under it. */
|
|
129
|
+
export const retiredArchiveOf = (cfg, name) => path.join(cfg, 'archived-skills', name);
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The emit's call, before the skill layer writes (so an alias freed here is claimed in the same
|
|
133
|
+
* emit, and the next one has nothing to do), with the manifest's `owned` from BEFORE this emit.
|
|
134
|
+
* Canonical global installs only: `diff`, Restore and a stray `--config-dir` never move a thing.
|
|
135
|
+
* A folder it cannot read, or a failed move, warns and leaves the folder; it never fails the emit.
|
|
136
|
+
* Raw stream writes, as `pruneOwned`'s: the driver's `withPlatformNewlines` already translates,
|
|
137
|
+
* and `printOut` on top of it would print `\r\r\n` on Windows.
|
|
138
|
+
*/
|
|
139
|
+
export function pruneRetiredSkills(host, cfg, oldOwned) {
|
|
140
|
+
if (!isCanonical(cfg, host)) return;
|
|
141
|
+
let found;
|
|
142
|
+
try { found = retiredSkillFolders(cfg, oldOwned); } catch (e) {
|
|
143
|
+
process.stderr.write(`[geneseed] WARN: ${host}: could not survey retired skills (${e.message}); nothing moved\n`);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
for (const u of found.unreadable) {
|
|
147
|
+
process.stderr.write(`[geneseed] WARN: ${host}: could not read retired skill folder ${u}; it stays\n`);
|
|
148
|
+
}
|
|
149
|
+
for (const dir of found.prune) {
|
|
150
|
+
const name = path.basename(dir);
|
|
151
|
+
try {
|
|
152
|
+
const dest = archiveStore(dir, renameSync, retiredArchiveOf(cfg, name));
|
|
153
|
+
process.stdout.write(`[geneseed] ${host}: pruned retired skill skills/${name} (moved to ${dest})\n`);
|
|
154
|
+
} catch (e) {
|
|
155
|
+
process.stderr.write(`[geneseed] WARN: ${host}: could not move retired skill skills/${name} aside (${e.message}); it stays\n`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
package/js/build/source.mjs
CHANGED
|
@@ -89,7 +89,10 @@ export const RETIRED_RULE_IDS = {
|
|
|
89
89
|
'external-gate': { was: 'Law IX', liveAs: 'DOCTRINE', note: 'moved to the rigor pack' },
|
|
90
90
|
'absence-is-a-claim': { was: 'Law XI', liveAs: null, note: 'folded into verify-before-asserting' },
|
|
91
91
|
// 2026-11-08: both rules set the reply format and shared one example, so one rule now holds both.
|
|
92
|
-
|
|
92
|
+
// `effect`: what an old exclusion of the address no longer does, printed with its WARN.
|
|
93
|
+
'mark-the-ask': { was: 'comms 5', liveAs: null, note: 'merged into comms 1, Codes and Markers',
|
|
94
|
+
effect: 'the ask markers it held now bind inside comms 1, so this exclusion no longer removes them; '
|
|
95
|
+
+ "only excluding 'comms 1' would, and that drops the item codes too" },
|
|
93
96
|
};
|
|
94
97
|
|
|
95
98
|
/**
|
|
@@ -386,23 +389,40 @@ export const PACK_ORDER = ['craft', 'rigor', 'ops', 'process', 'comms'];
|
|
|
386
389
|
* constitution in the same sequence; a sort would silently disagree with a file whose headings
|
|
387
390
|
* were ever out of order, and disagree in the direction that reads as correct.
|
|
388
391
|
*/
|
|
389
|
-
export function knownRuleIds() {
|
|
390
|
-
return
|
|
392
|
+
export function knownRuleIds(rules = ruleCanon(SRC).rules) {
|
|
393
|
+
return rules.filter((r) => r.kind === 'DOCTRINE').map((r) => `${r.pack}.${r.n}`);
|
|
391
394
|
}
|
|
392
395
|
|
|
393
396
|
/**
|
|
394
|
-
* `<pack>.<n>` ->
|
|
395
|
-
* live rule took over. Read off `
|
|
396
|
-
* install that excluded `comms 5` replays it on every rebuild; refusing it would
|
|
397
|
-
* rebuild forever, so the flag parsers warn and drop it instead. A live address is
|
|
398
|
-
* retired: a rule appended later at the same number takes the address back
|
|
397
|
+
* `<pack>.<n>` -> its `RETIRED_RULE_IDS` entry (`note`, and `effect` when set), for every
|
|
398
|
+
* retired doctrine rule whose address no live rule took over. Read off `was`, so the reason has
|
|
399
|
+
* one home. An install that excluded `comms 5` replays it on every rebuild; refusing it would
|
|
400
|
+
* break that rebuild forever, so the flag parsers warn and drop it instead. A live address is
|
|
401
|
+
* never retired: a rule appended later at the same number takes the address back
|
|
402
|
+
* (`reusedRuleAddresses`).
|
|
399
403
|
*/
|
|
400
404
|
export function retiredRuleAddresses(known = knownRuleIds()) {
|
|
401
405
|
const out = new Map();
|
|
402
|
-
for (const
|
|
403
|
-
const m = /^([a-z]+) (\d+)$/.exec(was);
|
|
406
|
+
for (const entry of Object.values(RETIRED_RULE_IDS)) {
|
|
407
|
+
const m = /^([a-z]+) (\d+)$/.exec(entry.was);
|
|
404
408
|
const id = m && `${m[1]}.${m[2]}`;
|
|
405
|
-
if (id && PACK_ORDER.includes(m[1]) && !known.includes(id)) out.set(id,
|
|
409
|
+
if (id && PACK_ORDER.includes(m[1]) && !known.includes(id)) out.set(id, entry);
|
|
410
|
+
}
|
|
411
|
+
return out;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* `<pack>.<n>` -> `{ old, note, now }` for every retired doctrine rule whose address a different
|
|
416
|
+
* live rule (`now`, a `ruleCanon` rule) holds today. An exclusion stored for `old` would bind
|
|
417
|
+
* `now` in silence, so the flag parsers warn loudly with both names; the exclusion still binds,
|
|
418
|
+
* because the address is the new rule's now and nothing tells an old entry from a new one.
|
|
419
|
+
*/
|
|
420
|
+
export function reusedRuleAddresses(rules = ruleCanon(SRC).rules) {
|
|
421
|
+
const out = new Map();
|
|
422
|
+
for (const [old, { was, note }] of Object.entries(RETIRED_RULE_IDS)) {
|
|
423
|
+
const m = /^([a-z]+) (\d+)$/.exec(was);
|
|
424
|
+
const now = m && rules.find((r) => r.kind === 'DOCTRINE' && r.pack === m[1] && r.n === Number(m[2]));
|
|
425
|
+
if (now && now.id !== old) out.set(`${m[1]}.${m[2]}`, { old, note, now });
|
|
406
426
|
}
|
|
407
427
|
return out;
|
|
408
428
|
}
|
package/js/cli-table.json
CHANGED
|
@@ -694,7 +694,7 @@
|
|
|
694
694
|
"names": ["--factory"],
|
|
695
695
|
"dest": "factory",
|
|
696
696
|
"metavar": null,
|
|
697
|
-
"help": "a factory name or a .json factory file (check, init)",
|
|
697
|
+
"help": "a factory name, or a .json factory file relative to the current directory (check, init)",
|
|
698
698
|
"choices": null,
|
|
699
699
|
"default": null,
|
|
700
700
|
"required": false,
|
|
@@ -759,7 +759,7 @@
|
|
|
759
759
|
"names": ["--spec"],
|
|
760
760
|
"dest": "spec",
|
|
761
761
|
"metavar": null,
|
|
762
|
-
"help": "the spec a stage wrote; its ordered tasks replay the next loop stage once each (record)",
|
|
762
|
+
"help": "the spec a stage wrote, at specs/<slug>/spec.md (a path relative to the current directory); its ordered tasks replay the next loop stage once each (record)",
|
|
763
763
|
"choices": null,
|
|
764
764
|
"default": null,
|
|
765
765
|
"required": false,
|
|
@@ -781,6 +781,19 @@
|
|
|
781
781
|
"type": null,
|
|
782
782
|
"hidden": false
|
|
783
783
|
},
|
|
784
|
+
{
|
|
785
|
+
"names": ["--carry-file"],
|
|
786
|
+
"dest": "carry_file",
|
|
787
|
+
"metavar": null,
|
|
788
|
+
"help": "record's carry read from this file (relative to the current directory; CRLF folded, trimmed) — for free text, or text that mentions git commit/push",
|
|
789
|
+
"choices": null,
|
|
790
|
+
"default": null,
|
|
791
|
+
"required": false,
|
|
792
|
+
"nargs": null,
|
|
793
|
+
"is_flag": false,
|
|
794
|
+
"type": null,
|
|
795
|
+
"hidden": false
|
|
796
|
+
},
|
|
784
797
|
{
|
|
785
798
|
"names": ["--verdict"],
|
|
786
799
|
"dest": "verdict",
|
|
@@ -810,6 +823,19 @@
|
|
|
810
823
|
"is_flag": false,
|
|
811
824
|
"type": null,
|
|
812
825
|
"hidden": false
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
"names": ["--note-file"],
|
|
829
|
+
"dest": "note_file",
|
|
830
|
+
"metavar": null,
|
|
831
|
+
"help": "decide's note read from this file (relative to the current directory; CRLF folded, trimmed) — for the user's own words, or text that mentions git commit/push",
|
|
832
|
+
"choices": null,
|
|
833
|
+
"default": null,
|
|
834
|
+
"required": false,
|
|
835
|
+
"nargs": null,
|
|
836
|
+
"is_flag": false,
|
|
837
|
+
"type": null,
|
|
838
|
+
"hidden": false
|
|
813
839
|
}
|
|
814
840
|
],
|
|
815
841
|
"mutex": []
|
|
@@ -1382,7 +1408,7 @@
|
|
|
1382
1408
|
],
|
|
1383
1409
|
"dest": "dry_run",
|
|
1384
1410
|
"metavar": null,
|
|
1385
|
-
"help": "survey and print the plan, with the fold each global install would run and any orphan; write nothing",
|
|
1411
|
+
"help": "survey and print the plan, with the fold each global install would run, the retired skill folders it would prune and any orphan; write nothing",
|
|
1386
1412
|
"choices": null,
|
|
1387
1413
|
"default": false,
|
|
1388
1414
|
"required": false,
|
package/js/factory/cli.mjs
CHANGED
|
@@ -19,12 +19,29 @@
|
|
|
19
19
|
*
|
|
20
20
|
* THE PORCELAIN IS TRUSTED AS PIPED. A TTY stdin is `null` and the engine refuses it after a
|
|
21
21
|
* stage outside a loop (J5); an empty pipe (or a null device) reads as a clean tree, and nothing
|
|
22
|
-
* here can tell it from one. The Rite pipes `git status --porcelain --untracked-files=all
|
|
23
|
-
* new spec reaches the engine as its own path
|
|
22
|
+
* here can tell it from one. The Rite pipes `git status --porcelain --untracked-files=all` straight
|
|
23
|
+
* into `record`, in one command, so a new spec reaches the engine as its own path. No temp status
|
|
24
|
+
* file and no shell variable: three attempts at those (F1/F2) shared a file across repos, broke on
|
|
25
|
+
* zsh's read-only `$status`, or put free text back on the line. Windows PowerShell 5.1 pipes too,
|
|
26
|
+
* but ends lines with CRLF, and adds a leading BOM when `$OutputEncoding` is UTF-8; both are stripped below.
|
|
27
|
+
* The git gate (`GIT_GATE_RE`) asks on a line that holds the word `git` and the word `commit` or
|
|
28
|
+
* `push`, so a record line whose spec path, carry path or outcome holds `commit` or `push` asks.
|
|
29
|
+
* That ask is a false alarm the user answers yes to, and the skill says so; a shared or broken
|
|
30
|
+
* status file would be a wrong record. `init` refuses a `loop/factory-<slug>` branch whose slug
|
|
31
|
+
* holds those words, which removes the commonest case.
|
|
24
32
|
*
|
|
25
33
|
* `--spec` IS READ HERE, not in the state module: the engine stays pure, and the CLI is the one
|
|
26
34
|
* layer that may read files. The path is stored root-relative with forward slashes, the form a
|
|
27
35
|
* porcelain line carries it in, and a path outside the root is refused before it is read.
|
|
36
|
+
*
|
|
37
|
+
* EVERY PATH ARGUMENT RESOLVES AGAINST THE CURRENT DIRECTORY (M6): `--spec`, `--factory <file>`,
|
|
38
|
+
* `--carry-file` and `--note-file`, as `geneseed loop`'s `--note-file` does and as a shell user
|
|
39
|
+
* means a relative path. Only FACTORY.md itself is found at the git root. `--spec` resolved
|
|
40
|
+
* against the root once, so the same relative path named two files depending on the flag.
|
|
41
|
+
*
|
|
42
|
+
* `--carry-file` AND `--note-file` (M7) take the text from a file, never the command line
|
|
43
|
+
* (`textArg`, shared with `geneseed loop`): free text can hold any word and any quote. The Rite
|
|
44
|
+
* writes that file with the host's file tool, never the shell, under a name it makes unique.
|
|
28
45
|
*/
|
|
29
46
|
import { readFileSync } from 'node:fs';
|
|
30
47
|
import path from 'node:path';
|
|
@@ -33,6 +50,7 @@ import { gitRootOf, headCommit, currentBranch } from '../hosts/gitref.mjs';
|
|
|
33
50
|
import { loadCatalog } from '../loop/catalog.mjs';
|
|
34
51
|
import { LOOP_FILE, parseLoopFile } from '../loop/state.mjs';
|
|
35
52
|
import { loopInitAt } from '../loop/registry.mjs';
|
|
53
|
+
import { textArg } from '../loop/cli.mjs';
|
|
36
54
|
import { recordFactory } from './registry.mjs';
|
|
37
55
|
import { checkFactory, factoryCatalogProblems } from './graph.mjs';
|
|
38
56
|
import {
|
|
@@ -44,6 +62,7 @@ const emit = (obj) => { printOut(`${JSON.stringify(obj)}\n`); return obj.error |
|
|
|
44
62
|
const stdin = () => (process.stdin.isTTY ? null : readFileSync(0, 'utf8'));
|
|
45
63
|
const byName = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
46
64
|
|
|
65
|
+
|
|
47
66
|
/** R3: the LOOP.md at `root` — its status (`running` when it does not parse) and graph name; nulls without one. */
|
|
48
67
|
function loopFileOf(root) {
|
|
49
68
|
const file = path.join(root, LOOP_FILE);
|
|
@@ -79,7 +98,11 @@ function withState(fn) {
|
|
|
79
98
|
function resolveFactory(spec, catalog) {
|
|
80
99
|
if (spec.endsWith('.json')) return JSON.parse(readText(path.resolve(spec)));
|
|
81
100
|
const f = catalog.factories.get(spec);
|
|
82
|
-
if (!f)
|
|
101
|
+
if (!f) {
|
|
102
|
+
// M8: a file of that name that does not load is why, and is named; it never falls back to a lower level's factory
|
|
103
|
+
const why = catalog.factoryProblems.filter((p) => p.startsWith(`factories/${spec}.json (`));
|
|
104
|
+
throw new Error(`no factory named ${JSON.stringify(spec)}${why.length ? `: ${why.join('; ')}` : ''}`);
|
|
105
|
+
}
|
|
83
106
|
const { origin, ...factory } = f;
|
|
84
107
|
return factory;
|
|
85
108
|
}
|
|
@@ -93,7 +116,10 @@ const ACTIONS = {
|
|
|
93
116
|
return { ok: !problems.length, problems };
|
|
94
117
|
}
|
|
95
118
|
const problems = factoryCatalogProblems(catalog);
|
|
96
|
-
return {
|
|
119
|
+
return {
|
|
120
|
+
ok: !problems.length, problems, factories: [...catalog.factories.keys()].sort(byName),
|
|
121
|
+
...(catalog.factoryOverridden.length ? { overridden: catalog.factoryOverridden } : {}),
|
|
122
|
+
};
|
|
97
123
|
},
|
|
98
124
|
list() {
|
|
99
125
|
const root = gitRootOf(process.cwd()) ?? process.cwd();
|
|
@@ -109,6 +135,16 @@ const ACTIONS = {
|
|
|
109
135
|
const file = path.join(root, FACTORY_FILE);
|
|
110
136
|
if (isFile(file)) throw new Error(`${file} already exists — a factory is already running here`);
|
|
111
137
|
if (!args.title || !args.requirement || !args.factory) throw new Error('init needs --title, --requirement and --factory');
|
|
138
|
+
// F1: the slug lands on the spec's record line (`--spec specs/<slug>/spec.md`), where the git
|
|
139
|
+
// gate asks on the words git, commit and push. The run's branch carries it, so check it there.
|
|
140
|
+
// Case-insensitive on purpose: stricter than the (case-sensitive) gate.
|
|
141
|
+
const slug = /^loop\/factory-(.+)$/.exec(currentBranch(root) ?? '')?.[1];
|
|
142
|
+
const word = slug && /\b(git|commit|push)\b/i.exec(slug);
|
|
143
|
+
if (word) {
|
|
144
|
+
throw new Error(`the run's slug ${JSON.stringify(slug)} holds the word ${word[1]}, in any case refused: the git gate `
|
|
145
|
+
+ 'asks on git, commit and push on the spec\'s record line. Rename the branch loop/factory-<slug> to a slug without '
|
|
146
|
+
+ 'git, commit or push (spell them g1t, cmt, psh)');
|
|
147
|
+
}
|
|
112
148
|
const catalog = loadCatalog({ projectRoot: root });
|
|
113
149
|
const factory = resolveFactory(args.factory, catalog);
|
|
114
150
|
const problems = checkFactory(factory, catalog);
|
|
@@ -122,11 +158,12 @@ const ACTIONS = {
|
|
|
122
158
|
next: () => withState((s, c, { loopStatus, head }) => nextStage(s, c, { loopStatus, head, now: new Date().toISOString() })),
|
|
123
159
|
record(args) {
|
|
124
160
|
if (!args.outcome) throw new Error('record needs --outcome');
|
|
161
|
+
const carry = textArg(args, 'carry', 'carry', 'record');
|
|
125
162
|
const porcelain = stdin();
|
|
126
163
|
return withState((s, c, { root, loopStatus, loopTemplate, head }) => {
|
|
127
164
|
let specPath = null; let taskCount = null;
|
|
128
165
|
if (args.spec) {
|
|
129
|
-
const abs = path.resolve(
|
|
166
|
+
const abs = path.resolve(args.spec);
|
|
130
167
|
const rel = path.relative(root, abs);
|
|
131
168
|
if (!rel || rel === '..' || rel.startsWith(`..${path.sep}`) || path.isAbsolute(rel)) throw new Error(`--spec ${args.spec} is outside the worktree`);
|
|
132
169
|
let text;
|
|
@@ -135,13 +172,17 @@ const ACTIONS = {
|
|
|
135
172
|
taskCount = countSpecTasks(text);
|
|
136
173
|
}
|
|
137
174
|
return recordStage(s, c, args.outcome, {
|
|
138
|
-
|
|
139
|
-
|
|
175
|
+
// Windows PowerShell 5.1 re-encodes a native pipe: CRLF line ends, and a leading BOM when $OutputEncoding is UTF-8
|
|
176
|
+
porcelain: porcelain === null ? null : porcelain.replace(/^\uFEFF/, '').replace(/\r\n/g, '\n').trimEnd(),
|
|
177
|
+
specPath, taskCount, carry, loopStatus, loopTemplate, head,
|
|
140
178
|
loopInitAt: loopInitAt(root),
|
|
141
179
|
});
|
|
142
180
|
});
|
|
143
181
|
},
|
|
144
|
-
decide
|
|
182
|
+
decide(args) {
|
|
183
|
+
const note = textArg(args, 'note', 'note', 'decide') ?? '';
|
|
184
|
+
return withState((s, c) => decideFactory(s, c, args.verdict, note));
|
|
185
|
+
},
|
|
145
186
|
};
|
|
146
187
|
|
|
147
188
|
export function cmdFactory(args) {
|