@astrofoundry/pi-astro 0.40.56 → 0.40.58

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.
@@ -19,7 +19,7 @@ Work in this order:
19
19
 
20
20
  1. **Title.** When the context says "New request", your reply always starts with the line `TITLE: [CATEGORY YYYY-MM-DD] <place>: <subject>`, also when it only asks questions. Example: `TITLE: [PRODUCT 2026-11-04] UAE: top 5 running shoes for men`. Categories: PRODUCT, FLIGHT, STAY, SERVICE, LOCAL, EVENT, INFO. Keep the number the user asked for. Put it at the top of your last message, the reply the user sees; the bridge turns it into the thread's name and removes it.
21
21
  2. **Defaults.** Run `defaults list` and apply GLOBAL and the category's defaults.
22
- 3. **Questions.** If anything still open would change the answer (size, budget, dates, passengers, cabin, type of use), ask it as a numbered list of at most five short questions. Give each one your suggested answer in brackets. Then stop: do not search before the user answers. When nothing is open, state the defaults you applied in one line and research.
22
+ 3. **Questions.** If anything still open would change the answer (size, budget, dates, passengers, cabin, type of use), ask it as a numbered list of at most five short questions. Give each one your suggested answer in brackets, and end that reply with the line `CHOICE: suggestions`, which shows a Use suggestions button. Then stop: do not search before the user answers or presses it. When nothing is open, state the defaults you applied in one line and research.
23
23
  4. **Research.** Follow the skill's sources and checks. Verify every fact you report on the page itself, in this sandbox, today.
24
24
  5. **Answer.** Use the skill's format. It has no open assumptions: anything you could not check is either checked another way or left out, never reported as "unchecked". Only an answer with researched results ends with the line `REFRESH: yes`; a reply that asks questions or confirms a default never does.
25
25
 
@@ -50,7 +50,12 @@ function runCommand(specialist: string, text: string): Command {
50
50
  /** Prompt paragraph appended for tasks that arrive from a chat channel. */
51
51
  export const CHANNEL_RULES = `## Channel rules
52
52
 
53
- This task arrived from a Discord channel and your answer is posted there. Answer in plain text under 1500 characters when possible, facts first, no headings. When the task is ambiguous (which guest, which record, which host), do not act: ask one precise question and stop. Risky calls may wait for an operator's approval; if the tool reports a denial or a missing answer, report it and stop.`;
53
+ This task arrived from a Discord channel and your answer is posted there. Answer in plain text under 1500 characters when possible, facts first, no headings. When the task is ambiguous (which guest, which record, which host), do not act: ask one precise question and stop. Risky calls may wait for an operator's approval; if the tool reports a denial or a missing answer, report it and stop. When you need something from the owner (a go, a decision, an action, or a blocker you cannot remove), your first line starts with **Needs you:** and says what you need in one sentence; the bridge then tags them.`;
54
+
55
+ /** A reply whose first line asks the owner for something; the bridge tags the requester on it. */
56
+ export function needsYou(output: string): boolean {
57
+ return /^\s*\**Needs you:/i.test(output);
58
+ }
54
59
 
55
60
  export function helpText(allowed: readonly string[], present: readonly string[], isOwner: boolean, trigger: Trigger, canConfig: boolean): string {
56
61
  if (allowed.length === 0) return present.length === 0 ? "No specialist is present in this channel." : "You may not use the specialists present in this channel.";
@@ -198,6 +198,7 @@ describe("Arcane report plans", () => {
198
198
  const task = carefulTask(pdf);
199
199
  expect(task).toContain("- stirling-pdf: 2.14.3 → 3.0.0 (major version); release notes: check, the config key changed");
200
200
  expect(task).toContain("Wait in this thread for the owner's \"go\"; then apply the image change with `stack-update stirling-pdf --confirm`");
201
+ expect(task).toContain("Its first line is `**Needs you:**`");
201
202
  expect(carefulTask(entry(report(), "arcane"))).toContain("`manager-upgrade 2.17.0`");
202
203
  });
203
204
 
@@ -246,7 +246,7 @@ export function carefulTask(s: StackEntry): string {
246
246
  "Pending:",
247
247
  ...lines,
248
248
  `1. Read what changes: \`release-notes ${s.stack}/<service>\` for each line, \`git show ${s.stack}/compose.yaml\`, and the stack's README in the GitOps checkout.`,
249
- "2. Post a short plan: what changes, what must happen first (a `host db-dump <stack>` when the stack's database is one the tool covers), the order, how you will check it, and how to roll back.",
249
+ "2. Post the plan. Its first line is `**Needs you:**` and what you need in one sentence: the go, or the blocker and what the owner must do or decide. Then at most five numbered one-line steps: what changes, what must happen first (a `host db-dump <stack>` when the stack's database is one the tool covers), the order, how you will check it, and how to roll back.",
250
250
  `3. Change nothing yet. Wait in this thread for the owner's "go"; then apply the image change with ${apply} and the other steps of your plan, and report each result.`,
251
251
  ].join("\n");
252
252
  }
@@ -5,7 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
5
  import { ApprovalServer, type Ticket } from "./approvals.ts";
6
6
  import { chunkMessage, fenceState } from "./chunk.ts";
7
7
  import { applyAdminCommand, describeConfig } from "./admin.ts";
8
- import { helpText, needsPrefixText, parseCommand } from "./commands.ts";
8
+ import { helpText, needsPrefixText, needsYou, parseCommand } from "./commands.ts";
9
9
  import { allowedSpecialists, canUse, channelSpecialists, loadConfig, loadToken, validateConfig } from "./config.ts";
10
10
  import { GatewayClient, INTENTS, initialState, reduce } from "./gateway.ts";
11
11
  import type { RunResult } from "../astro-subagents/child.ts";
@@ -89,6 +89,12 @@ describe("chunk", () => {
89
89
  });
90
90
 
91
91
  describe("commands", () => {
92
+ it("tags the requester only when the reply's first line asks the owner for something", () => {
93
+ expect(needsYou("**Needs you:** the go for the queue drain.\n1. Pull the image.")).toBe(true);
94
+ expect(needsYou("Needs you: a decision on the backup.")).toBe(true);
95
+ expect(needsYou("All three services run.\n**Needs you:** nothing")).toBe(false);
96
+ });
97
+
92
98
  const many = { botUserId: ID, specialists: ["dns", "edge"], trigger: "always" as const, repliedToBot: false };
93
99
  const one = { ...many, specialists: ["arcane"] };
94
100
  it("parses prefixed tasks, mentions, help, status, and config", () => {
@@ -306,6 +312,9 @@ describe("rest", () => {
306
312
  expect(calls[4].url).toBe("https://discord.com/api/v10/channels/m9");
307
313
  expect(calls[4].init.method).toBe("PATCH");
308
314
  expect(JSON.parse(calls[4].init.body as string)).toEqual({ archived: true });
315
+ await rest.createThread("c1", "2026-11-06: Weekly media picks");
316
+ expect(calls[5].url).toBe("https://discord.com/api/v10/channels/c1/threads");
317
+ expect(JSON.parse(calls[5].init.body as string)).toEqual({ name: "2026-11-06: Weekly media picks", auto_archive_duration: 10080, type: 11 });
309
318
  });
310
319
  });
311
320
 
@@ -10,7 +10,7 @@ import { pruneSessions, sessionDirFor } from "../astro-subagents/sessions.ts";
10
10
  import { ApprovalServer, type Ticket } from "./approvals.ts";
11
11
  import { chunkMessage } from "./chunk.ts";
12
12
  import { applyAdminCommand } from "./admin.ts";
13
- import { CHANNEL_RULES, helpText, needsPrefixText, parseCommand } from "./commands.ts";
13
+ import { CHANNEL_RULES, helpText, needsPrefixText, needsYou, parseCommand } from "./commands.ts";
14
14
  import { ACTIVATION_ENV, type ChannelSettings, type DiscordConfig, MORNING_REPORTS, type ReportName, type ReportSchedule, allowedSpecialists, canUse, channelSpecialists, isOwner, loadConfig, loadToken, reportSchedule, saveConfig } from "./config.ts";
15
15
  import { type ConversationState, type ResolvedConversation, forgetStale, loadState, newConversationId, recordAnswer, resolveConversation, saveState, sessionsRoot, startConversation } from "./conversations.ts";
16
16
  import { describeImages, downloadImages, type ImageAttachment, imageAttachments } from "./attachments.ts";
@@ -36,7 +36,7 @@ import {
36
36
  import { GatewayClient } from "./gateway.ts";
37
37
  import { type CommandOption, IS_COMPONENTS_V2, KeyedQueue, MEDIA, MEDIA_COMMANDS, type MediaKind, type Outcome, PAUSED_TEXT, RESUME_ID, addOutcome, addedWhilePaused, applyOutcome, commandArgs, escapeDiscord, hasActiveButton, listMessage, mediaAccess, mediaPointer, parseAddButton, parseAddReport, parseMediaList, parseQueueState, queueLine, resumedText, unpauseRow } from "./media.ts";
38
38
  import { cancelledApprovalText, interruptedTaskText, readOpenWork, type OpenWork, type StopReason, writeOpenWork } from "./open-work.ts";
39
- import { DISMISSED, type Picks, parseNoButton, parsePicks, picksArgs, picksFailureText, picksMessage, readPicksState, withDismissed, withSuggested, writePicksState } from "./media-picks.ts";
39
+ import { DISMISSED, type Picks, parseNoButton, parsePicks, picksArgs, picksFailureText, picksMessage, picksThreadName, readPicksState, withDismissed, withSuggested, writePicksState } from "./media-picks.ts";
40
40
  import { FRIDAY, isDue, MONDAY, readReportState, writeReportState, zonedWeekday } from "./reports.ts";
41
41
  import { ACTIVITY_COMMAND, type Activity, addRestarts, astrogateActivity, herdrActivity, needsPrompt, type PendingRestart, readRestarts, restartCommand, SERVICE_LABEL, SERVICE_ORDER, writeRestarts } from "./restarts.ts";
42
42
  import {
@@ -74,7 +74,7 @@ import {
74
74
  } from "./tools-report.ts";
75
75
  import { type Quote, type QuotedMessage, withQuotes } from "./quote.ts";
76
76
  import { DiscordRest, type MessageComponent } from "./rest.ts";
77
- import { BUTTON_TASKS, CAPTCHA_LABELS, captchaText, captchaVerdict, continueRow, provisionalName, refreshRow, shapeAnswer, threadContext, threadDate, titleFromTexts } from "./research.ts";
77
+ import { answerButtons, BUTTON_TASKS, CAPTCHA_LABELS, captchaText, captchaVerdict, provisionalName, shapeAnswer, threadContext, threadDate, titleFromTexts } from "./research.ts";
78
78
  import { ArcaneWatch } from "./arcane-watch-monitor.ts";
79
79
  import { parseSnapshot } from "./arcane-watch.ts";
80
80
  import { type Applied, autoFailureText, foremanTask, stackProblems, stackUpdateAnswer, SUPERVISE_DELAY_MS, SUPERVISE_LIMIT_MS } from "./supervise.ts";
@@ -576,13 +576,14 @@ class Bridge {
576
576
  if (this.stopping) return;
577
577
  const label = new Intl.DateTimeFormat("en-GB", { timeZone: schedule.timeZone, weekday: "short", day: "numeric", month: "short" }).format(new Date());
578
578
  writeReportState("media-weekly", { date, status: "sending" });
579
+ const thread = await this.rest.createThread(schedule.channelId, picksThreadName(date));
579
580
  if (!picks) {
580
- const posted = await this.rest.createMessage(schedule.channelId, { content: picksFailureText(label) });
581
+ const posted = await this.rest.createMessage(thread.id, { content: picksFailureText(label) });
581
582
  writeReportState("media-weekly", { date, status: "failed", messageId: posted.id });
582
583
  return;
583
584
  }
584
585
  const tagged = picks.movies.length + picks.series.length > 0;
585
- const posted = await this.rest.createComponentsMessage(schedule.channelId, picksMessage(picks, label, this.config.owners), tagged ? this.config.owners : undefined);
586
+ const posted = await this.rest.createComponentsMessage(thread.id, picksMessage(picks, label, this.config.owners), tagged ? this.config.owners : undefined);
586
587
  writePicksState(withSuggested(readPicksState(), picks, date));
587
588
  writeReportState("media-weekly", { date, status: "sent", messageId: posted.id });
588
589
  log(`media picks ${date}: ${picks.movies.length} movie(s), ${picks.series.length} series`);
@@ -1871,25 +1872,22 @@ class Bridge {
1871
1872
  }
1872
1873
  // During shutdown the interrupted message was already written; an aborted run has nothing else to say.
1873
1874
  if (this.stopping) return true;
1874
- let refreshable = false;
1875
- let continuable = false;
1875
+ let buttons: MessageComponent[] | null = null;
1876
1876
  if (task.threaded && !failed) {
1877
1877
  const shaped = shapeAnswer(output);
1878
1878
  const texts = messages.flatMap((m) => (m.role === "assistant" ? m.content.flatMap((part) => (part.type === "text" ? [part.text] : [])) : []));
1879
1879
  const title = shaped.title ?? titleFromTexts(texts);
1880
1880
  if (title) await this.rest.renameThread(task.channelId, title).catch((err) => log(`${task.specialist}: renaming thread ${task.channelId} failed: ${err instanceof Error ? err.message : String(err)}`));
1881
1881
  output = shaped.text || "(no output)";
1882
- refreshable = shaped.refreshable;
1883
- continuable = shaped.continuable;
1882
+ buttons = answerButtons(shaped);
1884
1883
  }
1885
1884
  await this.rest.removeOwnReaction(task.channelId, task.messageId, REACTION.running).catch(() => undefined);
1886
1885
  await this.rest.addReaction(task.channelId, task.messageId, failed ? REACTION.failed : REACTION.done).catch(() => undefined);
1887
- // In a request's thread the requester is tagged on every reply, questions or answer; an edited message never notifies, so it is posted new.
1888
- const notify = task.threaded ? task.userId : undefined;
1886
+ // In a request's thread the requester is tagged on every reply, elsewhere when the reply needs them; an edited message never notifies, so it is posted new.
1887
+ const notify = task.threaded || (!failed && needsYou(output)) ? task.userId : undefined;
1889
1888
  const reply = `${notify ? `<@${notify}> ` : ""}${failed ? "❌" : "✅"} **${task.specialist}**\n${output}`;
1890
1889
  const answers = await this.deliver(task, placeholder, reply, attachment, notify);
1891
1890
  const last = answers[answers.length - 1];
1892
- const buttons = continuable ? continueRow() : refreshable ? refreshRow() : null;
1893
1891
  if (buttons && last && attachment === undefined && reply.length <= ATTACHMENT_THRESHOLD) {
1894
1892
  const chunks = chunkMessage(reply);
1895
1893
  await this.rest.editMessage(task.channelId, last, chunks[chunks.length - 1] ?? reply, buttons).catch((err) => log(`${task.specialist}: answer buttons failed: ${err instanceof Error ? err.message : String(err)}`));
@@ -4,7 +4,7 @@ import { join } from "node:path";
4
4
  import { afterEach, beforeEach, describe, expect, it } from "vitest";
5
5
  import { validateReports } from "./config.ts";
6
6
  import { applyOutcome, countComponents, hasActiveButton } from "./media.ts";
7
- import { DISMISSED, type Pick, parseNoButton, parsePicks, pickText, picksArgs, picksMessage, readPicksState, withDismissed, withSuggested, writePicksState } from "./media-picks.ts";
7
+ import { DISMISSED, type Pick, parseNoButton, parsePicks, pickText, picksArgs, picksMessage, picksThreadName, readPicksState, withDismissed, withSuggested, writePicksState } from "./media-picks.ts";
8
8
  import { FRIDAY, isDue } from "./reports.ts";
9
9
 
10
10
  const OWNER = "178096425509453824";
@@ -14,6 +14,10 @@ function pick(over: Partial<Pick>): Pick {
14
14
  }
15
15
 
16
16
  describe("weekly picks", () => {
17
+ it("names each week's thread by its local date", () => {
18
+ expect(picksThreadName("2026-11-06")).toBe("2026-11-06: Weekly media picks");
19
+ });
20
+
17
21
  it("keeps only well-formed picks with an IMDb id, three per kind", () => {
18
22
  const raw = { movies: [pick({}), { title: "No id", imdb_id: null, matches: 1, because: [] }, pick({ imdb_id: "tt1" }), pick({ imdb_id: "tt2" }), pick({ imdb_id: "tt3" })], series: [], warnings: ["Sonarr slow", 3] };
19
23
  const picks = parsePicks(raw);
@@ -108,6 +108,11 @@ function withWarnings(components: MessageComponent[], warnings: readonly string[
108
108
  return components;
109
109
  }
110
110
 
111
+ /** Each week's picks get their own thread, named by the local date so the weeks stay apart. */
112
+ export function picksThreadName(date: string): string {
113
+ return `${date}: Weekly media picks`;
114
+ }
115
+
111
116
  export function picksFailureText(date: string): string {
112
117
  return `**🍿 Weekly picks** · ${date} · the recommendation check failed, so there are no picks this week. The bridge log on Cortex has the reason.`;
113
118
  }
@@ -1,14 +1,15 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { BUTTON_TASKS, CAPTCHA_LABELS, captchaText, captchaVerdict, CONTINUE_ID, continueRow, provisionalName, REFRESH_ID, refreshRow, shapeAnswer, STOP_ID, threadContext, threadDate, titleFromTexts } from "./research.ts";
2
+ import { answerButtons, BUTTON_TASKS, CAPTCHA_LABELS, captchaText, captchaVerdict, CONTINUE_ID, continueRow, provisionalName, REFRESH_ID, refreshRow, shapeAnswer, STOP_ID, SUGGESTIONS_ID, threadContext, threadDate, titleFromTexts } from "./research.ts";
3
3
  import { validateChannel } from "./config.ts";
4
4
 
5
5
  describe("research threads", () => {
6
6
  it("takes the title line and the refresh marker off an answer", () => {
7
7
  const shaped = shapeAnswer("TITLE: [PRODUCT 2026-11-04] UAE: top 5 running shoes for men\n\n1. Hoka Mach 7 …\n2. Adidas Evo SL …\n\nREFRESH: yes\n");
8
- expect(shaped).toEqual({ title: "[PRODUCT 2026-11-04] UAE: top 5 running shoes for men", text: "1. Hoka Mach 7 …\n2. Adidas Evo SL …", refreshable: true, continuable: false });
9
- expect(shapeAnswer("1. What is your size?\n2. Road or trail?")).toEqual({ title: null, text: "1. What is your size?\n2. Road or trail?", refreshable: false, continuable: false });
8
+ expect(shaped).toEqual({ title: "[PRODUCT 2026-11-04] UAE: top 5 running shoes for men", text: "1. Hoka Mach 7 …\n2. Adidas Evo SL …", refreshable: true, choice: null });
9
+ expect(shapeAnswer("1. What is your size?\n2. Road or trail?")).toEqual({ title: null, text: "1. What is your size?\n2. Road or trail?", refreshable: false, choice: null });
10
10
  expect(shapeAnswer("Read TITLE: inside a line\nREFRESH: yes, later")).toMatchObject({ title: null, refreshable: false });
11
- expect(shapeAnswer("Two candidates so far.\n\nContinue for up to 10 more minutes?\nCHOICE: continue\n")).toEqual({ title: null, text: "Two candidates so far.\n\nContinue for up to 10 more minutes?", refreshable: false, continuable: true });
11
+ expect(shapeAnswer("Two candidates so far.\n\nContinue for up to 10 more minutes?\nCHOICE: continue\n")).toEqual({ title: null, text: "Two candidates so far.\n\nContinue for up to 10 more minutes?", refreshable: false, choice: "continue" });
12
+ expect(shapeAnswer("1. What size? [EU 43]\nCHOICE: suggestions")).toEqual({ title: null, text: "1. What size? [EU 43]", refreshable: false, choice: "suggestions" });
12
13
  });
13
14
 
14
15
  it("finds the title in an earlier text of the run", () => {
@@ -33,7 +34,10 @@ describe("research threads", () => {
33
34
  expect(captchaVerdict("reddit.com", false, "1")).toBe("⏭️ reddit.com skipped by <@1>; the research continues without it.");
34
35
  expect(refreshRow()[0].components?.[0]).toMatchObject({ custom_id: REFRESH_ID, label: "🔄 Refresh" });
35
36
  expect(continueRow()[0].components?.map((b) => b.custom_id)).toEqual([CONTINUE_ID, STOP_ID]);
36
- expect(Object.keys(BUTTON_TASKS).sort()).toEqual([CONTINUE_ID, REFRESH_ID, STOP_ID].sort());
37
+ expect(Object.keys(BUTTON_TASKS).sort()).toEqual([CONTINUE_ID, REFRESH_ID, STOP_ID, SUGGESTIONS_ID].sort());
38
+ expect(answerButtons({ refreshable: false, choice: "suggestions" })?.[0].components?.[0]).toMatchObject({ custom_id: SUGGESTIONS_ID, label: "✅ Use suggestions" });
39
+ expect(answerButtons({ refreshable: true, choice: null })?.[0].components?.[0].custom_id).toBe(REFRESH_ID);
40
+ expect(answerButtons({ refreshable: false, choice: null })).toBeNull();
37
41
  });
38
42
 
39
43
  it("accepts the thread, everyone, and live view settings of a channel", () => {
@@ -3,24 +3,28 @@
3
3
  * thread on itself, the specialist names it with a first `TITLE:` line, and
4
4
  * every later message in that thread continues the same work without a
5
5
  * mention. A final answer that ends with `REFRESH: yes` gets a Refresh button;
6
- * a reply that ends with `CHOICE: continue` gets Continue and Stop buttons.
6
+ * a reply that ends with `CHOICE: continue` gets Continue and Stop buttons, and
7
+ * one that ends with `CHOICE: suggestions` (its questions) a Use suggestions button.
7
8
  */
8
9
  import type { MessageComponent } from "./rest.ts";
9
10
 
10
11
  export const REFRESH_ID = "research:refresh";
11
12
  export const CONTINUE_ID = "research:continue";
12
13
  export const STOP_ID = "research:stop";
14
+ export const SUGGESTIONS_ID = "research:suggestions";
13
15
  const TITLE = /^TITLE:\s*(\S.{1,98}\S)\s*$/;
14
16
  const REFRESH = /^\s*REFRESH:\s*yes\s*$/i;
15
- const CHOICE = /^\s*CHOICE:\s*continue\s*$/i;
17
+ const CHOICE = /^\s*CHOICE:\s*(continue|suggestions)\s*$/i;
18
+
19
+ export type Choice = "continue" | "suggestions";
16
20
  const MENTION = /<@[!&]?\d+>/g;
17
21
 
18
22
  export interface ShapedAnswer {
19
23
  title: string | null;
20
24
  text: string;
21
25
  refreshable: boolean;
22
- /** The specialist asks whether to go on past its time limit. */
23
- continuable: boolean;
26
+ /** Buttons for a question: go on past the time limit, or take the suggested answers. */
27
+ choice: Choice | null;
24
28
  }
25
29
 
26
30
  /** Takes the title line off the top and the refresh and choice markers off the bottom of a specialist's answer. */
@@ -34,15 +38,16 @@ export function shapeAnswer(output: string): ShapedAnswer {
34
38
  lines.splice(first, 1);
35
39
  }
36
40
  let refreshable = false;
37
- let continuable = false;
41
+ let choice: Choice | null = null;
38
42
  for (let i = lines.length - 1; i >= 0; i--) {
39
43
  if (lines[i].trim().length === 0) continue;
44
+ const chosen = CHOICE.exec(lines[i]);
40
45
  if (REFRESH.test(lines[i])) refreshable = true;
41
- else if (CHOICE.test(lines[i])) continuable = true;
46
+ else if (chosen) choice = chosen[1].toLowerCase() as Choice;
42
47
  else break;
43
48
  lines.splice(i, 1);
44
49
  }
45
- return { title, text: lines.join("\n").trim(), refreshable, continuable };
50
+ return { title, text: lines.join("\n").trim(), refreshable, choice };
46
51
  }
47
52
 
48
53
  /** The `TITLE:` line from any assistant text of the run, oldest first: the specialist may write it before its tool calls, and only the last text is the answer. */
@@ -80,6 +85,7 @@ export const BUTTON_TASKS: Readonly<Record<string, string>> = {
80
85
  [REFRESH_ID]: "Refresh your last answer: check every price, stock and size, delivery, date, and link again today, then give the answer in the same format, marking what changed.",
81
86
  [CONTINUE_ID]: "Continue the research for up to 10 more minutes, then answer.",
82
87
  [STOP_ID]: "Stop researching now. Answer with what you have verified; leave out anything you could not verify.",
88
+ [SUGGESTIONS_ID]: "Use your suggested answer for every open question, then research.",
83
89
  };
84
90
 
85
91
  export function refreshRow(): MessageComponent[] {
@@ -98,6 +104,17 @@ export function continueRow(): MessageComponent[] {
98
104
  ];
99
105
  }
100
106
 
107
+ export function suggestionsRow(): MessageComponent[] {
108
+ return [{ type: 1, components: [{ type: 2, style: 3, label: "✅ Use suggestions", custom_id: SUGGESTIONS_ID }] }];
109
+ }
110
+
111
+ /** The buttons a reply carries: its choice first, otherwise Refresh on a final answer. */
112
+ export function answerButtons(shaped: Pick<ShapedAnswer, "refreshable" | "choice">): MessageComponent[] | null {
113
+ if (shaped.choice === "continue") return continueRow();
114
+ if (shaped.choice === "suggestions") return suggestionsRow();
115
+ return shaped.refreshable ? refreshRow() : null;
116
+ }
117
+
101
118
  /** Labels of a `captcha-help` approval: Approve means the owner solved it, Deny skips the site. */
102
119
  export const CAPTCHA_LABELS = { approve: "✅ Solved", deny: "⏭️ Skip site" } as const;
103
120
 
@@ -1,4 +1,6 @@
1
1
  export const API = "https://discord.com/api/v10";
2
+ /** Channel type of a public thread; Start Thread without Message makes a private one when the type is left out. */
3
+ const PUBLIC_THREAD = 11;
2
4
 
3
5
  export interface MessageComponent {
4
6
  type: number;
@@ -113,6 +115,11 @@ export class DiscordRest {
113
115
  return (await this.call("POST", `/channels/${channelId}/messages/${messageId}/threads`, JSON.stringify({ name: name.slice(0, 100), auto_archive_duration: 10080 }), "application/json")).json() as Promise<{ id: string }>;
114
116
  }
115
117
 
118
+ /** A public thread with no message in the channel under it, such as a week's media picks. */
119
+ async createThread(channelId: string, name: string): Promise<{ id: string }> {
120
+ return (await this.call("POST", `/channels/${channelId}/threads`, JSON.stringify({ name: name.slice(0, 100), auto_archive_duration: 10080, type: PUBLIC_THREAD }), "application/json")).json() as Promise<{ id: string }>;
121
+ }
122
+
116
123
  /** Renames a thread the bot started. */
117
124
  async renameThread(threadId: string, name: string): Promise<void> {
118
125
  await this.call("PATCH", `/channels/${threadId}`, JSON.stringify({ name: name.slice(0, 100) }), "application/json");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrofoundry/pi-astro",
3
- "version": "0.40.56",
3
+ "version": "0.40.58",
4
4
  "description": "Personal pi customizations (extensions, subagents, skills, prompts, themes) for the pi coding agent.",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -68,7 +68,7 @@ The `research` tool reaches VM 110 `research` at Mira, on an internet-only netwo
68
68
  REFRESH: yes
69
69
  ```
70
70
 
71
- Wrap every link in `<…>` so Discord shows no preview. A reply that stops at the time limit ends with `CHOICE: continue` instead of `REFRESH: yes`; the buttons send "Continue the research for up to 10 more minutes" or "Stop researching now and answer with what you verified". Keep each item to two lines at most. Use the number the user asked for; give fewer only when fewer pass the checks, and say so.
71
+ Wrap every link in `<…>` so Discord shows no preview. A questions reply ends with `CHOICE: suggestions` (a Use suggestions button that answers every question with its bracketed suggestion). A reply that stops at the time limit ends with `CHOICE: continue` instead of `REFRESH: yes`; the buttons send "Continue the research for up to 10 more minutes" or "Stop researching now and answer with what you verified". Keep each item to two lines at most. Use the number the user asked for; give fewer only when fewer pass the checks, and say so.
72
72
 
73
73
  ## Defaults
74
74