yadflow 4.7.0 → 4.9.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 +116 -0
- package/README.md +43 -4
- package/bin/commands.mjs +5 -1
- package/bin/yad.mjs +169 -22
- package/cli/agent-guard.mjs +511 -0
- package/cli/agent-guide.mjs +83 -0
- package/cli/agent-rules.mjs +388 -0
- package/cli/argv-flags.mjs +7 -0
- package/cli/build.mjs +1 -1
- package/cli/ci-check.mjs +492 -0
- package/cli/docs.mjs +1 -1
- package/cli/doctor.mjs +148 -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/machine.mjs +141 -0
- 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/openpr.mjs +46 -6
- package/cli/plan.mjs +326 -22
- package/cli/preview.mjs +253 -0
- package/cli/protection.mjs +50 -0
- package/cli/reconcile.mjs +187 -26
- package/cli/repo.mjs +64 -3
- package/cli/report.mjs +62 -14
- package/cli/review.mjs +4 -0
- package/cli/setup.mjs +244 -25
- package/cli/signing.mjs +377 -0
- package/cli/story-frames.mjs +296 -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-machine.mjs +140 -0
- package/cli/test-node.mjs +129 -0
- package/cli/test-preview.mjs +511 -0
- package/cli/test-setup-agent.mjs +352 -0
- package/cli/test-signing.mjs +524 -0
- package/cli/test-story-frames.mjs +339 -0
- package/cli/toolbox.mjs +35 -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-design/SKILL.md +7 -4
- package/skills/yad-connect-design/references/design-context.md +23 -0
- package/skills/yad-connect-design/references/design-registry.md +3 -3
- package/skills/yad-connect-repos/SKILL.md +13 -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 +25 -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 +7 -1
- package/skills/yad-guide/SKILL.md +192 -0
- package/skills/yad-implement/SKILL.md +14 -0
- package/skills/yad-open-pr/SKILL.md +5 -2
- package/skills/yad-pair-review/SKILL.md +19 -5
- package/skills/yad-pr-template/templates/github/pull_request_template.md +1 -0
- package/skills/yad-pr-template/templates/gitlab/merge_request_templates/Default.md +1 -0
- 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 +9 -4
- 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-spec/SKILL.md +21 -0
- package/skills/yad-stories/SKILL.md +22 -0
- package/skills/yad-stories/references/story-schema.md +1 -0
- package/skills/yad-sync-repos/SKILL.md +2 -1
- package/skills/yad-ui/SKILL.md +7 -2
|
@@ -0,0 +1,1267 @@
|
|
|
1
|
+
// `yad guide` and the agent rules (E157). The rules each test pins:
|
|
2
|
+
// - every command `bin/yad.mjs` knows has a class in the rules, so a new command cannot arrive without one;
|
|
3
|
+
// - an approval, a gate reopen and a gate comment are the person's; a push to the default branch is asked
|
|
4
|
+
// every time; a dial, the mode and the kill switch only when asked;
|
|
5
|
+
// - the brief comes from the lifecycle default: what the step is for, mandatory or skippable (by the
|
|
6
|
+
// epic's route), who does it (the epic's recorded driver first), and a gate is always a person's;
|
|
7
|
+
// - a review gate hands the approval to the person, with a platform or without one, and names the command
|
|
8
|
+
// that confirms it; the agent never picks an epic for the person;
|
|
9
|
+
// - with no Product, the answer is how to start one, and the rules ride every answer.
|
|
10
|
+
import { test } from 'node:test';
|
|
11
|
+
import assert from 'node:assert/strict';
|
|
12
|
+
import { execFileSync, spawnSync } from 'node:child_process';
|
|
13
|
+
import fs from 'node:fs';
|
|
14
|
+
import os from 'node:os';
|
|
15
|
+
import path from 'node:path';
|
|
16
|
+
|
|
17
|
+
// The #280 guard (cli/test.mjs): printed lines go to stderr while the runner owns stdout.
|
|
18
|
+
if (process.env.NODE_TEST_CONTEXT) {
|
|
19
|
+
const write = process.stdout.write;
|
|
20
|
+
for (const k of ['log', 'info']) {
|
|
21
|
+
const orig = console[k];
|
|
22
|
+
console[k] = (...a) => (process.stdout.write === write ? console.error(...a) : orig(...a));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
process.env.YAD_NO_UPDATE_NOTIFIER = '1';
|
|
26
|
+
process.env.YAD_PLATFORM_LOGIN = '0';
|
|
27
|
+
process.env.YAD_PLATFORM_READ = '0';
|
|
28
|
+
process.env.YAD_CAPTURE = '0';
|
|
29
|
+
for (const k of Object.keys(process.env)) if (/^GIT_(AUTHOR|COMMITTER)_/.test(k)) delete process.env[k];
|
|
30
|
+
|
|
31
|
+
const { buildGuide, stepFacts, playbook, tok, agentRun } = await import('./guide.mjs');
|
|
32
|
+
const COMMAND_CLASS_MODULE = await import('./agent-rules.mjs');
|
|
33
|
+
const { COMMAND_CLASS, CLASSES, ASK, RULES, HUMAN_ONLY_ACTS, NEVER, classify, askFor } = await import('./agent-rules.mjs');
|
|
34
|
+
const { DEFAULT_LIFECYCLE } = await import('./lifecycle.mjs');
|
|
35
|
+
const { runEpicNew } = await import('./epic.mjs');
|
|
36
|
+
const { gateOpen } = await import('./gate.mjs');
|
|
37
|
+
|
|
38
|
+
const ROOT = path.join(path.dirname(new URL(import.meta.url).pathname), '..');
|
|
39
|
+
const YAD = path.join(ROOT, 'bin', 'yad.mjs');
|
|
40
|
+
const tmp = () => fs.mkdtempSync(path.join(os.tmpdir(), 'yad-guide-'));
|
|
41
|
+
// A path with no file: a test repo set to it reads no global ignore file, so a machine whose own one hides
|
|
42
|
+
// `.claude/` sees what CI sees.
|
|
43
|
+
const NO_GLOBAL_IGNORE = path.join(os.tmpdir(), 'yad-guide-no-global-ignore');
|
|
44
|
+
const put = (file, data) => { fs.mkdirSync(path.dirname(file), { recursive: true }); fs.writeFileSync(file, typeof data === 'string' ? data : JSON.stringify(data, null, 2)); };
|
|
45
|
+
const git = (cwd, args) => execFileSync('git', args, { cwd, stdio: 'pipe' }).toString().trim();
|
|
46
|
+
|
|
47
|
+
async function product({ platform = 'github', solo = false, epics = ['pay'], verified = true } = {}) {
|
|
48
|
+
const T = tmp();
|
|
49
|
+
git(T, ['init', '-q', '-b', 'main']);
|
|
50
|
+
git(T, ['config', 'user.name', 'Alice Smith']);
|
|
51
|
+
git(T, ['config', 'user.email', 'alice@work.com']);
|
|
52
|
+
git(T, ['config', 'commit.gpgsign', 'false']);
|
|
53
|
+
git(T, ['commit', '-q', '--allow-empty', '-m', 'chore: start']);
|
|
54
|
+
put(path.join(T, '.sdlc/product.json'), { platform, git_url: 'git@github.com:acme/product.git', default_branch: 'main', ...(solo ? { solo: true } : {}), ...(platform && verified ? { ledger: 'verified' } : {}) });
|
|
55
|
+
for (const slug of epics) await runEpicNew(T, { slug, today: '2026-10-20' });
|
|
56
|
+
return T;
|
|
57
|
+
}
|
|
58
|
+
const statePath = (T, id) => path.join(T, 'epics', id, '.sdlc', 'state.json');
|
|
59
|
+
const readState = (T, id) => JSON.parse(fs.readFileSync(statePath(T, id), 'utf8'));
|
|
60
|
+
// Walk the chain to one step: every step before it done, it in `status`.
|
|
61
|
+
function moveTo(T, id, stepId, status = 'in_progress') {
|
|
62
|
+
const st = readState(T, id);
|
|
63
|
+
const at = st.steps.findIndex((s) => s.id === stepId);
|
|
64
|
+
assert.ok(at >= 0, `${stepId} is on the chain`);
|
|
65
|
+
st.steps.forEach((s, i) => { if (i < at) s.status = 'done'; if (i === at) s.status = status; });
|
|
66
|
+
st.currentStep = stepId;
|
|
67
|
+
put(statePath(T, id), st);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ---- the rules ----------------------------------------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
test('every command bin/yad.mjs knows has a class, and every class is one the rules define', () => {
|
|
73
|
+
const src = fs.readFileSync(YAD, 'utf8');
|
|
74
|
+
const sw = src.slice(src.indexOf('switch (cmd) {'));
|
|
75
|
+
const cmds = [...new Set([...sw.matchAll(/^\s{4}case '([a-z-]+)':/gm)].map((m) => m[1]))];
|
|
76
|
+
assert.ok(cmds.length > 50, `found ${cmds.length} commands`);
|
|
77
|
+
const actions = src.slice(src.indexOf('const ACTIONS = {'), src.indexOf('};', src.indexOf('const ACTIONS = {')));
|
|
78
|
+
const known = Object.fromEntries([...actions.matchAll(/^\s+'?([a-z-]+)'?: \{ known: \[([^\]]*)\]/gm)].map((m) => [m[1], [...m[2].matchAll(/'([a-z-]+)'/g)].map((x) => x[1])]));
|
|
79
|
+
const missing = [];
|
|
80
|
+
for (const cmd of cmds) {
|
|
81
|
+
if (known[cmd]) { for (const action of known[cmd]) if (!classify([cmd, action])) missing.push(`${cmd} ${action}`); }
|
|
82
|
+
else if (!classify([cmd])) missing.push(cmd);
|
|
83
|
+
}
|
|
84
|
+
assert.deepEqual(missing, [], 'add these to COMMAND_CLASS in cli/agent-rules.mjs');
|
|
85
|
+
for (const [k, v] of Object.entries(COMMAND_CLASS)) {
|
|
86
|
+
assert.ok(CLASSES.includes(v.class), `${k}: ${v.class}`);
|
|
87
|
+
for (const f of Object.values(v.flags || {})) assert.ok(CLASSES.includes(f), `${k}: ${f}`);
|
|
88
|
+
}
|
|
89
|
+
assert.deepEqual(Object.keys(ASK), CLASSES);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('the classes the person decided: approvals are theirs, a default-branch push is asked every time, dials only on request', () => {
|
|
93
|
+
for (const a of ['approve', 'advance', 'reopen', 'comment']) assert.equal(classify(['gate', a]), 'human-only', `gate ${a}`);
|
|
94
|
+
assert.equal(askFor('human-only'), 'person-runs');
|
|
95
|
+
for (const [w, f] of [[['update'], ['push']], [['gate', 'repair'], ['push']], [['checkpoint'], ['push']], [['tidy', 'up'], ['push']], [['repo', 'refresh'], ['push']]]) {
|
|
96
|
+
assert.equal(classify(w, f), 'default-push', w.join(' '));
|
|
97
|
+
assert.equal(classify(w), 'local-write', `${w.join(' ')} without --push`);
|
|
98
|
+
}
|
|
99
|
+
assert.equal(askFor('default-push'), 'each-time');
|
|
100
|
+
assert.equal(classify(['dial']), 'read');
|
|
101
|
+
assert.equal(classify(['dial', 'open-pr'], ['to']), 'on-request');
|
|
102
|
+
for (const c of ['kill', 'unkill']) assert.equal(classify([c]), 'on-request');
|
|
103
|
+
assert.equal(classify(['mode']), 'read', 'yad mode alone reads it');
|
|
104
|
+
for (const m of ['solo', 'team']) assert.equal(classify(['mode', m]), 'on-request');
|
|
105
|
+
// A skip, a deferral or clearing a blocker is a decision about the work: the person's.
|
|
106
|
+
for (const c of ['skip', 'unskip', 'defer', 'undefer', 'unblock']) assert.equal(classify([c]), 'on-request', c);
|
|
107
|
+
assert.equal(classify(['check'], ['fix', 'push']), 'default-push', 'check --fix --push is update --push');
|
|
108
|
+
assert.equal(classify(['commit']), 'local-write');
|
|
109
|
+
assert.equal(classify(['commit'], ['manual']), 'human-only', 'the door past the ledger hook is the person\'s');
|
|
110
|
+
assert.equal(classify(['member', 'remove']), 'local-write', 'your own member file');
|
|
111
|
+
assert.equal(classify(['member', 'remove'], ['reason']), 'on-request', 'someone else\'s');
|
|
112
|
+
for (const w of [['commit'], ['ship'], ['assign'], ['unassign']]) assert.equal(classify(w, ['force']), 'on-request', `${w[0]} --force`);
|
|
113
|
+
// A run's verdict is the person's judgement; the skills record it once given (yad-spec, yad-implement,
|
|
114
|
+
// yad-engineer-review), so the agent may run it, never decide it.
|
|
115
|
+
assert.equal(classify(['build', 'trust'], ['uid']), 'on-request');
|
|
116
|
+
// Setting a Product up chooses its mode (a run with no answers takes solo): run only with the person's answers (E159).
|
|
117
|
+
for (const c of ['setup', 'new', 'init']) for (const f of [[], ['solo'], ['team']]) assert.equal(classify([c], f), 'on-request', `${c} ${f.join(' ')}`);
|
|
118
|
+
assert.equal(classify(['join']), 'open-pr', 'a joined Product\'s mode is already set');
|
|
119
|
+
for (const w of [['skill', 'bind'], ['skill', 'unbind'], ['toolbox', 'add'], ['toolbox', 'remove']]) assert.equal(classify(w), 'on-request', w.join(' '));
|
|
120
|
+
for (const w of [['commit'], ['ship']]) assert.equal(classify(w, ['ai']), 'on-request', `${w[0]} --ai`);
|
|
121
|
+
for (const w of [['check'], ['update'], ['checkpoint'], ['gate', 'repair'], ['tidy', 'up'], ['repo', 'refresh']]) assert.equal(classify(w, ['allow-branch']), 'on-request', `${w.join(' ')} --allow-branch`);
|
|
122
|
+
// The person asking for a command does not cover its push: still asked every time.
|
|
123
|
+
assert.equal(askFor(classify(['update'], ['overwrite-local', 'push'])), 'each-time');
|
|
124
|
+
assert.equal(askFor(classify(['checkpoint'], ['retro-ship', 'push'])), 'each-time');
|
|
125
|
+
assert.equal(askFor(classify(['check'], ['fix', 'overwrite-local', 'push'])), 'each-time');
|
|
126
|
+
for (const c of ['check', 'update']) assert.equal(classify([c], ['overwrite-local']), 'on-request', `${c} --overwrite-local`);
|
|
127
|
+
assert.equal(classify(['build', 'ship'], ['merge-commit', 'approver']), 'on-request', 'a merge no platform confirmed');
|
|
128
|
+
assert.equal(classify(['checkpoint'], ['retro-ship']), 'on-request');
|
|
129
|
+
assert.equal(classify(['review', 'reconcile']), 'local-write');
|
|
130
|
+
assert.equal(askFor('on-request'), 'only-when-asked');
|
|
131
|
+
for (const w of [['gate', 'open'], ['gate', 'sync'], ['member', 'add']]) assert.equal(askFor(classify(w)), 'never', w.join(' '));
|
|
132
|
+
// A task PR/MR follows `yad dial open-pr` (#356): asked first unless the dial is `auto`.
|
|
133
|
+
for (const w of [['open-pr'], ['ship']]) assert.equal(classify(w), 'task-pr', w.join(' '));
|
|
134
|
+
assert.equal(askFor('task-pr'), 'per-dial');
|
|
135
|
+
assert.equal(classify(['docs', 'deploy']), 'local-write', 'it builds here; CI publishes on a push');
|
|
136
|
+
// A preview posts nothing; posting is asked every time (E158).
|
|
137
|
+
assert.equal(classify(['report']), 'read');
|
|
138
|
+
assert.equal(classify(['report'], ['post']), 'public-post');
|
|
139
|
+
assert.equal(askFor('public-post'), 'each-time');
|
|
140
|
+
assert.equal(classify(['check']), 'read');
|
|
141
|
+
assert.equal(classify(['check'], ['fix']), 'local-write');
|
|
142
|
+
assert.equal(classify(['gate', 'ci'], ['merged']), 'ci-only');
|
|
143
|
+
assert.equal(classify(['roster']), 'removed');
|
|
144
|
+
assert.equal(classify(['frobnicate']), null);
|
|
145
|
+
assert.equal(askFor(null), 'each-time', 'an unknown command is asked about');
|
|
146
|
+
// The acts that are not commands, and what is never done.
|
|
147
|
+
assert.deepEqual(HUMAN_ONLY_ACTS.map((a) => a.id), ['approve-merge', 'login', 'secrets', 'signing-key', 'platform-settings']);
|
|
148
|
+
assert.ok(NEVER.some((n) => n.id === 'force-push'));
|
|
149
|
+
assert.ok(RULES.some((r) => r.id === 'report'));
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('a command named alone runs its default action, and is classed as that action', () => {
|
|
153
|
+
const { DEFAULT_ACTION } = COMMAND_CLASS_MODULE;
|
|
154
|
+
const src = fs.readFileSync(YAD, 'utf8');
|
|
155
|
+
const actions = src.slice(src.indexOf('const ACTIONS = {'), src.indexOf('};', src.indexOf('const ACTIONS = {')));
|
|
156
|
+
const defaults = Object.fromEntries([...actions.matchAll(/^\s+'?([a-z-]+)'?: \{ known: \[[^\]]*\], default: '([a-z-]+)' \}/gm)].map((m) => [m[1], m[2]]));
|
|
157
|
+
assert.equal(Object.keys(defaults).length, (actions.match(/default:/g) || []).length, 'every default in ACTIONS was read');
|
|
158
|
+
assert.deepEqual(DEFAULT_ACTION, defaults, 'DEFAULT_ACTION in cli/agent-rules.mjs follows ACTIONS in bin/yad.mjs');
|
|
159
|
+
for (const [cmd, action] of Object.entries(defaults)) assert.equal(classify([cmd]), classify([cmd, action]), cmd);
|
|
160
|
+
assert.equal(classify(['member']), 'read');
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test('every command that pushes with --push says so: its --push is asked every time', () => {
|
|
164
|
+
// Each `case` of bin/yad.mjs's dispatch that hands `o.push` on must class --push as default-push.
|
|
165
|
+
const src = fs.readFileSync(YAD, 'utf8');
|
|
166
|
+
const sw = src.slice(src.indexOf('switch (cmd) {'));
|
|
167
|
+
const blocks = sw.split(/\n(?=\s{4}case ')/);
|
|
168
|
+
const pushers = [];
|
|
169
|
+
// `o.push` read directly, or `push` taken out of `o` by destructuring.
|
|
170
|
+
const readsPush = (b) => /\bo\.push\b/.test(b) || /\{[^}]*\bpush\b[^}]*\}\s*=\s*o\b/.test(b);
|
|
171
|
+
// `gate ci` is CI's own, and pushes there by design.
|
|
172
|
+
const ok = (cls) => cls === 'default-push' || cls === 'human-only' || cls === 'ci-only';
|
|
173
|
+
for (const b of blocks) {
|
|
174
|
+
if (!readsPush(b)) continue;
|
|
175
|
+
const cmds = [...b.matchAll(/^\s{4}case '([a-z-]+)':/gm)].map((m) => m[1]);
|
|
176
|
+
for (const cmd of cmds) {
|
|
177
|
+
// The actions whose own line hands `push` on (`action === 'repair'`), else the command as a whole.
|
|
178
|
+
const lines = b.split('\n').filter((l) => /\bpush\b/.test(l));
|
|
179
|
+
const actions = [...new Set(lines.flatMap((l) => [...l.matchAll(/action === '([a-z-]+)'/g)].map((m) => m[1])))];
|
|
180
|
+
pushers.push(...(actions.length ? actions.map((x) => [cmd, x]) : [[cmd]]));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
assert.ok(pushers.length >= 6, pushers.map((w) => w.join(' ')).join(', '));
|
|
184
|
+
for (const words of pushers) {
|
|
185
|
+
// A command whose action is a variable (`yad repo <action>`): one of its actions must class --push.
|
|
186
|
+
const keys = words.length === 1 && !COMMAND_CLASS[words[0]] ? Object.keys(COMMAND_CLASS).filter((k) => k.startsWith(`${words[0]} `)) : null;
|
|
187
|
+
if (keys) assert.ok(keys.some((k) => ok(classify(k.split(' '), ['push']))), `${words[0]}: no action classes --push`);
|
|
188
|
+
else assert.ok(ok(classify(words, ['push'])), `${words.join(' ')} --push is ${classify(words, ['push'])}: it must be default-push`);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// ---- the brief ----------------------------------------------------------------------------------------
|
|
193
|
+
|
|
194
|
+
test('the lifecycle facts: an author step, its gate, a lane step, and a sentinel', () => {
|
|
195
|
+
const epic = stepFacts('epic');
|
|
196
|
+
assert.equal(epic.description, DEFAULT_LIFECYCLE.steps.find((s) => s.id === 'epic').description);
|
|
197
|
+
assert.equal(epic.driver, 'pair');
|
|
198
|
+
assert.equal(epic.part, 'Shape');
|
|
199
|
+
const gate = stepFacts('epic-review');
|
|
200
|
+
assert.equal(gate.gate, true);
|
|
201
|
+
assert.equal(gate.reviews, 'epic');
|
|
202
|
+
assert.equal(gate.driver, 'human');
|
|
203
|
+
assert.equal(gate.advance, 'human');
|
|
204
|
+
assert.match(gate.description, /A person reviews the epic/);
|
|
205
|
+
assert.equal(stepFacts('implement').driver, 'agent');
|
|
206
|
+
assert.equal(stepFacts('engineer-review').driver, 'human');
|
|
207
|
+
assert.equal(stepFacts('ready-for-build'), null);
|
|
208
|
+
assert.equal(stepFacts('nope-review'), null);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
test('an author step: its brief, mandatory, the epic\'s recorded driver, the bound skill, recommendations, and the agent\'s check', async () => {
|
|
212
|
+
const T = await product();
|
|
213
|
+
try {
|
|
214
|
+
const g = buildGuide(T, { epic: 'EP-pay' });
|
|
215
|
+
assert.equal(g.situation.stage, 'in-epic');
|
|
216
|
+
assert.equal(g.situation.ledger, 'verified');
|
|
217
|
+
assert.equal(g.step.id, 'epic');
|
|
218
|
+
assert.equal(g.step.actionKind, 'author');
|
|
219
|
+
assert.equal(g.step.brief, stepFacts('epic').description);
|
|
220
|
+
assert.equal(g.step.mandatory, true);
|
|
221
|
+
assert.equal(g.step.skip, null);
|
|
222
|
+
assert.equal(g.step.driver, 'pair');
|
|
223
|
+
assert.deepEqual(g.step.skills.bound, ['yad-epic']);
|
|
224
|
+
assert.ok(g.step.skills.recommended.some((r) => r.skill === 'bmad-prd' && r.bind.startsWith('yad skill bind epic') && r.decidedBy === 'human'));
|
|
225
|
+
assert.deepEqual(g.agent.map((a) => a.skill ?? a.run), ['yad next EP-pay --check epic', 'yad-epic']);
|
|
226
|
+
assert.equal(g.agent[0].class, 'read');
|
|
227
|
+
assert.equal(g.person[0].act, 'answer');
|
|
228
|
+
assert.equal(g.person[0].verify, null);
|
|
229
|
+
assert.doesNotMatch(g.then, /verify/, 'no verify command to name');
|
|
230
|
+
assert.deepEqual(g.rules, RULES);
|
|
231
|
+
// An epic that records another driver is told as it records it.
|
|
232
|
+
const st = readState(T, 'EP-pay');
|
|
233
|
+
st.steps.find((s) => s.id === 'epic').driver = 'human';
|
|
234
|
+
put(statePath(T, 'EP-pay'), st);
|
|
235
|
+
assert.equal(buildGuide(T, { epic: 'EP-pay' }).step.driver, 'human');
|
|
236
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
test('an optional step on the epic\'s route can be skipped, and the skip is the person\'s decision', async () => {
|
|
240
|
+
const T = await product();
|
|
241
|
+
try {
|
|
242
|
+
moveTo(T, 'EP-pay', 'ui-design');
|
|
243
|
+
const g = buildGuide(T, { epic: 'EP-pay' });
|
|
244
|
+
assert.equal(g.step.id, 'ui-design');
|
|
245
|
+
assert.equal(g.step.mandatory, false);
|
|
246
|
+
assert.equal(g.step.skip.command, 'yad skip EP-pay ui-design --reason "<why>"');
|
|
247
|
+
assert.equal(g.step.skip.decidedBy, 'human');
|
|
248
|
+
// A verified Product with no origin to read: offered, with the same caution `yad skip` prints.
|
|
249
|
+
assert.match(g.step.skip.note, /origin could not be read/);
|
|
250
|
+
// At its review the step is already written: `yad skip` would refuse, so no skip is offered.
|
|
251
|
+
moveTo(T, 'EP-pay', 'ui-design-review', 'todo');
|
|
252
|
+
const atGate = buildGuide(T, { epic: 'EP-pay' }).step;
|
|
253
|
+
assert.equal(atGate.id, 'ui-design-review');
|
|
254
|
+
assert.equal(atGate.skip, null);
|
|
255
|
+
moveTo(T, 'EP-pay', 'architecture');
|
|
256
|
+
assert.equal(buildGuide(T, { epic: 'EP-pay' }).step.mandatory, true);
|
|
257
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
test('a review gate on a verified Product: the agent opens it once, and the person approves and merges', async () => {
|
|
261
|
+
const T = await product();
|
|
262
|
+
try {
|
|
263
|
+
moveTo(T, 'EP-pay', 'epic-review', 'todo');
|
|
264
|
+
// On a verified Product the PR/MR is recorded only at the merge, so the review stays `review-open`
|
|
265
|
+
// while it is open: the person's hand-off is given with it.
|
|
266
|
+
const g = buildGuide(T, { epic: 'EP-pay' });
|
|
267
|
+
assert.equal(g.situation.ledger, 'verified');
|
|
268
|
+
assert.equal(g.step.actionKind, 'review-open');
|
|
269
|
+
assert.equal(g.step.name, 'Epic review');
|
|
270
|
+
assert.equal(g.step.driver, 'human');
|
|
271
|
+
assert.equal(g.step.advance, 'human');
|
|
272
|
+
assert.deepEqual(g.agent.map((a) => [a.run, a.class, a.ask]), [['yad gate open EP-pay epic.md', 'open-pr', 'never']]);
|
|
273
|
+
assert.match(g.agent[0].why, /do not open another/);
|
|
274
|
+
assert.equal(g.person[0].act, 'approve-merge');
|
|
275
|
+
assert.match(g.person[0].steps[0], /^Once the agent has opened it, open the review pull request for epic\.md on GitHub/);
|
|
276
|
+
assert.ok(g.person[0].steps.some((x) => /CI writes the approval into the ledger at the merge/.test(x)));
|
|
277
|
+
assert.equal(g.person[0].verify, 'yad gate sync EP-pay epic.md');
|
|
278
|
+
assert.match(g.then, /never go on from their word alone/);
|
|
279
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test('a review gate with a platform and a local ledger: once the PR/MR is recorded, the person approves and merges', async () => {
|
|
283
|
+
const T = await product({ verified: false });
|
|
284
|
+
try {
|
|
285
|
+
moveTo(T, 'EP-pay', 'epic-review', 'in_review');
|
|
286
|
+
put(path.join(T, 'epics/EP-pay/.sdlc/product-prs.json'), [{ artifact: 'epic.md', number: 7, url: 'https://github.com/acme/product/pull/7' }]);
|
|
287
|
+
const g = buildGuide(T, { epic: 'EP-pay' });
|
|
288
|
+
assert.equal(g.situation.ledger, 'local');
|
|
289
|
+
assert.equal(g.step.actionKind, 'review-sync');
|
|
290
|
+
assert.deepEqual(g.agent.map((a) => [a.run, a.class]), [['yad gate sync EP-pay epic.md', 'open-pr']]);
|
|
291
|
+
assert.match(g.person[0].steps[0], /^Open the review pull request #7 for epic\.md on GitHub/);
|
|
292
|
+
assert.deepEqual(g.person[0].commands, []);
|
|
293
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
test('a review gate with no platform: the agent marks it open, then the person approves and advances as themselves', async () => {
|
|
297
|
+
const T = await product({ platform: null });
|
|
298
|
+
try {
|
|
299
|
+
moveTo(T, 'EP-pay', 'epic-review', 'todo');
|
|
300
|
+
put(path.join(T, 'epics/EP-pay/epic.md'), '---\nid: EP-pay\nstatus: draft\n---\n# Pay\n');
|
|
301
|
+
let g = buildGuide(T, { epic: 'EP-pay' });
|
|
302
|
+
assert.equal(g.situation.platform, null);
|
|
303
|
+
assert.deepEqual(g.agent.map((a) => a.run), ['yad gate open EP-pay epic.md']);
|
|
304
|
+
assert.deepEqual(g.person[0].commands, ['yad gate approve EP-pay epic.md --by "<your name>"', 'yad gate advance EP-pay epic.md']);
|
|
305
|
+
// The real `yad gate open`, with no platform, marks the review open here; the agent has nothing left to run.
|
|
306
|
+
await gateOpen(T, { epic: 'EP-pay', artifact: 'epic.md', today: '2026-10-27' });
|
|
307
|
+
g = buildGuide(T, { epic: 'EP-pay' });
|
|
308
|
+
assert.equal(g.step.status, 'in_review');
|
|
309
|
+
assert.deepEqual(g.agent, []);
|
|
310
|
+
assert.deepEqual(g.person[0].commands, ['yad gate approve EP-pay epic.md --by "<your name>"', 'yad gate advance EP-pay epic.md']);
|
|
311
|
+
for (const cmd of g.person[0].commands) assert.equal(classify(cmd.split(' ').slice(1, 3)), 'human-only');
|
|
312
|
+
assert.equal(g.person[0].verify, 'yad guide EP-pay --json');
|
|
313
|
+
// Solo: nothing to approve, only the advance.
|
|
314
|
+
const settings = path.join(T, '.sdlc/product.json');
|
|
315
|
+
put(settings, { ...JSON.parse(fs.readFileSync(settings, 'utf8')), solo: true });
|
|
316
|
+
assert.deepEqual(buildGuide(T, { epic: 'EP-pay' }).person[0].commands, ['yad gate advance EP-pay epic.md']);
|
|
317
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
test('a word from the ledger that is not a plain path never reaches a command line', async () => {
|
|
321
|
+
const T = await product({ platform: null });
|
|
322
|
+
try {
|
|
323
|
+
moveTo(T, 'EP-pay', 'epic-review', 'todo');
|
|
324
|
+
const st = readState(T, 'EP-pay');
|
|
325
|
+
st.steps.find((s) => s.id === 'epic-review').artifact = 'epic.md; rm -rf ~';
|
|
326
|
+
put(statePath(T, 'EP-pay'), st);
|
|
327
|
+
const g = buildGuide(T, { epic: 'EP-pay' });
|
|
328
|
+
const lines = [...g.agent.map((a) => a.run ?? ''), ...g.person.flatMap((p) => p.commands)];
|
|
329
|
+
assert.ok(lines.length > 0);
|
|
330
|
+
for (const l of lines) assert.doesNotMatch(l, /rm -rf/, l);
|
|
331
|
+
assert.ok(lines.some((l) => l.includes('<artifact>')));
|
|
332
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
test('a blocked step: the agent clears it only when the person asks; on a verified Product it cannot', () => {
|
|
336
|
+
const p = playbook({ epicId: 'EP-pay', kind: 'blocked', step: 'architecture', record: { reason: 'waiting on\u001b[31m legal' } }, {});
|
|
337
|
+
assert.equal(p.agent[0].run, 'yad unblock EP-pay architecture');
|
|
338
|
+
assert.equal(p.agent[0].ask, 'only-when-asked');
|
|
339
|
+
const v = playbook({ epicId: 'EP-pay', kind: 'blocked', step: 'architecture', record: null }, { verified: true, platform: 'github', ciOwns: true });
|
|
340
|
+
assert.deepEqual(v.agent, []);
|
|
341
|
+
assert.match(v.person[0].steps[1], /yad unblock` refuses/);
|
|
342
|
+
assert.equal(p.person[0].steps[0], 'Resolve the blocker: waiting on [31m legal, then tell the agent to clear it.', 'a control character from the ledger is cleaned');
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
test('the agent never picks an epic: several open epics are listed, one is chosen by name, an unknown name is said', async () => {
|
|
346
|
+
const T = await product({ epics: ['pay', 'ship'] });
|
|
347
|
+
try {
|
|
348
|
+
const g = buildGuide(T);
|
|
349
|
+
assert.equal(g.situation.stage, 'choose-epic');
|
|
350
|
+
assert.deepEqual(g.epics.map((e) => e.epic).sort(), ['EP-pay', 'EP-ship']);
|
|
351
|
+
assert.equal(g.step, null);
|
|
352
|
+
assert.equal(g.person[0].act, 'choose');
|
|
353
|
+
assert.equal(buildGuide(T, { epic: 'EP-ship' }).step.epic, 'EP-ship');
|
|
354
|
+
const bad = buildGuide(T, { epic: 'EP-none' });
|
|
355
|
+
assert.equal(bad.ok, false, 'a refusal, so an agent that checks ok does not read success');
|
|
356
|
+
assert.equal(bad.situation.stage, 'unknown-epic');
|
|
357
|
+
assert.match(bad.error, /no epic EP-none/);
|
|
358
|
+
assert.deepEqual(bad.epics.map((e) => e.epic).sort(), ['EP-pay', 'EP-ship']);
|
|
359
|
+
assert.equal(bad.step, null);
|
|
360
|
+
const cli = spawnSync(process.execPath, [YAD, 'guide', 'EP-none', '--json', '--dir', T], { encoding: 'utf8' });
|
|
361
|
+
assert.equal(cli.status, 1);
|
|
362
|
+
const out = JSON.parse(cli.stdout);
|
|
363
|
+
assert.equal(out.ok, false);
|
|
364
|
+
assert.match(out.error, /no epic EP-none/);
|
|
365
|
+
assert.ok('code' in out && 'hint' in out);
|
|
366
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
367
|
+
// One open epic is the one.
|
|
368
|
+
const one = await product();
|
|
369
|
+
try { assert.equal(buildGuide(one).step.epic, 'EP-pay'); } finally { fs.rmSync(one, { recursive: true, force: true }); }
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
test('a Product with no epic yet: the first epic, and the Foundation offered as optional', async () => {
|
|
373
|
+
const T = await product({ epics: [] });
|
|
374
|
+
try {
|
|
375
|
+
const g = buildGuide(T);
|
|
376
|
+
assert.equal(g.situation.stage, 'ready');
|
|
377
|
+
assert.deepEqual(g.agent.map((a) => a.skill ?? a.run), ['yad foundation new', 'yad-epic']);
|
|
378
|
+
assert.equal(g.agent[0].optional, true);
|
|
379
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
test('Build: the step is the Build loop, with its brief', async () => {
|
|
383
|
+
const T = await product();
|
|
384
|
+
try {
|
|
385
|
+
const st = readState(T, 'EP-pay');
|
|
386
|
+
for (const s of st.steps) s.status = 'done';
|
|
387
|
+
st.currentStep = 'ready-for-build';
|
|
388
|
+
put(statePath(T, 'EP-pay'), st);
|
|
389
|
+
const g = buildGuide(T, { epic: 'EP-pay' });
|
|
390
|
+
assert.equal(g.step.actionKind, 'build');
|
|
391
|
+
assert.equal(g.step.name, 'Build');
|
|
392
|
+
assert.equal(g.step.brief, DEFAULT_LIFECYCLE.phases.find((p) => p.id === 'build').description);
|
|
393
|
+
assert.equal(g.agent[0].skill, 'yad-run');
|
|
394
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
test('a ledger that does not load: the answer is yad doctor, never another epic', async () => {
|
|
398
|
+
const T = await product();
|
|
399
|
+
try {
|
|
400
|
+
put(statePath(T, 'EP-pay'), '{ not json');
|
|
401
|
+
const g = buildGuide(T);
|
|
402
|
+
assert.equal(g.situation.stage, 'broken');
|
|
403
|
+
assert.deepEqual(g.problems.map((p) => p.epic), ['EP-pay']);
|
|
404
|
+
assert.deepEqual(g.agent.map((a) => a.run), ['yad doctor']);
|
|
405
|
+
assert.ok(!g.agent.some((a) => a.skill === 'yad-epic'));
|
|
406
|
+
const named = buildGuide(T, { epic: 'EP-pay' });
|
|
407
|
+
assert.equal(named.situation.stage, 'broken');
|
|
408
|
+
put(statePath(T, 'EP-pay'), 'null');
|
|
409
|
+
assert.equal(buildGuide(T, { epic: 'EP-pay' }).situation.stage, 'broken');
|
|
410
|
+
put(statePath(T, 'EP-pay'), { epicId: 'EP-pay', steps: 'nope' });
|
|
411
|
+
assert.equal(buildGuide(T, { epic: 'EP-pay' }).situation.stage, 'broken');
|
|
412
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
test('the Foundation is the Product level: neither mandatory nor skippable', async () => {
|
|
416
|
+
const T = await product({ epics: [] });
|
|
417
|
+
try {
|
|
418
|
+
const { runFoundationNew } = await import('./epic.mjs');
|
|
419
|
+
await runFoundationNew(T, { today: '2026-10-27' });
|
|
420
|
+
const g = buildGuide(T);
|
|
421
|
+
assert.equal(g.step.id, 'foundation');
|
|
422
|
+
assert.equal(g.step.mandatory, null);
|
|
423
|
+
assert.equal(g.step.skip, null);
|
|
424
|
+
assert.equal(g.step.brief, stepFacts('foundation').description);
|
|
425
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
test('a Product one folder away is named, so the agent never starts a second one', () => {
|
|
429
|
+
const g = buildGuide(null, { productElsewhere: '../product' });
|
|
430
|
+
assert.equal(g.situation.stage, 'product-elsewhere');
|
|
431
|
+
assert.equal(g.situation.product, '../product');
|
|
432
|
+
assert.deepEqual(g.agent.map((a) => a.run), ['yad guide --dir ../product --json']);
|
|
433
|
+
assert.ok(!JSON.stringify(g).includes('yadflow@4 new'));
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
test('a Build step yad-run halted waits for the person, with the reason the build-state records', async () => {
|
|
437
|
+
const T = await product();
|
|
438
|
+
try {
|
|
439
|
+
const st = readState(T, 'EP-pay');
|
|
440
|
+
for (const s of st.steps) s.status = 'done';
|
|
441
|
+
st.currentStep = 'ready-for-build';
|
|
442
|
+
put(statePath(T, 'EP-pay'), st);
|
|
443
|
+
put(path.join(T, 'epics/EP-pay/.sdlc/build-state/EP-pay-S01.json'), { story: 'EP-pay-S01', repos: {
|
|
444
|
+
api: { currentStep: 'implement', steps: [{ id: 'spec', status: 'done' }, { id: 'tasks', status: 'done' }, { id: 'implement', status: 'blocked', record: { reason: 'contract touch' } }, { id: 'checks', status: 'todo' }] },
|
|
445
|
+
web: { currentStep: 'spec', steps: [{ id: 'spec', status: 'in_progress' }] },
|
|
446
|
+
} });
|
|
447
|
+
const g = buildGuide(T, { epic: 'EP-pay' });
|
|
448
|
+
const halts = g.person.filter((x) => x.act === 'unblock');
|
|
449
|
+
assert.equal(halts.length, 1);
|
|
450
|
+
assert.equal(halts[0].steps[0], 'Resolve the halt on EP-pay-S01 in api (implement): contract touch, then tell the agent to move it on.');
|
|
451
|
+
assert.ok(RULES.some((r) => r.id === 'build-halts'));
|
|
452
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
test('a flag that needs the person to have asked is kept under a push', () => {
|
|
456
|
+
const { reaches } = COMMAND_CLASS_MODULE;
|
|
457
|
+
assert.deepEqual(reaches(['update'], ['push', 'overwrite-local']).sort(), ['default-push', 'local-write', 'on-request']);
|
|
458
|
+
const p = playbook({ epicId: 'EP-pay', kind: 'unknown-kind' }, {});
|
|
459
|
+
assert.equal(p.agent[0].onRequest, undefined);
|
|
460
|
+
const both = agentRun('yad update --push --overwrite-local', 'x');
|
|
461
|
+
assert.deepEqual([both.class, both.ask, both.onRequest], ['default-push', 'each-time', true]);
|
|
462
|
+
assert.equal(agentRun('yad update --push', 'x').onRequest, undefined);
|
|
463
|
+
assert.deepEqual(reaches(['gate', 'ci'], ['merged']), ['ci-only'], 'never raised, as in classify');
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
test('the test-cases track beside Build is given to the agent too', () => {
|
|
467
|
+
const p = playbook({ epicId: 'EP-pay', kind: 'build', step: 'ready-for-build', parallel: { step: 'test-cases', skill: 'yad-test-cases', artifact: 'test-cases.md' } }, {});
|
|
468
|
+
assert.deepEqual(p.agent.map((a) => [a.skill, a.class, a.ask]), [['yad-run', 'task-pr', 'per-dial'], ['yad-test-cases', 'local-write', 'never']]);
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
test('a review re-opened behind finished work: the agent opens it once, and the person approves it too (no platform)', async () => {
|
|
472
|
+
const T = await product({ platform: null });
|
|
473
|
+
try {
|
|
474
|
+
const st = readState(T, 'EP-pay');
|
|
475
|
+
const idx = (id) => st.steps.findIndex((s) => s.id === id);
|
|
476
|
+
st.steps.forEach((s, i) => { if (i < idx('stories-review')) s.status = 'done'; });
|
|
477
|
+
st.steps[idx('ui-design-review')].status = 'todo';
|
|
478
|
+
st.steps[idx('stories-review')].status = 'in_review';
|
|
479
|
+
st.currentStep = 'stories-review';
|
|
480
|
+
put(statePath(T, 'EP-pay'), st);
|
|
481
|
+
let g = buildGuide(T, { epic: 'EP-pay' });
|
|
482
|
+
assert.deepEqual(g.agent.map((a) => a.run), ['yad gate open EP-pay ui-design.md']);
|
|
483
|
+
const approves = (gg) => gg.person.flatMap((p) => p.commands).filter((c) => c.startsWith('yad gate approve'));
|
|
484
|
+
assert.deepEqual(approves(g), ['yad gate approve EP-pay stories/ --by "<your name>"', 'yad gate approve EP-pay ui-design.md --by "<your name>"']);
|
|
485
|
+
// Once marked open, nothing is left for the agent; the person still approves and advances it.
|
|
486
|
+
st.steps[idx('ui-design-review')].status = 'in_review';
|
|
487
|
+
put(statePath(T, 'EP-pay'), st);
|
|
488
|
+
g = buildGuide(T, { epic: 'EP-pay' });
|
|
489
|
+
assert.deepEqual(g.agent, []);
|
|
490
|
+
assert.ok(g.person.flatMap((p) => p.commands).includes('yad gate advance EP-pay ui-design.md'));
|
|
491
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
test('on a verified Product whose ledger CI owns, a skip is said to be refused, not offered', async () => {
|
|
495
|
+
const T = await product();
|
|
496
|
+
const R = tmp();
|
|
497
|
+
try {
|
|
498
|
+
git(R, ['init', '-q', '--bare', '-b', 'main']);
|
|
499
|
+
git(T, ['remote', 'add', 'origin', R]);
|
|
500
|
+
git(T, ['add', '-A']);
|
|
501
|
+
git(T, ['commit', '-q', '-m', 'docs(ep-pay): seed']);
|
|
502
|
+
git(T, ['push', '-q', '-u', 'origin', 'main']);
|
|
503
|
+
moveTo(T, 'EP-pay', 'ui-design');
|
|
504
|
+
const g = buildGuide(T, { epic: 'EP-pay' });
|
|
505
|
+
assert.equal(g.step.mandatory, false);
|
|
506
|
+
assert.equal(g.step.skip.command, null);
|
|
507
|
+
assert.match(g.step.skip.note, /only CI writes it/);
|
|
508
|
+
const said = spawnSync(process.execPath, [YAD, 'guide', 'EP-pay', '--dir', T], { encoding: 'utf8', env: { ...process.env, NO_COLOR: '1' } });
|
|
509
|
+
const text = `${said.stdout}${said.stderr}`;
|
|
510
|
+
assert.match(text, /optional, but it cannot be skipped here: on this verified Product/);
|
|
511
|
+
assert.doesNotMatch(text, /null/);
|
|
512
|
+
// A blocked step there is not the agent's to clear either.
|
|
513
|
+
const st = readState(T, 'EP-pay');
|
|
514
|
+
st.steps.find((s) => s.id === 'ui-design').status = 'blocked';
|
|
515
|
+
st.steps.find((s) => s.id === 'ui-design').record = { reason: 'legal', by: 'alice', date: '2026-10-27' };
|
|
516
|
+
put(statePath(T, 'EP-pay'), st);
|
|
517
|
+
assert.deepEqual(buildGuide(T, { epic: 'EP-pay' }).agent, []);
|
|
518
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); fs.rmSync(R, { recursive: true, force: true }); }
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
test('the review branch is named as yad gate open names it', () => {
|
|
522
|
+
for (const [art, branch] of [['stories/EP-pay-S01.md', 'review/EP-pay/stories-S01'], ['stories/', 'review/EP-pay/stories'], ['epic.md', 'review/EP-pay/epic']]) {
|
|
523
|
+
const p = playbook({ epicId: 'EP-pay', kind: 'review-open', step: 'x-review', status: 'todo', artifact: art }, { platform: 'github' });
|
|
524
|
+
assert.ok(p.agent[0].why.includes(`\`${branch}\``), `${art}: ${p.agent[0].why}`);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
test('on a verified Product whose epic is not on origin as fetched, the skip is offered with yad skip\'s fetch caution', async () => {
|
|
529
|
+
const T = await product();
|
|
530
|
+
const R = tmp();
|
|
531
|
+
try {
|
|
532
|
+
git(R, ['init', '-q', '--bare', '-b', 'main']);
|
|
533
|
+
git(T, ['remote', 'add', 'origin', R]);
|
|
534
|
+
git(T, ['push', '-q', '-u', 'origin', 'main']);
|
|
535
|
+
moveTo(T, 'EP-pay', 'ui-design');
|
|
536
|
+
const g = buildGuide(T, { epic: 'EP-pay' });
|
|
537
|
+
assert.equal(g.step.skip.command, 'yad skip EP-pay ui-design --reason "<why>"');
|
|
538
|
+
assert.match(g.step.skip.note, /origin as last fetched: run `git fetch origin` first/);
|
|
539
|
+
const said = spawnSync(process.execPath, [YAD, 'guide', 'EP-pay', '--dir', T], { encoding: 'utf8', env: { ...process.env, NO_COLOR: '1' } });
|
|
540
|
+
assert.match(`${said.stdout}${said.stderr}`, /can be skipped — the person decides: yad skip EP-pay ui-design --reason "<why>" \(checked against origin as last fetched/);
|
|
541
|
+
// An unblock there carries the same caution; with no origin at all, the unreadable one.
|
|
542
|
+
const st = readState(T, 'EP-pay');
|
|
543
|
+
Object.assign(st.steps.find((s) => s.id === 'ui-design'), { status: 'blocked', record: { reason: 'legal', by: 'alice', date: '2026-10-27' } });
|
|
544
|
+
put(statePath(T, 'EP-pay'), st);
|
|
545
|
+
assert.match(buildGuide(T, { epic: 'EP-pay' }).agent[0].why, /origin as last fetched/);
|
|
546
|
+
git(T, ['remote', 'remove', 'origin']);
|
|
547
|
+
assert.match(buildGuide(T, { epic: 'EP-pay' }).agent[0].why, /origin could not be read/);
|
|
548
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); fs.rmSync(R, { recursive: true, force: true }); }
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
test('a ledger word goes into a command only as a plain path or id', () => {
|
|
552
|
+
assert.equal(tok('payment_service', '<repo>'), 'payment_service');
|
|
553
|
+
assert.equal(tok('stories/', '<a>'), 'stories/');
|
|
554
|
+
assert.equal(tok('foundation/', '<a>'), 'foundation/');
|
|
555
|
+
for (const bad of ['a b', 'x;y', '../up', '-rf', '', null, '$(id)']) assert.equal(tok(bad, '<a>'), '<a>', String(bad));
|
|
556
|
+
const g = buildGuide(null, { productElsewhere: '../my product' });
|
|
557
|
+
assert.equal(g.agent[0].run, "yad guide --dir '../my product' --json");
|
|
558
|
+
assert.equal(buildGuide(null, { productElsewhere: "../it's!" }).agent[0].run, "yad guide --dir '../it'\\''s!' --json");
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
test('a blocked step re-opened behind finished work: the person resolves it, the agent clears it on request (not where CI owns the ledger)', () => {
|
|
562
|
+
const a = { epicId: 'EP-pay', kind: 'review-open', step: 'stories-review', status: 'in_review', artifact: 'stories/',
|
|
563
|
+
reopened: [{ step: 'ui-design', kind: 'blocked', status: 'blocked', record: { reason: 'waiting on design' } }] };
|
|
564
|
+
const p = playbook(a, { platform: null });
|
|
565
|
+
assert.ok(p.agent.some((x) => x.run === 'yad unblock EP-pay ui-design' && x.ask === 'only-when-asked'));
|
|
566
|
+
assert.ok(p.person.some((x) => x.act === 'unblock' && /ui-design was re-opened behind finished work, and is blocked/.test(x.why) && /waiting on design/.test(x.steps[0])));
|
|
567
|
+
const v = playbook(a, { platform: 'github', verified: true, ciOwns: true });
|
|
568
|
+
assert.ok(!v.agent.some((x) => (x.run ?? '').startsWith('yad unblock')));
|
|
569
|
+
assert.ok(v.person.some((x) => x.act === 'unblock' && x.steps.some((st) => /yad unblock` refuses/.test(st))));
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
test('an install behind yadflow: the guide says so, from what is committed, and hands the rest to the run', async () => {
|
|
573
|
+
const { installState } = await import('./guide.mjs');
|
|
574
|
+
const T = await product();
|
|
575
|
+
try {
|
|
576
|
+
const stamp = path.join(T, '.sdlc/cli-version.json');
|
|
577
|
+
const commitStamp = (v) => { put(stamp, { version: v }); git(T, ['add', '-A']); git(T, ['commit', '-q', '-m', `chore: stamp ${v}`]); };
|
|
578
|
+
commitStamp('4.0.0');
|
|
579
|
+
assert.equal(installState(T, '4.7.0').behind, true);
|
|
580
|
+
assert.equal(installState(T, '4.0.0').behind, false);
|
|
581
|
+
assert.equal(installState(T, '3.9.9').behind, false, 'an older yadflow here is not upkeep');
|
|
582
|
+
// Pre-releases compare label by label: an older build is never told to update.
|
|
583
|
+
commitStamp('4.8.0-next.3');
|
|
584
|
+
assert.equal(installState(T, '4.8.0-next.1').behind, false);
|
|
585
|
+
assert.equal(installState(T, '4.8.0-next.4').behind, true);
|
|
586
|
+
commitStamp('4.8.0-next.9');
|
|
587
|
+
assert.equal(installState(T, '4.8.0-next.10').behind, true);
|
|
588
|
+
// Read as committed: an update left uncommitted in the working tree still counts as behind.
|
|
589
|
+
commitStamp('4.0.0');
|
|
590
|
+
put(stamp, { version: '4.7.0' });
|
|
591
|
+
assert.equal(installState(T, '4.7.0').behind, true);
|
|
592
|
+
// The guide hands the update to the run, and the run's answer to the person.
|
|
593
|
+
const g = buildGuide(T, { epic: 'EP-pay' });
|
|
594
|
+
assert.deepEqual(g.situation.install.repos, [{ repo: 'product', version: '4.0.0', behind: true }]);
|
|
595
|
+
assert.deepEqual(g.upkeep.agent.map((a) => [a.run, a.class, a.ask]), [['yad update --open-pr --json', 'open-pr', 'never']]);
|
|
596
|
+
assert.match(g.upkeep.agent[0].why, /every `commits\[\]` row that has a `hint`, with its `reason`/);
|
|
597
|
+
assert.ok(RULES.some((r) => r.id === 'update'));
|
|
598
|
+
// No platform: the person publishes it their way.
|
|
599
|
+
const settings = path.join(T, '.sdlc/product.json');
|
|
600
|
+
put(settings, { ...JSON.parse(fs.readFileSync(settings, 'utf8')), platform: null });
|
|
601
|
+
const local = buildGuide(T, { epic: 'EP-pay' });
|
|
602
|
+
assert.deepEqual(local.upkeep.agent, []);
|
|
603
|
+
assert.deepEqual(local.upkeep.person[0].commands, ['yad update']);
|
|
604
|
+
// Current: no upkeep.
|
|
605
|
+
const { VERSION } = await import('./manifest.mjs');
|
|
606
|
+
commitStamp(VERSION);
|
|
607
|
+
assert.equal(buildGuide(T, { epic: 'EP-pay' }).upkeep, null);
|
|
608
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
// Two clones of one Product with an origin, for the run's own reading of what origin holds.
|
|
612
|
+
async function twoClones() {
|
|
613
|
+
const P = tmp();
|
|
614
|
+
const R = path.join(P, 'origin.git');
|
|
615
|
+
const A = path.join(P, 'a');
|
|
616
|
+
const B = path.join(P, 'b');
|
|
617
|
+
git(P, ['init', '-q', '--bare', '-b', 'main', R]);
|
|
618
|
+
fs.mkdirSync(A);
|
|
619
|
+
git(A, ['init', '-q', '-b', 'main']);
|
|
620
|
+
const noGlobalIgnore = (d) => git(d, ['config', 'core.excludesFile', NO_GLOBAL_IGNORE]);
|
|
621
|
+
for (const d of [A]) { git(d, ['config', 'user.name', 'Alice Smith']); git(d, ['config', 'user.email', 'alice@work.com']); git(d, ['config', 'commit.gpgsign', 'false']); noGlobalIgnore(d); }
|
|
622
|
+
put(path.join(A, '.sdlc/product.json'), { platform: 'github', git_url: 'git@github.com:acme/product.git', default_branch: 'main' });
|
|
623
|
+
put(path.join(A, '.sdlc/cli-version.json'), { version: '4.0.0' });
|
|
624
|
+
git(A, ['add', '-A']); git(A, ['commit', '-q', '-m', 'chore: start']);
|
|
625
|
+
git(A, ['remote', 'add', 'origin', R]); git(A, ['push', '-q', '-u', 'origin', 'main']);
|
|
626
|
+
git(P, ['clone', '-q', '-b', 'main', R, B]);
|
|
627
|
+
for (const d of [B]) { git(d, ['config', 'user.name', 'Bo Lee']); git(d, ['config', 'user.email', 'bo@work.com']); git(d, ['config', 'commit.gpgsign', 'false']); noGlobalIgnore(d); }
|
|
628
|
+
return { P, R, A, B };
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
test('the run reads origin first: an update opened from another clone is held, and one already merged is "pull it", never a second PR/MR', async () => {
|
|
632
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
633
|
+
const { VERSION } = await import('./manifest.mjs');
|
|
634
|
+
const { P, A, B } = await twoClones();
|
|
635
|
+
try {
|
|
636
|
+
// Clone A opens the update.
|
|
637
|
+
const calls = [];
|
|
638
|
+
const creator = (platform, opts) => { calls.push(opts.head); return { ok: true, url: 'https://github.com/acme/product/pull/1' }; };
|
|
639
|
+
await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
|
|
640
|
+
assert.equal(calls.length, 1);
|
|
641
|
+
// Clone B, never fetched since: held as on review, nothing written, no PR.
|
|
642
|
+
const rb = await reconcile(B, { fix: true, scope: 'changed', openPr: true, creator });
|
|
643
|
+
assert.deepEqual(rb.commits.map((c) => [c.reason, c.error]), [['open', false]]);
|
|
644
|
+
assert.match(rb.commits[0].hint, /a person merges its PR\/MR, then run this again/);
|
|
645
|
+
assert.equal(git(B, ['status', '--porcelain']), '');
|
|
646
|
+
assert.equal(calls.length, 1, 'no second PR/MR');
|
|
647
|
+
// The PR merges on origin, and its branch is deleted there.
|
|
648
|
+
git(A, ['push', '-q', 'origin', `chore/yad-update-v${VERSION}:main`]);
|
|
649
|
+
// Deleted on origin only, as the web page's button does: clone B still has its copy of the branch.
|
|
650
|
+
git(A, ['push', '-q', 'origin', '--delete', `chore/yad-update-v${VERSION}`]);
|
|
651
|
+
assert.ok(git(B, ['branch', '-r']).includes(`origin/chore/yad-update-v${VERSION}`));
|
|
652
|
+
// Clone B, stale again: the run fetches, drops its copy of the deleted branch, sees the update merged,
|
|
653
|
+
// and says to pull.
|
|
654
|
+
const rm = await reconcile(B, { fix: true, scope: 'changed', openPr: true, creator });
|
|
655
|
+
assert.deepEqual(rm.commits.map((c) => c.reason), ['merged']);
|
|
656
|
+
assert.ok(!git(B, ['branch', '-r']).includes(`origin/chore/yad-update-v${VERSION}`), 'the copy of a branch origin lost is dropped');
|
|
657
|
+
assert.match(rm.commits[0].hint, /pull --ff-only origin main/);
|
|
658
|
+
assert.equal(git(B, ['status', '--porcelain']), '');
|
|
659
|
+
assert.equal(calls.length, 1, 'never a second PR/MR for a merged update');
|
|
660
|
+
} finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
test('the run after a pull is not held as merged; a person\'s own file in a skill folder never rides the update', async () => {
|
|
664
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
665
|
+
const { VERSION } = await import('./manifest.mjs');
|
|
666
|
+
const { P, R, A, B } = await twoClones();
|
|
667
|
+
try {
|
|
668
|
+
const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/3' });
|
|
669
|
+
// Install everything, commit it, and make the stamp old again: the next update has folders already right.
|
|
670
|
+
await reconcile(A, { fix: true, scope: 'all' });
|
|
671
|
+
put(path.join(A, '.sdlc/cli-version.json'), { version: '4.0.0' });
|
|
672
|
+
git(A, ['add', '-A']); git(A, ['commit', '-q', '-m', 'chore: install']); git(A, ['push', '-q']);
|
|
673
|
+
const skills = fs.readdirSync(path.join(A, '.claude/skills')).filter((d) => d.startsWith('yad-'));
|
|
674
|
+
const [skill, old] = skills;
|
|
675
|
+
put(path.join(A, '.claude/skills', skill, 'my-notes.md'), 'private\n');
|
|
676
|
+
// A second folder the update rewrites (outdated), holding a person's committed file and an untracked one.
|
|
677
|
+
fs.appendFileSync(path.join(A, '.claude/skills', old, 'SKILL.md'), '\nan older line\n');
|
|
678
|
+
put(path.join(A, '.claude/skills', old, 'team-notes.md'), 'ours\n');
|
|
679
|
+
git(A, ['add', '-A', `.claude/skills/${old}`]); git(A, ['commit', '-q', '-m', 'docs: team notes']); git(A, ['push', '-q']);
|
|
680
|
+
put(path.join(A, '.claude/skills', old, 'scratch.md'), 'mine\n');
|
|
681
|
+
const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
|
|
682
|
+
assert.equal(r.commits[0].opened, true);
|
|
683
|
+
const files = git(R, ['diff', '--name-only', 'main', `chore/yad-update-v${VERSION}`]).split('\n');
|
|
684
|
+
assert.ok(files.includes('.sdlc/cli-version.json'), files.join(', '));
|
|
685
|
+
assert.ok(files.includes(`.claude/skills/${old}/SKILL.md`), `the outdated folder is updated: ${files.join(', ')}`);
|
|
686
|
+
assert.ok(!files.some((f) => /(my|team)-notes\.md$|scratch\.md$/.test(f)), `never the person's own file: ${files.join(', ')}`);
|
|
687
|
+
for (const f of [`${skill}/my-notes.md`, `${old}/team-notes.md`, `${old}/scratch.md`]) {
|
|
688
|
+
assert.ok(fs.existsSync(path.join(A, '.claude/skills', f)), `${f} is left where it was`);
|
|
689
|
+
}
|
|
690
|
+
// The PR merges; clone B pulls it. The next run there is not "merged — pull it": it was pulled.
|
|
691
|
+
git(A, ['push', '-q', 'origin', `chore/yad-update-v${VERSION}:main`]);
|
|
692
|
+
git(B, ['pull', '-q', '--ff-only', 'origin', 'main']);
|
|
693
|
+
const again = await reconcile(B, { fix: true, scope: 'changed', openPr: true, creator });
|
|
694
|
+
assert.ok(!again.commits.some((c) => c.reason === 'merged'), JSON.stringify(again.commits));
|
|
695
|
+
// Clone A pulls too. Its own update branch, left behind, is not "on review": a same-version repair runs.
|
|
696
|
+
git(A, ['pull', '-q', '--ff-only', 'origin', 'main']);
|
|
697
|
+
// A managed file deleted on the default branch: the repair puts it back.
|
|
698
|
+
git(A, ['rm', '-q', `.claude/skills/${skill}/SKILL.md`]); git(A, ['commit', '-q', '-m', 'chore: lose a file']); git(A, ['push', '-q']);
|
|
699
|
+
const blocked = await reconcile(A, { fix: true, scope: 'all', openPr: true, creator });
|
|
700
|
+
assert.ok(!blocked.commits.some((c) => c.reason === 'open'), JSON.stringify(blocked.commits));
|
|
701
|
+
// The local branch held only the update's own commit, so it is gone; origin still has the branch: said.
|
|
702
|
+
assert.equal(git(A, ['branch', '--list', `chore/yad-update-v${VERSION}`]), '', JSON.stringify(blocked.commits));
|
|
703
|
+
assert.deepEqual(blocked.commits.map((c) => c.reason), ['leftover-branch']);
|
|
704
|
+
assert.match(blocked.commits[0].hint, /push origin --delete/);
|
|
705
|
+
assert.notEqual(git(A, ['status', '--porcelain']), '', 'the repair waits in the working tree, unstaged');
|
|
706
|
+
assert.equal(git(A, ['diff', '--cached', '--name-only']), '');
|
|
707
|
+
process.exitCode = 0;
|
|
708
|
+
git(A, ['push', '-q', 'origin', '--delete', `chore/yad-update-v${VERSION}`]);
|
|
709
|
+
const repaired = await reconcile(A, { fix: true, scope: 'all', openPr: true, creator });
|
|
710
|
+
assert.deepEqual(repaired.commits.map((c) => [c.reason ?? null, c.opened]), [[null, true]]);
|
|
711
|
+
assert.ok(git(R, ['diff', '--name-only', 'main', `chore/yad-update-v${VERSION}`]).includes(`.claude/skills/${skill}/SKILL.md`));
|
|
712
|
+
} finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
test('a repo newer than the yadflow running is refused, never rolled back; a failed git add is said', async () => {
|
|
716
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
717
|
+
const { P, A } = await twoClones();
|
|
718
|
+
try {
|
|
719
|
+
const creator = () => { throw new Error('no PR/MR'); };
|
|
720
|
+
put(path.join(A, '.sdlc/cli-version.json'), { version: '99.0.0' });
|
|
721
|
+
git(A, ['commit', '-q', '-am', 'chore: newer']); git(A, ['push', '-q']);
|
|
722
|
+
const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
|
|
723
|
+
assert.deepEqual(r.commits.map((c) => [c.reason, c.error]), [['newer', true]]);
|
|
724
|
+
assert.match(r.commits[0].hint, /update yadflow itself to v99\.0\.0 or later/);
|
|
725
|
+
assert.equal(git(A, ['status', '--porcelain']), '', 'nothing written');
|
|
726
|
+
assert.equal(process.exitCode, 1);
|
|
727
|
+
process.exitCode = 0;
|
|
728
|
+
// A git add that fails (a leftover index.lock): said, with nothing committed and no branch.
|
|
729
|
+
put(path.join(A, '.sdlc/cli-version.json'), { version: '4.0.0' });
|
|
730
|
+
git(A, ['commit', '-q', '-am', 'chore: older']); git(A, ['push', '-q']);
|
|
731
|
+
const lock = path.join(A, '.git/index.lock');
|
|
732
|
+
const ran = await (async () => {
|
|
733
|
+
fs.writeFileSync(lock, '');
|
|
734
|
+
try { return await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator }); } finally { fs.rmSync(lock, { force: true }); }
|
|
735
|
+
})();
|
|
736
|
+
assert.deepEqual(ran.commits.map((c) => [c.reason, c.committed]), [['add-failed', false]]);
|
|
737
|
+
assert.match(ran.commits[0].hint, /index\.lock/);
|
|
738
|
+
assert.notEqual(git(A, ['status', '--porcelain']), '', 'the update is in the working tree');
|
|
739
|
+
assert.equal(git(A, ['rev-parse', '--abbrev-ref', 'HEAD']), 'main');
|
|
740
|
+
} finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
test('a held repo has its row too when another repo goes ahead', async () => {
|
|
744
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
745
|
+
const { VERSION } = await import('./manifest.mjs');
|
|
746
|
+
const P = tmp();
|
|
747
|
+
const T = path.join(P, 'product');
|
|
748
|
+
const A = path.join(P, 'app');
|
|
749
|
+
try {
|
|
750
|
+
for (const d of [T, A]) {
|
|
751
|
+
const r = path.join(P, `${path.basename(d)}.git`);
|
|
752
|
+
git(P, ['init', '-q', '--bare', '-b', 'main', r]);
|
|
753
|
+
fs.mkdirSync(d);
|
|
754
|
+
git(d, ['init', '-q', '-b', 'main']);
|
|
755
|
+
git(d, ['config', 'user.name', 'Alice Smith']); git(d, ['config', 'user.email', 'alice@work.com']); git(d, ['config', 'commit.gpgsign', 'false']); git(d, ['config', 'core.excludesFile', NO_GLOBAL_IGNORE]);
|
|
756
|
+
git(d, ['commit', '-q', '--allow-empty', '-m', 'chore: start']);
|
|
757
|
+
git(d, ['remote', 'add', 'origin', r]); git(d, ['push', '-q', '-u', 'origin', 'main']);
|
|
758
|
+
}
|
|
759
|
+
put(path.join(T, '.sdlc/product.json'), { platform: 'github', git_url: 'git@github.com:acme/product.git', default_branch: 'main' });
|
|
760
|
+
put(path.join(T, '.sdlc/repos.json'), { repos: [{ name: 'app', path: '../app', platform: 'github', default_branch: 'main' }] });
|
|
761
|
+
git(T, ['add', '-A']); git(T, ['commit', '-q', '-m', 'chore: settings']); git(T, ['push', '-q']);
|
|
762
|
+
git(A, ['branch', `chore/yad-update-v${VERSION}`]);
|
|
763
|
+
const r = await reconcile(T, { fix: true, scope: 'all', openPr: true, creator: () => ({ ok: true, url: 'https://github.com/acme/product/pull/4' }) });
|
|
764
|
+
const app = r.commits.find((c) => c.label === 'app');
|
|
765
|
+
assert.deepEqual([app.reason, app.error], ['open', false]);
|
|
766
|
+
assert.match(app.hint, /on review/);
|
|
767
|
+
assert.ok(r.commits.some((c) => c.product && c.opened), JSON.stringify(r.commits));
|
|
768
|
+
assert.equal(git(A, ['status', '--porcelain']), '', 'nothing written in the held repo');
|
|
769
|
+
} finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
test('an update a failed push left in the working tree is carried by the next run', async () => {
|
|
773
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
774
|
+
const { P, R, A } = await twoClones();
|
|
775
|
+
try {
|
|
776
|
+
const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/2' });
|
|
777
|
+
git(A, ['remote', 'set-url', '--push', 'origin', path.join(P, 'nowhere.git')]);
|
|
778
|
+
const failed = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
|
|
779
|
+
assert.equal(failed.commits[0].reason, 'push-failed');
|
|
780
|
+
assert.notEqual(git(A, ['status', '--porcelain']), '', 'the update is still here, uncommitted');
|
|
781
|
+
process.exitCode = 0;
|
|
782
|
+
git(A, ['remote', 'set-url', '--push', 'origin', R]);
|
|
783
|
+
const again = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
|
|
784
|
+
assert.deepEqual([again.commits[0].pushed, again.commits[0].opened], [true, true]);
|
|
785
|
+
// Nothing left behind, the hook settings included. Only a source checkout's build output in the yad-docs
|
|
786
|
+
// template (node_modules, dist) is left: the published package does not ship it.
|
|
787
|
+
const left = git(A, ['status', '--porcelain', '-uall']).split('\n').filter((l) => l && !/^\?\? \.claude\/skills\/yad-docs\/templates\/app\/(node_modules|dist)\//.test(l));
|
|
788
|
+
assert.deepEqual(left, [], 'nothing left behind');
|
|
789
|
+
const files = git(R, ['diff', '--name-only', 'main', `chore/yad-update-v${(await import('./manifest.mjs')).VERSION}`]).split('\n');
|
|
790
|
+
assert.ok(files.length > 1, `more than the stamp: ${files.join(', ')}`);
|
|
791
|
+
assert.ok(files.includes('.claude/settings.json') && files.includes('hooks/yad-capture.mjs'), `the hook script and the entry that runs it land together: ${files.join(', ')}`);
|
|
792
|
+
} finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
test('hook settings with the person\'s own uncommitted edits never ride the update: said in a row', async () => {
|
|
796
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
797
|
+
const { P, R, A } = await twoClones();
|
|
798
|
+
try {
|
|
799
|
+
const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/5' });
|
|
800
|
+
put(path.join(A, '.claude/settings.json'), { permissions: { allow: ['Bash(ls)'] } });
|
|
801
|
+
git(A, ['add', '.claude/settings.json']); git(A, ['commit', '-q', '-m', 'chore: settings']); git(A, ['push', '-q']);
|
|
802
|
+
put(path.join(A, '.claude/settings.json'), { permissions: { allow: ['Bash(ls)', 'Bash(pwd)'] } });
|
|
803
|
+
const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
|
|
804
|
+
const row = r.commits.find((c) => c.reason === 'settings-uncommitted');
|
|
805
|
+
assert.ok(row, JSON.stringify(r.commits));
|
|
806
|
+
assert.match(row.hint, /commit \.claude\/settings\.json as it now stands/);
|
|
807
|
+
const files = git(R, ['diff', '--name-only', 'main', `chore/yad-update-v${(await import('./manifest.mjs')).VERSION}`]).split('\n');
|
|
808
|
+
assert.ok(!files.includes('.claude/settings.json'), files.join(', '));
|
|
809
|
+
assert.match(fs.readFileSync(path.join(A, '.claude/settings.json'), 'utf8'), /Bash\(pwd\)/, 'their edit is still there');
|
|
810
|
+
} finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
test('hook settings whose yad entries are already committed: the person\'s own edit there gets no row', async () => {
|
|
814
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
815
|
+
const { P, A } = await twoClones();
|
|
816
|
+
try {
|
|
817
|
+
const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/6' });
|
|
818
|
+
// Everything installed and committed, then the stamp made old so the next update has work to do.
|
|
819
|
+
await reconcile(A, { fix: true, scope: 'all' });
|
|
820
|
+
put(path.join(A, '.sdlc/cli-version.json'), { version: '4.0.0' });
|
|
821
|
+
git(A, ['add', '-A']); git(A, ['commit', '-q', '-m', 'chore: install']); git(A, ['push', '-q']);
|
|
822
|
+
const file = path.join(A, '.claude/settings.json');
|
|
823
|
+
put(file, { ...JSON.parse(fs.readFileSync(file, 'utf8')), permissions: { allow: ['Bash(npm test)'] } });
|
|
824
|
+
const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
|
|
825
|
+
assert.ok(!r.commits.some((c) => c.reason === 'settings-uncommitted'), JSON.stringify(r.commits));
|
|
826
|
+
assert.ok(r.commits.some((c) => c.opened), JSON.stringify(r.commits));
|
|
827
|
+
assert.match(fs.readFileSync(file, 'utf8'), /npm test/, 'their edit is still there');
|
|
828
|
+
} finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
test('the AGENTS.md rules block rides the update when it is yad\'s change alone; the team\'s committed text is kept', async () => {
|
|
832
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
833
|
+
const { P, R, A } = await twoClones();
|
|
834
|
+
try {
|
|
835
|
+
const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/7' });
|
|
836
|
+
put(path.join(A, 'AGENTS.md'), '# Our team rules\n');
|
|
837
|
+
git(A, ['add', 'AGENTS.md']); git(A, ['commit', '-q', '-m', 'docs: team rules']); git(A, ['push', '-q']);
|
|
838
|
+
const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
|
|
839
|
+
assert.ok(!r.commits.some((c) => c.reason === 'agents-uncommitted'), JSON.stringify(r.commits));
|
|
840
|
+
const branch = `chore/yad-update-v${(await import('./manifest.mjs')).VERSION}`;
|
|
841
|
+
const files = git(R, ['diff', '--name-only', 'main', branch]).split('\n');
|
|
842
|
+
assert.ok(files.includes('AGENTS.md'), files.join(', '));
|
|
843
|
+
const shipped = git(R, ['show', `${branch}:AGENTS.md`]);
|
|
844
|
+
assert.ok(shipped.startsWith('# Our team rules\n\n<!-- yadflow:begin'), shipped.slice(0, 80));
|
|
845
|
+
} finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
test('AGENTS.md a run already wrote (its push failed) still rides the update, whatever blank lines the team left at its end', async () => {
|
|
849
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
850
|
+
const { P, R, A } = await twoClones();
|
|
851
|
+
try {
|
|
852
|
+
const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/9' });
|
|
853
|
+
put(path.join(A, 'AGENTS.md'), '# Our team rules\n\n\n');
|
|
854
|
+
git(A, ['add', 'AGENTS.md']); git(A, ['commit', '-q', '-m', 'docs: team rules']); git(A, ['push', '-q']);
|
|
855
|
+
// The block written on disk, as a run whose push failed leaves it.
|
|
856
|
+
const { agentFileActions } = await import('./plan.mjs');
|
|
857
|
+
agentFileActions(A, ['.agents']).forEach((a) => a.apply());
|
|
858
|
+
const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
|
|
859
|
+
assert.ok(!r.commits.some((c) => c.reason === 'agents-uncommitted'), JSON.stringify(r.commits));
|
|
860
|
+
const files = git(R, ['diff', '--name-only', 'main', `chore/yad-update-v${(await import('./manifest.mjs')).VERSION}`]).split('\n');
|
|
861
|
+
assert.ok(files.includes('AGENTS.md'), files.join(', '));
|
|
862
|
+
} finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
|
|
863
|
+
});
|
|
864
|
+
|
|
865
|
+
test('AGENTS.md with the team\'s own uncommitted edits never rides the update: said in a row', async () => {
|
|
866
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
867
|
+
const { P, R, A } = await twoClones();
|
|
868
|
+
try {
|
|
869
|
+
const creator = () => ({ ok: true, url: 'https://github.com/acme/product/pull/8' });
|
|
870
|
+
put(path.join(A, 'AGENTS.md'), '# Our team rules\n');
|
|
871
|
+
git(A, ['add', 'AGENTS.md']); git(A, ['commit', '-q', '-m', 'docs: team rules']); git(A, ['push', '-q']);
|
|
872
|
+
put(path.join(A, 'AGENTS.md'), '# Our team rules\n\nA new rule, not committed.\n');
|
|
873
|
+
const r = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
|
|
874
|
+
const row = r.commits.find((c) => c.reason === 'agents-uncommitted');
|
|
875
|
+
assert.ok(row, JSON.stringify(r.commits));
|
|
876
|
+
assert.match(row.hint, /left its yadflow rules block out of the PR\/MR: commit AGENTS\.md as it now stands/);
|
|
877
|
+
const files = git(R, ['diff', '--name-only', 'main', `chore/yad-update-v${(await import('./manifest.mjs')).VERSION}`]).split('\n');
|
|
878
|
+
assert.ok(!files.includes('AGENTS.md'), files.join(', '));
|
|
879
|
+
const now = fs.readFileSync(path.join(A, 'AGENTS.md'), 'utf8');
|
|
880
|
+
assert.match(now, /A new rule, not committed\./, 'their edit is still there');
|
|
881
|
+
assert.match(now, /yadflow:end/, 'the block is written on disk');
|
|
882
|
+
} finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
test('a code repo yad never wired: its own AGENTS.md is left alone by update --open-pr, with no row', async () => {
|
|
886
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
887
|
+
const P = tmp();
|
|
888
|
+
const T = path.join(P, 'product');
|
|
889
|
+
const A = path.join(P, 'app');
|
|
890
|
+
const RT = tmp();
|
|
891
|
+
const RA = tmp();
|
|
892
|
+
try {
|
|
893
|
+
fs.mkdirSync(T); fs.mkdirSync(A);
|
|
894
|
+
for (const [d, r] of [[T, RT], [A, RA]]) {
|
|
895
|
+
git(r, ['init', '-q', '--bare', '-b', 'main']);
|
|
896
|
+
git(d, ['init', '-q', '-b', 'main']);
|
|
897
|
+
git(d, ['config', 'user.name', 'Alice Smith']);
|
|
898
|
+
git(d, ['config', 'user.email', 'alice@work.com']);
|
|
899
|
+
git(d, ['config', 'commit.gpgsign', 'false']); git(d, ['config', 'core.excludesFile', NO_GLOBAL_IGNORE]);
|
|
900
|
+
git(d, ['commit', '-q', '--allow-empty', '-m', 'chore: start']);
|
|
901
|
+
git(d, ['remote', 'add', 'origin', r]);
|
|
902
|
+
git(d, ['push', '-q', '-u', 'origin', 'main']);
|
|
903
|
+
}
|
|
904
|
+
put(path.join(T, '.sdlc/product.json'), { platform: 'github', git_url: 'git@github.com:acme/product.git', default_branch: 'main' });
|
|
905
|
+
put(path.join(T, '.sdlc/cli-version.json'), { version: '4.0.0' });
|
|
906
|
+
put(path.join(T, '.sdlc/repos.json'), { repos: [{ name: 'app', path: '../app', platform: 'github', default_branch: 'main' }] });
|
|
907
|
+
git(T, ['add', '-A']); git(T, ['commit', '-q', '-m', 'chore: settings']); git(T, ['push', '-q']);
|
|
908
|
+
// The team's own AGENTS.md, committed, then edited and not committed (E158 review 4).
|
|
909
|
+
fs.writeFileSync(path.join(A, 'AGENTS.md'), '# App notes\n');
|
|
910
|
+
git(A, ['add', 'AGENTS.md']); git(A, ['commit', '-q', '-m', 'docs: notes']); git(A, ['push', '-q']);
|
|
911
|
+
fs.writeFileSync(path.join(A, 'AGENTS.md'), '# App notes\n\nNot committed.\n');
|
|
912
|
+
const r = await reconcile(T, { fix: true, scope: 'changed', openPr: true, creator: () => ({ ok: true, url: 'https://github.com/acme/product/pull/10' }) });
|
|
913
|
+
assert.ok(!r.commits.some((c) => c.reason === 'agents-uncommitted'), JSON.stringify(r.commits));
|
|
914
|
+
assert.equal(fs.readFileSync(path.join(A, 'AGENTS.md'), 'utf8'), '# App notes\n\nNot committed.\n', 'never written');
|
|
915
|
+
} finally { for (const d of [P, RT, RA]) fs.rmSync(d, { recursive: true, force: true }); process.exitCode = 0; }
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
test('--open-pr is all or nothing: one repo that cannot take it, and nothing is written anywhere', async () => {
|
|
919
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
920
|
+
const P = tmp();
|
|
921
|
+
const T = path.join(P, 'product');
|
|
922
|
+
const A = path.join(P, 'app');
|
|
923
|
+
const RT = tmp();
|
|
924
|
+
const RA = tmp();
|
|
925
|
+
try {
|
|
926
|
+
fs.mkdirSync(T); fs.mkdirSync(A);
|
|
927
|
+
for (const [d, r] of [[T, RT], [A, RA]]) {
|
|
928
|
+
git(r, ['init', '-q', '--bare', '-b', 'main']);
|
|
929
|
+
git(d, ['init', '-q', '-b', 'main']);
|
|
930
|
+
git(d, ['config', 'user.name', 'Alice Smith']);
|
|
931
|
+
git(d, ['config', 'user.email', 'alice@work.com']);
|
|
932
|
+
git(d, ['config', 'commit.gpgsign', 'false']); git(d, ['config', 'core.excludesFile', NO_GLOBAL_IGNORE]);
|
|
933
|
+
git(d, ['commit', '-q', '--allow-empty', '-m', 'chore: start']);
|
|
934
|
+
git(d, ['remote', 'add', 'origin', r]);
|
|
935
|
+
git(d, ['push', '-q', '-u', 'origin', 'main']);
|
|
936
|
+
}
|
|
937
|
+
put(path.join(T, '.sdlc/product.json'), { platform: 'github', git_url: 'git@github.com:acme/product.git', default_branch: 'main' });
|
|
938
|
+
put(path.join(T, '.sdlc/repos.json'), { repos: [{ name: 'app', path: '../app', platform: 'github', default_branch: 'main' }] });
|
|
939
|
+
git(T, ['add', '-A']);
|
|
940
|
+
git(T, ['commit', '-q', '-m', 'chore: settings']);
|
|
941
|
+
git(T, ['push', '-q']);
|
|
942
|
+
git(A, ['checkout', '-q', '-b', 'feat/x']);
|
|
943
|
+
const r = await reconcile(T, { fix: true, scope: 'all', openPr: true, creator: () => { throw new Error('no PR may open'); } });
|
|
944
|
+
assert.equal(r.applied, 0);
|
|
945
|
+
assert.deepEqual(r.commits.map((c) => [c.label, c.reason]), [['app', 'branch']]);
|
|
946
|
+
assert.equal(git(T, ['status', '--porcelain']), '', 'nothing written in the Product');
|
|
947
|
+
assert.equal(git(A, ['status', '--porcelain']), '', 'nothing written in the repo on a feature branch');
|
|
948
|
+
assert.equal(process.exitCode, 1);
|
|
949
|
+
process.exitCode = 0;
|
|
950
|
+
} finally { for (const d of [P, RT, RA]) fs.rmSync(d, { recursive: true, force: true }); process.exitCode = 0; }
|
|
951
|
+
});
|
|
952
|
+
|
|
953
|
+
test('--open-pr reaches every cloned repo: one on a feature branch stops it even with nothing of its own to update', async () => {
|
|
954
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
955
|
+
const { VERSION } = await import('./manifest.mjs');
|
|
956
|
+
const P = tmp();
|
|
957
|
+
const T = path.join(P, 'product');
|
|
958
|
+
const A = path.join(P, 'app');
|
|
959
|
+
const RT = tmp();
|
|
960
|
+
const RA = tmp();
|
|
961
|
+
try {
|
|
962
|
+
fs.mkdirSync(T); fs.mkdirSync(A);
|
|
963
|
+
for (const [d, r] of [[T, RT], [A, RA]]) {
|
|
964
|
+
git(r, ['init', '-q', '--bare', '-b', 'main']);
|
|
965
|
+
git(d, ['init', '-q', '-b', 'main']);
|
|
966
|
+
git(d, ['config', 'user.name', 'Alice Smith']);
|
|
967
|
+
git(d, ['config', 'user.email', 'alice@work.com']);
|
|
968
|
+
git(d, ['config', 'commit.gpgsign', 'false']); git(d, ['config', 'core.excludesFile', NO_GLOBAL_IGNORE]);
|
|
969
|
+
git(d, ['commit', '-q', '--allow-empty', '-m', 'chore: start']);
|
|
970
|
+
git(d, ['remote', 'add', 'origin', r]);
|
|
971
|
+
git(d, ['push', '-q', '-u', 'origin', 'main']);
|
|
972
|
+
}
|
|
973
|
+
put(path.join(T, '.sdlc/product.json'), { platform: 'github', git_url: 'git@github.com:acme/product.git', default_branch: 'main' });
|
|
974
|
+
put(path.join(T, '.sdlc/repos.json'), { repos: [{ name: 'app', path: '../app', platform: 'github', default_branch: 'main' }] });
|
|
975
|
+
git(T, ['add', '-A']); git(T, ['commit', '-q', '-m', 'chore: settings']); git(T, ['push', '-q']);
|
|
976
|
+
// The app's own work, on its feature branch; its managed ledger already current.
|
|
977
|
+
git(A, ['checkout', '-q', '-b', 'feat/x']);
|
|
978
|
+
put(path.join(A, '.sdlc/managed.json'), { version: VERSION, files: {} });
|
|
979
|
+
git(A, ['add', '-A']); git(A, ['commit', '-q', '-m', 'feat: my work']);
|
|
980
|
+
const r = await reconcile(T, { fix: true, scope: 'all', openPr: true, creator: () => { throw new Error('no PR may open'); } });
|
|
981
|
+
assert.equal(r.applied, 0);
|
|
982
|
+
assert.deepEqual(r.commits.map((c) => [c.label, c.reason]), [['app', 'branch']]);
|
|
983
|
+
assert.equal(git(A, ['rev-parse', '--abbrev-ref', 'HEAD']), 'feat/x', 'never moved off its branch');
|
|
984
|
+
assert.equal(git(A, ['status', '--porcelain']), '');
|
|
985
|
+
assert.equal(git(T, ['status', '--porcelain']), '');
|
|
986
|
+
process.exitCode = 0;
|
|
987
|
+
} finally { for (const d of [P, RT, RA]) fs.rmSync(d, { recursive: true, force: true }); process.exitCode = 0; }
|
|
988
|
+
});
|
|
989
|
+
|
|
990
|
+
test('a push that fails keeps the update in the working tree, unstaged, deletions included, and drops the branch', async () => {
|
|
991
|
+
const { openUpdatePr } = await import('./update-commit.mjs');
|
|
992
|
+
const T = tmp();
|
|
993
|
+
try {
|
|
994
|
+
git(T, ['init', '-q', '-b', 'main']);
|
|
995
|
+
git(T, ['config', 'user.name', 'Alice Smith']);
|
|
996
|
+
git(T, ['config', 'user.email', 'alice@work.com']);
|
|
997
|
+
git(T, ['config', 'commit.gpgsign', 'false']);
|
|
998
|
+
put(path.join(T, 'old.sh'), 'old\n');
|
|
999
|
+
put(path.join(T, 'a.txt'), 'v1\n');
|
|
1000
|
+
git(T, ['add', '-A']); git(T, ['commit', '-q', '-m', 'chore: start']);
|
|
1001
|
+
git(T, ['remote', 'add', 'origin', path.join(T, 'no-such-remote')]);
|
|
1002
|
+
fs.rmSync(path.join(T, 'old.sh'));
|
|
1003
|
+
put(path.join(T, 'a.txt'), 'v2\n');
|
|
1004
|
+
// The person's own change, staged before the run: it stays staged, and never rides the update.
|
|
1005
|
+
put(path.join(T, 'mine.txt'), 'mine\n');
|
|
1006
|
+
git(T, ['add', 'mine.txt']);
|
|
1007
|
+
const r = openUpdatePr({ root: T, paths: ['old.sh', 'a.txt'], items: [] }, { productRoot: T, defaultBranch: 'main', platform: 'github', creator: () => ({ ok: true }), version: '4.7.0', checked: true });
|
|
1008
|
+
assert.deepEqual([r.pushed, r.error], [false, true]);
|
|
1009
|
+
assert.equal(git(T, ['rev-parse', '--abbrev-ref', 'HEAD']), 'main');
|
|
1010
|
+
assert.equal(git(T, ['branch', '--list', 'chore/yad-update-v4.7.0']), '', 'the branch is dropped, so a later run retries');
|
|
1011
|
+
assert.equal(fs.readFileSync(path.join(T, 'a.txt'), 'utf8'), 'v2\n');
|
|
1012
|
+
assert.ok(!fs.existsSync(path.join(T, 'old.sh')));
|
|
1013
|
+
assert.equal(git(T, ['diff', '--cached', '--name-only']), 'mine.txt', 'only the person\'s own staged file is staged');
|
|
1014
|
+
assert.deepEqual(git(T, ['diff', '--name-status']).split('\n').sort(), ['D\told.sh', 'M\ta.txt'], 'the update, unstaged');
|
|
1015
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); process.exitCode = 0; }
|
|
1016
|
+
});
|
|
1017
|
+
|
|
1018
|
+
test('a leftover update branch holding a person\'s own commit is never deleted: said, with nothing staged', async () => {
|
|
1019
|
+
const { openUpdatePr } = await import('./update-commit.mjs');
|
|
1020
|
+
const T = tmp();
|
|
1021
|
+
try {
|
|
1022
|
+
git(T, ['init', '-q', '-b', 'main']);
|
|
1023
|
+
git(T, ['config', 'user.name', 'Alice Smith']); git(T, ['config', 'user.email', 'alice@work.com']); git(T, ['config', 'commit.gpgsign', 'false']);
|
|
1024
|
+
put(path.join(T, 'a.txt'), 'v1\n');
|
|
1025
|
+
git(T, ['add', '-A']); git(T, ['commit', '-q', '-m', 'chore: start']);
|
|
1026
|
+
git(T, ['switch', '-q', '-c', 'chore/yad-update-v4.7.0']);
|
|
1027
|
+
put(path.join(T, 'b.txt'), 'theirs\n');
|
|
1028
|
+
git(T, ['add', '-A']); git(T, ['commit', '-q', '-m', 'feat: their work']);
|
|
1029
|
+
git(T, ['switch', '-q', 'main']);
|
|
1030
|
+
put(path.join(T, 'a.txt'), 'v2\n');
|
|
1031
|
+
const r = openUpdatePr({ root: T, paths: ['a.txt'], items: [] }, { productRoot: T, defaultBranch: 'main', platform: 'github', creator: () => ({ ok: true }), version: '4.7.0', checked: true });
|
|
1032
|
+
assert.deepEqual([r.reason, r.committed], ['leftover-branch', false]);
|
|
1033
|
+
assert.match(r.hint, /holds other commits/);
|
|
1034
|
+
assert.equal(git(T, ['log', '-1', '--format=%s', 'chore/yad-update-v4.7.0']), 'feat: their work', 'their branch is kept');
|
|
1035
|
+
assert.equal(git(T, ['diff', '--cached', '--name-only']), '');
|
|
1036
|
+
assert.equal(fs.readFileSync(path.join(T, 'a.txt'), 'utf8'), 'v2\n');
|
|
1037
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); process.exitCode = 0; }
|
|
1038
|
+
});
|
|
1039
|
+
|
|
1040
|
+
test('a skill folder keeps the person\'s files; an older template\'s file where a folder now is, is replaced', async () => {
|
|
1041
|
+
const { moduleActions } = await import('./plan.mjs');
|
|
1042
|
+
const T = tmp();
|
|
1043
|
+
try {
|
|
1044
|
+
const a = moduleActions(T, ['.claude']).find((x) => x.item === 'yad-architecture');
|
|
1045
|
+
const dest = path.join(T, '.claude/skills/yad-architecture');
|
|
1046
|
+
put(path.join(dest, 'references'), 'an older template had a file here\n');
|
|
1047
|
+
put(path.join(dest, 'notes/mine.md'), 'mine\n');
|
|
1048
|
+
const kept = a.applyKeepingOwn();
|
|
1049
|
+
assert.deepEqual(kept, ['.claude/skills/yad-architecture/notes/mine.md']);
|
|
1050
|
+
assert.ok(fs.statSync(path.join(dest, 'references')).isDirectory(), 'the template\'s folder is in place');
|
|
1051
|
+
assert.equal(fs.readFileSync(path.join(dest, 'notes/mine.md'), 'utf8'), 'mine\n');
|
|
1052
|
+
assert.deepEqual(fs.readdirSync(path.join(T, '.claude/skills')), ['yad-architecture'], 'no side folder left');
|
|
1053
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
1054
|
+
});
|
|
1055
|
+
|
|
1056
|
+
test('yad update --open-pr: the update on its own branch, pushed, a PR/MR opened, and the repo back on its default branch', async () => {
|
|
1057
|
+
const { openUpdatePr, updateBranchName, buildUpdatePrBody } = await import('./update-commit.mjs');
|
|
1058
|
+
const T = tmp();
|
|
1059
|
+
const R = tmp();
|
|
1060
|
+
try {
|
|
1061
|
+
git(R, ['init', '-q', '--bare', '-b', 'main']);
|
|
1062
|
+
git(T, ['init', '-q', '-b', 'main']);
|
|
1063
|
+
git(T, ['config', 'user.name', 'Alice Smith']);
|
|
1064
|
+
git(T, ['config', 'user.email', 'alice@work.com']);
|
|
1065
|
+
git(T, ['config', 'commit.gpgsign', 'false']); git(T, ['config', 'core.excludesFile', NO_GLOBAL_IGNORE]);
|
|
1066
|
+
put(path.join(T, '.sdlc/cli-version.json'), { version: '4.0.0' });
|
|
1067
|
+
put(path.join(T, 'notes.txt'), 'mine\n');
|
|
1068
|
+
git(T, ['add', '.sdlc/cli-version.json']);
|
|
1069
|
+
git(T, ['commit', '-q', '-m', 'chore: start']);
|
|
1070
|
+
git(T, ['remote', 'add', 'origin', R]);
|
|
1071
|
+
git(T, ['push', '-q', '-u', 'origin', 'main']);
|
|
1072
|
+
put(path.join(T, '.sdlc/cli-version.json'), { version: '4.7.0' });
|
|
1073
|
+
const calls = [];
|
|
1074
|
+
const creator = (platform, opts) => { calls.push([platform, opts]); return { ok: true, url: 'https://github.com/acme/p/pull/9' }; };
|
|
1075
|
+
const r = openUpdatePr({ root: T, paths: ['.sdlc/cli-version.json'], items: ['product/.sdlc/cli-version.json'] }, { productRoot: T, defaultBranch: 'main', platform: 'github', creator, version: '4.7.0' });
|
|
1076
|
+
assert.equal(r.branch, updateBranchName('4.7.0'));
|
|
1077
|
+
assert.equal(r.branch, 'chore/yad-update-v4.7.0');
|
|
1078
|
+
assert.deepEqual([r.committed, r.pushed, r.pr, r.error], [true, true, 'https://github.com/acme/p/pull/9', false]);
|
|
1079
|
+
assert.equal(git(T, ['rev-parse', '--abbrev-ref', 'HEAD']), 'main', 'back on the default branch');
|
|
1080
|
+
assert.match(fs.readFileSync(path.join(T, '.sdlc/cli-version.json'), 'utf8'), /4\.0\.0/, 'the default branch has the update only once the PR/MR merges');
|
|
1081
|
+
assert.equal(fs.readFileSync(path.join(T, 'notes.txt'), 'utf8'), 'mine\n', 'unrelated work is left alone');
|
|
1082
|
+
assert.match(git(R, ['log', '-1', '--format=%s', 'chore/yad-update-v4.7.0']), /^chore\(yad-update\): sync SDLC install to yadflow v4\.7\.0$/);
|
|
1083
|
+
assert.equal(calls.length, 1);
|
|
1084
|
+
const [platform, opts] = calls[0];
|
|
1085
|
+
assert.equal(platform, 'github');
|
|
1086
|
+
assert.deepEqual([opts.base, opts.head], ['main', 'chore/yad-update-v4.7.0']);
|
|
1087
|
+
assert.equal(opts.body, buildUpdatePrBody({ version: '4.7.0', items: ['product/.sdlc/cli-version.json'] }));
|
|
1088
|
+
for (const h of ['## Summary', '## Impact & Risk', 'Risk level: low', '## Checklist']) assert.ok(opts.body.includes(h), h);
|
|
1089
|
+
assert.ok(opts.body.indexOf('## Files') > opts.body.indexOf('## Checklist'), 'the file list comes last');
|
|
1090
|
+
// Run again with the branch still here: skipped, never a second branch.
|
|
1091
|
+
put(path.join(T, '.sdlc/cli-version.json'), { version: '4.7.0' });
|
|
1092
|
+
const again = openUpdatePr({ root: T, paths: ['.sdlc/cli-version.json'], items: [] }, { productRoot: T, defaultBranch: 'main', platform: 'github', creator, version: '4.7.0' });
|
|
1093
|
+
assert.deepEqual([again.skipped, again.reason, again.error], [true, 'open', false]);
|
|
1094
|
+
assert.equal(calls.length, 1);
|
|
1095
|
+
const { updatePrBlocker } = await import('./update-commit.mjs');
|
|
1096
|
+
const msg = updatePrBlocker(T, { defaultBranch: 'main', version: '4.7.0' }).message;
|
|
1097
|
+
assert.doesNotMatch(msg, /delete (its|the) PR|merge or delete/, 'never advise deleting an open PR/MR');
|
|
1098
|
+
assert.match(msg, /closed without merging, delete the branch/, 'a closed one: only its branch');
|
|
1099
|
+
// On origin from another clone, not here: still on review.
|
|
1100
|
+
git(T, ['branch', '-q', '-D', 'chore/yad-update-v4.7.0']);
|
|
1101
|
+
assert.equal(updatePrBlocker(T, { defaultBranch: 'main', version: '4.7.0' }).kind, 'open');
|
|
1102
|
+
// Local commits not on origin would ride the PR/MR: refused.
|
|
1103
|
+
git(T, ['checkout', '-q', '--', '.sdlc/cli-version.json']);
|
|
1104
|
+
git(T, ['commit', '-q', '--allow-empty', '-m', 'chore: local only']);
|
|
1105
|
+
assert.equal(updatePrBlocker(T, { defaultBranch: 'main', version: '4.9.0' }).kind, 'ahead');
|
|
1106
|
+
// Not on the default branch: skipped.
|
|
1107
|
+
git(T, ['checkout', '-q', '-b', 'feat/x']);
|
|
1108
|
+
const off = openUpdatePr({ root: T, paths: ['.sdlc/cli-version.json'], items: [] }, { productRoot: T, defaultBranch: 'main', platform: 'github', creator, version: '4.8.0' });
|
|
1109
|
+
assert.equal(off.skipped, true);
|
|
1110
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); fs.rmSync(R, { recursive: true, force: true }); }
|
|
1111
|
+
});
|
|
1112
|
+
|
|
1113
|
+
test('yad update refuses --push and --open-pr together; --open-pr is the agent\'s without asking', async () => {
|
|
1114
|
+
assert.equal(classify(['update'], ['open-pr']), 'open-pr');
|
|
1115
|
+
assert.equal(askFor(classify(['update'], ['open-pr'])), 'never');
|
|
1116
|
+
assert.equal(classify(['check'], ['fix', 'open-pr']), 'open-pr');
|
|
1117
|
+
const T = await product();
|
|
1118
|
+
try {
|
|
1119
|
+
const r = spawnSync(process.execPath, [YAD, 'update', '--push', '--open-pr', '--json', '--dir', T], { encoding: 'utf8' });
|
|
1120
|
+
assert.equal(r.status, 1);
|
|
1121
|
+
assert.match(JSON.parse(r.stdout).error, /two different ways/);
|
|
1122
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
1123
|
+
});
|
|
1124
|
+
|
|
1125
|
+
// ---- the command ----------------------------------------------------------------------------------------
|
|
1126
|
+
|
|
1127
|
+
test('yad guide --json: with no Product it says how to start one, and carries the rules; a bad id is refused', () => {
|
|
1128
|
+
const T = tmp();
|
|
1129
|
+
try {
|
|
1130
|
+
const r = spawnSync(process.execPath, [YAD, 'guide', '--json'], { cwd: T, encoding: 'utf8', env: { ...process.env, NO_COLOR: '1' } });
|
|
1131
|
+
assert.equal(r.status, 0, r.stderr);
|
|
1132
|
+
const out = JSON.parse(r.stdout);
|
|
1133
|
+
assert.equal(out.command, 'guide');
|
|
1134
|
+
assert.equal(out.ok, true);
|
|
1135
|
+
assert.equal(out.situation.stage, 'no-product');
|
|
1136
|
+
assert.deepEqual(out.rules, RULES);
|
|
1137
|
+
assert.ok(out.person[0].commands.includes('npx -y yadflow@4 new <name> --json <flags>'), JSON.stringify(out.person[0].commands));
|
|
1138
|
+
assert.equal(out.agent[0].run, 'npx -y yadflow@4 new <name> --json');
|
|
1139
|
+
assert.equal(out.agent[0].class, 'on-request');
|
|
1140
|
+
assert.equal(out.stage, undefined, 'the stage is in situation only');
|
|
1141
|
+
const bad = spawnSync(process.execPath, [YAD, 'guide', 'not-an-epic', '--json'], { cwd: T, encoding: 'utf8' });
|
|
1142
|
+
assert.equal(bad.status, 1);
|
|
1143
|
+
assert.match(JSON.parse(bad.stdout).error, /invalid epic id/);
|
|
1144
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
1145
|
+
});
|
|
1146
|
+
|
|
1147
|
+
test('yad guide prints the brief a person would read', async () => {
|
|
1148
|
+
const T = await product();
|
|
1149
|
+
try {
|
|
1150
|
+
moveTo(T, 'EP-pay', 'ui-design');
|
|
1151
|
+
const r = spawnSync(process.execPath, [YAD, 'guide', 'EP-pay', '--dir', T], { encoding: 'utf8', env: { ...process.env, NO_COLOR: '1' } });
|
|
1152
|
+
assert.equal(r.status, 0, r.stderr);
|
|
1153
|
+
const said = `${r.stdout}${r.stderr}`;
|
|
1154
|
+
assert.ok(said.includes(stepFacts('ui-design').description), said);
|
|
1155
|
+
assert.match(said, /can be skipped — the person decides: yad skip EP-pay ui-design/);
|
|
1156
|
+
assert.match(said, /who: the agent drafts, the person decides/);
|
|
1157
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
1158
|
+
});
|
|
1159
|
+
|
|
1160
|
+
test('E158b case 9: a code repo\'s settings ride the update PR when the change is yad\'s alone; with the team\'s own edit, a row', async () => {
|
|
1161
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
1162
|
+
const { VERSION } = await import('./manifest.mjs');
|
|
1163
|
+
const P = tmp();
|
|
1164
|
+
const T = path.join(P, 'product');
|
|
1165
|
+
const A = path.join(P, 'app');
|
|
1166
|
+
try {
|
|
1167
|
+
for (const d of [T, A]) {
|
|
1168
|
+
const r = path.join(P, `${path.basename(d)}.git`);
|
|
1169
|
+
git(P, ['init', '-q', '--bare', '-b', 'main', r]);
|
|
1170
|
+
fs.mkdirSync(d);
|
|
1171
|
+
git(d, ['init', '-q', '-b', 'main']);
|
|
1172
|
+
git(d, ['config', 'user.name', 'Alice Smith']); git(d, ['config', 'user.email', 'alice@work.com']); git(d, ['config', 'commit.gpgsign', 'false']); git(d, ['config', 'core.excludesFile', NO_GLOBAL_IGNORE]);
|
|
1173
|
+
git(d, ['commit', '-q', '--allow-empty', '-m', 'chore: start']);
|
|
1174
|
+
git(d, ['remote', 'add', 'origin', r]); git(d, ['push', '-q', '-u', 'origin', 'main']);
|
|
1175
|
+
}
|
|
1176
|
+
put(path.join(T, '.sdlc/product.json'), { platform: 'github', git_url: 'git@github.com:acme/product.git', default_branch: 'main' });
|
|
1177
|
+
put(path.join(T, '.sdlc/cli-version.json'), { version: '4.0.0', ideTargets: ['.claude'] });
|
|
1178
|
+
put(path.join(T, '.sdlc/repos.json'), { repos: [{ name: 'app', path: '../app', platform: 'github', default_branch: 'main' }] });
|
|
1179
|
+
git(T, ['add', '-A']); git(T, ['commit', '-q', '-m', 'chore: settings']); git(T, ['push', '-q']);
|
|
1180
|
+
// The app is wired (a gate script is there) and has its own committed settings.
|
|
1181
|
+
put(path.join(A, 'checks/spec-link.sh'), '#!/usr/bin/env bash\n');
|
|
1182
|
+
put(path.join(A, '.claude/settings.json'), { permissions: { allow: ['Bash(npm test)'] } });
|
|
1183
|
+
git(A, ['add', '-A']); git(A, ['commit', '-q', '-m', 'chore: wired']); git(A, ['push', '-q']);
|
|
1184
|
+
const branch = `chore/yad-update-v${VERSION}`;
|
|
1185
|
+
const creator = () => ({ ok: true, url: 'https://github.com/acme/app/pull/7' });
|
|
1186
|
+
// The team's own uncommitted edit: the file stays out of the PR, and a row says so.
|
|
1187
|
+
put(path.join(A, '.claude/settings.json'), { permissions: { allow: ['Bash(npm test)', 'Bash(npm run lint)'] } });
|
|
1188
|
+
const mixed = await reconcile(T, { fix: true, scope: 'changed', openPr: true, creator });
|
|
1189
|
+
const row = mixed.commits.find((c) => c.label === 'app' && c.reason === 'settings-uncommitted');
|
|
1190
|
+
assert.ok(row, JSON.stringify(mixed.commits));
|
|
1191
|
+
const files = git(A, ['diff', '--name-only', 'main', branch]).split('\n');
|
|
1192
|
+
assert.ok(files.includes('checks/agent-guard.mjs'), files.join(', '));
|
|
1193
|
+
assert.ok(!files.includes('.claude/settings.json'), files.join(', '));
|
|
1194
|
+
assert.match(fs.readFileSync(path.join(A, '.claude/settings.json'), 'utf8'), /npm run lint/, 'their edit is still there');
|
|
1195
|
+
process.exitCode = 0;
|
|
1196
|
+
} finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
|
|
1197
|
+
});
|
|
1198
|
+
|
|
1199
|
+
test('E158b case 9: with nothing of the team\'s pending, the code repo\'s settings ride the update PR', async () => {
|
|
1200
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
1201
|
+
const { VERSION } = await import('./manifest.mjs');
|
|
1202
|
+
const P = tmp();
|
|
1203
|
+
const T = path.join(P, 'product');
|
|
1204
|
+
const A = path.join(P, 'app');
|
|
1205
|
+
try {
|
|
1206
|
+
for (const d of [T, A]) {
|
|
1207
|
+
const r = path.join(P, `${path.basename(d)}.git`);
|
|
1208
|
+
git(P, ['init', '-q', '--bare', '-b', 'main', r]);
|
|
1209
|
+
fs.mkdirSync(d);
|
|
1210
|
+
git(d, ['init', '-q', '-b', 'main']);
|
|
1211
|
+
git(d, ['config', 'user.name', 'Alice Smith']); git(d, ['config', 'user.email', 'alice@work.com']); git(d, ['config', 'commit.gpgsign', 'false']); git(d, ['config', 'core.excludesFile', NO_GLOBAL_IGNORE]);
|
|
1212
|
+
git(d, ['commit', '-q', '--allow-empty', '-m', 'chore: start']);
|
|
1213
|
+
git(d, ['remote', 'add', 'origin', r]); git(d, ['push', '-q', '-u', 'origin', 'main']);
|
|
1214
|
+
}
|
|
1215
|
+
put(path.join(T, '.sdlc/product.json'), { platform: 'github', git_url: 'git@github.com:acme/product.git', default_branch: 'main' });
|
|
1216
|
+
put(path.join(T, '.sdlc/cli-version.json'), { version: '4.0.0', ideTargets: ['.claude'] });
|
|
1217
|
+
put(path.join(T, '.sdlc/repos.json'), { repos: [{ name: 'app', path: '../app', platform: 'github', default_branch: 'main' }] });
|
|
1218
|
+
git(T, ['add', '-A']); git(T, ['commit', '-q', '-m', 'chore: settings']); git(T, ['push', '-q']);
|
|
1219
|
+
put(path.join(A, 'checks/spec-link.sh'), '#!/usr/bin/env bash\n');
|
|
1220
|
+
put(path.join(A, '.claude/settings.json'), { permissions: { allow: ['Bash(npm test)'] } });
|
|
1221
|
+
git(A, ['add', '-A']); git(A, ['commit', '-q', '-m', 'chore: wired']); git(A, ['push', '-q']);
|
|
1222
|
+
const r = await reconcile(T, { fix: true, scope: 'changed', openPr: true, creator: () => ({ ok: true, url: 'https://github.com/acme/app/pull/8' }) });
|
|
1223
|
+
assert.ok(!r.commits.some((c) => c.reason === 'settings-uncommitted'), JSON.stringify(r.commits));
|
|
1224
|
+
const files = git(A, ['diff', '--name-only', 'main', `chore/yad-update-v${VERSION}`]).split('\n');
|
|
1225
|
+
assert.ok(files.includes('checks/agent-guard.mjs') && files.includes('.claude/settings.json'), `the script and the entry that runs it land together: ${files.join(', ')}`);
|
|
1226
|
+
assert.equal(git(A, ['status', '--porcelain', '--', '.claude', 'checks/agent-guard.mjs']), '', 'nothing of the guard left behind');
|
|
1227
|
+
} finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
|
|
1228
|
+
});
|
|
1229
|
+
|
|
1230
|
+
test('E158b cases 8 and 10 through yad itself: --push stages the script, never the repo\'s settings; a target that leaves takes yad\'s entries out', async () => {
|
|
1231
|
+
const { reconcile } = await import('./reconcile.mjs');
|
|
1232
|
+
const P = tmp();
|
|
1233
|
+
const T = path.join(P, 'product');
|
|
1234
|
+
const A = path.join(P, 'app');
|
|
1235
|
+
try {
|
|
1236
|
+
for (const d of [T, A]) {
|
|
1237
|
+
const r = path.join(P, `${path.basename(d)}.git`);
|
|
1238
|
+
git(P, ['init', '-q', '--bare', '-b', 'main', r]);
|
|
1239
|
+
fs.mkdirSync(d);
|
|
1240
|
+
git(d, ['init', '-q', '-b', 'main']);
|
|
1241
|
+
git(d, ['config', 'user.name', 'Alice Smith']); git(d, ['config', 'user.email', 'alice@work.com']); git(d, ['config', 'commit.gpgsign', 'false']); git(d, ['config', 'core.excludesFile', NO_GLOBAL_IGNORE]);
|
|
1242
|
+
git(d, ['commit', '-q', '--allow-empty', '-m', 'chore: start']);
|
|
1243
|
+
git(d, ['remote', 'add', 'origin', r]); git(d, ['push', '-q', '-u', 'origin', 'main']);
|
|
1244
|
+
}
|
|
1245
|
+
put(path.join(T, '.sdlc/product.json'), { platform: 'github', git_url: 'git@github.com:acme/product.git', default_branch: 'main' });
|
|
1246
|
+
put(path.join(T, '.sdlc/cli-version.json'), { version: '4.0.0', ideTargets: ['.claude'] });
|
|
1247
|
+
put(path.join(T, '.sdlc/repos.json'), { repos: [{ name: 'app', path: '../app', platform: 'github', default_branch: 'main' }] });
|
|
1248
|
+
git(T, ['add', '-A']); git(T, ['commit', '-q', '-m', 'chore: settings']); git(T, ['push', '-q']);
|
|
1249
|
+
put(path.join(A, 'checks/spec-link.sh'), '#!/usr/bin/env bash\n');
|
|
1250
|
+
put(path.join(A, '.claude/settings.json'), { permissions: { allow: ['Bash(npm test)'] } });
|
|
1251
|
+
git(A, ['add', '-A']); git(A, ['commit', '-q', '-m', 'chore: wired']); git(A, ['push', '-q']);
|
|
1252
|
+
// Case 8: the push commits the script, and leaves the repo's own settings file for its people.
|
|
1253
|
+
await reconcile(T, { fix: true, scope: 'changed', push: true });
|
|
1254
|
+
const pushed = git(A, ['show', '--name-only', '--format=', 'origin/main']).split('\n');
|
|
1255
|
+
assert.ok(pushed.includes('checks/agent-guard.mjs'), pushed.join(', '));
|
|
1256
|
+
assert.ok(!pushed.includes('.claude/settings.json'), pushed.join(', '));
|
|
1257
|
+
const settings = path.join(A, '.claude/settings.json');
|
|
1258
|
+
assert.ok(JSON.parse(fs.readFileSync(settings, 'utf8')).permissions.allow.includes('Bash(yad guide:*)'), 'written, not committed');
|
|
1259
|
+
process.exitCode = 0;
|
|
1260
|
+
// Case 10: Claude Code leaves the targets; check --fix takes yad's entries out of the repo's file.
|
|
1261
|
+
put(path.join(T, '.sdlc/cli-version.json'), { version: '4.0.0', ideTargets: ['.agents'] });
|
|
1262
|
+
await reconcile(T, { fix: true, scope: 'all' });
|
|
1263
|
+
const after = JSON.parse(fs.readFileSync(settings, 'utf8'));
|
|
1264
|
+
assert.deepEqual(after.permissions.allow, ['Bash(npm test)']);
|
|
1265
|
+
assert.equal(after.hooks?.PreToolUse, undefined);
|
|
1266
|
+
} finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
|
|
1267
|
+
});
|