yadflow 4.7.0 → 4.8.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 +89 -0
- package/README.md +43 -4
- package/bin/commands.mjs +4 -1
- package/bin/yad.mjs +147 -20
- package/cli/agent-guard.mjs +511 -0
- package/cli/agent-guide.mjs +83 -0
- package/cli/agent-rules.mjs +381 -0
- package/cli/argv-flags.mjs +7 -0
- package/cli/ci-check.mjs +492 -0
- package/cli/docs.mjs +1 -1
- package/cli/doctor.mjs +43 -7
- package/cli/epic-state.mjs +3 -3
- package/cli/errors.mjs +1 -0
- package/cli/guide.mjs +549 -0
- package/cli/hook.mjs +32 -3
- package/cli/lib.mjs +46 -0
- package/cli/lifecycle/defaults/2.json +124 -0
- package/cli/lifecycle/lifecycle.schema.json +5 -2
- package/cli/lifecycle.mjs +16 -3
- package/cli/manifest.mjs +75 -0
- package/cli/marked-block.mjs +48 -0
- package/cli/members.mjs +19 -5
- package/cli/migrate.mjs +17 -19
- package/cli/next.mjs +1 -1
- package/cli/plan.mjs +326 -22
- package/cli/protection.mjs +50 -0
- package/cli/reconcile.mjs +187 -26
- package/cli/report.mjs +62 -14
- package/cli/setup.mjs +244 -25
- package/cli/signing.mjs +377 -0
- package/cli/test-agents-file.mjs +993 -0
- package/cli/test-ci-check.mjs +616 -0
- package/cli/test-guide.mjs +1267 -0
- package/cli/test-node.mjs +129 -0
- package/cli/test-setup-agent.mjs +352 -0
- package/cli/test-signing.mjs +524 -0
- package/cli/toolbox.mjs +1 -1
- package/cli/update-commit.mjs +313 -11
- package/cli/workspace.mjs +37 -12
- package/package.json +6 -4
- package/skills/sdlc/config.yaml +4 -4
- package/skills/sdlc/module-help.csv +1 -0
- package/skills/yad-change/SKILL.md +3 -2
- package/skills/yad-checks/SKILL.md +29 -9
- package/skills/yad-checks/references/check-gates.md +9 -4
- package/skills/yad-checks/templates/checks/package-manager.sh +1 -1
- package/skills/yad-checks/templates/github/yad-checks.yml +1 -1
- package/skills/yad-checks/templates/gitlab/.gitlab-ci.yml +1 -1
- package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +1 -1
- package/skills/yad-checks/templates/gitlab/yad-product-checks.gitlab-ci.yml +1 -1
- package/skills/yad-checks/templates/gitlab/yad-update-guard.gitlab-ci.yml +1 -1
- package/skills/yad-checks/templates/gitlab/yad-verified-commits.gitlab-ci.yml +1 -1
- package/skills/yad-checks/templates/hooks/agent-guard.mjs +116 -0
- package/skills/yad-commit/SKILL.md +4 -3
- package/skills/yad-connect-repos/SKILL.md +5 -3
- package/skills/yad-connect-repos/references/code-context.md +2 -1
- package/skills/yad-connect-repos/references/repos-registry.md +2 -1
- package/skills/yad-docs-overview/references/pipeline-model.md +2 -2
- package/skills/yad-engineer-review/SKILL.md +12 -7
- package/skills/yad-engineer-review/references/ship-and-record.md +7 -4
- package/skills/yad-epic/SKILL.md +2 -1
- package/skills/yad-epic/references/state-schema.md +1 -1
- package/skills/yad-guide/SKILL.md +192 -0
- package/skills/yad-open-pr/SKILL.md +1 -1
- package/skills/yad-pair-review/SKILL.md +14 -5
- package/skills/yad-product-bridge/SKILL.md +32 -13
- package/skills/yad-product-bridge/references/bridge.md +6 -3
- package/skills/yad-product-bridge/templates/github/yad-gate-sync.yml +2 -2
- package/skills/yad-product-bridge/templates/gitlab/yad-gate-sync.gitlab-ci.yml +1 -1
- package/skills/yad-report/SKILL.md +15 -0
- package/skills/yad-review-companion/SKILL.md +5 -3
- package/skills/yad-review-gate/SKILL.md +13 -9
- package/skills/yad-review-gate/references/gating.md +1 -1
- package/skills/yad-run/SKILL.md +10 -6
- package/skills/yad-run/references/run-loop.md +2 -1
- package/skills/yad-sync-repos/SKILL.md +2 -1
- package/skills/yad-ui/SKILL.md +2 -2
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// E161: which Node line yadflow runs on. Below 18 it does not run (YAD-ENV-003); 18 and 20 are end of life —
|
|
2
|
+
// yadflow 4 still runs on them, with a warning (YAD-ENV-004), and yadflow 5 needs 22; 22 and later are ok.
|
|
3
|
+
// Also: the CI files yad installs in people's repos name no end-of-life Node.
|
|
4
|
+
import { test } from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import { spawnSync } from 'node:child_process';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
|
|
12
|
+
if (process.env.NODE_TEST_CONTEXT) {
|
|
13
|
+
const write = process.stdout.write;
|
|
14
|
+
for (const k of ['log', 'info']) {
|
|
15
|
+
const orig = console[k];
|
|
16
|
+
console[k] = (...a) => (process.stdout.write === write ? console.error(...a) : orig(...a));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
process.env.YAD_NO_UPDATE_NOTIFIER = '1';
|
|
20
|
+
|
|
21
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
22
|
+
const { nodeSupport, nodeEndOfLife, cpMerge } = await import('./lib.mjs');
|
|
23
|
+
const { envChecks } = await import('./doctor.mjs');
|
|
24
|
+
const { CODES } = await import('./errors.mjs');
|
|
25
|
+
|
|
26
|
+
test('E161: nodeSupport reads the major version into three bands', () => {
|
|
27
|
+
for (const v of ['16.20.2', '17.0.0', 'v16.1.0', 'not-a-version']) assert.equal(nodeSupport(v), 'unsupported', v);
|
|
28
|
+
for (const v of ['18.20.4', '20.19.5', 'v20.0.0', '21.7.3']) assert.equal(nodeSupport(v), 'end-of-life', v);
|
|
29
|
+
for (const v of ['22.0.0', '22.22.2', '24.22.1', '25.1.0']) assert.equal(nodeSupport(v), 'ok', v);
|
|
30
|
+
assert.match(nodeEndOfLife('20.19.5'), /^Node 20\.19\.5 is end of life and gets no security fixes\. yadflow 4 still runs on it; yadflow 5 will need Node 22 or newer\./);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('E161: yad doctor\'s node row — fail below 18, warn on 18 to 21 (YAD-ENV-004), ok from 22', () => {
|
|
34
|
+
const row = (nodeVersion) => { const checks = []; envChecks(checks, { nodeVersion }); return checks.find((x) => x.id === 'node'); };
|
|
35
|
+
assert.equal(row('16.0.0').status, 'fail');
|
|
36
|
+
assert.match(row('16.0.0').message, /YAD-ENV-003/);
|
|
37
|
+
const old = row('20.19.5');
|
|
38
|
+
assert.equal(old.status, 'warn');
|
|
39
|
+
assert.match(old.message, /end of life.*YAD-ENV-004/);
|
|
40
|
+
assert.match(old.hint, /22 or newer/);
|
|
41
|
+
assert.equal(row('24.22.1').status, 'ok');
|
|
42
|
+
assert.ok(CODES['YAD-ENV-004'], 'the code is in the catalogue');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('E161: the CLI warns once on an end-of-life Node, on stderr only, and never under `hook`', () => {
|
|
46
|
+
const T = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'yad-node-')));
|
|
47
|
+
try {
|
|
48
|
+
const yad = (args, version) => spawnSync(process.execPath, [path.join(ROOT, 'bin/yad.mjs'), ...args], {
|
|
49
|
+
cwd: T, encoding: 'utf8', input: '{}',
|
|
50
|
+
env: { ...process.env, NO_COLOR: '1', YAD_PLATFORM_READ: '0', ...(version ? { YAD_TEST_NODE_VERSION: version } : {}) },
|
|
51
|
+
});
|
|
52
|
+
const old = yad(['detect', '--json'], '20.19.5');
|
|
53
|
+
assert.equal((old.stderr.match(/is end of life/g) || []).length, 1, old.stderr);
|
|
54
|
+
assert.doesNotMatch(old.stdout, /end of life/, 'stdout stays clean JSON');
|
|
55
|
+
JSON.parse(old.stdout);
|
|
56
|
+
assert.doesNotMatch(yad(['detect', '--json'], '24.22.1').stderr, /end of life/);
|
|
57
|
+
// The running Node, with no stand-in: on the CI legs for 18 and 20 it warns, on 22 and later it does not.
|
|
58
|
+
const real = yad(['detect', '--json']).stderr;
|
|
59
|
+
if (nodeSupport() === 'end-of-life') assert.match(real, /is end of life/, 'this Node is end of life');
|
|
60
|
+
else assert.doesNotMatch(real, /end of life/, 'this Node (22 or later) gets no warning');
|
|
61
|
+
assert.doesNotMatch(yad(['hook', 'agent-guard'], '20.19.5').stderr, /end of life/, 'a hook\'s stderr reaches the model');
|
|
62
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('E161: no CI file yad installs or generates names an end-of-life Node', () => {
|
|
66
|
+
const files = [
|
|
67
|
+
...['skills/yad-checks/templates', 'skills/yad-product-bridge/templates', 'skills/yad-pr-template/templates'].flatMap((d) => fs.readdirSync(path.join(ROOT, d), { recursive: true }).map((f) => path.join(d, f))),
|
|
68
|
+
'cli/docs.mjs',
|
|
69
|
+
].filter((f) => fs.statSync(path.join(ROOT, f)).isFile());
|
|
70
|
+
for (const f of files) {
|
|
71
|
+
const text = fs.readFileSync(path.join(ROOT, f), 'utf8');
|
|
72
|
+
assert.doesNotMatch(text, /node-version:\s*["']?(1[0-9]|20)["']?\s*$/m, f);
|
|
73
|
+
assert.doesNotMatch(text, /image:\s*node:(1[0-9]|20)\b/, f);
|
|
74
|
+
assert.doesNotMatch(text, /YAD_NODE_VERSION[^\n]*["'](1[0-9]|20)["']/, f);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('E161: cpMerge joins folders and never replaces a file (Node 24\'s cpSync refuses an existing folder)', () => {
|
|
79
|
+
const T = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'yad-cp-')));
|
|
80
|
+
try {
|
|
81
|
+
fs.mkdirSync(path.join(T, 'a/sub'), { recursive: true });
|
|
82
|
+
fs.writeFileSync(path.join(T, 'a/f.txt'), 'x');
|
|
83
|
+
fs.writeFileSync(path.join(T, 'a/sub/g.txt'), 'y');
|
|
84
|
+
fs.mkdirSync(path.join(T, 'b/sub'), { recursive: true });
|
|
85
|
+
fs.writeFileSync(path.join(T, 'b/keep.txt'), 'mine');
|
|
86
|
+
cpMerge(path.join(T, 'a'), path.join(T, 'b'));
|
|
87
|
+
assert.equal(fs.readFileSync(path.join(T, 'b/sub/g.txt'), 'utf8'), 'y');
|
|
88
|
+
assert.equal(fs.readFileSync(path.join(T, 'b/keep.txt'), 'utf8'), 'mine', 'the folder\'s own files are kept');
|
|
89
|
+
assert.throws(() => cpMerge(path.join(T, 'a'), path.join(T, 'b')), /EEXIST/, 'a file already there is never replaced');
|
|
90
|
+
assert.equal(fs.readFileSync(path.join(T, 'b/f.txt'), 'utf8'), 'x');
|
|
91
|
+
// A new folder keeps its source's permissions; a file keeps its mode; a link stays the link it is.
|
|
92
|
+
if (process.platform !== 'win32') {
|
|
93
|
+
fs.mkdirSync(path.join(T, 'p/private'), { recursive: true, mode: 0o700 });
|
|
94
|
+
fs.chmodSync(path.join(T, 'p/private'), 0o700);
|
|
95
|
+
fs.writeFileSync(path.join(T, 'p/run.sh'), '#!/bin/sh\n', { mode: 0o755 });
|
|
96
|
+
fs.symlinkSync('run.sh', path.join(T, 'p/link'));
|
|
97
|
+
const made = [];
|
|
98
|
+
cpMerge(path.join(T, 'p'), path.join(T, 'q'), made);
|
|
99
|
+
assert.equal(fs.statSync(path.join(T, 'q/private')).mode & 0o777, 0o700);
|
|
100
|
+
assert.equal(fs.statSync(path.join(T, 'q/run.sh')).mode & 0o777, 0o755);
|
|
101
|
+
assert.equal(fs.readlinkSync(path.join(T, 'q/link')), 'run.sh', 'a relative link stays relative');
|
|
102
|
+
assert.deepEqual(made.map((p) => path.relative(T, p)).sort(), ['q', 'q/link', 'q/private', 'q/run.sh']);
|
|
103
|
+
// A read-only folder still takes its files, and is read-only after the copy.
|
|
104
|
+
fs.mkdirSync(path.join(T, 'ro/locked'), { recursive: true });
|
|
105
|
+
fs.writeFileSync(path.join(T, 'ro/locked/f.txt'), 'z');
|
|
106
|
+
fs.chmodSync(path.join(T, 'ro/locked'), 0o555);
|
|
107
|
+
try {
|
|
108
|
+
cpMerge(path.join(T, 'ro'), path.join(T, 'rw'));
|
|
109
|
+
assert.equal(fs.readFileSync(path.join(T, 'rw/locked/f.txt'), 'utf8'), 'z');
|
|
110
|
+
assert.equal(fs.statSync(path.join(T, 'rw/locked')).mode & 0o777, 0o555);
|
|
111
|
+
} finally {
|
|
112
|
+
for (const d of ['ro/locked', 'rw/locked']) if (fs.existsSync(path.join(T, d))) fs.chmodSync(path.join(T, d), 0o755);
|
|
113
|
+
}
|
|
114
|
+
// A named pipe is refused, never read (copying one would wait forever).
|
|
115
|
+
fs.mkdirSync(path.join(T, 'r'));
|
|
116
|
+
spawnSync('mkfifo', [path.join(T, 'r/pipe')]);
|
|
117
|
+
if (fs.existsSync(path.join(T, 'r/pipe'))) assert.throws(() => cpMerge(path.join(T, 'r'), path.join(T, 's')), /not a file, a folder or a link/);
|
|
118
|
+
}
|
|
119
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('E161: the error catalogue, docs/CLI.md and the docs site list the same YAD-ENV codes', () => {
|
|
123
|
+
const env = Object.keys(CODES).filter((k) => k.startsWith('YAD-ENV-')).sort();
|
|
124
|
+
const cli = [...fs.readFileSync(path.join(ROOT, 'docs/CLI.md'), 'utf8').matchAll(/^\| `(YAD-ENV-\d+)` \|/gm)].map((m) => m[1]).sort();
|
|
125
|
+
const site = [...fs.readFileSync(path.join(ROOT, 'docs/sdlc-site/src/data/referenceData.ts'), 'utf8').matchAll(/code: '(YAD-ENV-\d+)'/g)].map((m) => m[1]).sort();
|
|
126
|
+
assert.deepEqual(cli, env);
|
|
127
|
+
assert.deepEqual(site, env);
|
|
128
|
+
});
|
|
129
|
+
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
// E159: setup, new, init and join driven by an AI agent. The rules each test pins (the case list is in the
|
|
2
|
+
// E159 roadmap row):
|
|
3
|
+
// - every setup question has a flag; under --json a missing answer is refused BEFORE anything is written,
|
|
4
|
+
// with the unanswered questions listed (`questions`);
|
|
5
|
+
// - a bad flag value is refused before anything is written;
|
|
6
|
+
// - SDLC_NONINTERACTIVE still takes every default;
|
|
7
|
+
// - `member add` under --json never starts a login: the person's step says how;
|
|
8
|
+
// - `yad guide --json` lists the same questions for the command the folder calls for.
|
|
9
|
+
import { test } from 'node:test';
|
|
10
|
+
import assert from 'node:assert/strict';
|
|
11
|
+
import { spawnSync, execFileSync } from 'node:child_process';
|
|
12
|
+
import fs from 'node:fs';
|
|
13
|
+
import os from 'node:os';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
import { fileURLToPath } from 'node:url';
|
|
16
|
+
|
|
17
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
18
|
+
const YAD = path.join(ROOT, 'bin/yad.mjs');
|
|
19
|
+
// A space in the folder name: a home folder like `C:\Users\Jane Doe` must work.
|
|
20
|
+
const tmp = () => fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'yad e159-')));
|
|
21
|
+
const put = (file, data) => { fs.mkdirSync(path.dirname(file), { recursive: true }); fs.writeFileSync(file, typeof data === 'string' ? data : JSON.stringify(data, null, 2)); };
|
|
22
|
+
const read = (file) => fs.readFileSync(file, 'utf8');
|
|
23
|
+
|
|
24
|
+
// Every spawned yad and git reads an empty global git config and a HOME of its own (the global-skills check
|
|
25
|
+
// reads `~/.claude/skills`). No SDLC_NONINTERACTIVE: these are the agent's runs.
|
|
26
|
+
function env(T, extra = {}) {
|
|
27
|
+
const home = path.join(T, '.home');
|
|
28
|
+
fs.mkdirSync(home, { recursive: true });
|
|
29
|
+
const cfg = path.join(home, 'gitconfig');
|
|
30
|
+
if (!fs.existsSync(cfg)) fs.writeFileSync(cfg, '[user]\n\tname = Dev\n\temail = dev@example.com\n[init]\n\tdefaultBranch = main\n[commit]\n\tgpgsign = false\n');
|
|
31
|
+
const e = { ...process.env, HOME: home, USERPROFILE: home, GIT_CONFIG_GLOBAL: cfg, GIT_CONFIG_NOSYSTEM: '1', YAD_NO_UPDATE_NOTIFIER: '1', NO_COLOR: '1', YAD_CAPTURE: '0', YAD_PLATFORM_LOGIN: '0', YAD_PLATFORM_READ: '0' };
|
|
32
|
+
delete e.SDLC_NONINTERACTIVE;
|
|
33
|
+
delete e.NODE_TEST_CONTEXT;
|
|
34
|
+
Object.assign(e, extra);
|
|
35
|
+
for (const [k, v] of Object.entries(extra)) if (v === undefined) delete e[k];
|
|
36
|
+
return e;
|
|
37
|
+
}
|
|
38
|
+
const yad = (T, cwd, args, extra = {}) => {
|
|
39
|
+
const r = spawnSync(process.execPath, [YAD, ...args], { cwd, env: env(T, extra), encoding: 'utf8', timeout: 120_000 });
|
|
40
|
+
let json = null;
|
|
41
|
+
try { json = JSON.parse(r.stdout); } catch { /* not JSON: said below */ }
|
|
42
|
+
return { code: r.status, json, out: r.stdout, err: r.stderr };
|
|
43
|
+
};
|
|
44
|
+
const gitRepo = (T, dir) => { fs.mkdirSync(dir, { recursive: true }); execFileSync('git', ['init', '-q'], { cwd: dir, env: env(T) }); };
|
|
45
|
+
// Every file under a folder (no .git, no .home), so "nothing written" is checked byte for byte.
|
|
46
|
+
const snapshot = (dir) => {
|
|
47
|
+
const out = {};
|
|
48
|
+
const walk = (d) => {
|
|
49
|
+
for (const e of fs.readdirSync(d, { withFileTypes: true })) {
|
|
50
|
+
if (e.name === '.git' || e.name === '.home') continue;
|
|
51
|
+
const p = path.join(d, e.name);
|
|
52
|
+
if (e.isDirectory()) { out[`${path.relative(dir, p)}/`] = ''; walk(p); } else out[path.relative(dir, p)] = read(p);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
walk(dir);
|
|
56
|
+
return out;
|
|
57
|
+
};
|
|
58
|
+
const ids = (r) => (r.json?.questions || []).map((q) => q.id);
|
|
59
|
+
|
|
60
|
+
test('E159 cases 3 and 5: setup --json with no answers is refused before anything is written, and lists each question with its flag', () => {
|
|
61
|
+
const T = tmp();
|
|
62
|
+
try {
|
|
63
|
+
const P = path.join(T, 'p');
|
|
64
|
+
fs.mkdirSync(P);
|
|
65
|
+
const r = yad(T, P, ['setup', '--json']);
|
|
66
|
+
assert.equal(r.code, 1, r.out + r.err);
|
|
67
|
+
assert.equal(r.json.ok, false);
|
|
68
|
+
assert.equal(r.json.code, 'YAD-CLI-001');
|
|
69
|
+
assert.deepEqual(ids(r), ['mode', 'codebase', 'layout', 'tools', 'git-init', 'ide-targets', 'platform', 'default-branch', 'repos']);
|
|
70
|
+
// The default branch is asked with the platform, but needed only when the answer is github or gitlab.
|
|
71
|
+
assert.equal(r.json.questions.find((q) => q.id === 'default-branch').optional, true);
|
|
72
|
+
for (const q of r.json.questions) {
|
|
73
|
+
assert.ok(q.text && q.flag && Object.hasOwn(q, 'default') && Array.isArray(q.choices), JSON.stringify(q));
|
|
74
|
+
assert.ok(!Object.hasOwn(q, 'given'), 'only the unanswered are listed, without the bookkeeping');
|
|
75
|
+
}
|
|
76
|
+
assert.deepEqual(fs.readdirSync(P), [], 'nothing written, not even .git');
|
|
77
|
+
// Case 5: answering each question with its flag (the default) runs it: every flag listed is one yad reads.
|
|
78
|
+
const answers = ['--solo', '--greenfield', '--monorepo', '--no-tools', '--git-init', '--ide-targets', '.claude', '--platform', 'none', '--connect', 'none'];
|
|
79
|
+
const done = yad(T, P, ['setup', '--json', ...answers]);
|
|
80
|
+
assert.equal(done.code, 0, done.out + done.err);
|
|
81
|
+
assert.equal(done.json.ok, true);
|
|
82
|
+
assert.equal(JSON.parse(read(path.join(P, '.sdlc/product.json'))).platform, null);
|
|
83
|
+
assert.ok(fs.existsSync(path.join(P, '.git')));
|
|
84
|
+
// Only some answered: the rest are listed, and still nothing is written.
|
|
85
|
+
const Q = path.join(T, 'q');
|
|
86
|
+
fs.mkdirSync(Q);
|
|
87
|
+
const some = yad(T, Q, ['setup', '--json', '--solo', '--greenfield', '--monorepo', '--no-git-init']);
|
|
88
|
+
assert.deepEqual(ids(some), ['tools', 'ide-targets', 'platform', 'default-branch', 'repos']);
|
|
89
|
+
// --platform github makes the branch a question that must be answered.
|
|
90
|
+
const gh = yad(T, Q, ['setup', '--json', '--solo', '--greenfield', '--monorepo', '--no-git-init', '--no-tools', '--ide-targets', '.claude', '--platform', 'github', '--connect', 'none']);
|
|
91
|
+
assert.deepEqual(ids(gh), ['default-branch']);
|
|
92
|
+
assert.equal(gh.json.questions[0].optional, undefined);
|
|
93
|
+
assert.deepEqual(fs.readdirSync(Q), []);
|
|
94
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('E159 cases 2 and 4: every answer as a flag runs with no prompt; SDLC_NONINTERACTIVE still takes the defaults', () => {
|
|
98
|
+
const T = tmp();
|
|
99
|
+
try {
|
|
100
|
+
const P = path.join(T, 'p');
|
|
101
|
+
gitRepo(T, P);
|
|
102
|
+
const r = yad(T, P, ['setup', '--json', '--team', '3', '--brownfield', '--separate', '--no-tools', '--ide-targets', '.claude', '--platform', 'github', '--default-branch', 'trunk', '--connect', 'none']);
|
|
103
|
+
assert.equal(r.code, 0, r.out + r.err);
|
|
104
|
+
const product = JSON.parse(read(path.join(P, '.sdlc/product.json')));
|
|
105
|
+
assert.equal(product.platform, 'github');
|
|
106
|
+
assert.equal(product.default_branch, 'trunk');
|
|
107
|
+
assert.deepEqual(product.profile, { codebase: 'brownfield', repo_layout: 'separate', team_size: 3 });
|
|
108
|
+
const D = path.join(T, 'd');
|
|
109
|
+
fs.mkdirSync(D);
|
|
110
|
+
const defaults = yad(T, D, ['setup', '--json'], { SDLC_NONINTERACTIVE: '1' });
|
|
111
|
+
assert.equal(defaults.code, 0, defaults.out + defaults.err);
|
|
112
|
+
assert.equal(defaults.json.ok, true);
|
|
113
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('E159 case 6: a bad flag value is refused before anything is written', () => {
|
|
117
|
+
const T = tmp();
|
|
118
|
+
try {
|
|
119
|
+
const all = ['--solo', '--greenfield', '--monorepo', '--no-tools', '--no-git-init', '--ide-targets', '.claude', '--platform', 'none', '--connect', 'none'];
|
|
120
|
+
// A plain folder beside the Products, with a .coderabbit.yaml: no CodeRabbit question would be asked about it.
|
|
121
|
+
put(path.join(T, 'plain/.coderabbit.yaml'), 'reviews: {}\n');
|
|
122
|
+
const swap = (flag, value) => { const a = [...all]; const i = a.indexOf(flag); a[i + 1] = value; return a; };
|
|
123
|
+
for (const [args, said] of [
|
|
124
|
+
[swap('--platform', 'bitbucket'), /--platform bitbucket: expected github, gitlab or none/],
|
|
125
|
+
[[...all, '--platform', 'github', '--default-branch', 'a..b'], /not a plain branch name/],
|
|
126
|
+
[[...all.filter((a) => a !== '--no-tools'), '--design', 'paint'], /--design paint: expected one of/],
|
|
127
|
+
[[...all, '--design', 'none'], /--no-tools and a tool flag/],
|
|
128
|
+
[[...all, '--tools'], /--tools and --no-tools/],
|
|
129
|
+
[[...all, '--team', '2'], /--solo and --team/],
|
|
130
|
+
[[...all, '--add-repo', 'api'], /expected <name>=<path>/],
|
|
131
|
+
[[...all, '--add-repo', 'api=../../../outside'], /outside the workspace/],
|
|
132
|
+
[[...all, '--add-repo', 'api=../.git/x'], /\.git folder/],
|
|
133
|
+
[[...all, '--add-repo', 'api=../api,bitbucket'], /platform bitbucket/],
|
|
134
|
+
// Review 2: a folder that is not a git repo (registerRepo would skip it, and a monorepo would connect the next).
|
|
135
|
+
[[...all, '--add-repo', 'api=../plain'], /\.\.\/plain is not a git repository/],
|
|
136
|
+
[[...all, '--coderabbit', 'ghost'], /no connected repo named ghost/],
|
|
137
|
+
// Review 1: the AI tools and the team size are checked before any write too.
|
|
138
|
+
[swap('--ide-targets', '.vscode'), /--ide-targets: unsupported IDE target/],
|
|
139
|
+
[[...all.filter((a) => a !== '--solo'), '--team', 'abc'], /--team abc: expected how many people/],
|
|
140
|
+
[[...all.filter((a) => a !== '--solo'), '--team', '0'], /--team 0: expected how many people/],
|
|
141
|
+
]) {
|
|
142
|
+
const P = fs.mkdtempSync(path.join(T, 'p-'));
|
|
143
|
+
const before = fs.readdirSync(path.join(T, 'plain'));
|
|
144
|
+
const r = yad(T, P, ['setup', '--json', ...args]);
|
|
145
|
+
assert.equal(r.code, 1, args.join(' '));
|
|
146
|
+
assert.match(r.json.error, said, args.join(' '));
|
|
147
|
+
assert.deepEqual(fs.readdirSync(P), [], `nothing written: ${args.join(' ')}`);
|
|
148
|
+
assert.deepEqual(fs.readdirSync(path.join(T, 'plain')), before);
|
|
149
|
+
}
|
|
150
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('E159 case 7: a re-run asks whether to change the earlier settings; --no-reconfigure keeps them as they are', () => {
|
|
154
|
+
const T = tmp();
|
|
155
|
+
try {
|
|
156
|
+
const P = path.join(T, 'p');
|
|
157
|
+
gitRepo(T, P);
|
|
158
|
+
const first = ['--solo', '--greenfield', '--monorepo', '--no-tools', '--ide-targets', '.claude', '--platform', 'github', '--default-branch', 'main', '--connect', 'none'];
|
|
159
|
+
assert.equal(yad(T, P, ['setup', '--json', ...first]).code, 0);
|
|
160
|
+
const before = read(path.join(P, '.sdlc/product.json'));
|
|
161
|
+
const again = ['--no-tools', '--ide-targets', '.claude', '--connect', 'none'];
|
|
162
|
+
const files = snapshot(P);
|
|
163
|
+
const asked = yad(T, P, ['setup', '--json', ...again]);
|
|
164
|
+
assert.deepEqual(ids(asked), ['reconfigure'], 'the profile is carried; the earlier settings are the question');
|
|
165
|
+
assert.deepEqual(snapshot(P), files, 'a refused re-run changes nothing, byte for byte');
|
|
166
|
+
const kept = yad(T, P, ['setup', '--json', ...again, '--no-reconfigure']);
|
|
167
|
+
assert.equal(kept.code, 0, kept.out + kept.err);
|
|
168
|
+
assert.equal(read(path.join(P, '.sdlc/product.json')), before);
|
|
169
|
+
// --reconfigure asks the platform again, and the branch with it (needed only for github or gitlab).
|
|
170
|
+
assert.deepEqual(ids(yad(T, P, ['setup', '--json', ...again, '--reconfigure'])), ['platform', 'default-branch']);
|
|
171
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test('E159 cases 8, 9, 10: init --connect picks the repos found; --add-repo registers others; --coderabbit wires exactly those', () => {
|
|
175
|
+
const T = tmp();
|
|
176
|
+
try {
|
|
177
|
+
const W = path.join(T, 'ws');
|
|
178
|
+
for (const n of ['a', 'b']) gitRepo(T, path.join(W, n));
|
|
179
|
+
const base = ['--solo', '--greenfield', '--no-tools', '--ide-targets', '.claude', '--platform', 'none'];
|
|
180
|
+
const missing = yad(T, W, ['init', '--json', ...base]);
|
|
181
|
+
assert.deepEqual(ids(missing), ['repos', 'coderabbit']);
|
|
182
|
+
assert.ok(missing.json.questions[0].choices.includes('a,b'), JSON.stringify(missing.json.questions[0]));
|
|
183
|
+
assert.ok(!fs.existsSync(path.join(W, 'product')), 'the Product folder is not made');
|
|
184
|
+
assert.match(yad(T, W, ['init', '--json', ...base, '--connect', 'ghost', '--coderabbit', 'none']).json.error, /no repo named ghost was found/);
|
|
185
|
+
// Review 1: --add-repo alone does not answer the repos found: refused, and nothing is made.
|
|
186
|
+
// (A repo in a sub-folder of the workspace: init offers only the ones directly beside the Product.)
|
|
187
|
+
gitRepo(T, path.join(W, 'nested/x'));
|
|
188
|
+
const addOnly = yad(T, W, ['init', '--json', ...base, '--add-repo', 'x=../nested/x', '--coderabbit', 'none']);
|
|
189
|
+
assert.deepEqual(ids(addOnly), ['repos']);
|
|
190
|
+
assert.ok(!fs.existsSync(path.join(W, 'product')), 'the Product folder is not made');
|
|
191
|
+
const r = yad(T, W, ['init', '--json', ...base, '--connect', 'a', '--coderabbit', 'none']);
|
|
192
|
+
assert.equal(r.code, 0, r.out + r.err);
|
|
193
|
+
assert.deepEqual(JSON.parse(read(path.join(W, 'product/.sdlc/repos.json'))).repos.map((x) => x.name), ['a']);
|
|
194
|
+
// A re-run asks only about the repo not registered yet.
|
|
195
|
+
const rerun = yad(T, W, ['init', '--json', '--no-tools', '--ide-targets', '.claude', '--no-reconfigure', '--coderabbit', 'none']);
|
|
196
|
+
assert.deepEqual(rerun.json.questions.map((q) => [q.id, q.choices.at(-1)]), [['repos', 'b']]);
|
|
197
|
+
// --connect all and none, in fresh workspaces.
|
|
198
|
+
for (const [connect, want] of [['all', ['a', 'b']], ['none', []]]) {
|
|
199
|
+
const X = path.join(T, `ws-${connect}`);
|
|
200
|
+
for (const n of ['a', 'b']) gitRepo(T, path.join(X, n));
|
|
201
|
+
const c = yad(T, X, ['init', '--json', ...base, '--connect', connect, '--coderabbit', 'none']);
|
|
202
|
+
assert.equal(c.code, 0, c.out + c.err);
|
|
203
|
+
const reg = path.join(X, 'product/.sdlc/repos.json');
|
|
204
|
+
assert.deepEqual(fs.existsSync(reg) ? JSON.parse(read(reg)).repos.map((x) => x.name) : [], want, connect);
|
|
205
|
+
}
|
|
206
|
+
// A monorepo connects one repo: CodeRabbit is asked about that one only.
|
|
207
|
+
const M = path.join(T, 'ws-mono');
|
|
208
|
+
for (const n of ['a', 'b']) gitRepo(T, path.join(M, n));
|
|
209
|
+
const mono = yad(T, M, ['init', '--json', ...base, '--monorepo', '--connect', 'all']);
|
|
210
|
+
assert.deepEqual(mono.json.questions.map((q) => [q.id, q.choices.at(-1)]), [['coderabbit', 'a']]);
|
|
211
|
+
// setup --add-repo: two repos, one with its platform and branch; CodeRabbit in one of them only.
|
|
212
|
+
const V = path.join(T, 'ws2');
|
|
213
|
+
const P = path.join(V, 'product');
|
|
214
|
+
gitRepo(T, P);
|
|
215
|
+
for (const n of ['api', 'web']) gitRepo(T, path.join(V, n));
|
|
216
|
+
const s = yad(T, P, ['setup', '--json', '--solo', '--greenfield', '--separate', '--no-tools', '--ide-targets', '.claude', '--platform', 'none',
|
|
217
|
+
'--add-repo', 'api=../api,gitlab,trunk', '--add-repo', 'web=../web', '--coderabbit', 'web']);
|
|
218
|
+
assert.equal(s.code, 0, s.out + s.err);
|
|
219
|
+
const repos = JSON.parse(read(path.join(P, '.sdlc/repos.json'))).repos;
|
|
220
|
+
assert.deepEqual(repos.map((x) => [x.name, x.path, x.platform, x.default_branch]), [['api', '../api', 'gitlab', 'trunk'], ['web', '../web', 'github', 'main']]);
|
|
221
|
+
assert.ok(fs.existsSync(path.join(V, 'web/.coderabbit.yaml')));
|
|
222
|
+
assert.ok(!fs.existsSync(path.join(V, 'api/.coderabbit.yaml')));
|
|
223
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
test('E159 case 11: a tool named by flag turns the tools step on; the others are then asked; its URL comes by flag', () => {
|
|
227
|
+
const T = tmp();
|
|
228
|
+
try {
|
|
229
|
+
const base = ['--solo', '--greenfield', '--monorepo', '--no-git-init', '--ide-targets', '.claude', '--platform', 'none', '--connect', 'none'];
|
|
230
|
+
const P = path.join(T, 'p');
|
|
231
|
+
fs.mkdirSync(P);
|
|
232
|
+
assert.deepEqual(ids(yad(T, P, ['setup', '--json', ...base, '--design', 'figma'])), ['testing', 'learning']);
|
|
233
|
+
const r = yad(T, P, ['setup', '--json', ...base, '--design', 'figma', '--design-url', 'https://figma.example/f/1', '--testing', 'none', '--learning', 'none']);
|
|
234
|
+
assert.equal(r.code, 0, r.out + r.err);
|
|
235
|
+
const design = JSON.parse(read(path.join(P, '.sdlc/design.json')));
|
|
236
|
+
assert.deepEqual([design.tool, design.project_url], ['figma', 'https://figma.example/f/1']);
|
|
237
|
+
assert.equal(JSON.parse(read(path.join(P, '.sdlc/testing.json'))).tool, 'none');
|
|
238
|
+
// A tool name in capitals reads as setup reads a typed answer.
|
|
239
|
+
const U = path.join(T, 'u');
|
|
240
|
+
fs.mkdirSync(U);
|
|
241
|
+
const upper = yad(T, U, ['setup', '--json', ...base, '--design', 'Figma', '--testing', 'NONE', '--learning', 'none']);
|
|
242
|
+
assert.equal(upper.code, 0, upper.out + upper.err);
|
|
243
|
+
assert.equal(JSON.parse(read(path.join(U, '.sdlc/design.json'))).tool, 'figma');
|
|
244
|
+
// --no-tools records all three as none, and asks none of them.
|
|
245
|
+
const N = path.join(T, 'n');
|
|
246
|
+
fs.mkdirSync(N);
|
|
247
|
+
assert.equal(yad(T, N, ['setup', '--json', ...base, '--no-tools']).code, 0);
|
|
248
|
+
for (const f of ['design', 'testing', 'learning']) assert.equal(JSON.parse(read(path.join(N, `.sdlc/${f}.json`))).tool, 'none', f);
|
|
249
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
test('E159 case 12: new never asks about git init and makes nothing until answered; join asks only the AI tools, before it clones', () => {
|
|
253
|
+
const T = tmp();
|
|
254
|
+
try {
|
|
255
|
+
const W = path.join(T, 'here');
|
|
256
|
+
fs.mkdirSync(W);
|
|
257
|
+
const r = yad(T, W, ['new', 'acme', '--json']);
|
|
258
|
+
assert.equal(r.code, 1);
|
|
259
|
+
assert.ok(!ids(r).includes('git-init'), ids(r).join(','));
|
|
260
|
+
assert.deepEqual(fs.readdirSync(W), [], 'no workspace folder made');
|
|
261
|
+
const done = yad(T, W, ['new', 'acme', '--json', '--solo', '--monorepo', '--no-tools', '--ide-targets', '.claude', '--platform', 'none', '--connect', 'none']);
|
|
262
|
+
assert.equal(done.code, 0, done.out + done.err);
|
|
263
|
+
assert.ok(fs.existsSync(path.join(W, 'acme/product/.sdlc/product.json')));
|
|
264
|
+
const J = path.join(T, 'join');
|
|
265
|
+
fs.mkdirSync(J);
|
|
266
|
+
const join = yad(T, J, ['join', path.join(T, 'nowhere.git'), '--json']);
|
|
267
|
+
assert.equal(join.code, 1);
|
|
268
|
+
assert.deepEqual(ids(join), ['ide-targets']);
|
|
269
|
+
assert.deepEqual(fs.readdirSync(J), [], 'nothing cloned');
|
|
270
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
test('E159 case 13: member add --json never starts a login: the person\'s step names the exact command', { skip: process.platform === 'win32' && 'a shell-script gh' }, () => {
|
|
274
|
+
const T = tmp();
|
|
275
|
+
try {
|
|
276
|
+
const P = path.join(T, 'p');
|
|
277
|
+
gitRepo(T, P);
|
|
278
|
+
put(path.join(P, '.sdlc/product.json'), { platform: 'github', git_url: 'git@github.com:acme/p.git', default_branch: 'main' });
|
|
279
|
+
// A gh that knows no account (first on PATH, so a real one on the machine is never asked), and platform
|
|
280
|
+
// lookups on: nobody is logged in.
|
|
281
|
+
const bin = path.join(T, 'bin');
|
|
282
|
+
put(path.join(bin, 'gh'), '#!/bin/sh\nexit 1\n');
|
|
283
|
+
fs.chmodSync(path.join(bin, 'gh'), 0o755);
|
|
284
|
+
const r = yad(T, P, ['member', 'add', '--json'], { PATH: `${bin}${path.delimiter}${process.env.PATH}`, YAD_PLATFORM_LOGIN: undefined });
|
|
285
|
+
assert.equal(r.code, 1, r.out + r.err);
|
|
286
|
+
assert.equal(r.json.ok, false);
|
|
287
|
+
assert.match(r.json.error, /not logged in to GitHub on github\.com/);
|
|
288
|
+
assert.deepEqual(r.json.person.commands, ['gh auth login --hostname github.com --scopes user:email']);
|
|
289
|
+
assert.equal(r.json.person.verify, 'yad member add --json');
|
|
290
|
+
assert.match(r.json.hint, /the person runs/);
|
|
291
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
test('E159 case 14: yad guide --json lists the questions the folder\'s command would ask', () => {
|
|
295
|
+
const T = tmp();
|
|
296
|
+
try {
|
|
297
|
+
const E = path.join(T, 'empty');
|
|
298
|
+
fs.mkdirSync(E);
|
|
299
|
+
const g = yad(T, E, ['guide', '--json']);
|
|
300
|
+
assert.equal(g.json.situation.stage, 'no-product');
|
|
301
|
+
assert.equal(g.json.agent[0].run, 'npx -y yadflow@4 new <name> --json');
|
|
302
|
+
const refused = yad(T, E, ['new', 'acme', '--json']);
|
|
303
|
+
assert.deepEqual(g.json.questions.map((q) => q.id), ids(refused));
|
|
304
|
+
const W = path.join(T, 'ws');
|
|
305
|
+
for (const n of ['a', 'b']) gitRepo(T, path.join(W, n));
|
|
306
|
+
const gi = yad(T, W, ['guide', '--json']);
|
|
307
|
+
assert.equal(gi.json.agent[0].run, 'npx -y yadflow@4 init --json');
|
|
308
|
+
// Init's profile defaults (brownfield, separate) are the guide's too; with them answered, the rest match.
|
|
309
|
+
const left = yad(T, W, ['init', '--json']);
|
|
310
|
+
assert.deepEqual(gi.json.questions.map((q) => q.id), ids(left));
|
|
311
|
+
assert.ok(gi.json.questions.find((q) => q.id === 'repos').choices.includes('a,b'));
|
|
312
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
test('E159 case 15: under --json the old skills in the person\'s home folder are left alone, and said', () => {
|
|
316
|
+
const T = tmp();
|
|
317
|
+
try {
|
|
318
|
+
const old = path.join(T, '.home/.claude/skills/sdlc-author-epic');
|
|
319
|
+
put(path.join(old, 'SKILL.md'), '---\nname: sdlc-author-epic\n---\n');
|
|
320
|
+
const P = path.join(T, 'p');
|
|
321
|
+
fs.mkdirSync(P);
|
|
322
|
+
const r = yad(T, P, ['setup', '--json', '--solo', '--greenfield', '--monorepo', '--no-tools', '--no-git-init', '--ide-targets', '.claude', '--platform', 'none', '--connect', 'none']);
|
|
323
|
+
assert.equal(r.code, 0, r.out + r.err);
|
|
324
|
+
assert.ok(fs.existsSync(path.join(old, 'SKILL.md')), 'left as it is');
|
|
325
|
+
assert.ok((r.json.notes || []).some((n) => /global ~\/\.claude\/skills/.test(n)), JSON.stringify(r.json.notes));
|
|
326
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
test('E159 case 13 (join): join --json never starts a login; its member step is the person\'s', { skip: process.platform === 'win32' && 'a shell-script gh' }, () => {
|
|
330
|
+
const T = tmp();
|
|
331
|
+
try {
|
|
332
|
+
// A Product on GitHub, as a bare repo to clone.
|
|
333
|
+
const src = path.join(T, 'src');
|
|
334
|
+
gitRepo(T, src);
|
|
335
|
+
put(path.join(src, '.sdlc/product.json'), { platform: 'github', git_url: 'git@github.com:acme/p.git', default_branch: 'main' });
|
|
336
|
+
execFileSync('git', ['add', '-A'], { cwd: src, env: env(T) });
|
|
337
|
+
execFileSync('git', ['commit', '-q', '-m', 'chore: product'], { cwd: src, env: env(T) });
|
|
338
|
+
const bare = path.join(T, 'acme.git');
|
|
339
|
+
execFileSync('git', ['clone', '-q', '--bare', src, bare], { env: env(T) });
|
|
340
|
+
const bin = path.join(T, 'bin');
|
|
341
|
+
put(path.join(bin, 'gh'), '#!/bin/sh\nexit 1\n');
|
|
342
|
+
fs.chmodSync(path.join(bin, 'gh'), 0o755);
|
|
343
|
+
const J = path.join(T, 'join');
|
|
344
|
+
fs.mkdirSync(J);
|
|
345
|
+
assert.match(yad(T, J, ['join', bare, '--json', '--ide-targets', '.vscode']).json.error, /--ide-targets: unsupported/);
|
|
346
|
+
assert.deepEqual(fs.readdirSync(J), [], 'a bad value is refused before the clone');
|
|
347
|
+
const r = yad(T, J, ['join', bare, '--json', '--ide-targets', '.claude'], { PATH: `${bin}${path.delimiter}${process.env.PATH}`, YAD_PLATFORM_LOGIN: undefined });
|
|
348
|
+
assert.equal(r.code, 0, r.out + r.err);
|
|
349
|
+
assert.equal(r.json.member.written, false);
|
|
350
|
+
assert.deepEqual(r.json.member.person.commands, ['gh auth login --hostname github.com --scopes user:email']);
|
|
351
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
352
|
+
});
|