ticket-runner 0.6.3 → 0.6.5

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 (49) hide show
  1. package/README.ko.md +4 -4
  2. package/README.md +3 -3
  3. package/docs/templates/operator-skill.md +7 -7
  4. package/package.json +1 -1
  5. package/src/acceptance-criteria.ts +2 -2
  6. package/src/adapters/claude-agent-runner.ts +49 -5
  7. package/src/adapters/exec.ts +19 -4
  8. package/src/adapters/gh-tracker.ts +17 -17
  9. package/src/adapters/git-workspace.ts +12 -8
  10. package/src/adapters/liveness.ts +77 -0
  11. package/src/adapters/process-tree.ts +4 -7
  12. package/src/adapters/version.ts +5 -5
  13. package/src/branch.ts +1 -1
  14. package/src/cli.ts +2 -2
  15. package/src/config.ts +7 -6
  16. package/src/conventions.ts +23 -20
  17. package/src/credential.ts +92 -7
  18. package/src/criteria.ts +107 -15
  19. package/src/failing-base.ts +7 -7
  20. package/src/failure-message.ts +72 -0
  21. package/src/guards.ts +2 -2
  22. package/src/handoff.ts +2 -2
  23. package/src/init.ts +8 -8
  24. package/src/landing.ts +1 -1
  25. package/src/lifecycle.ts +2 -2
  26. package/src/lock.ts +10 -2
  27. package/src/note-schema.ts +3 -3
  28. package/src/notes.ts +8 -6
  29. package/src/operator-skill.ts +2 -2
  30. package/src/orchestrator.ts +194 -144
  31. package/src/ports/agent-runner.ts +21 -1
  32. package/src/ports/tracker.ts +14 -13
  33. package/src/ports/workspace.ts +23 -22
  34. package/src/progress.ts +2 -2
  35. package/src/prompts.ts +74 -25
  36. package/src/readiness.ts +11 -11
  37. package/src/remove.ts +7 -7
  38. package/src/resume.ts +12 -12
  39. package/src/run-log.ts +5 -5
  40. package/src/run.ts +72 -10
  41. package/src/staleness.ts +14 -14
  42. package/src/start.ts +20 -15
  43. package/src/stranded.ts +19 -19
  44. package/src/templates.ts +191 -73
  45. package/src/timer.ts +25 -0
  46. package/src/title.ts +45 -9
  47. package/src/verdict.ts +7 -7
  48. package/src/version-number.ts +13 -13
  49. package/src/version-pr.ts +12 -12
package/src/landing.ts CHANGED
@@ -17,7 +17,7 @@ export interface LandingTurn {
17
17
  * The Landing: the stretch of a Ticket from its rebase to the pull of the Base
18
18
  * branch after its merge, which one Ticket is in at a time (ADR-0005).
19
19
  *
20
- * A Run has one and every Ticket it drives shares it, so the Base branch cannot
20
+ * A Run has one and every Ticket it drives shares it, so the base branch cannot
21
21
  * move between a Ticket's rebase and its merge: what CI graded is what lands.
22
22
  * Turns are taken in arrival order — the Ticket that reaches the rebase first
23
23
  * lands first, whatever its number — and a Ticket that leaves the stretch for a
package/src/lifecycle.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Where a Ticket was when it failed. Named after the lifecycle step, not the
3
- * Stage, because Checks, rebase, PR and CI are not agent sessions.
3
+ * Stage, because Checks, rebase, pull request and CI are not agent sessions.
4
4
  */
5
5
  export type FailurePoint =
6
6
  | "setup"
@@ -19,7 +19,7 @@ export type FailurePoint =
19
19
  *
20
20
  * Every other failure ends the Ticket where it stands, because none of them is
21
21
  * a defect in the code a fresh session could go and mend: a Stage that never
22
- * came back, a Verdict with no evidence in it, a pull request whose checks
22
+ * came back, a verdict with no evidence in it, a pull request whose checks
23
23
  * timed out or never ran. A rebase conflict is on this list only once the
24
24
  * conflict Stage has failed to resolve it, which is what makes it a defect in
25
25
  * the branch rather than a state nobody has tried to mend yet. Uncommitted work
package/src/lock.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { execFileSync } from "node:child_process";
2
2
  import { readFileSync } from "node:fs";
3
+ import { endSentence } from "./failure-message.js";
3
4
  import { type Host, describeHost, sameHost } from "./host.js";
4
5
  import type { HeldLock, LockHolder } from "./ports/workspace.js";
5
6
 
@@ -57,10 +58,17 @@ export function lockFileContents(holder: LockHolder | undefined): string {
57
58
  /**
58
59
  * The commit message a lock change carries, which is what GitHub shows beside
59
60
  * the branch: who holds the Target, or that nobody does.
61
+ *
62
+ * A command that named a Ticket as `#<n>`, as `ticket-runner run #12` may, is
63
+ * written here without the `#`: GitHub links a pushed commit that mentions
64
+ * `#<n>` to issue `<n>`, on whatever branch the commit is, so every take would
65
+ * leave a line on that Ticket's timeline. The lock file keeps the command as it
66
+ * was typed.
60
67
  */
61
68
  export function lockCommitMessage(holder: LockHolder | undefined): string {
62
69
  if (holder === undefined) return "Free";
63
- return `Held by run ${holder.runId} on ${describeHost(holder.host)}: ${holder.command}`;
70
+ const command = holder.command.replace(/#+(?=\d)/g, "");
71
+ return `Held by run ${holder.runId} on ${describeHost(holder.host)}: ${command}`;
64
72
  }
65
73
 
66
74
  /**
@@ -121,7 +129,7 @@ export function lockHeldMessage({ holder, onAnotherHost }: HeldLock): string {
121
129
  */
122
130
  export function unreleasedLockMessage(reason: string): string {
123
131
  return (
124
- `Could not release the Run lock: ${reason}. It still names this Run on the ` +
132
+ `Could not release the Run lock: ${endSentence(reason)} It still names this Run on the ` +
125
133
  `\`${LOCK_BRANCH}\` branch. The next Run on this Host takes it over by itself; for a ` +
126
134
  `Run on any other Host, commit a \`${LOCK_FILE}\` that reads \`${FREE_LOCK}\` to that ` +
127
135
  "branch on GitHub, or ask an Operator to."
@@ -6,9 +6,9 @@
6
6
  * a Stage actually reads: two copies would drift, and the Stage reading the
7
7
  * stale one would be the only place it showed.
8
8
  *
9
- * A module of its own rather than a corner of `notes.ts`, because the Verdict's
9
+ * A module of its own rather than a corner of `notes.ts`, because the verdict's
10
10
  * schema carries this list too and `notes.ts` reaches the templates a Note is
11
- * posted with, which read a Verdict. Only the shape a Stage is asked for lives
11
+ * posted with, which read a verdict. Only the shape a Stage is asked for lives
12
12
  * here, so both schemas can share it without that cycle.
13
13
  *
14
14
  * `ticket` is optional on purpose: a Stage that guesses a number puts the Note
@@ -65,7 +65,7 @@ export const NOTES_LIST_SCHEMA = {
65
65
  * Stages' schema and their prompts use: one declaration, so the two cannot drift.
66
66
  */
67
67
  export const OWN_DEFECT =
68
- "A defect this branch introduced, one that behaves correctly on the Base branch and wrongly here, or one in code this branch added, belongs to this Ticket";
68
+ "A defect this branch introduced, one that behaves correctly on the base branch and wrongly here, or one in code this branch added, belongs to this Ticket";
69
69
 
70
70
  /**
71
71
  * The list as the implement and fix Stages read it: a defect their own branch
package/src/notes.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * A Stage that meets a defect in code it was not sent to touch has three bad
5
5
  * options and one good one. Fixing it widens the Ticket past the Acceptance
6
- * Criteria the Verdict grades. Ignoring it loses it. Writing it into the
6
+ * Criteria the verdict grades. Ignoring it loses it. Writing it into the
7
7
  * Ticket's own comments buries it under a Ticket that is about to close. So it
8
8
  * records a **Note** instead, and the pipeline puts the Note where somebody
9
9
  * will meet it: the comments of the Ticket it belongs to, or the standing
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * Notes ride along with the structured output of the implement, verify and fix
13
13
  * Stages: the two that write code, which meet what they were not sent to touch,
14
- * and the one that grades, whose Verdict has a slot per Acceptance Criterion and
14
+ * and the one that grades, whose verdict has a slot per Acceptance Criterion and
15
15
  * none for anything else it found. A Stage with nothing to report emits an empty
16
16
  * list and is not treated differently for it.
17
17
  */
@@ -61,7 +61,7 @@ export interface RoutedNote {
61
61
  origin: number;
62
62
  /**
63
63
  * The Stage that made it, or the pipeline itself: the one Note no Stage
64
- * writes is the pipeline's, about a Base branch failing a Check.
64
+ * writes is the pipeline's, about a base branch failing a Check.
65
65
  */
66
66
  stage: NotingStage | "pipeline";
67
67
  /** The issue the Note reached: the Ticket it named, or the standing Notes issue. */
@@ -378,9 +378,11 @@ async function route(routing: NoteRouting, note: Note): Promise<RoutedNote> {
378
378
  return { origin, stage, issue: ticket, opened: false, summary: text.summary };
379
379
  }
380
380
  } catch (error) {
381
+ // The message last, as every other event logs one, so what a failed
382
+ // command printed follows the line it is printed under.
381
383
  routing.log?.(
382
- `#${origin} could not comment its Note on #${ticket} ` +
383
- `(${(error as Error).message}); sending it to triage instead`,
384
+ `#${origin} could not comment its Note on #${ticket}, sending it to triage instead: ` +
385
+ (error as Error).message,
384
386
  );
385
387
  return await sendToTriage(routing, { ...from, intended: ticket });
386
388
  }
@@ -400,7 +402,7 @@ async function route(routing: NoteRouting, note: Note): Promise<RoutedNote> {
400
402
  * finishes with, after `which`.
401
403
  *
402
404
  * Claimed is the label alone, not the assignee with it: the pipeline's own
403
- * Claim writes both, but a human who took a Ticket may have written only the
405
+ * claim writes both, but a human who took a Ticket may have written only the
404
406
  * label, and either way there is somebody on it.
405
407
  */
406
408
  async function buriedOn(routing: NoteRouting, ticket: number): Promise<string | undefined> {
@@ -11,8 +11,8 @@ import { readFileSync } from "node:fs";
11
11
  * Its text is a shape like every other the pipeline writes, so it lives with
12
12
  * them in `docs/templates/`, and it is read from there rather than copied into
13
13
  * this module: the package carries that one file for this. The text names no
14
- * Version. The Operator reads the one to install off the conventions document's
15
- * mark, so a Target is never rewritten for a Version that changed nothing here.
14
+ * version. The Operator reads the one to install off the conventions document's
15
+ * mark, so a Target is never rewritten for a version that changed nothing here.
16
16
  */
17
17
 
18
18
  /** Where the skill goes in a Target, relative to the Target's root. */