@astrofoundry/pi-astro 0.22.1 → 0.22.3

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.
@@ -31,10 +31,13 @@ export class ApprovalServer {
31
31
  private server: Server | null = null;
32
32
  private port = 0;
33
33
 
34
- constructor(
35
- private readonly events: ApprovalEvents,
36
- private readonly timeoutMs: number,
37
- ) {}
34
+ private readonly events: ApprovalEvents;
35
+ private readonly timeoutMs: number;
36
+
37
+ constructor(events: ApprovalEvents, timeoutMs: number) {
38
+ this.events = events;
39
+ this.timeoutMs = timeoutMs;
40
+ }
38
41
 
39
42
  get url(): string {
40
43
  return `http://127.0.0.1:${this.port}`;
@@ -95,8 +95,11 @@ export class GatewayClient {
95
95
  private heartbeat: ReturnType<typeof setInterval> | null = null;
96
96
  private stopped = false;
97
97
  private attempts = 0;
98
+ private readonly options: GatewayClientOptions;
98
99
 
99
- constructor(private readonly options: GatewayClientOptions) {}
100
+ constructor(options: GatewayClientOptions) {
101
+ this.options = options;
102
+ }
100
103
 
101
104
  start(): void {
102
105
  this.stopped = false;
@@ -70,12 +70,12 @@ class Bridge {
70
70
  private readonly approvalMessages = new Map<string, { channelId: string; messageId: string; userMessage: ActiveTask }>();
71
71
  private config: DiscordConfig;
72
72
  private botUserId = "";
73
+ private readonly ctx: ExtensionContext;
74
+ private readonly token: string;
73
75
 
74
- constructor(
75
- private readonly ctx: ExtensionContext,
76
- config: DiscordConfig,
77
- private readonly token: string,
78
- ) {
76
+ constructor(ctx: ExtensionContext, config: DiscordConfig, token: string) {
77
+ this.ctx = ctx;
78
+ this.token = token;
79
79
  this.config = config;
80
80
  this.rest = new DiscordRest(token);
81
81
  this.approvals = new ApprovalServer({ onTicket: (t) => void this.askApproval(t), onExpired: (t) => void this.expireApproval(t) }, config.approvalTimeoutMinutes * 60_000);
@@ -31,11 +31,15 @@ interface RateLimit {
31
31
  * 429 using the returned `retry_after`; anything else non-2xx throws.
32
32
  */
33
33
  export class DiscordRest {
34
- constructor(
35
- private readonly token: string,
36
- private readonly fetchImpl: typeof fetch = fetch,
37
- private readonly base = API,
38
- ) {}
34
+ private readonly token: string;
35
+ private readonly fetchImpl: typeof fetch;
36
+ private readonly base: string;
37
+
38
+ constructor(token: string, fetchImpl: typeof fetch = fetch, base = API) {
39
+ this.token = token;
40
+ this.fetchImpl = fetchImpl;
41
+ this.base = base;
42
+ }
39
43
 
40
44
  private async call(method: string, path: string, body?: BodyInit, contentType?: string, attempt = 0): Promise<Response> {
41
45
  const headers: Record<string, string> = { Authorization: `Bot ${this.token}`, "User-Agent": "DiscordBot (https://github.com/astrofoundry/pi-astro, astro-discord)" };
@@ -30,11 +30,12 @@ class MutableOutput extends Writable {
30
30
  async function main(): Promise<void> {
31
31
  const output = new MutableOutput();
32
32
  const rl = createInterface({ input: process.stdin, output, terminal: true });
33
+ // readline redraws the prompt line on every keystroke, so the question must be its prompt, not a bare stdout write.
33
34
  const ask = async (question: string, hidden = false): Promise<string> => {
34
35
  output.muted = false;
35
- process.stdout.write(question);
36
+ const pending = rl.question(question);
36
37
  output.muted = hidden;
37
- const answer = await rl.question("");
38
+ const answer = await pending;
38
39
  output.muted = false;
39
40
  if (hidden) process.stdout.write("\n");
40
41
  return answer.trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrofoundry/pi-astro",
3
- "version": "0.22.1",
3
+ "version": "0.22.3",
4
4
  "description": "Personal pi customizations (extensions, subagents, skills, prompts, themes) for the pi coding agent.",
5
5
  "keywords": [
6
6
  "pi-package"