paseo-follow-up 2.0.1 → 2.0.2-beta.0

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.
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
- import { idSchema, textSchema, type Pr, type Snapshot, type Workspace } from "./model";
2
+ import { idSchema, textSchema } from "./model";
3
+ import type { ListPr as Pr, ListSnapshot as Snapshot, ListWorkspace as Workspace } from "./list";
3
4
 
4
5
  export const prActionKind = z.enum(["merge", "enable_mwr", "disable_mwr"]);
5
6
  export const actionPrSchema = z.object({ key: idSchema, repo: z.string(), number: z.number(), title: z.string(), head: z.string(), parent: idSchema.nullable(), base: z.string(), trunk: z.string(), blockers: z.array(z.string()) });
@@ -24,8 +25,8 @@ export const mergeStageSchema = z.enum(["merged", "queued", "requested"]);
24
25
  export type MergeStage = z.infer<typeof mergeStageSchema>;
25
26
  export const actionResultSchema = z.object({ state: z.enum(["submitted", "failed", "uncertain"]), result: textSchema, merge: mergeStageSchema.optional() });
26
27
 
27
- export function downstack(prs: Pr[], target: string): Pr[] {
28
- const selected: Pr[] = []; const seen = new Set<string>();
28
+ export function downstack<P extends Pr>(prs: P[], target: string): P[] {
29
+ const selected: P[] = []; const seen = new Set<string>();
29
30
  let key: string | null = target; let repo: string | null = null;
30
31
  while (key) {
31
32
  if (seen.has(key)) throw new Error("This stack has a parent cycle. Reconcile its tracking before merging.");
@@ -59,8 +60,8 @@ export function githubBlocker(s: Snapshot): string | null {
59
60
  if (state === "DIRTY" || state === "DRAFT") return null; // Reported as Merge conflicts / Draft already.
60
61
  if (state === "BEHIND") return "Behind its base branch (update the branch)";
61
62
  if (state === "BLOCKED") {
62
- if (s.threads.length) return `${s.threads.length} unresolved review thread${s.threads.length === 1 ? "" : "s"}`;
63
- if (s.failedChecks.length || s.checksPending || !githubApproved(s)) return null; // Already named.
63
+ if (s.threads?.length) return `${s.threads?.length} unresolved review thread${s.threads?.length === 1 ? "" : "s"}`;
64
+ if (s.failedChecks?.length || s.checksPending || !githubApproved(s)) return null; // Already named.
64
65
  return "A branch protection rule or ruleset";
65
66
  }
66
67
  return "GitHub’s mergeability check";
@@ -74,7 +75,7 @@ export function mergeBlockers(pr: Pr): string[] {
74
75
  if (s.draft) blockers.push("Draft");
75
76
  if (github ? !githubApproved(s) : s.reviewDecision !== "APPROVED") blockers.push(github && s.reviewDecision === "CHANGES_REQUESTED" ? "Changes requested" : "Awaiting approval");
76
77
  if (s.conflict) blockers.push("Merge conflicts");
77
- if (s.failedChecks.length) blockers.push("Required checks failed");
78
+ if (s.failedChecks?.length) blockers.push("Required checks failed");
78
79
  if (s.checksPending) blockers.push("Required checks pending");
79
80
  if (github) { if (s.inMergeQueue) blockers.push("Already in the merge queue"); const g = githubBlocker(s); if (g) blockers.push(g); }
80
81
  else if (!graphiteReady(s.graphiteMergeStatus)) blockers.push(graphiteBlocker(s.graphiteMergeStatus));
@@ -1,4 +1,5 @@
1
- import { settled, statusKnown, type Pr } from "./model";
1
+ import { settled, statusKnown } from "./model";
2
+ import type { ListPr as Pr } from "./list";
2
3
  import { deployed } from "./follow-up";
3
4
 
4
5
  export const graphitePrUrl = (pr: Pick<Pr, "repo" | "number">): string => `https://app.graphite.com/github/pr/${pr.repo}/${pr.number}`;
@@ -36,8 +37,8 @@ export function prPresentation(pr: Pr): { label: string; tone: "merged" | "appro
36
37
  if (s.state === "MERGED") return { label: "Merged", tone: "merged" };
37
38
  if (s.state === "CLOSED") return { label: "Closed", tone: "neutral" };
38
39
  if (s.conflict) return { label: "Conflicts", tone: "warning" };
39
- if (s.threads.length) return { label: `${s.threads.length} review thread${s.threads.length === 1 ? "" : "s"}`, tone: "warning" };
40
- if (s.failedChecks.length) return { label: "Checks failed", tone: "warning" };
40
+ if (s.threads?.length) return { label: `${s.threads?.length} review thread${s.threads?.length === 1 ? "" : "s"}`, tone: "warning" };
41
+ if (s.failedChecks?.length) return { label: "Checks failed", tone: "warning" };
41
42
  if (s.otherFailedChecks?.length) return { label: s.otherFailedChecks.length === 1 ? "Optional check failed" : "Optional checks failed", tone: "warning" };
42
43
  if (s.draft) return { label: "Draft", tone: "neutral" };
43
44
  if (s.checksPending) return { label: "Checks running", tone: "neutral" };
@@ -55,8 +56,8 @@ export function compactPrStatus(pr: Pr): ReturnType<typeof prPresentation> {
55
56
  if (status.label !== "Merged" || !pr.snapshot?.deployment) return { ...status, label: status.label.replace("Status unavailable", "Unknown").replace(/review thread/, "thread").replace("Checks running", "Checking") };
56
57
  return { label: deployed(pr) ? "Deployed" : "Merged", tone: "merged" };
57
58
  }
58
- export function orderedStacks(prs: Pr[]): { name: string; prs: Pr[] }[] {
59
- const groups = new Map<string, Pr[]>();
59
+ export function orderedStacks<P extends Pr>(prs: P[]): { name: string; prs: P[] }[] {
60
+ const groups = new Map<string, P[]>();
60
61
  for (const pr of prs) { const rows = groups.get(pr.stack) ?? []; rows.push(pr); groups.set(pr.stack, rows); }
61
62
  const priority = (rows: Pr[]) => rows.every(settledForDisplay) ? 2 : rows.some(p => prPresentation(p).tone === "warning" || !statusKnown(p) || p.snapshot.state === "CLOSED" && !settled(p)) ? 0 : 1;
62
63
  return [...groups].map(([name, prs]) => ({ name, prs })).sort((a, b) => priority(a.prs) - priority(b.prs));
@@ -91,7 +91,7 @@ export type Question = z.infer<typeof questionSchema>;
91
91
  export type QuestionOption = z.infer<typeof questionOptionSchema>;
92
92
  export type Answer = z.infer<typeof answerSchema>;
93
93
 
94
- export const isOpen = (q: Question) => !q.answer && !q.closed;
94
+ export const isOpen = (q: Pick<Question, "answer" | "closed">) => !q.answer && !q.closed;
95
95
 
96
96
  /** Q1, Q2…: unique for the life of the workspace, never reused after a question closes. */
97
97
  export function nextQuestionId(questions: Pick<Question, "id">[]): string {
@@ -140,7 +140,7 @@ export const answerTitle = (text: string) => text.replace(/\)/g, "").replace(/[(
140
140
  /** The lines Follow-up adds after an answer: the answer and the developer's note run until one of these. */
141
141
  const ANSWER_TRAILER = /^(?:The developer added: |None of your options|You were building |Continue|Answered by .+ for the developer\.$)/;
142
142
  /** The message sent to the asking agent. It starts with ANSWER_PREFIX so chat rows and history scans recognise it. */
143
- export function answerMessage(q: Question, choice: string, words?: string): string {
143
+ export function answerMessage(q: Pick<Question, "id" | "title" | "mode" | "big" | "recommend" | "taskId" | "answer"> & { options: readonly { letter: string; label: string }[] }, choice: string, words?: string): string {
144
144
  const lines = [`${ANSWER_PREFIX} ${q.id} (${answerTitle(q.title)}): ${answerHead(q, choice, words)}`];
145
145
  if (isOther(choice)) lines.push("None of your options: the developer's own answer is in the quotes.");
146
146
  else if (words?.trim()) lines.push(`The developer added: ${words.trim()}`);
@@ -280,8 +280,10 @@ const nearIdentical = (a: QuestionShape, b: QuestionShape) => textSimilarity(a,
280
280
  * open needs_you decisions; another agent's question only when near-identical. Blocked-task questions keep their own
281
281
  * identity (the task and its revision) and never match.
282
282
  */
283
- export function findOpenMatch(questions: readonly Question[], input: QuestionShape, askedBy: string | null): { question: Question; verdict: "same" | "changed" } | null {
284
- let best: { question: Question; verdict: "same" | "changed"; score: number } | null = null;
283
+ /** Matching reads only what list views carry (ListQuestion), so Home's invariant checks run on the list form too. */
284
+ type Matchable = QuestionShape & Pick<Question, "id" | "answer" | "closed" | "taskRevision" | "askedBy" | "via">;
285
+ export function findOpenMatch<Q extends Matchable>(questions: readonly Q[], input: QuestionShape, askedBy: string | null): { question: Q; verdict: "same" | "changed" } | null {
286
+ let best: { question: Q; verdict: "same" | "changed"; score: number } | null = null;
285
287
  for (const q of questions) {
286
288
  if (!isOpen(q) || q.taskRevision !== null) continue;
287
289
  const own = q.askedBy === askedBy || q.via === "needs_you";
@@ -294,9 +296,9 @@ export function findOpenMatch(questions: readonly Question[], input: QuestionSha
294
296
  }
295
297
 
296
298
  /** Open questions that repeat an older open one in the same workspace: [duplicate, original] pairs. The invariant. */
297
- export function duplicateOpenQuestions(questions: readonly Question[]): { duplicate: Question; of: Question }[] {
298
- const out: { duplicate: Question; of: Question }[] = [];
299
- const kept: Question[] = [];
299
+ export function duplicateOpenQuestions<Q extends Matchable>(questions: readonly Q[]): { duplicate: Q; of: Q }[] {
300
+ const out: { duplicate: Q; of: Q }[] = [];
301
+ const kept: Q[] = [];
300
302
  for (const q of questions) {
301
303
  if (!isOpen(q)) continue;
302
304
  const match = q.taskRevision === null ? findOpenMatch(kept, q, q.askedBy) : null;
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import type { Pr } from "./model";
2
+ import type { ListPr as Pr } from "./list";
3
3
 
4
4
  /**
5
5
  * Who "Add reviewers" asks, per repository, set by the developer in Settings → Reviewers or remembered from the
@@ -1,6 +1,6 @@
1
1
  import type { NeedItem } from "./attention";
2
2
  import type { Workstream } from "./home";
3
- import type { Workspace } from "./model";
3
+ import type { ListWorkspace as Workspace } from "./list";
4
4
 
5
5
  /**
6
6
  * Home's row menu (right-click, long-press, the menu key): the quick moves on one workspace row without opening it.
package/shared/search.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { HomeGroupId, HomeModel, PaseoWorkspaceLite } from "./home";
2
- import type { Workspace } from "./model";
2
+ import type { ArchivedListWorkspace, ListWorkspace as Workspace } from "./list";
3
3
  import { linkedSearchText, type LinkedSearchItem } from "./linked-display";
4
4
 
5
5
  /**
@@ -219,12 +219,12 @@ export type AgentLite = { id: string; title: string | null; workspaceId: string
219
219
  * One document per Home row, plus Follow-up's archived workspaces. A workspace row carries every agent title in
220
220
  * that workspace; an agent row (one of several roots) carries its own title too.
221
221
  */
222
- export function homeSearchDocs(input: { model: HomeModel; paseo: PaseoWorkspaceLite[]; tracked: Workspace[]; archived?: Workspace[]; agents?: AgentLite[]; linked?: Record<string, readonly LinkedSearchItem[]> }): SearchDoc[] {
222
+ export function homeSearchDocs(input: { model: HomeModel; paseo: PaseoWorkspaceLite[]; tracked: Workspace[]; archived?: ArchivedListWorkspace[]; agents?: AgentLite[]; linked?: Record<string, readonly LinkedSearchItem[]> }): SearchDoc[] {
223
223
  const paseo = new Map(input.paseo.map(p => [p.id, p]));
224
224
  const tracked = new Map(input.tracked.map(w => [w.id, w]));
225
225
  const agentsBy = new Map<string, string[]>();
226
226
  for (const a of input.agents ?? []) if (a.workspaceId && a.title) agentsBy.set(a.workspaceId, [...agentsBy.get(a.workspaceId) ?? [], a.title]);
227
- const workspaceFields = (id: string | null, w: Workspace | undefined): SearchDoc["fields"] => {
227
+ const workspaceFields = (id: string | null, w: Pick<Workspace | ArchivedListWorkspace, "prs"> | undefined): SearchDoc["fields"] => {
228
228
  if (!id) return [];
229
229
  const p = paseo.get(id);
230
230
  const out: SearchDoc["fields"] = [];
@@ -1,4 +1,5 @@
1
- import type { Batch, Task, Workspace } from "./model";
1
+ import type { Task } from "./model";
2
+ import type { ListBatch as Batch, ListWorkspace as Workspace } from "./list";
2
3
  import { recoveryBatch } from "./follow-up";
3
4
 
4
5
  /** How long a new batch waits before it goes out on its own, so tasks that land together go in one message. */
package/shared/sending.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import type { Workspace } from "./model";
2
+ import type { ListWorkspace as Workspace } from "./list";
3
3
  import { summary } from "./model";
4
4
  import { batchView } from "./status";
5
5
  import { sendDecision } from "./send-decision";
@@ -3,7 +3,7 @@ import { oneReading } from "./status";
3
3
  import type { Actor } from "./actor";
4
4
  import { ANY_HOOK_TEXT_PREFIXES } from "./message-sender";
5
5
  import { BATCH_PREFIXES, RECOVERY_TITLES } from "./legacy";
6
- import type { Workspace } from "./model";
6
+ import type { ListWorkspace as Workspace } from "./list";
7
7
  import { answerMessage, awaitingSend, duplicateOpenQuestions, isOther, parseAnswerMessage, parseAnswersMessage } from "./questions";
8
8
  import { briefAnswer, briefAnswers, briefAsks, briefStep, reviewersBriefPr, shouldReopen, type Brief } from "./brief";
9
9
  import { workspaceHeadline, sayNew, repeatsRow, flagHeadline, HEADLINE_WORD } from "./headline";
package/shared/status.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Batch, Workspace } from "./model";
1
+ import type { ListBatch as Batch, ListWorkspace as Workspace } from "./list";
2
2
  import { completionCheck, CANCEL_CAUSES } from "./model";
3
3
  import { recoveryBatch } from "./follow-up";
4
4
  import { SETTLE_MS, sendDecision } from "./send-decision";
@@ -1,4 +1,6 @@
1
- import type { Batch, Obligation, Task, Workspace } from "./model";
1
+ import type { Task } from "./model";
2
+ import type { Workspace as FullWorkspace } from "./model";
3
+ import type { ListBatch as Batch, ListObligation as Obligation, ListWorkspace as Workspace } from "./list";
2
4
  import { completionCheck } from "./model";
3
5
  import { recoveryBatch } from "./follow-up";
4
6
  import { sendDecision } from "./send-decision";
@@ -95,7 +97,7 @@ export function repairRows(w: Workspace, doneLimit = 20): { open: RepairRow[]; d
95
97
  }
96
98
 
97
99
  /** The next message for workspace_status (agent parity with Preview): who it goes to, its tasks, exact text, and when and why. */
98
- export function nextMessageInfo(w: Workspace, now: number): { to: string; tasks: string[]; text: string; reason: string; eta: string | null } | null {
100
+ export function nextMessageInfo(w: FullWorkspace, now: number): { to: string; tasks: string[]; text: string; reason: string; eta: string | null } | null {
99
101
  const pending = pendingMessage(w);
100
102
  if (!pending) return null;
101
103
  const d = sendDecision(w, now, { batch: pending });
@@ -1,4 +1,5 @@
1
- import { blockedOnDeveloper, type Obligation, type Workspace } from "./model";
1
+ import { blockedOnDeveloper } from "./model";
2
+ import type { ListObligation as Obligation, ListWorkspace as Workspace } from "./list";
2
3
  import { taskSchedule } from "./task-trigger";
3
4
  import { isLive } from "./agent-load";
4
5
  import { obligationDelivery } from "./task-rows";
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import type { Obligation, Workspace, Pr } from "./model";
2
+ import type { ListObligation as Obligation, ListWorkspace as Workspace, ListPr as Pr } from "./list";
3
3
  import { deployed } from "./follow-up";
4
4
 
5
5
  export const taskTriggerSchema = z.object({ event: z.enum(["now", "merge", "deploy"]), delayDays: z.number().int().min(0).max(3650).default(0) });