yadflow 4.11.0 → 4.12.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 +55 -0
- package/README.md +2 -0
- package/bin/commands.mjs +2 -0
- package/bin/yad.mjs +55 -2
- package/cli/agent-rules.mjs +26 -1
- package/cli/argv-flags.mjs +1 -1
- package/cli/brain/view/index.html +1 -1
- package/cli/brain/view/live.html +1 -1
- package/cli/brain-view.mjs +5 -4
- package/cli/brand-cmd.mjs +326 -0
- package/cli/brand.mjs +327 -0
- package/cli/doctor.mjs +65 -1
- package/cli/guide.mjs +26 -3
- package/cli/issues.mjs +9 -3
- package/cli/local-page.mjs +2 -2
- package/cli/local-setup-record.mjs +71 -0
- package/cli/local-setup-steps.mjs +186 -0
- package/cli/local-setup.mjs +611 -0
- package/cli/manifest.mjs +5 -0
- package/cli/map/view/index.html +1 -1
- package/cli/map-view.mjs +8 -4
- package/cli/plain-text.mjs +22 -0
- package/cli/plan.mjs +185 -36
- package/cli/reconcile.mjs +53 -11
- package/cli/reports-dir.mjs +6 -4
- package/cli/scan.mjs +3 -5
- package/cli/secret-text.mjs +66 -0
- package/cli/setup.mjs +25 -4
- package/cli/standup.mjs +8 -2
- package/cli/test-brand.mjs +558 -0
- package/cli/test-guide.mjs +227 -0
- package/cli/test-local-setup.mjs +1188 -0
- package/cli/toolbox.mjs +15 -1
- package/cli/update-commit.mjs +35 -18
- package/cli/usage.mjs +9 -3
- package/cli/workspace.mjs +11 -2
- package/package.json +3 -3
- package/skills/sdlc/module-help.csv +1 -0
- package/skills/yad-brand/SKILL.md +69 -0
- package/skills/yad-checks/templates/hooks/local-setup-notice.mjs +96 -0
- package/skills/yad-checks/templates/hooks/yad-activity.mjs +2 -2
- package/skills/yad-guide/SKILL.md +9 -6
package/cli/map/view/index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; base-uri 'none'; form-action 'none'">
|
|
6
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src data:; connect-src 'self'; base-uri 'none'; form-action 'none'">
|
|
7
7
|
<meta name="referrer" content="no-referrer">
|
|
8
8
|
<title>Progress Map</title>
|
|
9
9
|
<link rel="stylesheet" href="style.css?t=__TOKEN__">
|
package/cli/map-view.mjs
CHANGED
|
@@ -21,6 +21,7 @@ import { gatherMap, mapModel, digestOf } from './map.mjs';
|
|
|
21
21
|
import { TYPES, startPageServer, inlineSnapshot, writeOwnFile, trackedRisk } from './local-page.mjs';
|
|
22
22
|
import { saveReport, listReports, SIDE_SUFFIX } from './reports-dir.mjs';
|
|
23
23
|
import { openUrl } from './report.mjs';
|
|
24
|
+
import { brandForPage } from './brand.mjs';
|
|
24
25
|
|
|
25
26
|
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
26
27
|
const VIEW_DIR = path.join(HERE, 'map', 'view');
|
|
@@ -47,8 +48,9 @@ export function buildMap(root, { anonymous = false, fetch = false, env = process
|
|
|
47
48
|
return { model, problems: g.problems };
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
// `brandCss`: the Product's brand (E184), added after the page's own CSS so it wins — inside the hashed style.
|
|
52
|
+
export function mapSnapshot(model, { brandCss = '' } = {}) {
|
|
53
|
+
return inlineSnapshot({ shell: readView('index.html'), scripts: [readView('app.js')], css: `${readView('style.css')}\n${brandCss}`, dataId: 'yad-map-data', data: model });
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
// The live stream: the Product's epics/ and .sdlc/, and each code repo's refs, watched while a page is open.
|
|
@@ -118,7 +120,7 @@ export function startMapServer(root, { anonymous = false, live = false, env = pr
|
|
|
118
120
|
const routes = (token) => new Map([
|
|
119
121
|
['/', () => ({ type: TYPES.html, body: readView('index.html').replaceAll('__TOKEN__', token) })],
|
|
120
122
|
['/app.js', () => ({ type: TYPES.js, body: readView('app.js') })],
|
|
121
|
-
['/style.css', () => ({ type: TYPES.css, body: readView('style.css') })],
|
|
123
|
+
['/style.css', () => ({ type: TYPES.css, body: `${readView('style.css')}\n${brandForPage(root, 'map').css}` })],
|
|
122
124
|
['/map.json', () => ({ type: TYPES.json, body: JSON.stringify(buildMap(root, { anonymous, env, runner }).model) })],
|
|
123
125
|
]);
|
|
124
126
|
return startPageServer({ routes, stream, host, port, failText: 'the map could not be read' }).then((srv) => ({ ...srv, watchable: stream ? stream.canWatch() : null }));
|
|
@@ -138,7 +140,9 @@ export async function runMap(root, { args = [], html = false, open = false, live
|
|
|
138
140
|
if (html) {
|
|
139
141
|
const own = args.length === 1;
|
|
140
142
|
let page;
|
|
141
|
-
|
|
143
|
+
const brand = brandForPage(root, 'map');
|
|
144
|
+
for (const p of brand.problems) warn(`the brand file cannot be used, so the page wears yadflow's look: ${forTerminal(p)}`);
|
|
145
|
+
try { page = mapSnapshot(model, { brandCss: brand.css }); } catch (e) { return refuse(`cannot build the page: ${e.message}`, null, { json }); }
|
|
142
146
|
let file, riskLine = null;
|
|
143
147
|
if (own) {
|
|
144
148
|
file = path.resolve(args[0]);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Text a person reads and an agent acts on, with nothing hidden in it (E185). Shared by the local setup script and
|
|
2
|
+
// the toolbox's own tools, whose words become setup steps every member's agent reads.
|
|
3
|
+
import { forTerminal } from './lib.mjs';
|
|
4
|
+
|
|
5
|
+
// Every character a reader cannot see: control, format and separator characters (zero-width spaces, soft hyphens,
|
|
6
|
+
// tag characters, direction marks), every space but the plain one, variation selectors (which can carry text an
|
|
7
|
+
// agent reads and a person never sees), the fillers that render blank (Hangul, braille), and half a character
|
|
8
|
+
// pair (a lone surrogate).
|
|
9
|
+
// `Default_Ignorable_Code_Point` names the rest, now and as Unicode adds them (U+034F, U+17B4, …; review 2).
|
|
10
|
+
const INVISIBLE = String.raw`\p{Cf}\p{Zl}\p{Zp}\p{Cs}\p{Default_Ignorable_Code_Point}\u{FE00}-\u{FE0F}\u{E0100}-\u{E01EF}\u115F\u1160\u3164\uFFA0\u2800`;
|
|
11
|
+
export const HIDDEN = new RegExp(String.raw`[\p{Cc}${INVISIBLE}]|(?! )\p{Zs}`, 'u');
|
|
12
|
+
// Prose may wrap: a newline is its one allowed control character.
|
|
13
|
+
const HIDDEN_IN_PROSE = new RegExp(String.raw`[${INVISIBLE}]|[^\P{Cc}\n]|(?! )\p{Zs}`, 'u');
|
|
14
|
+
|
|
15
|
+
export const isText = (v) => typeof v === 'string' && v.trim().length > 0;
|
|
16
|
+
// One plain line: nothing `forTerminal` would change, and nothing hidden.
|
|
17
|
+
export const plainLine = (v) => isText(v) && forTerminal(v) === v && !HIDDEN.test(v);
|
|
18
|
+
// Plain prose: lines of text, nothing hidden.
|
|
19
|
+
export const plainProse = (v) => isText(v) && !HIDDEN_IN_PROSE.test(v);
|
|
20
|
+
|
|
21
|
+
// How long each part of a step may be: a step is read by every member, so it stays readable.
|
|
22
|
+
export const STEP_LIMITS = Object.freeze({ title: 120, text: 600, commands: 10, command: 500 });
|
package/cli/plan.mjs
CHANGED
|
@@ -1305,15 +1305,17 @@ function blockState(dest, opts) {
|
|
|
1305
1305
|
return { raw, state: now.status === 'ok' ? 'ok' : now.status === 'new' ? 'missing' : 'outdated', refused: null, exists: raw !== null };
|
|
1306
1306
|
}
|
|
1307
1307
|
|
|
1308
|
-
|
|
1308
|
+
// `markers` is AGENTS_MARKERS unless named: the local setup script's view (LOCAL-SETUP.md, E185) has its own.
|
|
1309
|
+
export function markedBlockAction(root, relDest, lines, { scope = 'product', markers = AGENTS_MARKERS, what = 'the yadflow rules block' } = {}) {
|
|
1309
1310
|
const dest = path.join(root, relDest);
|
|
1310
|
-
const opts = { ...
|
|
1311
|
-
|
|
1311
|
+
const opts = { ...markers, lines };
|
|
1312
|
+
// `what` names the block in the row `yad update --open-pr` gives a file it leaves out ("its yadflow rules block").
|
|
1313
|
+
const base = { scope, item: relDest, root, paths: [], shared: relDest, kind: 'text', what: what.replace(/^the /, 'its '), mergeShared: (text) => applyMarkedBlock(text, opts) };
|
|
1312
1314
|
const { state, refused } = blockState(dest, opts);
|
|
1313
1315
|
// Never written, said once at plan time. Markers yad cannot trust are never guessed around: the team's
|
|
1314
1316
|
// text is left as it is (as a broken config.yaml region is, cli/lifecycle.mjs).
|
|
1315
1317
|
if (refused) {
|
|
1316
|
-
warn(`${scope}/${relDest}: ${refused} —
|
|
1318
|
+
warn(`${scope}/${relDest}: ${refused} — ${what} was left out; ${state === 'refused' ? 'fix the markers (or delete both to have the block added again)' : 'make it a plain file'}, then re-run \`yad check --fix\``);
|
|
1317
1319
|
return { ...base, status: 'modified', writesNothing: true, apply: () => {} };
|
|
1318
1320
|
}
|
|
1319
1321
|
return {
|
|
@@ -1505,18 +1507,27 @@ export const gitHookLine = (prefix = '') => {
|
|
|
1505
1507
|
return `[ ! -f ${guard} ] || node ${guard} --staged || [ $? -ne 2 ] || exit 1`;
|
|
1506
1508
|
};
|
|
1507
1509
|
|
|
1508
|
-
//
|
|
1509
|
-
//
|
|
1510
|
-
//
|
|
1511
|
-
//
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1510
|
+
// A git hook yad writes into this clone, described once: the pre-commit ledger guard (E48) and the pull notices
|
|
1511
|
+
// (E185) take every rule below the same way. `spec`:
|
|
1512
|
+
// name the hook's file name in git's hooks folder ('pre-commit')
|
|
1513
|
+
// marker the line that makes a copy yad's own
|
|
1514
|
+
// scripts (prefix) → every text yad has written for it, today's first
|
|
1515
|
+
// line (prefix) → the one line a person adds to a hook yad will not touch
|
|
1516
|
+
// applies (root) → whether this Product wants the hook at all
|
|
1517
|
+
// item the action's name in `yad check`
|
|
1518
|
+
// advice (st) → the sentence for a hook yad may not write
|
|
1519
|
+
// Where the hook is, and whose it is. `{ applies: false }` when there is nothing to install (the spec says no,
|
|
1520
|
+
// or no git). Otherwise `{ applies: true, file, expected, prefix, state }` with `state` one of: 'missing' | 'ok'
|
|
1521
|
+
// | 'outdated' (ours, different bytes) | 'foreign' (a hook that is not ours) | 'hooks-path' (core.hooksPath is
|
|
1522
|
+
// set). The last two carry `line`, the one to add by hand.
|
|
1523
|
+
function hookStateFor(spec, root) {
|
|
1524
|
+
if (!spec.applies(root)) return { applies: false };
|
|
1525
|
+
const where = run('git', ['-C', root, 'rev-parse', '--git-path', `hooks/${spec.name}`, '--show-prefix']);
|
|
1515
1526
|
if (!where.ok) return { applies: false };
|
|
1516
1527
|
const [hookRel, prefix = ''] = where.stdout.split('\n');
|
|
1517
1528
|
const file = path.resolve(root, hookRel);
|
|
1518
|
-
const expected =
|
|
1519
|
-
const line =
|
|
1529
|
+
const [expected] = spec.scripts(prefix);
|
|
1530
|
+
const line = spec.line(prefix);
|
|
1520
1531
|
const hooksPath = run('git', ['-C', root, 'config', '--get', 'core.hooksPath']);
|
|
1521
1532
|
// A core.hooksPath that names the default folder anyway (some tools set it so) is not a tool's folder.
|
|
1522
1533
|
// `--path-format` needs git 2.31; an older git fails the call, and the setting is then treated as a tool's.
|
|
@@ -1530,30 +1541,49 @@ export function gitHookState(root) {
|
|
|
1530
1541
|
|| (path.basename(hooksDir) === 'hooks' && samePath(path.dirname(hooksDir), common.stdout)));
|
|
1531
1542
|
if (hooksPath.ok && hooksPath.stdout && !isDefault) {
|
|
1532
1543
|
// husky points core.hooksPath at `.husky/_`, a folder it generates; the hook a person edits is the one
|
|
1533
|
-
// beside it, `.husky
|
|
1544
|
+
// beside it, `.husky/<name>`. Name that one, or the advice sends them to a file husky rewrites.
|
|
1534
1545
|
const dir = hooksPath.stdout.replace(/[\\/]+$/, '');
|
|
1535
|
-
const edit = /(^|[\\/])_$/.test(dir) ? `${dir.replace(/[\\/]?_$/, '') || '.'}
|
|
1546
|
+
const edit = /(^|[\\/])_$/.test(dir) ? `${dir.replace(/[\\/]?_$/, '') || '.'}/${spec.name}` : `${dir}/${spec.name}`;
|
|
1547
|
+
// The hook the person edits there may already hold yad's line (reviews 3, 4). Read where git itself resolved
|
|
1548
|
+
// it (`file`: `~`, relative and absolute settings alike), husky's beside its `_` folder. husky's runner calls
|
|
1549
|
+
// its hook with sh, so its execute bit is husky's business; in any other folder git runs it, and skips one it
|
|
1550
|
+
// cannot run (everywhere but Windows).
|
|
1551
|
+
if (spec.wired) {
|
|
1552
|
+
const husky = /(^|[\\/])_$/.test(dir);
|
|
1553
|
+
const read = husky ? path.join(path.dirname(path.dirname(file)), spec.name) : file;
|
|
1554
|
+
let edited = null;
|
|
1555
|
+
try { edited = fs.readFileSync(read, 'utf8'); } catch { /* none */ }
|
|
1556
|
+
let canRun = true;
|
|
1557
|
+
if (!husky && process.platform !== 'win32') { try { canRun = (fs.statSync(read).mode & 0o111) !== 0; } catch { canRun = false; } }
|
|
1558
|
+
if (edited !== null && canRun && spec.wired(edited, prefix)) return { applies: true, file, expected, prefix, line, hooksPath: hooksPath.stdout, editFile: edit, state: 'hand-wired' };
|
|
1559
|
+
}
|
|
1536
1560
|
return { applies: true, file, expected, prefix, line, hooksPath: hooksPath.stdout, editFile: edit, state: 'hooks-path' };
|
|
1537
1561
|
}
|
|
1538
1562
|
let text = null;
|
|
1539
1563
|
try { text = fs.readFileSync(file, 'utf8'); } catch { /* absent */ }
|
|
1540
1564
|
if (text === null) return { applies: true, file, expected, prefix, state: 'missing' };
|
|
1541
|
-
|
|
1565
|
+
// A hook of the team's own that already runs ours by the line yad gave (`spec.wired`), and that git can run (its
|
|
1566
|
+
// execute bit, everywhere but Windows): nothing to say (reviews 2, 3).
|
|
1567
|
+
if (!text.includes(spec.marker)) {
|
|
1568
|
+
let canRun = true;
|
|
1569
|
+
if (process.platform !== 'win32') { try { canRun = (fs.statSync(file).mode & 0o111) !== 0; } catch { canRun = false; } }
|
|
1570
|
+
return { applies: true, file, expected, prefix, line, state: canRun && spec.wired?.(text, prefix) ? 'hand-wired' : 'foreign' };
|
|
1571
|
+
}
|
|
1542
1572
|
// Git silently skips a hook that is not executable (everywhere but Windows), so right bytes without the
|
|
1543
1573
|
// bit are not an installed hook.
|
|
1544
1574
|
let runnable = true;
|
|
1545
1575
|
if (process.platform !== 'win32') { try { runnable = (fs.statSync(file).mode & 0o111) !== 0; } catch { runnable = false; } }
|
|
1546
1576
|
if (text === expected && runnable) return { applies: true, file, expected, prefix, state: 'ok' };
|
|
1547
1577
|
// `earlier`: a text an earlier yad wrote, so nothing in it is anyone's edit.
|
|
1548
|
-
const why = text === expected ? 'not-executable' :
|
|
1578
|
+
const why = text === expected ? 'not-executable' : spec.scripts(prefix).includes(text) ? 'earlier' : 'changed';
|
|
1549
1579
|
return { applies: true, file, expected, prefix, state: 'outdated', why };
|
|
1550
1580
|
}
|
|
1551
1581
|
|
|
1552
1582
|
// The install action. 'foreign' and 'hooks-path' build no action — there is nothing yad may write —
|
|
1553
|
-
// and are reported by
|
|
1554
|
-
|
|
1555
|
-
const st =
|
|
1556
|
-
if (!st.applies || st.state === 'foreign' || st.state === 'hooks-path') return [];
|
|
1583
|
+
// and are reported by the spec's advice instead.
|
|
1584
|
+
function hookActionsFor(spec, root) {
|
|
1585
|
+
const st = hookStateFor(spec, root);
|
|
1586
|
+
if (!st.applies || st.state === 'foreign' || st.state === 'hooks-path' || st.state === 'hand-wired') return [];
|
|
1557
1587
|
const status = st.state === 'missing' ? 'new' : st.state;
|
|
1558
1588
|
// An outdated copy may carry a person's edit below our marker, so it is saved beside itself first —
|
|
1559
1589
|
// the same rule `wiredFileAction` keeps for content it cannot prove it wrote. Not when only the execute
|
|
@@ -1561,7 +1591,7 @@ export function gitHookActions(root) {
|
|
|
1561
1591
|
const backup = st.state === 'outdated' && st.why === 'changed' ? backupPathFor(st.file) : null;
|
|
1562
1592
|
return [{
|
|
1563
1593
|
scope: 'product',
|
|
1564
|
-
item:
|
|
1594
|
+
item: spec.item,
|
|
1565
1595
|
status,
|
|
1566
1596
|
root,
|
|
1567
1597
|
paths: [],
|
|
@@ -1575,27 +1605,146 @@ export function gitHookActions(root) {
|
|
|
1575
1605
|
}];
|
|
1576
1606
|
}
|
|
1577
1607
|
|
|
1578
|
-
// A
|
|
1579
|
-
//
|
|
1580
|
-
|
|
1581
|
-
if (
|
|
1582
|
-
const where = run('git', ['-C', root, 'rev-parse', '--git-path',
|
|
1608
|
+
// A hook the Product no longer wants (the spec says no): removed only when its bytes are exactly what yad
|
|
1609
|
+
// writes — an edited copy is left for its owner. Only on a Product: elsewhere nothing of yad's was written.
|
|
1610
|
+
function orphanHookActionsFor(spec, root) {
|
|
1611
|
+
if (!exists(productConfigPath(root)) || spec.applies(root)) return [];
|
|
1612
|
+
const where = run('git', ['-C', root, 'rev-parse', '--git-path', `hooks/${spec.name}`, '--show-prefix']);
|
|
1583
1613
|
if (!where.ok) return [];
|
|
1584
1614
|
const [hookRel, prefix = ''] = where.stdout.split('\n');
|
|
1585
1615
|
const file = path.resolve(root, hookRel);
|
|
1586
1616
|
let text;
|
|
1587
1617
|
try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
|
|
1588
|
-
if (!
|
|
1589
|
-
return [{ scope: 'product', item:
|
|
1590
|
-
}
|
|
1618
|
+
if (!spec.scripts(prefix).includes(text)) return [];
|
|
1619
|
+
return [{ scope: 'product', item: `${spec.item} (removed)`, status: 'removed', root, paths: [], apply: () => fs.rmSync(file, { force: true }) }];
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
const PRE_COMMIT_HOOK = Object.freeze({
|
|
1623
|
+
name: 'pre-commit',
|
|
1624
|
+
marker: GIT_HOOK_MARKER,
|
|
1625
|
+
scripts: (prefix) => gitPreCommitScripts(prefix),
|
|
1626
|
+
line: (prefix) => gitHookLine(prefix),
|
|
1627
|
+
applies: (root) => isVerifiedLedger(readJSON(productConfigPath(root))),
|
|
1628
|
+
item: 'pre-commit git hook (this clone)',
|
|
1629
|
+
// A tool that owns the hook (the pre-commit framework, husky v4) may rewrite it on reinstall, which drops
|
|
1630
|
+
// an added line, so the advice says to check after one.
|
|
1631
|
+
advice: (st) => (st?.state === 'hooks-path' ? `git's core.hooksPath is set (${st.hooksPath}), so yad did not install its pre-commit ledger guard; add this line to ${st.editFile}: ${st.line}`
|
|
1632
|
+
: st?.state === 'foreign' ? `${st.file} is not yad's, so yad left it alone; add this line to it to refuse a hand commit to the CI-owned ledger (and again if a tool rewrites the hook): ${st.line}` : null),
|
|
1633
|
+
});
|
|
1591
1634
|
|
|
1635
|
+
// The pre-commit hook (E48), as it always was.
|
|
1636
|
+
export const gitHookState = (root) => hookStateFor(PRE_COMMIT_HOOK, root);
|
|
1637
|
+
export const gitHookActions = (root) => hookActionsFor(PRE_COMMIT_HOOK, root);
|
|
1638
|
+
// A local ledger: the hook yad installed while the Product was verified has nothing to guard.
|
|
1639
|
+
export const orphanGitHookActions = (root) => orphanHookActionsFor(PRE_COMMIT_HOOK, root);
|
|
1592
1640
|
// The sentence for a clone where yad may not write the hook, or null.
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1641
|
+
export const gitHookAdvice = (st) => PRE_COMMIT_HOOK.advice(st);
|
|
1642
|
+
|
|
1643
|
+
// ---- the local setup notice after a pull (E185 part 4) -----------------------------------------------
|
|
1644
|
+
//
|
|
1645
|
+
// git's post-merge hook (after `git pull`, `git merge`) and post-rewrite hook (after `git pull --rebase`; an
|
|
1646
|
+
// `--amend` is left alone) say in one line which local setup steps the pull brought for this machine. They only
|
|
1647
|
+
// print and never fail the pull. Per clone like the pre-commit hook: each machine's `yad check --fix` (or setup,
|
|
1648
|
+
// update, join) installs them; every ledger mode; `"localSetupNotice": false` turns them off, and yad's exact
|
|
1649
|
+
// copies are then removed.
|
|
1650
|
+
//
|
|
1651
|
+
// The script they run is yad's own, copied from its package into this clone's git folder
|
|
1652
|
+
// (`<git-common-dir>/yad/local-setup-notice.mjs`), never a file of the Product's: a pull never changes git's
|
|
1653
|
+
// folder, so a pull can never make a teammate's machine run code the pull brought (review 1).
|
|
1654
|
+
export const NOTICE_HOOK_MARKER = '# yadflow local-setup notice (E185)';
|
|
1655
|
+
const NOTICE_ASSET = 'skills/yad-checks/templates/hooks/local-setup-notice.mjs';
|
|
1656
|
+
const noticeWanted = (root) => {
|
|
1657
|
+
if (!exists(productConfigPath(root))) return false;
|
|
1658
|
+
const cfg = readJSON(productConfigPath(root), null);
|
|
1659
|
+
return !(cfg && cfg.localSetupNotice === false);
|
|
1660
|
+
};
|
|
1661
|
+
// Where this clone keeps its copy, or null outside git.
|
|
1662
|
+
function noticeCopyPath(root) {
|
|
1663
|
+
const r = run('git', ['-C', root, 'rev-parse', '--git-common-dir']);
|
|
1664
|
+
return r.ok && r.stdout ? path.join(path.resolve(root, r.stdout), 'yad', 'local-setup-notice.mjs') : null;
|
|
1665
|
+
}
|
|
1666
|
+
// The hook finds the copy through git at run time, and tells it where the Product is within the repo.
|
|
1667
|
+
// When git cannot say where its folder is, nothing runs: never a fixed path (review 2).
|
|
1668
|
+
const NOTICE_FIND = 'd="$(git rev-parse --git-common-dir 2>/dev/null)" && [ -n "$d" ] || exit 0; notice="$d/yad/local-setup-notice.mjs"';
|
|
1669
|
+
// `|| d=`: a failing git never stops a team's hook that runs under `set -e` (review 3).
|
|
1670
|
+
const NOTICE_FIND_LINE = 'd="$(git rev-parse --git-common-dir 2>/dev/null)" || d=; notice="$d/yad/local-setup-notice.mjs"';
|
|
1671
|
+
const noticeHookScript = (name, prefix = '') => [
|
|
1672
|
+
'#!/bin/sh',
|
|
1673
|
+
`${NOTICE_HOOK_MARKER} — installed in this clone by \`yad check --fix\`.`,
|
|
1674
|
+
'# After a pull, says in one line which local setup steps it brought for this machine. It only prints and',
|
|
1675
|
+
'# never fails the pull. Skip it once with YAD_HOOK_DISABLE=1. yad rewrites this file; to stop it for the',
|
|
1676
|
+
'# whole team, set "localSetupNotice": false in .sdlc/product.json.',
|
|
1677
|
+
...(name === 'post-rewrite' ? ['[ "$1" = rebase ] || exit 0'] : []),
|
|
1678
|
+
NOTICE_FIND,
|
|
1679
|
+
'command -v node >/dev/null 2>&1 || exit 0',
|
|
1680
|
+
'[ -f "$notice" ] || exit 0',
|
|
1681
|
+
`node "$notice" ${shQuote(prefix || '.')} || true`,
|
|
1682
|
+
'exit 0',
|
|
1683
|
+
'',
|
|
1684
|
+
].join('\n');
|
|
1685
|
+
// The one line a person adds to a hook yad will not touch. post-rewrite's keeps the rebase-only rule.
|
|
1686
|
+
const noticeLine = (name, prefix = '') => {
|
|
1687
|
+
const body = `{ ${NOTICE_FIND_LINE}; [ -z "$d" ] || [ ! -f "$notice" ] || node "$notice" ${shQuote(prefix || '.')} || true; }`;
|
|
1688
|
+
return name === 'post-rewrite' ? `[ "$1" != rebase ] || ${body}` : body;
|
|
1689
|
+
};
|
|
1690
|
+
const NOTICE_HOOKS = Object.freeze(['post-merge', 'post-rewrite'].map((name) => Object.freeze({
|
|
1691
|
+
name,
|
|
1692
|
+
marker: NOTICE_HOOK_MARKER,
|
|
1693
|
+
scripts: (prefix) => [noticeHookScript(name, prefix)],
|
|
1694
|
+
line: (prefix) => noticeLine(name, prefix),
|
|
1695
|
+
applies: noticeWanted,
|
|
1696
|
+
// Wired by hand: a line that is not a comment and runs our copy for this Product's folder — and, for
|
|
1697
|
+
// post-rewrite, only on a rebase (review 3: a mention of the path alone is not enough).
|
|
1698
|
+
// A file with any carriage return is read as not wired: a CR after `}` breaks yad's line under sh, and one after
|
|
1699
|
+
// the `#!` line stops git running the file (reviews 4, 5). husky's sh would tolerate a CR on the `#!` or a comment
|
|
1700
|
+
// line alone — there yad only repeats its advice, the safe side (review 6).
|
|
1701
|
+
wired: (text, prefix) => !text.includes('\r') && text.split('\n').some((l) => !/^\s*#/.test(l) && l.includes('/yad/local-setup-notice.mjs')
|
|
1702
|
+
&& l.includes(`node "$notice" ${shQuote(prefix || '.')}`) && (name !== 'post-rewrite' || l.includes('[ "$1" != rebase ]'))),
|
|
1703
|
+
item: `${name} git hook (this clone)`,
|
|
1704
|
+
advice: () => null,
|
|
1705
|
+
})));
|
|
1706
|
+
|
|
1707
|
+
// The copy's state: { file, state: 'ok' | 'missing' | 'outdated' } | null outside git.
|
|
1708
|
+
export function noticeCopyState(root) {
|
|
1709
|
+
const file = noticeCopyPath(root);
|
|
1710
|
+
if (!file) return null;
|
|
1711
|
+
let text = null;
|
|
1712
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch { /* absent */ }
|
|
1713
|
+
const want = fs.readFileSync(asset(NOTICE_ASSET), 'utf8');
|
|
1714
|
+
return { file, want, state: text === null ? 'missing' : text === want ? 'ok' : 'outdated' };
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
// This clone's copy of the script, then both hooks. None of it is committed (`paths` is empty).
|
|
1718
|
+
export function localSetupNoticeActions(root) {
|
|
1719
|
+
if (!noticeWanted(root)) return [];
|
|
1720
|
+
const copy = noticeCopyState(root);
|
|
1721
|
+
const out = [];
|
|
1722
|
+
if (copy && copy.state !== 'ok') {
|
|
1723
|
+
out.push({ scope: 'product', item: 'local setup notice script (this clone, in git\'s folder)', status: copy.state === 'missing' ? 'new' : 'outdated', root, paths: [],
|
|
1724
|
+
apply: () => { fs.mkdirSync(path.dirname(copy.file), { recursive: true }); fs.writeFileSync(copy.file, copy.want); } });
|
|
1725
|
+
}
|
|
1726
|
+
return [...out, ...NOTICE_HOOKS.flatMap((spec) => hookActionsFor(spec, root))];
|
|
1727
|
+
}
|
|
1728
|
+
// Turned off: yad's exact hook copies come out, and the script's copy with them.
|
|
1729
|
+
export function orphanLocalSetupNoticeActions(root) {
|
|
1730
|
+
const out = NOTICE_HOOKS.flatMap((spec) => orphanHookActionsFor(spec, root));
|
|
1731
|
+
if (exists(productConfigPath(root)) && !noticeWanted(root)) {
|
|
1732
|
+
const copy = noticeCopyState(root);
|
|
1733
|
+
// yad's own file in git's folder, which nobody edits: removed whatever its version (review 2).
|
|
1734
|
+
if (copy && copy.state !== 'missing') out.push({ scope: 'product', item: 'local setup notice script (this clone) (removed)', status: 'removed', root, paths: [], apply: () => fs.rmSync(copy.file, { force: true }) });
|
|
1735
|
+
}
|
|
1736
|
+
return out;
|
|
1737
|
+
}
|
|
1738
|
+
// Each hook's state, for doctor: [{ name, ...hook state }].
|
|
1739
|
+
export const localSetupNoticeStates = (root) => NOTICE_HOOKS.map((spec) => ({ name: spec.name, ...hookStateFor(spec, root) }));
|
|
1740
|
+
// ONE sentence for the hooks yad may not write here (a team's own, or core.hooksPath), or null. A convenience,
|
|
1741
|
+
// not a guard: said by check --fix, update, setup and doctor, never on a plain `yad check` (review 1).
|
|
1742
|
+
export function localSetupNoticeAdvice(root) {
|
|
1743
|
+
const blocked = localSetupNoticeStates(root).filter((st) => st.applies && (st.state === 'foreign' || st.state === 'hooks-path'));
|
|
1744
|
+
if (!blocked.length) return null;
|
|
1745
|
+
const where = blocked.map((st) => (st.state === 'hooks-path' ? st.editFile : st.file));
|
|
1746
|
+
const lines = blocked.map((st) => `${st.name}: ${st.line}`).join(' · ');
|
|
1747
|
+
return `yad left ${blocked.map((st) => st.name).join(' and ')} alone (${blocked[0].state === 'hooks-path' ? `core.hooksPath is ${blocked[0].hooksPath}` : 'not yad\'s'}); for the local setup notice after a pull, add to ${where.join(' and ')} — ${lines}`;
|
|
1599
1748
|
}
|
|
1600
1749
|
|
|
1601
1750
|
// ---- background capture wiring (E43) -----------------------------------------------------------
|
package/cli/reconcile.mjs
CHANGED
|
@@ -15,13 +15,14 @@ import { VERSION, PROJECT_FILES, MANAGED_LEDGER, BACKUP_SUFFIX , productConfigPa
|
|
|
15
15
|
import {
|
|
16
16
|
moduleActions, repoActions, productActions, hookActions, agentFileActions, agentGuardActions, orphanAgentGuardActions, allowListActions, orphanAllowListActions, repoOrphanAgentGuardActions,
|
|
17
17
|
legacyModuleActions, removedModuleActions, orphanHookActions, captureHookActions, orphanCaptureHookActions, activityHookActions, orphanActivityHookActions, repoOrphanActivityActions, legacyHookScriptActions, legacyRepoActions, legacyProductActions,
|
|
18
|
-
ideTargetStateFor, recordManagedWrites, gitHookActions, orphanGitHookActions, gitHookState, gitHookAdvice, renamedNameHits, withoutKeptRenames, PRODUCT_PROFILE_GATES, productProfileGap, productProfileEffect, PRODUCT_PROFILE_FIX, workflowsPassingProduct, productGateBlockers, oldProfileAdvice,
|
|
18
|
+
ideTargetStateFor, recordManagedWrites, gitHookActions, orphanGitHookActions, gitHookState, gitHookAdvice, localSetupNoticeActions, orphanLocalSetupNoticeActions, localSetupNoticeAdvice, renamedNameHits, withoutKeptRenames, PRODUCT_PROFILE_GATES, productProfileGap, productProfileEffect, PRODUCT_PROFILE_FIX, workflowsPassingProduct, productGateBlockers, oldProfileAdvice,
|
|
19
19
|
} from './plan.mjs';
|
|
20
20
|
import { gitHead, packRepo } from './setup.mjs';
|
|
21
|
-
import { groupByRoot, commitUpdates, openUpdatePrs, repoLabel, updatePrBlocker, updateTargets, HELD_KINDS } from './update-commit.mjs';
|
|
21
|
+
import { groupByRoot, commitUpdates, openUpdatePrs, repoLabel, updatePrBlocker, updateTargets, HELD_KINDS, ignoreFileLines, ignoreRules } from './update-commit.mjs';
|
|
22
22
|
import { createPr } from './platform.mjs';
|
|
23
23
|
import { hasSiblingRepo, workspaceFileState, writeWorkspaceFile, WORKSPACE_FILE } from './find-product.mjs';
|
|
24
24
|
import { offerToolbox } from './toolbox.mjs';
|
|
25
|
+
import { localSetupActions, localSetupSection } from './local-setup.mjs';
|
|
25
26
|
|
|
26
27
|
const MARK = { missing: c.red('missing'), new: c.cyan('new'), outdated: c.yellow('outdated'), modified: c.cyan('modified'), stale: c.yellow('stale'), legacy: c.yellow('legacy'), removed: c.yellow('removed'), ok: c.green('ok') };
|
|
27
28
|
|
|
@@ -33,7 +34,7 @@ const repoShown = (repo) => `product (the code repo at ${forTerminal(repo.path)}
|
|
|
33
34
|
const shown = (a) => a.shownScope ?? a.scope;
|
|
34
35
|
const itemsOf = (actions) => actions.map((a) => ({ scope: a.scope, item: a.item, status: a.status, product: !a.fromRepo }));
|
|
35
36
|
|
|
36
|
-
export async function reconcile(root, { fix = false, scope = 'all', force = false, push = false, openPr = false, allowBranch = false, overwriteLocal = false, toolbox: toolboxAt = null, creator = createPr } = {}) {
|
|
37
|
+
export async function reconcile(root, { fix = false, scope = 'all', force = false, push = false, openPr = false, allowBranch = false, overwriteLocal = false, toolbox: toolboxAt = null, creator = createPr, invite = false } = {}) {
|
|
37
38
|
log(c.bold(`\nSDLC reconcile ${c.dim('v' + VERSION)}`));
|
|
38
39
|
log(c.dim(`target: ${root}\n`));
|
|
39
40
|
|
|
@@ -64,6 +65,8 @@ export async function reconcile(root, { fix = false, scope = 'all', force = fals
|
|
|
64
65
|
...withoutKeptRenames([...productActions(root), ...legacyProductActions(root)]), ...hookActions(root, ideTargets),
|
|
65
66
|
// E158: the rules block in AGENTS.md (and CLAUDE.md importing it), which every agent reads first.
|
|
66
67
|
...agentFileActions(root, ideTargets),
|
|
68
|
+
// E185: the local setup script for each team member's machine — yad's steps rewritten, the team's kept.
|
|
69
|
+
...localSetupActions(root),
|
|
67
70
|
// E158: the agent guard, before every shell command the agent runs.
|
|
68
71
|
...agentGuardActions(root, ideTargets), ...orphanAgentGuardActions(root, ideTargets),
|
|
69
72
|
// E158 (#353): the read-only yad commands, pre-approved for Claude Code.
|
|
@@ -71,6 +74,8 @@ export async function reconcile(root, { fix = false, scope = 'all', force = fals
|
|
|
71
74
|
...orphanHookActions(root, ideTargets),
|
|
72
75
|
// E48: this clone's git pre-commit hook — the person's half of the ledger guard.
|
|
73
76
|
...gitHookActions(root), ...orphanGitHookActions(root),
|
|
77
|
+
// E185 part 4: the notice after a pull — its script, and this clone's post-merge and post-rewrite hooks.
|
|
78
|
+
...localSetupNoticeActions(root), ...orphanLocalSetupNoticeActions(root),
|
|
74
79
|
// E43: the post-edit capture hook, in both ledger modes.
|
|
75
80
|
...captureHookActions(root, ideTargets), ...orphanCaptureHookActions(root, ideTargets),
|
|
76
81
|
// E178: the live activity record, only while the config says `"activity": true`.
|
|
@@ -158,6 +163,9 @@ export async function reconcile(root, { fix = false, scope = 'all', force = fals
|
|
|
158
163
|
// A hook yad may not write (someone else's, or a hooks folder a tool manages) has no action; say so.
|
|
159
164
|
const gitHookNote = gitHookAdvice(gitHookState(root));
|
|
160
165
|
if (gitHookNote) warn(gitHookNote);
|
|
166
|
+
// The pull notice is a convenience, not a guard: its one line for a hook yad left alone only on --fix/update.
|
|
167
|
+
const noticeNote = fix ? localSetupNoticeAdvice(root) : null;
|
|
168
|
+
if (noticeNote) info(noticeNote);
|
|
161
169
|
const shownInvalid = ideState.invalid.map((v) => {
|
|
162
170
|
try { return JSON.stringify(v) ?? String(v); } catch { return String(v); }
|
|
163
171
|
});
|
|
@@ -263,7 +271,8 @@ export async function reconcile(root, { fix = false, scope = 'all', force = fals
|
|
|
263
271
|
if (fixable.length || gaps.length) hand('run `yad check --fix` to reconcile (or `yad setup` for missing one-time setup).');
|
|
264
272
|
// After the --fix hint, never above it: --fix installs no tool, and must not read as if it did.
|
|
265
273
|
const toolbox = toolboxSection(root, toolboxAt);
|
|
266
|
-
|
|
274
|
+
const localSetup = localSetupSection(root);
|
|
275
|
+
return { fix: false, counts, gaps, items: itemsOf(actions), applied: 0, modified: modified.length, commits: [], workspaceFile, toolbox, localSetup };
|
|
267
276
|
}
|
|
268
277
|
|
|
269
278
|
// Each repo's default branch and platform, for --push and --open-pr.
|
|
@@ -300,7 +309,8 @@ export async function reconcile(root, { fix = false, scope = 'all', force = fals
|
|
|
300
309
|
fail(`--open-pr: ${stop.length} repo(s) cannot take the update as a PR/MR now — nothing was written; fix the above, then run it again`);
|
|
301
310
|
process.exitCode = 1;
|
|
302
311
|
const toolbox = toolboxSection(root, toolboxAt);
|
|
303
|
-
|
|
312
|
+
const localSetup = localSetupSection(root);
|
|
313
|
+
return { fix: true, counts, gaps, items: itemsOf(actions), applied: 0, modified: modified.length, commits: stop.map(([r, b]) => row(r, b)), workspaceFile, toolbox, localSetup };
|
|
304
314
|
}
|
|
305
315
|
held = new Set(checks.filter(([, b]) => b).map(([r]) => r));
|
|
306
316
|
heldRows = checks.filter(([, b]) => b).map(([r, b]) => row(r, b));
|
|
@@ -308,7 +318,8 @@ export async function reconcile(root, { fix = false, scope = 'all', force = fals
|
|
|
308
318
|
if (held.size === checks.length) {
|
|
309
319
|
info('every repo\'s update is already merged or on review — nothing written');
|
|
310
320
|
const toolbox = toolboxSection(root, toolboxAt);
|
|
311
|
-
|
|
321
|
+
const localSetup = localSetupSection(root);
|
|
322
|
+
return { fix: true, counts, gaps, items: itemsOf(actions), applied: 0, modified: modified.length, commits: checks.map(([r, b]) => row(r, b)), workspaceFile, toolbox, localSetup };
|
|
312
323
|
}
|
|
313
324
|
fixable = fixable.filter((a) => (!a.root || reached.has(a.root)) && !held.has(a.root) && (!a.managed?.root || reached.has(a.managed.root)) && !held.has(a.managed?.root));
|
|
314
325
|
}
|
|
@@ -337,10 +348,10 @@ export async function reconcile(root, { fix = false, scope = 'all', force = fals
|
|
|
337
348
|
// yad's block is merged into (E158 review 1).
|
|
338
349
|
let head;
|
|
339
350
|
if (a.kind === 'text') {
|
|
340
|
-
const r = spawnSync('git', ['show', `HEAD
|
|
351
|
+
const r = spawnSync('git', ['show', `HEAD:./${a.shared}`], { cwd: a.root, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, windowsHide: true });
|
|
341
352
|
head = r.status === 0 ? r.stdout : null;
|
|
342
353
|
} else {
|
|
343
|
-
const r = run('git', ['show', `HEAD
|
|
354
|
+
const r = run('git', ['show', `HEAD:./${a.shared}`], { cwd: a.root, maxBuffer: 64 * 1024 * 1024 });
|
|
344
355
|
head = r.ok ? r.stdout : null;
|
|
345
356
|
}
|
|
346
357
|
shared.set(file, { a, merges: [], disk: sharedText(file), head });
|
|
@@ -387,7 +398,8 @@ export async function reconcile(root, { fix = false, scope = 'all', force = fals
|
|
|
387
398
|
}
|
|
388
399
|
const sharedRows = [];
|
|
389
400
|
const lf = (t) => t.replace(/\r\n/g, '\n');
|
|
390
|
-
|
|
401
|
+
// A byte-order mark (some Windows editors add one) is read past, as the files' own readers do.
|
|
402
|
+
const parse = (t) => { try { const v = JSON.parse(t.charCodeAt(0) === 0xfeff ? t.slice(1) : t); return v && typeof v === 'object' && !Array.isArray(v) ? v : null; } catch { return null; } };
|
|
391
403
|
// A settings file is JSON, merged as objects; a rules file (AGENTS.md, CLAUDE.md, E158) is text, with yad's
|
|
392
404
|
// block put into it. Each kind: how to read it, merge yad's part in, and compare.
|
|
393
405
|
const KINDS = {
|
|
@@ -407,12 +419,40 @@ export async function reconcile(root, { fix = false, scope = 'all', force = fals
|
|
|
407
419
|
// yad's parts are all committed already: nothing of yad's is left out, and the person's own edits in the
|
|
408
420
|
// file are theirs to keep or share — no row (E157 update review 12).
|
|
409
421
|
if (ours !== undefined && base !== null && k.same(ours, base)) continue;
|
|
422
|
+
// A file with no committed copy that an ignore rule hides can never ride a PR/MR (git refuses to add it,
|
|
423
|
+
// #555). A rule whose line is in its ignore file's committed copy is the team's choice: the file stays on each machine,
|
|
424
|
+
// where each person's `yad update` or `yad check --fix` writes it — said once, no row. Any other rule (a
|
|
425
|
+
// global ignore, `.git/info/exclude`, or a `.gitignore` line not committed) is only this machine's: the row
|
|
426
|
+
// stays, naming the rule and the way out — also when the file is yad's alone, which staging would
|
|
427
|
+
// otherwise drop without a word.
|
|
428
|
+
const what = e.a.what ?? k.what;
|
|
429
|
+
const tracked = e.head !== null || run('git', ['ls-files', '--error-unmatch', '--', e.a.shared], { cwd: e.a.root }).ok;
|
|
430
|
+
const rule = tracked ? null : ignoreRules(e.a.root, [e.a.shared]).get(e.a.shared);
|
|
431
|
+
const at = rule ? `${rule.source}${rule.line ? `:${rule.line}` : ''}` : '';
|
|
432
|
+
// The team's rule is one its committed ignore file holds: the same line in `HEAD:<source>`, wherever it
|
|
433
|
+
// sits there, so an unrelated edit to that file not yet committed changes nothing (review 2). Read as
|
|
434
|
+
// committed, never trimmed as a whole (`run` trims).
|
|
435
|
+
const committedLines = () => {
|
|
436
|
+
const r = spawnSync('git', ['show', `HEAD:./${rule.source}`], { cwd: e.a.root, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, windowsHide: true });
|
|
437
|
+
return r.status === 0 ? ignoreFileLines(r.stdout) : [];
|
|
438
|
+
};
|
|
439
|
+
const teams = rule && !rule.outside && committedLines().includes(rule.pattern);
|
|
440
|
+
if (teams) {
|
|
441
|
+
info(`${repoLabel(root, e.a.root)}: ${e.a.shared} is ignored by ${at}, so it stays on each machine; the update leaves it out of the PR/MR`);
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
if (rule) {
|
|
445
|
+
const hint = `an ignore rule only this machine has (${at}, \`${rule.pattern}\`${rule.outside ? '' : ', not committed'}) hides ${e.a.shared}, so the update left ${what} out of the PR/MR: remove or narrow that rule, or commit it with \`git add -f ${e.a.shared}\`, through review on a branch of your own`;
|
|
446
|
+
info(`${repoLabel(root, e.a.root)}: ${hint}`);
|
|
447
|
+
sharedRows.push({ label: repoLabel(root, e.a.root), product: e.a.root === root, branch: null, committed: false, pushed: false, opened: false, pr: null, skipped: true, error: false, reason: k.reason, hint });
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
410
450
|
const was = e.disk === null ? null : k.read(e.disk);
|
|
411
451
|
const yadsAlone = e.disk === null ? e.head === null
|
|
412
452
|
: e.head !== null && k.eq(e.disk, e.head) ? true
|
|
413
453
|
: !!(ours !== undefined && was !== null && k.same(was, ours));
|
|
414
454
|
if (yadsAlone) { appliedActions.push({ ...e.a, paths: [e.a.shared] }); continue; }
|
|
415
|
-
const hint = `${e.a.shared} has changes that are not committed, so the update left ${
|
|
455
|
+
const hint = `${e.a.shared} has changes that are not committed, so the update left ${what} out of the PR/MR: commit ${e.a.shared} as it now stands, through review on a branch of your own`;
|
|
416
456
|
info(`${repoLabel(root, e.a.root)}: ${hint}`);
|
|
417
457
|
sharedRows.push({ label: repoLabel(root, e.a.root), product: e.a.root === root, branch: null, committed: false, pushed: false, opened: false, pr: null, skipped: true, error: false, reason: k.reason, hint });
|
|
418
458
|
}
|
|
@@ -485,7 +525,9 @@ export async function reconcile(root, { fix = false, scope = 'all', force = fals
|
|
|
485
525
|
});
|
|
486
526
|
}
|
|
487
527
|
const toolbox = toolboxSection(root, toolboxAt);
|
|
488
|
-
|
|
528
|
+
// `invite`: `yad update` asks for the line inviting the team's own steps; `check --fix` does not (E185 part 3).
|
|
529
|
+
const localSetup = localSetupSection(root, { invite });
|
|
530
|
+
return { fix: true, counts, gaps, items: itemsOf(actions), applied, modified: modified.length, commits, workspaceFile, toolbox, localSetup };
|
|
489
531
|
}
|
|
490
532
|
|
|
491
533
|
// E85: `yad check` and `yad update` end with the toolbox check — the tools this Product uses that are not
|
package/cli/reports-dir.mjs
CHANGED
|
@@ -32,6 +32,7 @@ import path from 'node:path';
|
|
|
32
32
|
import { spawnSync } from 'node:child_process';
|
|
33
33
|
import { randomBytes } from 'node:crypto';
|
|
34
34
|
import { readJSONStrict, writeJSON } from './lib.mjs';
|
|
35
|
+
import { brandForPage } from './brand.mjs';
|
|
35
36
|
|
|
36
37
|
export const REPORTS_SUFFIX = '--reports';
|
|
37
38
|
export const CATALOG_FILE = 'catalog.json';
|
|
@@ -228,7 +229,7 @@ const madeAt = (iso) => { const d = new Date(iso); return Number.isFinite(d.getT
|
|
|
228
229
|
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (ch) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[ch]));
|
|
229
230
|
|
|
230
231
|
// The catalog page. Static: no script, no network; links are relative, so the folder can be moved.
|
|
231
|
-
export function renderIndex(entries) {
|
|
232
|
+
export function renderIndex(entries, { brandCss = '' } = {}) {
|
|
232
233
|
const kinds = [...new Set(entries.map((e) => e.kind))].sort((a, b) => (KINDS[a] || a).localeCompare(KINDS[b] || b));
|
|
233
234
|
const section = (k) => {
|
|
234
235
|
const rows = entries.filter((e) => e.kind === k).sort((a, b) => String(b.createdAt).localeCompare(String(a.createdAt)));
|
|
@@ -237,7 +238,7 @@ export function renderIndex(entries) {
|
|
|
237
238
|
};
|
|
238
239
|
return `<!doctype html>
|
|
239
240
|
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
240
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'">
|
|
241
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:; font-src data:">
|
|
241
242
|
<title>Saved reports</title>
|
|
242
243
|
<style>
|
|
243
244
|
:root{--bg:#fbfbfd;--ink:#1d2333;--muted:#667089;--line:#e3e6ee;--tag:#eef1f8;--link:#2457c5}
|
|
@@ -248,6 +249,7 @@ h2{font-size:15px;margin:26px 0 8px}h2 small{color:var(--muted);font-weight:500}
|
|
|
248
249
|
table{border-collapse:collapse;width:100%;display:block;overflow-x:auto}th,td{text-align:left;padding:6px 10px;border-top:1px solid var(--line);white-space:nowrap}
|
|
249
250
|
th{color:var(--muted);font-weight:600;font-size:12px;border-top:0}a{color:var(--link)}
|
|
250
251
|
.tag{background:var(--tag);border-radius:4px;padding:1px 6px;font-size:12px;color:var(--muted)}code{font-size:12px}
|
|
252
|
+
${brandCss}
|
|
251
253
|
</style></head><body><main>
|
|
252
254
|
<h1>Saved reports</h1>
|
|
253
255
|
<p>Each report shows the state of the work when it was made. They are kept on this machine only and never committed. Run <code>yad reports list</code> to see which ones are stale.</p>
|
|
@@ -287,7 +289,7 @@ export function saveReport(root, { kind, scope, state, ext, content, command = n
|
|
|
287
289
|
const entry = { file: `${kind}/${name}`, kind, scope: String(scope ?? ''), state: String(state ?? ''), createdAt: at.toISOString(), ...productAt(root, runner), anonymous: !!anonymous, command };
|
|
288
290
|
const entries = [...cat.entries, entry];
|
|
289
291
|
writeJSON(path.join(dir, CATALOG_FILE), { version: CATALOG_VERSION, entries });
|
|
290
|
-
writeNew(path.join(dir, INDEX_FILE), renderIndex(entries));
|
|
292
|
+
writeNew(path.join(dir, INDEX_FILE), renderIndex(entries, { brandCss: brandForPage(root, 'catalog').css }));
|
|
291
293
|
return {};
|
|
292
294
|
}, { waitMs: lockWaitMs });
|
|
293
295
|
if (done.problem) warnings.push(done.held ? `the report was saved at ${file}, but not added to the catalog: ${done.problem}. It is in the folder; open it by that path` : done.problem);
|
|
@@ -370,7 +372,7 @@ export function pruneReports(root, { days = null, apply = false, now = Date.now(
|
|
|
370
372
|
if (sst && (sst.isFile() || sst.isSymbolicLink())) fs.rmSync(side, { force: true });
|
|
371
373
|
}
|
|
372
374
|
writeJSON(path.join(dir, CATALOG_FILE), { version: CATALOG_VERSION, entries: p.kept });
|
|
373
|
-
writeNew(path.join(dir, INDEX_FILE), renderIndex(p.kept));
|
|
375
|
+
writeNew(path.join(dir, INDEX_FILE), renderIndex(p.kept, { brandCss: brandForPage(root, 'catalog').css }));
|
|
374
376
|
return p;
|
|
375
377
|
};
|
|
376
378
|
let r;
|
package/cli/scan.mjs
CHANGED
|
@@ -9,6 +9,8 @@ import fs from 'node:fs';
|
|
|
9
9
|
import { createHash } from 'node:crypto';
|
|
10
10
|
import { run, readJSON, forTerminal, c, log, fail, hand, info, warn, emitJSON } from './lib.mjs';
|
|
11
11
|
import { productConfigPath } from './manifest.mjs';
|
|
12
|
+
import { redact, redactTokens } from './secret-text.mjs';
|
|
13
|
+
export { redact, redactTokens };
|
|
12
14
|
import { productIdentity } from './members.mjs';
|
|
13
15
|
import { prTarget } from './pr-list.mjs';
|
|
14
16
|
import { repoSources } from './standup.mjs';
|
|
@@ -68,11 +70,7 @@ export const fingerprint = (f) => createHash('sha256').update(JSON.stringify([f.
|
|
|
68
70
|
|
|
69
71
|
// ---- making text safe to post ------------------------------------------------------------------------
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
// Text a person wrote keeps its commit hashes and long names: only tokens with a known prefix are redacted.
|
|
73
|
-
const PREFIXED = /(gh[pousr]_[A-Za-z0-9]{10,}|github_pat_[A-Za-z0-9_]{10,}|glpat-[A-Za-z0-9_-]{10,}|AKIA[0-9A-Z]{12,}|xox[abprs]-[A-Za-z0-9-]{10,}|sk-[A-Za-z0-9_-]{16,}|eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}(?:\.[A-Za-z0-9_-]+)?|-----BEGIN[^-]*-----)/g;
|
|
74
|
-
export const redactTokens = (s) => String(s ?? '').replace(PREFIXED, '[redacted]');
|
|
75
|
-
export const redact = (s) => String(s ?? '').replace(SECRET, '[redacted]');
|
|
73
|
+
// The patterns live in cli/secret-text.mjs, shared with the local setup script (E185 part 3).
|
|
76
74
|
const plain = (s, max) => { const t = forTerminal(redact(s)).replace(/\s+/g, ' ').trim(); return t.length > max ? `${t.slice(0, max - 1)}…` : t; };
|
|
77
75
|
// An invisible space after each trigger stops a mention or a reference. GitHub reads backslashes and HTML entities as
|
|
78
76
|
// the real character before it looks for one, so neither of those is enough (checked against its renderer).
|