@kana-ai/edgar-ext-slack 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -54,7 +54,7 @@ The first message about a card opens its thread. The message is the card's title
54
54
  The end note is one message with blocks and the same words as plain text, which a notification and a screen reader show:
55
55
 
56
56
  1. The headline: one emoji, the status in words, and the card. When the run names the card's id, the id is the link, and the service and the title follow: "ENG-1 · api: Search fails". With no id, the title is the link. A run with no card names its workflow, or the run.
57
- 2. One or two sentences. They greet the assignee ("Hey <assignee>,") when the card is assigned: a Slack mention, `<@U0123ABCD>`, when the extension finds their Slack user, else the name as the tracker gives it. The extension uses the first of these: the `people` entry whose key is the assignee's name, the `operators` entry whose name is the assignee's name, and the assignee itself when it is an email address. An email is found with `users.lookupByEmail`, once per process. When an email finds no user, the lookup fails, or the answer is not a Slack user id, the greeting has the plain name, the note is still posted, and the log has one line that names the assignee, the email and the reason. Then what happened:
57
+ 2. One or two sentences. They greet the assignee ("Hey <assignee>,") when the card is assigned: a Slack mention, `<@U0123ABCD>`, when the extension finds their Slack user, and no greeting otherwise, so a tracker name with no Slack user is never written. The extension uses the first of these: the `people` entry whose key is the assignee's name, the `operators` entry whose name is the assignee's name, and the assignee itself when it is an email address. An email is found with `users.lookupByEmail`, once per process. When an email finds no user, the lookup fails, or the answer is not a Slack user id, the note has no greeting, it is still posted, and the log has one line that names the assignee, the email and the reason. Then what happened:
58
58
  - "I've opened a pull request for <card>." or "I've opened <n> pull requests for <card>.", then the proposal's summary and, for a risk above low, the merge risk and its reason. A run of the built-in `remediate` says this at the moment its review wait (`wait_review`) starts, with no summary: see "The note that a pull request is ready".
59
59
  - "The pull request for <card> is merged.", then "<logins> approved it." and "The merge commit is `<7 characters>`." when the run read them. The note has no "Your move" and no word of the proposal, which was written before the pull request.
60
60
  - "The pull request for <card> is approved, and it isn't merged yet.", "A reviewer asked for changes on the pull request for <card>." or "The pull request for <card> was closed with no merge.", when the run ended with that decision of its reviewers.
@@ -84,7 +84,7 @@ An event whose `outcome` `endNote` cannot read still ends the progress message a
84
84
 
85
85
  ## The progress message
86
86
 
87
- Each run with a card keeps one message in the card's thread, with the metadata `edgar_plan`, and the hook changes it in place. The hook posts it at the run's first `attempt_started` event, not at `run_created`, so a run that ends before any stage starts leaves no line in the thread, and, when it ends `done`, no note either. A run that waits in a queue posts it earlier, at its `waiting_for_slot` event: the first line reads "Queued" with the still hourglass, and the next line says what the run waits on, such as "1 run for ENG-12 is going, which is my limit. I'll start when one ends." for a workflow's `concurrency`, or "I'm already running 4 steps at once, which is my limit." for the project's `[concurrency]`. The first stage that starts turns the same message into the plan. The `run_created` event only lists the run on the card's first message and, for a card from Slack, sets the session status `processing` with the card's title. Its first line is the status and the card, in a `context` block, so that Slack shows its text and its emoji small; the plain text of the message keeps the same line. Then it has one line for each stage that started, in the order of the starts: the emoji of its state and its label. A stage is added at its `attempt_started` event, so a stage that the run skips or never reaches is never shown, and an outcome `skipped` removes its line. A stage of the built-in workflows has a label in `words.ts`; another stage reads as its name in words. A stage that waits reads "Waiting for CI", "Waiting for a review" or "Waiting for you"; another wait reads "Waiting:" and the label. More than three done steps fold into one line, "<n> steps done". A done stage whose output has the `state` and the `review_state` of a pull request says what people decided in place of its label, on a line of its own beside the folded steps: "The pull request is approved", "The pull request is approved and merged", "The pull request is merged", "A reviewer asked for changes" or "The pull request was closed with no merge". The last line links the run's page, when `console_url` is set, and each pull request that a stage answered with `url` and `number`. In Slack the steps are a `plan` block, and the stage that runs also sets the moving status line of the thread with `assistant.threads.setStatus`: the stage's phrase from `status`, else "is on it:" and its label. Slack removes that line at the app's next message in the thread, or after 2 minutes.
87
+ Each run with a card keeps one message in the card's thread, with the metadata `edgar_plan`, and the hook changes it in place. The hook posts it at the run's first `attempt_started` event, not at `run_created`, so a run that ends before any stage starts leaves no line in the thread, and, when it ends `done`, no note either. A run that waits in a queue posts it earlier, at its `waiting_for_slot` event: the first line reads "Queued" with the still hourglass, and the next line says what the run waits on, such as "1 run for ENG-12 is going, which is my limit. I'll start when one ends." for a workflow's `concurrency`, "3 triage runs are going, which is my limit." when the run's input has no value at the key, so it counts with every other such run of its workflow, or "I'm already running 4 steps at once, which is my limit." for the project's `[concurrency]`. The first stage that starts turns the same message into the plan. The `run_created` event only lists the run on the card's first message and, for a card from Slack, sets the session status `processing` with the card's title. Its first line is the status and the card, in a `context` block, so that Slack shows its text and its emoji small; the plain text of the message keeps the same line. Then it has one line for each stage that started, in the order of the starts: the emoji of its state and its label. A stage is added at its `attempt_started` event, so a stage that the run skips or never reaches is never shown, and an outcome `skipped` removes its line. A stage of the built-in workflows has a label in `words.ts`; another stage reads as its name in words. A stage that waits reads "Waiting for CI", "Waiting for a review" or "Waiting for you"; another wait reads "Waiting:" and the label. More than three done steps fold into one line, "<n> steps done". A done stage whose output has the `state` and the `review_state` of a pull request says what people decided in place of its label, on a line of its own beside the folded steps: "The pull request is approved", "The pull request is approved and merged", "The pull request is merged", "A reviewer asked for changes" or "The pull request was closed with no merge". The last line links the run's page, when `console_url` is set, and each pull request that a stage answered with `url` and `number`. In Slack the steps are a `plan` block, and the stage that runs also sets the moving status line of the thread with `assistant.threads.setStatus`: the stage's phrase from `status`, else "is on it:" and its label. Slack removes that line at the app's next message in the thread, or after 2 minutes.
88
88
 
89
89
  The hook's process ends after some minutes with no work, so the hook keeps nothing that it cannot read again: the progress message holds its own state in its metadata, and the card and the trigger of a run that the process did not see start are read from the run's first event with `runs.read`, which the hook holds the capability `runs:read` for. A run that does not read is one line in the log, and its messages name no card.
90
90
 
@@ -23,7 +23,6 @@ export interface Asked {
23
23
  readonly cut: boolean;
24
24
  } | undefined;
25
25
  readonly card: NoteCard | undefined;
26
- readonly assignee: string | undefined;
27
26
  readonly user: string | undefined;
28
27
  readonly consoleUrl: string | undefined;
29
28
  }
@@ -33,7 +32,6 @@ export declare function askLayout(asked: Asked): Layout;
33
32
  export declare function questionLayout(asked: {
34
33
  readonly run: string;
35
34
  readonly card: NoteCard | undefined;
36
- readonly assignee: string | undefined;
37
35
  readonly user: string | undefined;
38
36
  readonly question: string;
39
37
  }): Layout;
@@ -71,11 +71,9 @@ function greeted(who, sentence) {
71
71
  : `${sentence.charAt(0).toLowerCase()}${sentence.slice(1)}`;
72
72
  return `${SAYS.greet(who)} ${after}`;
73
73
  }
74
- /** The person a message is for, as Slack writes them: a mention of `user`, else the assignee's name as text, else nobody. */
75
- function whoOf(user, assignee) {
76
- if (user !== undefined)
77
- return `<@${user}>`;
78
- return assignee === undefined ? undefined : escape(assignee);
74
+ /** The person a message is for, as a Slack mention of `user`, else nobody: a tracker name with no Slack user, such as EDGAR's own, is never written as text. */
75
+ function whoOf(user) {
76
+ return user === undefined ? undefined : `<@${user}>`;
79
77
  }
80
78
  /** The state of a task card that Slack's plan block knows, for each state of a step. A step that waits is still in progress. */
81
79
  const cardStatus = {
@@ -132,7 +130,7 @@ export function planLayout(plan, settings) {
132
130
  const links = linksOf(targets);
133
131
  const lines = queued !== undefined
134
132
  ? [
135
- PLAN.queued(queued.key, queued.value === undefined ? undefined : escape(queued.value), queued.limit),
133
+ PLAN.queued(queued.key, queued.value === undefined ? undefined : escape(queued.value), queued.limit, queued.workflow === undefined ? undefined : escape(queued.workflow)),
136
134
  ]
137
135
  : rows.length === 0 && !over
138
136
  ? [PLAN.started]
@@ -162,7 +160,7 @@ function toolWords(tool) {
162
160
  /** The approval question: who it is for and what EDGAR wants to run, the one thing to do, the input, the Approve and Deny buttons beside a link button to the card and to the run's page in the console, and the tool's own name in small text. With no card and no console, the small text says how to see the run. */
163
161
  export function askLayout(asked) {
164
162
  const { run, tool, card, input } = asked;
165
- const who = whoOf(asked.user, asked.assignee);
163
+ const who = whoOf(asked.user);
166
164
  const base = asked.consoleUrl?.replace(/\/$/, "");
167
165
  const page = base === undefined ? undefined : `${base}/needs-a-person`;
168
166
  const targets = [
@@ -207,7 +205,7 @@ export function questionLayout(asked) {
207
205
  const { run, card } = asked;
208
206
  const name = card === undefined ? `run ${run}` : escape(card.id ?? "this card");
209
207
  const head = headline("waiting", SAYS.questionTitle, card === undefined ? name : cardLine(card, style));
210
- const said = greeted(whoOf(asked.user, asked.assignee), SAYS.question(name));
208
+ const said = greeted(whoOf(asked.user), SAYS.question(name));
211
209
  const question = cutEscaped(escape(asked.question.trim()), QUESTION_CHARS).text;
212
210
  const next = `*${SAYS.next}* ${SAYS.questionNext}`;
213
211
  return {
@@ -231,7 +229,7 @@ export function noteLayout(run, note, user) {
231
229
  ? `run ${run}`
232
230
  : `the ${workflow} workflow`
233
231
  : escape(card.id ?? "this card");
234
- const who = whoOf(user, note.assignee);
232
+ const who = whoOf(user);
235
233
  const opened = facts.pulls.filter((pull) => pull.referenced !== true).length;
236
234
  const count = what === "recovered"
237
235
  ? facts.failedBefore
@@ -36,7 +36,7 @@ export async function mentioned(ctx, run, message, assignee, settings) {
36
36
  const user = await recipient(ctx, entry);
37
37
  if (user.ok && userId.safeParse(user.value).success)
38
38
  return user.value;
39
- ctx.log(`run ${run}: ${message} names ${assignee} with no mention, because users.lookupByEmail gave no user for ${entry} (${user.ok ? "not a user id" : user.error.kind})`);
39
+ ctx.log(`run ${run}: ${message} greets nobody for ${assignee}, because users.lookupByEmail gave no user for ${entry} (${user.ok ? "not a user id" : user.error.kind})`);
40
40
  return undefined;
41
41
  }
42
42
  /** The DM conversation of a `dm` entry, which a card's thread needs to be found again. */
@@ -134,7 +134,6 @@ async function ask(ctx, event, place, settings, first) {
134
134
  ? undefined
135
135
  : inputBlock(JSON.stringify(input, null, 2)),
136
136
  card: first.card,
137
- assignee,
138
137
  user,
139
138
  consoleUrl: settings.console_url,
140
139
  });
@@ -168,7 +167,6 @@ async function question(ctx, event, stage, place, settings, first) {
168
167
  const { text, blocks } = questionLayout({
169
168
  run,
170
169
  card: first.card,
171
- assignee,
172
170
  user,
173
171
  question: asked,
174
172
  });
@@ -521,7 +519,8 @@ const steps = {
521
519
  const { thread } = place;
522
520
  if (!wait.success || thread === undefined)
523
521
  return ok(undefined);
524
- const queued = (p) => ({ ...p, queued: wait.data });
522
+ const workflow = first.workflow === undefined ? {} : { workflow: first.workflow };
523
+ const queued = (p) => ({ ...p, queued: { ...wait.data, ...workflow } });
525
524
  return await replan(ctx, event, { ...place, thread }, settings, queued, first);
526
525
  },
527
526
  };
@@ -96,7 +96,7 @@ export declare const PLAN: {
96
96
  readonly failed: "Ended early";
97
97
  };
98
98
  readonly started: "I'll show each step here as I go.";
99
- readonly queued: (key: string, value: string | undefined, limit: number) => string;
99
+ readonly queued: (key: string, value: string | undefined, limit: number, workflow?: string) => string;
100
100
  readonly folded: (count: number) => string;
101
101
  readonly waiting: (label: string) => string;
102
102
  readonly status: (label: string) => string;
@@ -222,14 +222,19 @@ export const SAYS = {
222
222
  askHere: "Reply here when you're ready, and I'll carry on from your answer.",
223
223
  askThread: "Reply in this thread when you're ready, and I'll carry on from your answer.",
224
224
  };
225
+ /** The value EDGAR counts a run under when its input has no value at any field of its workflow's concurrency key. */
226
+ const NO_VALUE = "null";
225
227
  /** The words of the progress message: the status in words beside the emoji while the run waits its turn, while EDGAR works and when the run is over, short because the end note under it says why and what to do, the line of a run with no step yet, what a queued run waits on, the one line that stands for the done steps when there are many, a wait that the built-in table does not know, and the moving line under the thread. */
226
228
  export const PLAN = {
227
229
  title: { queued: "Queued", working: "I'm on it", done: "All done", failed: "Ended early" },
228
230
  started: "I'll show each step here as I go.",
229
- queued: (key, value, limit) => {
231
+ queued: (key, value, limit, workflow) => {
230
232
  const many = (one) => `${String(limit)} ${one}${limit === 1 ? "" : "s"}`;
233
+ const going = `${limit === 1 ? "is" : "are"} going, which is my limit. I'll start when one ends.`;
234
+ if (value === NO_VALUE)
235
+ return `${workflow === undefined ? `${many("run")} of this workflow` : many(`${workflow} run`)} ${going}`;
231
236
  if (value !== undefined)
232
- return `${many("run")} for ${value} ${limit === 1 ? "is" : "are"} going, which is my limit. I'll start when one ends.`;
237
+ return `${many("run")} for ${value} ${going}`;
233
238
  if (key === "sandboxes")
234
239
  return `I already have ${many("run")} open, which is my limit. I'll start when one ends.`;
235
240
  return `I'm already running ${many("step")} at once, which is my limit. I'll start when one ends.`;
@@ -118,7 +118,7 @@ export declare const taskState: z.ZodEnum<{
118
118
  waiting: "waiting";
119
119
  working: "working";
120
120
  }>;
121
- /** The plan of one run, kept in its message's metadata so each event updates it in place: the run's card as the line that links it, what the run waits on while it is queued, each stage that started in the order of its start, each pull request a stage opened, and the outcome word once the run is over. A stage that read what people decided on the pull request has that as its `label`. */
121
+ /** The plan of one run, kept in its message's metadata so each event updates it in place: the run's card as the line that links it, what the run waits on while it is queued with the run's workflow, each stage that started in the order of its start, each pull request a stage opened, and the outcome word once the run is over. A stage that read what people decided on the pull request has that as its `label`. */
122
122
  export declare const planState: z.ZodObject<{
123
123
  run: z.ZodString;
124
124
  card: z.ZodOptional<z.ZodString>;
@@ -126,6 +126,7 @@ export declare const planState: z.ZodObject<{
126
126
  key: z.ZodString;
127
127
  value: z.ZodOptional<z.ZodString>;
128
128
  limit: z.ZodNumber;
129
+ workflow: z.ZodOptional<z.ZodString>;
129
130
  }, z.core.$loose>>;
130
131
  tasks: z.ZodArray<z.ZodObject<{
131
132
  stage: z.ZodString;
@@ -80,11 +80,11 @@ export const waitingForSlot = z.looseObject({
80
80
  });
81
81
  /** The state of one stage on the plan message. */
82
82
  export const taskState = z.enum(["working", "done", "failed", "waiting"]);
83
- /** The plan of one run, kept in its message's metadata so each event updates it in place: the run's card as the line that links it, what the run waits on while it is queued, each stage that started in the order of its start, each pull request a stage opened, and the outcome word once the run is over. A stage that read what people decided on the pull request has that as its `label`. */
83
+ /** The plan of one run, kept in its message's metadata so each event updates it in place: the run's card as the line that links it, what the run waits on while it is queued with the run's workflow, each stage that started in the order of its start, each pull request a stage opened, and the outcome word once the run is over. A stage that read what people decided on the pull request has that as its `label`. */
84
84
  export const planState = z.object({
85
85
  run: z.string(),
86
86
  card: z.string().optional(),
87
- queued: waitingForSlot.optional(),
87
+ queued: waitingForSlot.extend({ workflow: z.string().optional() }).optional(),
88
88
  tasks: z.array(z.object({ stage: z.string(), state: taskState, label: z.string().optional() })),
89
89
  pulls: z.array(z.object({ url: z.string(), label: z.string() })).default([]),
90
90
  ended: z.string().optional(),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "contract": 1,
3
3
  "name": "slack",
4
- "version": "0.1.3",
4
+ "version": "0.1.4",
5
5
  "config_schema": "schemas/config.json",
6
6
  "secrets": [
7
7
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kana-ai/edgar-ext-slack",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "EDGAR extension for Slack: a DM or a mention opens a card, the thread shows each stage, and tools post the summary, send a DM, ask a person and delete a message.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -22,8 +22,8 @@
22
22
  ".": "./dist/src/index.js"
23
23
  },
24
24
  "dependencies": {
25
- "@kana-ai/edgar-contracts": "0.1.3",
26
- "@kana-ai/edgar-sdk": "0.1.3",
25
+ "@kana-ai/edgar-contracts": "0.1.4",
26
+ "@kana-ai/edgar-sdk": "0.1.4",
27
27
  "zod": "4.6.7"
28
28
  },
29
29
  "devDependencies": {