@staff0rd/assist 0.1028.0 → 0.1030.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.1028.0",
9
+ version: "0.1030.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -8743,8 +8743,8 @@ function subsequenceScore(text20, query) {
8743
8743
  function scoreFilePath(path109, query) {
8744
8744
  const needle = query.trim().toLowerCase();
8745
8745
  if (!needle) return 0;
8746
- const basename36 = path109.slice(path109.lastIndexOf("/") + 1);
8747
- const inBasename = subsequenceScore(basename36, needle);
8746
+ const basename37 = path109.slice(path109.lastIndexOf("/") + 1);
8747
+ const inBasename = subsequenceScore(basename37, needle);
8748
8748
  if (inBasename !== null) return BASENAME_WEIGHT + inBasename;
8749
8749
  return subsequenceScore(path109, needle);
8750
8750
  }
@@ -40703,6 +40703,9 @@ async function runHighLevelReview(number, options2 = {}) {
40703
40703
  await openHighLevelOverlay(sessionId, subject);
40704
40704
  }
40705
40705
 
40706
+ // src/commands/review/reviewPr.ts
40707
+ import { basename as basename26 } from "path";
40708
+
40706
40709
  // src/commands/review/ci/writeJobSummary.ts
40707
40710
  import { appendFileSync as appendFileSync3, readFileSync as readFileSync53 } from "fs";
40708
40711
 
@@ -41461,6 +41464,47 @@ The review request is at: ${requestPath}
41461
41464
  `;
41462
41465
  }
41463
41466
 
41467
+ // src/shared/db/recordJobRun.ts
41468
+ async function recordJobRun(db, run4) {
41469
+ await db.insert(jobRuns).values(run4);
41470
+ }
41471
+
41472
+ // src/commands/review/recordReviewerRuns.ts
41473
+ function toJobRun(result, target, startedAt, now) {
41474
+ const durationMs = result.elapsedMs ?? now.getTime() - startedAt.getTime();
41475
+ const failed3 = result.exitCode !== 0;
41476
+ return {
41477
+ kind: "review",
41478
+ trigger: "manual",
41479
+ model: result.model ?? null,
41480
+ startedAt,
41481
+ finishedAt: new Date(startedAt.getTime() + durationMs),
41482
+ durationMs,
41483
+ inputTokens: result.usage?.input ?? 0,
41484
+ outputTokens: result.usage?.output ?? 0,
41485
+ cacheReadTokens: result.usage?.cacheRead ?? 0,
41486
+ cacheWriteTokens: result.usage?.cacheWrite ?? 0,
41487
+ costUsd: null,
41488
+ status: failed3 ? "failed" : "finished",
41489
+ detail: failed3 ? `exit ${result.exitCode}` : null,
41490
+ repo: target.repo,
41491
+ prNumber: target.prNumber,
41492
+ reviewer: result.name
41493
+ };
41494
+ }
41495
+ async function recordReviewerRuns(fresh, target, startedAt, openDb = getDb) {
41496
+ if (fresh.length === 0) return;
41497
+ const now = /* @__PURE__ */ new Date();
41498
+ try {
41499
+ const db = await openDb();
41500
+ for (const result of fresh)
41501
+ await recordJobRun(db, toJobRun(result, target, startedAt, now));
41502
+ } catch (error) {
41503
+ const message3 = error instanceof Error ? error.message : String(error);
41504
+ console.error(`Could not record reviewer runs: ${message3}`);
41505
+ }
41506
+ }
41507
+
41464
41508
  // src/commands/review/reviewerLabel.ts
41465
41509
  function reviewerLabel(name, model) {
41466
41510
  return model ? `${name} (${model})` : name;
@@ -42042,7 +42086,10 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
42042
42086
  });
42043
42087
  const results = await Promise.all([claudePromise, codexPromise]);
42044
42088
  const anyFresh = options2.cachedClaude === null || options2.codexPlan.kind !== "cached";
42045
- return { results, anyFresh };
42089
+ const fresh = results.filter(
42090
+ (_, i) => i === 0 ? options2.cachedClaude === null : options2.codexPlan.kind === "run"
42091
+ );
42092
+ return { results, anyFresh, fresh };
42046
42093
  }
42047
42094
 
42048
42095
  // src/commands/review/synthesiseAfterReviewers.ts
@@ -42183,7 +42230,8 @@ function failed2(results) {
42183
42230
  }
42184
42231
  async function runAndSynthesise(args) {
42185
42232
  const { paths, multi } = args;
42186
- const { results, anyFresh } = await runReviewers(
42233
+ const startedAt = /* @__PURE__ */ new Date();
42234
+ const { results, anyFresh, fresh } = await runReviewers(
42187
42235
  paths.reviewDir,
42188
42236
  paths.claudePath,
42189
42237
  paths.codexPath,
@@ -42195,6 +42243,7 @@ async function runAndSynthesise(args) {
42195
42243
  models: args.models
42196
42244
  }
42197
42245
  );
42246
+ if (args.job) await recordReviewerRuns(fresh, args.job, startedAt);
42198
42247
  const failures = failed2(results);
42199
42248
  const reason4 = skipReason(results, failures, args.strict);
42200
42249
  if (reason4) {
@@ -42257,7 +42306,8 @@ async function runReviewPipeline(paths, options2) {
42257
42306
  codexPlan,
42258
42307
  multi: ui.multi,
42259
42308
  models: options2.models ?? {},
42260
- strict: options2.strict ?? false
42309
+ strict: options2.strict ?? false,
42310
+ job: options2.job
42261
42311
  });
42262
42312
  finishUi(ui, outcome.ok);
42263
42313
  reportFailures(outcome.failures, ui.multi !== void 0);
@@ -42901,7 +42951,8 @@ async function reviewPr(repoRoot2, options2) {
42901
42951
  const outcome = await runReviewPipeline(paths, {
42902
42952
  verbose: options2.verbose ?? false,
42903
42953
  models: options2.ci?.models,
42904
- strict: options2.ci !== void 0
42954
+ strict: options2.ci !== void 0,
42955
+ job: options2.ci ? void 0 : { repo: basename26(repoRoot2), prNumber: context.prNumber }
42905
42956
  });
42906
42957
  const synthesisOk = outcome.ok;
42907
42958
  if (!synthesisOk && options2.ci)
@@ -45188,7 +45239,7 @@ function list5() {
45188
45239
 
45189
45240
  // src/commands/transcript/move.ts
45190
45241
  import { existsSync as existsSync80, mkdirSync as mkdirSync38, renameSync as renameSync5, writeFileSync as writeFileSync54 } from "fs";
45191
- import { basename as basename28, join as join105 } from "path";
45242
+ import { basename as basename29, join as join105 } from "path";
45192
45243
 
45193
45244
  // src/commands/transcript/convertVttToMarkdown.ts
45194
45245
  function convertVttToMarkdown(inputPath) {
@@ -45209,13 +45260,13 @@ function move(file, options2) {
45209
45260
  process.exit(1);
45210
45261
  }
45211
45262
  const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
45212
- const filename = basename28(file);
45263
+ const filename = basename29(file);
45213
45264
  const sourcePath = join105(vttDir, filename);
45214
45265
  if (!existsSync80(sourcePath)) {
45215
45266
  console.error(`Error: VTT file not found: ${sourcePath}`);
45216
45267
  process.exit(1);
45217
45268
  }
45218
- const base = basename28(filename, ".vtt").replace(/ Transcription$/, "");
45269
+ const base = basename29(filename, ".vtt").replace(/ Transcription$/, "");
45219
45270
  const outputName = `${date} ${base}.md`;
45220
45271
  const formattedDir = join105(transcriptsDir, client);
45221
45272
  mkdirSync38(formattedDir, { recursive: true });
@@ -45229,7 +45280,7 @@ function move(file, options2) {
45229
45280
 
45230
45281
  // src/commands/transcript/merge.ts
45231
45282
  import { existsSync as existsSync81, writeFileSync as writeFileSync55 } from "fs";
45232
- import { basename as basename29 } from "path";
45283
+ import { basename as basename30 } from "path";
45233
45284
 
45234
45285
  // src/commands/transcript/failTranscript.ts
45235
45286
  function failTranscript(message3) {
@@ -45375,7 +45426,7 @@ function readSource3(file) {
45375
45426
  if (!existsSync81(file)) failTranscript(`VTT file not found: ${file}`);
45376
45427
  const cues = readCleanedCues(file);
45377
45428
  if (cues.length === 0) failTranscript(`no cues found in: ${file}`);
45378
- return { path: file, name: basename29(file), cues };
45429
+ return { path: file, name: basename30(file), cues };
45379
45430
  }
45380
45431
  function wholePassages(sources) {
45381
45432
  return sources.map((source) => ({
@@ -46044,7 +46095,7 @@ function listMigrationFiles(dir) {
46044
46095
 
46045
46096
  // src/commands/verify/migrations/readBaselineMigrations.ts
46046
46097
  import { execSync as execSync59 } from "child_process";
46047
- import { basename as basename30 } from "path";
46098
+ import { basename as basename31 } from "path";
46048
46099
  var MIGRATION_FILE3 = /^migration\d+[A-Za-z0-9]*\.ts$/;
46049
46100
  function readBaselineMigrations(repoRelativeDir, ref) {
46050
46101
  const baseline = /* @__PURE__ */ new Map();
@@ -46057,7 +46108,7 @@ function readBaselineMigrations(repoRelativeDir, ref) {
46057
46108
  } catch {
46058
46109
  return baseline;
46059
46110
  }
46060
- const paths = listing.split("\n").map((line) => line.trim()).filter(Boolean).filter((path109) => MIGRATION_FILE3.test(basename30(path109)));
46111
+ const paths = listing.split("\n").map((line) => line.trim()).filter(Boolean).filter((path109) => MIGRATION_FILE3.test(basename31(path109)));
46061
46112
  for (const path109 of paths) {
46062
46113
  try {
46063
46114
  const content = execSync59(`git show "${ref}:${path109}"`, {
@@ -46065,7 +46116,7 @@ function readBaselineMigrations(repoRelativeDir, ref) {
46065
46116
  maxBuffer: 16 * 1024 * 1024,
46066
46117
  stdio: ["pipe", "pipe", "pipe"]
46067
46118
  });
46068
- baseline.set(basename30(path109), content);
46119
+ baseline.set(basename31(path109), content);
46069
46120
  } catch {
46070
46121
  }
46071
46122
  }
@@ -49901,7 +49952,7 @@ function setStatus2(session, newStatus) {
49901
49952
 
49902
49953
  // src/commands/sessions/daemon/worktree/reapWorktree.ts
49903
49954
  import { existsSync as existsSync95 } from "fs";
49904
- import { basename as basename31 } from "path";
49955
+ import { basename as basename32 } from "path";
49905
49956
 
49906
49957
  // src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
49907
49958
  import { existsSync as existsSync94 } from "fs";
@@ -50044,7 +50095,7 @@ async function reapWorktree(worktreePath, force = false) {
50044
50095
  const clone = owningClone(worktreePath);
50045
50096
  const removal = await removeTree(clone, worktreePath, force);
50046
50097
  if (!removal.removed) return removal;
50047
- await deleteWorktreeBranch(clone, basename31(worktreePath));
50098
+ await deleteWorktreeBranch(clone, basename32(worktreePath));
50048
50099
  forgetWorktree(worktreePath);
50049
50100
  daemonLog(`worktree ${worktreePath} reaped${force ? " (forced)" : ""}`);
50050
50101
  return removal;
@@ -52167,7 +52218,7 @@ function transferRefusal(s, target, links2) {
52167
52218
  }
52168
52219
 
52169
52220
  // src/commands/sessions/daemon/transfer/pushTransferSnapshot.ts
52170
- import { basename as basename32 } from "path";
52221
+ import { basename as basename33 } from "path";
52171
52222
 
52172
52223
  // src/commands/sessions/daemon/transfer/TransferSnapshot.ts
52173
52224
  function transferRefFor(itemId2) {
@@ -52203,7 +52254,7 @@ var WIP_COMMIT = [
52203
52254
  ];
52204
52255
  async function currentBranch6(path109, treeRoot) {
52205
52256
  const branch2 = await gitOrNull(path109, ["symbolic-ref", "--short", "HEAD"]);
52206
- if (!branch2 || treeRoot && branch2 === basename32(treeRoot)) return void 0;
52257
+ if (!branch2 || treeRoot && branch2 === basename33(treeRoot)) return void 0;
52207
52258
  return branch2;
52208
52259
  }
52209
52260
  async function upstreamBranch2(path109) {
@@ -53419,7 +53470,7 @@ function rearmStoppedSessions(sessions, notify2) {
53419
53470
 
53420
53471
  // src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
53421
53472
  import { existsSync as existsSync100 } from "fs";
53422
- import { basename as basename34 } from "path";
53473
+ import { basename as basename35 } from "path";
53423
53474
 
53424
53475
  // src/commands/sessions/daemon/worktree/accountedTrees.ts
53425
53476
  function accountedTrees(sessions) {
@@ -53527,7 +53578,7 @@ function capped2(lines2) {
53527
53578
  }
53528
53579
 
53529
53580
  // src/commands/sessions/daemon/worktree/resurfaceOrphanedWorktree.ts
53530
- import { basename as basename33 } from "path";
53581
+ import { basename as basename34 } from "path";
53531
53582
  function resurfaceOrphanedWorktree(sessions, spawnWith, recovered, notify2) {
53532
53583
  const { orphan, reason: reason4, held } = recovered;
53533
53584
  let id;
@@ -53550,7 +53601,7 @@ function orphanedSession(id, recovered) {
53550
53601
  const { orphan, reason: reason4, held } = recovered;
53551
53602
  return {
53552
53603
  ...sessionBase(id, "stopped"),
53553
- name: `recovered ${basename33(orphan.path)}`,
53604
+ name: `recovered ${basename34(orphan.path)}`,
53554
53605
  subtitle: `${held.summary} in ${orphan.path}`,
53555
53606
  commandType: "claude",
53556
53607
  pty: null,
@@ -53611,7 +53662,7 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
53611
53662
  logVanishedTree(sessions, path109);
53612
53663
  vanished.set(clone, [
53613
53664
  ...vanished.get(clone) ?? [],
53614
- { path: path109, branch: basename34(path109) }
53665
+ { path: path109, branch: basename35(path109) }
53615
53666
  ]);
53616
53667
  continue;
53617
53668
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.1028.0",
3
+ "version": "0.1030.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {