@staff0rd/assist 0.367.1 → 0.368.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.367.1",
9
+ version: "0.368.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -963,7 +963,7 @@ function createPool() {
963
963
  return pool;
964
964
  }
965
965
  async function initSchema(pool) {
966
- await ensureSchema((sql10) => pool.query(sql10));
966
+ await ensureSchema((sql11) => pool.query(sql11));
967
967
  const orm = makeOrmFromPool(pool);
968
968
  await seedNewsFeeds(orm);
969
969
  await runUsagePeakCleanup(orm);
@@ -3881,8 +3881,8 @@ async function buildDump(tables, copyOut) {
3881
3881
  // src/commands/backlog/dump/copyTableOut.ts
3882
3882
  import { to as copyTo } from "pg-copy-streams";
3883
3883
  async function copyTableOut(client, table) {
3884
- const sql10 = `COPY ${table.name} (${table.columns.join(", ")}) TO STDOUT`;
3885
- const stream = client.query(copyTo(sql10));
3884
+ const sql11 = `COPY ${table.name} (${table.columns.join(", ")}) TO STDOUT`;
3885
+ const stream = client.query(copyTo(sql11));
3886
3886
  const chunks = [];
3887
3887
  for await (const chunk of stream) {
3888
3888
  chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
@@ -5234,6 +5234,7 @@ function buildAuthoredPhasePrompt(item, phaseNumber, phase) {
5234
5234
  const confirmSuffix = needsConfirmation ? " and the user confirms" : "";
5235
5235
  return [
5236
5236
  ...buildContextLines(item, phaseNumber, phase),
5237
+ ...buildJiraStartedLines(item, phaseNumber),
5237
5238
  "",
5238
5239
  "Focus ONLY on this phase. Do not work on other phases.",
5239
5240
  "If you need to modify backlog items, run `assist backlog --help` to discover available commands.",
@@ -5262,6 +5263,15 @@ function buildContextLines(item, phaseNumber, phase) {
5262
5263
  formatTasks(phase)
5263
5264
  ];
5264
5265
  }
5266
+ function buildJiraStartedLines(item, phaseNumber) {
5267
+ if (phaseNumber !== 1 || !item.jiraKey) {
5268
+ return [];
5269
+ }
5270
+ return [
5271
+ "",
5272
+ `As your first step, before any implementation, run \`/jira started ${item.jiraKey}\` to assign the issue to yourself and transition it to In Progress.`
5273
+ ];
5274
+ }
5265
5275
  function buildManualCheckLines(manualChecks) {
5266
5276
  if (manualChecks.length > 0) {
5267
5277
  return [
@@ -6311,8 +6321,12 @@ function createFallbackHandler(routes3, htmlHandler2, extra) {
6311
6321
  import { eq as eq12 } from "drizzle-orm";
6312
6322
 
6313
6323
  // src/commands/backlog/loadItemSummaries.ts
6314
- import { asc as asc5, eq as eq11 } from "drizzle-orm";
6324
+ import { asc as asc5, eq as eq11, ne, sql as sql5 } from "drizzle-orm";
6315
6325
  async function loadItemSummaries(orm, origin) {
6326
+ const incompleteCounts = orm.select({
6327
+ itemId: itemSubtasks.itemId,
6328
+ count: sql5`count(*)::int`.as("incomplete_subtasks")
6329
+ }).from(itemSubtasks).where(ne(itemSubtasks.status, "done")).groupBy(itemSubtasks.itemId).as("incomplete_counts");
6316
6330
  const rows = await orm.select({
6317
6331
  id: items.id,
6318
6332
  origin: items.origin,
@@ -6320,8 +6334,9 @@ async function loadItemSummaries(orm, origin) {
6320
6334
  name: items.name,
6321
6335
  status: items.status,
6322
6336
  starred: items.starred,
6323
- jiraKey: items.jiraKey
6324
- }).from(items).where(origin === void 0 ? void 0 : eq11(items.origin, origin)).orderBy(asc5(items.id));
6337
+ jiraKey: items.jiraKey,
6338
+ incompleteSubtasks: incompleteCounts.count
6339
+ }).from(items).leftJoin(incompleteCounts, eq11(incompleteCounts.itemId, items.id)).where(origin === void 0 ? void 0 : eq11(items.origin, origin)).orderBy(asc5(items.id));
6325
6340
  return rows.map((row) => ({
6326
6341
  id: row.id,
6327
6342
  origin: row.origin,
@@ -6329,7 +6344,8 @@ async function loadItemSummaries(orm, origin) {
6329
6344
  name: row.name,
6330
6345
  status: row.status,
6331
6346
  starred: row.starred,
6332
- jiraKey: row.jiraKey ?? void 0
6347
+ jiraKey: row.jiraKey ?? void 0,
6348
+ incompleteSubtasks: row.incompleteSubtasks ?? 0
6333
6349
  }));
6334
6350
  }
6335
6351
 
@@ -7986,8 +8002,8 @@ async function readStdinBuffer() {
7986
8002
  import { finished } from "stream/promises";
7987
8003
  import { from as copyFrom } from "pg-copy-streams";
7988
8004
  async function copyTableIn(client, table, data) {
7989
- const sql10 = `COPY ${table.name} (${table.columns.join(", ")}) FROM STDIN`;
7990
- const stream = client.query(copyFrom(sql10));
8005
+ const sql11 = `COPY ${table.name} (${table.columns.join(", ")}) FROM STDIN`;
8006
+ const stream = client.query(copyFrom(sql11));
7991
8007
  stream.end(data);
7992
8008
  await finished(stream);
7993
8009
  }
@@ -8114,11 +8130,11 @@ async function insertPhaseAt(orm, itemId, phaseIdx, name, tasks, manualChecks, c
8114
8130
  }
8115
8131
 
8116
8132
  // src/commands/backlog/insertSubtask.ts
8117
- import { sql as sql5 } from "drizzle-orm";
8133
+ import { sql as sql6 } from "drizzle-orm";
8118
8134
  async function insertSubtask(orm, itemId, title, description) {
8119
8135
  await orm.insert(itemSubtasks).values({
8120
8136
  itemId,
8121
- idx: sql5`(SELECT COALESCE(MAX(${itemSubtasks.idx}) + 1, 0) FROM ${itemSubtasks} WHERE ${itemSubtasks.itemId} = ${itemId})`,
8137
+ idx: sql6`(SELECT COALESCE(MAX(${itemSubtasks.idx}) + 1, 0) FROM ${itemSubtasks} WHERE ${itemSubtasks.itemId} = ${itemId})`,
8122
8138
  title,
8123
8139
  description: description ?? null,
8124
8140
  status: "todo"
@@ -13259,9 +13275,9 @@ function registerGithub(program2) {
13259
13275
  }
13260
13276
 
13261
13277
  // src/commands/handover/countPendingHandovers.ts
13262
- import { and as and16, eq as eq35, isNull, sql as sql6 } from "drizzle-orm";
13278
+ import { and as and16, eq as eq35, isNull, sql as sql7 } from "drizzle-orm";
13263
13279
  async function countPendingHandovers(orm, origin) {
13264
- const [row] = await orm.select({ count: sql6`count(*)::int` }).from(handovers).where(and16(eq35(handovers.origin, origin), isNull(handovers.recalledAt)));
13280
+ const [row] = await orm.select({ count: sql7`count(*)::int` }).from(handovers).where(and16(eq35(handovers.origin, origin), isNull(handovers.recalledAt)));
13265
13281
  return row?.count ?? 0;
13266
13282
  }
13267
13283
 
@@ -19458,8 +19474,8 @@ function filterToSql(filter) {
19458
19474
  // src/commands/seq/fetchSeqData.ts
19459
19475
  function buildDataParams(filter, count8, from, to) {
19460
19476
  const sqlFilter = filterToSql(filter);
19461
- const sql10 = `select @Timestamp, @Level, @Exception, @Message from stream where ${sqlFilter} order by @Timestamp desc limit ${count8}`;
19462
- const params = new URLSearchParams({ q: sql10 });
19477
+ const sql11 = `select @Timestamp, @Level, @Exception, @Message from stream where ${sqlFilter} order by @Timestamp desc limit ${count8}`;
19478
+ const params = new URLSearchParams({ q: sql11 });
19463
19479
  if (from) params.set("rangeStartUtc", from);
19464
19480
  if (to) params.set("rangeEndUtc", to);
19465
19481
  return params;
@@ -19719,26 +19735,26 @@ import chalk186 from "chalk";
19719
19735
  // src/commands/sql/loadConnections.ts
19720
19736
  function loadConnections3() {
19721
19737
  const raw = loadGlobalConfigRaw();
19722
- const sql10 = raw.sql;
19723
- return sql10?.connections ?? [];
19738
+ const sql11 = raw.sql;
19739
+ return sql11?.connections ?? [];
19724
19740
  }
19725
19741
  function saveConnections3(connections) {
19726
19742
  const raw = loadGlobalConfigRaw();
19727
- const sql10 = raw.sql ?? {};
19728
- sql10.connections = connections;
19729
- raw.sql = sql10;
19743
+ const sql11 = raw.sql ?? {};
19744
+ sql11.connections = connections;
19745
+ raw.sql = sql11;
19730
19746
  saveGlobalConfig(raw);
19731
19747
  }
19732
19748
  function getDefaultConnection2() {
19733
19749
  const raw = loadGlobalConfigRaw();
19734
- const sql10 = raw.sql;
19735
- return sql10?.defaultConnection;
19750
+ const sql11 = raw.sql;
19751
+ return sql11?.defaultConnection;
19736
19752
  }
19737
19753
  function setDefaultConnection2(name) {
19738
19754
  const raw = loadGlobalConfigRaw();
19739
- const sql10 = raw.sql ?? {};
19740
- sql10.defaultConnection = name;
19741
- raw.sql = sql10;
19755
+ const sql11 = raw.sql ?? {};
19756
+ sql11.defaultConnection = name;
19757
+ raw.sql = sql11;
19742
19758
  saveGlobalConfig(raw);
19743
19759
  }
19744
19760
 
@@ -19809,9 +19825,9 @@ function resolveConnection3(name) {
19809
19825
  }
19810
19826
 
19811
19827
  // src/commands/sql/sqlConnect.ts
19812
- import sql7 from "mssql";
19828
+ import sql8 from "mssql";
19813
19829
  async function sqlConnect(conn) {
19814
- return await sql7.connect({
19830
+ return await sql8.connect({
19815
19831
  server: conn.server,
19816
19832
  port: conn.port,
19817
19833
  user: conn.user,
@@ -19874,11 +19890,11 @@ var MUTATION_PATTERN = new RegExp(
19874
19890
  `\\b(${MUTATION_KEYWORDS.join("|")})\\b`,
19875
19891
  "i"
19876
19892
  );
19877
- function stripComments(sql10) {
19878
- return sql10.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/--[^\n]*/g, " ");
19893
+ function stripComments(sql11) {
19894
+ return sql11.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/--[^\n]*/g, " ");
19879
19895
  }
19880
- function isMutation(sql10) {
19881
- const stripped = stripComments(sql10);
19896
+ function isMutation(sql11) {
19897
+ const stripped = stripComments(sql11);
19882
19898
  if (MUTATION_PATTERN.test(stripped)) return true;
19883
19899
  return /\bSELECT\b[\s\S]+\bINTO\s+\w/i.test(stripped);
19884
19900
  }
@@ -21992,13 +22008,13 @@ function logSpawnedSession(session) {
21992
22008
  }
21993
22009
 
21994
22010
  // src/shared/db/recordPhaseActiveMs.ts
21995
- import { sql as sql8 } from "drizzle-orm";
22011
+ import { sql as sql9 } from "drizzle-orm";
21996
22012
  async function recordPhaseActiveMs(db, itemId, phaseIdx, activeMs) {
21997
22013
  if (activeMs <= 0) return;
21998
22014
  await db.insert(phaseUsage).values({ itemId, phaseIdx, activeMs }).onConflictDoUpdate({
21999
22015
  target: [phaseUsage.itemId, phaseUsage.phaseIdx],
22000
22016
  set: {
22001
- activeMs: sql8`${phaseUsage.activeMs} + excluded.active_ms`
22017
+ activeMs: sql9`${phaseUsage.activeMs} + excluded.active_ms`
22002
22018
  }
22003
22019
  });
22004
22020
  }
@@ -22141,15 +22157,15 @@ function makeStatusChangeHandler(dismiss, notify2, reuseForRun) {
22141
22157
  }
22142
22158
 
22143
22159
  // src/shared/db/recordPhaseTokens.ts
22144
- import { sql as sql9 } from "drizzle-orm";
22160
+ import { sql as sql10 } from "drizzle-orm";
22145
22161
  async function recordPhaseTokens(db, itemId, phaseIdx, totalIn, totalOut) {
22146
22162
  await db.insert(phaseUsage).values({ itemId, phaseIdx, lastTotalIn: totalIn, lastTotalOut: totalOut }).onConflictDoUpdate({
22147
22163
  target: [phaseUsage.itemId, phaseUsage.phaseIdx],
22148
22164
  set: {
22149
- tokensDown: sql9`${phaseUsage.tokensDown} + CASE WHEN ${phaseUsage.lastTotalIn} IS NULL THEN 0 ELSE GREATEST(excluded.last_total_in - ${phaseUsage.lastTotalIn}, 0) END`,
22150
- tokensUp: sql9`${phaseUsage.tokensUp} + CASE WHEN ${phaseUsage.lastTotalOut} IS NULL THEN 0 ELSE GREATEST(excluded.last_total_out - ${phaseUsage.lastTotalOut}, 0) END`,
22151
- lastTotalIn: sql9`excluded.last_total_in`,
22152
- lastTotalOut: sql9`excluded.last_total_out`
22165
+ tokensDown: sql10`${phaseUsage.tokensDown} + CASE WHEN ${phaseUsage.lastTotalIn} IS NULL THEN 0 ELSE GREATEST(excluded.last_total_in - ${phaseUsage.lastTotalIn}, 0) END`,
22166
+ tokensUp: sql10`${phaseUsage.tokensUp} + CASE WHEN ${phaseUsage.lastTotalOut} IS NULL THEN 0 ELSE GREATEST(excluded.last_total_out - ${phaseUsage.lastTotalOut}, 0) END`,
22167
+ lastTotalIn: sql10`excluded.last_total_in`,
22168
+ lastTotalOut: sql10`excluded.last_total_out`
22153
22169
  }
22154
22170
  });
22155
22171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.367.1",
3
+ "version": "0.368.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {