@staff0rd/assist 0.325.1 → 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.
- package/dist/index.js +36 -17
- 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.
|
|
9
|
+
version: "0.326.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -9381,8 +9381,6 @@ function codeCommentConfirm(pin) {
|
|
|
9381
9381
|
}
|
|
9382
9382
|
|
|
9383
9383
|
// src/commands/codeComment/codeCommentSet.ts
|
|
9384
|
-
import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync23 } from "fs";
|
|
9385
|
-
import { randomBytes } from "crypto";
|
|
9386
9384
|
import chalk93 from "chalk";
|
|
9387
9385
|
|
|
9388
9386
|
// src/commands/codeComment/validateCommentText.ts
|
|
@@ -9410,10 +9408,27 @@ function validateCommentText(raw) {
|
|
|
9410
9408
|
return { ok: true, text: text6 };
|
|
9411
9409
|
}
|
|
9412
9410
|
|
|
9413
|
-
// src/commands/codeComment/
|
|
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
|
+
}
|
|
9414
9427
|
function generatePin() {
|
|
9415
|
-
return
|
|
9428
|
+
return randomInt(0, 1e3).toString().padStart(3, "0");
|
|
9416
9429
|
}
|
|
9430
|
+
|
|
9431
|
+
// src/commands/codeComment/codeCommentSet.ts
|
|
9417
9432
|
function codeCommentSet(file, line, text6) {
|
|
9418
9433
|
const lineNumber = Number.parseInt(line, 10);
|
|
9419
9434
|
if (!Number.isInteger(lineNumber) || lineNumber < 1) {
|
|
@@ -9430,20 +9445,24 @@ function codeCommentSet(file, line, text6) {
|
|
|
9430
9445
|
}
|
|
9431
9446
|
console.error(
|
|
9432
9447
|
chalk93.yellow.bold(
|
|
9433
|
-
"
|
|
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."
|
|
9434
9449
|
)
|
|
9435
9450
|
);
|
|
9436
|
-
const
|
|
9437
|
-
|
|
9438
|
-
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
|
|
9442
|
-
|
|
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
|
+
}
|
|
9443
9461
|
console.log(
|
|
9444
|
-
|
|
9462
|
+
`A confirmation pin was sent to your desktop notifications.
|
|
9445
9463
|
To insert "// ${validation.text}" at ${file}:${lineNumber}, run:
|
|
9446
|
-
${chalk93.cyan(
|
|
9464
|
+
${chalk93.cyan(" assist code-comment confirm <PIN>")}
|
|
9465
|
+
using the pin from that notification.`
|
|
9447
9466
|
);
|
|
9448
9467
|
}
|
|
9449
9468
|
|
|
@@ -19408,7 +19427,7 @@ function registerVoice(program2) {
|
|
|
19408
19427
|
}
|
|
19409
19428
|
|
|
19410
19429
|
// src/commands/roam/auth.ts
|
|
19411
|
-
import { randomBytes
|
|
19430
|
+
import { randomBytes } from "crypto";
|
|
19412
19431
|
import chalk178 from "chalk";
|
|
19413
19432
|
|
|
19414
19433
|
// src/commands/roam/waitForCallback.ts
|
|
@@ -19538,7 +19557,7 @@ async function auth() {
|
|
|
19538
19557
|
const existingRoam = config.roam ?? {};
|
|
19539
19558
|
config.roam = { ...existingRoam, clientId, clientSecret };
|
|
19540
19559
|
saveGlobalConfig(config);
|
|
19541
|
-
const state =
|
|
19560
|
+
const state = randomBytes(16).toString("hex");
|
|
19542
19561
|
console.log(
|
|
19543
19562
|
chalk178.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
19544
19563
|
);
|