@yagni-app/code-staging 1.2.14-staging.2318.1 → 1.2.14-staging.2335.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.
@@ -73,7 +73,22 @@ export interface PlanFile {
73
73
  size?: PlanSize;
74
74
  /** One line on why the size, clipped; absent when the plan wrote none. */
75
75
  sizeReason?: string;
76
+ /**
77
+ * The ticket's problem is already gone, as the ticket check shows: the plan
78
+ * recommends closing the ticket, with its evidence, and has nothing to
79
+ * build. The host opens a Decision a person answers instead of the plan's
80
+ * gate. Absent on every plan that builds something.
81
+ */
82
+ closeTicket?: {
83
+ why: string;
84
+ evidence: string[];
85
+ };
76
86
  }
87
+ /**
88
+ * The plan's `closeTicket`, or null when it says neither why nor any
89
+ * evidence. Evidence lines are clipped, and an empty one is dropped.
90
+ */
91
+ export declare function readCloseTicket(value: unknown): PlanFile["closeTicket"] | null;
77
92
  /** The plan's `wrongRepository`, or null when it names no `owner/name`. Confidence is high only when said. */
78
93
  export declare function readWrongRepository(value: unknown): PlanFile["wrongRepository"] | null;
79
94
  /** The plan's `dependsOn`, one entry per distinct repository, in the order written. */
@@ -27,6 +27,24 @@ const MAX_REPOSITORIES_NEEDED = 12;
27
27
  * outside this set is dropped, never the plan.
28
28
  */
29
29
  const PLAN_SIZES = ["small", "standard", "complex"];
30
+ /** At most this many evidence lines on a close recommendation. */
31
+ const MAX_CLOSE_EVIDENCE = 10;
32
+ /**
33
+ * The plan's `closeTicket`, or null when it says neither why nor any
34
+ * evidence. Evidence lines are clipped, and an empty one is dropped.
35
+ */
36
+ export function readCloseTicket(value) {
37
+ if (!isRecord(value))
38
+ return null;
39
+ const why = text(value.why) ?? "";
40
+ const evidence = list(value.evidence)
41
+ .map((entry) => text(entry))
42
+ .filter((entry) => entry !== null)
43
+ .slice(0, MAX_CLOSE_EVIDENCE);
44
+ if (!why && evidence.length === 0)
45
+ return null;
46
+ return { why, evidence };
47
+ }
30
48
  /** The plan's `wrongRepository`, or null when it names no `owner/name`. Confidence is high only when said. */
31
49
  export function readWrongRepository(value) {
32
50
  if (!isRecord(value))
@@ -165,8 +183,10 @@ export function buildPlanFile(planText, fallbackPaths) {
165
183
  if (decisionsCited.length === MAX_LIST)
166
184
  break;
167
185
  }
186
+ const closeTicket = readCloseTicket(block?.closeTicket);
168
187
  const checks = [];
169
- for (const entry of list(block?.checks)) {
188
+ // A close recommendation builds nothing, so it proves nothing and touches no folder.
189
+ for (const entry of closeTicket ? [] : list(block?.checks)) {
170
190
  const command = isRecord(entry) ? text(entry.command) : null;
171
191
  if (!isRecord(entry) || !command)
172
192
  continue;
@@ -181,7 +201,9 @@ export function buildPlanFile(planText, fallbackPaths) {
181
201
  const named = list(block?.paths)
182
202
  .map(repoPath)
183
203
  .filter((path) => path !== null);
184
- const paths = [...new Set(named.length > 0 ? named : fallbackPaths())].slice(0, MAX_LIST);
204
+ const paths = closeTicket
205
+ ? []
206
+ : [...new Set(named.length > 0 ? named : fallbackPaths())].slice(0, MAX_LIST);
185
207
  const repositoriesNeeded = readRepositoriesNeeded(block?.repositoriesNeeded);
186
208
  const wrongRepository = readWrongRepository(block?.wrongRepository);
187
209
  const size = PLAN_SIZES.find((known) => known === block?.size);
@@ -199,6 +221,7 @@ export function buildPlanFile(planText, fallbackPaths) {
199
221
  followUps: readFollowUps(block?.followUps),
200
222
  ...(size ? { size } : {}),
201
223
  ...(size && sizeReason ? { sizeReason } : {}),
224
+ ...(closeTicket ? { closeTicket } : {}),
202
225
  },
203
226
  found: block !== null,
204
227
  };
@@ -38,7 +38,7 @@ export function planReviewTask(inputDir, planText, round) {
38
38
  `Read the ticket, every image it names, and ${at("checks.json")}, ${at("memo.md")} and ${at("playbook.md")} when they exist. Then read the code the plan touches. Change nothing in the repository and commit nothing.`,
39
39
  [
40
40
  "Judge the plan on these questions, and verify each against the code before you answer it:",
41
- '1. Ticket check: does the plan open with a premises table, each premise checked with the command, file or query that shows it, or marked as not checkable, and with "Done when"? Is a premise it marks as checked really true? A missing ticket check, a missing "Done when", or a false premise is major.',
41
+ '1. Ticket check: does the plan open with a premises table, each premise checked with the command, file or query that shows it, or marked as not checkable, and with "Done when"? Is a premise it marks as checked really true? A missing ticket check, a missing "Done when", or a false premise is major. A plan that recommends closing the ticket because its problem is already gone: check that evidence yourself; a close the code does not support is major.',
42
42
  "2. Half-measures: is any step a shortcut where the right fix is known and cheap now?",
43
43
  "3. Needless complexity: a new file, abstraction, option or flag the ticket does not need?",
44
44
  "4. Unintended side effects: other callers of the code it changes, shared state, contracts, data. Search for the callers; do not guess.",
@@ -183,13 +183,15 @@ const INPUTS = (inputDir) => [
183
183
  "- playbook.md: the Team's planning rules. Always follow them.",
184
184
  "- plan-line.md: this Team's instructions for planning.",
185
185
  ].join("\n");
186
+ /** A close recommendation sent back is a person's call that the ticket needs work. */
187
+ const PLANNED_ANYWAY = "If the plan sent back recommended closing the ticket, the person chose to plan it anyway: plan the change, and do not recommend closing it again.";
186
188
  const PLAN_RULES = [
187
189
  "This turn you have read, grep, find, ls, bash, ask_yagni, team_read, prototype_read and subagent, and no edit or write tool.",
188
190
  "Run whatever settles a fact: the tests, a type check, the app, Docker, a query. Change no tracked file and commit nothing: anything this turn changes in the repository is put back before the plan's gate.",
189
191
  `Call team_read with tool "${DECISIONS_READ_TOOL}" before you ask a person anything: a question an earlier decision on this repository already answers is not a question.`,
190
192
  "Check the ticket before you plan on it: each premise it states that the plan relies on, against the code, the git history or the data.",
191
193
  "End the turn with the plan as your last message. Open it with ## Ticket check: a table of premise | checked, or not checkable | the command, file:line or query that shows it, one row per premise. Then ## Done when: the ticket's acceptance criteria, or yours when it has none, one line each. Then ## Goal (one sentence), ## Plan (numbered steps, each naming the file or function), ## Files to modify / create (say \"new\" beside a file the plan creates), ## Checks and ## Risks, then the plan-json block. Where there is a real choice of approach, ask it as a decision question with your recommendation and its alternatives; the plan's steps follow your recommendation.",
192
- 'When the ticket check shows the problem is already gone, recommend closing the ticket instead of planning a change: ## Goal says so in one sentence, the ticket check holds the evidence, ## Plan has the one step "Close the ticket: nothing to build", and the plan-json block names no checks and no paths.',
194
+ 'When the ticket check shows the problem is already gone, recommend closing the ticket instead of planning a change: ## Goal says so in one sentence, the ticket check holds the evidence, ## Plan says "Nothing to build." with no numbered steps, and the plan-json block carries "closeTicket" with the evidence and names no checks and no paths. A person then decides whether to close it.',
193
195
  PLAN_JSON_CONTRACT,
194
196
  "Then stop: a fresh reviewer reads the plan next, and its major findings come back to you in this session to revise. A person approves the plan before anything is built.",
195
197
  ].join("\n\n");
@@ -203,7 +205,7 @@ export function turnMessage(facts) {
203
205
  const newSince = facts.newSinceLastTurn?.trim();
204
206
  if (facts.stage === "plan") {
205
207
  if (facts.resumed && facts.sentBack) {
206
- parts.push(`A person sent your plan back. What they asked is in ${at("ticket.md")}, and the plan they sent back is ${at("sent-back-plan.md")}. Plan again: keep what they did not ask to change.`);
208
+ parts.push(`A person sent your plan back. What they asked is in ${at("ticket.md")}, and the plan they sent back is ${at("sent-back-plan.md")}. Plan again: keep what they did not ask to change. ${PLANNED_ANYWAY}`);
207
209
  }
208
210
  else if (facts.resumed) {
209
211
  parts.push(`Plan this ticket again from ${at("ticket.md")}.`);
@@ -211,7 +213,7 @@ export function turnMessage(facts) {
211
213
  else {
212
214
  parts.push("This is the plan turn of a YAGNI attempt. Work the ticket as your playbook says, up to the plan: nothing is built until a person approves it.", INPUTS(facts.inputDir));
213
215
  if (facts.sentBack) {
214
- parts.push(`A person sent an earlier plan back: what they asked is in ${at("ticket.md")}, and that plan is ${at("sent-back-plan.md")}.`);
216
+ parts.push(`A person sent an earlier plan back: what they asked is in ${at("ticket.md")}, and that plan is ${at("sent-back-plan.md")}. ${PLANNED_ANYWAY}`);
215
217
  }
216
218
  }
217
219
  if (newSince)
@@ -88,6 +88,12 @@ export declare const RIGHT_REPOSITORY_RULE: string;
88
88
  * repository goes in repositoriesNeeded, so the host offers the split.
89
89
  */
90
90
  export declare const FOLLOW_UPS_RULE: string;
91
+ /**
92
+ * A ticket whose problem is already gone (the ticket check shows it) is a
93
+ * close recommendation, not a plan: the host opens a Decision a person
94
+ * answers, Close the ticket or Plan it anyway, and nothing is built.
95
+ */
96
+ export declare const CLOSE_TICKET_RULE: string;
91
97
  export declare const PLAN_JSON_CONTRACT: string;
92
98
  /**
93
99
  * The one-attempt lane's session (`yagni go --headless --cloud`): plan,
@@ -187,6 +187,15 @@ export const FOLLOW_UPS_RULE = '- "followUps" lists what you found that the tick
187
187
  '- Never put off the ticket\'s own work ("for another session", "in a later ticket"). Plan all of ' +
188
188
  "what it asked for. Work it needs in another repository goes in repositoriesNeeded, so the ticket " +
189
189
  "is split, and is never left out of the plan.";
190
+ /**
191
+ * A ticket whose problem is already gone (the ticket check shows it) is a
192
+ * close recommendation, not a plan: the host opens a Decision a person
193
+ * answers, Close the ticket or Plan it anyway, and nothing is built.
194
+ */
195
+ export const CLOSE_TICKET_RULE = '- "closeTicket" is only for a ticket whose problem the ticket check shows is already gone: ' +
196
+ 'say why in one line and list the evidence, each the command, file:line or query and what it showed. ' +
197
+ 'Then the plan has no steps, and "checks" and "paths" stay empty. A person decides whether to close ' +
198
+ "the ticket. Leave it out whenever there is anything to build.";
190
199
  export const PLAN_JSON_CONTRACT = "End your answer with a fenced ```plan-json block and nothing after it:\n" +
191
200
  "```plan-json\n" +
192
201
  "{\n" +
@@ -204,7 +213,8 @@ export const PLAN_JSON_CONTRACT = "End your answer with a fenced ```plan-json bl
204
213
  ' "dependsOn": [{"repository": "owner/name", "what": "one line on what it needs there"}],\n' +
205
214
  ' "size": "small|standard|complex",\n' +
206
215
  ' "sizeReason": "one line on why the size",\n' +
207
- ' "followUps": [{"title": "...", "why": "one line", "repository": "owner/name"}]\n' +
216
+ ' "followUps": [{"title": "...", "why": "one line", "repository": "owner/name"}],\n' +
217
+ ' "closeTicket": {"why": "one line", "evidence": ["the command, file:line or query, and what it showed"]}\n' +
208
218
  "}\n" +
209
219
  "```\n" +
210
220
  "Rules the host enforces, so getting them wrong loses the question:\n" +
@@ -227,7 +237,9 @@ export const PLAN_JSON_CONTRACT = "End your answer with a fenced ```plan-json bl
227
237
  "\n" +
228
238
  RIGHT_REPOSITORY_RULE +
229
239
  "\n" +
230
- FOLLOW_UPS_RULE;
240
+ FOLLOW_UPS_RULE +
241
+ "\n" +
242
+ CLOSE_TICKET_RULE;
231
243
  /**
232
244
  * The cloud plan stage's task: the input folder the host wrote, read first,
233
245
  * then a plan grounded in the installed checkout, inside the stage's own
@@ -470,6 +470,39 @@ export function detectVerifyTestCommands(cwd, opts = {}) {
470
470
  const root = pickTestScript(cwd, readFile, pm);
471
471
  return root ? [root] : [];
472
472
  }
473
+ /**
474
+ * The shell's own line for a command it could not find, ending the line, after
475
+ * whatever prefix a runner adds (`[0] `, turbo's `app:test: `, `pnpm -r`'s
476
+ * `packages/app test: `): bash's `bash: line 1: pnpm: command not found`,
477
+ * `node: command not found`, make's `make[1]: tsc: Command not found`, zsh's
478
+ * `zsh: command not found: tsc` (`./x.zsh:12: …`, `(eval):1: …`) and dash's
479
+ * `sh: 1: tsc: not found`. Never the words inside a sentence: a test's name,
480
+ * an assertion or a fixture that quotes them is not why the run failed
481
+ * (BENCH-1464, YAG-1254).
482
+ */
483
+ const SHELL_COMMAND_NOT_FOUND = [
484
+ /(?:^|[\s:\]>|])[\w./@+-]+: command not found\s*$/im,
485
+ /:(?:\d+:)? command not found: [\w./@+-]+\s*$/m,
486
+ /(?:^|[\s:\]>|])(?:\S*\/)?(?:da)?sh: \d+: [\w./@+-]+: not found\s*$/m,
487
+ ];
488
+ /**
489
+ * A line a test runner prints to name a test, a suite or a result: node:test's
490
+ * `✔ name (1ms)` / `✖ name (1ms)` / `▶ suite`, jest's and vitest's `✓` / `✕` /
491
+ * `×`, TAP's `ok 1 - name` / `not ok 1 - name` / `# Subtest: name`. A test's
492
+ * name is not evidence of why the run failed, however it reads (a test of the
493
+ * infra classifier is named for what it classifies); an error printed under it
494
+ * is. A failure bullet counts only with the runner's duration after it, so a
495
+ * logger's `✖ connect ECONNREFUSED` or a diagnostic's `× …` is still read.
496
+ */
497
+ const TEST_NAME_LINE = /^\s*(?:[✔✓▶]\s|(?:not )?ok \d+ - |# Subtest: )/u;
498
+ const FAILED_TEST_NAME_LINE = /^\s*[✕✖✗×]\s.*\s\(?\d+(?:\.\d+)?\s?m?s\)?\s*$/u;
499
+ /** The output without the lines that only name tests ({@link TEST_NAME_LINE}). */
500
+ function withoutTestNames(output) {
501
+ return output
502
+ .split("\n")
503
+ .filter((line) => !TEST_NAME_LINE.test(line) && !FAILED_TEST_NAME_LINE.test(line))
504
+ .join("\n");
505
+ }
473
506
  /**
474
507
  * Infra/environment failure classification for the typecheck half (spec §3b,
475
508
  * invariant §0.2). A fresh run worktree has no node_modules until the bootstrap
@@ -491,8 +524,9 @@ export function detectVerifyTestCommands(cwd, opts = {}) {
491
524
  export function classifyVerifyInfraFailure(output, exitCode) {
492
525
  if (exitCode === 127)
493
526
  return "command not found (exit 127; missing node_modules?)";
494
- if (/command not found/i.test(output))
527
+ if (SHELL_COMMAND_NOT_FOUND.some((re) => re.test(output))) {
495
528
  return "command not found (missing node_modules?)";
529
+ }
496
530
  if (/not recognized as an internal or external command/i.test(output)) {
497
531
  return "command not found (missing node_modules?)";
498
532
  }
@@ -812,14 +846,17 @@ const FAILURE_SUMMARY = [
812
846
  export function classifyTestFailure(output, exitCode, limit = MAX_LOCATED_FINDINGS, env) {
813
847
  if (exitCode === 0)
814
848
  return { kind: "clean" };
815
- const spawnInfra = classifyVerifyInfraFailure(output, exitCode);
849
+ // Infra evidence is read without the lines that only name tests: a test
850
+ // named for "command not found" or ECONNREFUSED is not why the run failed.
851
+ const evidence = withoutTestNames(output);
852
+ const spawnInfra = classifyVerifyInfraFailure(evidence, exitCode);
816
853
  if (spawnInfra)
817
854
  return { kind: "infra", reason: spawnInfra };
818
- const needs = classifyMissingPrerequisite(output, env);
855
+ const needs = classifyMissingPrerequisite(evidence, env);
819
856
  if (needs)
820
857
  return { kind: "infra", reason: `needs ${needs}`, needs };
821
858
  for (const [re, reason] of TEST_INFRA_PATTERNS) {
822
- if (re.test(output))
859
+ if (re.test(evidence))
823
860
  return { kind: "infra", reason };
824
861
  }
825
862
  // Per-test failure lines, deduped by test name; a later duplicate that DOES
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagni-app/code-staging",
3
- "version": "1.2.14-staging.2318.1",
3
+ "version": "1.2.14-staging.2335.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": "6e6f47f73826b217af99de721a08c4b933ad7b50"
61
+ "yagniSourceSha": "35efd555ad9b431ae70fff71519cd0da75cd814b"
62
62
  }