yadflow 4.6.0 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/CHANGELOG.md +170 -0
  2. package/README.md +4 -1
  3. package/bin/commands.mjs +5 -1
  4. package/bin/yad.mjs +167 -15
  5. package/cli/artifact-status.mjs +88 -20
  6. package/cli/build.mjs +1372 -0
  7. package/cli/checkpoint.mjs +2 -2
  8. package/cli/commit.mjs +1 -0
  9. package/cli/dial.mjs +21 -1
  10. package/cli/docs.mjs +6 -1
  11. package/cli/doctor.mjs +133 -26
  12. package/cli/epic-state.mjs +357 -9
  13. package/cli/errors.mjs +2 -0
  14. package/cli/find-product.mjs +36 -2
  15. package/cli/fold.mjs +9 -5
  16. package/cli/gate-local.mjs +9 -1
  17. package/cli/gate.mjs +364 -22
  18. package/cli/history.mjs +22 -2
  19. package/cli/hook.mjs +3 -1
  20. package/cli/index-command.mjs +2 -2
  21. package/cli/ledger.mjs +60 -0
  22. package/cli/next.mjs +34 -11
  23. package/cli/openpr.mjs +81 -5
  24. package/cli/platform.mjs +21 -0
  25. package/cli/pr-list.mjs +5 -3
  26. package/cli/product-index.mjs +6 -3
  27. package/cli/product-token.mjs +186 -0
  28. package/cli/productcommit.mjs +33 -0
  29. package/cli/recommend.mjs +3 -1
  30. package/cli/repo-publish.mjs +2 -2
  31. package/cli/run-checks.mjs +586 -0
  32. package/cli/ship-drift.mjs +49 -18
  33. package/cli/standup.mjs +1 -1
  34. package/cli/status.mjs +282 -0
  35. package/cli/test-build.mjs +1559 -0
  36. package/cli/test-run-checks.mjs +603 -0
  37. package/cli/test-worktree.mjs +520 -0
  38. package/cli/thread.mjs +4 -0
  39. package/cli/tidy.mjs +2 -2
  40. package/cli/toolbox.mjs +36 -5
  41. package/cli/workspace.mjs +4 -1
  42. package/cli/worktree-record.mjs +53 -0
  43. package/cli/worktree.mjs +379 -0
  44. package/package.json +3 -3
  45. package/skills/sdlc/config.yaml +1 -1
  46. package/skills/sdlc/module-help.csv +1 -1
  47. package/skills/yad-backfill/templates/checks/backfill-check.sh +9 -9
  48. package/skills/yad-change/SKILL.md +3 -0
  49. package/skills/yad-checks/SKILL.md +34 -5
  50. package/skills/yad-checks/references/check-gates.md +69 -10
  51. package/skills/yad-checks/templates/checks/build-test-lint.sh +22 -3
  52. package/skills/yad-checks/templates/checks/commit-message.sh +8 -2
  53. package/skills/yad-checks/templates/checks/contract-check.sh +61 -33
  54. package/skills/yad-checks/templates/checks/epic-open.sh +87 -14
  55. package/skills/yad-checks/templates/checks/ledger-guard.sh +3 -3
  56. package/skills/yad-checks/templates/checks/lineage-check.sh +88 -15
  57. package/skills/yad-checks/templates/checks/member-check.mjs +206 -35
  58. package/skills/yad-checks/templates/checks/package-manager.sh +41 -4
  59. package/skills/yad-checks/templates/checks/product-checkout.sh +161 -13
  60. package/skills/yad-checks/templates/checks/reconcile-debt-check.sh +94 -15
  61. package/skills/yad-checks/templates/checks/risk-map-check.sh +2 -2
  62. package/skills/yad-checks/templates/checks/spec-link.sh +63 -4
  63. package/skills/yad-checks/templates/checks/verified-commits.sh +23 -5
  64. package/skills/yad-checks/templates/github/yad-checks.yml +8 -8
  65. package/skills/yad-checks/templates/gitlab/.gitlab-ci.yml +3 -0
  66. package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +4 -4
  67. package/skills/yad-checks/templates/gitlab/yad-product-checks.gitlab-ci.yml +16 -3
  68. package/skills/yad-checks/templates/gitlab/yad-update-guard.gitlab-ci.yml +5 -1
  69. package/skills/yad-checks/templates/gitlab/yad-verified-commits.gitlab-ci.yml +5 -1
  70. package/skills/yad-commit/SKILL.md +4 -2
  71. package/skills/yad-docs/templates/app/package-lock.json +395 -106
  72. package/skills/yad-docs/templates/app/package.json +2 -2
  73. package/skills/yad-engineer-review/SKILL.md +45 -20
  74. package/skills/yad-engineer-review/references/ship-and-record.md +42 -8
  75. package/skills/yad-epic/references/state-schema.md +75 -16
  76. package/skills/yad-implement/SKILL.md +75 -13
  77. package/skills/yad-implement/references/implement-conventions.md +8 -1
  78. package/skills/yad-implement/templates/.gitmessage +3 -0
  79. package/skills/yad-open-pr/SKILL.md +21 -0
  80. package/skills/yad-pr-template/SKILL.md +6 -2
  81. package/skills/yad-pr-template/templates/checks/pr-template.sh +85 -4
  82. package/skills/yad-pr-template/templates/checks/pr-title.sh +1 -1
  83. package/skills/yad-pr-template/templates/github/pull_request_template.md +1 -1
  84. package/skills/yad-pr-template/templates/gitlab/merge_request_templates/Default.md +1 -1
  85. package/skills/yad-product-bridge/SKILL.md +14 -1
  86. package/skills/yad-product-bridge/references/bridge.md +5 -2
  87. package/skills/yad-product-bridge/templates/gitlab/yad-gate-sync.gitlab-ci.yml +9 -4
  88. package/skills/yad-reconcile/SKILL.md +9 -3
  89. package/skills/yad-review-gate/SKILL.md +4 -0
  90. package/skills/yad-review-gate/references/gating.md +26 -1
  91. package/skills/yad-run/SKILL.md +52 -28
  92. package/skills/yad-run/references/run-loop.md +42 -21
  93. package/skills/yad-spec/SKILL.md +137 -16
  94. package/skills/yad-spec/references/spec-handoff.md +50 -3
  95. package/skills/yad-status/SKILL.md +7 -0
  96. package/skills/yad-stories/references/story-schema.md +1 -1
@@ -0,0 +1,186 @@
1
+ // #345 — where a connected code repo's CI gets `YAD_PRODUCT_TOKEN`, the token `checks/product-checkout.sh`
2
+ // clones the Product with before the four Product-reading gates. Without it those gates only defer, so a
3
+ // token that is missing, or set where the PR pipelines never see it, goes quiet. `yad doctor` asks the
4
+ // platform, with the user's own `gh`/`glab` (the E70 reads in cli/protection.mjs, and the same
5
+ // `YAD_PLATFORM_READ=0` off switch), and reports:
6
+ // - whether the code repo has the secret (GitHub: an Actions secret on the repo, or an organisation
7
+ // secret shared with it; GitLab: a CI/CD variable on the project, or on one of its groups);
8
+ // - on GitLab, a variable that MR pipelines never get: `protected` (only protected branches get it) or
9
+ // limited to one environment;
10
+ // - on GitLab, a token set on a GROUP — every project in that group then gets a token that reads the
11
+ // Product (the user's decision, 2026-10-19: that is the "wrong level"), with the other registered
12
+ // repos in that group named;
13
+ // - on a GitLab Product, its own access tokens that can clone it and expire within 30 days. Which of them
14
+ // is the one in a code repo's variable is never known here, and the line says so.
15
+ // NAMES ONLY. A token's value never reaches this machine from GitHub (its API lists secret names), but
16
+ // GitLab's variables API answers with each variable's value: the answer is cut down to key, `protected`
17
+ // and `environment_scope` at the call, and nothing else of it is kept or printed. The token's own expiry
18
+ // is read where the token is — in CI, by product-checkout.sh.
19
+ import { run } from './lib.mjs';
20
+ import { api, loggedIn, whyFailed, repoPathFromGitUrl, shown, PAGE, PLATFORM_NAME } from './protection.mjs';
21
+ import { cliFor, hostFromGitUrl, detectPlatform, plainHost } from './platform.mjs';
22
+
23
+ export const TOKEN_NAME = 'YAD_PRODUCT_TOKEN';
24
+ export const EXPIRY_WARN_DAYS = 30;
25
+
26
+ const enc = (p) => encodeURIComponent(p);
27
+
28
+ // The parts every platform read shares: which CLI, which host, which repo, and whether it may be asked.
29
+ function target({ platform, gitUrl }, { runner, env, authCache }) {
30
+ const rawHost = hostFromGitUrl(gitUrl || '');
31
+ const host = plainHost(rawHost);
32
+ const repo = repoPathFromGitUrl(gitUrl || '');
33
+ const plat = platform || detectPlatform(gitUrl || '') || null;
34
+ const base = { platform: plat, host, repo };
35
+ const unknown = (kind, why) => ({ ...base, known: false, kind, why });
36
+ const cli = cliFor(plat);
37
+ if (!cli) return { fail: unknown('no-platform', 'no platform yad reads (GitHub or GitLab) is set for it') };
38
+ if (env.YAD_PLATFORM_READ === '0') return { fail: unknown('off', 'platform reads are turned off (YAD_PLATFORM_READ=0)') };
39
+ if (rawHost && !host) return { fail: unknown('no-url', 'its git remote URL names a host that is not a plain host name, so yad does not ask about it') };
40
+ if (!host || !repo) return { fail: unknown('no-url', 'no git remote URL yad can read, so it cannot tell which repo to ask about') };
41
+ if (!runner(process.platform === 'win32' ? 'where' : 'which', [cli], {}).ok) return { fail: unknown('no-cli', `${cli} is not installed, so yad cannot ask ${PLATFORM_NAME[plat]}`) };
42
+ if (!loggedIn(runner, cli, host, authCache)) return { fail: unknown('no-login', `${cli} is not logged in for ${host} (or ${host} did not answer)`) };
43
+ return { base, cli, unknown };
44
+ }
45
+
46
+ // GitLab variables, cut down at the call to what may be kept: never the value.
47
+ const gitlabVars = (body) => (Array.isArray(body) ? body : [])
48
+ .filter((v) => v && v.key === TOKEN_NAME)
49
+ .map((v) => ({ protected: v.protected === true, scope: typeof v.environment_scope === 'string' ? v.environment_scope : '*' }));
50
+
51
+ // Where the code repo's CI gets the token. `{ known: false, why, kind }` when the repo's own list could not
52
+ // be read; otherwise `{ known: true, platform, project, org | groups }`, where each place is
53
+ // GitHub project: { set } org: { set: true|false|null, why }
54
+ // GitLab project: { set, vars: [{ protected, scope }] }
55
+ // groups: [{ path, set: true|false|null, vars, why }] — nearest group first
56
+ export function readTokenPlacement({ platform, gitUrl }, { runner = run, env = process.env, authCache = new Map() } = {}) {
57
+ const t = target({ platform, gitUrl }, { runner, env, authCache });
58
+ if (t.fail) return t.fail;
59
+ const { base, unknown } = t;
60
+ const { host, repo } = base;
61
+ if (base.platform === 'github') {
62
+ const what = `the Actions secrets of ${shown(repo)}`;
63
+ const r = api(runner, 'gh', host, `repos/${repo}/actions/secrets?per_page=${PAGE}`);
64
+ if (!r.ok || !Array.isArray(r.body?.secrets)) return unknown('other', r.ok ? `GitHub answered ${what} with something yad could not read` : whyFailed(r, { platform: 'github', host, what, plural: true }));
65
+ const set = r.body.secrets.some((s) => s?.name === TOKEN_NAME);
66
+ // A full page that does not hold the name proves nothing about the next one.
67
+ if (!set && r.body.secrets.length >= PAGE) return unknown('partial', `${shown(repo)} has more than ${PAGE} Actions secrets, and yad reads one page`);
68
+ if (set) return { ...base, known: true, project: { set: true } };
69
+ const o = api(runner, 'gh', host, `repos/${repo}/actions/organization-secrets?per_page=${PAGE}`);
70
+ const orgRead = o.ok && Array.isArray(o.body?.secrets);
71
+ const orgSet = orgRead ? o.body.secrets.some((s) => s?.name === TOKEN_NAME) : null;
72
+ const orgWhy = orgRead ? (!orgSet && o.body.secrets.length >= PAGE ? `it shares more than ${PAGE}, and yad reads one page` : null)
73
+ : (o.ok ? 'GitHub answered with something yad could not read' : whyFailed(o, { platform: 'github', host, what: 'the organisation secrets shared with it', plural: true }));
74
+ return { ...base, known: true, project: { set: false }, org: { set: orgWhy ? null : orgSet, why: orgWhy } };
75
+ }
76
+ const what = `the CI/CD variables of ${shown(repo)}`;
77
+ const r = api(runner, 'glab', host, `projects/${enc(repo)}/variables?per_page=${PAGE}`);
78
+ if (!r.ok || !Array.isArray(r.body)) return unknown('other', r.ok ? `GitLab answered ${what} with something yad could not read` : whyFailed(r, { platform: 'gitlab', host, what, plural: true }));
79
+ const vars = gitlabVars(r.body);
80
+ if (!vars.length && r.body.length >= PAGE) return unknown('partial', `${shown(repo)} has more than ${PAGE} CI/CD variables, and yad reads one page`);
81
+ // Its groups, nearest first: `a/b/c` is in `a/b`, which is in `a`. A group's variable reaches every
82
+ // project under it. Reading a group's variables needs a maintainer or owner there.
83
+ const parts = repo.split('/');
84
+ const groups = [];
85
+ // A project in a user's own namespace (`someone/app`) has no groups. The project's own answer says whose
86
+ // namespace it is, and anyone who can read its variables can read it — `namespaces/<user>` answers 404
87
+ // to all but that user and an admin (review 2).
88
+ const proj = api(runner, 'glab', host, `projects/${enc(repo)}`);
89
+ const userNs = proj.ok && proj.body?.namespace?.kind === 'user';
90
+ for (let i = userNs ? 0 : parts.length - 1; i >= 1; i--) {
91
+ const g = parts.slice(0, i).join('/');
92
+ const gr = api(runner, 'glab', host, `groups/${enc(g)}/variables?per_page=${PAGE}`);
93
+ if (!gr.ok || !Array.isArray(gr.body)) {
94
+ groups.push({ path: g, set: null, vars: [], why: gr.ok ? 'GitLab answered with something yad could not read' : whyFailed(gr, { platform: 'gitlab', host, what: `the CI/CD variables of the group ${shown(g)}`, plural: true }) });
95
+ continue;
96
+ }
97
+ const gv = gitlabVars(gr.body);
98
+ const full = !gv.length && gr.body.length >= PAGE;
99
+ groups.push({ path: g, set: full ? null : gv.length > 0, vars: gv, why: full ? `it has more than ${PAGE} CI/CD variables, and yad reads one page` : null });
100
+ }
101
+ return { ...base, known: true, project: { set: vars.length > 0, vars }, groups };
102
+ }
103
+
104
+ // What a set of GitLab variables misses: MR pipelines on unprotected branches never get a protected one,
105
+ // and get an environment-scoped one only in a job that names that environment (the gate jobs name none).
106
+ function reachProblem(vars) {
107
+ if (!vars.length) return null;
108
+ if (vars.some((v) => !v.protected && v.scope === '*')) return null;
109
+ if (vars.every((v) => v.protected)) return 'it is a PROTECTED variable, which only pipelines on protected branches get — so no merge request from a feature branch does';
110
+ return `it is limited to the environment ${vars.filter((v) => v.scope !== '*').map((v) => shown(v.scope)).join(', ')}, which the gate jobs do not name — so they never get it`;
111
+ }
112
+ const UNPROTECT = 'Settings → CI/CD → Variables: edit it, untick "Protect variable", keep "Mask variable", and set the environment to All (*)';
113
+
114
+ // One doctor line for one code repo: { status, message, hint }. `others(groupPath)` names the other
115
+ // registered repos in that group.
116
+ export function tokenLine(r, { name, others = () => [] } = {}) {
117
+ const who = name;
118
+ // A warn, as E70's "not known" is: doctor prints ok, warn and fail only (review 1).
119
+ if (!r.known) return { status: 'warn', message: `${who}: whether ${TOKEN_NAME} is set for its CI is not known — ${r.why}` };
120
+ const defer = 'contract-check, lineage-check, epic-open and reconcile-debt-check cannot read the Product there and only defer';
121
+ if (r.platform === 'github') {
122
+ if (r.project.set) return { status: 'ok', message: `${who}: ${TOKEN_NAME} is set as an Actions secret` };
123
+ if (r.org.set === true) return { status: 'ok', message: `${who}: ${TOKEN_NAME} comes from an organisation secret shared with it` };
124
+ const add = `add a token that can read the Product: gh secret set ${TOKEN_NAME} --repo ${shown(r.repo)}`;
125
+ if (r.org.set === null) return { status: 'warn', message: `${who}: ${TOKEN_NAME} is not an Actions secret of the repo, and the organisation secrets shared with it could not be read (${r.org.why}) — unless it is one of those, ${defer} on every PR`, hint: add };
126
+ return { status: 'warn', message: `${who}: ${TOKEN_NAME} is not set for its CI — ${defer} on every PR`, hint: add };
127
+ }
128
+ const groupSet = r.groups.filter((g) => g.set === true);
129
+ const unread = r.groups.filter((g) => g.set === null);
130
+ const groupNote = (g) => {
131
+ const also = others(g.path);
132
+ return `the group ${shown(g.path)} also sets ${TOKEN_NAME}, so every project in it gets a token that can read the Product${also.length ? ` (registered here: ${also.join(', ')})` : ''}`;
133
+ };
134
+ if (r.project.set) {
135
+ const miss = reachProblem(r.project.vars);
136
+ if (miss) return { status: 'warn', message: `${who}: ${TOKEN_NAME} is set on the project, but ${miss} and ${defer} on them`, hint: UNPROTECT };
137
+ if (groupSet.length) return { status: 'warn', message: `${who}: ${TOKEN_NAME} is set on the project, and ${groupNote(groupSet[0])}`, hint: `remove it from the group's CI/CD variables (Settings → CI/CD → Variables of ${shown(groupSet[0].path)}) unless every project there should read the Product` };
138
+ return { status: 'ok', message: `${who}: ${TOKEN_NAME} is set on the project` };
139
+ }
140
+ if (groupSet.length) {
141
+ const g = groupSet[0];
142
+ const miss = reachProblem(g.vars);
143
+ const also = others(g.path);
144
+ return {
145
+ status: 'warn',
146
+ message: `${who}: ${TOKEN_NAME} comes from the group ${shown(g.path)}, so every project in that group gets a token that can read the Product${also.length ? ` (registered here: ${also.join(', ')})` : ''}${miss ? `; and ${miss}` : ''}`,
147
+ hint: `set it on the project instead (Settings → CI/CD → Variables: masked, not protected, all environments), then remove it from the group ${shown(g.path)}`,
148
+ };
149
+ }
150
+ const add = `add a token that can read the Product as the ${TOKEN_NAME} CI/CD variable of ${shown(r.repo)} (Settings → CI/CD → Variables: masked, not protected, all environments)`;
151
+ if (unread.length) {
152
+ return { status: 'warn', message: `${who}: ${TOKEN_NAME} is not set on the project, and ${unread.length === 1 ? `the group ${shown(unread[0].path)} could` : `the groups ${unread.map((g) => shown(g.path)).join(', ')} could`} not be read (${unread[0].why}) — unless it is set there, ${defer} on every merge request`, hint: add };
153
+ }
154
+ return { status: 'warn', message: `${who}: ${TOKEN_NAME} is not set on the project or its groups — ${defer} on every merge request`, hint: add };
155
+ }
156
+
157
+ // A GitLab Product's own access tokens that can clone it and expire within EXPIRY_WARN_DAYS, or expired
158
+ // within the last EXPIRY_WARN_DAYS. `today` is
159
+ // YYYY-MM-DD (injectable for tests). `{ known: false, why }`, or `{ known: true, soon: [{ name, expires,
160
+ // days, scopes }] }`.
161
+ export function readExpiringProductTokens({ gitUrl }, { runner = run, env = process.env, authCache = new Map(), today = new Date().toISOString().slice(0, 10) } = {}) {
162
+ const t = target({ platform: 'gitlab', gitUrl }, { runner, env, authCache });
163
+ if (t.fail) return t.fail;
164
+ const { base, unknown } = t;
165
+ const what = `the access tokens of ${shown(base.repo)}`;
166
+ const r = api(runner, 'glab', base.host, `projects/${enc(base.repo)}/access_tokens?per_page=${PAGE}`);
167
+ if (!r.ok || !Array.isArray(r.body)) return unknown('other', r.ok ? `GitLab answered ${what} with something yad could not read` : whyFailed(r, { platform: 'gitlab', host: base.host, what, plural: true }));
168
+ const day = (d) => Date.parse(`${d}T00:00:00Z`) / 864e5;
169
+ const soon = [];
170
+ for (const tok of r.body) {
171
+ // An EXPIRED token is listed with `active: false`: kept, so doctor says it expired (review 1). Only a
172
+ // revoked one is gone on purpose.
173
+ if (!tok || tok.revoked === true) continue;
174
+ const scopes = Array.isArray(tok.scopes) ? tok.scopes.filter((s) => typeof s === 'string') : [];
175
+ if (!scopes.some((s) => s === 'read_repository' || s === 'api')) continue;
176
+ const exp = typeof tok.expires_at === 'string' && /^\d{4}-\d{2}-\d{2}/.test(tok.expires_at) ? tok.expires_at.slice(0, 10) : null;
177
+ if (!exp) continue;
178
+ const days = Math.round(day(exp) - day(today));
179
+ // Within 30 days either side: one that expired long ago is no news, and GitLab offers no way to remove
180
+ // an expired token from its list, so a line about it could never be cleared (review 3).
181
+ if (days <= EXPIRY_WARN_DAYS && days >= -EXPIRY_WARN_DAYS) soon.push({ id: Number.isInteger(tok.id) ? tok.id : null, name: typeof tok.name === 'string' ? tok.name : `#${tok.id}`, expires: exp, days, scopes });
182
+ }
183
+ // A full page proves nothing about the tokens past it (review 1).
184
+ if (r.body.length >= PAGE) return unknown('partial', `${shown(base.repo)} has more than ${PAGE} access tokens, and yad reads one page`);
185
+ return { ...base, known: true, soon };
186
+ }
@@ -4,6 +4,7 @@
4
4
  // strand required checks and fail verified-commits). This module is the single home of that guard.
5
5
  import { warn, fail, hand, run, forTerminal } from './lib.mjs';
6
6
  import { SETTINGS_EDIT_HINT, settingsEditHint } from './manifest.mjs';
7
+ import { worktreeAt } from './worktree-record.mjs';
7
8
 
8
9
  export const productGit = (root) => (...args) => run('git', args, { cwd: root });
9
10
 
@@ -30,6 +31,32 @@ export function resolveDefaultBranch(git, productConfig) {
30
31
  || 'main';
31
32
  }
32
33
 
34
+ // The branch a default-branch command commits on: the current one — or, in an epic's Product worktree
35
+ // (#115), which sits DETACHED because the default branch is checked out in the main tree, the default
36
+ // branch itself, so the commit is pushed as HEAD:<default>. Only when every commit HEAD holds that the
37
+ // default branch lacks (fetched first) is one of yad's own default-branch commits — each subject is
38
+ // `chore(product|gate): … [skip ci]`, so a `Revert "…"` of one, or a step's commit, is not. One a run made
39
+ // without --push, or whose push failed, is pushed by the next run, as in the main checkout. Anything else (a step's unreviewed work) must never reach the default branch. A detached
40
+ // HEAD anywhere else stays 'HEAD', and the guard below refuses it as before.
41
+ // `fetch: false` judges by the local origin/<default> — for a caller that writes a derived file and pushes
42
+ // nothing (the index refresh): a stale or missing ref can only make it skip — unless the default branch
43
+ // was rewound — and it asks no network.
44
+ export function branchToCommitOn(root, git, defaultBranch, { fetch = true } = {}) {
45
+ const branch = git('rev-parse', '--abbrev-ref', 'HEAD').stdout;
46
+ return branch === 'HEAD' && worktreeAt(root)?.repo === null && onlyYadCommitsAhead(git, defaultBranch, { fetch }) ? defaultBranch : branch;
47
+ }
48
+
49
+ // The subject every yad default-branch commit has (checkpoint, tidy, repo refresh, gate ci/repair/reopen).
50
+ export const YAD_COMMIT_SUBJECT = /^chore\((product|gate)\): .* \[skip ci\]$/;
51
+ // HEAD holds nothing origin/<default> lacks but yad's own `[skip ci]` commits. False when the fetch or the
52
+ // read fails: unknown is not safe.
53
+ export function onlyYadCommitsAhead(git, defaultBranch, { fetch = true } = {}) {
54
+ if (fetch && !git('fetch', '--quiet', 'origin', `+refs/heads/${defaultBranch}:refs/remotes/origin/${defaultBranch}`).ok) return false;
55
+ const ahead = git('log', '--format=%s', `origin/${defaultBranch}..HEAD`);
56
+ if (!ahead.ok) return false;
57
+ return ahead.stdout.split('\n').filter(Boolean).every((s) => YAD_COMMIT_SUBJECT.test(s));
58
+ }
59
+
33
60
  // Guard: only commit on the default branch. Returns true when OK; on a non-default branch it prints the
34
61
  // refusal + sets a non-zero exit code, unless `allowBranch` overrides (with a warning). `--allow-branch`
35
62
  // is the SINGLE documented override — never `--force` (which elsewhere only waives the atomic guard).
@@ -43,6 +70,12 @@ export function guardDefaultBranch(branch, defaultBranch, { allowBranch = false,
43
70
  return true;
44
71
  }
45
72
  fail(`on '${b}', not the default branch '${d}' — ${cmd} commits go to the default branch to stay out of PR-checked ranges`);
73
+ // An epic worktree (#115) refused here holds commits origin/<default> lacks, or could not fetch it.
74
+ if (branch === 'HEAD' && root && worktreeAt(root)?.repo === null) {
75
+ hand(`this epic worktree's HEAD has commits origin/${d} does not that are not yad's own (or the fetch failed) — a step's work goes on its branch and through review: \`git switch -c <step>/<epic>\` keeps it, then \`git fetch origin ${d}\` and \`git switch --detach origin/${d}\``);
76
+ process.exitCode = 1;
77
+ return false;
78
+ }
46
79
  hand(`switch to '${d}' and re-run, or pass --allow-branch to override (if '${d}' is wrong, set default_branch in ${root ? settingsEditHint(root) : SETTINGS_EDIT_HINT})`);
47
80
  process.exitCode = 1;
48
81
  return false;
package/cli/recommend.mjs CHANGED
@@ -142,7 +142,9 @@ export const RECOMMENDATIONS = Object.freeze([
142
142
 
143
143
  // ---- checking an entry ------------------------------------------------------------------------------
144
144
 
145
- const POOLS = () => TOOLBOX.filter((t) => t.tier === 'recommended').map((t) => t.id);
145
+ // The skill pools: the recommended tools `yad skill bind` takes skills from. Docker MCP is recommended too,
146
+ // but it is a gateway, not a pool (#361).
147
+ const POOLS = () => TOOLBOX.filter((t) => t.tier === 'recommended' && t.usedBy.includes('yad skill bind')).map((t) => t.id);
146
148
  const bindable = (step) => !!stepDef(step)?.skill && STEPS.some((s) => s.id === step);
147
149
 
148
150
  // Every way an entry is malformed, as sentences; [] means it is well formed. The vetting record is
@@ -20,7 +20,7 @@ import { c, ok, info, fail, hand, exists, pushWithRebase, forTerminal } from './
20
20
  import { PROJECT_FILES , productConfigPath } from './manifest.mjs';
21
21
  import { loadProduct } from './gate.mjs';
22
22
  import { platformLogin } from './platform.mjs';
23
- import { productGit, resolveDefaultBranch, guardDefaultBranch, preflightGuardReadiness } from './productcommit.mjs';
23
+ import { productGit, resolveDefaultBranch, guardDefaultBranch, preflightGuardReadiness, branchToCommitOn } from './productcommit.mjs';
24
24
  import { ensurePackIgnored, PACK_IGNORE_BLOCK } from './setup.mjs';
25
25
  import { checkpointAuthor } from './checkpoint.mjs';
26
26
  import { codeContextPathOk } from './workspace.mjs';
@@ -152,8 +152,8 @@ export async function publishCodeContext(root, { push = false, allowBranch = fal
152
152
  const registry = { repos: repos || [] };
153
153
  const git = productGit(root);
154
154
 
155
- const branch = git('rev-parse', '--abbrev-ref', 'HEAD').stdout;
156
155
  const defaultBranch = resolveDefaultBranch(git, productConfig);
156
+ const branch = branchToCommitOn(root, git, defaultBranch);
157
157
  if (!guardDefaultBranch(branch, defaultBranch, { allowBranch, cmd: 'yad repo refresh --push', root })) return;
158
158
 
159
159
  // Stage the EXPLICIT allowlist (code-maps + registry), scoped so an unrelated pre-staged file is never