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.
Files changed (42) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +2 -0
  3. package/bin/commands.mjs +2 -0
  4. package/bin/yad.mjs +55 -2
  5. package/cli/agent-rules.mjs +26 -1
  6. package/cli/argv-flags.mjs +1 -1
  7. package/cli/brain/view/index.html +1 -1
  8. package/cli/brain/view/live.html +1 -1
  9. package/cli/brain-view.mjs +5 -4
  10. package/cli/brand-cmd.mjs +326 -0
  11. package/cli/brand.mjs +327 -0
  12. package/cli/doctor.mjs +65 -1
  13. package/cli/guide.mjs +26 -3
  14. package/cli/issues.mjs +9 -3
  15. package/cli/local-page.mjs +2 -2
  16. package/cli/local-setup-record.mjs +71 -0
  17. package/cli/local-setup-steps.mjs +186 -0
  18. package/cli/local-setup.mjs +611 -0
  19. package/cli/manifest.mjs +5 -0
  20. package/cli/map/view/index.html +1 -1
  21. package/cli/map-view.mjs +8 -4
  22. package/cli/plain-text.mjs +22 -0
  23. package/cli/plan.mjs +185 -36
  24. package/cli/reconcile.mjs +53 -11
  25. package/cli/reports-dir.mjs +6 -4
  26. package/cli/scan.mjs +3 -5
  27. package/cli/secret-text.mjs +66 -0
  28. package/cli/setup.mjs +25 -4
  29. package/cli/standup.mjs +8 -2
  30. package/cli/test-brand.mjs +558 -0
  31. package/cli/test-guide.mjs +227 -0
  32. package/cli/test-local-setup.mjs +1188 -0
  33. package/cli/toolbox.mjs +15 -1
  34. package/cli/update-commit.mjs +35 -18
  35. package/cli/usage.mjs +9 -3
  36. package/cli/workspace.mjs +11 -2
  37. package/package.json +3 -3
  38. package/skills/sdlc/module-help.csv +1 -0
  39. package/skills/yad-brand/SKILL.md +69 -0
  40. package/skills/yad-checks/templates/hooks/local-setup-notice.mjs +96 -0
  41. package/skills/yad-checks/templates/hooks/yad-activity.mjs +2 -2
  42. package/skills/yad-guide/SKILL.md +9 -6
@@ -32,6 +32,7 @@ const { buildGuide, stepFacts, playbook, tok, agentRun } = await import('./guide
32
32
  const COMMAND_CLASS_MODULE = await import('./agent-rules.mjs');
33
33
  const { COMMAND_CLASS, CLASSES, ASK, RULES, HUMAN_ONLY_ACTS, NEVER, classify, askFor } = await import('./agent-rules.mjs');
34
34
  const { DEFAULT_LIFECYCLE } = await import('./lifecycle.mjs');
35
+ const TOOLBOX_IDS = (await import('./toolbox.mjs')).TOOLBOX.map((t) => t.id);
35
36
  const { runEpicNew } = await import('./epic.mjs');
36
37
  const { gateOpen } = await import('./gate.mjs');
37
38
 
@@ -608,6 +609,52 @@ test('an install behind yadflow: the guide says so, from what is committed, and
608
609
  } finally { fs.rmSync(T, { recursive: true, force: true }); }
609
610
  });
610
611
 
612
+ test('local setup steps waiting for this machine ride the upkeep, after the update, and the guide starts no gh (E185)', async () => {
613
+ const { localSetupActions, runLocalSetupSkip } = await import('./local-setup.mjs');
614
+ const { VERSION } = await import('./manifest.mjs');
615
+ const T = await product();
616
+ const saved = [console.log, process.exitCode, process.env.PATH];
617
+ console.log = () => {};
618
+ try {
619
+ put(path.join(T, '.sdlc/cli-version.json'), { version: VERSION });
620
+ // Every shipped tool skipped, and one team step.
621
+ put(path.join(T, '.sdlc/toolbox.json'), { shipped: Object.fromEntries(TOOLBOX_IDS.map((id) => [id, 'skip'])) });
622
+ for (const a of localSetupActions(T)) if (!a.writesNothing) a.apply();
623
+ const file = path.join(T, '.sdlc/local-setup.json');
624
+ const team = { id: 'docker', title: 'Install Docker', purpose: 'runs the API', impact: 'adds Docker', when: 'optional', commands: ['brew install docker'], check: { run: 'docker --version' } };
625
+ put(file, { ...JSON.parse(fs.readFileSync(file, 'utf8')), team: [team] });
626
+ git(T, ['add', '-A']); git(T, ['commit', '-q', '-m', 'chore: local setup']);
627
+
628
+ // A gh or glab the guide started would leave a mark: none may (the login check can reach the network).
629
+ const calls = path.join(T, '.calls');
630
+ if (process.platform !== 'win32') {
631
+ const bin = path.join(T, '.bin');
632
+ fs.mkdirSync(bin);
633
+ for (const name of ['gh', 'glab']) { const f = path.join(bin, name); fs.writeFileSync(f, `#!/bin/sh\necho ${name} >> '${calls}'\nexit 1\n`); fs.chmodSync(f, 0o755); }
634
+ process.env.PATH = `${bin}${path.delimiter}${saved[2]}`;
635
+ }
636
+ const g = buildGuide(T, { epic: 'EP-pay' });
637
+ assert.ok(!fs.existsSync(calls), 'the guide started gh or glab');
638
+ assert.ok(g.upkeep.localSetup.ask.includes('platform-login'), 'judged by the record: not checked here');
639
+ assert.ok(g.upkeep.localSetup.ask.includes('docker'));
640
+ assert.equal(g.upkeep.agent.length, 1, 'not behind: only the local setup');
641
+ const run = g.upkeep.agent[0];
642
+ assert.deepEqual([run.run, run.class, run.ask], ['yad local-setup list --json', 'read', 'never']);
643
+ assert.match(run.why, /docker/);
644
+ assert.ok(RULES.some((r) => r.id === 'local-setup'));
645
+
646
+ // The person said no: it waits no more.
647
+ runLocalSetupSkip(T, { ids: ['docker'], reason: 'not for me' });
648
+ assert.ok(!buildGuide(T, { epic: 'EP-pay' }).upkeep.localSetup.ask.includes('docker'));
649
+
650
+ // Behind as well: the update comes first.
651
+ put(path.join(T, '.sdlc/cli-version.json'), { version: '4.0.0' });
652
+ git(T, ['add', '-A']); git(T, ['commit', '-q', '-m', 'chore: old stamp']);
653
+ const both = buildGuide(T, { epic: 'EP-pay' }).upkeep;
654
+ assert.deepEqual(both.agent.map((x) => x.run), ['yad update --open-pr --json', 'yad local-setup list --json']);
655
+ } finally { [console.log, process.exitCode, process.env.PATH] = saved; fs.rmSync(T, { recursive: true, force: true }); }
656
+ });
657
+
611
658
  // Two clones of one Product with an origin, for the run's own reading of what origin holds.
612
659
  async function twoClones() {
613
660
  const P = tmp();
@@ -897,6 +944,186 @@ test('AGENTS.md with the team\'s own uncommitted edits never rides the update: s
897
944
  } finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
898
945
  });
899
946
 
947
+ // #555: a shared file the repo's own .gitignore keeps out of git can never ride a PR/MR, so it gets no row.
948
+ for (const [label, rule] of [['the file', '.claude/settings.json'], ['its folder', '.claude/']]) {
949
+ test(`#555: hook settings the Product gitignores (a rule on ${label}) get no row, and stay as they are`, async () => {
950
+ const { reconcile } = await import('./reconcile.mjs');
951
+ const { P, R, A } = await twoClones();
952
+ try {
953
+ const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/10' });
954
+ put(path.join(A, '.gitignore'), `${rule}\n`);
955
+ git(A, ['add', '.gitignore']); git(A, ['commit', '-q', '-m', 'chore: ignore']); git(A, ['push', '-q']);
956
+ put(path.join(A, '.claude/settings.json'), { permissions: { allow: ['Bash(ls)'] } });
957
+ const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
958
+ assert.ok(!r.commits.some((c) => c.reason === 'settings-uncommitted'), JSON.stringify(r.commits));
959
+ assert.ok(r.commits.some((c) => c.opened), JSON.stringify(r.commits));
960
+ const files = git(R, ['diff', '--name-only', 'main', `chore/yad-update-v${(await import('./manifest.mjs')).VERSION}`]).split('\n');
961
+ assert.ok(!files.includes('.claude/settings.json'), files.join(', '));
962
+ assert.match(fs.readFileSync(path.join(A, '.claude/settings.json'), 'utf8'), /Bash\(ls\)/, 'their entry is still there');
963
+ } finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
964
+ });
965
+ }
966
+
967
+ test('#555: hook settings hidden by a rule only this machine has keep the row, naming the rule and git add -f', async () => {
968
+ const { reconcile } = await import('./reconcile.mjs');
969
+ const { P, A } = await twoClones();
970
+ try {
971
+ const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/11' });
972
+ put(path.join(A, '.git/info/exclude'), '.claude/settings.json\n');
973
+ put(path.join(A, '.claude/settings.json'), { permissions: { allow: ['Bash(ls)'] } });
974
+ const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
975
+ const row = r.commits.find((c) => c.reason === 'settings-uncommitted');
976
+ assert.ok(row, JSON.stringify(r.commits));
977
+ assert.match(row.hint, /an ignore rule only this machine has \(\.git\/info\/exclude:1, `\.claude\/settings\.json`\) hides \.claude\/settings\.json/);
978
+ assert.match(row.hint, /git add -f \.claude\/settings\.json/);
979
+ } finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
980
+ });
981
+
982
+ // The settings file is yad's alone (this run writes it from nothing): a committed rule still gets no row, and a
983
+ // rule only this machine has gets the row — staging would otherwise drop it without a word (review 1).
984
+ test('#555: settings this run creates, hidden by a committed .gitignore: no row, the PR/MR opens', async () => {
985
+ const { reconcile } = await import('./reconcile.mjs');
986
+ const { P, A } = await twoClones();
987
+ try {
988
+ const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/13' });
989
+ put(path.join(A, '.gitignore'), '.claude/settings.json\n');
990
+ git(A, ['add', '.gitignore']); git(A, ['commit', '-q', '-m', 'chore: ignore']); git(A, ['push', '-q']);
991
+ assert.ok(!fs.existsSync(path.join(A, '.claude/settings.json')));
992
+ const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
993
+ assert.ok(!r.commits.some((c) => c.reason === 'settings-uncommitted'), JSON.stringify(r.commits));
994
+ assert.ok(r.commits.some((c) => c.opened), JSON.stringify(r.commits));
995
+ assert.ok(fs.existsSync(path.join(A, '.claude/settings.json')), 'written on this machine');
996
+ } finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
997
+ });
998
+
999
+ for (const [label, hide, source] of [
1000
+ ['.git/info/exclude', (A) => put(path.join(A, '.git/info/exclude'), '.claude/settings.json\n'), /\.git\/info\/exclude:1/],
1001
+ ['a global ignore file', (A, P) => { put(path.join(P, 'global-ignore'), '.claude/\n'); git(A, ['config', 'core.excludesFile', path.join(P, 'global-ignore')]); }, /global-ignore:1, `\.claude\/`\)/],
1002
+ ['a .gitignore line not committed', (A) => put(path.join(A, '.gitignore'), '.claude/settings.json\n'), /\(\.gitignore:1, `\.claude\/settings\.json`, not committed\)/],
1003
+ ]) {
1004
+ test(`#555: settings this run creates, hidden by ${label}: the row names the rule and git add -f`, async () => {
1005
+ const { reconcile } = await import('./reconcile.mjs');
1006
+ const { P, A } = await twoClones();
1007
+ try {
1008
+ const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/14' });
1009
+ hide(A, P);
1010
+ const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
1011
+ const row = r.commits.find((c) => c.reason === 'settings-uncommitted');
1012
+ assert.ok(row, JSON.stringify(r.commits));
1013
+ assert.match(row.hint, source);
1014
+ assert.match(row.hint, /hides \.claude\/settings\.json, so the update left its entries \(hooks, the read-only allow list\) out of the PR\/MR/);
1015
+ assert.match(row.hint, /git add -f \.claude\/settings\.json/);
1016
+ } finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
1017
+ });
1018
+ }
1019
+
1020
+ // The team's rule is a line the committed ignore file holds (review 2): an unrelated edit not yet committed, or
1021
+ // the line moved, keeps it the team's; the line added but not committed is this machine's.
1022
+ test('#555: a committed .gitignore rule stays the team\'s beside an unrelated edit not yet committed', async () => {
1023
+ const { reconcile } = await import('./reconcile.mjs');
1024
+ const { P, A } = await twoClones();
1025
+ try {
1026
+ const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/16' });
1027
+ put(path.join(A, '.gitignore'), 'node_modules/\n.claude/settings.json\n');
1028
+ git(A, ['add', '.gitignore']); git(A, ['commit', '-q', '-m', 'chore: ignore']); git(A, ['push', '-q']);
1029
+ put(path.join(A, '.gitignore'), '.env.local\nnode_modules/\n.claude/settings.json\n');
1030
+ put(path.join(A, '.claude/settings.json'), { permissions: { allow: ['Bash(ls)'] } });
1031
+ const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
1032
+ assert.ok(!r.commits.some((c) => c.reason === 'settings-uncommitted'), JSON.stringify(r.commits));
1033
+ assert.ok(r.commits.some((c) => c.opened), JSON.stringify(r.commits));
1034
+ } finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
1035
+ });
1036
+
1037
+ test('#555: a committed .gitignore with a byte-order mark and Windows line endings still holds the team\'s rule', async () => {
1038
+ const { reconcile } = await import('./reconcile.mjs');
1039
+ const { P, A } = await twoClones();
1040
+ try {
1041
+ const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/18' });
1042
+ put(path.join(A, '.gitignore'), '\uFEFF.claude/settings.json \r\nnode_modules/\r\n');
1043
+ git(A, ['add', '.gitignore']); git(A, ['commit', '-q', '-m', 'chore: ignore']); git(A, ['push', '-q']);
1044
+ put(path.join(A, '.claude/settings.json'), { permissions: { allow: ['Bash(ls)'] } });
1045
+ const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
1046
+ assert.ok(!r.commits.some((c) => c.reason === 'settings-uncommitted'), JSON.stringify(r.commits));
1047
+ assert.ok(r.commits.some((c) => c.opened), JSON.stringify(r.commits));
1048
+ } finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
1049
+ });
1050
+
1051
+ test('#555: a rule line added to a committed .gitignore but not committed is this machine\'s: the row stays', async () => {
1052
+ const { reconcile } = await import('./reconcile.mjs');
1053
+ const { P, A } = await twoClones();
1054
+ try {
1055
+ const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/17' });
1056
+ put(path.join(A, '.gitignore'), 'node_modules/\n');
1057
+ git(A, ['add', '.gitignore']); git(A, ['commit', '-q', '-m', 'chore: ignore']); git(A, ['push', '-q']);
1058
+ put(path.join(A, '.gitignore'), 'node_modules/\n.claude/settings.json\n');
1059
+ put(path.join(A, '.claude/settings.json'), { permissions: { allow: ['Bash(ls)'] } });
1060
+ const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
1061
+ const row = r.commits.find((c) => c.reason === 'settings-uncommitted');
1062
+ assert.ok(row, JSON.stringify(r.commits));
1063
+ assert.match(row.hint, /\(\.gitignore:2, `\.claude\/settings\.json`, not committed\)/);
1064
+ } finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
1065
+ });
1066
+
1067
+ test('#555: the local setup file\'s row names its own steps, never the hook entries', async () => {
1068
+ const { reconcile } = await import('./reconcile.mjs');
1069
+ const { P, A } = await twoClones();
1070
+ try {
1071
+ const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/15' });
1072
+ put(path.join(A, '.git/info/exclude'), '.sdlc/local-setup.json\n');
1073
+ const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
1074
+ const row = r.commits.find((c) => /local-setup\.json/.test(c.hint ?? ''));
1075
+ assert.ok(row, JSON.stringify(r.commits));
1076
+ assert.match(row.hint, /left its yadflow steps out of the PR\/MR/);
1077
+ } finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
1078
+ });
1079
+
1080
+ test('#555: an AGENTS.md the Product gitignores gets no agents-uncommitted row either', async () => {
1081
+ const { reconcile } = await import('./reconcile.mjs');
1082
+ const { P, R, A } = await twoClones();
1083
+ try {
1084
+ const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/12' });
1085
+ put(path.join(A, '.gitignore'), 'AGENTS.md\n');
1086
+ git(A, ['add', '.gitignore']); git(A, ['commit', '-q', '-m', 'chore: ignore']); git(A, ['push', '-q']);
1087
+ put(path.join(A, 'AGENTS.md'), '# My own rules\n');
1088
+ const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
1089
+ assert.ok(!r.commits.some((c) => c.reason === 'agents-uncommitted'), JSON.stringify(r.commits));
1090
+ const files = git(R, ['diff', '--name-only', 'main', `chore/yad-update-v${(await import('./manifest.mjs')).VERSION}`]).split('\n');
1091
+ assert.ok(!files.includes('AGENTS.md'), files.join(', '));
1092
+ assert.match(fs.readFileSync(path.join(A, 'AGENTS.md'), 'utf8'), /# My own rules/, 'their text is still there');
1093
+ } finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
1094
+ });
1095
+
1096
+ test('#555: ignoreFileLines reads an ignore file\'s lines as git does', async () => {
1097
+ const { ignoreFileLines } = await import('./update-commit.mjs');
1098
+ const cases = [
1099
+ ['a ', 'a'], ['a\t', 'a\t'], ['a\\ ', 'a\\ '], ['a\\ ', 'a\\ '], ['a\\\\ ', 'a\\\\'],
1100
+ ['\\\\ ', '\\\\'], ['\\ ', '\\ '], [' ', ''], ['a\r', 'a'], ['a \r', 'a'],
1101
+ ['\\\\\\ ', '\\\\\\ '], ['a\\ \r', 'a\\ '],
1102
+ ];
1103
+ for (const [line, want] of cases) assert.deepEqual(ignoreFileLines(line), [want], JSON.stringify(line));
1104
+ assert.deepEqual(ignoreFileLines('\uFEFFx\r\ny\n'), ['x', 'y', '']);
1105
+ assert.deepEqual(ignoreFileLines('x\uFEFF'), ['x\uFEFF'], 'a mark only counts at the start');
1106
+ });
1107
+
1108
+ test('#555: ignoreRules names a file rule and a folder rule, says whose rule it is, and never counts a negation', async () => {
1109
+ const { ignoreRules } = await import('./update-commit.mjs');
1110
+ const P = tmp();
1111
+ try {
1112
+ git(P, ['init', '-q', '-b', 'main']);
1113
+ git(P, ['config', 'core.excludesFile', NO_GLOBAL_IGNORE]);
1114
+ put(path.join(P, '.gitignore'), 'secret.txt\nbuild/\n*.log\n!keep.log\n');
1115
+ put(path.join(P, '.git/info/exclude'), 'mine.md\n');
1116
+ for (const f of ['secret.txt', 'build/out.js', 'keep.log', 'mine.md', 'plain.md']) put(path.join(P, f), 'x');
1117
+ const got = ignoreRules(P, ['secret.txt', 'build/out.js', 'keep.log', 'mine.md', 'plain.md']);
1118
+ assert.deepEqual(got.get('secret.txt'), { source: '.gitignore', line: 1, pattern: 'secret.txt', outside: false });
1119
+ assert.deepEqual(got.get('build/out.js'), { source: '.gitignore', line: 2, pattern: 'build/', outside: false });
1120
+ assert.equal(got.get('mine.md').outside, true);
1121
+ assert.equal(got.get('mine.md').source, '.git/info/exclude');
1122
+ assert.ok(!got.has('keep.log') && !got.has('plain.md'), [...got.keys()].join(', '));
1123
+ assert.equal(ignoreRules(P, []).size, 0);
1124
+ } finally { fs.rmSync(P, { recursive: true, force: true }); }
1125
+ });
1126
+
900
1127
  test('a code repo yad never wired: its own AGENTS.md is left alone by update --open-pr, with no row', async () => {
901
1128
  const { reconcile } = await import('./reconcile.mjs');
902
1129
  const P = tmp();