@staff0rd/assist 0.325.0 → 0.326.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.
Files changed (2) hide show
  1. package/dist/index.js +38 -17
  2. package/package.json +1 -1
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.325.0",
9
+ version: "0.326.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -6011,8 +6011,10 @@ function extractPath(rest) {
6011
6011
  const arrow = rest.indexOf(" -> ");
6012
6012
  return arrow === -1 ? rest : rest.slice(arrow + 4);
6013
6013
  }
6014
+ var UNMERGED_STATES = /* @__PURE__ */ new Set(["DD", "AU", "UD", "UA", "DU", "AA", "UU"]);
6014
6015
  function categorize(xy) {
6015
6016
  if (xy === "??") return "new";
6017
+ if (UNMERGED_STATES.has(xy)) return "modified";
6016
6018
  const codes = xy.replace(/ /g, "");
6017
6019
  if (codes.includes("A")) return "new";
6018
6020
  if (codes.includes("D")) return "deleted";
@@ -9379,8 +9381,6 @@ function codeCommentConfirm(pin) {
9379
9381
  }
9380
9382
 
9381
9383
  // src/commands/codeComment/codeCommentSet.ts
9382
- import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync23 } from "fs";
9383
- import { randomBytes } from "crypto";
9384
9384
  import chalk93 from "chalk";
9385
9385
 
9386
9386
  // src/commands/codeComment/validateCommentText.ts
@@ -9408,10 +9408,27 @@ function validateCommentText(raw) {
9408
9408
  return { ok: true, text: text6 };
9409
9409
  }
9410
9410
 
9411
- // src/commands/codeComment/codeCommentSet.ts
9411
+ // src/commands/codeComment/issuePin.ts
9412
+ import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync23 } from "fs";
9413
+ import { randomInt } from "crypto";
9414
+ function issuePin(file, lineNumber, text6) {
9415
+ const pin = generatePin();
9416
+ mkdirSync11(getRestrictedDir(), { recursive: true });
9417
+ sweepRestrictedDir();
9418
+ writeFileSync23(
9419
+ getPinStatePath(pin),
9420
+ JSON.stringify({ pin, file, line: lineNumber, text: text6 })
9421
+ );
9422
+ return showNotification({
9423
+ title: "assist code-comment pin",
9424
+ message: `Pin ${pin} \u2014 run: assist code-comment confirm ${pin}`
9425
+ });
9426
+ }
9412
9427
  function generatePin() {
9413
- return randomBytes(4).toString("hex");
9428
+ return randomInt(0, 1e3).toString().padStart(3, "0");
9414
9429
  }
9430
+
9431
+ // src/commands/codeComment/codeCommentSet.ts
9415
9432
  function codeCommentSet(file, line, text6) {
9416
9433
  const lineNumber = Number.parseInt(line, 10);
9417
9434
  if (!Number.isInteger(lineNumber) || lineNumber < 1) {
@@ -9428,20 +9445,24 @@ function codeCommentSet(file, line, text6) {
9428
9445
  }
9429
9446
  console.error(
9430
9447
  chalk93.yellow.bold(
9431
- "Think hard. Comments are a last resort, not a habit.\nAlmost every comment you reach for is a sign the code should be clearer instead.\nBefore you confirm this pin, ask whether a better name, a smaller function, or a\ntest would make the comment redundant. If you are still sure this one line earns\nits keep, run the confirm step below."
9448
+ "THIS IS YOUR LAST CHANCE TO RECONSIDER BEFORE INVOLVING A HUMAN.\nRequesting this pin pages a real person to approve a comment. DO NOT WASTE THEIR TIME.\nYou had BETTER BE RIGHT that this comment is genuinely necessary.\n\nComments are a last resort, not a habit. Almost every comment you reach for is a sign\nthe code should be clearer instead. Before a human is pulled in, ask whether a better\nname, a smaller function, or a test would make the comment redundant. ONLY if you are\ncertain this one line earns its keep should you proceed to the confirm step below."
9432
9449
  )
9433
9450
  );
9434
- const pin = generatePin();
9435
- mkdirSync11(getRestrictedDir(), { recursive: true });
9436
- sweepRestrictedDir();
9437
- writeFileSync23(
9438
- getPinStatePath(pin),
9439
- JSON.stringify({ pin, file, line: lineNumber, text: validation.text })
9440
- );
9451
+ const delivered = issuePin(file, lineNumber, validation.text);
9452
+ if (!delivered) {
9453
+ console.error(
9454
+ chalk93.red(
9455
+ "Could not deliver the confirmation pin via notification.\nThe comment cannot be confirmed until the notification channel works."
9456
+ )
9457
+ );
9458
+ process.exitCode = 1;
9459
+ return;
9460
+ }
9441
9461
  console.log(
9442
- `${chalk93.green(`Pin issued: ${pin}`)}
9462
+ `A confirmation pin was sent to your desktop notifications.
9443
9463
  To insert "// ${validation.text}" at ${file}:${lineNumber}, run:
9444
- ${chalk93.cyan(` assist code-comment confirm ${pin}`)}`
9464
+ ${chalk93.cyan(" assist code-comment confirm <PIN>")}
9465
+ using the pin from that notification.`
9445
9466
  );
9446
9467
  }
9447
9468
 
@@ -19406,7 +19427,7 @@ function registerVoice(program2) {
19406
19427
  }
19407
19428
 
19408
19429
  // src/commands/roam/auth.ts
19409
- import { randomBytes as randomBytes2 } from "crypto";
19430
+ import { randomBytes } from "crypto";
19410
19431
  import chalk178 from "chalk";
19411
19432
 
19412
19433
  // src/commands/roam/waitForCallback.ts
@@ -19536,7 +19557,7 @@ async function auth() {
19536
19557
  const existingRoam = config.roam ?? {};
19537
19558
  config.roam = { ...existingRoam, clientId, clientSecret };
19538
19559
  saveGlobalConfig(config);
19539
- const state = randomBytes2(16).toString("hex");
19560
+ const state = randomBytes(16).toString("hex");
19540
19561
  console.log(
19541
19562
  chalk178.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
19542
19563
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.325.0",
3
+ "version": "0.326.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {