@yagni-app/code-staging 1.2.14-staging.2283.1 → 1.2.14-staging.2286.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.
- package/dist/extension/pipeline/cloud.d.ts +30 -0
- package/dist/extension/pipeline/cloud.js +79 -3
- package/dist/extension/pipeline/finish.d.ts +6 -0
- package/dist/extension/pipeline/finish.js +46 -2
- package/dist/extension/pipeline/sessionLane.d.ts +2 -1
- package/dist/extension/pipeline/sessionLane.js +17 -1
- package/package.json +2 -2
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* lives (`packages/shared/src/attempts.ts`): the two meet only at this JSON.
|
|
17
17
|
*/
|
|
18
18
|
import type { ContinuationStage } from "./continuation.js";
|
|
19
|
+
import { type RunFinishOpts } from "./finish.js";
|
|
19
20
|
import { type PlanChange } from "./planChanges.js";
|
|
20
21
|
import { type VerifyCheckRun, type VerifyOutcome } from "./verify.js";
|
|
21
22
|
import type { WorktreeExec } from "./worktree.js";
|
|
@@ -210,7 +211,36 @@ export interface CloudCompletion {
|
|
|
210
211
|
planPaths: (planText: string) => string[];
|
|
211
212
|
exec: WorktreeExec;
|
|
212
213
|
writeFile: (path: string, text: string) => void;
|
|
214
|
+
/**
|
|
215
|
+
* The System's other repositories a yak's session may change in place
|
|
216
|
+
* (YAG-1211), each with its dirt from before the turn: each gets this
|
|
217
|
+
* repository's final commit over its own leftovers (YAG-1217). Absent on
|
|
218
|
+
* every other session.
|
|
219
|
+
*/
|
|
220
|
+
others?: ReadonlyArray<OtherRepositoryFinish>;
|
|
221
|
+
/** The attempt's branch, for a detached checkout among `others` to take before its commit. */
|
|
222
|
+
othersBranch?: string | null;
|
|
223
|
+
}
|
|
224
|
+
/** Another repository of a yak's System, as the turn's final commit meets it (YAG-1217). */
|
|
225
|
+
export interface OtherRepositoryFinish {
|
|
226
|
+
/** `owner/name`. */
|
|
227
|
+
repository: string;
|
|
228
|
+
/** Its working copy. */
|
|
229
|
+
cwd: string;
|
|
230
|
+
/** Its dirt from before the turn, never committed. */
|
|
231
|
+
preRunDirt: readonly string[];
|
|
213
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* The final commit in each of the System's other repositories a yak's
|
|
235
|
+
* session changed (YAG-1217): the ticket's own repository's commit, with its
|
|
236
|
+
* message and trailers, over that repository's own leftovers only (never its
|
|
237
|
+
* dirt from before the turn). One holding nothing of the turn's own is left
|
|
238
|
+
* alone, so no note is written for it. A detached checkout takes the
|
|
239
|
+
* attempt's branch first when that branch is not there yet, so the next
|
|
240
|
+
* wake knows the work as this attempt's. What could not be committed is a
|
|
241
|
+
* note naming the repository; the host names the repository in the thread.
|
|
242
|
+
*/
|
|
243
|
+
export declare function finishOtherRepositories(others: ReadonlyArray<OtherRepositoryFinish>, finish: Omit<RunFinishOpts, "cwd" | "baselinePaths" | "baseSha" | "exec">, exec: WorktreeExec, branch: string | null): Promise<string[]>;
|
|
214
244
|
/**
|
|
215
245
|
* The changes to the plan the session's implement stage reported: the last
|
|
216
246
|
* implement summary that carries a plan-changes block. None when no implement
|
|
@@ -23,7 +23,7 @@ import { extractPlanChanges, planChangeNote } from "./planChanges.js";
|
|
|
23
23
|
import { buildPlanFile, planMarkdown } from "./planOutput.js";
|
|
24
24
|
import { cloudLane } from "./stages.js";
|
|
25
25
|
import { applyStageTiers, parseStageTiers, STAGE_TIERS_ENV } from "./tierCap.js";
|
|
26
|
-
import { CHECK_NOT_RUN_NOTE } from "./verify.js";
|
|
26
|
+
import { CHECK_NOT_RUN_NOTE, parseChangedPaths, } from "./verify.js";
|
|
27
27
|
/** Set on every stage child of a cloud session, so its prompt describes the cloud sandbox. */
|
|
28
28
|
export const CLOUD_SESSION_ENV = "YAGNI_GO_CLOUD";
|
|
29
29
|
/** Where the session writes `plan.md`, `plan.json` and `result.json`. */
|
|
@@ -291,6 +291,75 @@ export function cannotRunNote(checks) {
|
|
|
291
291
|
function findingKey(finding) {
|
|
292
292
|
return `${finding.file ?? ""}:${finding.line ?? ""}:${finding.message}`;
|
|
293
293
|
}
|
|
294
|
+
const ATTEMPT_BRANCH = /^yagni\/[a-z0-9][a-z0-9._-]{0,120}$/;
|
|
295
|
+
/**
|
|
296
|
+
* Whether a checkout is on the attempt's branch, after a detached one takes
|
|
297
|
+
* it when that branch is not there yet: true, or why not, in words.
|
|
298
|
+
*/
|
|
299
|
+
async function onAttemptBranch(run, branch) {
|
|
300
|
+
if (!branch || !ATTEMPT_BRANCH.test(branch))
|
|
301
|
+
return "the host named no branch for this ticket";
|
|
302
|
+
const on = await run(["git", "branch", "--show-current"]);
|
|
303
|
+
if (on.code !== 0)
|
|
304
|
+
return "its branch could not be read";
|
|
305
|
+
const current = on.output.trim();
|
|
306
|
+
if (current === branch)
|
|
307
|
+
return true;
|
|
308
|
+
if (current)
|
|
309
|
+
return `it is on ${current}, not this ticket's branch`;
|
|
310
|
+
const there = await run(["git", "rev-parse", "--verify", "--quiet", `refs/heads/${branch}`]);
|
|
311
|
+
if (there.code === 0)
|
|
312
|
+
return "it is detached away from this ticket's branch";
|
|
313
|
+
const made = await run(["git", "checkout", "--quiet", "-b", branch]);
|
|
314
|
+
return made.code === 0 ? true : "this ticket's branch could not be made there";
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* The final commit in each of the System's other repositories a yak's
|
|
318
|
+
* session changed (YAG-1217): the ticket's own repository's commit, with its
|
|
319
|
+
* message and trailers, over that repository's own leftovers only (never its
|
|
320
|
+
* dirt from before the turn). One holding nothing of the turn's own is left
|
|
321
|
+
* alone, so no note is written for it. A detached checkout takes the
|
|
322
|
+
* attempt's branch first when that branch is not there yet, so the next
|
|
323
|
+
* wake knows the work as this attempt's. What could not be committed is a
|
|
324
|
+
* note naming the repository; the host names the repository in the thread.
|
|
325
|
+
*/
|
|
326
|
+
export async function finishOtherRepositories(others, finish, exec, branch) {
|
|
327
|
+
const notes = [];
|
|
328
|
+
for (const other of others) {
|
|
329
|
+
const run = (argv) => exec(argv, other.cwd).catch((err) => ({
|
|
330
|
+
code: -1,
|
|
331
|
+
output: err instanceof Error ? err.message : String(err),
|
|
332
|
+
}));
|
|
333
|
+
const status = await run(["git", "status", "--porcelain"]);
|
|
334
|
+
if (status.code !== 0) {
|
|
335
|
+
notes.push(`In ${other.repository}: what the turn left could not be read, so nothing there was committed.`);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
const before = new Set(other.preRunDirt);
|
|
339
|
+
if (parseChangedPaths(status.output).every((path) => before.has(path)))
|
|
340
|
+
continue;
|
|
341
|
+
// The commit goes on the attempt's branch only, never on another
|
|
342
|
+
// ticket's: a detached checkout takes the branch when it is not there
|
|
343
|
+
// yet; any other is said and left (Codex round 2).
|
|
344
|
+
const owned = await onAttemptBranch(run, branch);
|
|
345
|
+
if (owned !== true) {
|
|
346
|
+
notes.push(`In ${other.repository}: ${owned}, so what the turn left there was not committed.`);
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
const done = await runFinish({
|
|
350
|
+
...finish,
|
|
351
|
+
cwd: other.cwd,
|
|
352
|
+
// Dirt from before the turn stays out, staged or not (Codex round 1).
|
|
353
|
+
...(other.preRunDirt.length > 0
|
|
354
|
+
? { baselinePaths: [...other.preRunDirt], onlyRunOwned: true }
|
|
355
|
+
: {}),
|
|
356
|
+
exec,
|
|
357
|
+
});
|
|
358
|
+
if (!done.committed)
|
|
359
|
+
notes.push(...done.notes.map((note) => `In ${other.repository}: ${note}`));
|
|
360
|
+
}
|
|
361
|
+
return notes;
|
|
362
|
+
}
|
|
294
363
|
/**
|
|
295
364
|
* The changes to the plan the session's implement stage reported: the last
|
|
296
365
|
* implement summary that carries a plan-changes block. None when no implement
|
|
@@ -395,8 +464,7 @@ export async function completeCloudSession(c, ran) {
|
|
|
395
464
|
notes.push("The review loop stopped clean, but the final scan or checks found a blocker in what is committed.");
|
|
396
465
|
}
|
|
397
466
|
const title = c.plan ? planTitle(c.plan) : undefined;
|
|
398
|
-
const
|
|
399
|
-
cwd: c.cwd,
|
|
467
|
+
const commit = {
|
|
400
468
|
worktreeMode: true,
|
|
401
469
|
hereBaseline: "unknown",
|
|
402
470
|
ticket: ticketOfBranch(branch) ?? c.identity.attemptId,
|
|
@@ -411,12 +479,20 @@ export async function completeCloudSession(c, ran) {
|
|
|
411
479
|
decisionsRecorded: result?.decisionsRecorded ?? 0,
|
|
412
480
|
rounds: result?.rounds.length ?? 0,
|
|
413
481
|
openPr: false,
|
|
482
|
+
};
|
|
483
|
+
const finish = await runFinish({
|
|
484
|
+
...commit,
|
|
485
|
+
cwd: c.cwd,
|
|
414
486
|
...(c.preRunDirt.length > 0 ? { baselinePaths: c.preRunDirt } : {}),
|
|
415
487
|
...(c.baseSha ? { baseSha: c.baseSha } : {}),
|
|
416
488
|
exec: c.exec,
|
|
417
489
|
});
|
|
418
490
|
committed = finish.committed;
|
|
419
491
|
notes.push(...finish.notes);
|
|
492
|
+
// The System's other repositories get the same final commit (YAG-1217).
|
|
493
|
+
if (c.others?.length) {
|
|
494
|
+
notes.push(...(await finishOtherRepositories(c.others, commit, c.exec, c.othersBranch ?? null)));
|
|
495
|
+
}
|
|
420
496
|
}
|
|
421
497
|
const facts = await gitFacts(c.cwd, c.exec, c.baseSha);
|
|
422
498
|
notes.push(...facts.notes);
|
|
@@ -80,6 +80,12 @@ export interface RunFinishOpts extends TrailerInputs {
|
|
|
80
80
|
* commit on top, so the branch still carries the run's `YAGNI-Run` line.
|
|
81
81
|
*/
|
|
82
82
|
baseSha?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Commit only the run's own paths (`git commit -- <paths>`), never what was
|
|
85
|
+
* already staged among `baselinePaths` (a yak's System's other
|
|
86
|
+
* repositories, YAG-1217). Absent: the index is committed as staged.
|
|
87
|
+
*/
|
|
88
|
+
onlyRunOwned?: boolean;
|
|
83
89
|
signal?: AbortSignal;
|
|
84
90
|
exec?: WorktreeExec;
|
|
85
91
|
}
|
|
@@ -260,6 +260,36 @@ async function committedSince(run, baseSha) {
|
|
|
260
260
|
.map((line) => line.trim())
|
|
261
261
|
.filter(Boolean);
|
|
262
262
|
}
|
|
263
|
+
/** Each rename in `git status --porcelain` (`R old -> new`), as its source and destination. */
|
|
264
|
+
function renamesIn(status) {
|
|
265
|
+
const renames = [];
|
|
266
|
+
for (const raw of status.split("\n")) {
|
|
267
|
+
if (raw.length < 4 || !raw.slice(0, 2).includes("R"))
|
|
268
|
+
continue;
|
|
269
|
+
const entry = raw[2] === " " ? raw.slice(3) : raw.slice(2);
|
|
270
|
+
const arrow = entry.indexOf(" -> ");
|
|
271
|
+
if (arrow < 0)
|
|
272
|
+
continue;
|
|
273
|
+
const from = entry.slice(0, arrow).trim();
|
|
274
|
+
const to = entry.slice(arrow + 4).trim();
|
|
275
|
+
if (from && to)
|
|
276
|
+
renames.push({ from, to });
|
|
277
|
+
}
|
|
278
|
+
return renames;
|
|
279
|
+
}
|
|
280
|
+
/** The source of each rename whose destination is one of `paths`: a commit limited to paths names both. */
|
|
281
|
+
function renameSources(status, paths) {
|
|
282
|
+
const wanted = new Set(paths);
|
|
283
|
+
return renamesIn(status)
|
|
284
|
+
.filter((rename) => wanted.has(rename.to) && !wanted.has(rename.from))
|
|
285
|
+
.map((rename) => rename.from);
|
|
286
|
+
}
|
|
287
|
+
/** The destination of each rename whose source is among `baseline`. */
|
|
288
|
+
function renamedFrom(status, baseline) {
|
|
289
|
+
return renamesIn(status)
|
|
290
|
+
.filter((rename) => baseline.has(rename.from))
|
|
291
|
+
.map((rename) => rename.to);
|
|
292
|
+
}
|
|
263
293
|
/**
|
|
264
294
|
* Run the FINISH stage. NEVER throws; every failure path returns an honest
|
|
265
295
|
* {@link FinishResult} with notes. See the module docblock for the contract.
|
|
@@ -300,7 +330,12 @@ export async function runFinish(opts) {
|
|
|
300
330
|
// commit only these, so the provenance commit never folds in non-run work.
|
|
301
331
|
const changed = parseChangedPaths(status.output);
|
|
302
332
|
const baseline = new Set(opts.baselinePaths ?? []);
|
|
303
|
-
|
|
333
|
+
// A path-limited commit leaves out a rename whose source was dirt from
|
|
334
|
+
// before the run too: its destination carries that dirt (Codex round 3).
|
|
335
|
+
const dirtyRenames = opts.onlyRunOwned === true ? renamedFrom(status.output, baseline) : [];
|
|
336
|
+
const runOwned = baseline.size === 0
|
|
337
|
+
? changed
|
|
338
|
+
: changed.filter((p) => !baseline.has(p) && !dirtyRenames.includes(p));
|
|
304
339
|
// Nothing of the run's own left in the tree, but its work may already be
|
|
305
340
|
// committed past its base: the trailer then goes on an empty commit.
|
|
306
341
|
const committed = runOwned.length === 0 ? await committedSince(run, opts.baseSha) : [];
|
|
@@ -329,7 +364,16 @@ export async function runFinish(opts) {
|
|
|
329
364
|
return skipped(`FINISH could not stage the changes (git add failed: ${tail(add.output)}); nothing was committed.`);
|
|
330
365
|
}
|
|
331
366
|
}
|
|
332
|
-
|
|
367
|
+
// Only the run's own paths, so dirt from before the run that was already
|
|
368
|
+
// staged is never committed with them.
|
|
369
|
+
const only = opts.onlyRunOwned === true && !trailerOnly && baseline.size > 0;
|
|
370
|
+
const commitArgs = [
|
|
371
|
+
...(trailerOnly ? ["--allow-empty"] : []),
|
|
372
|
+
"-m",
|
|
373
|
+
message,
|
|
374
|
+
// A rename's source too, so its deletion goes with it (Codex round 2).
|
|
375
|
+
...(only ? ["--", ...runOwned, ...renameSources(status.output, runOwned)] : []),
|
|
376
|
+
];
|
|
333
377
|
let commit = await run(["git", "commit", ...commitArgs]);
|
|
334
378
|
if (commit.code !== 0) {
|
|
335
379
|
// Most likely a missing git identity in a fresh environment (mirrors
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
* verifies with a fresh `verification` subagent, commits and never
|
|
28
28
|
* pushes, and writes its own account to `session-report.json`. This
|
|
29
29
|
* process then runs what the cloud lane's finish runs (the secret and
|
|
30
|
-
* binary scan, a commit of anything left, the
|
|
30
|
+
* binary scan, a commit of anything left, in the ticket's repository
|
|
31
|
+
* and in each of a yak's System's other repositories, the git facts) and writes
|
|
31
32
|
* `result.json` with the model's checks, what it could not verify and
|
|
32
33
|
* where it departed from the plan folded in, each departure in
|
|
33
34
|
* `planChanges` for the host to write into the plan (`planChanges.ts`).
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
* verifies with a fresh `verification` subagent, commits and never
|
|
28
28
|
* pushes, and writes its own account to `session-report.json`. This
|
|
29
29
|
* process then runs what the cloud lane's finish runs (the secret and
|
|
30
|
-
* binary scan, a commit of anything left, the
|
|
30
|
+
* binary scan, a commit of anything left, in the ticket's repository
|
|
31
|
+
* and in each of a yak's System's other repositories, the git facts) and writes
|
|
31
32
|
* `result.json` with the model's checks, what it could not verify and
|
|
32
33
|
* where it departed from the plan folded in, each departure in
|
|
33
34
|
* `planChanges` for the host to write into the plan (`planChanges.ts`).
|
|
@@ -517,9 +518,12 @@ async function runTurn(input, deps, pulse) {
|
|
|
517
518
|
// A yak's System's other repositories, each as the turn found it, for the
|
|
518
519
|
// read of a writing turn's change for a placed secret (YAG-1211).
|
|
519
520
|
const others = [];
|
|
521
|
+
/** The attempt's branch the host named with them: a detached one takes it before its commit. */
|
|
522
|
+
let othersBranch = null;
|
|
520
523
|
if (writes) {
|
|
521
524
|
const listed = systemRepositoriesOf(readOrNull(join(input.inputDir, SYSTEM_REPOSITORIES_FILE_NAME)), input.cwd);
|
|
522
525
|
for (const { repository, dir, pushedHead, branch } of listed) {
|
|
526
|
+
othersBranch ??= branch;
|
|
523
527
|
const found = await snapshot(dir, input.signal);
|
|
524
528
|
others.push({
|
|
525
529
|
repository,
|
|
@@ -671,6 +675,18 @@ async function runTurn(input, deps, pulse) {
|
|
|
671
675
|
planPaths: (text) => baselineDirs(input.cwd, planPaths(text), readFile).map((dir) => relative(input.cwd, dir) || "."),
|
|
672
676
|
exec,
|
|
673
677
|
writeFile,
|
|
678
|
+
// Each other repository of the System gets the same final commit,
|
|
679
|
+
// over what the turn left there (YAG-1217).
|
|
680
|
+
...(others.length > 0
|
|
681
|
+
? {
|
|
682
|
+
others: others.map((other) => ({
|
|
683
|
+
repository: other.repository,
|
|
684
|
+
cwd: other.cwd,
|
|
685
|
+
preRunDirt: other.skip ?? [],
|
|
686
|
+
})),
|
|
687
|
+
othersBranch,
|
|
688
|
+
}
|
|
689
|
+
: {}),
|
|
674
690
|
}, ran);
|
|
675
691
|
const noted = { ...done.attempt, notes: [...notes, ...done.attempt.notes] };
|
|
676
692
|
const attempt = writes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yagni-app/code-staging",
|
|
3
|
-
"version": "1.2.14-staging.
|
|
3
|
+
"version": "1.2.14-staging.2286.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": "
|
|
61
|
+
"yagniSourceSha": "b3afbfd2d6403169485a62c523d0f37c0b07cf00"
|
|
62
62
|
}
|