yadflow 4.6.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 +259 -0
- package/README.md +46 -4
- package/bin/commands.mjs +9 -2
- package/bin/yad.mjs +309 -30
- 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/artifact-status.mjs +88 -20
- package/cli/build.mjs +1372 -0
- package/cli/checkpoint.mjs +2 -2
- package/cli/ci-check.mjs +492 -0
- package/cli/commit.mjs +1 -0
- package/cli/dial.mjs +21 -1
- package/cli/docs.mjs +7 -2
- package/cli/doctor.mjs +176 -33
- package/cli/epic-state.mjs +360 -12
- package/cli/errors.mjs +3 -0
- package/cli/find-product.mjs +36 -2
- package/cli/fold.mjs +9 -5
- package/cli/gate-local.mjs +9 -1
- package/cli/gate.mjs +364 -22
- package/cli/guide.mjs +549 -0
- package/cli/history.mjs +22 -2
- package/cli/hook.mjs +35 -4
- package/cli/index-command.mjs +2 -2
- package/cli/ledger.mjs +60 -0
- 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 +35 -12
- package/cli/openpr.mjs +81 -5
- package/cli/plan.mjs +326 -22
- package/cli/platform.mjs +21 -0
- package/cli/pr-list.mjs +5 -3
- package/cli/product-index.mjs +6 -3
- package/cli/product-token.mjs +186 -0
- package/cli/productcommit.mjs +33 -0
- package/cli/protection.mjs +50 -0
- package/cli/recommend.mjs +3 -1
- package/cli/reconcile.mjs +187 -26
- package/cli/repo-publish.mjs +2 -2
- package/cli/report.mjs +62 -14
- package/cli/run-checks.mjs +586 -0
- package/cli/setup.mjs +244 -25
- package/cli/ship-drift.mjs +49 -18
- package/cli/signing.mjs +377 -0
- package/cli/standup.mjs +1 -1
- package/cli/status.mjs +282 -0
- package/cli/test-agents-file.mjs +993 -0
- package/cli/test-build.mjs +1559 -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-run-checks.mjs +603 -0
- package/cli/test-setup-agent.mjs +352 -0
- package/cli/test-signing.mjs +524 -0
- package/cli/test-worktree.mjs +520 -0
- package/cli/thread.mjs +4 -0
- package/cli/tidy.mjs +2 -2
- package/cli/toolbox.mjs +37 -6
- package/cli/update-commit.mjs +313 -11
- package/cli/workspace.mjs +38 -10
- package/cli/worktree-record.mjs +53 -0
- package/cli/worktree.mjs +379 -0
- package/package.json +6 -4
- package/skills/sdlc/config.yaml +5 -5
- package/skills/sdlc/module-help.csv +2 -1
- package/skills/yad-backfill/templates/checks/backfill-check.sh +9 -9
- package/skills/yad-change/SKILL.md +5 -1
- package/skills/yad-checks/SKILL.md +61 -12
- package/skills/yad-checks/references/check-gates.md +78 -14
- package/skills/yad-checks/templates/checks/build-test-lint.sh +22 -3
- package/skills/yad-checks/templates/checks/commit-message.sh +8 -2
- package/skills/yad-checks/templates/checks/contract-check.sh +61 -33
- package/skills/yad-checks/templates/checks/epic-open.sh +87 -14
- package/skills/yad-checks/templates/checks/ledger-guard.sh +3 -3
- package/skills/yad-checks/templates/checks/lineage-check.sh +88 -15
- package/skills/yad-checks/templates/checks/member-check.mjs +206 -35
- package/skills/yad-checks/templates/checks/package-manager.sh +42 -5
- package/skills/yad-checks/templates/checks/product-checkout.sh +161 -13
- package/skills/yad-checks/templates/checks/reconcile-debt-check.sh +94 -15
- package/skills/yad-checks/templates/checks/risk-map-check.sh +2 -2
- package/skills/yad-checks/templates/checks/spec-link.sh +63 -4
- package/skills/yad-checks/templates/checks/verified-commits.sh +23 -5
- package/skills/yad-checks/templates/github/yad-checks.yml +9 -9
- package/skills/yad-checks/templates/gitlab/.gitlab-ci.yml +4 -1
- package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +5 -5
- package/skills/yad-checks/templates/gitlab/yad-product-checks.gitlab-ci.yml +16 -3
- package/skills/yad-checks/templates/gitlab/yad-update-guard.gitlab-ci.yml +5 -1
- package/skills/yad-checks/templates/gitlab/yad-verified-commits.gitlab-ci.yml +5 -1
- package/skills/yad-checks/templates/hooks/agent-guard.mjs +116 -0
- package/skills/yad-commit/SKILL.md +8 -5
- 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/templates/app/package-lock.json +395 -106
- package/skills/yad-docs/templates/app/package.json +2 -2
- package/skills/yad-docs-overview/references/pipeline-model.md +2 -2
- package/skills/yad-engineer-review/SKILL.md +55 -25
- package/skills/yad-engineer-review/references/ship-and-record.md +49 -12
- package/skills/yad-epic/SKILL.md +2 -1
- package/skills/yad-epic/references/state-schema.md +76 -17
- package/skills/yad-guide/SKILL.md +192 -0
- package/skills/yad-implement/SKILL.md +75 -13
- package/skills/yad-implement/references/implement-conventions.md +8 -1
- package/skills/yad-implement/templates/.gitmessage +3 -0
- package/skills/yad-open-pr/SKILL.md +21 -0
- package/skills/yad-pair-review/SKILL.md +14 -5
- package/skills/yad-pr-template/SKILL.md +6 -2
- package/skills/yad-pr-template/templates/checks/pr-template.sh +85 -4
- package/skills/yad-pr-template/templates/checks/pr-title.sh +1 -1
- package/skills/yad-pr-template/templates/github/pull_request_template.md +1 -1
- package/skills/yad-pr-template/templates/gitlab/merge_request_templates/Default.md +1 -1
- package/skills/yad-product-bridge/SKILL.md +44 -12
- package/skills/yad-product-bridge/references/bridge.md +11 -5
- 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 +9 -4
- package/skills/yad-reconcile/SKILL.md +9 -3
- package/skills/yad-report/SKILL.md +15 -0
- package/skills/yad-review-companion/SKILL.md +5 -3
- package/skills/yad-review-gate/SKILL.md +16 -8
- package/skills/yad-review-gate/references/gating.md +26 -1
- package/skills/yad-run/SKILL.md +61 -33
- package/skills/yad-run/references/run-loop.md +44 -22
- package/skills/yad-spec/SKILL.md +137 -16
- package/skills/yad-spec/references/spec-handoff.md +50 -3
- package/skills/yad-status/SKILL.md +7 -0
- package/skills/yad-stories/references/story-schema.md +1 -1
- package/skills/yad-sync-repos/SKILL.md +2 -1
- package/skills/yad-ui/SKILL.md +2 -2
|
@@ -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
|
+
});
|