yadflow 4.8.0 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +114 -0
- package/README.md +4 -3
- package/bin/commands.mjs +7 -0
- package/bin/yad.mjs +123 -8
- package/cli/agent-guard.mjs +793 -65
- package/cli/agent-rules.mjs +40 -5
- package/cli/argv-flags.mjs +1 -1
- package/cli/build.mjs +1 -1
- package/cli/ci-check.mjs +45 -1
- package/cli/codeowners-command.mjs +72 -6
- package/cli/commit.mjs +17 -3
- package/cli/docs.mjs +2 -0
- package/cli/doctor.mjs +176 -12
- package/cli/epic-state.mjs +94 -4
- package/cli/epic.mjs +11 -7
- package/cli/fold.mjs +31 -6
- package/cli/guide.mjs +3 -1
- package/cli/hook.mjs +50 -7
- package/cli/issue-links.mjs +61 -0
- package/cli/issues-act.mjs +327 -0
- package/cli/issues-write.mjs +428 -0
- package/cli/issues.mjs +474 -0
- package/cli/lifecycle.mjs +7 -0
- package/cli/machine.mjs +141 -0
- package/cli/manifest.mjs +9 -3
- package/cli/openpr.mjs +69 -9
- package/cli/plan.mjs +2 -0
- package/cli/platform.mjs +157 -2
- package/cli/preview.mjs +253 -0
- package/cli/protection.mjs +21 -3
- package/cli/reconcile.mjs +1 -1
- package/cli/repo.mjs +64 -3
- package/cli/review.mjs +4 -0
- package/cli/run-checks.mjs +10 -2
- package/cli/scan.mjs +314 -0
- package/cli/setup.mjs +12 -3
- package/cli/standup.mjs +33 -7
- package/cli/story-frames.mjs +307 -0
- package/cli/test-agents-file.mjs +378 -11
- package/cli/test-build.mjs +25 -0
- package/cli/test-ci-check.mjs +469 -10
- package/cli/test-guide.mjs +7 -0
- package/cli/test-machine.mjs +140 -0
- package/cli/test-node.mjs +15 -0
- package/cli/test-preview.mjs +511 -0
- package/cli/test-run-checks.mjs +17 -0
- package/cli/test-setup-agent.mjs +14 -0
- package/cli/test-story-frames.mjs +409 -0
- package/cli/toolbox-connect.mjs +244 -0
- package/cli/toolbox.mjs +159 -5
- package/package.json +7 -3
- package/skills/sdlc/config.yaml +1 -1
- package/skills/sdlc/module-help.csv +3 -1
- package/skills/yad-analysis/SKILL.md +4 -0
- package/skills/yad-backfill/SKILL.md +4 -0
- package/skills/yad-change/SKILL.md +4 -0
- package/skills/yad-checks/SKILL.md +13 -7
- package/skills/yad-checks/references/check-gates.md +62 -30
- package/skills/yad-checks/templates/checks/member-check.mjs +3 -2
- package/skills/yad-checks/templates/checks/risk-map-check.sh +2 -2
- package/skills/yad-checks/templates/checks/verified-commits.sh +3 -3
- package/skills/yad-checks/templates/github/yad-checks.yml +357 -69
- package/skills/yad-checks/templates/github/yad-pr-text.yml +118 -0
- package/skills/yad-checks/templates/github/yad-product-checks.yml +130 -54
- package/skills/yad-checks/templates/github/yad-product-pr-text.yml +131 -0
- package/skills/yad-checks/templates/github/yad-update-guard.yml +2 -1
- package/skills/yad-checks/templates/github/yad-verified-commits.yml +49 -3
- package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +79 -20
- package/skills/yad-checks/templates/gitlab/yad-product-checks.gitlab-ci.yml +59 -9
- package/skills/yad-checks/templates/gitlab/yad-update-guard.gitlab-ci.yml +1 -0
- package/skills/yad-checks/templates/gitlab/yad-verified-commits.gitlab-ci.yml +49 -1
- package/skills/yad-checks/templates/hooks/agent-guard.mjs +44 -10
- package/skills/yad-checks/templates/hooks/ledger-guard-cursor.mjs +12 -6
- package/skills/yad-commit/SKILL.md +3 -1
- package/skills/yad-connect-design/SKILL.md +48 -13
- package/skills/yad-connect-design/references/design-context.md +56 -3
- package/skills/yad-connect-design/references/design-registry.md +4 -4
- package/skills/yad-connect-learning/SKILL.md +12 -2
- package/skills/yad-connect-repos/SKILL.md +12 -0
- package/skills/yad-connect-testing/SKILL.md +22 -5
- package/skills/yad-connect-testing/references/testing-context.md +1 -1
- package/skills/yad-engineer-review/SKILL.md +13 -0
- package/skills/yad-epic/SKILL.md +4 -0
- package/skills/yad-epic/references/state-schema.md +21 -0
- package/skills/yad-guide/SKILL.md +8 -4
- package/skills/yad-implement/SKILL.md +69 -3
- package/skills/yad-implement/references/implement-conventions.md +2 -1
- package/skills/yad-issues/SKILL.md +53 -0
- package/skills/yad-learn/SKILL.md +4 -0
- package/skills/yad-open-pr/SKILL.md +10 -1
- package/skills/yad-pair-review/SKILL.md +5 -0
- package/skills/yad-pr-template/SKILL.md +2 -1
- package/skills/yad-pr-template/templates/checks/pr-title.sh +34 -2
- 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/references/bridge.md +28 -0
- package/skills/yad-product-bridge/templates/github/yad-gate-sync.yml +25 -11
- package/skills/yad-product-bridge/templates/gitlab/yad-gate-sync.gitlab-ci.yml +38 -14
- package/skills/yad-review-companion/SKILL.md +4 -1
- package/skills/yad-run/SKILL.md +5 -0
- package/skills/yad-scan/SKILL.md +51 -0
- package/skills/yad-spec/SKILL.md +32 -0
- package/skills/yad-stories/SKILL.md +22 -0
- package/skills/yad-stories/references/story-schema.md +1 -0
- package/skills/yad-test-cases/SKILL.md +18 -2
- package/skills/yad-ui/SKILL.md +48 -8
- package/skills/yad-checks/templates/gitlab/.gitlab-ci.yml +0 -49
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
// #354: each story records its design frames (`design-frames: [id, …]`), `yad story frames` reads them
|
|
2
|
+
// with their names and links from the epic's design-links.json, and `yad doctor` warns on any it cannot
|
|
3
|
+
// read. One rule (`frameFindings`) decides for both, and every finding is a warning in both.
|
|
4
|
+
import { test } from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import { spawnSync } from 'node:child_process';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
|
|
12
|
+
if (process.env.NODE_TEST_CONTEXT) {
|
|
13
|
+
const write = process.stdout.write;
|
|
14
|
+
for (const k of ['log', 'info']) {
|
|
15
|
+
const orig = console[k];
|
|
16
|
+
console[k] = (...a) => (process.stdout.write === write ? console.error(...a) : orig(...a));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
process.env.YAD_NO_UPDATE_NOTIFIER = '1';
|
|
20
|
+
|
|
21
|
+
const { frameFindings, readDesignLinks, readStoryFrames, allStoryFrames, FRAMES_KEY } = await import('./story-frames.mjs');
|
|
22
|
+
const { storyFrameChecks } = await import('./doctor.mjs');
|
|
23
|
+
|
|
24
|
+
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
25
|
+
const YAD = path.join(HERE, '..', 'bin', 'yad.mjs');
|
|
26
|
+
const REPO = path.join(HERE, '..');
|
|
27
|
+
|
|
28
|
+
const tmp = () => fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'yad-frames-')));
|
|
29
|
+
const put = (file, data) => { fs.mkdirSync(path.dirname(file), { recursive: true }); fs.writeFileSync(file, typeof data === 'string' ? data : JSON.stringify(data)); };
|
|
30
|
+
const done = (T) => fs.rmSync(T, { recursive: true, force: true });
|
|
31
|
+
const story = (id, line) => `---\nid: ${id}\nepic: ${id.replace(/-S\d+$/, '')}\nstatus: draft\nrepos: [web]\n${line === null ? '' : `${line}\n`}---\n\n## Story\n`;
|
|
32
|
+
const LINKS = {
|
|
33
|
+
tool: 'pencil', fileUrl: 'https://design.example/f', direction: 'generate', source: 'pencil',
|
|
34
|
+
screens: [
|
|
35
|
+
{ name: 'Cart', platform: 'web', nodeId: '12:34', url: 'https://design.example/f?node=12:34' },
|
|
36
|
+
{ name: 'Pay', platform: 'mobile', nodeId: 'aB3xQ', url: 'https://design.example/f?node=aB3xQ' },
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
const ok = { state: 'ok', tool: 'pencil', fileUrl: LINKS.fileUrl, screens: LINKS.screens };
|
|
40
|
+
const kinds = (r) => r.findings.map((f) => f.kind);
|
|
41
|
+
const BOM = String.fromCharCode(0xfeff);
|
|
42
|
+
|
|
43
|
+
// A Product with one epic: its design-links.json (or none) and the given stories.
|
|
44
|
+
function product(stories, links = LINKS) {
|
|
45
|
+
const T = tmp();
|
|
46
|
+
const epic = path.join(T, 'epics', 'EP-shop');
|
|
47
|
+
fs.mkdirSync(epic, { recursive: true });
|
|
48
|
+
if (links !== null) put(path.join(epic, '.sdlc', 'design-links.json'), links);
|
|
49
|
+
for (const [id, line] of Object.entries(stories)) put(path.join(epic, 'stories', `${id}.md`), story(id, line));
|
|
50
|
+
return T;
|
|
51
|
+
}
|
|
52
|
+
const yad = (T, ...args) => spawnSync(process.execPath, [YAD, ...args, '--dir', T], { encoding: 'utf8', env: { ...process.env, NO_COLOR: '1', SDLC_NONINTERACTIVE: '1' } });
|
|
53
|
+
|
|
54
|
+
test('#354: frameFindings — no key, an empty list, and IDs that all resolve', () => {
|
|
55
|
+
assert.deepEqual(frameFindings({}, ok), { recorded: false, ids: [], frames: [], findings: [] });
|
|
56
|
+
const none = frameFindings({ [FRAMES_KEY]: [] }, { state: 'missing' });
|
|
57
|
+
assert.equal(none.recorded, true);
|
|
58
|
+
assert.deepEqual(none.findings, [], '`[]` needs no design-links.json — a story with no screens');
|
|
59
|
+
const r = frameFindings({ [FRAMES_KEY]: ['12:34', 'aB3xQ'] }, ok);
|
|
60
|
+
assert.deepEqual(r.findings, []);
|
|
61
|
+
assert.deepEqual(r.frames, [
|
|
62
|
+
{ id: '12:34', found: true, name: 'Cart', platform: 'web', url: LINKS.screens[0].url },
|
|
63
|
+
{ id: 'aB3xQ', found: true, name: 'Pay', platform: 'mobile', url: LINKS.screens[1].url },
|
|
64
|
+
], 'a Figma 12:34 ID and a Pencil-style ID both resolve');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('#354: frameFindings — every problem is a finding, never a silent "no frames"', () => {
|
|
68
|
+
assert.deepEqual(kinds(frameFindings({ [FRAMES_KEY]: ['12:34', '99:99'] }, ok)), ['not-found']);
|
|
69
|
+
assert.deepEqual(kinds(frameFindings({ [FRAMES_KEY]: '[12:34] # the cart' }, ok)), ['commented'], 'the comment trap');
|
|
70
|
+
assert.deepEqual(kinds(frameFindings({ [FRAMES_KEY]: '' }, ok)), ['not-a-list'], 'blank — what a `- id` block list reads as');
|
|
71
|
+
assert.deepEqual(kinds(frameFindings({ [FRAMES_KEY]: '12:34' }, ok)), ['not-a-list']);
|
|
72
|
+
assert.deepEqual(kinds(frameFindings({ [FRAMES_KEY]: ['12 34'] }, ok)), ['bad-id', 'not-found']);
|
|
73
|
+
assert.deepEqual(kinds(frameFindings({ [FRAMES_KEY]: ['12:34', '12:34'] }, ok)), ['duplicate']);
|
|
74
|
+
assert.deepEqual(kinds(frameFindings({ [FRAMES_KEY]: ['12:34'] }, { state: 'missing' })), ['no-design-links']);
|
|
75
|
+
assert.deepEqual(kinds(frameFindings({ [FRAMES_KEY]: ['12:34'] }, { state: 'unreadable', why: 'x' })), ['design-links-unreadable']);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('#354: frameFindings — text from the files reaches the terminal cleaned', () => {
|
|
79
|
+
const r = frameFindings({ [FRAMES_KEY]: ['\x1b[31m1:2'] }, ok);
|
|
80
|
+
for (const f of r.findings) assert.ok(!f.message.includes('\x1b'), f.message);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('#354: readDesignLinks — missing, not JSON, no screens list, and ok', () => {
|
|
84
|
+
const T = tmp();
|
|
85
|
+
try {
|
|
86
|
+
assert.equal(readDesignLinks(T).state, 'missing');
|
|
87
|
+
put(path.join(T, '.sdlc', 'design-links.json'), '{ nope');
|
|
88
|
+
assert.equal(readDesignLinks(T).state, 'unreadable');
|
|
89
|
+
put(path.join(T, '.sdlc', 'design-links.json'), { tool: 'figma' });
|
|
90
|
+
assert.equal(readDesignLinks(T).state, 'unreadable');
|
|
91
|
+
put(path.join(T, '.sdlc', 'design-links.json'), LINKS);
|
|
92
|
+
const r = readDesignLinks(T);
|
|
93
|
+
assert.equal(r.state, 'ok');
|
|
94
|
+
assert.equal(r.screens.length, 2);
|
|
95
|
+
} finally { done(T); }
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('#354: the frontmatter reader round-trips the key the stories step writes', () => {
|
|
99
|
+
const T = product({ 'EP-shop-S01': `${FRAMES_KEY}: [12:34, aB3xQ]`, 'EP-shop-S02': `${FRAMES_KEY}: []`, 'EP-shop-S03': null });
|
|
100
|
+
try {
|
|
101
|
+
assert.deepEqual(readStoryFrames(T, 'EP-shop-S01').frames.map((f) => f.found), [true, true]);
|
|
102
|
+
const s2 = readStoryFrames(T, 'EP-shop-S02');
|
|
103
|
+
assert.deepEqual([s2.recorded, s2.ids, s2.findings], [true, [], []]);
|
|
104
|
+
assert.equal(readStoryFrames(T, 'EP-shop-S03').recorded, false);
|
|
105
|
+
assert.throws(() => readStoryFrames(T, 'EP-shop-S09'), /no story file/);
|
|
106
|
+
assert.throws(() => readStoryFrames(T, 'shop'), /not a story id/);
|
|
107
|
+
assert.throws(() => readStoryFrames(T, undefined), /needs a story id/);
|
|
108
|
+
} finally { done(T); }
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('#354: yad story frames — text, --json, and the exit code', () => {
|
|
112
|
+
const T = product({ 'EP-shop-S01': `${FRAMES_KEY}: [12:34, 99:99]` });
|
|
113
|
+
try {
|
|
114
|
+
const text = yad(T, 'story', 'frames', 'EP-shop-S01');
|
|
115
|
+
assert.equal(text.status, 0, text.stderr);
|
|
116
|
+
assert.match(text.stdout, /12:34 {2}Cart {2}\[web\]/);
|
|
117
|
+
assert.match(text.stdout, /99:99 — not found/);
|
|
118
|
+
const j = yad(T, 'story', 'frames', 'EP-shop-S01', '--json');
|
|
119
|
+
assert.equal(j.status, 0, j.stderr);
|
|
120
|
+
const out = JSON.parse(j.stdout);
|
|
121
|
+
assert.equal(out.command, 'story frames');
|
|
122
|
+
assert.equal(out.ok, true);
|
|
123
|
+
assert.equal(out.tool, 'pencil');
|
|
124
|
+
assert.deepEqual(out.frames.map((f) => [f.id, f.found]), [['12:34', true], ['99:99', false]]);
|
|
125
|
+
assert.deepEqual(out.findings.map((f) => f.kind), ['not-found']);
|
|
126
|
+
assert.equal(out.warnings.length, 1, 'a missing frame is a warning, and the exit code stays 0');
|
|
127
|
+
|
|
128
|
+
const gone = yad(T, 'story', 'frames', 'EP-shop-S09', '--json');
|
|
129
|
+
assert.equal(gone.status, 1);
|
|
130
|
+
const g = JSON.parse(gone.stdout);
|
|
131
|
+
assert.equal(g.ok, false);
|
|
132
|
+
assert.match(g.hint, /story id/);
|
|
133
|
+
assert.equal(yad(T, 'story', 'paint').status, 1, 'an unknown action is refused');
|
|
134
|
+
} finally { done(T); }
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('#354: doctor — no row without frames, an ok row with a count, one warn row naming the problems', () => {
|
|
138
|
+
const run = (T) => { const checks = []; storyFrameChecks(checks, T); return checks; };
|
|
139
|
+
let T = product({ 'EP-shop-S01': null });
|
|
140
|
+
try { assert.deepEqual(run(T), []); } finally { done(T); }
|
|
141
|
+
|
|
142
|
+
T = product({ 'EP-shop-S01': `${FRAMES_KEY}: [12:34]`, 'EP-shop-S02': `${FRAMES_KEY}: []` }, LINKS);
|
|
143
|
+
try {
|
|
144
|
+
const [row, ...rest] = run(T);
|
|
145
|
+
assert.equal(rest.length, 0);
|
|
146
|
+
assert.deepEqual([row.id, row.status], ['stories:design-frames', 'ok']);
|
|
147
|
+
assert.match(row.message, /^1 story\(ies\) record design frames.*; 1 story\(ies\) say they have no screens/);
|
|
148
|
+
} finally { done(T); }
|
|
149
|
+
|
|
150
|
+
T = product({ 'EP-shop-S01': `${FRAMES_KEY}: [12:34] # cart`, 'EP-shop-S02': `${FRAMES_KEY}: [77:1]` });
|
|
151
|
+
try {
|
|
152
|
+
const rows = run(T);
|
|
153
|
+
assert.equal(rows.length, 1);
|
|
154
|
+
assert.deepEqual([rows[0].id, rows[0].status], ['stories:design-frames', 'warn']);
|
|
155
|
+
assert.match(rows[0].message, /^2 problem/);
|
|
156
|
+
assert.match(rows[0].message, /EP-shop-S01: .*#/);
|
|
157
|
+
assert.match(rows[0].message, /EP-shop-S02: .*77:1/);
|
|
158
|
+
assert.deepEqual(allStoryFrames(T, ['EP-shop']).map((s) => s.findings[0].kind), ['commented', 'not-found']);
|
|
159
|
+
} finally { done(T); }
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test('#354 review 1: Windows line endings, a byte-order mark and a trailing space still read the list', () => {
|
|
163
|
+
const T = product({});
|
|
164
|
+
try {
|
|
165
|
+
const dir = path.join(T, 'epics', 'EP-shop', 'stories');
|
|
166
|
+
put(path.join(dir, 'EP-shop-S01.md'), story('EP-shop-S01', `${FRAMES_KEY}: [12:34]`).replace(/\n/g, '\r\n'));
|
|
167
|
+
put(path.join(dir, 'EP-shop-S02.md'), BOM + story('EP-shop-S02', `${FRAMES_KEY}: [12:34]`));
|
|
168
|
+
put(path.join(dir, 'EP-shop-S03.md'), story('EP-shop-S03', `${FRAMES_KEY}: [12:34] `));
|
|
169
|
+
for (const id of ['EP-shop-S01', 'EP-shop-S02', 'EP-shop-S03']) {
|
|
170
|
+
const r = readStoryFrames(T, id);
|
|
171
|
+
assert.deepEqual([r.recorded, r.frames.map((f) => f.found), r.findings], [true, [true], []], id);
|
|
172
|
+
}
|
|
173
|
+
assert.deepEqual(allStoryFrames(T, ['EP-shop']).map((s) => s.findings.length), [0, 0, 0], 'doctor reads them the same way');
|
|
174
|
+
} finally { done(T); }
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('#354 review 1: a misspelled key and quoted IDs are said, not read as "no frames" or "not found"', () => {
|
|
178
|
+
for (const k of ['Design-Frames', 'designFrames', 'design_frames']) {
|
|
179
|
+
const r = frameFindings({ [k]: ['12:34'] }, ok);
|
|
180
|
+
assert.deepEqual([r.recorded, kinds(r)], [false, ['key-spelling']], k);
|
|
181
|
+
}
|
|
182
|
+
const q = frameFindings({ [FRAMES_KEY]: ['"12:34"', "'aB3xQ'"] }, ok);
|
|
183
|
+
assert.deepEqual(kinds(q), ['quoted']);
|
|
184
|
+
assert.deepEqual(q.frames.map((f) => [f.id, f.found]), [['12:34', true], ['aB3xQ', true]]);
|
|
185
|
+
assert.doesNotMatch(frameFindings({ [FRAMES_KEY]: 'x y' }, ok).findings[0].message, /\[\[/, 'never advice to double the brackets');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
test('#354 review 1: doctor never points at a command that would refuse the story', () => {
|
|
189
|
+
const T = product({ 'EP-shop-S01': `${FRAMES_KEY}: []` });
|
|
190
|
+
try {
|
|
191
|
+
const dir = path.join(T, 'epics', 'EP-shop', 'stories');
|
|
192
|
+
put(path.join(dir, 'EP-Shop-S04.md'), story('EP-Shop-S04', `${FRAMES_KEY}: [12:34]`));
|
|
193
|
+
put(path.join(dir, 'EP-other-S01.md'), story('EP-other-S01', `${FRAMES_KEY}: [12:34]`));
|
|
194
|
+
fs.mkdirSync(path.join(dir, 'EP-shop-S07.md'));
|
|
195
|
+
const rows = allStoryFrames(T, ['EP-shop']);
|
|
196
|
+
assert.deepEqual(rows.map((s) => [s.story, kinds(s)]), [['EP-Shop-S04', ['not-a-story-file']], ['EP-other-S01', ['not-a-story-file']], ['EP-shop-S01', []]]);
|
|
197
|
+
for (const s of rows.filter((x) => x.findings.length)) assert.match(s.findings[0].message, /rename the file/);
|
|
198
|
+
assert.throws(() => readStoryFrames(T, 'EP-shop-S07'), /no story file/, 'a folder named like a story is refused, not a crash');
|
|
199
|
+
const checks = [];
|
|
200
|
+
storyFrameChecks(checks, T);
|
|
201
|
+
assert.equal(checks[0].status, 'warn');
|
|
202
|
+
} finally { done(T); }
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test('#354 review 1: the ok row tells stories with frames from stories with no screens', () => {
|
|
206
|
+
const T = product({ 'EP-shop-S01': `${FRAMES_KEY}: []` }, null);
|
|
207
|
+
try {
|
|
208
|
+
const checks = [];
|
|
209
|
+
storyFrameChecks(checks, T);
|
|
210
|
+
assert.equal(checks[0].status, 'ok');
|
|
211
|
+
assert.match(checks[0].message, /^1 story\(ies\) say they have no screens/);
|
|
212
|
+
assert.equal(yad(T, 'story', 'frames', 'EP-shop-S01', 'EP-shop-S02').status, 1, 'one story at a time');
|
|
213
|
+
} finally { done(T); }
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
test('#354 review 2: doctor reads what the command reads — a symlinked story, a misspelled key', () => {
|
|
217
|
+
const T = product({ 'EP-shop-S02': 'designFrames: [12:34]' });
|
|
218
|
+
try {
|
|
219
|
+
const dir = path.join(T, 'epics', 'EP-shop', 'stories');
|
|
220
|
+
put(path.join(T, 'elsewhere.md'), story('EP-shop-S01', `${FRAMES_KEY}: [9:9]`));
|
|
221
|
+
fs.symlinkSync(path.join(T, 'elsewhere.md'), path.join(dir, 'EP-shop-S01.md'));
|
|
222
|
+
assert.deepEqual(kinds(readStoryFrames(T, 'EP-shop-S01')), ['not-found']);
|
|
223
|
+
assert.deepEqual(allStoryFrames(T, ['EP-shop']).map((s) => [s.story, kinds(s)]), [['EP-shop-S01', ['not-found']], ['EP-shop-S02', ['key-spelling']]]);
|
|
224
|
+
const checks = [];
|
|
225
|
+
storyFrameChecks(checks, T);
|
|
226
|
+
assert.equal(checks[0].status, 'warn');
|
|
227
|
+
assert.match(checks[0].hint, /rename a story file/);
|
|
228
|
+
} finally { done(T); }
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test('#354 review 2: a misspelled key beside the right one is said; `""` is not an empty ID', () => {
|
|
232
|
+
const both = frameFindings({ [FRAMES_KEY]: ['12:34'], designFrames: ['56:78'] }, ok);
|
|
233
|
+
assert.deepEqual(kinds(both), ['key-spelling']);
|
|
234
|
+
assert.match(both.findings[0].message, /move its IDs/);
|
|
235
|
+
const empty = frameFindings({ [FRAMES_KEY]: ['""'] }, ok);
|
|
236
|
+
assert.deepEqual(kinds(empty), ['not-found'], '`""` is left as it is, never turned into an empty ID');
|
|
237
|
+
assert.deepEqual(empty.ids, ['""']);
|
|
238
|
+
assert.match(frameFindings({ [FRAMES_KEY]: ['"12:34"'] }, ok).findings[0].message, /should be written without quotes/);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
const { designPreflight, readDesignConfig } = await import('./story-frames.mjs');
|
|
242
|
+
const { TOOLBOX, toolProblems, reachFor } = await import('./toolbox.mjs');
|
|
243
|
+
|
|
244
|
+
test('#358: designPreflight — Pencil is read through the app; Figma only through its desktop server', () => {
|
|
245
|
+
const frames = [{ id: '99:1', found: false }, { id: '12:34', found: true }];
|
|
246
|
+
const links = { state: 'ok', fileUrl: 'design/app.pen', screens: [] };
|
|
247
|
+
const pencil = designPreflight({ state: 'ok', data: { tool: 'pencil', provider: 'pencil-mcp' } }, links, frames);
|
|
248
|
+
assert.deepEqual([pencil.reachable, pencil.appBound, pencil.frame, pencil.file], ['check', true, '12:34', 'design/app.pen'], 'the first frame that resolves is the one probed');
|
|
249
|
+
assert.match(pencil.stop, /^Open the Pencil desktop app with `design\/app\.pen` loaded/);
|
|
250
|
+
assert.match(pencil.probe, /get_app_state/);
|
|
251
|
+
// E165: the command to connect the tool, when it is not on this machine at all.
|
|
252
|
+
assert.equal(pencil.connect, 'yad toolbox connect pencil --json');
|
|
253
|
+
const desk = designPreflight({ state: 'ok', data: { tool: 'figma', provider: 'figma-desktop' } }, links, frames);
|
|
254
|
+
assert.deepEqual([desk.appBound, /desktop app/.test(desk.stop)], [true, true]);
|
|
255
|
+
assert.equal(desk.connect, undefined, 'the desktop app\'s own server: open the app, never the hosted plugin\'s recipe');
|
|
256
|
+
const cloud = designPreflight({ state: 'ok', data: { tool: 'figma', provider: 'figma' } }, links, frames);
|
|
257
|
+
assert.deepEqual([cloud.appBound, /^Sign in to Figma/.test(cloud.stop), cloud.connect], [false, true, 'yad toolbox connect figma --json']);
|
|
258
|
+
assert.match(cloud.probe, /`12:34`/);
|
|
259
|
+
const old = designPreflight({ state: 'ok', data: { tool: 'figma', provider: 'figma-mcp' } }, links, frames);
|
|
260
|
+
assert.deepEqual([old.appBound, /desktop app.*or sign in/.test(old.stop)], [null, true], 'the older figma-mcp: yad cannot tell, so both');
|
|
261
|
+
const viaSource = designPreflight({ state: 'ok', data: { tool: 'figma', source: 'figma-desktop' } }, links, frames);
|
|
262
|
+
assert.deepEqual([viaSource.provider, viaSource.appBound], ['figma-desktop', true], 'no provider: source names the server');
|
|
263
|
+
const noFile = designPreflight({ state: 'ok', data: { tool: 'pencil', project_url: 'https://team/project' } }, { state: 'ok', tool: 'pencil', fileUrl: null, screens: [] }, frames);
|
|
264
|
+
assert.match(noFile.stop, /the design file/, 'no file: said plainly — a project_url is a project, never compared as the file');
|
|
265
|
+
const switched = designPreflight({ state: 'ok', data: { tool: 'pencil' } }, { state: 'ok', tool: 'figma', fileUrl: 'https://figma/f', screens: [] }, frames);
|
|
266
|
+
assert.deepEqual([switched.reachable, /recorded for figma.*re-run the UI step/.test(switched.why)], ['not-checkable', true], 'frames of another tool are never probed through this one');
|
|
267
|
+
const odd = designPreflight({ state: 'ok', data: { tool: 'figma', source: 'figma-dev-mode-mcp-server' } }, links, frames);
|
|
268
|
+
assert.deepEqual([odd.reachable, odd.appBound], ['check', null], 'an MCP id yad does not know is still probed, with both messages');
|
|
269
|
+
assert.equal(designPreflight({ state: 'ok', data: { tool: 'figma', provider: 'Figma-Desktop' } }, links, frames).appBound, true, 'names are compared in lower case');
|
|
270
|
+
for (const provider of ['HTML-to-Design', 'html.to.design', ' html_to_design ']) {
|
|
271
|
+
assert.equal(designPreflight({ state: 'ok', data: { tool: 'figma', provider } }, links, frames).reachable, 'not-checkable', provider);
|
|
272
|
+
}
|
|
273
|
+
assert.equal(designPreflight({ state: 'ok', data: { tool: 'figma' } }, { ...links, tool: 'Figma' }, frames).reachable, 'check', 'the same tool in other letters is not a switch');
|
|
274
|
+
for (const r of [pencil, desk, cloud, old]) assert.equal(r.local, false, 'only a provider in reach.local is local');
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
test('E164: designPreflight — OpenPencil\'s CLI needs no app and no sign-in; its MCP server needs the app', () => {
|
|
278
|
+
const frames = [{ id: 'login-mobile', found: true }];
|
|
279
|
+
const links = { state: 'ok', tool: 'openpencil', fileUrl: 'epics/EP-shop/design/screens.fig', screens: [] };
|
|
280
|
+
const cli = designPreflight({ state: 'ok', data: { tool: 'openpencil', provider: 'openpencil-cli' } }, links, frames);
|
|
281
|
+
assert.deepEqual([cli.reachable, cli.appBound, cli.local, cli.frame], ['check', false, true, 'login-mobile']);
|
|
282
|
+
assert.match(cli.probe, /^check that `epics\/EP-shop\/design\/screens\.fig` is in the Product checkout and that `openpencil --version` runs/);
|
|
283
|
+
assert.match(cli.probe, /shared plugin data `yad`\/`nodeId` is `login-mobile`/, 'the frame is found by the ID yad stored on it');
|
|
284
|
+
assert.match(cli.stop, /^Pull the Product so that `epics\/EP-shop\/design\/screens\.fig` is there with frame `login-mobile` in it/);
|
|
285
|
+
for (const text of [cli.probe, cli.stop]) assert.doesNotMatch(text, /desktop app|sign in/i, 'the CLI path never asks for an app or a sign-in');
|
|
286
|
+
assert.equal(cli.connect, 'yad toolbox connect openpencil --json');
|
|
287
|
+
const mcp = designPreflight({ state: 'ok', data: { tool: 'openpencil', provider: 'openpencil-mcp' } }, links, frames);
|
|
288
|
+
assert.deepEqual([mcp.appBound, mcp.local], [true, false]);
|
|
289
|
+
assert.match(mcp.probe, /OpenPencil MCP: its eval tool/);
|
|
290
|
+
assert.match(mcp.stop, /^Open the OpenPencil desktop app with `epics\/EP-shop\/design\/screens\.fig` loaded \(the file must be inside OPENPENCIL_MCP_ROOT\)/);
|
|
291
|
+
assert.equal(mcp.connect, 'yad toolbox connect openpencil --json', 'OpenPencil\'s recipe adds its MCP server, so it is offered');
|
|
292
|
+
const unknown = designPreflight({ state: 'ok', data: { tool: 'openpencil' } }, links, frames);
|
|
293
|
+
assert.deepEqual([unknown.appBound, unknown.local, /runs in your terminal \(the CLI\), or open the OpenPencil desktop app/.test(unknown.stop)], [null, false, true], 'no provider: both ways');
|
|
294
|
+
assert.match(unknown.probe, /^try the CLI first: .*`openpencil eval`.* if that does not find it, find frame .* through the OpenPencil MCP's eval tool.*It fails only when neither finds it/, 'reviews 1-2: the check tries both ways the stop text names, the MCP whenever the CLI does not find the frame');
|
|
295
|
+
assert.equal(designPreflight({ state: 'ok', data: { tool: 'figma', provider: 'figma-mcp' } }, { ...links, tool: 'figma' }, frames).probe.includes('get_metadata'), true, 'a tool with no eitherProbe keeps its probe');
|
|
296
|
+
assert.equal(designPreflight({ state: 'ok', data: { tool: 'openpencil', provider: 'OpenPencil_CLI' } }, links, frames).local, true, 'names are compared on letters and digits');
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
test('#358: designPreflight — nothing to probe is not-checkable, and no frame means no preflight', () => {
|
|
300
|
+
const frames = [{ id: '12:34', found: true }];
|
|
301
|
+
const links = { state: 'ok', fileUrl: 'f', screens: [] };
|
|
302
|
+
for (const design of [{ state: 'missing' }, { state: 'unreadable' }, { state: 'ok', data: { tool: 'none' } }, { state: 'ok', data: { tool: 'pencil', source: 'unavailable' } }, { state: 'ok', data: { tool: 'sketch' } }]) {
|
|
303
|
+
const r = designPreflight(design, links, frames);
|
|
304
|
+
assert.equal(r.reachable, 'not-checkable', JSON.stringify(design));
|
|
305
|
+
assert.equal(r.connect, undefined, 'nothing to probe, nothing to connect: connecting the team\'s tool is yad-connect-design\'s');
|
|
306
|
+
}
|
|
307
|
+
assert.equal(designPreflight({ state: 'ok', data: { tool: 'pencil' } }, links, []), null);
|
|
308
|
+
const writer = designPreflight({ state: 'ok', data: { tool: 'figma', provider: 'html-to-design' } }, links, frames);
|
|
309
|
+
assert.deepEqual([writer.reachable, /cannot read a frame/.test(writer.why)], ['not-checkable', true]);
|
|
310
|
+
const gone = designPreflight({ state: 'ok', data: { tool: 'pencil' } }, { state: 'missing' }, [{ id: '9:9', found: false }]);
|
|
311
|
+
assert.match(gone.why, /no design-links\.json/, 'a missing file is named, not blamed on the IDs');
|
|
312
|
+
assert.match(designPreflight({ state: 'ok', data: { tool: 'pencil' } }, { state: 'unreadable', why: 'it does not parse as JSON' }, [{ id: '9:9', found: false }]).why, /cannot be read/);
|
|
313
|
+
const unresolved = designPreflight({ state: 'ok', data: { tool: 'pencil' } }, links, [{ id: '9:9', found: false }]);
|
|
314
|
+
assert.deepEqual([unresolved.reachable, /fix the frame IDs/.test(unresolved.why)], ['not-checkable', true]);
|
|
315
|
+
for (const data of [{ tool: 123 }, { tool: 'figma', provider: {} }, { tool: 'pencil', source: ['unavailable'] }]) {
|
|
316
|
+
const r = designPreflight({ state: 'ok', data }, links, frames);
|
|
317
|
+
assert.ok(r && ['check', 'not-checkable'].includes(r.reachable), JSON.stringify(data));
|
|
318
|
+
}
|
|
319
|
+
const dirty = designPreflight({ state: 'ok', data: { tool: 'pencil' } }, { state: 'ok', fileUrl: 'a\x1b[31mb', screens: [] }, frames);
|
|
320
|
+
assert.ok(!dirty.stop.includes('\x1b') && !dirty.probe.includes('\x1b'));
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
test('#358: readDesignConfig, the reach data, and preflight through the command', () => {
|
|
324
|
+
for (const t of TOOLBOX.filter((x) => x.reach)) assert.deepEqual(toolProblems(t), [], t.id);
|
|
325
|
+
const figma = TOOLBOX.find((x) => x.id === 'figma');
|
|
326
|
+
assert.deepEqual(toolProblems({ ...figma, reach: { app: 'F', probe: 'p', open: 'o', readers: true, appBound: ['x'] } }), ['reach.either says what to do when yad cannot tell whether the provider needs the app']);
|
|
327
|
+
assert.deepEqual(toolProblems({ ...figma, reach: { app: 'F', probe: 'p', open: 'o', appBound: ['x'], either: 'e', signInOnly: ['y'] } }), ['reach.signIn says what to do for a provider in signInOnly']);
|
|
328
|
+
// E164: a local provider (a CLI on the file) carries its own probe and stop text.
|
|
329
|
+
const op = TOOLBOX.find((x) => x.id === 'openpencil');
|
|
330
|
+
assert.deepEqual(toolProblems({ ...op, reach: { ...op.reach, localStop: undefined } }), ['reach.localProbe and reach.localStop say how to check a provider in local, and what to do when that fails']);
|
|
331
|
+
assert.deepEqual(toolProblems({ ...op, reach: { ...op.reach, local: 'openpencil-cli' } }), ['reach.local is absent or a list of providers']);
|
|
332
|
+
assert.deepEqual(toolProblems({ ...figma, reach: { ...figma.reach, ownServer: [1] } }), ['reach.ownServer is absent or a list of providers']);
|
|
333
|
+
assert.deepEqual(toolProblems({ ...op, reach: { ...op.reach, eitherProbe: '' } }), ['reach.eitherProbe is absent or how to check when yad cannot tell the provider']);
|
|
334
|
+
assert.deepEqual(toolProblems({ ...op, reach: { ...op.reach, local: ['openpencil-mcp'] } }), ['a provider is in reach.local or reach.appBound, not both']);
|
|
335
|
+
assert.deepEqual(toolProblems({ ...op, reach: { ...op.reach, local: ['OpenPencil_MCP'] } }), ['a provider is in reach.local or reach.appBound, not both'], 'review 2: compared as the preflight compares them');
|
|
336
|
+
assert.ok(toolProblems({ ...figma, reach: { readers: true, appBound: true } }).includes('reach has app, probe and open'));
|
|
337
|
+
assert.ok(toolProblems({ ...figma, reach: null }).length > 0);
|
|
338
|
+
assert.ok(toolProblems({ ...figma, reach: { ...figma.reach, appBound: false } }).includes('reach.appBound is true, or the providers read through the app'));
|
|
339
|
+
assert.equal(reachFor('repomix'), null);
|
|
340
|
+
const T = product({ 'EP-shop-S01': `${FRAMES_KEY}: [12:34]`, 'EP-shop-S02': `${FRAMES_KEY}: []` });
|
|
341
|
+
try {
|
|
342
|
+
assert.equal(readDesignConfig(T).state, 'missing');
|
|
343
|
+
put(path.join(T, '.sdlc', 'design.json'), '{ nope');
|
|
344
|
+
assert.equal(readDesignConfig(T).state, 'unreadable');
|
|
345
|
+
put(path.join(T, '.sdlc', 'design.json'), { tool: 'pencil', provider: 'pencil-mcp', source: 'pencil-mcp', auth: 'user' });
|
|
346
|
+
const j = JSON.parse(yad(T, 'story', 'frames', 'EP-shop-S01', '--json').stdout);
|
|
347
|
+
assert.deepEqual([j.preflight.reachable, j.preflight.tool, j.preflight.appBound], ['check', 'pencil', true]);
|
|
348
|
+
assert.match(yad(T, 'story', 'frames', 'EP-shop-S01').stdout, /before UI work: .* if that fails, stop: Open the Pencil desktop app[\s\S]*if pencil is not on this machine at all, your agent can offer to connect it first: `yad toolbox connect pencil --json`/);
|
|
349
|
+
assert.equal(j.preflight.connect, 'yad toolbox connect pencil --json');
|
|
350
|
+
// Review 2: no `connect`, no offer line — Figma's desktop server is opened, never connected.
|
|
351
|
+
put(path.join(T, '.sdlc', 'design.json'), { tool: 'figma', provider: 'figma-desktop', source: 'figma-desktop', auth: 'user' });
|
|
352
|
+
put(path.join(T, 'epics', 'EP-shop', '.sdlc', 'design-links.json'), { ...LINKS, tool: 'figma', source: 'figma' });
|
|
353
|
+
const desk = yad(T, 'story', 'frames', 'EP-shop-S01');
|
|
354
|
+
assert.match(desk.stdout, /before UI work: .* if that fails, stop: .*Figma desktop app/);
|
|
355
|
+
assert.doesNotMatch(desk.stdout, /offer to connect/);
|
|
356
|
+
// E164: OpenPencil's CLI — the local probe and stop, and the connect offer.
|
|
357
|
+
put(path.join(T, '.sdlc', 'design.json'), { tool: 'openpencil', provider: 'openpencil-cli', source: 'openpencil-cli', auth: 'user' });
|
|
358
|
+
put(path.join(T, 'epics', 'EP-shop', '.sdlc', 'design-links.json'), { ...LINKS, tool: 'openpencil', source: 'openpencil-cli' });
|
|
359
|
+
const opj = JSON.parse(yad(T, 'story', 'frames', 'EP-shop-S01', '--json').stdout).preflight;
|
|
360
|
+
assert.deepEqual([opj.reachable, opj.appBound, opj.local, opj.connect], ['check', false, true, 'yad toolbox connect openpencil --json']);
|
|
361
|
+
assert.match(yad(T, 'story', 'frames', 'EP-shop-S01').stdout, /before UI work: check that .* `openpencil --version` runs.* if that fails, stop: Pull the Product[\s\S]*offer to connect it first: `yad toolbox connect openpencil --json`/);
|
|
362
|
+
assert.equal(JSON.parse(yad(T, 'story', 'frames', 'EP-shop-S02', '--json').stdout).preflight, null, 'no screens, no probe');
|
|
363
|
+
} finally { done(T); }
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
test('#354: the stories, spec and implement skills all name `yad story frames`', () => {
|
|
367
|
+
for (const skill of ['yad-stories', 'yad-spec', 'yad-implement']) {
|
|
368
|
+
const body = fs.readFileSync(path.join(REPO, 'skills', skill, 'SKILL.md'), 'utf8');
|
|
369
|
+
assert.ok(body.includes('yad story frames'), `${skill} does not read the story's frames`);
|
|
370
|
+
}
|
|
371
|
+
const schema = fs.readFileSync(path.join(REPO, 'skills', 'yad-stories', 'references', 'story-schema.md'), 'utf8');
|
|
372
|
+
assert.ok(schema.includes(FRAMES_KEY), 'the story schema names the key');
|
|
373
|
+
const template = fs.readFileSync(path.join(REPO, 'skills', 'yad-stories', 'SKILL.md'), 'utf8');
|
|
374
|
+
assert.match(template, new RegExp(`^${FRAMES_KEY}: \\[\\]$`, 'm'), 'the template ships the key bare, with no trailing comment');
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
test('#358: spec and implement probe the design tool first, stop on a failure, and record an override', () => {
|
|
378
|
+
for (const [skill, where] of [['yad-spec', '## Clarifications'], ['yad-implement', 'Decisions:']]) {
|
|
379
|
+
const body = fs.readFileSync(path.join(REPO, 'skills', skill, 'SKILL.md'), 'utf8');
|
|
380
|
+
for (const word of ['preflight.probe', 'not-checkable', where]) assert.ok(body.includes(word), `${skill} lacks ${word}`);
|
|
381
|
+
assert.match(body, /STOP\W+print `preflight\.stop` word for word/i, `${skill} does not stop with the message`);
|
|
382
|
+
}
|
|
383
|
+
const ctx = fs.readFileSync(path.join(REPO, 'skills', 'yad-connect-design', 'references', 'design-context.md'), 'utf8');
|
|
384
|
+
assert.ok(ctx.includes('Reachable before Build (#358)'));
|
|
385
|
+
const connect = fs.readFileSync(path.join(REPO, 'skills', 'yad-connect-design', 'SKILL.md'), 'utf8');
|
|
386
|
+
for (const p of ['figma-desktop', '`figma`', 'html-to-design']) assert.ok(connect.includes(p), `yad-connect-design does not name the ${p} provider`);
|
|
387
|
+
const example = connect.slice(connect.indexOf('### Step 2'), connect.indexOf('### Step 3'));
|
|
388
|
+
assert.ok(example.includes('"provider": "figma-desktop"') && !example.includes('figma-mcp'), 'the registry example records a provider the preflight can read');
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
test('E164 PR 2: the skills give each OpenPencil frame yad\'s own ID, fold takes design/, and the probe may be a CLI command', () => {
|
|
392
|
+
const read = (rel) => fs.readFileSync(path.join(REPO, rel), 'utf8');
|
|
393
|
+
const ui = read('skills/yad-ui/SKILL.md');
|
|
394
|
+
const ctx = read('skills/yad-connect-design/references/design-context.md');
|
|
395
|
+
for (const [name, text] of [['yad-ui', ui], ['design-context', ctx]]) {
|
|
396
|
+
assert.match(text, /setSharedPluginData\('yad', 'nodeId', '<id>'\)/, `${name}: yad stores its own ID on the frame`);
|
|
397
|
+
assert.match(text, /getSharedPluginData\('yad', 'nodeId'\) === '<id>'/, `${name}: and finds the frame by it`);
|
|
398
|
+
assert.match(text, /`yad fold` (takes that folder too|commits the\s+`design\/` folder)/, `${name}: fold takes design/`);
|
|
399
|
+
assert.doesNotMatch(text, /not taken by `yad fold` yet|Until E164's second PR/, `${name}: no note from before PR 2`);
|
|
400
|
+
}
|
|
401
|
+
assert.match(ui, /each screen's `nodeId` is the ID yad stored on its frame/);
|
|
402
|
+
assert.match(ctx, /\| `openpencil`, provider `openpencil-cli` \|/);
|
|
403
|
+
assert.doesNotMatch(ctx, /not checked yet: yad has no reach rule/);
|
|
404
|
+
for (const skill of ['yad-spec', 'yad-implement']) {
|
|
405
|
+
const text = read(`skills/${skill}/SKILL.md`);
|
|
406
|
+
assert.match(text, /make the check `preflight\.probe`\s+describes \(an MCP call, or for a tool's\s+CLI — `preflight\.local` is true — a command in your terminal\)/, skill);
|
|
407
|
+
assert.doesNotMatch(text, /make the MCP call/, skill);
|
|
408
|
+
}
|
|
409
|
+
});
|