yadflow 4.5.2 → 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 (101) hide show
  1. package/CHANGELOG.md +206 -0
  2. package/README.md +4 -1
  3. package/bin/commands.mjs +5 -1
  4. package/bin/yad.mjs +174 -18
  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 +396 -123
  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 +442 -33
  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/lib.mjs +12 -1
  23. package/cli/lifecycle/defaults/1.json +96 -0
  24. package/cli/lifecycle/lifecycle.schema.json +121 -0
  25. package/cli/lifecycle.mjs +695 -0
  26. package/cli/next.mjs +34 -11
  27. package/cli/openpr.mjs +81 -5
  28. package/cli/platform.mjs +21 -0
  29. package/cli/pr-list.mjs +49 -3
  30. package/cli/product-index.mjs +6 -3
  31. package/cli/product-token.mjs +186 -0
  32. package/cli/productcommit.mjs +33 -0
  33. package/cli/recommend.mjs +3 -1
  34. package/cli/repo-publish.mjs +2 -2
  35. package/cli/run-checks.mjs +586 -0
  36. package/cli/ship-drift.mjs +384 -0
  37. package/cli/standup.mjs +1 -1
  38. package/cli/status.mjs +282 -0
  39. package/cli/test-build.mjs +1559 -0
  40. package/cli/test-run-checks.mjs +603 -0
  41. package/cli/test-worktree.mjs +520 -0
  42. package/cli/thread.mjs +50 -3
  43. package/cli/tidy.mjs +2 -2
  44. package/cli/toolbox.mjs +36 -5
  45. package/cli/workspace.mjs +4 -1
  46. package/cli/worktree-record.mjs +53 -0
  47. package/cli/worktree.mjs +379 -0
  48. package/package.json +4 -3
  49. package/skills/sdlc/config.yaml +28 -20
  50. package/skills/sdlc/module-help.csv +1 -1
  51. package/skills/yad-backfill/references/backfill.md +8 -1
  52. package/skills/yad-backfill/templates/checks/backfill-check.sh +54 -6
  53. package/skills/yad-change/SKILL.md +3 -0
  54. package/skills/yad-checks/SKILL.md +47 -5
  55. package/skills/yad-checks/references/check-gates.md +124 -12
  56. package/skills/yad-checks/templates/checks/build-test-lint.sh +22 -3
  57. package/skills/yad-checks/templates/checks/commit-message.sh +8 -2
  58. package/skills/yad-checks/templates/checks/contract-check.sh +354 -48
  59. package/skills/yad-checks/templates/checks/epic-open.sh +87 -14
  60. package/skills/yad-checks/templates/checks/ledger-guard.sh +3 -3
  61. package/skills/yad-checks/templates/checks/lineage-check.sh +88 -15
  62. package/skills/yad-checks/templates/checks/member-check.mjs +206 -35
  63. package/skills/yad-checks/templates/checks/package-manager.sh +41 -4
  64. package/skills/yad-checks/templates/checks/product-checkout.sh +161 -13
  65. package/skills/yad-checks/templates/checks/reconcile-debt-check.sh +94 -15
  66. package/skills/yad-checks/templates/checks/risk-map-check.sh +2 -2
  67. package/skills/yad-checks/templates/checks/spec-link.sh +63 -4
  68. package/skills/yad-checks/templates/checks/verified-commits.sh +23 -5
  69. package/skills/yad-checks/templates/github/yad-checks.yml +8 -8
  70. package/skills/yad-checks/templates/gitlab/.gitlab-ci.yml +3 -0
  71. package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +4 -4
  72. package/skills/yad-checks/templates/gitlab/yad-product-checks.gitlab-ci.yml +16 -3
  73. package/skills/yad-checks/templates/gitlab/yad-update-guard.gitlab-ci.yml +5 -1
  74. package/skills/yad-checks/templates/gitlab/yad-verified-commits.gitlab-ci.yml +5 -1
  75. package/skills/yad-commit/SKILL.md +4 -2
  76. package/skills/yad-docs/templates/app/package-lock.json +395 -106
  77. package/skills/yad-docs/templates/app/package.json +2 -2
  78. package/skills/yad-engineer-review/SKILL.md +45 -20
  79. package/skills/yad-engineer-review/references/ship-and-record.md +42 -8
  80. package/skills/yad-epic/references/state-schema.md +83 -20
  81. package/skills/yad-implement/SKILL.md +75 -13
  82. package/skills/yad-implement/references/implement-conventions.md +8 -1
  83. package/skills/yad-implement/templates/.gitmessage +3 -0
  84. package/skills/yad-open-pr/SKILL.md +21 -0
  85. package/skills/yad-pr-template/SKILL.md +6 -2
  86. package/skills/yad-pr-template/templates/checks/pr-template.sh +85 -4
  87. package/skills/yad-pr-template/templates/checks/pr-title.sh +1 -1
  88. package/skills/yad-pr-template/templates/github/pull_request_template.md +1 -1
  89. package/skills/yad-pr-template/templates/gitlab/merge_request_templates/Default.md +1 -1
  90. package/skills/yad-product-bridge/SKILL.md +14 -1
  91. package/skills/yad-product-bridge/references/bridge.md +29 -5
  92. package/skills/yad-product-bridge/templates/gitlab/yad-gate-sync.gitlab-ci.yml +9 -4
  93. package/skills/yad-reconcile/SKILL.md +30 -0
  94. package/skills/yad-review-gate/SKILL.md +8 -2
  95. package/skills/yad-review-gate/references/gating.md +26 -1
  96. package/skills/yad-run/SKILL.md +52 -28
  97. package/skills/yad-run/references/run-loop.md +42 -21
  98. package/skills/yad-spec/SKILL.md +142 -17
  99. package/skills/yad-spec/references/spec-handoff.md +68 -5
  100. package/skills/yad-status/SKILL.md +7 -0
  101. package/skills/yad-stories/references/story-schema.md +1 -1
package/cli/errors.mjs CHANGED
@@ -24,6 +24,8 @@ export const CODES = {
24
24
  'YAD-STATE-006': 'a Build ledger is locked by another yad process that is writing it',
25
25
  'YAD-STATE-007': 'an epic cannot be seeded — the profile, the type or the existing ledger refuses it',
26
26
  'YAD-STATE-008': 'a file kept under two names (product.json + hub.json, or product-prs.json + hub-prs.json) says different things under each',
27
+ 'YAD-STATE-009': 'a Build record cannot be written in its current state (no lane yet, a step out of order, a PR not merged, a task not shipped)',
28
+ 'YAD-STATE-010': 'an epic worktree cannot be added or removed in its current state (a path taken, no origin, uncommitted or unpushed work, a lock)',
27
29
  'YAD-CFG-001': 'the Product settings (product.json, or hub.json on a Product that has only that name) name an unknown platform (expected github, gitlab, or null)',
28
30
  'YAD-CFG-002': 'design.json names an unknown design tool (expected one of config.yaml design.tools, or none)',
29
31
  'YAD-CFG-003': 'testing.json names an unknown testing tool (expected one of config.yaml testing.tools, or none)',
@@ -26,6 +26,7 @@ import os from 'node:os';
26
26
  import path from 'node:path';
27
27
  import { exists, readJSON, writeJSON } from './lib.mjs';
28
28
  import { productConfigPath, PROJECT_FILES } from './manifest.mjs';
29
+ import { worktreeAt, sameDir } from './worktree-record.mjs';
29
30
 
30
31
  export const WORKSPACE_FILE = '.yad-workspace.json';
31
32
  export const WORKSPACE_VERSION = 1;
@@ -94,7 +95,15 @@ export function findProduct(start) {
94
95
  if (ws.problem) return { problem: ws.problem };
95
96
  // Only for a repo this Product registers — never for any folder that happens to sit beside it.
96
97
  const repo = registeredRepoHolding(ws.product, from);
97
- return repo ? { root: ws.product, via: 'workspace', workspace: d, repo } : { elsewhere: ws.product };
98
+ if (repo) return { root: ws.product, via: 'workspace', workspace: d, repo };
99
+ // An epic's worktree of a registered repo (#115), beside it: that repo — and the Product commands go
100
+ // to the same epic's Product worktree when there is one, so its Build records stay in its own tree.
101
+ const wt = codeWorktreeOf(ws.product, from);
102
+ if (wt) {
103
+ const epicTree = epicProductWorktree(ws.product, wt.epic);
104
+ return { root: epicTree ?? ws.product, via: 'workspace', workspace: d, repo: wt.meta, ...(epicTree ? { worktree: wt.epic } : {}) };
105
+ }
106
+ return { elsewhere: ws.product };
98
107
  }
99
108
  if (fs.existsSync(path.join(d, '.git'))) crossedRepo = true;
100
109
  if (path.dirname(d) === d) return null;
@@ -121,6 +130,27 @@ export function registeredRepoHolding(productRoot, dir) {
121
130
  return best;
122
131
  }
123
132
 
133
+ // The registered repo whose epic worktree (#115) holds `dir`: yad made it (its record names the repo), and
134
+ // its common git folder IS that repo's — a record copied into some other clone maps nothing.
135
+ // → { meta, epic, top } or null.
136
+ export function codeWorktreeOf(productRoot, dir) {
137
+ const top = gitTopOf(dir);
138
+ const rec = worktreeAt(top);
139
+ if (!rec || typeof rec.repo !== 'string') return null;
140
+ const reg = readJSON(path.join(productRoot, PROJECT_FILES.reposRegistry), null);
141
+ const meta = (Array.isArray(reg?.repos) ? reg.repos : []).find((r) => r?.name === rec.repo && typeof r.path === 'string');
142
+ if (!meta || !sameDir(rec.main, path.resolve(productRoot, meta.path))) return null;
143
+ return { meta, epic: rec.epic, top };
144
+ }
145
+
146
+ // The epic's Product worktree beside the Product, when yad made one; else null.
147
+ export function epicProductWorktree(productRoot, epic) {
148
+ const root = path.resolve(productRoot);
149
+ const at = path.join(path.dirname(root), `${path.basename(root)}--${epic}`);
150
+ const rec = worktreeAt(at);
151
+ return rec && rec.repo === null && rec.epic === epic && sameDir(rec.main, root) && hasProduct(at) ? at : null;
152
+ }
153
+
124
154
  // Folders a workspace file is never written into: the home folder, the temp folder and the top of a disk.
125
155
  // A file there would be found from every folder below it — every project, every test's temp folder.
126
156
  function sharedFolder(dir) {
@@ -214,7 +244,11 @@ export function registryEntryFor(productRoot, dir) {
214
244
  const top = gitTopOf(dir);
215
245
  if (!top) return null;
216
246
  const meta = registeredRepoHolding(productRoot, top);
217
- if (!meta) return null;
247
+ if (!meta) {
248
+ // The one worktree that IS the registered repo's: an epic worktree yad made of it (#115).
249
+ const wt = codeWorktreeOf(productRoot, dir);
250
+ return wt && sameDir(wt.top, top) ? { meta: wt.meta, top } : null;
251
+ }
218
252
  const at = real(path.resolve(productRoot, meta.path));
219
253
  const topAt = real(top);
220
254
  return at && topAt && fold(at) === fold(topAt) ? { meta, top } : null;
package/cli/fold.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  //
3
3
  // E43 saves every draft of an artifact to a private `yad/wip/<name>/<epic>` branch, as unsigned `wip(…)`
4
4
  // commits. At the end of an authoring step, this command makes the ONE commit the record keeps:
5
- // `docs(<epic>): author <step>`. The decisions were the user's (2026-09-25):
5
+ // `docs(<epic, lowercase>): author <step>` (#413). The decisions were the user's (2026-09-25):
6
6
  // 1. THE DRAFT BRANCH IS LEFT ALONE. The fold does not delete, reset or mark it. E95 (rework measurement)
7
7
  // reads the draft history, and deleting a capture branch is the multi-machine trap E43's reviews kept
8
8
  // finding (another machine pushes its copy back). Capture's own rule makes the next capture a no-op:
@@ -30,7 +30,7 @@ import os from 'node:os';
30
30
  import path from 'node:path';
31
31
  import { ok, info, warn, fail, hand, readJSON } from './lib.mjs';
32
32
  import { productConfigPath, isVerifiedLedger } from './manifest.mjs';
33
- import { STEPS, FOUNDATION_EPIC, FOUNDATION_DIR, DISCOVERY_EPIC, artifactBase, artifactPaths, epicRoot } from './epic-state.mjs';
33
+ import { STEPS, FOUNDATION_EPIC, FOUNDATION_DIR, DISCOVERY_EPIC, artifactBase, artifactPaths, epicRoot, isValidEpicId } from './epic-state.mjs';
34
34
  import { capturedEpic, gitIn, isOwnerPath, statusEntries, wipName, wipBranch, runCapture } from './capture.mjs';
35
35
  import { resolveDefaultBranch, preflightGuardReadiness } from './productcommit.mjs';
36
36
 
@@ -55,8 +55,11 @@ export function stepPaths(epic, stepId) {
55
55
  }
56
56
  const covers = (paths, p) => paths.some((s) => p === s || p.startsWith(`${s}/`));
57
57
 
58
+ // The scope is the epic ID in lowercase (#413): the commit-message gate takes a lowercase scope
59
+ // (`[a-z0-9._-]`), so `docs(EP-x)` failed every review PR. The exact ID stays in the Yad-Epic trailer.
60
+ export const foldSubject = (epic, step) => `docs(${epic.toLowerCase()}): author ${step}`;
58
61
  export const foldMessage = ({ epic, step, folded }) =>
59
- `docs(${epic}): author ${step}\n\nYad-Epic: ${epic}\nYad-Step: ${step}\nYad-Folded: ${folded || 'none'}\n`;
62
+ `${foldSubject(epic, step)}\n\nYad-Epic: ${epic}\nYad-Step: ${step}\nYad-Folded: ${folded || 'none'}\n`;
60
63
 
61
64
  // Sort one epic's changed files into what the fold takes and what it leaves. `entries` are
62
65
  // `statusEntries` rows; `verified` is the ledger mode; `seeding` is true while the epic has no
@@ -113,7 +116,8 @@ export function unfoldedPaths(root, epic, base, env = process.env) {
113
116
  export async function runFold(root, { epic, step, env = process.env, capture = runCapture } = {}) {
114
117
  const refuse = (msg, hint) => { fail(msg); if (hint) hand(hint); process.exitCode = 1; };
115
118
  if (!epic || !step) return refuse('yad fold needs an epic and a step', `usage: yad fold <epic> <step> (steps: ${FOLD_STEPS.join(', ')})`);
116
- if (!/^EP-[a-z0-9-]+$/.test(epic)) return refuse(`not an epic id: ${epic}`, 'an epic id looks like EP-<slug> (the Product level is EP-foundation)');
119
+ // One rule with the rest of yad, which also keeps foldSubject's lowercased scope inside the gate's [a-z0-9._-].
120
+ if (!isValidEpicId(epic)) return refuse(`not an epic id: ${epic}`, 'an epic id looks like EP-<slug> (the Product level is EP-foundation)');
117
121
  if (!FOLD_STEPS.includes(step)) return refuse(`${step} is not an authoring step with an artifact`, `steps: ${FOLD_STEPS.join(', ')}`);
118
122
  // The Product level has one folder, `foundation/`; a feature step never runs there, and `foundation`
119
123
  // never runs in an epic. (`discovery` is the old spelling, which lived in an ordinary epic folder.)
@@ -236,7 +240,7 @@ export async function runFold(root, { epic, step, env = process.env, capture = r
236
240
  fs.rmSync(tmp, { recursive: true, force: true });
237
241
  }
238
242
  const sha = git(['rev-parse', 'HEAD']).out.trim();
239
- const subject = `docs(${epic}): author ${step}`;
243
+ const subject = foldSubject(epic, step);
240
244
  ok(`${subject} → ${sha.slice(0, 7)} (${files.length} file(s))`);
241
245
  if (sorted.seed.length) info(`with the new epic's seed: ${sorted.seed.join(', ')}`);
242
246
  if (sorted.ledger.length) info(`with the ledger (${verified ? 'a new epic\'s seed' : 'ledger: local'}): ${sorted.ledger.length} file(s)`);
@@ -23,7 +23,7 @@ import { isVerifiedLedger } from './manifest.mjs';
23
23
  import {
24
24
  epicRel, epicRoot, loadLedger, findReviewStep, artifactHash, acceptedHashes, gatePredicate, printable, advanceState,
25
25
  gateRuleSum, gateRuleEnforced, legacyLogins, canonicalApprovals, canonicalComments, optionalStepsFor, writeState,
26
- isPassed, stepStatus, readFrontmatter,
26
+ isPassed, stepStatus, readFrontmatter, heldByReopen,
27
27
  } from './epic-state.mjs';
28
28
  import { activePeople, activeSum, activeBasis } from './people.mjs';
29
29
  import { actorName } from './platform.mjs';
@@ -270,6 +270,14 @@ export async function gateAdvance(root, { epic, artifact, today, headCount = nul
270
270
  return;
271
271
  }
272
272
  if (refuseUnopened(g, { epic, artifact, verb: 'advance' })) return;
273
+ // After a reopen the gates pass again in order (#322).
274
+ const held = heldByReopen(ledger.state, step.id);
275
+ if (held) {
276
+ fail(`${step.id} waits for ${held}, an earlier step not passed since \`yad gate reopen\` — nothing is written`);
277
+ hand(`pass ${held} first; the gates from a reopened step pass again in order`);
278
+ process.exitCode = 1;
279
+ return { epic, advanced: false, currentStep: ledger.state.currentStep ?? null, gate: null };
280
+ }
273
281
  const people = countPeople(root, g.productConfig, today, headCount);
274
282
  log(` ${c.dim(activeSum(people))}`);
275
283
  note(c.dim(activeBasis(people)));