@staff0rd/assist 0.469.3 → 0.469.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/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.469.3",
9
+ version: "0.469.4",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -27943,7 +27943,7 @@ function dismissSession(sessions, id) {
27943
27943
  return true;
27944
27944
  }
27945
27945
 
27946
- // src/commands/sessions/daemon/isDraftCommand.ts
27946
+ // src/commands/sessions/shared/isDraftCommand.ts
27947
27947
  var DRAFT_COMMANDS = ["draft", "bug", "refine"];
27948
27948
  function isDraftCommand(command) {
27949
27949
  return command != null && DRAFT_COMMANDS.includes(command);
@@ -28291,6 +28291,76 @@ function logSpawnedSession(session) {
28291
28291
  );
28292
28292
  }
28293
28293
 
28294
+ // src/commands/sessions/daemon/generateSessionTitle.ts
28295
+ import { execFile as execFile9 } from "child_process";
28296
+ import { promisify as promisify8 } from "util";
28297
+ var execFileAsync7 = promisify8(execFile9);
28298
+ var SESSION_TITLE_MAX_LENGTH = 48;
28299
+ async function generateSessionTitle(prompt) {
28300
+ try {
28301
+ const { stdout } = await execFileAsync7(
28302
+ "claude",
28303
+ ["-p", "--model", "haiku", buildPrompt3(prompt)],
28304
+ { encoding: "utf8", timeout: 3e4 }
28305
+ );
28306
+ return normaliseTitle(stdout);
28307
+ } catch {
28308
+ return void 0;
28309
+ }
28310
+ }
28311
+ function normaliseTitle(stdout) {
28312
+ const title = (stdout.trim().split(/\r?\n/)[0] ?? "").trim().replace(/^["'`]+/, "").replace(/["'`]+$/, "").replace(/[.,:;!?]+$/, "").trim().slice(0, SESSION_TITLE_MAX_LENGTH).trim();
28313
+ return title || void 0;
28314
+ }
28315
+ function buildPrompt3(prompt) {
28316
+ return [
28317
+ "Summarise the task below as a short title for a session card.",
28318
+ "Rules:",
28319
+ "- 2 to 5 words that capture the essence of the task",
28320
+ "- sentence case, no trailing punctuation",
28321
+ "- reply with ONLY the title, no quotes or explanation",
28322
+ "",
28323
+ `Task: ${prompt}`
28324
+ ].join("\n");
28325
+ }
28326
+
28327
+ // src/commands/sessions/shared/sessionTitlePrompt.ts
28328
+ function sessionTitlePrompt(session) {
28329
+ if (session.commandType === "claude")
28330
+ return session.initialPrompt?.trim() || void 0;
28331
+ if (session.commandType !== "assist") return void 0;
28332
+ if (!isDraftCommand(session.assistArgs?.[0])) return void 0;
28333
+ return assistPromptArg(session.assistArgs);
28334
+ }
28335
+ function assistPromptArg(args) {
28336
+ const rest = args?.slice(1).filter((a) => !a.startsWith("--"));
28337
+ const text17 = rest?.[rest.length - 1]?.trim();
28338
+ if (!text17 || isBacklogItemId(text17)) return void 0;
28339
+ return text17;
28340
+ }
28341
+ function isBacklogItemId(text17) {
28342
+ return /^\d+$/.test(text17);
28343
+ }
28344
+
28345
+ // src/commands/sessions/daemon/startSessionTitleGeneration.ts
28346
+ function startSessionTitleGeneration(session, notify2) {
28347
+ if (!session || session.generatedTitle) return;
28348
+ const prompt = sessionTitlePrompt(session);
28349
+ if (!prompt) return;
28350
+ void generateSessionTitle(prompt).then((generated) => {
28351
+ session.generatedTitle = generated ?? singleLine(prompt);
28352
+ daemonLog(
28353
+ generated ? `session ${session.id} generated title: ${generated}` : `session ${session.id} title generation failed; falling back to "${session.generatedTitle}"`
28354
+ );
28355
+ notify2();
28356
+ }).catch((error) => {
28357
+ daemonLog(`session ${session.id} title generation errored: ${error}`);
28358
+ });
28359
+ }
28360
+ function singleLine(prompt) {
28361
+ return prompt.replace(/\s+/g, " ").trim().slice(0, SESSION_TITLE_MAX_LENGTH);
28362
+ }
28363
+
28294
28364
  // src/commands/sessions/daemon/emitSessionOutput.ts
28295
28365
  var MAX_SCROLLBACK = 256 * 1024;
28296
28366
  function emitSessionOutput(session, clients, data) {
@@ -28771,6 +28841,7 @@ function registerSpawnedSession(session, sessions, clients, onStatusChange, noti
28771
28841
  notify2();
28772
28842
  wireSessionWatchers(session, notify2, onStatusChange);
28773
28843
  logSpawnedSession(session);
28844
+ startSessionTitleGeneration(session, notify2);
28774
28845
  return session.id;
28775
28846
  }
28776
28847
 
@@ -30615,73 +30686,6 @@ function resumeSession(id, sessionId, cwd, name) {
30615
30686
  };
30616
30687
  }
30617
30688
 
30618
- // src/commands/sessions/daemon/generateSessionTitle.ts
30619
- import { execFile as execFile9 } from "child_process";
30620
- import { promisify as promisify8 } from "util";
30621
- var execFileAsync7 = promisify8(execFile9);
30622
- var MAX_LENGTH2 = 48;
30623
- async function generateSessionTitle(prompt) {
30624
- try {
30625
- const { stdout } = await execFileAsync7(
30626
- "claude",
30627
- ["-p", "--model", "haiku", buildPrompt3(prompt)],
30628
- { encoding: "utf8", timeout: 3e4 }
30629
- );
30630
- return normaliseTitle(stdout);
30631
- } catch {
30632
- return void 0;
30633
- }
30634
- }
30635
- function normaliseTitle(stdout) {
30636
- const title = (stdout.trim().split(/\r?\n/)[0] ?? "").trim().replace(/^["'`]+/, "").replace(/["'`]+$/, "").replace(/[.,:;!?]+$/, "").trim().slice(0, MAX_LENGTH2).trim();
30637
- return title || void 0;
30638
- }
30639
- function buildPrompt3(prompt) {
30640
- return [
30641
- "Summarise the task below as a short title for a session card.",
30642
- "Rules:",
30643
- "- 2 to 5 words that capture the essence of the task",
30644
- "- sentence case, no trailing punctuation",
30645
- "- reply with ONLY the title, no quotes or explanation",
30646
- "",
30647
- `Task: ${prompt}`
30648
- ].join("\n");
30649
- }
30650
-
30651
- // src/commands/sessions/daemon/startSessionTitleGeneration.ts
30652
- function startSessionTitleGeneration(session, notify2) {
30653
- if (!session || session.generatedTitle) return;
30654
- const prompt = titlePrompt(session);
30655
- if (!prompt) return;
30656
- void generateSessionTitle(prompt).then((title) => {
30657
- if (!title) {
30658
- daemonLog(`session ${session.id} title generation failed`);
30659
- return;
30660
- }
30661
- session.generatedTitle = title;
30662
- daemonLog(`session ${session.id} generated title: ${title}`);
30663
- notify2();
30664
- }).catch((error) => {
30665
- daemonLog(`session ${session.id} title generation errored: ${error}`);
30666
- });
30667
- }
30668
- function titlePrompt(session) {
30669
- if (session.commandType === "claude")
30670
- return session.initialPrompt?.trim() || void 0;
30671
- if (session.commandType !== "assist") return void 0;
30672
- if (!isDraftCommand(session.assistArgs?.[0])) return void 0;
30673
- return assistPromptArg(session.assistArgs);
30674
- }
30675
- function assistPromptArg(args) {
30676
- const rest = args?.slice(1).filter((a) => !a.startsWith("--"));
30677
- const text17 = rest?.[rest.length - 1]?.trim();
30678
- if (!text17 || isBacklogItemId(text17)) return void 0;
30679
- return text17;
30680
- }
30681
- function isBacklogItemId(text17) {
30682
- return /^\d+$/.test(text17);
30683
- }
30684
-
30685
30689
  // src/commands/sessions/daemon/worktree/isPrCheckoutArgs.ts
30686
30690
  var CHECKOUT_COMMANDS = /* @__PURE__ */ new Set(["review", "review-pr-comments"]);
30687
30691
  function isPrCheckoutArgs(args) {
@@ -30696,7 +30700,6 @@ function allocateAndBind(ctx, cwd, create, options2 = {}) {
30696
30700
  const needsSeeding = alloc.kind === "worktree" && alloc.created === true;
30697
30701
  const id = ctx.spawnWith((sid) => create(sid, alloc.cwd, needsSeeding));
30698
30702
  bindNewWorktree(ctx.sessions.get(id), alloc, ctx.notify, ctx.startHeld);
30699
- startSessionTitleGeneration(ctx.sessions.get(id), ctx.notify);
30700
30703
  return id;
30701
30704
  }
30702
30705
  function spawnInTree(ctx, prompt, cwd, design, harness) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.469.3",
3
+ "version": "0.469.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {