yadflow 4.9.0 → 4.11.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 (155) hide show
  1. package/CHANGELOG.md +184 -0
  2. package/README.md +15 -5
  3. package/bin/commands.mjs +11 -1
  4. package/bin/yad.mjs +203 -14
  5. package/cli/agent-guard-worker.mjs +13 -0
  6. package/cli/agent-guard.mjs +1797 -73
  7. package/cli/agent-rules.mjs +64 -5
  8. package/cli/argv-flags.mjs +2 -2
  9. package/cli/brain/vendor/LICENSE-graphology-library.txt +21 -0
  10. package/cli/brain/vendor/LICENSE-graphology.txt +21 -0
  11. package/cli/brain/vendor/LICENSE-sigma.txt +12 -0
  12. package/cli/brain/vendor/graphology-library.min.js +2 -0
  13. package/cli/brain/vendor/graphology.umd.min.js +2 -0
  14. package/cli/brain/vendor/sigma.min.js +1369 -0
  15. package/cli/brain/view/app.js +382 -0
  16. package/cli/brain/view/index.html +63 -0
  17. package/cli/brain/view/live.css +228 -0
  18. package/cli/brain/view/live.html +110 -0
  19. package/cli/brain/view/live.js +884 -0
  20. package/cli/brain/view/style.css +141 -0
  21. package/cli/brain-about.mjs +206 -0
  22. package/cli/brain-activity.mjs +285 -0
  23. package/cli/brain-skills.mjs +118 -0
  24. package/cli/brain-vendor.mjs +71 -0
  25. package/cli/brain-view.mjs +344 -0
  26. package/cli/brain.mjs +810 -0
  27. package/cli/ci-check.mjs +48 -4
  28. package/cli/codeowners-command.mjs +72 -6
  29. package/cli/commit.mjs +17 -3
  30. package/cli/docs.mjs +2 -0
  31. package/cli/doctor.mjs +151 -25
  32. package/cli/epic-state.mjs +186 -4
  33. package/cli/epic.mjs +26 -10
  34. package/cli/errors.mjs +2 -1
  35. package/cli/find-product.mjs +69 -15
  36. package/cli/fold.mjs +31 -6
  37. package/cli/foundation-publish.mjs +256 -0
  38. package/cli/gate.mjs +29 -3
  39. package/cli/git-read.mjs +38 -0
  40. package/cli/guard-stream.mjs +409 -0
  41. package/cli/guide.mjs +3 -1
  42. package/cli/hook.mjs +102 -9
  43. package/cli/issue-links.mjs +61 -0
  44. package/cli/issues-act.mjs +371 -0
  45. package/cli/issues-write.mjs +441 -0
  46. package/cli/issues.mjs +513 -0
  47. package/cli/lib.mjs +37 -2
  48. package/cli/lifecycle.mjs +7 -0
  49. package/cli/local-page.mjs +138 -0
  50. package/cli/machine.mjs +1 -1
  51. package/cli/manifest.mjs +59 -3
  52. package/cli/map/view/app.js +712 -0
  53. package/cli/map/view/index.html +50 -0
  54. package/cli/map/view/style.css +142 -0
  55. package/cli/map-view.mjs +186 -0
  56. package/cli/map.mjs +637 -0
  57. package/cli/members.mjs +9 -15
  58. package/cli/next.mjs +1 -1
  59. package/cli/openpr.mjs +26 -6
  60. package/cli/plan.mjs +127 -0
  61. package/cli/platform.mjs +159 -4
  62. package/cli/product-index.mjs +1 -1
  63. package/cli/protection.mjs +53 -3
  64. package/cli/reconcile.mjs +9 -3
  65. package/cli/report.mjs +9 -3
  66. package/cli/reports-dir.mjs +391 -0
  67. package/cli/reports.mjs +65 -0
  68. package/cli/run-checks.mjs +15 -4
  69. package/cli/scan.mjs +314 -0
  70. package/cli/setup.mjs +42 -8
  71. package/cli/standup.mjs +120 -78
  72. package/cli/status.mjs +6 -5
  73. package/cli/story-frames.mjs +17 -6
  74. package/cli/test-agents-file.mjs +985 -12
  75. package/cli/test-brain-activity.mjs +753 -0
  76. package/cli/test-brain-view.mjs +381 -0
  77. package/cli/test-brain.mjs +795 -0
  78. package/cli/test-build.mjs +25 -0
  79. package/cli/test-ci-check.mjs +469 -10
  80. package/cli/test-guide.mjs +218 -0
  81. package/cli/test-machine.mjs +59 -0
  82. package/cli/test-map.mjs +615 -0
  83. package/cli/test-node.mjs +15 -0
  84. package/cli/test-reports.mjs +382 -0
  85. package/cli/test-run-checks.mjs +21 -0
  86. package/cli/test-setup-agent.mjs +14 -0
  87. package/cli/test-story-frames.mjs +74 -4
  88. package/cli/test-worktree.mjs +24 -3
  89. package/cli/toolbox-connect.mjs +259 -0
  90. package/cli/toolbox.mjs +187 -12
  91. package/cli/update-commit.mjs +101 -9
  92. package/cli/usage.mjs +8 -4
  93. package/package.json +12 -4
  94. package/skills/sdlc/config.yaml +1 -1
  95. package/skills/sdlc/module-help.csv +3 -1
  96. package/skills/yad-analysis/SKILL.md +4 -0
  97. package/skills/yad-architecture/SKILL.md +22 -4
  98. package/skills/yad-backfill/SKILL.md +4 -0
  99. package/skills/yad-change/SKILL.md +7 -1
  100. package/skills/yad-change/references/triage.md +2 -0
  101. package/skills/yad-checks/SKILL.md +15 -7
  102. package/skills/yad-checks/references/check-gates.md +70 -35
  103. package/skills/yad-checks/templates/checks/build-test-lint.sh +7 -0
  104. package/skills/yad-checks/templates/checks/install-deps.sh +6 -0
  105. package/skills/yad-checks/templates/checks/member-check.mjs +3 -2
  106. package/skills/yad-checks/templates/checks/package-manager.sh +42 -0
  107. package/skills/yad-checks/templates/checks/risk-map-check.sh +2 -2
  108. package/skills/yad-checks/templates/checks/verified-commits.sh +3 -3
  109. package/skills/yad-checks/templates/github/yad-checks.yml +358 -69
  110. package/skills/yad-checks/templates/github/yad-pr-text.yml +118 -0
  111. package/skills/yad-checks/templates/github/yad-product-checks.yml +130 -54
  112. package/skills/yad-checks/templates/github/yad-product-pr-text.yml +131 -0
  113. package/skills/yad-checks/templates/github/yad-update-guard.yml +2 -1
  114. package/skills/yad-checks/templates/github/yad-verified-commits.yml +49 -3
  115. package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +80 -20
  116. package/skills/yad-checks/templates/gitlab/yad-product-checks.gitlab-ci.yml +59 -9
  117. package/skills/yad-checks/templates/gitlab/yad-update-guard.gitlab-ci.yml +1 -0
  118. package/skills/yad-checks/templates/gitlab/yad-verified-commits.gitlab-ci.yml +49 -1
  119. package/skills/yad-checks/templates/hooks/agent-guard.mjs +44 -10
  120. package/skills/yad-checks/templates/hooks/ledger-guard-cursor.mjs +12 -6
  121. package/skills/yad-checks/templates/hooks/yad-activity.mjs +238 -0
  122. package/skills/yad-commit/SKILL.md +3 -1
  123. package/skills/yad-connect-design/SKILL.md +42 -10
  124. package/skills/yad-connect-design/references/design-context.md +35 -5
  125. package/skills/yad-connect-design/references/design-registry.md +3 -3
  126. package/skills/yad-connect-learning/SKILL.md +12 -2
  127. package/skills/yad-connect-repos/SKILL.md +18 -0
  128. package/skills/yad-connect-testing/SKILL.md +22 -5
  129. package/skills/yad-connect-testing/references/testing-context.md +1 -1
  130. package/skills/yad-discovery/SKILL.md +11 -0
  131. package/skills/yad-discovery/references/foundation-schema.md +11 -0
  132. package/skills/yad-docs/templates/app/package-lock.json +18 -10
  133. package/skills/yad-docs/templates/app/package.json +6 -1
  134. package/skills/yad-epic/SKILL.md +7 -0
  135. package/skills/yad-epic/references/state-schema.md +50 -1
  136. package/skills/yad-guide/SKILL.md +8 -4
  137. package/skills/yad-implement/SKILL.md +117 -4
  138. package/skills/yad-implement/references/implement-conventions.md +2 -1
  139. package/skills/yad-issues/SKILL.md +54 -0
  140. package/skills/yad-learn/SKILL.md +4 -0
  141. package/skills/yad-open-pr/SKILL.md +6 -0
  142. package/skills/yad-pr-template/SKILL.md +2 -1
  143. package/skills/yad-pr-template/templates/checks/pr-template.sh +8 -4
  144. package/skills/yad-pr-template/templates/checks/pr-title.sh +42 -6
  145. package/skills/yad-product-bridge/references/bridge.md +28 -0
  146. package/skills/yad-product-bridge/templates/github/yad-gate-sync.yml +25 -11
  147. package/skills/yad-product-bridge/templates/gitlab/yad-gate-sync.gitlab-ci.yml +38 -14
  148. package/skills/yad-run/SKILL.md +5 -0
  149. package/skills/yad-scan/SKILL.md +51 -0
  150. package/skills/yad-spec/SKILL.md +32 -2
  151. package/skills/yad-stories/SKILL.md +22 -4
  152. package/skills/yad-stories/references/story-schema.md +1 -1
  153. package/skills/yad-test-cases/SKILL.md +18 -2
  154. package/skills/yad-ui/SKILL.md +43 -8
  155. package/skills/yad-checks/templates/gitlab/.gitlab-ci.yml +0 -49
package/cli/standup.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  //
4
4
  // READ-ONLY, DERIVED LIVE, FACTS ONLY. Nothing here is stored; every line is rebuilt from git, the Product
5
5
  // ledgers, the capture branches and the platform each time. No score, no ranking and no judging flag
6
- // (`yad usage`'s rule), and never an email, a commit message, a PR title or a comment body. The one write
6
+ // (`yad usage`'s rule), and never an email, a commit message, a PR title or a comment body. Issue and work item titles are the one exception (E171). The one write
7
7
  // is E131's access cache in git's own folder (`memberStatuses`), never a Product file.
8
8
  //
9
9
  // WHO. The team list is E131's member files. Each member is one block, joined through every identity the
@@ -41,11 +41,13 @@ import { readClaims, fetchCaptures } from './claims.mjs';
41
41
  import { gitIn, wipName, WIP_PREFIX } from './capture.mjs';
42
42
  import { gitAuthors, personKey } from './people.mjs';
43
43
  import { isBot } from './riskmap.mjs';
44
+ import { accountId, buildIssues, mdEscape, mdUrl } from './issues.mjs';
44
45
  import { readMembers, memberStatuses, memberMatches, productIdentity, ttlDays, accountLabel, accessCheck } from './members.mjs';
45
- import { ledgerEvents, esc, mdText, writeReport } from './usage.mjs';
46
+ import { ledgerEvents, esc, mdText } from './usage.mjs';
47
+ import { writeOrSave } from './reports-dir.mjs';
46
48
  import { readRegistry, judgeRepo, runnable } from './workspace.mjs';
47
49
  import { listPrs, prTarget } from './pr-list.mjs';
48
- import { shown } from './protection.mjs';
50
+ import { shown, configuredGitUrl } from './protection.mjs';
49
51
  import { platformLogin } from './platform.mjs';
50
52
 
51
53
  const DAY_MS = 86_400_000;
@@ -168,9 +170,9 @@ function wipSaves(root, env, startMs) {
168
170
 
169
171
  // The repos to read: the Product and every registered repo. `dir` is set only when git may run there
170
172
  // (judged first, E81); `gitUrl` is what the platform is asked about.
171
- export function repoSources(root, identity, productConfig, notRead, env) {
172
- const productUrl = typeof productConfig?.git_url === 'string' && productConfig.git_url ? productConfig.git_url
173
- : (gitIn(root, env)(['remote', 'get-url', 'origin']).out.trim() || '');
173
+ export function repoSources(root, identity, productConfig, notRead, env, { localPaths = true } = {}) {
174
+ // A git_url that names only a host is no repo: origin then (#513).
175
+ const productUrl = configuredGitUrl(productConfig?.git_url, () => gitIn(root, env)(['remote', 'get-url', 'origin']).out);
174
176
  const out = [{ label: 'Product', dir: root, gitUrl: productUrl, platform: identity.platform }];
175
177
  const { registry, problem } = readRegistry(root);
176
178
  if (problem) notRead.push(`${safe(problem)} — the code repos are not read`);
@@ -178,7 +180,7 @@ export function repoSources(root, identity, productConfig, notRead, env) {
178
180
  if (!r || typeof r.name !== 'string' || !r.name) continue;
179
181
  const label = forTerminal(r.name);
180
182
  let dir = null;
181
- if (typeof r.path === 'string' && r.path) {
183
+ if (!localPaths) { /* a platform-only read (`yad issues`) needs no checkout */ } else if (typeof r.path === 'string' && r.path) {
182
184
  const j = judgeRepo(root, r);
183
185
  if (runnable(j)) dir = path.resolve(root, r.path);
184
186
  else notRead.push(`${label}: ${j.state === 'missing' ? 'not cloned on this machine' : j.linked ? "reached through a link inside a repo's tree" : safe(j.reason)} — its commits are not read`);
@@ -192,14 +194,14 @@ export function repoSources(root, identity, productConfig, notRead, env) {
192
194
 
193
195
  // The one member a piece of evidence belongs to: `{ member }`, `{ ambiguous: [...] }` when more than one
194
196
  // matches, or `{}` when none does.
195
- function whose(members, e) {
197
+ export function whose(members, e) {
196
198
  const hit = members.filter((m) => memberMatches(m, e));
197
199
  if (hit.length === 1) return { member: hit[0] };
198
200
  return hit.length ? { ambiguous: hit } : {};
199
201
  }
200
202
  // A git name made branch-safe (an owner file, a claim, a capture branch) — compared with the same form of
201
203
  // each name a member file holds.
202
- function whoseWip(members, w) {
204
+ export function whoseWip(members, w) {
203
205
  const hit = members.filter((m) => m.names.some((n) => wipName(n) === w));
204
206
  if (hit.length === 1) return { member: hit[0] };
205
207
  return hit.length ? { ambiguous: hit } : {};
@@ -209,7 +211,7 @@ function whoseWip(members, w) {
209
211
  // and the same login on GitLab can be two people, so the platform and host must match too; an account two
210
212
  // files claim (`matchLogins` leaves it out) matches nobody.
211
213
  const keyOf = (a) => `${a.platform}\0${String(a.host).toLowerCase()}\0${String(a.login).toLowerCase()}`; // members.mjs's accountKey
212
- function whoseAccount(members, { platform, host, login }, disputed = new Set()) {
214
+ export function whoseAccount(members, { platform, host, login }, disputed = new Set()) {
213
215
  const want = keyOf({ platform, host: host || '', login: login || '' });
214
216
  // An account two files claim is matched by nobody — unless it is a member's own primary (E131's rule).
215
217
  const hit = members.filter((m) => m.accounts.some((a) => keyOf(a) === want && (keyOf(a) === keyOf(m.primary) || !disputed.has(want))));
@@ -261,6 +263,70 @@ const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
261
263
  const prWord = (platform) => (platform === 'gitlab' ? 'MR !' : 'PR #');
262
264
 
263
265
  // The whole report as data. `now` is epoch milliseconds (injected, so a test can pin the day).
266
+ // WAITING — gates, by the owner of the step they review: the live E47 owner, else the epic's `owner`.
267
+ // Each epic on its own: a shared file that is not what yad writes stops that epic's lines, said in
268
+ // "not read", never the whole report. → { waits: [{ owner: { at, display, key } | null, item }], notRead }
269
+ // Shared by `yad standup` and `yad map` (E181), so the gate rule is read in one place.
270
+ export function gateWaits(root, { ledgers, members, productConfig, identity, places = [] }) {
271
+ const solo = isSolo(productConfig);
272
+ const engagement = requireEngagement(productConfig);
273
+ const waits = [];
274
+ const notRead = [];
275
+ const mergeWord = identity.platform ? `its review ${identity.platform === 'gitlab' ? 'MR' : 'PR'} to merge` : '`yad gate advance` (no platform: the gate moves on when it is advanced)';
276
+ for (const [epic, led] of ledgers) {
277
+ try {
278
+ const state = led.state;
279
+ if (!state?.steps) continue;
280
+ const owners = new Map(readOwners(root, epic).filter((o) => !o.error && o.live).map((o) => [o.step, o]));
281
+ const front = readFrontmatter(path.join(epicRoot(root, epic), 'epic.md')).owner || readFrontmatter(path.join(epicRoot(root, epic), 'roadmap.md')).owner;
282
+ const epicOwner = typeof front === 'string' && front.trim() ? front.trim() : null;
283
+ const ownerOf = (stepId) => {
284
+ const o = owners.get(stepId);
285
+ if (o) return { at: whoseWip(members, o.owner), display: o.name || o.owner, key: `wip:${o.owner}` };
286
+ if (epicOwner) return { at: whose(members, { login: epicOwner, name: epicOwner }), display: epicOwner, key: personKey({ login: epicOwner }) };
287
+ return null;
288
+ };
289
+ const put = (stepId, item) => { waits.push({ owner: ownerOf(stepId), item }); };
290
+ const approvals = records(led.approvals);
291
+ const comments = records(led.comments);
292
+ const reviewPrs = records(led.productPrs);
293
+ // (b) the current step is an author step someone owns, and it is not done.
294
+ const cur = state.steps.find((s) => s?.id === state.currentStep);
295
+ const curDef = STEPS.find((d) => d.id === cur?.id);
296
+ if (cur && !isPassed(cur) && curDef && curDef.kind !== 'review' && cur.type !== 'review+approve' && ownerOf(cur.id)) {
297
+ put(cur.id, { kind: 'next-move', epic, step: cur.id, state: stepStatus(cur), text: `${epic} ${safe(cur.id)} is the current step and theirs to author (${stepStatus(cur) || 'unknown state'})` });
298
+ }
299
+ // (a) an open gate: its author step passed, the review not yet. Read through the gate's own predicate,
300
+ // so this line never says more than `yad gate status` would (engagement, revoked approvals, solo).
301
+ for (const s of state.steps.filter((x) => x?.type === 'review+approve' && !isPassed(x))) {
302
+ const a = authorStepFor(state, s);
303
+ if (!a || !isPassed(a)) continue;
304
+ const verdict = gatePredicate({ step: s, approvals, acceptedHashes: acceptedHashes(epicRoot(root, epic), s.artifact), solo, requireEngagement: engagement, optional: optionalStepsFor(state) });
305
+ const rule = gateRuleFor(s);
306
+ const pr = reviewPrs.find((p) => (typeof p.step === 'string' && p.step === s.id) || (typeof p.artifact === 'string' && p.artifact === s.artifact));
307
+ const prNo = pr && Number.isSafeInteger(pr.number) ? pr.number : null;
308
+ const via = prNo != null ? `${prWord(identity.platform)}${prNo}` : null;
309
+ const asks = rule.riskStep ? `; the count asks ${gateRuleSum(rule)} (risk step advisory)` : '';
310
+ const waitsFor = solo
311
+ ? `waits for ${via ? `review ${via} to merge` : mergeWord} (solo mode: approvals waived)`
312
+ : verdict.approvalsSatisfied
313
+ ? `has the ${plural(verdict.have ?? 0, 'approval')} it needs to pass; waits for ${via ? `review ${via} to merge` : mergeWord}${asks}`
314
+ : `waits for approval — missing: ${verdict.missing.map(safe).join('; ')}${asks}${via ? `; review ${via}` : ''}`;
315
+ put(a.id, { kind: 'gate', epic, step: s.id, approvals: verdict.have ?? null, needed: rule.base, asks: rule.needed, missing: verdict.missing, pr: prNo, text: `${epic} ${safe(s.id)} ${waitsFor}` });
316
+ const rounds = comments.filter((x) => x.step === s.id && Number.isSafeInteger(x.round) && x.round >= 0);
317
+ if (rounds.length) {
318
+ const round = Math.max(...rounds.map((x) => x.round));
319
+ const count = rounds.filter((x) => x.round === round).reduce((n, x) => n + (Number.isSafeInteger(x.count) && x.count >= 0 && x.count <= 100_000 ? x.count : 1), 0);
320
+ put(a.id, { kind: 'comments', epic, step: s.id, round, count, text: `${epic} ${safe(s.id)}: ${plural(count, 'comment')} recorded in review round ${round} (yad does not know which are answered)` });
321
+ }
322
+ }
323
+ } catch (e) {
324
+ notRead.push(`${epic}: its gates could not be read (${why(e, places)}) — nothing is said about what waits there`);
325
+ }
326
+ }
327
+ return { waits, notRead };
328
+ }
329
+
264
330
  export function buildStandup(root, { now = Date.now(), tz = 'UTC', since = null, env = process.env, runner, fetch = true, access = accessCheck } = {}) {
265
331
  const win = windowFor(now, { tz, since });
266
332
  if (win.error) return win;
@@ -424,67 +490,13 @@ export function buildStandup(root, { now = Date.now(), tz = 'UTC', since = null,
424
490
  byWip(w.name, w.name, 'working', { kind: 'drafts', epic: w.epic, last: new Date(w.at).toISOString(), text: `saved drafts on ${safe(w.epic)} (${zoneStamp(w.at, tz)}; nothing unmerged is open now)` });
425
491
  }
426
492
 
427
- // WAITING — gates, by the owner of the step they review: the live E47 owner, else the epic's `owner`.
428
- // Each epic on its own: a shared file that is not what yad writes stops that epic's lines, said in
429
- // "not read", never the whole report.
430
- const solo = isSolo(productConfig);
431
- const engagement = requireEngagement(productConfig);
493
+ // WAITING — gates, by the owner of the step they review (gateWaits).
432
494
  const ownerless = [];
433
- const mergeWord = identity.platform ? `its review ${identity.platform === 'gitlab' ? 'MR' : 'PR'} to merge` : '`yad gate advance` (no platform: the gate moves on when it is advanced)';
434
- for (const [epic, led] of ledgers) {
435
- try {
436
- const state = led.state;
437
- if (!state?.steps) continue;
438
- const owners = new Map(readOwners(root, epic).filter((o) => !o.error && o.live).map((o) => [o.step, o]));
439
- const front = readFrontmatter(path.join(epicRoot(root, epic), 'epic.md')).owner || readFrontmatter(path.join(epicRoot(root, epic), 'roadmap.md')).owner;
440
- const epicOwner = typeof front === 'string' && front.trim() ? front.trim() : null;
441
- const ownerOf = (stepId) => {
442
- const o = owners.get(stepId);
443
- if (o) return { at: whoseWip(members, o.owner), display: o.name || o.owner, key: `wip:${o.owner}` };
444
- if (epicOwner) return { at: whose(members, { login: epicOwner, name: epicOwner }), display: epicOwner, key: personKey({ login: epicOwner }) };
445
- return null;
446
- };
447
- const put = (stepId, item) => {
448
- const o = ownerOf(stepId);
449
- if (!o) { ownerless.push(item); return; }
450
- place(o.at, o.display, o.key, 'waiting', item);
451
- };
452
- const approvals = records(led.approvals);
453
- const comments = records(led.comments);
454
- const reviewPrs = records(led.productPrs);
455
- // (b) the current step is an author step someone owns, and it is not done.
456
- const cur = state.steps.find((s) => s?.id === state.currentStep);
457
- const curDef = STEPS.find((d) => d.id === cur?.id);
458
- if (cur && !isPassed(cur) && curDef && curDef.kind !== 'review' && cur.type !== 'review+approve' && ownerOf(cur.id)) {
459
- put(cur.id, { kind: 'next-move', epic, step: cur.id, state: stepStatus(cur), text: `${epic} ${safe(cur.id)} is the current step and theirs to author (${stepStatus(cur) || 'unknown state'})` });
460
- }
461
- // (a) an open gate: its author step passed, the review not yet. Read through the gate's own predicate,
462
- // so this line never says more than `yad gate status` would (engagement, revoked approvals, solo).
463
- for (const s of state.steps.filter((x) => x?.type === 'review+approve' && !isPassed(x))) {
464
- const a = authorStepFor(state, s);
465
- if (!a || !isPassed(a)) continue;
466
- const verdict = gatePredicate({ step: s, approvals, acceptedHashes: acceptedHashes(epicRoot(root, epic), s.artifact), solo, requireEngagement: engagement, optional: optionalStepsFor(state) });
467
- const rule = gateRuleFor(s);
468
- const pr = reviewPrs.find((p) => (typeof p.step === 'string' && p.step === s.id) || (typeof p.artifact === 'string' && p.artifact === s.artifact));
469
- const prNo = pr && Number.isSafeInteger(pr.number) ? pr.number : null;
470
- const via = prNo != null ? `${prWord(identity.platform)}${prNo}` : null;
471
- const asks = rule.riskStep ? `; the count asks ${gateRuleSum(rule)} (risk step advisory)` : '';
472
- const waitsFor = solo
473
- ? `waits for ${via ? `review ${via} to merge` : mergeWord} (solo mode: approvals waived)`
474
- : verdict.approvalsSatisfied
475
- ? `has the ${plural(verdict.have ?? 0, 'approval')} it needs to pass; waits for ${via ? `review ${via} to merge` : mergeWord}${asks}`
476
- : `waits for approval — missing: ${verdict.missing.map(safe).join('; ')}${asks}${via ? `; review ${via}` : ''}`;
477
- put(a.id, { kind: 'gate', epic, step: s.id, approvals: verdict.have ?? null, needed: rule.base, asks: rule.needed, missing: verdict.missing, pr: prNo, text: `${epic} ${safe(s.id)} ${waitsFor}` });
478
- const rounds = comments.filter((x) => x.step === s.id && Number.isSafeInteger(x.round) && x.round >= 0);
479
- if (rounds.length) {
480
- const round = Math.max(...rounds.map((x) => x.round));
481
- const count = rounds.filter((x) => x.round === round).reduce((n, x) => n + (Number.isSafeInteger(x.count) && x.count >= 0 && x.count <= 100_000 ? x.count : 1), 0);
482
- put(a.id, { kind: 'comments', epic, step: s.id, round, count, text: `${epic} ${safe(s.id)}: ${plural(count, 'comment')} recorded in review round ${round} (yad does not know which are answered)` });
483
- }
484
- }
485
- } catch (e) {
486
- notRead.push(`${epic}: its gates could not be read (${why(e, places)}) — nothing is said about what waits there`);
487
- }
495
+ const gw = gateWaits(root, { ledgers, members, productConfig, identity, places });
496
+ notRead.push(...gw.notRead);
497
+ for (const { owner, item } of gw.waits) {
498
+ if (!owner) ownerless.push(item);
499
+ else place(owner.at, owner.display, owner.key, 'waiting', item);
488
500
  }
489
501
  // WAITING / WORKING — their own open PRs/MRs.
490
502
  for (const p of prRead) {
@@ -504,9 +516,21 @@ export function buildStandup(root, { now = Date.now(), tz = 'UTC', since = null,
504
516
  const shape = (m) => ({
505
517
  login: m.primary.login, logins: m.accounts.map((a) => a.login), account: accountLabel(m.primary), accounts: m.accounts.map(accountLabel), status: m.status, lastActive: isDay(m.lastActive) ? m.lastActive : null, ...blocks.get(m),
506
518
  });
507
- const team = members.filter((m) => m.status !== 'left').map(shape);
519
+ // E171. Each member's items: open ones, and those closed in this window. Titles are shown on purpose: a list of
520
+ // numbers is no use in a standup. A repo not read is "not read", through `gapLines`, never "no items".
521
+ const active = members.filter((m) => m.status !== 'left');
522
+ const backlog = active.length ? buildIssues(root, { now, closedSinceMs: win.startMs, env, authCache, ...(runner ? { runner } : {}) }) : { items: [], repos: [], notes: [], registryUnread: false };
523
+ const platformGone = new Set(prMissing.map((p) => p.label));
524
+ // Each repo's failure is said once, with its PR read's line if that failed too. The flag does not depend on that.
525
+ const issuesNotRead = backlog.repos.filter((r) => !r.read && !platformGone.has(r.label)).map((r) => `${r.label}: items not read — ${r.why}`);
526
+ notes.push(...backlog.notes.filter((n) => !notes.includes(n)));
527
+ const issuesUnknown = backlog.registryUnread || backlog.repos.some((r) => !r.read || r.partial) || backlog.items.some((i) => i.assignees.some((a) => a.ambiguous));
528
+ const itemsFor = (m) => backlog.items.filter((i) => i.assignees.some((a) => a.memberKey === accountId(m.primary))).map((i) => ({ ref: i.ref, url: i.url, title: i.title, priority: i.priority, status: i.status, epic: i.epic?.id ?? null, flags: i.flags }));
529
+ const team = active.map((m) => ({ ...shape(m), issues: itemsFor(m) }));
508
530
  const left = members.filter((m) => m.status === 'left').map(shape);
509
531
  return {
532
+ issuesNotRead,
533
+ issuesUnknown,
510
534
  window: { start: new Date(win.startMs).toISOString(), end: new Date(now).toISOString(), tz, basis: win.basis, ledgerFrom: win.startUtcDay },
511
535
  fetched,
512
536
  ttlDays: ttl,
@@ -524,6 +548,9 @@ export function buildStandup(root, { now = Date.now(), tz = 'UTC', since = null,
524
548
  };
525
549
  }
526
550
 
551
+ // How many things wait, across every person in the model — the state word in a saved report's name.
552
+ export const waitingCount = (model) => [...(model.team || []), ...(model.unlisted || []), ...(model.left || [])].reduce((n, p) => n + (Array.isArray(p.waiting) ? p.waiting.length : 0), 0);
553
+
527
554
  // Narrow the report to one member: by any of their logins (any account), case-insensitive.
528
555
  export function onlyMember(model, login) {
529
556
  const want = String(login).toLowerCase();
@@ -534,7 +561,7 @@ export function onlyMember(model, login) {
534
561
  // ---- rendering -----------------------------------------------------------------------------------
535
562
 
536
563
  const SECTIONS = [['done', 'Done'], ['working', 'Working on'], ['waiting', 'Waiting']];
537
- const FOOTER = 'Derived, read-only — rebuilt from git, the Product ledgers, the capture branches and the platform each time it runs. Facts only: no score, no ranking, and no emails, commit messages, PR titles or comment bodies.';
564
+ const FOOTER = 'Derived, read-only — rebuilt from git, the Product ledgers, the capture branches and the platform each time it runs. Facts only: no score, no ranking, and no emails, commit messages, PR titles or comment bodies. Issue and work item titles are shown: check before sharing outside the team.';
538
565
 
539
566
  const LOCAL_ONLY = 'no remote named origin — only your own capture branches are read';
540
567
 
@@ -544,6 +571,7 @@ export function gapLines(model) {
544
571
  ...(model.fetched === 'failed' ? ['could not fetch the capture branches — claims and drafts are as last fetched'] : []),
545
572
  ...model.platform.filter((p) => !p.read).map((p) => `${p.repo}: platform not read — ${p.why}`),
546
573
  ...model.notRead,
574
+ ...(model.issuesNotRead ?? []),
547
575
  ...model.notes,
548
576
  ...(model.fetched === 'local' ? [LOCAL_ONLY] : []),
549
577
  ...model.memberErrors,
@@ -577,6 +605,9 @@ const emptyLine = (model) => {
577
605
  return gaps.length ? `nothing recorded here — but ${gaps.join(', and ')}, so something may be missing (see the end)` : 'nothing';
578
606
  };
579
607
 
608
+ const itemMeta = (i) => [i.priority ?? 'no priority', i.status, i.epic ?? 'no epic', ...(i.flags ?? [])].join(' · ');
609
+ const noItems = (model) => (model.issuesUnknown ? 'none found — but some items could not be read or matched to a member (see the end)' : 'none');
610
+
580
611
  function blockText(model, b, title) {
581
612
  log(`\n ${c.bold(title)}`);
582
613
  for (const [k, label] of SECTIONS) {
@@ -584,6 +615,10 @@ function blockText(model, b, title) {
584
615
  if (!b[k].length) log(` ${c.dim(emptyLine(model))}`);
585
616
  for (const it of b[k]) log(` • ${it.text}`);
586
617
  }
618
+ if (!b.issues) return;
619
+ log(` ${c.dim('Assigned items')}`);
620
+ if (!b.issues.length) log(` ${c.dim(noItems(model))}`);
621
+ for (const i of b.issues) log(` • ${forTerminal(i.ref)} ${i.title} ${c.dim(`[${itemMeta(i)}]`)}${i.url ? ` ${i.url}` : ''}`);
587
622
  }
588
623
 
589
624
  const memberTitle = (m) => `${forTerminal(m.login)} ${c.dim(`— ${m.status}${m.lastActive ? `, last active ${m.lastActive}` : ''}${m.accounts.length > 1 ? ` · ${m.accounts.join(', ')}` : ''}`)}`;
@@ -623,6 +658,11 @@ export function renderMarkdown(model) {
623
658
  for (const it of b[k]) L.push(`- ${mdText(it.text)}`);
624
659
  L.push('');
625
660
  }
661
+ if (!b.issues) return;
662
+ L.push('**Assigned items**', '');
663
+ if (!b.issues.length) L.push(`- _${noItems(model)}_`);
664
+ for (const i of b.issues) L.push(`- ${i.url ? `[${mdEscape(i.ref)}](${mdUrl(i.url)})` : mdEscape(i.ref)} ${mdEscape(i.title)} (${mdEscape(itemMeta(i))})`);
665
+ L.push('');
626
666
  };
627
667
  const none = noTeamLine(model);
628
668
  if (none) L.push(`_${mdText(none)}_`, '');
@@ -641,7 +681,7 @@ export function renderMarkdown(model) {
641
681
 
642
682
  export function renderHtml(model) {
643
683
  const list = (items, empty) => (items.length ? `<ul>${items.map((it) => `<li>${esc(it.text)}</li>`).join('')}</ul>` : `<p class="none">${esc(empty)}</p>`);
644
- const block = (b, title, sub = '') => `<section class="member"><h2>${esc(title)}${sub ? ` <span>${esc(sub)}</span>` : ''}</h2>${SECTIONS.map(([k, label]) => `<h3>${label}</h3>${list(b[k], emptyLine(model))}`).join('')}</section>`;
684
+ const block = (b, title, sub = '') => `<section class="member"><h2>${esc(title)}${sub ? ` <span>${esc(sub)}</span>` : ''}</h2>${SECTIONS.map(([k, label]) => `<h3>${label}</h3>${list(b[k], emptyLine(model))}`).join('')}${b.issues ? `<h3>Assigned items</h3>${b.issues.length ? `<ul>${b.issues.map((it) => `<li>${it.url ? `<a href="${esc(it.url)}">${esc(it.ref)}</a>` : esc(it.ref)} ${esc(it.title)} <span class="none">(${esc(itemMeta(it))})</span></li>`).join('')}</ul>` : `<p class="none">${esc(noItems(model))}</p>`}` : ''}</section>`;
645
685
  const missing = gapLines(model);
646
686
  return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
647
687
  <title>yadflow — standup</title><style>
@@ -698,11 +738,13 @@ export async function runStandup(root, { now = Date.now(), tz = 'UTC', since = n
698
738
  if (model.error) return refuse(model.error, model.hint);
699
739
  if (who) model = onlyMember(model, who);
700
740
  if (format) {
701
- const dest = out || `standup-report.${format}`;
702
- writeReport(dest, format === 'md' ? renderMarkdown(model) : renderHtml(model));
703
- if (json) note(`wrote ${format.toUpperCase()} report → ${dest}`);
704
- else info(`wrote ${format.toUpperCase()} report → ${c.bold(dest)}`);
705
- return { ...model, out: dest };
741
+ // E180: with no --out, saved in the local reports folder, named by who it covers and how much waits.
742
+ const saved = writeOrSave(root, { out, kind: 'standup', scope: who || 'team', state: `${waitingCount(model)} waiting`, ext: format, content: format === 'md' ? renderMarkdown(model) : renderHtml(model), command: 'standup', env });
743
+ if (saved.problem) return refuse(saved.problem);
744
+ for (const w of saved.warnings) warn(w);
745
+ if (json) note(`wrote ${format.toUpperCase()} report → ${saved.file}`);
746
+ else info(`wrote ${format.toUpperCase()} report → ${c.bold(saved.file)}`);
747
+ return { ...model, out: saved.file };
706
748
  }
707
749
  if (!json) renderText(model);
708
750
  return { ...model, out: null };
package/cli/status.mjs CHANGED
@@ -60,11 +60,12 @@ function finished(root, id, ledger, a) {
60
60
  const laneSteps = (lane) => (Array.isArray(lane?.steps) ? lane.steps.filter((s) => s && typeof s.id === 'string') : []);
61
61
  const real = (p) => { try { return fs.realpathSync(p); } catch { return path.resolve(p); } };
62
62
 
63
- // The registered repo this checkout is. A monorepo registers the Product's own folder (`path: "."`), which
64
- // `registryEntryFor` never answers (it is a code-repo command's guard), so that one case is matched here.
65
- // So is a git worktree of a registered repo (agents often work in one): `registryEntryFor` refuses it on
66
- // purpose — a command that WRITES must not swap one checkout for another — but this view only reads, and
67
- // the branch it reports is the worktree's own. The worktree's main checkout names the repo.
63
+ // The registered repo this checkout is. A git worktree of a registered repo (agents often work in one) is
64
+ // that repo, and `registryEntryFor` answers it (#515); the branch reported is the worktree's own. This view
65
+ // only reads, so it is more lenient than a command that writes: a worktree moved by hand, whose git
66
+ // back-link is stale (`git worktree repair` not yet run), still names its repo by git's common folder. A
67
+ // monorepo registers the Product's own folder (`path: "."`), which `registryEntryFor` never answers (it is
68
+ // a code-repo command's guard), so that one case is matched here.
68
69
  function repoHere(root, cwd, top) {
69
70
  const hit = registryEntryFor(root, cwd)?.meta?.name;
70
71
  if (typeof hit === 'string') return hit;
@@ -152,7 +152,8 @@ export function readDesignConfig(root) {
152
152
  // when the answer is no; the yad-spec and yad-implement skills make the call and stop on a failure.
153
153
  // null when the story names no frame (no UI task, nothing to check). `reachable` is `check` (probe, and
154
154
  // stop when it fails) or `not-checkable` (nothing to probe: go on with the links). `appBound` is true (read
155
- // through the running app), false (a hosted server: sign in) or null (yad cannot tell: `stop` names both).
155
+ // through the running app), false (no app: a hosted server, so sign in — or, with `local` true, a CLI that
156
+ // works on the design file on disk, E164) or null (yad cannot tell: `stop` names both).
156
157
  export function designPreflight(design, links, frames) {
157
158
  if (!frames.length) return null;
158
159
  const d = design.state === 'ok' ? design.data : null;
@@ -184,14 +185,21 @@ export function designPreflight(design, links, frames) {
184
185
  // Every recorded ID is unresolved: the bad IDs are the problem (the warnings name them), not the app.
185
186
  const found = frames.find((f) => f.found);
186
187
  if (!found) return notCheckable('no recorded frame is in design-links.json — fix the frame IDs first');
187
- const appBound = reach.appBound === true || listed(reach.appBound) ? true : listed(reach.signInOnly) ? false : null;
188
+ const local = listed(reach.local);
189
+ const appBound = local ? false : reach.appBound === true || listed(reach.appBound) ? true : listed(reach.signInOnly) ? false : null;
188
190
  // design.json's project_url is a project, not a file, so it is never compared against.
189
191
  const file = links.fileUrl;
190
192
  const fill = (s) => s.replace(/<file>/g, file ? `\`${forTerminal(file)}\`` : 'the design file').replace(/<frame>/g, `\`${forTerminal(found.id)}\``);
191
193
  return {
192
- tool, provider, reachable: 'check', appBound, file, frame: found.id,
193
- probe: fill(reach.probe),
194
- stop: fill(appBound === true ? reach.open : appBound === false ? reach.signIn : reach.either),
194
+ tool, provider, reachable: 'check', appBound, local, file, frame: found.id,
195
+ probe: fill(local ? reach.localProbe : appBound === null && reach.eitherProbe ? reach.eitherProbe : reach.probe),
196
+ stop: fill(local ? reach.localStop : appBound === true ? reach.open : appBound === false ? reach.signIn : reach.either),
197
+ // E165: when the probe fails because the tool is not on this machine at all (not a closed app or a
198
+ // sign-in), the agent offers this first, under the connect-tool rule. A tool with a reach rule is shipped.
199
+ // Not for a provider that is one app's own server (`reach.ownServer`: Figma's figma-desktop): the tool's
200
+ // recipe connects its other server, so the person opens the app instead, as `stop` says. OpenPencil's
201
+ // MCP server is not one: its recipe adds it.
202
+ ...(listed(reach.ownServer) ? {} : { connect: `yad toolbox connect ${tool} --json` }),
195
203
  };
196
204
  }
197
205
 
@@ -290,7 +298,10 @@ export async function runStory(root, { action, story, json = false } = {}) {
290
298
  }
291
299
  for (const w of warnings) warn(w);
292
300
  const p = r.preflight;
293
- if (p?.reachable === 'check') hand(`before UI work: ${p.probe} — if that fails, stop: ${p.stop}`);
301
+ if (p?.reachable === 'check') {
302
+ hand(`before UI work: ${p.probe} — if that fails, stop: ${p.stop}`);
303
+ if (p.connect) hand(`if ${forTerminal(p.tool)} is not on this machine at all, your agent can offer to connect it first: \`${p.connect}\``);
304
+ }
294
305
  else if (p) info(`before UI work: the design tool is not checked (${p.why}) — build from the frame links`);
295
306
  return { ok: true, ...r };
296
307
  }