yadflow 4.8.0 → 4.10.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 (107) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/README.md +4 -3
  3. package/bin/commands.mjs +7 -0
  4. package/bin/yad.mjs +123 -8
  5. package/cli/agent-guard.mjs +793 -65
  6. package/cli/agent-rules.mjs +40 -5
  7. package/cli/argv-flags.mjs +1 -1
  8. package/cli/build.mjs +1 -1
  9. package/cli/ci-check.mjs +45 -1
  10. package/cli/codeowners-command.mjs +72 -6
  11. package/cli/commit.mjs +17 -3
  12. package/cli/docs.mjs +2 -0
  13. package/cli/doctor.mjs +176 -12
  14. package/cli/epic-state.mjs +94 -4
  15. package/cli/epic.mjs +11 -7
  16. package/cli/fold.mjs +31 -6
  17. package/cli/guide.mjs +3 -1
  18. package/cli/hook.mjs +50 -7
  19. package/cli/issue-links.mjs +61 -0
  20. package/cli/issues-act.mjs +327 -0
  21. package/cli/issues-write.mjs +428 -0
  22. package/cli/issues.mjs +474 -0
  23. package/cli/lifecycle.mjs +7 -0
  24. package/cli/machine.mjs +141 -0
  25. package/cli/manifest.mjs +9 -3
  26. package/cli/openpr.mjs +69 -9
  27. package/cli/plan.mjs +2 -0
  28. package/cli/platform.mjs +157 -2
  29. package/cli/preview.mjs +253 -0
  30. package/cli/protection.mjs +21 -3
  31. package/cli/reconcile.mjs +1 -1
  32. package/cli/repo.mjs +64 -3
  33. package/cli/review.mjs +4 -0
  34. package/cli/run-checks.mjs +10 -2
  35. package/cli/scan.mjs +314 -0
  36. package/cli/setup.mjs +12 -3
  37. package/cli/standup.mjs +33 -7
  38. package/cli/story-frames.mjs +307 -0
  39. package/cli/test-agents-file.mjs +378 -11
  40. package/cli/test-build.mjs +25 -0
  41. package/cli/test-ci-check.mjs +469 -10
  42. package/cli/test-guide.mjs +7 -0
  43. package/cli/test-machine.mjs +140 -0
  44. package/cli/test-node.mjs +15 -0
  45. package/cli/test-preview.mjs +511 -0
  46. package/cli/test-run-checks.mjs +17 -0
  47. package/cli/test-setup-agent.mjs +14 -0
  48. package/cli/test-story-frames.mjs +409 -0
  49. package/cli/toolbox-connect.mjs +244 -0
  50. package/cli/toolbox.mjs +159 -5
  51. package/package.json +7 -3
  52. package/skills/sdlc/config.yaml +1 -1
  53. package/skills/sdlc/module-help.csv +3 -1
  54. package/skills/yad-analysis/SKILL.md +4 -0
  55. package/skills/yad-backfill/SKILL.md +4 -0
  56. package/skills/yad-change/SKILL.md +4 -0
  57. package/skills/yad-checks/SKILL.md +13 -7
  58. package/skills/yad-checks/references/check-gates.md +62 -30
  59. package/skills/yad-checks/templates/checks/member-check.mjs +3 -2
  60. package/skills/yad-checks/templates/checks/risk-map-check.sh +2 -2
  61. package/skills/yad-checks/templates/checks/verified-commits.sh +3 -3
  62. package/skills/yad-checks/templates/github/yad-checks.yml +357 -69
  63. package/skills/yad-checks/templates/github/yad-pr-text.yml +118 -0
  64. package/skills/yad-checks/templates/github/yad-product-checks.yml +130 -54
  65. package/skills/yad-checks/templates/github/yad-product-pr-text.yml +131 -0
  66. package/skills/yad-checks/templates/github/yad-update-guard.yml +2 -1
  67. package/skills/yad-checks/templates/github/yad-verified-commits.yml +49 -3
  68. package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +79 -20
  69. package/skills/yad-checks/templates/gitlab/yad-product-checks.gitlab-ci.yml +59 -9
  70. package/skills/yad-checks/templates/gitlab/yad-update-guard.gitlab-ci.yml +1 -0
  71. package/skills/yad-checks/templates/gitlab/yad-verified-commits.gitlab-ci.yml +49 -1
  72. package/skills/yad-checks/templates/hooks/agent-guard.mjs +44 -10
  73. package/skills/yad-checks/templates/hooks/ledger-guard-cursor.mjs +12 -6
  74. package/skills/yad-commit/SKILL.md +3 -1
  75. package/skills/yad-connect-design/SKILL.md +48 -13
  76. package/skills/yad-connect-design/references/design-context.md +56 -3
  77. package/skills/yad-connect-design/references/design-registry.md +4 -4
  78. package/skills/yad-connect-learning/SKILL.md +12 -2
  79. package/skills/yad-connect-repos/SKILL.md +12 -0
  80. package/skills/yad-connect-testing/SKILL.md +22 -5
  81. package/skills/yad-connect-testing/references/testing-context.md +1 -1
  82. package/skills/yad-engineer-review/SKILL.md +13 -0
  83. package/skills/yad-epic/SKILL.md +4 -0
  84. package/skills/yad-epic/references/state-schema.md +21 -0
  85. package/skills/yad-guide/SKILL.md +8 -4
  86. package/skills/yad-implement/SKILL.md +69 -3
  87. package/skills/yad-implement/references/implement-conventions.md +2 -1
  88. package/skills/yad-issues/SKILL.md +53 -0
  89. package/skills/yad-learn/SKILL.md +4 -0
  90. package/skills/yad-open-pr/SKILL.md +10 -1
  91. package/skills/yad-pair-review/SKILL.md +5 -0
  92. package/skills/yad-pr-template/SKILL.md +2 -1
  93. package/skills/yad-pr-template/templates/checks/pr-title.sh +34 -2
  94. package/skills/yad-pr-template/templates/github/pull_request_template.md +1 -0
  95. package/skills/yad-pr-template/templates/gitlab/merge_request_templates/Default.md +1 -0
  96. package/skills/yad-product-bridge/references/bridge.md +28 -0
  97. package/skills/yad-product-bridge/templates/github/yad-gate-sync.yml +25 -11
  98. package/skills/yad-product-bridge/templates/gitlab/yad-gate-sync.gitlab-ci.yml +38 -14
  99. package/skills/yad-review-companion/SKILL.md +4 -1
  100. package/skills/yad-run/SKILL.md +5 -0
  101. package/skills/yad-scan/SKILL.md +51 -0
  102. package/skills/yad-spec/SKILL.md +32 -0
  103. package/skills/yad-stories/SKILL.md +22 -0
  104. package/skills/yad-stories/references/story-schema.md +1 -0
  105. package/skills/yad-test-cases/SKILL.md +18 -2
  106. package/skills/yad-ui/SKILL.md +48 -8
  107. package/skills/yad-checks/templates/gitlab/.gitlab-ci.yml +0 -49
@@ -0,0 +1,140 @@
1
+ // #352: `yad doctor` checks the machine setup local work depends on — the active Node against each repo's
2
+ // pinned version, Docker only where a repo asks for it, and more than one glab config file.
3
+ import { test } from 'node:test';
4
+ import assert from 'node:assert/strict';
5
+ import { execFileSync } from 'node:child_process';
6
+ import fs from 'node:fs';
7
+ import os from 'node:os';
8
+ import path from 'node:path';
9
+
10
+ if (process.env.NODE_TEST_CONTEXT) {
11
+ const write = process.stdout.write;
12
+ for (const k of ['log', 'info']) {
13
+ const orig = console[k];
14
+ console[k] = (...a) => (process.stdout.write === write ? console.error(...a) : orig(...a));
15
+ }
16
+ }
17
+ process.env.YAD_NO_UPDATE_NOTIFIER = '1';
18
+
19
+ const { nodePins, satisfies, nodeFix, dockerReasons, dockerState, glabConfigs } = await import('./machine.mjs');
20
+ const { machineChecks } = await import('./doctor.mjs');
21
+
22
+ const tmp = () => fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'yad-machine-')));
23
+ const put = (file, data) => { fs.mkdirSync(path.dirname(file), { recursive: true }); fs.writeFileSync(file, typeof data === 'string' ? data : JSON.stringify(data)); };
24
+ const done = (T) => fs.rmSync(T, { recursive: true, force: true });
25
+
26
+ test('#352: satisfies reads the version forms repos pin, and says "not known" for the rest', () => {
27
+ const yes = [['24.22.1', '>= 22'], ['24.22.1', '>=22.0.0 <25'], ['25.0.0', '>24'], ['0.0.3', '^0.0.3'], ['24.22.1', '24'], ['24.22.1', 'v24.22.1'], ['24.22.1', '>=22'], ['24.22.1', '^24.1.0'], ['24.22.1', '~24.22.0'],
28
+ ['24.22.1', '22 || 24'], ['24.22.1', '>=20 <25'], ['24.22.1', '20 - 24.30'], ['24.22.1', '24.x'], ['24.22.1', '*'], ['22.8.0', '>=22.8'], ['24.22.1', '<=24']];
29
+ const no = [['22.8.0', '>22'], ['24.5.0', '>24.x'], ['24.1.9', '>24.1'], ['0.0.4', '^0.0.3'], ['20.19.5', '>= 22'], ['20.19.5', '24'], ['20.19.5', '>=22'], ['25.0.0', '^24.1.0'], ['24.23.0', '~24.22.0'], ['24.22.1', '<24'], ['24.22.1', '18 || 20'], ['21.0.0', '>=20 <21']];
30
+ for (const [v, s] of yes) assert.equal(satisfies(v, s), true, `${v} ${s}`);
31
+ for (const [v, s] of no) assert.equal(satisfies(v, s), false, `${v} ${s}`);
32
+ for (const s of ['lts/*', 'node', 'lts/iron', 'https://x', '24.0.0-rc.1']) assert.equal(satisfies('24.22.1', s), null, s);
33
+ assert.equal(satisfies('25.0.0-nightly', '>=22'), null, 'a pre-release Node is not judged');
34
+ });
35
+
36
+ test('#352: nodePins reads .nvmrc, .node-version, .tool-versions, engines.node and volta.node', () => {
37
+ const T = tmp();
38
+ try {
39
+ put(path.join(T, '.nvmrc'), '# the team\'s Node\n24\n');
40
+ put(path.join(T, '.node-version'), 'v24.1.0\n');
41
+ put(path.join(T, '.tool-versions'), 'python 3.12.1\nnodejs 24.2.0 # pinned\n');
42
+ put(path.join(T, 'package.json'), { engines: { node: '>=22' }, volta: { node: '24.3.0' } });
43
+ assert.deepEqual(nodePins(T), [
44
+ { source: '.nvmrc', want: '24' }, { source: '.node-version', want: 'v24.1.0' }, { source: '.tool-versions', want: '24.2.0' },
45
+ { source: 'package.json engines.node', want: '>=22' }, { source: 'package.json volta.node', want: '24.3.0' }]);
46
+ fs.rmSync(path.join(T, 'package.json'));
47
+ put(path.join(T, 'package.json'), '{ not json');
48
+ assert.equal(nodePins(T).length, 3, 'a package.json that does not parse pins nothing');
49
+ } finally { done(T); }
50
+ });
51
+
52
+ test('#352: the fix names nvm\'s commands when nvm is here, plain words otherwise', () => {
53
+ assert.match(nodeFix('24', { env: { NVM_DIR: '/x' }, home: '/nowhere' }), /^nvm install 24 && nvm use 24 \(and `nvm alias default 24`/);
54
+ assert.match(nodeFix('>=22', { env: { NVM_DIR: '/x' }, home: '/nowhere' }), /a version that meets >=22/);
55
+ assert.match(nodeFix('24', { env: {}, home: '/nowhere' }), /^install Node 24/);
56
+ });
57
+
58
+ test('#352: Docker is asked about only where a repo names it', () => {
59
+ const T = tmp();
60
+ try {
61
+ assert.deepEqual(dockerReasons(T), []);
62
+ put(path.join(T, 'package.json'), { scripts: {
63
+ test: 'node --test', scan: 'docker run --rm zricethezav/gitleaks', up: 'npm ci && docker compose up', full: '/usr/local/bin/docker build .',
64
+ notdocker: 'echo dockerfile', lint: 'eslint . --ignore-pattern docker', say: 'echo run docker', '\u001b]8;;x\u0007odd': 'docker ps' } });
65
+ assert.deepEqual(dockerReasons(T), ['package.json scripts: scan, up, full, ]8;;x odd'], 'a script name is cleaned for the terminal');
66
+ put(path.join(T, 'compose.yaml'), 'services: {}\n');
67
+ put(path.join(T, 'Dockerfile.dev'), 'FROM node\n');
68
+ put(path.join(T, '.pre-commit-config.yaml'), 'repos:\n - repo: local\n hooks:\n - id: x\n language: "docker_image" # the scanner\n');
69
+ assert.deepEqual(dockerReasons(T).sort(), ['.pre-commit-config.yaml (a docker hook)', 'Dockerfile.dev', 'compose.yaml', 'package.json scripts: scan, up, full, ]8;;x odd'].sort());
70
+ const runner = (answers) => (cmd, args) => ({ ok: answers[`${cmd} ${args[0]}`] ?? false });
71
+ assert.equal(dockerState({ runner: runner({}) }), 'missing');
72
+ assert.equal(dockerState({ runner: runner({ 'which docker': true }) }), 'stopped');
73
+ assert.equal(dockerState({ runner: runner({ 'which docker': true, 'docker info': true }) }), 'running');
74
+ } finally { done(T); }
75
+ });
76
+
77
+ test('#352: more than one glab config file is found where glab looks', () => {
78
+ const T = tmp();
79
+ try {
80
+ assert.deepEqual(glabConfigs({ env: {}, home: T, platform: 'darwin' }), []);
81
+ put(path.join(T, '.config/glab-cli/config.yml'), 'hosts: {}\n');
82
+ put(path.join(T, 'Library/Application Support/glab-cli/config.yml'), 'hosts: {}\n');
83
+ assert.equal(glabConfigs({ env: {}, home: T, platform: 'darwin' }).length, 2);
84
+ assert.equal(glabConfigs({ env: {}, home: T, platform: 'linux' }).length, 1, 'not the macOS folder on Linux');
85
+ // GLAB_CONFIG_DIR or XDG_CONFIG_HOME names the one place glab reads: no duplicate is possible.
86
+ put(path.join(T, 'own/config.yml'), 'hosts: {}\n');
87
+ assert.deepEqual(glabConfigs({ env: { GLAB_CONFIG_DIR: path.join(T, 'own') }, home: T, platform: 'darwin' }), [path.join(T, 'own/config.yml')]);
88
+ put(path.join(T, 'xdg/glab-cli/config.yml'), 'hosts: {}\n');
89
+ assert.deepEqual(glabConfigs({ env: { XDG_CONFIG_HOME: path.join(T, 'xdg') }, home: T, platform: 'darwin' }), [path.join(T, 'xdg/glab-cli/config.yml')]);
90
+ } finally { done(T); }
91
+ });
92
+
93
+ test('#352: yad doctor rows — a Node a repo does not accept, Docker stopped where a repo needs it, two glab configs', () => {
94
+ const T = tmp();
95
+ try {
96
+ const root = path.join(T, 'product');
97
+ put(path.join(root, '.sdlc/product.json'), { platform: null });
98
+ put(path.join(root, '.nvmrc'), '24\n');
99
+ put(path.join(root, 'package.json'), { engines: { node: '>=24.1' } });
100
+ const app = path.join(T, 'app');
101
+ put(path.join(app, 'package.json'), { engines: { node: '>=22' }, scripts: { scan: 'docker compose run gitleaks' } });
102
+ execFileSync('git', ['init', '-q'], { cwd: app });
103
+ put(path.join(root, '.sdlc/repos.json'), { repos: [{ name: 'app', path: '../app' }] });
104
+ const home = path.join(T, 'home');
105
+ put(path.join(home, '.config/glab-cli/config.yml'), 'hosts: {}\n');
106
+ put(path.join(home, 'Library/Application Support/glab-cli/config.yml'), 'hosts: {}\n');
107
+ const runner = (cmd, args) => ({ ok: `${cmd} ${args[0]}` === 'which docker' });
108
+ const rows = (nodeVersion) => { const checks = []; machineChecks(checks, root, { nodeVersion, env: { NVM_DIR: '/x' }, home, platform: 'darwin', runner }); return Object.fromEntries(checks.map((c) => [c.id, c])); };
109
+ const old = rows('20.19.5');
110
+ assert.equal(old['node-version:product'].status, 'warn');
111
+ assert.match(old['node-version:product'].message, /node 20\.19\.5 does not meet what the Product pins: 24 \(\.nvmrc\), >=24\.1 \(package\.json engines\.node\)/, 'both pins, one row');
112
+ assert.match(old['node-version:product'].hint, /nvm install 24 && nvm use 24/);
113
+ assert.equal(old['node-version:repo:app'].status, 'warn');
114
+ assert.equal(old.docker.status, 'warn');
115
+ assert.match(old.docker.message, /Docker is not running, and app \(package\.json scripts: scan\) asks for it/);
116
+ assert.equal(old['glab-config'].status, 'warn');
117
+ assert.match(old['glab-config'].message, /glab has 2 config files: ~\/\.config\/glab-cli\/config\.yml, ~\/Library\/Application Support\/glab-cli\/config\.yml/);
118
+ const now = rows('24.22.1');
119
+ assert.equal(now['node-version'].status, 'ok');
120
+ assert.match(now['node-version'].message, /meets every Node version the repos pin \(3 read\)/);
121
+ assert.equal(now['node-version:product'], undefined);
122
+ // The glab hint says what goes wrong: one file is ignored.
123
+ assert.match(old['glab-config'].hint, /reads only one of them and ignores the other/);
124
+ // A pin yad does not read is counted as skipped, never judged.
125
+ put(path.join(app, '.nvmrc'), 'lts/*\n');
126
+ assert.match(rows('24.22.1')['node-version'].message, /\(3 read, 1 not a version yad reads\)/);
127
+ } finally { done(T); }
128
+ });
129
+
130
+ test('#352: a repo that names no pin and no Docker adds no rows, and Docker is never run', () => {
131
+ const T = tmp();
132
+ try {
133
+ put(path.join(T, '.sdlc/product.json'), { platform: null });
134
+ let asked = 0;
135
+ const checks = [];
136
+ machineChecks(checks, T, { nodeVersion: '24.22.1', env: {}, home: path.join(T, 'home'), platform: 'linux', runner: () => { asked += 1; return { ok: false }; } });
137
+ assert.deepEqual(checks, []);
138
+ assert.equal(asked, 0, 'docker is not asked about');
139
+ } finally { done(T); }
140
+ });
package/cli/test-node.mjs CHANGED
@@ -127,3 +127,18 @@ test('E161: the error catalogue, docs/CLI.md and the docs site list the same YAD
127
127
  assert.deepEqual(site, env);
128
128
  });
129
129
 
130
+ test('#427: npm run coverage runs exactly the test files npm test runs — CI skips npm test on the coverage leg', () => {
131
+ // ci.yml's test (ubuntu-latest, node 24) job and release-check.sh run only `npm run coverage`. A test file
132
+ // listed in `test` but not in `coverage` would never run there, so the two lists must stay the same.
133
+ const { scripts } = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8'));
134
+ const files = (s) => s.split(/\s+/).filter((w) => /^cli\/test[^ ]*\.(mjs|js)$/.test(w));
135
+ assert.ok(files(scripts.test).length > 10, scripts.test);
136
+ assert.deepEqual(files(scripts.coverage), files(scripts.test), 'the coverage script must list the same test files as npm test');
137
+ // A new test file left out of both lists would run nowhere: every cli/test* file on disk is listed.
138
+ const onDisk = fs.readdirSync(path.join(ROOT, 'cli')).filter((f) => /^test[^/]*\.(mjs|js)$/.test(f)).map((f) => `cli/${f}`);
139
+ assert.deepEqual([...files(scripts.test)].sort(), onDisk.sort(), 'every cli/test* file must be listed in npm test');
140
+ const ci = fs.readFileSync(path.join(ROOT, '.github/workflows/ci.yml'), 'utf8');
141
+ const has = (re, what) => assert.ok(re.test(ci), `ci.yml: ${what}`);
142
+ has(/- name: Test\n {8}if: \$\{\{ !\(matrix\.os == 'ubuntu-latest' && matrix\.node-version == 24\) \}\}\n {8}run: npm test\n/, 'the Test step skips only the ubuntu/24 coverage leg');
143
+ has(/\n {8}if: matrix\.os == 'ubuntu-latest' && matrix\.node-version == 24\n {8}run: npm run coverage\n/, 'the coverage step runs on the ubuntu/24 leg');
144
+ });