@staff0rd/assist 0.246.0 → 0.248.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.
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.246.0",
9
+ version: "0.248.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -514,8 +514,8 @@ var SCHEMA = `
514
514
  value TEXT NOT NULL
515
515
  );
516
516
  `;
517
- async function ensureSchema(exec3) {
518
- await exec3(SCHEMA);
517
+ async function ensureSchema(exec4) {
518
+ await exec4(SCHEMA);
519
519
  }
520
520
 
521
521
  // src/commands/backlog/getBacklogOrm.ts
@@ -4508,6 +4508,27 @@ function getHtml() {
4508
4508
  </html>`;
4509
4509
  }
4510
4510
 
4511
+ // src/commands/sessions/web/openInCode.ts
4512
+ import { exec as exec2 } from "child_process";
4513
+ import { promisify } from "util";
4514
+ var execAsync = promisify(exec2);
4515
+ async function openInCode(req, res) {
4516
+ const url = new URL(req.url ?? "/", "http://localhost");
4517
+ const cwd = url.searchParams.get("cwd");
4518
+ if (!cwd) {
4519
+ respondJson(res, 400, { error: "Missing cwd" });
4520
+ return;
4521
+ }
4522
+ try {
4523
+ await execAsync(`code "${cwd}"`);
4524
+ respondJson(res, 200, { ok: true });
4525
+ } catch {
4526
+ respondJson(res, 500, {
4527
+ error: "Failed to open VS Code. Is the 'code' command on your PATH?"
4528
+ });
4529
+ }
4530
+ }
4531
+
4511
4532
  // src/commands/sessions/web/handleRequest.ts
4512
4533
  var require3 = createRequire2(import.meta.url);
4513
4534
  function createCssHandler(packageEntry) {
@@ -4532,7 +4553,8 @@ var routes = {
4532
4553
  "GET /api/items": listItems,
4533
4554
  "POST /api/items": createItem,
4534
4555
  "GET /api/backlog/exists": getBacklogExists,
4535
- "POST /api/backlog/init": initBacklog
4556
+ "POST /api/backlog/init": initBacklog,
4557
+ "POST /api/open-in-code": openInCode
4536
4558
  };
4537
4559
  var handleRequest = createFallbackHandler(
4538
4560
  routes,
@@ -6850,10 +6872,10 @@ function hasSubcommands(helpText) {
6850
6872
  }
6851
6873
 
6852
6874
  // src/commands/permitCliReads/runHelp.ts
6853
- import { exec as exec2 } from "child_process";
6875
+ import { exec as exec3 } from "child_process";
6854
6876
  function runHelp(args) {
6855
6877
  return new Promise((resolve16) => {
6856
- exec2(
6878
+ exec3(
6857
6879
  `${args.join(" ")} --help`,
6858
6880
  { encoding: "utf-8", timeout: 3e4 },
6859
6881
  (_err, stdout, stderr) => {
@@ -17063,6 +17085,19 @@ async function discoverSessions() {
17063
17085
  return sessions;
17064
17086
  }
17065
17087
 
17088
+ // src/commands/sessions/daemon/shouldAutoDismiss.ts
17089
+ function shouldAutoDismiss(session, exitCode) {
17090
+ const args = session.assistArgs;
17091
+ return session.status === "done" && exitCode === 0 && args !== void 0 && args.includes("--once") && args[0] !== "next";
17092
+ }
17093
+
17094
+ // src/commands/sessions/daemon/applyStatusChange.ts
17095
+ function applyStatusChange(session, status2, exitCode, dismiss, notify2) {
17096
+ session.status = status2;
17097
+ if (shouldAutoDismiss(session, exitCode)) dismiss(session.id);
17098
+ else notify2();
17099
+ }
17100
+
17066
17101
  // src/commands/sessions/daemon/broadcast.ts
17067
17102
  function sendTo(client, msg) {
17068
17103
  client.send(JSON.stringify(msg));
@@ -17331,9 +17366,9 @@ function wirePtyEvents(session, clients, onStatusChange) {
17331
17366
  scheduleIdle(session, () => onStatusChange(session, "waiting"));
17332
17367
  broadcast(clients, { type: "output", sessionId: session.id, data });
17333
17368
  });
17334
- session.pty.onExit(() => {
17369
+ session.pty.onExit(({ exitCode }) => {
17335
17370
  clearIdle(session);
17336
- onStatusChange(session, "done");
17371
+ onStatusChange(session, "done", exitCode);
17337
17372
  });
17338
17373
  scheduleIdle(session, () => onStatusChange(session, "waiting"));
17339
17374
  }
@@ -17521,10 +17556,7 @@ var SessionManager = class {
17521
17556
  resume(sessionId, cwd, name) {
17522
17557
  return this.add(resumeSession(String(this.nextId++), sessionId, cwd, name));
17523
17558
  }
17524
- onStatusChange = (s, status2) => {
17525
- s.status = status2;
17526
- this.notify();
17527
- };
17559
+ onStatusChange = (s, status2, exitCode) => applyStatusChange(s, status2, exitCode, this.dismissSession, this.notify);
17528
17560
  wire(session) {
17529
17561
  this.sessions.set(session.id, session);
17530
17562
  wirePtyEvents(session, this.clients, this.onStatusChange);
@@ -17540,9 +17572,9 @@ var SessionManager = class {
17540
17572
  const s = this.sessions.get(id);
17541
17573
  if (s && retrySession(s, this.clients, this.onStatusChange)) this.notify();
17542
17574
  }
17543
- dismissSession(id) {
17575
+ dismissSession = (id) => {
17544
17576
  if (dismissSession(this.sessions, id)) this.notify();
17545
- }
17577
+ };
17546
17578
  listSessions() {
17547
17579
  return [...this.sessions.values()].map(toSessionInfo);
17548
17580
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.246.0",
3
+ "version": "0.248.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {