@staff0rd/assist 0.1142.0 → 0.1143.1

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
@@ -10,6 +10,6 @@ if (isStatusLineInvocation(process.argv)) {
10
10
  const { runStatusLine } = await import("./runStatusLine-6VBMFNUZ.js");
11
11
  await runStatusLine();
12
12
  } else {
13
- const { runCli } = await import("./runCli-AJWCPYHW.js");
13
+ const { runCli } = await import("./runCli-OSXLT6CQ.js");
14
14
  await runCli();
15
15
  }
@@ -16,7 +16,7 @@ import { Command } from "commander";
16
16
  // package.json
17
17
  var package_default = {
18
18
  name: "@staff0rd/assist",
19
- version: "0.1142.0",
19
+ version: "0.1143.1",
20
20
  type: "module",
21
21
  main: "dist/index.js",
22
22
  bin: {
@@ -3131,9 +3131,6 @@ async function ensureMigrated(orm, dir, origin) {
3131
3131
  await migrateLocalBacklog(orm, dir, origin);
3132
3132
  }
3133
3133
 
3134
- // src/shared/db/getDb.ts
3135
- import { Pool } from "pg";
3136
-
3137
3134
  // src/commands/backlog/addFeed.ts
3138
3135
  async function addFeed(db, url) {
3139
3136
  const inserted = await db.insert(feeds).values({ url }).onConflictDoNothing({ target: feeds.url }).returning({ id: feeds.id });
@@ -3778,6 +3775,9 @@ function pgExecutor(queryable) {
3778
3775
  };
3779
3776
  }
3780
3777
 
3778
+ // src/shared/db/createPool.ts
3779
+ import { Pool } from "pg";
3780
+
3781
3781
  // src/shared/db/MissingDatabaseUrlError.ts
3782
3782
  var DATABASE_URL_ENV = "ASSIST_DATABASE_URL";
3783
3783
  var MISSING_URL_MESSAGE = `No assist database configured.
@@ -3805,21 +3805,17 @@ function getDatabaseUrl() {
3805
3805
  return url;
3806
3806
  }
3807
3807
 
3808
- // src/shared/db/getDb.ts
3809
- async function runUsagePeakCleanup(orm) {
3810
- try {
3811
- await cleanupFalseResetSegments(orm);
3812
- } catch (error) {
3813
- console.error(
3814
- `${(/* @__PURE__ */ new Date()).toISOString()} usage-peaks cleanup failed: ${String(error)}`
3815
- );
3816
- }
3817
- }
3808
+ // src/shared/db/createPool.ts
3818
3809
  function logPoolError(error) {
3819
3810
  console.error(
3820
3811
  `${(/* @__PURE__ */ new Date()).toISOString()} backlog pool error: ${error.message}`
3821
3812
  );
3822
3813
  }
3814
+ function logClientError(error) {
3815
+ console.error(
3816
+ `${(/* @__PURE__ */ new Date()).toISOString()} backlog client error: ${error.message}`
3817
+ );
3818
+ }
3823
3819
  function createPool() {
3824
3820
  const pool = new Pool({
3825
3821
  connectionString: getDatabaseUrl(),
@@ -3830,8 +3826,24 @@ function createPool() {
3830
3826
  connectionTimeoutMillis: 1e4
3831
3827
  });
3832
3828
  pool.on("error", logPoolError);
3829
+ pool.on("acquire", (client) => client.on("error", logClientError));
3830
+ pool.on(
3831
+ "release",
3832
+ (_error, client) => client.removeListener("error", logClientError)
3833
+ );
3833
3834
  return pool;
3834
3835
  }
3836
+
3837
+ // src/shared/db/getDb.ts
3838
+ async function runUsagePeakCleanup(orm) {
3839
+ try {
3840
+ await cleanupFalseResetSegments(orm);
3841
+ } catch (error) {
3842
+ console.error(
3843
+ `${(/* @__PURE__ */ new Date()).toISOString()} usage-peaks cleanup failed: ${String(error)}`
3844
+ );
3845
+ }
3846
+ }
3835
3847
  async function initDb(pool) {
3836
3848
  try {
3837
3849
  await assertMigrationsInSync(pgExecutor(pool));
@@ -10122,6 +10134,15 @@ function azureDevopsRepoUrl({ org, project, repo }) {
10122
10134
  return `https://dev.azure.com/${encodeURIComponent(org)}/${encodeURIComponent(project)}/_git/${encodeURIComponent(repo)}`;
10123
10135
  }
10124
10136
 
10137
+ // src/commands/sessions/web/fromGithub/azureDevopsNotCloned.ts
10138
+ function azureDevopsNotCloned(repo, baseDir) {
10139
+ return {
10140
+ ok: false,
10141
+ status: 404,
10142
+ error: `${repo.org}/${repo.project}/${repo.repo} is not cloned under ${baseDir}; clone ${azureDevopsRepoUrl(repo)} there and retry`
10143
+ };
10144
+ }
10145
+
10125
10146
  // src/commands/sessions/web/fromGithub/findAzureDevopsClone.ts
10126
10147
  import { existsSync as existsSync23, readdirSync as readdirSync8 } from "fs";
10127
10148
  import { join as join29 } from "path";
@@ -10166,12 +10187,7 @@ function planAzureDevopsReview(pr, args, baseDir) {
10166
10187
  error: "Unsupported assist args for an Azure DevOps PR"
10167
10188
  };
10168
10189
  const cwd = findAzureDevopsClone(pr, baseDir);
10169
- if (!cwd)
10170
- return {
10171
- ok: false,
10172
- status: 404,
10173
- error: `${pr.org}/${pr.project}/${pr.repo} is not cloned under ${baseDir}; clone ${azureDevopsRepoUrl(pr)} there and retry`
10174
- };
10190
+ if (!cwd) return azureDevopsNotCloned(pr, baseDir);
10175
10191
  return { ok: true, cwd, assistArgs: [...args, pr.id] };
10176
10192
  }
10177
10193
 
@@ -10381,26 +10397,44 @@ function reviewFromGithub(req, res) {
10381
10397
  );
10382
10398
  }
10383
10399
 
10384
- // src/commands/sessions/web/fromGithub/linkPrompt.ts
10400
+ // src/commands/sessions/web/fromGithub/remotePrGuidance.ts
10385
10401
  var githubPrUrl = /^https?:\/\/github\.com\/[^/]+\/[^/]+\/pull\/\d+/;
10386
- function remotePrGuidance(prUrl) {
10387
- return `This is a pull request. Read it remotely with \`gh pr view ${prUrl} --comments\` and \`gh pr diff ${prUrl}\`; do not check out its branch.`;
10402
+ function remotePrGuidance(url) {
10403
+ const githubPr = url.match(githubPrUrl)?.[0];
10404
+ if (githubPr)
10405
+ return `This is a pull request. Read it remotely with \`gh pr view ${githubPr} --comments\` and \`gh pr diff ${githubPr}\`; do not check out its branch.`;
10406
+ const pr = parseAzureDevopsPrUrl(url);
10407
+ if (!pr) return void 0;
10408
+ const org = `https://dev.azure.com/${encodeURIComponent(pr.org)}`;
10409
+ return `This is an Azure DevOps pull request. Read it remotely with \`az repos pr show --id ${pr.id} --org ${org}\` and its comment threads with \`az devops invoke --area git --resource pullRequestThreads --route-parameters "project=${pr.project}" "repositoryId=${pr.repo}" pullRequestId=${pr.id} --org ${org}\`; diff it with \`git fetch origin refs/pull/${pr.id}/merge\` then \`git diff FETCH_HEAD^1 FETCH_HEAD\`. Do not check out its branch.`;
10388
10410
  }
10411
+
10412
+ // src/commands/sessions/web/fromGithub/linkPrompt.ts
10389
10413
  function linkPrompt(url, instructions) {
10390
10414
  const extra = typeof instructions === "string" ? instructions.trim() : "";
10391
- const prUrl = url.match(githubPrUrl)?.[0];
10415
+ const guidance = remotePrGuidance(url);
10392
10416
  const parts2 = [url];
10393
- if (prUrl) parts2.push(remotePrGuidance(prUrl));
10417
+ if (guidance) parts2.push(guidance);
10394
10418
  if (extra) parts2.push(extra);
10395
10419
  return parts2.join("\n\n");
10396
10420
  }
10397
10421
 
10422
+ // src/commands/sessions/web/fromGithub/resolveSessionClone.ts
10423
+ function resolveSessionClone(url, baseDir, redirects) {
10424
+ const trimmed = typeof url === "string" ? url.trim() : "";
10425
+ const azurePr = parseAzureDevopsPrUrl(trimmed);
10426
+ if (!azurePr) return resolveGithubClone(url, baseDir, redirects);
10427
+ const cwd = findAzureDevopsClone(azurePr, baseDir);
10428
+ if (!cwd) return azureDevopsNotCloned(azurePr, baseDir);
10429
+ return { ok: true, url: trimmed, cwd };
10430
+ }
10431
+
10398
10432
  // src/commands/sessions/web/fromGithub/planGithubSession.ts
10399
10433
  function planGithubSession(body, baseDir, redirects) {
10400
10434
  const { url, instructions, mode } = body ?? {};
10401
10435
  if (mode !== void 0 && !isGithubAssistMode(mode))
10402
10436
  return { ok: false, status: 400, error: `Unknown mode: ${mode}` };
10403
- const clone = resolveGithubClone(url, baseDir, redirects);
10437
+ const clone = resolveSessionClone(url, baseDir, redirects);
10404
10438
  if (!clone.ok) return clone;
10405
10439
  const prompt = linkPrompt(clone.url, instructions);
10406
10440
  return { ok: true, cwd: clone.cwd, prompt, ...mode && { mode } };
@@ -24316,6 +24350,7 @@ import chalk64 from "chalk";
24316
24350
 
24317
24351
  // src/commands/backlog/propose/proposedItemSchema.ts
24318
24352
  import { z as z18 } from "zod";
24353
+ var PHASE_DEFINITION = /^\W*phase\s+\d+\s*[:.)\-–—]/i;
24319
24354
  var proposedPhaseSchema = z18.strictObject({
24320
24355
  name: z18.string().trim().min(1, "phase name is required").refine(
24321
24356
  (name2) => name2.toLowerCase() !== REVIEW_PHASE_NAME.toLowerCase(),
@@ -24328,7 +24363,12 @@ var proposedItemSchema = z18.strictObject({
24328
24363
  name: z18.string().trim().min(1, "name is required"),
24329
24364
  type: z18.enum(["story", "bug"]),
24330
24365
  description: z18.string().optional(),
24331
- acceptanceCriteria: z18.array(z18.string().trim().min(1)).default([]),
24366
+ acceptanceCriteria: z18.array(
24367
+ z18.string().trim().min(1).refine(
24368
+ (criterion) => !PHASE_DEFINITION.test(criterion),
24369
+ "reads as a phase definition \u2014 move it to `phases` as { name, tasks } and keep acceptance criteria to conditions that confirm the item is done"
24370
+ )
24371
+ ).default([]),
24332
24372
  phases: z18.array(proposedPhaseSchema).default([])
24333
24373
  });
24334
24374
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.1142.0",
3
+ "version": "0.1143.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {