@yagni-app/code-staging 1.2.14-staging.2338.1 → 1.2.14-staging.2344.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.
@@ -122,6 +122,12 @@ export interface AttemptResult extends CloudIdentity {
122
122
  * host writes each into the plan as Wright's decision.
123
123
  */
124
124
  planChanges?: PlanChange[];
125
+ /**
126
+ * The pull request's description the session wrote (`pull-request.md`,
127
+ * `sessionLane.ts`); absent when it wrote none. The host scrubs it and
128
+ * adds its own parts.
129
+ */
130
+ pullRequestText?: string;
125
131
  }
126
132
  /** The findings the result reports, blocking first. */
127
133
  export declare function openFindings(findings: readonly Finding[]): OpenFinding[];
@@ -63,6 +63,17 @@ export declare const SESSION_CALLER_LABEL = "go:session";
63
63
  export declare function isSessionLaneTurn(env?: NodeJS.ProcessEnv): boolean;
64
64
  /** The model's own account of a turn that builds, beside `result.json` in the output folder. */
65
65
  export declare const SESSION_REPORT_FILE_NAME = "session-report.json";
66
+ /**
67
+ * The pull request's description as the session writes it, beside its
68
+ * report. A file of its own, never a field of the report: Markdown of many
69
+ * lines inside JSON is easy to break, and a report that does not read loses
70
+ * the checks. The host scrubs it and adds its own parts.
71
+ */
72
+ export declare const PULL_REQUEST_FILE_NAME = "pull-request.md";
73
+ /** The most of the description a result carries (the host's bound, `MAX_PULL_REQUEST_TEXT_CHARS`). */
74
+ export declare const MAX_PULL_REQUEST_TEXT_CHARS = 20000;
75
+ /** The description as the result carries it: trimmed and bounded, or null when the file is missing or empty. */
76
+ export declare function pullRequestTextOf(text: string | null): string | null;
66
77
  /** What a plan turn may use: everything that reads or runs, nothing that edits. */
67
78
  export declare const PLAN_TURN_TOOLS: string[];
68
79
  /** What a turn that builds may use: the plan turn's tools and the writes. */
@@ -77,6 +77,20 @@ export function isSessionLaneTurn(env = process.env) {
77
77
  }
78
78
  /** The model's own account of a turn that builds, beside `result.json` in the output folder. */
79
79
  export const SESSION_REPORT_FILE_NAME = "session-report.json";
80
+ /**
81
+ * The pull request's description as the session writes it, beside its
82
+ * report. A file of its own, never a field of the report: Markdown of many
83
+ * lines inside JSON is easy to break, and a report that does not read loses
84
+ * the checks. The host scrubs it and adds its own parts.
85
+ */
86
+ export const PULL_REQUEST_FILE_NAME = "pull-request.md";
87
+ /** The most of the description a result carries (the host's bound, `MAX_PULL_REQUEST_TEXT_CHARS`). */
88
+ export const MAX_PULL_REQUEST_TEXT_CHARS = 20_000;
89
+ /** The description as the result carries it: trimmed and bounded, or null when the file is missing or empty. */
90
+ export function pullRequestTextOf(text) {
91
+ const words = text?.trim() ?? "";
92
+ return words ? words.slice(0, MAX_PULL_REQUEST_TEXT_CHARS) : null;
93
+ }
80
94
  /** What a plan turn may use: everything that reads or runs, nothing that edits. */
81
95
  export const PLAN_TURN_TOOLS = [
82
96
  "read",
@@ -165,6 +179,12 @@ const REPORT_CONTRACT = (outDir) => `Last, write ${join(outDir, SESSION_REPORT_F
165
179
  'not a pass, and goes in "notVerified". "baseline" is "fails_on_base" only when the check already ' +
166
180
  'failed on the unchanged code. "planChanges" lists only a step you did differently than plan.md ' +
167
181
  "says, or left out, never a choice the plan left to you. Then end your turn.";
182
+ const PULL_REQUEST_CONTRACT = (outDir) => `Before the report, write ${join(outDir, PULL_REQUEST_FILE_NAME)}: the description of this attempt's pull request ` +
183
+ "as it stands after this turn, whole, in Markdown, for a reviewer who has not read the ticket. Lead with the product, " +
184
+ 'never the files: what changes for the user, or one line "No product change: <what this is>". For a product change ' +
185
+ "give a **Before:** and **After:** pair as the user meets it. Then what you verified and how, and what you did not " +
186
+ "verify and why. Short sentences, no file-by-file list. Never quote command output, a log, or a value from the " +
187
+ "environment: everyone on the repository reads it. Write no title, checks table or plan version: YAGNI adds those.";
168
188
  const BUILD_RULES = (outDir) => [
169
189
  "Write tools are on now. Work as your playbook says:",
170
190
  "- Prefer the smallest change that meets the ticket.",
@@ -172,6 +192,7 @@ const BUILD_RULES = (outDir) => [
172
192
  "- Run the checks that prove the change (checks.json, the plan's checks) and fix what your change breaks.",
173
193
  "- Before you finish, dispatch a fresh verification subagent on your diff with the ticket and the plan, and fix what it finds that is real.",
174
194
  "- Commit on the branch you are on. Never push and never open or edit a pull request: YAGNI pushes your commits and opens it.",
195
+ `- ${PULL_REQUEST_CONTRACT(outDir)}`,
175
196
  `- ${REPORT_CONTRACT(outDir)}`,
176
197
  ].join("\n");
177
198
  const INPUTS = (inputDir) => [
@@ -769,7 +790,7 @@ async function runTurn(input, deps, pulse) {
769
790
  }, ran);
770
791
  const noted = { ...done.attempt, notes: [...notes, ...done.attempt.notes] };
771
792
  const attempt = writes
772
- ? withSessionAccount(noted, parseSessionReport(readOrNull(join(input.outDir, SESSION_REPORT_FILE_NAME)), knownBaselines(input.inputDir, readFile)))
793
+ ? withSessionAccount(noted, parseSessionReport(readOrNull(join(input.outDir, SESSION_REPORT_FILE_NAME)), knownBaselines(input.inputDir, readFile)), pullRequestTextOf(readOrNull(join(input.outDir, PULL_REQUEST_FILE_NAME))))
773
794
  : noted;
774
795
  // The cloud lane's finish wrote `result.json`; it is written again when
775
796
  // this turn adds to it (the model's account, the plan turn's put-back).
@@ -798,13 +819,23 @@ async function planWithBlock(run, turn, signal) {
798
819
  return { run: took ? again : run, asked: [again] };
799
820
  }
800
821
  /**
801
- * A writing turn's result with the model's own account folded in, and a
822
+ * A writing turn's result with the model's own account and its pull
823
+ * request's description folded in (one that wrote none says so), and a
802
824
  * clean turn that committed nothing read as having found nothing to change:
803
825
  * the host's `no_changes`, which it finishes as a clean one when the turn
804
826
  * verified work an earlier turn pushed.
805
827
  */
806
- function withSessionAccount(attempt, report) {
807
- const folded = withReport(attempt, report);
828
+ function withSessionAccount(attempt, report, pullRequestText) {
829
+ const reported = withReport(attempt, report);
830
+ const folded = pullRequestText
831
+ ? { ...reported, pullRequestText }
832
+ : {
833
+ ...reported,
834
+ notes: [
835
+ ...reported.notes,
836
+ `The session wrote no ${PULL_REQUEST_FILE_NAME}, so its pull request's description is YAGNI's own.`,
837
+ ],
838
+ };
808
839
  return folded.stopReason === "clean" && folded.commits.length === 0
809
840
  ? { ...folded, stopReason: "no_changes" }
810
841
  : folded;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagni-app/code-staging",
3
- "version": "1.2.14-staging.2338.1",
3
+ "version": "1.2.14-staging.2344.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": "b21f46be1a45b4fc1810754e49f64635b25f748e"
61
+ "yagniSourceSha": "59b841d14cd83acb42f9360256e74be3f6f15144"
62
62
  }