@yagni-app/code-staging 1.2.15-staging.2594.1 → 1.2.15-staging.2596.1

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.
@@ -143,6 +143,18 @@ export interface AttemptResult extends CloudIdentity {
143
143
  qaSteps?: {
144
144
  text: string;
145
145
  skill: string | null;
146
+ /**
147
+ * What the steps were written from (YAG-1520): every repository read,
148
+ * its own (`repository: null`) and each other one by `owner/name`, with
149
+ * the head it was read at and whether it changed.
150
+ */
151
+ covers?: {
152
+ read: Array<{
153
+ repository: string | null;
154
+ head: string;
155
+ changed: boolean;
156
+ }>;
157
+ };
146
158
  };
147
159
  /**
148
160
  * How a plan turn asked for the plan's UI preview left it (`sessionLane.ts`):
@@ -226,6 +226,8 @@ export declare function systemRepositoriesOf(text: string | null, cwd: string):
226
226
  repository: string;
227
227
  dir: string;
228
228
  pushedHead: string | null;
229
+ /** Its pull request's target, as the host fetched it there this wake (YAG-1520). */
230
+ baseTip: string | null;
229
231
  branch: string | null;
230
232
  }>;
231
233
  /**
@@ -456,8 +458,8 @@ export declare function writeQaSteps(source: QaStepsSource, turn: (message: stri
456
458
  writeFile: (path: string, text: string) => void;
457
459
  /** The build's change, given up front (`changeForQaSteps`). */
458
460
  change?: string;
459
- /** The System's other repositories this session works in: named, their changes not shown. */
460
- otherRepositories?: readonly string[];
461
+ /** How many repositories the change is read from: one set of steps covers them all (YAG-1520). */
462
+ repositories?: number;
461
463
  }): Promise<{
462
464
  steps: {
463
465
  text: string;
@@ -283,7 +283,7 @@ export function systemRepositoriesOf(text, cwd) {
283
283
  if (!Array.isArray(parsed.repositories))
284
284
  return [];
285
285
  return parsed.repositories.flatMap((entry) => {
286
- const { fullName, dir, pushedHead } = (entry ?? {});
286
+ const { fullName, dir, pushedHead, baseTip } = (entry ?? {});
287
287
  if (typeof fullName !== "string" || typeof dir !== "string")
288
288
  return [];
289
289
  if (!isAbsolute(dir) || dir.includes("..") || dir === cwd)
@@ -294,6 +294,7 @@ export function systemRepositoriesOf(text, cwd) {
294
294
  repository: fullName,
295
295
  dir,
296
296
  pushedHead: pushed,
297
+ baseTip: typeof baseTip === "string" && SHA.test(baseTip) ? baseTip : null,
297
298
  branch,
298
299
  },
299
300
  ];
@@ -1037,12 +1038,16 @@ async function runTurn(input, deps, pulse, tally) {
1037
1038
  // A yak's System's other repositories, each as the turn found it, for the
1038
1039
  // read of a writing turn's change for a placed secret (YAG-1211).
1039
1040
  const others = [];
1041
+ /** Each other repository's pull request target, as the host fetched it there (YAG-1520). */
1042
+ const otherTips = new Map();
1040
1043
  /** The attempt's branch the host named with them: a detached one takes it before its commit. */
1041
1044
  let othersBranch = null;
1042
1045
  if (writes) {
1043
1046
  const listed = systemRepositoriesOf(readOrNull(join(input.inputDir, SYSTEM_REPOSITORIES_FILE_NAME)), input.cwd);
1044
- for (const { repository, dir, pushedHead, branch } of listed) {
1047
+ for (const { repository, dir, pushedHead, baseTip, branch } of listed) {
1045
1048
  othersBranch ??= branch;
1049
+ if (baseTip)
1050
+ otherTips.set(dir, baseTip);
1046
1051
  const found = await snapshot(dir, input.signal);
1047
1052
  others.push({
1048
1053
  repository,
@@ -1405,24 +1410,31 @@ async function runTurn(input, deps, pulse, tally) {
1405
1410
  done.ok &&
1406
1411
  finalStop === "clean" &&
1407
1412
  input.signal?.aborted !== true) {
1408
- // The steps describe the ticket's own repository's pull request, from
1409
- // the commit the host names as where it starts. The System's other
1410
- // repositories are named and not diffed: their checkouts hold no fetched
1411
- // base to read a pull request's start from, and the host's comment says
1412
- // their changes are not covered. A start not named, or not in the
1413
- // history, is unreadable, and no steps are written; the note says why.
1413
+ // The steps describe the whole ticket (YAG-1520): every repository's
1414
+ // pull request, each as GitHub reads it, from the merge-base with the
1415
+ // branch it merges into, read together. A start that cannot be found is
1416
+ // unreadable, and no steps are written for any repository; the note says
1417
+ // which one and why. A repository this turn did not change adds nothing.
1414
1418
  const baseOf = async (cwd, sha, fetchedBaseRef) => {
1415
1419
  const found = await pullRequestBaseOf(exec, cwd, sha, input.signal, fetchedBaseRef);
1416
1420
  return "sha" in found ? { base: found.sha } : { base: null, noBase: found.reason };
1417
1421
  };
1418
1422
  const change = await changeForQaSteps([
1419
1423
  {
1420
- repository: "This repository",
1424
+ repository: OWN_QA_REPOSITORY,
1421
1425
  cwd: input.cwd,
1422
1426
  // The base as the host last fetched it, where it did (every turn
1423
1427
  // that can follow a base merge); else the commit it names.
1424
1428
  ...(await baseOf(input.cwd, workflow.baseSha, FETCHED_BASE_REF)),
1425
1429
  },
1430
+ ...(await Promise.all(others.map(async (other) => ({
1431
+ repository: other.repository,
1432
+ cwd: other.cwd,
1433
+ // As the own one: the merge-base with the branch its pull
1434
+ // request merges into, at the commit the host fetched into its
1435
+ // checkout this wake and named. Not named, it has no start: no steps.
1436
+ ...(await baseOf(other.cwd, null, otherTips.get(other.cwd))),
1437
+ })))),
1426
1438
  ], exec, input.signal);
1427
1439
  if (change.unread.length > 0) {
1428
1440
  // Steps written without seeing the change are worse than none.
@@ -1440,7 +1452,7 @@ async function runTurn(input, deps, pulse, tally) {
1440
1452
  readOrNull,
1441
1453
  writeFile,
1442
1454
  change: change.text,
1443
- otherRepositories: others.map((other) => other.repository),
1455
+ repositories: change.changed,
1444
1456
  });
1445
1457
  if (steps.asked)
1446
1458
  stages.push(steps.asked);
@@ -1448,7 +1460,19 @@ async function runTurn(input, deps, pulse, tally) {
1448
1460
  notes.push(steps.note);
1449
1461
  input.writeErr(steps.logged ?? steps.note);
1450
1462
  }
1451
- qaSteps = steps.steps;
1463
+ // What the steps were written from, each repository at the head it was
1464
+ // read at: the host posts them for a ticket's several pull requests only
1465
+ // where these are its pull requests at the heads it published.
1466
+ qaSteps = steps.steps && {
1467
+ ...steps.steps,
1468
+ covers: {
1469
+ read: change.read.map(({ repository, head, changed }) => ({
1470
+ repository: repository === OWN_QA_REPOSITORY ? null : repository,
1471
+ head,
1472
+ changed,
1473
+ })),
1474
+ },
1475
+ };
1452
1476
  }
1453
1477
  }
1454
1478
  const noted = {
@@ -1482,6 +1506,8 @@ async function runTurn(input, deps, pulse, tally) {
1482
1506
  * The steps go to `qa-steps.md` and the result. A message that fails, or
1483
1507
  * leaves nothing, is a note: the build stands as it was. Never throws.
1484
1508
  */
1509
+ /** How the session's own repository is named in the change the QA steps message is given. */
1510
+ const OWN_QA_REPOSITORY = "This repository";
1485
1511
  /** How a QA steps turn that did not complete is named on the attempt, by `turnStop`'s reason. */
1486
1512
  const QA_STEPS_EARLY_STOP = {
1487
1513
  failed: "error",
@@ -1507,7 +1533,7 @@ export async function writeQaSteps(source, turn, buildStage, io) {
1507
1533
  else {
1508
1534
  skills = listRepositorySkills(io.cwd, trusted);
1509
1535
  }
1510
- asked = await turn(qaStepsMessage(source, skills, io.change ?? "", io.otherRepositories ?? []), {
1536
+ asked = await turn(qaStepsMessage(source, skills, io.change ?? "", io.repositories ?? 1), {
1511
1537
  ...buildStage,
1512
1538
  tools: QA_STEPS_TURN_TOOLS,
1513
1539
  });
@@ -73,7 +73,7 @@ type Exec = (argv: string[], cwd: string, signal?: AbortSignal) => Promise<{
73
73
  */
74
74
  export declare const FETCHED_BASE_REF = "refs/yagni/base";
75
75
  export declare function pullRequestBaseOf(exec: Exec, cwd: string, baseSha: string | null, signal?: AbortSignal,
76
- /** The ticket's checkout only: where the host fetched the base, when it did. */
76
+ /** Where the host fetched the branch the pull request merges into, when it did. */
77
77
  fetchedBaseRef?: string): Promise<{
78
78
  sha: string;
79
79
  } | {
@@ -102,13 +102,26 @@ export declare function changeForQaSteps(repositories: ReadonlyArray<{
102
102
  repository: string;
103
103
  reason: string;
104
104
  }>;
105
+ /** How many repositories changed, for the message's words. */
106
+ changed: number;
107
+ /**
108
+ * Every repository read, changed or not, with the head it was read at:
109
+ * what the steps were written from (YAG-1520).
110
+ */
111
+ read: Array<{
112
+ repository: string;
113
+ head: string;
114
+ changed: boolean;
115
+ }>;
105
116
  }>;
106
117
  /**
107
118
  * The message that asks for the QA steps, after a clean build: which skill
108
119
  * to use (the named one, the best fit among the repository's, or none), and
109
120
  * the answer's shape. Nothing in the repository is to change.
110
121
  */
111
- export declare function qaStepsMessage(source: QaStepsSource, skills: readonly RepositorySkill[], change?: string, otherRepositories?: readonly string[]): string;
122
+ export declare function qaStepsMessage(source: QaStepsSource, skills: readonly RepositorySkill[], change?: string,
123
+ /** How many repositories the change is read from (YAG-1520). */
124
+ repositories?: number): string;
112
125
  /**
113
126
  * The turn's answer as the result carries it: the steps without the first
114
127
  * line, and the skill that line names when it is one of the repository's;
@@ -216,7 +216,7 @@ export function repositorySkillsTrusted(sourcesText) {
216
216
  */
217
217
  export const FETCHED_BASE_REF = "refs/yagni/base";
218
218
  export async function pullRequestBaseOf(exec, cwd, baseSha, signal,
219
- /** The ticket's checkout only: where the host fetched the base, when it did. */
219
+ /** Where the host fetched the branch the pull request merges into, when it did. */
220
220
  fetchedBaseRef) {
221
221
  // After a merge of a newer base the pull request starts at the merge-base
222
222
  // with that base, never the attempt's first base: the merged-in upstream
@@ -253,6 +253,7 @@ export const MAX_QA_CHANGE_CHARS = 60_000;
253
253
  export async function changeForQaSteps(repositories, exec, signal) {
254
254
  const unread = [];
255
255
  const parts = [];
256
+ const read = [];
256
257
  let left = MAX_QA_CHANGE_CHARS;
257
258
  for (const repo of repositories) {
258
259
  const git = (...args) => exec(["git", "-c", "core.hooksPath=/dev/null", ...args], repo.cwd, signal).catch(() => ({
@@ -268,8 +269,10 @@ export async function changeForQaSteps(repositories, exec, signal) {
268
269
  }
269
270
  const files = await git("diff", "--name-status", `${repo.base}..HEAD`);
270
271
  const diff = await git("diff", "--no-color", "--no-ext-diff", `${repo.base}..HEAD`);
271
- if (files.code !== 0 || diff.code !== 0) {
272
- const failed = files.code !== 0 ? files : diff;
272
+ const head = await git("rev-parse", "HEAD");
273
+ const at = head.output.trim();
274
+ if (files.code !== 0 || diff.code !== 0 || head.code !== 0 || !COMMIT.test(at)) {
275
+ const failed = [files, diff, head].find((ran) => ran.code !== 0) ?? head;
273
276
  // The tail of what git said, through the lane's redaction, bounded.
274
277
  const tail = scrubSecrets(failed.output).trim().split("\n").slice(-3).join(" ").slice(-300);
275
278
  unread.push({
@@ -278,7 +281,9 @@ export async function changeForQaSteps(repositories, exec, signal) {
278
281
  });
279
282
  continue;
280
283
  }
281
- if (!files.output.trim())
284
+ const changed = files.output.trim() !== "";
285
+ read.push({ repository: repo.repository, head: at, changed });
286
+ if (!changed)
282
287
  continue;
283
288
  const text = diff.output.length > left
284
289
  ? `${diff.output.slice(0, Math.max(0, left))}\n(The diff is cut here; read the files for the rest.)`
@@ -286,7 +291,7 @@ export async function changeForQaSteps(repositories, exec, signal) {
286
291
  left -= Math.min(diff.output.length, left);
287
292
  parts.push(`## ${repo.repository}\n\nFiles changed:\n${files.output.trim()}\n\n\`\`\`diff\n${text.trimEnd()}\n\`\`\``);
288
293
  }
289
- return { text: parts.join("\n\n"), unread };
294
+ return { text: parts.join("\n\n"), unread, changed: parts.length, read };
290
295
  }
291
296
  /** The first line of the turn's answer when the yak wrote the steps itself. */
292
297
  const OWN_WORDS = "written-by: yak";
@@ -295,7 +300,9 @@ const OWN_WORDS = "written-by: yak";
295
300
  * to use (the named one, the best fit among the repository's, or none), and
296
301
  * the answer's shape. Nothing in the repository is to change.
297
302
  */
298
- export function qaStepsMessage(source, skills, change = "", otherRepositories = []) {
303
+ export function qaStepsMessage(source, skills, change = "",
304
+ /** How many repositories the change is read from (YAG-1520). */
305
+ repositories = 1) {
299
306
  const named = source.source === "skill"
300
307
  ? skills.find((skill) => skill.name.toLowerCase() === source.skill.toLowerCase())
301
308
  : undefined;
@@ -325,8 +332,8 @@ export function qaStepsMessage(source, skills, change = "", otherRepositories =
325
332
  lines.push(`Write the steps in your own words, and start your last message with the line "${OWN_WORDS}".`);
326
333
  }
327
334
  lines.push("Where a skill says to run a command, you cannot: write the steps from what you can read.", "Your last message is the steps, in Markdown, and nothing else.");
328
- if (otherRepositories.length > 0) {
329
- lines.push(`This build also works in ${otherRepositories.join(", ")}. Their changes are not shown here and the steps do not cover them: write the steps for this repository's change.`);
335
+ if (repositories > 1) {
336
+ lines.push(`This change spans ${repositories} repositories, each shown below. A tester tests the application, not a repository: write one set of steps for the whole change, as a person uses it, with no section per repository.`);
330
337
  }
331
338
  if (change.trim())
332
339
  lines.push("", "The change, as the build committed it:", "", change);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagni-app/code-staging",
3
- "version": "1.2.15-staging.2594.1",
3
+ "version": "1.2.15-staging.2596.1",
4
4
  "description": "YAGNI Code: a terminal coding agent that already knows your company. One YAGNI login routes the model and grounds the agent in your team's context.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "YAGNI, Inc. <jack@yagni.app> (https://yagni.app)",
@@ -58,5 +58,5 @@
58
58
  "turndown": "^7.2.4",
59
59
  "typebox": "^1.3.15"
60
60
  },
61
- "yagniSourceSha": "25126ec6429f90ed337088607a80c80d827a653b"
61
+ "yagniSourceSha": "160670818b2891ed1484b086aaf1fdd0a36dc7a4"
62
62
  }